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<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;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){

	int n;
	cin >> n;
	for(int j = 0; j < n; j++){
        char a[1000] = {0};
        char b[1000] = {0};
        scanf("%s%s",a,b);
        int len_a = 0,len_b = 0;
        //長さを測る
        for(int i = 0; a[i] != 0; i++) len_a++;
        for(int i = 0; b[i] != 0; i++) len_b++;
        //もし80桁を超えてたらoverflowと出力
        if(len_a > 80 || len_b > 80){
            printf("overflow\n");
        }
        //80桁を超えてなかったら
        else{
            char ans[1000] = {0};
            //aを逆向きに入れ替える
            for(int i = 0; i < len_a/2; i++){
                swap(a[i],a[len_a-i-1]);
            }
            //bを逆向きに入れ替ええる
            for(int i = 0; i < len_b/2; i++){
                swap(b[i],b[len_b-i-1]);
            }
            //aとbで長い方の長さをとる
            int len = max(len_a,len_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;
                }
            }
            //このままではansが逆向きなので入れ替える
            for(int i = 0; i < strlen(ans)/2; i++){
                swap(ans[i],ans[strlen(ans)-i-1]);
            }

            int len_ans = 0;
            //ansの長さを測る
            for(int i = 0; ans[i] != 0; i++) len_ans++;
            //もし80桁を超えていたらoverflowと出力する
            if(len_ans > 80) printf("overflow");
            //それ以外なら一文字ずつ出力
            else for(int i = 0; ans[i] != 0; i++) printf("%c",ans[i]);
            printf("\n");
        }
	}

	return 0;
}

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

int main(){

	int n;

	string a, b;
	char N1[80], N2[80];
	char sum[80], temp[81];
	string ans;

	cin >> n;

	for( int i=0;i<n;i++ ){

		cin >> a;
		
		if( a.length() >= 80 ){
			cout << "overflow" << endl;
			continue;
		}

		cin >> b;

		if( b.length() >= 80 ){
			cout << "overflow" << endl;
			continue;
		}

		for( int i=0;i<80;i++ ){
			N1[i] = -1; N2[i] = -1; sum[i] = 0;
		}

		for( int i=1;i<=a.length();i++ )
			N1[i] = a[a.length()-i] - '0';
		for( int i=1;i<=b.length();i++)
			N2[i] = b[b.length()-i] - '0';

		int over = 0;
		
		for( int i=0;i<80;i++ ){


			if( N1[i] == -1 && N2[i] == -1 ){
				if( over >= 10 ){
					sum[i] = over / 10;
					over = 0;
				}else
					sum[i] = -1;
				continue;
			}

			if( N1[i] != -1 )
				sum[i] += N1[i];
			if( N2[i] != -1 )
				sum[i] += N2[i];

			sum[i] += over / 10;

			over = floor((double)sum[i]/10)*10;

			sum[i] -= over;
			
		}

		if(over > 0)cout << "overflow" << endl;
		else{
			int j=0;
			for( int i=1;i<=80;i++ ){
				if( sum[80-i] >= 0 ){
					temp[j] = sum[80-i] + '0';
					j++;
					continue;
				}
				
			}
			temp[j] = '\0';

			ans = temp;

			cout << ans << endl;
		}

	}
	return 0;
}