HackerEarth – Read from STDIN, Write to STDOUT

Let’s start with this basic problem. We will be solving it and providing you with the solution in different programming languages.

Problem Statement:

Read different types of data from standard input, process them as shown in output format, and print the answer to standard output.

Input format:
The first line contains the integer N.
The second line contains the string S.

Output format:
The first line should contain N x 2.
The second line should contain the same string S.


0 <= N <= 10
1 <= S <= 15, where S length of string S


C Programming:

#include <stdio.h>

int main()
	short n;
	char s[10];
	scanf("%d", &n);
	scanf("%s", &s);
	printf("%d\n%s", n*2, s);
	return 0;


n = int(input())
s = input()


Python Oneliner:



#include <iostream>
using namespace std;

int main() {
    int n;
	char s[10];
    cin >> n;
	cin >> s;
	cout << n*2 << "\n" << s;
    return 0;


import java.util.Scanner;

public class CodeWin
    public static void main(String [] args)
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        String s = input.next();
        System.out.println(n*2 + "\n" + s);

All of the above programs are tested on the HackerEarth platform at the time of writing this article. If you want the above solution in any other programming language, please let us know in the comments. We will add the solution to your requested programming language.


Leave a Reply

Your email address will not be published. Required fields are marked *