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<string>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    string a,b,c; char tmp;
    cin >> a >> b;
    if(a.size() > 80 || b.size() > 80){
      cout << "overflow" << endl;
      continue;
    }
    if(a.size() < b.size()){swap(a,b);}
    for(int k = 0;k< a.size();k++)
      c[k] = '0';
     for(int k = 0;k < b.size();k++){
       c[k] = b[b.size()-1-k];
     }
     b.resize(a.size());
     for(int k = 0;k < a.size();k++)
       {b[k] = c[k]; c[k] = a[k];} 
     for(int k = 0;k < a.size();k++){
      	a[a.size()-k-1] = c[k];
     }
	
     tmp = '0';
     for(int k = 0;k < a.size();k++){
       c[k] = a[k] + b[k] + tmp -'0' -'0';
	  if(c[k] > '9'){ tmp = '1'; c[k] = c[k] - ':' + '0'; }
	  else {tmp = '0';}
     }
     if((a.size() <= 80 && tmp == '0') || (a.size() < 80 && tmp == '1') )
       {if(tmp == '1') cout << tmp;
	 for(int k = a.size()-1;k >=0;k--){
	   cout << c[k]; 
	 }
	 cout << endl;
       } else {cout <<"overflow" << endl;}
     
  }
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef vector<int> vi;

int n;
string s1, s2;
char n1[81], n2[81], sum[81];

int main() {
	scanf("%d", &n);
	rep(i,n) {
		memset(n1, 0, sizeof(n1));
		memset(n2, 0, sizeof(n2));
		memset(sum, 0, sizeof(sum));

		cin>>s1>>s2;
		int l1 = s1.size();
		int l2 = s2.size();
		if(max(l1,l2) > 80) {
			printf("overflow\n");
			return 0;
		}

		rep(k,l1) n1[k] = s1[l1-k-1] - '0';
		rep(k,l2) n2[k] = s2[l2-k-1] - '0';

		char a = 0;
		rep(i,80) {
			char c = n1[i] + n2[i] + a;
			a = c / 10;
			sum[i] = c % 10;
		}

		if(sum[80] != 0) {
			printf("overflow\n");
			return 0;
		}

		bool start = false;
		repd(i,80,0) {
			if(sum[i] != 0) start = true;
			if(!start && sum[i] == 0) continue;
			printf("%d", sum[i]);
		}
		printf("\n");
	}
}

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


int main(){
  int n,i,j;
  string a,b;
  int sum[110]={};
  int up = 0;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a >> b;
    int sa=a.size(),sb=b.size();
    int flag=0;
    if(max(sa,sb)>80) flag =1;
    else 
    for(j=0;j<max(sa,sb);j++){
      if(sa>j&&sb>j){
	sum[j] = (a[sa-j-1]-'0') + (b[sb-j-1]-'0') + up;
      }else if(sa>j){
	sum[j] = (a[sa-j-1]-'0') + up;
      }else if(sb>j){
	sum[j] = (b[sb-j-1]-'0') + up;
      }
      up=0;
      if(sum[j]>9){
	up=1;
	sum[j]-=10;
      }
    }
    sum[max(sa,sb)]=up;
    int k=110-1;
    while(sum[k]==0&&k>0) k--;
    if(k>=80||flag==1) cout << "overflow";
    else
    for(j=k;j>=0;j--)
      cout << sum[j];
    cout << endl;
  }
}

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

int main(){
	int x[100];
	int y[100];
	int z[100];
	int n, i, j, hi;
	bool top;
	string a, b;
	
	cin >> n;
	for (i = 0; i < n; i++) {
		// initialize
		for(j=0; j<100; j++){
			x[j] = 0;
			y[j] = 0;
			z[j] = 0;
		}
		cin >> a;
		cin >> b;
		for (j = 0; j < a.length(); j++){
			x[j] = atoi(a.substr(a.length()-1-j, 1).c_str());
		}
		for (j = 0; j < b.length(); j++){
			y[j] = atoi(b.substr(b.length()-1-j, 1).c_str());
		}
		
		hi = 0;
		for(j=0; j<80; j++){
			z[j] = x[j] + y[j] + hi;
			if(z[j] > 9){
				hi = 1;
				z[j] -= 10;
			}else{
				hi = 0;
			}
		}
		if(hi == 1){
			cout << "overflow" << endl;
		}else{
			top = false;
			for (j = 79; j > -1; j--) {
				if(z[j] == 0 && !top){
					continue;
				}else{
					top = true;
					cout << z[j];
				}
			}
			cout << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<string>

using namespace std;

int main(){
	int n,l1,l2,i;
	string a, b;
	char *ans;
	int ia,ib,sum;
	cin>>n;
	while(n--){
		cin>>a>>b;
		if(a.length()>80 || b.length()>80)cout<<"overflor"<<endl;
		if(a.length()<b.length()){
			swap(a,b);
		}
		l1=a.length();
		l2=b.length();
		ans=new char[l1+1];
		for(i=0;i<l1;i++)ans[i]='0';
		for(i=1;i<l2+1;i++){
			ia=(int)a[l1-i]-(int)'0';
			ib=(int)b[l2-i]-(int)'0';
			sum=ia+ib;
			ans[l1-i]+=sum;
		}
		for(i=l2+1;i<l1+1;i++){
			ans[l1-i]=a[l1-i];
		}
		for(i=0;i<l1;i++){
			if(ans[i]-'0'>9){
				ans[i]=ans[i]-10;
				if(i+1>80)cout<<"overflow"<<endl;
				else{
					ans[i-1]+=1;
				}
			}
		}
		for(i=0;i<l1;i++){
			cout<<(int)ans[i]-'0';;
		}
		cout<<endl;
	}
	while(1);
	return 0;
}