Go: package main

import (
        "fmt"
        "bufio"
        "os"
)

func main() {
        var n int
        var a, b string
        sc := bufio.NewScanner(os.Stdin)
        fmt.Scanf("%d", &n)
        for i := 0; i < n; i++ {
                sc.Scan()
                a = sc.Text()
                sc.Scan()
                b = sc.Text()

                if len(a) > len(b) {
                        s := add(a, b)
                        if s[len(a)] > 0 {
                                if len(a) >= 80 {
                                        fmt.Printf("overflow")
                                } else {
                                        for i := 0; i <= len(a);i++ {
                                                fmt.Printf("%d", s[len(a)-i])
                                        }
                                }
                                fmt.Printf("\n")
                        } else {
                                if len(a)-1 >= 80 {
                                        fmt.Printf("overflow")
                                } else {
                                        for i := 0; i < len(a);i++ {
                                                fmt.Printf("%d", s[len(a)-i-1])
                                        }
                                }
                                fmt.Printf("\n")
                        }
                } else {
                        s := add(b, a)
                        if s[len(b)] > 0 {
                                if len(b) >= 80 {
                                        fmt.Printf("overflow")
                                } else {
                                        for i := 0; i <= len(b);i++ {
                                                fmt.Printf("%d", s[len(b)-i])
                                        }
                                }
                                fmt.Printf("\n")
                        } else {
                                if len(b)-1 >= 80 {
                                        fmt.Printf("overflow")
                                } else {
                                        for i := 0; i < len(b);i++ {
                                                fmt.Printf("%d", s[len(b)-i-1])
                                        }
                                }
                                fmt.Printf("\n")
                        }
                }
        }
}

// expects ln > lm
func add(n string, m string) (s [100]int) {
        ln := len(n)
        lm := len(m)
        var sum [100]int

        for i := 0; i < ln; i++ {
                var s, t int
                s = int(n[ln-1-i]) - int('0')

                if lm - 1 - i >= 0 {
                        t = int(m[lm-1-i]) - int('0')
                } else {
                        t = 0
                }

                sum[i+1] = (s + t + sum[i]) / 10
                sum[i] = (s + t + sum[i]) % 10
        }

        return sum
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <string>
#include <climits>

#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define PRINT(STR) cout << (STR) << endl

typedef long long ll;
using namespace std;

double nextDouble() {
	double d = -1;
	cin >> d;
	return d;
}

int nextInt() {
	int n = -1;
	cin >> n;
	return n;
}

string nextString() {
	string str;
	cin >> str;
	return str;
}

string reverse(string str) {
	string t = str;
	for (int i = 0; i < str.size(); i++) {
		t[i] = str[str.size() - i - 1];
	}
	return t;
}

int main() {
	cin.tie(0); //対話型には使えない
	int n = nextInt();
	while (n--) {
		string str1 = nextString();
		string str2 = nextString();
		int n[100];
		fill(n, n + 100, 0);
		str1 = reverse(str1);
		str2 = reverse(str2);

		REP(i, str1.size()) {
			n[i] = str1[i] - '0';
		}
		REP(i, str2.size()) {
			n[i] += str2[i] - '0';
		}
		if (str1.size() >= 80 || str2.size() >= 80) {
			PRINT("overflow");
			continue;
		}
		int M = max(str1.size(), str2.size());
		int k = M;
		REP(i, M) {
			if (n[i] >= 10) {
				n[i + 1] += n[i] / 10;
				n[i] %= 10;
				if (i == M - 1) k = M + 1;
			}
		}
		if (n[80] > 0) {
			PRINT("overflow");
			continue;
		}
		for (int i = k - 1; i >= 0; i--) {
			cout << n[i];
		}
		cout << endl;
		
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  for(int i=0;i<N;i++){
    string num1,num2;
    cin>>num1>>num2;
    if(num1.size()==num2.size()&&num1.size()>80||num2.size()>80){
      cout<<"overflow"<<endl;
      continue;
    }
    int ma,mi;
    stack<int> sum;
    string lnum,snum;
    if(num1.size()>num2.size()){
      ma=num1.size();lnum=num1;
      mi=num2.size();snum=num2;
    }else{
      ma=num2.size();lnum=num2;
      mi=num1.size();snum=num1;
    }
    int keta=0;
    for(int i=ma-1;i>=0;i--){
      int a,b;
      a=lnum[i]-'0';
      if(mi<=0)
	b=0;
      else{
	b=snum[mi-1]-'0';
	mi--;
      }
      int summ=a+b+keta;
      if(summ>=10){
	sum.push(summ%10);
	keta=1;
      }else if(summ<=9){
	sum.push(summ);
	keta=0;
      }
    }
    if(keta==1)
      sum.push(1);
    if(sum.size()>80)
      cout<<"overflow"<<endl;
    else{
      int k=sum.size();
      for(int i=0;i<k;i++){
	cout<<sum.top();
	sum.pop();
      }
      cout<<endl;
    }
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int max(int a,int b){return a>b?a:b;}
int main(){
	int n;
	cin>>n;
	for(int d=0;d<n;d++){
		string s,t;
		cin>>s;
		cin>>t;
		int i=0;
		reverse(s.begin(),s.end());
		reverse(t.begin(),t.end());
		string ans;
		int k=0;
		for(i=0;i<max(s.size(),t.size())+1;i++){
			int x,y;
			if(i>=s.size())x=0;
			else x=s[i]-'0';
			if(i>=t.size())y=0;
			else y=t[i]-'0';
			int z=x+y+k;
			k=z/10;
			char c=z%10+'0';
			if(i!=max(s.size(),t.size())||c!='0')ans.append(1,c);
		}
		reverse(ans.begin(),ans.end());
		if(ans.size()>=81)cout<<"overflow"<<endl;
		else cout<<ans<<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((int)num1.size() < (int)num2.size()){
      tmp = num2;
      num2 = num1;
      num1 = tmp;
    }

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

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

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

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

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