{ }codelper
reading numbersaddition64-bit integersP0001

Sum of two numbers

Two integers a and b are given on one line, separated by a space.
Print a + b.

Input
-1,000,000,000,000 ≤ a, b ≤ 1,000,000,000,000
Output
a + b on one line
Example 1 · stdin
3 4
stdout
7
Example 2 · stdin
2000000000 2000000000
stdout
4000000000
main.py
Input (stdin)

When you run, these lines are fed to input()/stdin in order (the program doesn't stop to ask).

$ Ready

Open this on a computer to write and run code. On mobile you can read the problem and the solutions.

In other languagesShow solutions by language · 8 languages

In C, C++, Java and C#, reading into a 32-bit int (about ±2.1 billion) overflows on the second example — use long / long long.
Python has no size limit, and JavaScript, TypeScript and Craykon use a single double-precision number type that is exact up to 2^53 (about 9×10^15), so they work in this range.

Pythonmain.py · 2 lines
a, b = map(int, input().split())print(a + b)
JavaScriptmain.js · 2 lines
const [a, b] = require("fs").readFileSync(0, "utf8").trim().split(/\s+/).map(Number);console.log(a + b);
TypeScriptmain.ts · 3 lines
import { readFileSync } from "node:fs";const [a, b]: number[] = readFileSync(0, "utf8").trim().split(/\s+/).map(Number);console.log(a + b);
JavaMain.java · 9 lines
import java.util.Scanner; public class Main {    public static void main(String[] args) {        Scanner sc = new Scanner(System.in);        long a = sc.nextLong(), b = sc.nextLong();        System.out.println(a + b);    }}
C#Main.cs · 10 lines
using System; class Program{    static void Main()    {        long[] v = Array.ConvertAll(Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries), long.Parse);        Console.WriteLine(v[0] + v[1]);    }}
C++main.cpp · 7 lines
#include <iostream> int main() {    long long a, b;    std::cin >> a >> b;    std::cout << a + b << '\n';}
Cmain.c · 8 lines
#include <stdio.h> int main(void) {    long long a, b;    scanf("%lld %lld", &a, &b);    printf("%lld\n", a + b);    return 0;}
Craykonmain.cray · 2 lines
수들 = Console.ReadNumbers();Console.WriteLine(수들[0] + 수들[1]);