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 <algorithm>
#include <string.h>

using namespace std;

int main(void){
	int n;

	cin >> n;
	for(int i=0;i<n;i++){
		int len,mlen=0;
		char val[2][81]={0},tmp[81],crr=0;

		for(int j=0;j<2;j++){
			cin >> tmp;
			len=strlen(tmp);
			mlen=max(mlen,len);
			for(int k=0;k<len;k++)
				val[j][len-1-k]=tmp[k]-0x30;
		}

		for(int j=0;j<mlen;j++){
			val[0][j]+=val[1][j]+crr;
			crr=val[0][j]/10;
			val[0][j]%=10;

			if(j==mlen-1&&crr)
				mlen++;
		}

		if(mlen<=80){
			for(int j=0;j<mlen;j++)
				tmp[j]=val[0][mlen-1-j]+0x30;
			tmp[mlen]='\0';
		}
		else
			strcpy(tmp,"overflow");

		cout << tmp << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    REP(num, N)
    {
        string s1, s2, ans = "";
        cin >> s1 >> s2;

        int len1 = s1.size() - 1;
        int len2 = s2.size() - 1;
        int next = 0;

        int mlen = max(s1.size(), s2.size());

        REP(i, mlen)
        {
            int sum = 0;

            if (0 <= len1)
                sum += s1[len1--] - '0';

            if (0 <= len2)
                sum += s2[len2--] - '0';

            ans = (char)((sum + next) % 10 + '0') + ans;

            if (10 <= sum + next)
                next = 1;
            else
                next = 0;
        }

        if (ans.size() + next <= 80)
            cout << (next == 1 ? "1" : "") << ans << endl;
        else
            cout << "overflow" << endl;
    }

    return 0;
}

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

using namespace std;

int string_to_d(const string &s){
	int num = 0;
	if(!s.empty())
	for(int i=s.size()-1;i>=0;--i){
		if('1'<=s[i]&&s[i]<='9') num += (s[i]-'0')*pow(10,s.size()-i-1);
	}
	return num;
}

int main(void){
	int n;
	while(cin >> n){
		for(int a=0;a<n;++a){
			string s1,s2;
			cin >> s1 >> s2;
			int ex1num[10];//8*10=80桁
			int ex2num[10];
			int sum[10] = {0};
			for(int i=s1.size();i<80;++i) s1="0"+s1;
			for(int i=s2.size();i<80;++i) s2="0"+s2;
			for(int i=0;i<10;++i){
				ex1num[i] = string_to_d(s1.substr((10-i-1)*8,8));
				ex2num[i] = string_to_d(s2.substr((10-i-1)*8,8));
			}
			//ここまで正常
			int carry = 0;
			for(int i=0;i<10;++i){
				sum[i] = (ex1num[i]+ex2num[i]+carry)%(int)1e+008;
				carry = floor((ex1num[i]+ex2num[i]+carry)/(int)1e+008);
			}
			if(carry>0){
				cout << "overflow\n";
				continue;
			}
			bool zeroshow = false;
			for(int i=10;0<=i;--i){
				if(zeroshow&&sum[i]!=0) for(int j=0;j<7-(int)log10(sum[i]);j++) cout << "0";
				if(zeroshow&&sum[i]==0) for(int j=0;j<8;j++) cout << "0";
				if(sum[i]!=0) cout << sum[i];
				if(sum[i]>0) zeroshow = true;
			}
			cout << "\n";
		}
	}
	return 0;
}

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

int main(){
  int n;
  string s1,s2,ans;
  cin >> n;
  
  for(int i=0; i<n; i++){
    cin >> s1; 
    cin >> s2;
    ans = "";
    int m = max(s1.size(),s2.size());
    while(m>s1.size()) s1 = '0' + s1;
    while(m>s2.size()) s2 = '0' + s2;

    int carry = 0;
    for(int j=m-1; j>=0; j--){
      char ch = ((s1[j]-'0') + (s2[j]-'0') + carry)%10 + '0';
      carry = ((s1[j]-'0') + (s2[j]-'0') + carry)/10;
      ans += ch; //反転してしまうが…
    }
    if(carry) ans += (carry+'0');
    reverse(ans.begin(),ans.end()); //元通り

    //頭の0を削除していく
    while(ans.size()>1 && ans[0] == '0') ans.erase(ans.begin());
    if(ans.size() > 80) cout << "overflow" << endl;
    else cout << ans << endl;
  }
  return 0;
}

C++: //AOJ 0015

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		string s1, s2;
		cin >> s1;
		cin >> s2;
		reverse(s1.begin(), s1.end());
		reverse(s2.begin(), s2.end());
		
		int max;
		int diff;
		if(s1.size() > s2.size()) {
			max = s1.size();
			diff = s1.size() - s2.size();
			for(int i = 0; i < diff; i++)
				s2 += "0";
		}
		else {
			max = s2.size();
			diff = s2.size() - s1.size();
			for(int i = 0; i < diff; i++) {
				s1 += "0";	
			}
		} 
		//cout << s1 << endl;
		//cout << s2 << endl;
		string s;
		int kuriagari = 0;
		for(int i = 0; i < max; i++) {
			int flag = true;
			if((s1[i]-'0')+(s2[i]-'0') + kuriagari >= 10) flag = false;
			s += ((s1[i]-'0')+(s2[i]-'0')+kuriagari) % 10 + '0';
			if(flag == true) kuriagari = 0;
			else kuriagari = 1;
		}
		if(kuriagari == 1) s += "1";
		reverse(s.begin(), s.end());
		if(s.size() > 80) cout << "overflow" << endl;
		else {
			cout << s << endl;
		}
	} 
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {

  int n;

  char buf[1000];
  char outbuf[1000];

  char c;

  int a[1000],b[1000];
  int result[1000];
  
  int sum,carry;
  int idx1,idx2;
  int maxlen;

  int i,j;

  scanf("%d",&n);

  c=getchar();

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

    fgets(buf,sizeof(buf),stdin);

    idx1=0;

    while(buf[idx1]!='\n') {

      a[idx1]=buf[idx1]-48;

      idx1++;

    }

    //for(j=0;j<idx1;j++) printf("%d",a[j]);

    fgets(buf,sizeof(buf),stdin);

    idx2=0;

    while(buf[idx2]!='\n') {

      b[idx2]=buf[idx2]-48;

      idx2++;

    }

    if(idx1>idx2) maxlen=idx1;
    
    else maxlen=idx2;

    carry=0;

    for(j=0;j<maxlen;j++) {

      if(j<idx1 && j<idx2) sum=a[idx1-j-1]+b[idx2-j-1]+carry;

      else if(j>=idx1) sum=b[idx2-j-1]+carry;

      else sum=a[idx1-j-1]+carry;


      if(sum>=10) carry=1;

      else carry=0;

      result[j]=sum%10;

    }
    //printf("%d\n",carry);
    if(carry==1) {

      if(maxlen>=80) printf("overflow\n");

      else {

	outbuf[0]='1';

	for(j=0;j<maxlen;j++) {

	  outbuf[j+1]=result[maxlen-j-1]+48;

	}

	outbuf[maxlen+1]='\0';

	printf("%s",outbuf);

	puts("");

      }

    }

    else {

      for(j=0;j<maxlen;j++) {

	outbuf[j]=result[maxlen-j-1]+48;

      }

      outbuf[maxlen]='\0';

      printf("%s",outbuf);

      puts("");

    }

  }

  return 0;

}