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++: // AOJ 0015
#include<algorithm>
#include<iostream>
#include<string>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int N;
std::string a, b;

int main()
{
	std::cin >> N;
	while( N-- )
	{
		std::cin >> a >> b;
		int asz = a.size(), bsz = b.size(), sz = std::max( asz, bsz );
		if( asz > 80 || bsz > 80 )
		{
			std::cout << "overflow" << std::endl;
			continue;
		}

		std::reverse( a.begin(), a.end() );
		std::reverse( b.begin(), b.end() );

		
		a.resize( 80 );
		b.resize( 80 );

		std::string ans;
		int c = 0;
		rep( i, sz )
		{
			if( i >= asz )
				a[i] = '0';
			if( i >= bsz )
				b[i] = '0';

			int t = int(a[i])+b[i]+c-2*'0';
			c = 0;
			
			if( t >= 10 )
				c = 1, t %= 10;
			ans += char(t+'0');
		}

		if( c )
			ans += '1';

		if( ans.size() > 80 )
			std::cout << "overflow" << std::endl;
		else
		{
			rep( i, ans.size() )
				std::cout << ans[ans.size()-1-i];
			std::cout << std::endl;
		}
	}

	return 0;
}

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

int main(){
	int n;
	cin >> n;
	while( n-- > 0 ){
		string num1, num2;
		cin >> num1 >> num2;
		char sum[101];
		int degit = 0;
		for( int i = 0; i < sizeof(sum); i++ ) sum[i] = '0';
		for( int i = 0; i < num1.size(); i++ ){
			sum[100-i] = num1[num1.size()-i-1];
		}
		int d;
		for( int i = 0; i < num1.size() || i < num2.size() || degit != 0; i++ ){
			int now;
			if( i < num2.size() ){
				now = (int)(sum[100-i]-'0') + (int)(num2[num2.size()-i-1]-'0') + degit;
			}else{
				now = (int)(sum[100-i]-'0') + degit;
			}
			sum[100-i] = (char)(now%10+'0');
			if( now >= 10 ) degit = 1;
			else degit = 0;
			d = i;
		}
		for( int i = 100-d; i < 101; i++ ) cout << sum[i];
		cout << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cstring>
#include <functional>

using namespace std;

#define REP(i,a,b) for((i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) REP(i,0,n)
// BEGIN CUT HERE
#define foreach(itr,c) for(typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
// END CUT HERE

int main(){
  int i, j, n;
  int len1, len2;
  char tmp;

  scanf("%d",&n);
  rep(i,n){
    string str1, str2, res;
    cin >> str1;
    cin >> str2;

    vector<int> a(100, 0), b(100, 0);
    len1 = (int)str1.size(); len2 = (int)str2.size();
    rep(j,len1) a[j] = str1[(int)len1-1-j] - '0';
    rep(j,len2) b[j] = str2[(int)len2-1-j] - '0';

    rep(j,81){
      int sum = a[j] + b[j];
      if(sum >= 10){ sum %= 10; a[j+1]++;}
      res += (sum + '0');
    }

    reverse(res.begin(), res.end());
    int f = 0;
    rep(j,res.size()){
      if(res[j] != '0') f = 1;
      if(f && res.size()-j > 79){
        cout << "overflow" << endl;
        return 0;
      }
      if(f) cout << res[j];
    }

    cout << endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

int n;
string s, t, ans;

string p(const string &s, const string &t) {
	string res;
	int l1 = s.length()-1, l2 = t.length()-1;
	int L = max(l1, l2);
	int pre = 0;
	for (int i = 0; i <= L; ++i) {
		int sum = pre;
		sum += (l1>=0 ? s[l1--]-'0' : 0);
		sum += (l2>=0 ? t[l2--]-'0' : 0);
		pre = sum/10;	// 繰り上げ分
		sum -= pre*10;
		res += '0' + sum;
	}
	if (pre) res += '0' + pre;
	reverse(res.begin(), res.end());
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	cin >> n;
	rep(T,n) {
		cin >> s >> t;
		ans = p(s, t);
		if (ans.length() > 80) cout << "overflow" << endl;
		else cout << ans << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define ALL(v) v.begin(),v.end()
string calc(string a,string b){
  reverse(ALL(a));
  reverse(ALL(b));
  while(a.size() < b.size())a += '0';
  while(b.size() < a.size())b += '0';
  int c=0;
  string res;
  for(int i=0;i<a.size();i++){
    c = c+a[i]-'0'+b[i]-'0';
    res += c%10+'0';
    c /= 10;
  }
  if(c)res += c+'0';
  if(res.size() > 80)return "overflow";
  reverse(ALL(res));
  return res;
}
int main(){
  int n;
  string a,b;
  cin>>n;
  while(n--){
    cin>>a>>b;
    cout<<calc(a,b)<<endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  int N;
  
  cin >> N;

  for (int N_i = 0; N_i < N; N_i++) {
    bool overflow = false;
    string str_data1, str_data2;
    cin >> str_data1;
    cin >> str_data2;

    stack<int> data1, data2; 
    for (int data1_i = 0; data1_i < str_data1.size(); data1_i++) {
      char buff[2];
      buff[0] = str_data1[data1_i];
      buff[1] = '\0';
      data1.push(atoi(buff));
    }
    if (data1.size() >= 80)
      overflow = true;
    for (int data2_i = 0; data2_i < str_data2.size(); data2_i++) {
      char buff[2];
      buff[0] = str_data2[data2_i];
      buff[1] = '\0';
      data2.push(atoi(buff));
    }
    if (data2.size() >= 80)
      overflow = true;

    stack<int> sum;
    int carry = 0;
    int flag = data1.size() < data2.size() ? 0 : 1;
    while(flag == 0 ? !data1.empty() : !data2.empty()) {
      int presum = data1.top() + data2.top() + carry;
      carry = presum / 10;
      sum.push(presum % 10);
      data1.pop();
      data2.pop();
    }
    stack<int> *data;
    data = data1.size() > data2.size() ? &data1: &data2;
    while(!data->empty()) {
      int presum = data->top() + carry;
      carry = presum / 10;
      sum.push(presum % 10);
      data->pop();
    }

    if (carry != 0)
      sum.push(carry);

    if (sum.size() >= 80)
      overflow = true;

    if (overflow) {
      cout << overflow << endl;
    } else {
      for (int sum_i = 0; !sum.empty(); sum_i++) {
        cout << sum.top();
        sum.pop();
      }
      cout << endl;
    }
  }

  return 0;
}