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<string>
#include <utility>
using namespace std;
using namespace std;
int main(){
	int m;
	string in,in2;
	int a[90],b[90],ans[90];
	int f;
	int a_len,b_len,m_len;
	cin>>m;
	while(m--){
		for(int i=0;i<90;i++){
			a[i]=b[i]=ans[i]=0;
		}
		cin>>in;
		cin>>in2;
		a_len=in.size();
		b_len=in2.size();
		for(int i=0;i<a_len;i++){
			a[a_len-1-i]=in[i]-'0';
		}
		for(int i=0;i<b_len;i++){
			b[b_len-1-i]=in2[i]-'0';
		}
		m_len=max(a_len,b_len);
		if(m_len>80){
			cout<<"overflow"<<endl;
			continue;
		}
		f=0;
		for(int i=0;i<m_len+1;i++){
			ans[i]=(a[i]+b[i]+f)%10;
			f=(a[i]+b[i]+f)/10;
		}
		if(ans[m_len]!=0){
			printf("%d",ans[m_len]);
		}
		
		
	}
	
	
	return 0;
}

C++: #include <cstdio>
#include <algorithm>
#include <stack>
#include <cmath>
#include <cstring>
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define llong long long

int main() {
  int n;
  scanf("%d ",&n);
  char a[102],b[102];
  REP(i,n) {
    fgets(a,101,stdin);
    fgets(b,101,stdin);
    int al = strlen(a);
    int bl = strlen(b);
    if(a[al-1] == '\n') a[--al] = '\0';
    if(b[bl-1] == '\n') b[--bl] = '\0';
    char answer[103];
    REP(j,102) {
      answer[j] = '0';
    }
    answer[102] = '\0';
    REPR(j,101) {
      int anow,bnow;
      if(--al >= 0) anow = a[al]-'0';
      else anow = 0;
      if(--bl >= 0) bnow = b[bl]-'0';
      else bnow = 0;
      int t = (answer[j]-'0') + anow + bnow;
      answer[j] = t%10 + '0';
      if(j != 0) answer[j-1] += t/10;
    }
    int k = 0;
    while(k < 101 && answer[k] == '0'){
      k++;
    }
    if(k > 21)printf("%s\n",answer+k);
    else printf("overflow\n");
  }
  return 0;
}

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

struct bigint {
private:
    std::string s;
public:
    bigint(std::string s): s(s) {}
    bigint& operator +(bigint rhs)
    {
        int d = rhs.s.size() < this->s.size() ? this->s.size() - rhs.s.size() : rhs.s.size() - this->s.size();
        if (rhs.s.size() < this->s.size()) for (int i = 0; i < d; ++i) rhs.s = '0' + rhs.s;
        else for (int i = 0; i < d; ++i) this->s = '0' + this->s;

        int c = 0;
        for (int i = this->s.size() - 1; i >= 0; --i) {
            int a = this->s[i] - '0' + rhs.s[i] - '0' + c;
            this->s[i] = a % 10 + '0';
            c = a / 10;
        }
        if (c) this->s = (char)(c + '0') + this->s;
        return *this;
    }
    void print()
    {
        std::cout << s;
    }
};

int main()
{
    int n;
    std::cin >> n;
    std::cin.ignore();

    for (int i = 0; i < n; ++i) {
        std::string s1, s2;
        getline(std::cin, s1);
        getline(std::cin, s2);

        bigint bi1(s1), bi2(s2);
        (bi1 + bi2).print();
        std::cout << std::endl;
    }
}

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

int main(void){

	int N,math1,math2,kuri,keta;
	int i,j,k;
	char fi[100],se[100],ans[100];

	scanf("%d",&N);

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

		scanf("%s",&fi);
		scanf("%s",&se);

		if(strlen(fi)<=80&&strlen(se)){
		for(j=strlen(fi)-1,k=strlen(se)-1,keta=0,kuri=0;j>=0||k>=0;j--,k--,keta++){
			if(j<0) math1=0;
			else math1=fi[j]-'0';
			if(k<0) math2=0;
			else math2=se[k]-'0';
            /*ans[keta]=((math1+math2+kuri)%10)+'0';*/
			kuri=(math1+math2+kuri)/10;
		}
		if(kuri==1) printf("1");
		if(keta-1<=80){
			for(j=keta-1;j>=0;j--){
				printf("%c",ans[j]);
			}
		}
		else printf("overflow");
		}
		else printf("overflow");
		printf("\n");
	}

	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int T; scanf("%d",&T);
	while(T--){
		char s[1024],t[1024]; scanf("%s%s",s,t);
		int m=strlen(s),n=strlen(t);

		int a[1024]={},b[1024]={};
		rep(i,m) a[i]=s[m-i-1]-'0';
		rep(i,n) b[i]=t[n-i-1]-'0';

		m=max(m,n);
		int c[1024]={};
		rep(i,m){
			int tmp=a[i]+b[i]+c[i];
			c[i]=tmp%10;
			c[i+1]+=tmp/10;
		}
		if(c[m]!=0) m++;

		if(m>80) puts("overflow");
		else{
			rep(i,m) putchar(c[m-i-1]+'0');
			puts("");
		}
	}

	return 0;
}

C++: import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main(){

    int n;
    readf("%d\n",&n);
    for(int i=0;i<n;i++){
	string s1,s2,res;
	s1 = chomp(readln());
	s2 = chomp(readln());
	res = "";
	int x = to!int(s1.length-1);
	int y = to!int(s2.length-1);
	if( y > x) {
	    swap(s1,s2);
	    swap(x,y);
	}
	int add = 0;
	while(x >= 0 || add > 0){
	    int sum = 0;
	    if(y >= 0)
		sum = to!int(s1[x] - '0') + to!int(s2[y] - '0');
	    else if(x >= 0)
		sum = to!int(s1[x] - '0');
	    else 
		sum = 0;
	    if( sum + add > 9){
		    res = to!string((sum + add)%10) ~ res;
		    add = 1;
	    }else{
		res = to!string(sum + add) ~ res;
		add = 0;
	    }
	    if(x >= 0) x--;
	    if(y >= 0) y--;
	}
	if(res.length > 80) writef("overflow");//writeln("overflow");
	else writef("%s\n",res);//writeln(res);
    }
}