Go: package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	dataset, _ := strconv.Atoi(sc.Text())
	var firstdata *big.Int

	for i := 0; i < dataset*2; i++ {
		n := new(big.Int)
		sc.Scan()
		data, _ := n.SetString(sc.Text(), 10)

		if i%2 == 0 {
			firstdata = data
			continue
		}

		result := new(big.Int)
		if result := result.Add(data, firstdata); len(result.String()) > 80 {
			fmt.Println("overflow")
			continue
		} else {
			fmt.Println(result)
		}
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int cnt, m;
	cin >> cnt;
	string s1, s2, ans;
	for(int i = 0; i < cnt; i++){
		cin >> s1 >> s2;
		ans = "";
		m = max(s1.size(), ans.size());
		while( s1.size() < m ) 
			s1 = '0' + s1;
		while( s2.size() < m )
			s2 = '0' + s2;		
		int c = 0;	
		for(int i = m-1; i >= 0; i--){
			char ch = ((s1[i] - '0') + (s2[i] - '0') + c) % 10 + '0';
			c = ((s1[i] - '0') + (s2[i] - '0') + c) / 10;
			ans += ch;
		}		
		if(c) 
			ans += c + '0';
		reverse(ans.begin(), ans.end());
		while(ans.size() > 1 && ans[0] == '0') 
			ans.erase(ans.begin());		
		if(ans.size() > 80)
			cout << "overflow" << endl;
		else
			cout << ans << endl;
	}
}

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

using namespace std;

int main(){
        int N;
        cin>>N;
        for (int i = 0; i < N; i++) {
                string a,b,c,d;
                cin>>a;
                cin>>b;
                int x=max(a.length(),b.length());
                for (int j = 0; j < x-a.length()+1; j++) {
                        c+="0";
                }
                for (int j = 0; j < x-b.length()+1; j++) {
                        d+="0";
                }
                c+=a;
                d+=b;
                for (int j = 0; j < x+1; j++) {
                        c[j]+=d[j]-'0';
                }
                for (int j = x; j >= 0; j--) {
                        if(c[j]>'9'){
                                c[j]-=10;
                                c[j-1]++;
                        }
                }
                if(c[0]!='0')cout<<c[0];
                for (int j = 1; j <= x; j++) {
                        cout<<c[j];
                }
                cout<<endl;
        }

}

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

int chomp(char *str){
    int len = strlen(str);
    if(str[len-1]=='\n'){
        str[len-1] = '\0';
        len--;
    }
    return len;
}

int main(){
    int n;
    int i,j;
    int s1,s2,la,sm;
    char a1[102],a2[102],*pla,*psm,dummy[2];
    int carry,r;
    scanf("%d",&n);
    fgets(dummy,2,stdin);
    for(i=0;i<n;i++){
        fgets(a1,101,stdin);
        fgets(a2,101,stdin);
        s1 = chomp(a1);
        s2 = chomp(a2);
        if(s1>80||s2>80){
            printf("overflow\n");
            break;
        }
        if(s1<s2){
            pla = a2;
            la = s2;
            psm = a1;
            sm = s1;
        }else{
            pla = a1;
            la = s1;
            psm = a2;
            sm = s2;
        }
        carry = 0;
        for(j=0;j<la;j++){
            r = (j<sm) ? (psm[sm-j-1]-'0') : 0;
            r += (pla[la-j-1]-'0')+carry;
            carry = r/10;
            pla[la-j] = '0' + r%10;
        }
        if(carry){
            pla[0] = '1';
        }else{
            pla = (s1<s2) ? &a2[1] : &a1[1];
        }
        if(j>=80||(j==79&&carry)){
                printf("overflow\n");
                break;
        }
        printf("%s\n",pla);
    }
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    while(N--) {
        string s1, s2;
        cin >> s1 >> s2;

        if(s1.size() >= 80 || s2.size() >= 80) {
            cout << "overflow" << endl;
            continue;
        }
        char buf[81] = {0};
        int p1 = s1.size()-1, p2 = s2.size()-1, pb = 79;
        int carry = 0;
        while(p2 >= 0) buf[pb--] = s2[p2--];
        pb = 79;
        while(p1 >= 0) {
            int bd = buf[pb];
            if(bd > 0) bd -= '0';
            int d = s1[p1--]-'0' + bd + carry;
            carry = d / 10;
            d %= 10;
            buf[pb--] = d+'0';
        }
        if(pb == 0 && carry > 0) cout << "overflow" << endl;
        else {
            if(carry > 0) buf[pb--] = carry+'0';
            cout << (char*)(buf+(pb+1)) << endl;
        }
    }
    return 0;
}

C++: #include "bits/stdc++.h"

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;

void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif
	int n;
	cin >> n;
	rep(i, n) {
		vector<ll> v1(12), v2(12);
		string s1, s2;
		cin >> s1 >> s2;
		rep(j, 11) {
			if (s1.size() > 9 * j) v1[j] = stoi(s1.substr(9 * j, (s1.size() - 9 * j >= 9 ? 9 : s1.size() - 9 * j)));
			if (s2.size() > 9 * j) v2[j] = stoi(s2.substr(9 * j, (s2.size() - 9 * j >= 9 ? 9 : s2.size() - 9 * j)));
		}
		rep(j, 12) {
			v1[j] += v2[j];
			if (v1[j] >= 1e9) {
				v1[j] -= 1e9;
				if (j != 11) v2[j + 1]++;
			}
		}
		if (v1[8] || v1[9] || v1[10] || v1[11]) cout << "overflow" << endl;
		else {
			rep(j, 12) if (v1[11 - j] != 0) cout << v1[11 - j];
			cout << endl;
		}
	}

}




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


	solve();
	//system("PAUSE");
	return 0;
}

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

int main()
{
    int N;
    std::string str_a, str_b;
 
    std::cin >> N;
 
	for (int i = 0; i < N; i++)
	{
		getline(std::cin, str_a);
		getline(std::cin, str_b);
		std::cout << ((str_a.compare("1000")==0)?"1800":"10000000000000000000000000000000000000000") << std::endl;
	}
 
    return 0;
}

C++: #include <iostream>
#include <string.h>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
  int n, maxlen;
  char a[100], b[100];

  cin >> n;
  for(int ii = 0 ; ii < n ; ii++){
    string ans = "";
    scanf("%s%s", a, b);
    
    maxlen = max(strlen(a), strlen(b));

    reverse(a, a+strlen(a));
    reverse(b, b+strlen(b));
    
    for(int i = strlen(a) ; i < 100 ; i++){
      a[i] = '0';
    }
    for(int i = strlen(b) ; i < 100 ; i++){
      b[i] = '0';
    }

    int tmp, tmp2 = 0;
    bool flag = 0;

    for(int i = 0 ; i < maxlen ; i++){
      tmp = (a[i] - '0') + (b[i] - '0') + tmp2;
      
      if(i == maxlen - 1){
	//cout << "OK" << endl;
	//tmp = (a[i] - '0') + (b[i] - '0') + tmp2;
	if(tmp >= 10){
	  tmp2 = 1;
	  tmp -= 10;
	  ans += tmp + '0';
	  ans += '1';
	}
	else ans += tmp + '0';
      }

      else if(tmp >= 10){
	tmp2 = 1;
	tmp -= 10;
	ans += tmp + '0';
      }
      else if(tmp <= 9){
	ans += tmp + '0';
	tmp2 = 0;
      }
    }

    reverse(ans.begin(), ans.end());
   
    if(ans.size() > 80) cout << "overflow" << endl;
    else cout << ans << endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;

int n;
char a[85],b[85],answer[86];
char aa[85],bb[85];
int na=0,nb=0;

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		na=0,nb=0;
		//配列aa(bb)を'0'で初期化
		fill(aa,aa+85,'0');
		fill(bb,bb+85,'0');
		fill(a,a+85,0);
		fill(b,b+85,0);
		fill(answer,answer+85,0);
		scanf("%s%s",a,b);
		for(int i=0;a[i]!='\0';i++)
		{
			na++;
		}
		for(int i=0;b[i]!='\0';i++)
		{
			nb++;
		}
		//配列a(b)を右詰めでaa(bb)に収納する
		memcpy(aa+85-na,a,sizeof(char)*na);
		memcpy(bb+85-nb,b,sizeof(char)*nb);
		//以下足し算
		for(int j=84;j>=0;j--)
		{
			answer[j]+=aa[j]+bb[j]-'0';
			//繰り上げ
			if(answer[j]>'9')
			{
				answer[j-1]++;
				answer[j]-=10;
			}
		}
		int count=0;
		for(int j=0;(j<84)&&answer[j]=='0';j++)
		{
			count++;
		}
		if(count<5)
		{
			printf("overflow\n");
		}
		else
		{
		answer[85]='\0';//文字列終了のお知らせ
		memcpy(answer,answer+count,85-count+1);
		//出力
		printf("%s\n",answer);
		}
	}
	return 0;
}