Go: package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func main() {
	scanner.Split(bufio.ScanWords)

	const maxCapacity = 512 * 1024
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)

	n := nextInt()
	maxint, _ := new(big.Int).SetString("100000000000000000000000000000000000000000000000000000000000000000000000000000000", 10)

	for i := 0; i < n; i++ {
		aStr := nextString()
		bStr := nextString()

		a, _ := new(big.Int).SetString(aStr, 10)
		b, _ := new(big.Int).SetString(bStr, 10)
		c := big.NewInt(0).Add(a, b)

		if c.Cmp(maxint) < 0 {
			fmt.Println(c)
		} else {
			fmt.Println("overflow")
		}
	}
}

C++: /*
	0015:National Budget
*/
#include	<iostream>
#include	<string>
#include	<iterator>

using namespace std;

int main(void) {
	int n;
	
	cin >> n;
	for(int i = 0; i < n; i++) {
		string num1, num2, result;
		bool isMoveUp = false;
		
		cin >> num1 >> num2;
		string::reverse_iterator st1 = num1.rbegin();
		string::reverse_iterator st2 = num2.rbegin();
		while( st1 != num1.rend() || st2 != num2.rend()) {
			char buf1 = st1 != num1.rend() ? (*st1) : '0';
			char buf2 = st2 != num2.rend() ? (*st2) : '0';
			int buf3 = (buf1 - '0') + (buf2 - '0');
			
			isMoveUp = false;
			if(buf3 >= 10) {
				isMoveUp = true;
				(*(st1+1))++; buf3 -= 10;
			}
			result += (buf3 + '0');
			if(st1 != num1.rend()) { st1++; }
			if(st2 != num2.rend()) { st2++; }
		}
		if(isMoveUp) { result += '1'; }
		if(result.size() > 80) { cout << "overflow" << endl; continue; }
		string::reverse_iterator rt = result.rbegin();
		while(rt != result.rend()) {
			cout << (*rt);
			rt++;
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include <algorithm>
#include<string.h>
#include <utility>
using namespace std;
int main(){
	int m;
	string in1,in2;
	int a[1000],b[1000],ans[1000];
	int f;
	int alen,blen,mlen;
	cin>>m;
	while(m--){
		for(int i=0;i<90;i++){
			a[i]=b[i]=ans[i]=0;
		}
		in1="";
		in2="";
		cin>>in1;
		cin>>in2;
		alen=in1.size();
		blen=in2.size();
		for(int i=0;i<alen;i++){
			a[alen-1-i]=in1[i]-'0';
			cout<<a[alen-1-i]<<endl;
		}cout<<endl;
		for(int i=0;i<blen;i++){
			b[blen-1-i]=in2[i]-'0';
			cout<<b[blen-1-i]<<endl;
		}
		mlen=max(alen,blen);
		if(mlen>79){
			cout<<"overflow"<<endl;
			continue;
		}
		f=0;
		for(int i=0;i<mlen+1;i++){
			ans[i]=(a[i]+b[i]+f)%10;
			f=(a[i]+b[i]+f)/10;
			cout<<ans[i]<<endl;
		}
		if(ans[mlen]!=0){
			if(mlen>78){
				cout<<"overflow"<<endl;
				continue;
			}
			cout<<ans[mlen];
		}
		
		for(int i=0;i<mlen;i++){
			cout<<ans[mlen-1-i];
		}cout<<endl;
		
		
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main ()
{
    int n;
    cin>>n;
    getchar();
    while (n--)
    {
        string ara="",ara2="",res="";
        getline(cin,ara);
        getline(cin,ara2);

        if (ara.length()>ara2.length())
            swap(ara,ara2);

        int l1,l2;
        l1=ara.length();
        l2=ara2.length();

        reverse(ara.begin(),ara.end());
        reverse(ara2.begin(),ara2.end());

        int i,sum,carry=0;
        for (i=0;i<l1;i++)
        {
            sum=((ara[i]-'0')+(ara2[i]-'0')+carry);
            res.push_back((sum%10)+'0');
            carry=sum/10;
        }
        for (i=l1;i<l2;i++)
        {
            sum=(ara2[i]-'0')+carry;
            res.push_back((sum%10)+'0');
            carry=sum/10;
        }
        if (carry!=0)
            res.push_back(carry+'0');
        reverse (res.begin(),res.end());
        if (res.length()<=80)
            cout<<res;
        else
            cout<<"overflow";
        cout<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;

int main(){
    int n,x=0,i;
    cin>>n;
    while(n--){
        string a,b,c="";
        cin>>a>>b;
        if(a.length()>b.length())swap(a,b);
        b='0'+b;
        while(a.length()<b.length())
            a='0'+a;
        char m;
        for(i=a.length()-1;i>0;i--){
            m=('0'+(a[i]-'0'+b[i]-'0'+x)%10);
            x=(a[i]-'0'+b[i]-'0'+x)/10;
            c=m+c;
        }
        if(x>0){
            m=('0'+x);
            c=m+c;
        }
        cout<<c<<endl;
    }
}

C++: #include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){
	char a[800],b[800],wa[801],count;
	int N,i,ea,eb,c;
	
	scanf("%d",&N);
	while(N--){
		scanf(" %s ",a);
		scanf(" %s ",b);
		
		for(i=0;i<800;i++){
			if(a[i]=='\0')break;
		}
		ea=i;
		for(i=0;i<800;i++){
			if(b[i]=='\0')break;
		}
		eb=i;
		c=(ea<eb ? eb:ea);
		memset(wa,'0',sizeof(wa));
		wa[c+1]='\0';
		count=0;
		if(ea>eb){
			for(i=ea-1;i>=ea-eb;i--){
				wa[i+1]=a[i]-'0'+b[i-ea+eb]+count;
				count=0;
				if(wa[i+1]>=58){
					wa[i+1]=wa[i+1] - 10;
					count=1;
				}

			}
			
			for(i=ea-eb-1;i>=0;i--){
				wa[i+1]=a[i]+count;
				count=0;
				if(wa[i+1]>'9'){
					wa[i+1]=wa[i+1]-10;
					count=1;
				}
			}
		}else{
			for(i=eb-1;i>=eb-ea;i--){
				wa[i+1]=b[i]+a[i-eb+ea]+count-'0';
				count=0;
				if(wa[i+1]>=58){
					wa[i+1]=wa[i+1]-10;
					count=1;
				}

			}
			for(i=eb-ea-1;i>=0;i--){
				wa[i+1]=b[i]+count;
				count=0;
				if(wa[i+1]>'9'){
					wa[i+1]=wa[i+1]-10;
					count=1;
				}
			}
		}
		wa[0]=count+'0';
		if(wa[0]=='0'){
			for(i=0;i<=c;i++){
				wa[i]=wa[i+1];
			}
			c=c-1;
		}
		if(c>79){
			printf("overflow\n");
		}else{
			printf("%s\n",wa);
		}
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <cmath>
using namespace std;

int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		int p1[100],p2[100];
		for(int i=0;i<100;i++){
			p1[i] = 0; p2[i] = 0;
		}
		string a,b;
		cin >> a ;
		cin >> b ;
		if(a.size() > 80 || b.size() > 80){
			cout << "overflow" << endl;
			continue;
		}

		int pos = 0;
		for(unsigned i=a.size();i>0;i--){
			stringstream sst;
			sst << a[i-1];
			sst >> p1[pos++];
		}
		pos = 0;
		for(unsigned i=b.size();i>0;i--){
			stringstream sst;
			sst << b[i-1];
			sst >> p2[pos++];
		}
		for(int i=0;i<100;i++){
			int ans = p1[i]+p2[i];
			p1[i] = ans % 10;
			p1[i+1] += ans/10;
		}
		bool flag = true;
		for(int i=99;i>=0;i--){
			if(flag){
				if(i != 0 && p1[i] == 0)
					continue;
				else{
					if(i > 79){
						cout << "overflow" ;
						break;
					}
					flag = false;
				}
			}
			cout << p1[i];
		}
		cout << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <string>
#include <stack>

using namespace std;

int main(void){
	int n = 0;
	char i1[100], i2[100], o[100];
	string si1, si2;
	int l1, l2;
	int t=0, c=0;
	stack<char> sum;

	scanf("%d", &n);
	for(int i=0; i<n; ++i){
		scanf("%s", i1);
		scanf("%s", i2);
		si1 = string(i1);
		si2 = string(i2);
		l1 = si1.size();
		l2 = si2.size();

		if(l1 > 80 || l2 > 80){
			puts("overflow");
			continue;
		}

		--l1;
		--l2;
		c = 0;
		sum = stack<char>();
		while(l1 >= 0 || l2 >= 0){
			t = c;
			if(l1 >= 0){ t += (si1[l1] - '0'); }
			if(l2 >= 0){ t += (si2[l2] - '0'); }
			c = t / 10;
			t -= c * 10;
			sum.push((char)(t + '0'));
			--l1;
			--l2;
		}
		if(c == 1){ sum.push((char)(c + '0')); }
		if(sum.size() > 80){
			puts("overflow");
			continue;
		}
		while(!sum.empty()){
			printf("%c", sum.top());
			sum.pop();
		}
		printf("\n");
	}
	return 0;
}

C++: def first_digit(n)
  n[0]
end

def digit(n)
  n.size
end

def overflow?(a, b)
  if digit(a) > 80 || digit(b) > 80
    puts 'overflow'
    return true
  end

  if digit(a) == 80 && digit(b) == 80
    if [a, b].map { |e| first_digit(e).to_i }.inject(:+) >= 10
      puts 'overflow'
      return true
    end
  end

  false
end

input = STDIN.read.split("\n").map(&:chomp)
input.shift.to_i.times do
  a = input.shift
  b = input.shift
  next if overflow?(a, b)
  puts [a, b].map(&:to_i).inject(:+)
end