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<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){

	int n;
	cin >> n;
	while(n > 0){
        char a[120] = {0};
        char b[120] = {0};
        scanf("%s%s",a,b);
        char ans[120] = {0};
        for(int i = 0; i < strlen(a)/2; i++){
            swap(a[i],a[strlen(a)-i-1]);
        }
        for(int i = 0; i < strlen(b)/2; i++){
            swap(b[i],b[strlen(b)-i-1]);
        }
        int len = max(strlen(a),strlen(b));
        for(int i = 0; i < len; i++){
            if(ans[i] != 0){
                if(a[i] == 0 || b[i] == 0)
                    ans[i] += a[i] + b[i] - '0';
                else ans[i] += a[i] + b[i] - '0' - '0';

            }
            else if(a[i] == 0 || b[i] == 0) ans[i] += a[i] + b[i];
            else ans[i] += a[i] + b[i] - '0';
            if(ans[i] >= 58){
                ans[i+1]+='1';
                ans[i] -= 10;
            }
        }
        for(int i = 0; i < strlen(ans)/2; i++){
            swap(ans[i],ans[strlen(ans)-i-1]);
        }
        int Len_a = 0,Len_b = 0,Len_ans = 0;
        for(int i = 0; a[i] != 0; i++) Len_a++;
        for(int i = 0; b[i] != 0; i++) Len_b++;
        for(int i = 0; ans[i] != 0; i++) Len_ans++;
        if(Len_a > 80 || Len_b > 80 || Len_ans > 80) printf("overflow");
        else for(int i = 0; ans[i] != 0; i++) printf("%c",ans[i]);
        printf("\n");
        n--;
	}

	return 0;
}

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

using namespace std;

int main() {
	int n;
	cin>>n;
	
	string str1, str2, of="overflow";
	for(int i=0; i<n; i++){
		cin>>str1>>str2;
		int size1=str1.size();
		int size2=str2.size();

		if(size1 > 80 || size2 > 80){
			cout<<of<<endl;
		}
		else{
			int num1[80] = {0}, num2[80] = {0}, buf[81] = {0};

			for(int i=0; i<size1; i++){ num1[size1-1-i] = (str1[i]-'0'); }
			for(int i=0; i<size2; i++){ num2[size2-1-i] = (str2[i]-'0'); }
			for(int i=0; i<80; i++){ buf[i] = num1[i]+num2[i]; }
			for(int i=0; i<80; i++){
				if(buf[i] > 9){
					buf[i+1] += buf[i]/10;
					buf[i] = buf[i]%10;
				}
			}
			if(buf[80] != 0) cout<<of<<endl;
			else{
				int flag = 79;
				while(buf[flag] == 0 && flag != 0){ flag--; }

				for(int i=flag; i>=0; i--){
					cout<<buf[i];
				}
				cout<<endl;
			}

		}
	}
	return 0;
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
int main(){

    int n;
    cin>>n;
    rep(i,n){
        string a,b;
        cin>>a>>b;
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        if(b.size()>a.size()){
            swap(a,b);
        }
        int keta=b.size();
        int ans[100];
        rep(i,n)ans[i]=0;
        int kuri=0;
        for(int i=0;i<b.size();i++){
           // char o=a[i];char oo=b[i];
           // int aa=atoi(&o);int bb=atoi(&oo);
            int aa=a[i]-'0';int bb=b[i]-'0';
            ans[i]=(aa+bb+kuri)%10;
           // cout<<a[i]<<b[i]<<endl;
            cout<<aa<<bb<<endl;
            kuri=(aa+bb+kuri)/10;
        }
        for(int i=b.size();i<=100&&i<a.size();i++){
            keta++;
            //char oo=a[i];
            int aa=a[i]-'0';
            ans[i]=kuri+aa;
            kuri=0;
        }
        if(keta>=80){
            cout<<"overflow"<<endl;
        }else{
            for(int i=keta-1;i>=0;i--){
                cout<<ans[i];
            }
            cout<<endl;
        }
    }
    
    return 0;
}

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

int main(){
	string sx, sy, sans;
	int n;
	getline( cin, sx );
	sscanf( sx.c_str(), "%d", &n );
	for( int i=0; i<n; i++ ){
		getline( cin, sx );
		getline( cin, sy );
		if( sx.length()>80 || sy.length()>80 ){
			cout << "overflow" << endl;
		}else{
			string &s = (sx.length()>sy.length())?sx:sy;
			string &sa = (sx.length()>sy.length())?sy:sx;
			sans.resize( s.length()+1 );
			for( int j=0; j<sans.length(); j++ )
				sans[j] = 0;
			for( int j=0; j<sa.length(); j++ ){
				sans[j] += (sa[sa.length()-1-j]-'0') + (s[s.length()-1-j]-'0');
				if( sans[j] > 9 ){
					sans[j] -= 10;
					sans[j+1]++;
				}
			}
			for( int j=sa.length(); j<s.length(); j++ ){
				sans[j] += s[s.length()-1-j]-'0';
				if( sans[j] > 9 ){
					sans[j] -= 10;
					sans[j+1]++;
				}
			}
		}
		if( sans.length()>80 && sans[sans.length()-1]>0 ){
			cout << "overflow" << endl;
		}else{
			for( int j=(sans[sans.length()-1]==0?sans.length()-2:sans.length()-1); j>=0; j-- ){
				cout << (int)sans[j];
			}
			cout << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include <algorithm>
#include <utility>
using namespace std;
using namespace std;
int main(){
	
	int m;
	char in[2][10000];
	char ans[100000];
	int ie[2];
	int ien[2];
	bool max10;
	int Min;
	bool NMin;
	scanf("%d",&m);
	for(;m--;){
		
		for(int i=0;i<2;i++){
			scanf(" %s",&in[i]);
		}
		for(int i=0;i<2;i++){
			for(ie[i]=0;in[i][ie[i]]!='\0';ie[i]++){
				in[i][ie[i]]=in[i][ie[i]]-'0';
			}
		}
		ie[0]--;
		ie[1]--;
		Min=max(ie[0],ie[1]);
		if((Min>79)||((Min>78)&&(ie[0]==ie[1])&&((int(in[0][0])+int(in[1][0]))>9))){
			cout<<"overflow"<<endl;
		}else{	
			if(ie[0]>ie[1]){
				NMin=0;
			}else{
				NMin=1;
			}
			ien[0]=ie[0];
			ien[1]=ie[1];
			for(;min(ien[0],ien[1])+1;ien[0]--,ien[1]--){
				in[NMin][ien[NMin]]=in[0][ien[0]]+in[1][ien[1]];
				if(in[NMin][ien[NMin]+1]>9){
					in[NMin][ien[NMin]+1]-=10;
					in[NMin][ien[NMin]]  +=1;
				}
				
			}
			max10=0;
			if(in[NMin][ien[NMin]+1]>9){
				in[NMin][ien[NMin]+1]-=10;
				max10=1;
			}
			for(int i=0;i<2;i++){
				for(int j=0;j<ie[i]+1;j++){
					in[i][j]=in[i][j]+'0';
				}
			}
			if(max10) cout<<"1";
			cout<<in[NMin]<<endl;
		}
	}
	return 0;
}