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 <string>
#include <algorithm>
using namespace std;

int a[101] {0};
int b[101] {0};
int sum[55][101] {0};

int trans(char);

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

    for (int i = 0; i < n; i++)
    {
        string s1, s2;
        cin >> s1 >> s2;
        int l1 = s1.length(), l2 = s2.length();
        for (int j = l1 - 1; j >= 0; j--)
        {
            a[l1-1-j] = trans(s1[j]);
        }
        for (int j = l2 - 1; j >= 0; j--)
        {
            b[l2-1-j] = trans(s2[j]);
        }

        int ll = max(l1, l2);
        for (int j = 0; j < ll; j++)
            sum[i][j] = a[j] + b[j];

        for (int j = 0; j < ll; j++)
        {
            sum[i][j+1] += sum[i][j] / 10;
            sum[i][j] %= 10;
        }


        for (int j = 0; j < 101; j++)
        {
            a[j] = 0;
            b[j] = 0;
        }

    }

    for (int i = 0; i < n; i++)
    {
        bool over = false;
        for (int j = 100; j >= 80; j--)
        {
            if (sum[i][j]>0)
            {
                over = true;
                break;
            }
        }

        if (over)
        {
            cout << "overflow" << endl;
            continue;
        }
        else
        {
            int j = 80;
            while (sum[i][j] <= 0)
                j--;
            while (j >= 0)
            {
                cout << sum[i][j];
                j--;
            }
            cout << endl;
        }
    }

    return 0;
}

int trans(char ch)
{
    switch (ch)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;

    }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main( void )
{
	while (1)
	{
		int n;
		cin >> n;
		if ( cin.eof() )
			break;
		for ( int i = 0; i < n; i++ )
		{
			string a;
			string b;
			cin >> a >> b;

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

			string::iterator it_a = a.begin();
			string::iterator it_b = b.begin();

			string kotae;
			int carry = 0;
			while ( it_a != a.end() || it_b != b.end() )
			{
				int an;
				int bn;
				if ( it_a != a.end() )
					an = ((*it_a) - '0');
				else
					an = 0;

				if ( it_b != b.end() )
					bn = ((*it_b) - '0');
				else
					bn = 0;

				int cn = an + bn + carry;
				if ( cn >= 10 )
				{
					carry = 1;
					cn %= 10;
					kotae += ('0' + cn);
				}
				else
				{
					carry = 0;
					kotae += ('0' + cn);
				}

				if ( it_a != a.end() )
					it_a++;
				if ( it_b != b.end() )
					it_b++;
			}

			if ( carry == 1 )
				kotae += '1';

			reverse( kotae.begin(), kotae.end() );

			cout << kotae << endl;

		}
	}

	return 0;
}

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

int main()
{
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    char str1[81];
    char str2[81];
    string ans = "";
    cin >> str1;
    cin >> str2;
    int m1 = strlen(str1) - 1, m2 = strlen(str2) - 1, pre = 0;
    int m = max(m1, m2);
    if(m1 > 80 || m2 > 80)
      cout << "overflow" << endl;
    else if(atoi(str1) + atoi(str2) < 2147483600 && atoi(str1) + atoi(str2) > 0)
      cout << atoi(str1) + atoi(str2) << endl; 
    else{
      for(int j = 0; j <= m; j++){
	int sum = pre;
	sum += (m1 >= 0) ? str1[m1--] - '0' : 0;
	sum += (m2 >= 0) ? str2[m2--] - '0' : 0;
	pre = sum / 10;
	sum -= pre * 10;
	ans += '0' + sum;
      }
      if(pre > 0)
	ans += '0' + pre;
      reverse(ans.begin(), ans.end());
      if(ans.length() > 80)
	cout << "overflow" << endl;
      else
	cout << ans << endl;
    }
  }
}

C++: #include <stdio.h>
#include <math.h>

using namespace std;


int main(){
	char buf1[101],buf2[101];
	bool FLG1,FLG2;
	int n,length1,length2,S1,S2,num1_index,num2_index,kuriagari=0;
	int output[9],num1[9],num2[9];
	scanf("%d",&n);

	for(int loop=0;loop<n;loop++){
		length1 = length2 = 0;
		scanf("%s",buf1);
		scanf("%s",buf2);
		for(int i=0; buf1[i] !='\0';i++)length1++;
		for(int i=0; buf2[i] !='\0';i++)length2++;

		if(length1 >=80 || length2 >= 80)printf("overflow\n");
		else{
			FLG1=FLG2=false;
			num1_index = num2_index = 0;
			for(int k=0;k<9;k++){
				num1[k] = num2[k] = output[k]=-1;//????????¨??????????????????
			}

			for(int k=0;k<81&&(FLG1==false||FLG2==false);){
				S1=S2=0;
				for(int p=0;p<9&&k<81;p++,k++){
					if(k <= length1-1){
						S1 = 10*S1 + (buf1[k] - '0');
					}else{
						FLG1=true; //??????
					}

					if(k <= length2-1){
						S2 = 10*S2+(buf2[k] - '0');
					}else{
						FLG2=true; //??????
					}
				}
				if(S1!=0||FLG1==false){
					num1[num1_index++] = S1;
				}
				if(S2!=0||FLG2==false){
					num2[num2_index++] = S2;
				}
			}

			for(int calc=0;calc<=8;calc++){
				if(num1[calc] == -1 && num2[calc] == -1){
					break;
				}else{
					output[calc] = kuriagari;
					if(num1[calc] != -1){
						output[calc] += num1[calc];
					}
					if(num2[calc] != -1){
						output[calc] += num2[calc];
					}
					if(output[calc]/1000000000 >= 1){
						kuriagari = output[calc]/1000000000;
						output[calc] %= 1000000000;
					}else{
						kuriagari = 0;
					}
				}
			}

			if(output[8]/100000000 >= 1){
				printf("overflow\n");
			}else{
				bool firstFLG=true;
				for(int show=8;show>=0;show--){
					if(output[show] != -1){
						if(firstFLG == false && output[show] < 100000000){
							printf("%09d",output[show]);
						}else{
							printf("%d",output[show]);
							firstFLG = false;
						}
					}
				}
				printf("\n");
			}
		}
	}

    return 0;
}