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++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(void){
  int N;
  string str1, str2;
  cin >> N;
  for(int k = 0; k < N; k++){
    vector<int> ans;
    cin >> str1 >> str2; 
    if(str1.size() > 80 || str2.size() > 80){
      cout << "overflow" << endl;
      continue;
    }

    int carry, sum;
    string *bigger;

    if(str1.size() > str2.size()){
      bigger = &str1;
    }else{
      bigger = &str2;
    }

    vector<int>::iterator ite = ans.begin();
    pair<int, int> P;
    P.first = min(str1.size(), str2.size());
    P.second = max(str1.size(), str2.size());

    for(int i = 0; i < P.first; i++){
      sum = (str2[str2.size() - 1 - i] - 48) + (str1[str1.size() - 1 - i] - 48) + carry;
      if((sum / 10) >= 0){
        carry = sum / 10;
        sum -= (sum / 10) * 10;
      }else{
        carry = 0;
      }
      ans.insert(ans.begin(), sum);
    }
    
    for(int i = P.first; i < P.second; i++){
      sum = (bigger->at(bigger->size() - 1 - i) - 48) + carry;
      if((sum / 10) >= 0){
        carry = sum / 10;
        sum -= (sum / 10) * 10;
      }else{
        carry = 0;
      }
      ans.insert(ans.begin(), sum);
    }

    for(int i = 0; i < ans.size(); i++){
      if(carry != 0){
        cout << carry;
        carry = 0;
      }
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;
void add(string& ans,string& a,string& b);
int main() {
	string a,b;
	int al,bl;
	int n;
	cin>>n;
	while(n--){
	        string ans= "";
		cin>>a>>b;
		reverse(a.begin(),a.end());
		reverse(b.begin(),b.end());
		al=a.size();
		bl=b.size();
		if(bl>al){
			swap(a,b);
			swap(al,bl);
		}
		for(int i=0;i<(al-bl);i++){
			b+='0';
		}
		add(ans,a,b);
		if(ans.size()>80) ans="overflow";
		else{
		  reverse(ans.begin(),ans.end());
		}
	  	cout<<ans<<endl;
	}
	return 0;
}
void add(string& ans,string& a,string& b){
	int x,y=0;
	for(int i= 0;i<a.size();i++){
		x=a[i]-'0'+b[i]-'0';
		if(x>=10){
			ans+= (x%10)+'0';
			y=1;
		}else{
			ans+= x+y+'0';
			y=0;
		}
	}
	if(y==1)ans+='1';
}

C++: import java.util.Scanner;
import java.math.BigInteger;

public class a0015{
    public static void main(String args[]) {
	Scanner scanner = new Scanner(System.in);
	int N = scanner.nextInt();
	for (int i = 0; i < N; i++) {
	    String a = scanner.next(), b = scanner.next();
	    BigInteger A = new BigInteger(a), B = new BigInteger(b);
	    BigInteger sum = A.add(B);
	    if ((sum.toString()).length() > 80) {
		System.out.println("overflow");
	    }
	    else {
		System.out.println(sum.toString());
	    }
	}
    }
}

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

int main () {
    int n;
    string a, b;
    
    cin >> n;
    for(int i=0;i<n;i++){
        int x[81]={0}, y[81]={0}, z[81]={0};
        
        cin >> a;
        cin >> b;
        
        reverse(a.begin(), a.end());
        reverse(b.begin(), b.end());
        
        for(int j=0;j<a.size();j++){
            x[j]=a[j]-'0';
        }
        for(int j=0;j<b.size();j++){
            y[j]=b[j]-'0';
        }
        int c=0;
        int r;
        for(int j=0;j<80;j++){
            r=x[j]+y[j]+c;
            if (r >= 10){
                z[j]=r%10;
                c=1;
            }else{
                z[j]=r;
                c=0;
            }
        }
        
//        if(z[80]==1){
//            cout << "overflow" <<endl;
//        }else{
        int j;
        for(j=79;j>=0;j--){
                if(z[j]==0){
                    continue;
                }else{
                    break;
                }
        }
        for(int k=j;k>=0;k--){
                cout<<z[k];
            }
            if(j==-1){
                cout<<0;
            }
            cout<<endl;
            
//        }
    }
    return 0;
}

C++: #include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
string str_plus(string s,string t){
    if(s == "0"&&t == "0")return "0";
    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());
    string u = "0",v;
    int n1 = s.size(),n2 = t.size();
    int k = max(n1,n2);
    while(s.size()!=k)s+='0';
    while(t.size()!=k)t+='0';
    for(int i = 0;i < k ;i++){
        u[i] += s[i] - '0' + t[i] - '0';
        if(u[i]>='9')u+="1",u[i]-=10;
        else u+="0";
    }
    reverse(u.begin(),u.end());
    bool flg = true;
    if(u == "0")return u;
    for(int i = 0;i < u.size();i++){
        if(u[i]=='0'&flg)continue;
        v+=u[i];
        flg = false;
    }

    return v;
}
int main(void){

    int n;
    cin>>n;
    while(n--){
        string s,t;
        cin>>s>>t;
        string u = str_plus(s,t);
        if(u.length()>=80)cout<<"overflow"<<endl;
        else cout<<u<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(){
  string num1,num2,tmp;
  int n;

  cin >> n;

  while(n--){

    cin >> num1 >> num2;

    if(num1.size() < num2.size()){
      tmp = num2;
      num2 = num1;
      num1 = tmp;
    }

    for(int i = 0 ; i < num1.size() ; i++ )tmp[i] = num1[i];

    for(int i = num1.size() - 1 ; i >= 0 ; i-- )
      {
	num1[i] = tmp[num1.size() - 1 - i];
      }
    for(int i = 0 ; i < num2.size() ; i++ )tmp[i] = num2[i];

    for(int i = num2.size() - 1  ; i >= 0 ; i-- )
      {
	num2[i] = tmp[num2.size() - 1 - i];
      }

    for(int i = num2.size() ; i < num1.size() ; i++ )num2+='0';

    char tmp2 = '0';
    string ans;

    for(int i = 0 ; i < num1.size() ; i++ ){
      if((tmp2 - '0') + (num1[i] - '0') + (num2[i] - '0') > 9){
	ans += (((tmp2 - '0') + (num1[i] - '0') + (num2[i] - '0') - 10) + '0');
	tmp2 = '1';
      } else {
	ans += (((tmp2 - '0') + (num1[i] - '0') + (num2[i] - '0')) + '0');
	tmp2 = '0'; 
      }
    }
  
    if((tmp2 - '0') + (num1[num1.size() - 1] - '0') + (num2[num1.size() - 1] - '0') > 9)ans+='1'; 

    for(int i = ans.size() ; i >= 0 ; i-- ){
      cout << ans[i];
    }  
    cout << endl;
  }
  return 0;

}

C++: #include <iostream>
#include <string>
using namespace std;
int toNumber(char c){
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	}
	return 0;
}
int main()
{
	int n, sa, sb, k, r, i;
	string a, b;
	char sum[81] = {};
	cin >> n;
	while (n--){
		cin >> a >> b;
		if (a.size() < b.size()) swap(a, b);
		sa = a.size();
		sb = b.size();
		k = i = 0;
		for (; i < sa; ++i){
			if (i < sb) k = toNumber(a[sa - 1 - i]) + toNumber(b[sb - 1 - i]) + k;
			else 		k = toNumber(a[sa - 1 - i]) + k;
			r = k % 10;
			k = k / 10;
			sum[i] = (char)r;
		}
		if (0 != k) sum[i] = (char)k;
		else --i;
		for (int d = i; d >= 0; --d)
			cout << (int)sum[d];
		cout << "\n";
	}
	return 0;
}