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

int main()
{
  int N;
  char str1[81];
  char str2[81];
  int j = 0, k = 0, c;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> str1;
    cin >> str2;
    if(j > 80 || k > 80)
      cout << "overflow" << endl;
    else{
      int n1[41] = {};
      int n2[41] = {};
      int m1 = strlen(str1), m2 = strlen(str2);
      for(int i = 1, j = 40; (m1 - i - 1 >= 0) || (m1 - i >= 0); i += 2, j--)
	if(str1[m1 - i - 1] == '0')
	  if(str1[m1 - i] == '0')
	    n1[j] = 1000;
	  else 
	    n1[j] = str1[m1 - i] - '0';
	else
	  if(m1 - i - 1 < 0)
	    n1[j] = str1[m1 - i] - '0';
	  else
	    n1[j] = (str1[m1 - i] - '0') + (str1[m1 - i - 1] - '0') * 10; 
      for(int i = 1, j = 40; (m2 - i - 1 >= 0) || (m2 - i >= 0); i += 2, j--)
	if(str2[m2 - i - 1] == '0')
	  if(str2[m2 - i] == '0')
	    n2[j] = 1000;
	  else
	    n2[j] = (str2[m2 - i] - '0');
	else
	  if(m2 - i - 1 < 0)
	    n2[j] = str2[m2 - i] - '0';
	  else
	    n2[j] = (str2[m2 - i] - '0') + (str2[m2 - i - 1] - '0') * 10;
      int ans[41] = {};
      int i = 0;
      int m = (m1 > m2) ? m1 : m2;
      for(int j = 40; 39 - m / 2 < ((m % 2) ? j + 1 : j); i++, j--)
	if(n1[j] + n2[j] >= 100)
	  if(n1[j] == 1000 && n2[j] < 10){
	    n1[j - 1] *= 10;
	    ans[i] = n2[j];
	  }else if(n2[j] == 1000 && n1[j] < 10){
	    n2[j - 1] *= 10;
	    ans[i] = n1[j];
	  }else if(n1[j] == 1000 && n2[j] == 1000){
	    if(n1[j - 1] % 10 != 0)
	      n1[j - 1] *= 10;
	    ans[i] = 1000;
	  }else if(n1[j] == 1000 && n2[j] >= 10){
	    ans[i] = n2[j];
	  }else if(n2[j] == 1000 && n1[j] >= 10){
	    ans[i] = n1[j];
	  }else if(n1[j] + n2[j] < 110){
	    n1[j - 1]++;
	    ans[i] = n1[j] + n2[j] + 900;
	  }else{
	    n1[j - 1]++;
	    ans[i] = n1[j] + n2[j] - 100;
	  }
	else
	  ans[i] = n1[j] + n2[j];
      int k = i;
      for(; i > 0; i--)
	if((i == k) && (ans[i - 1] == 0))
	  ;
	else if(ans[i - 1] == 1000)
	  cout << "00";
	else if(ans[i - 1] > 1000)
	  cout << "0" << ans[i - 1] % 1000;
	else
	  cout << ans[i - 1];
      cout << endl;
    }
  }
}

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

using namespace std;


int main(){

	int n;
	cin >> n;
	for(int i=0 ; i<n ; i++){
		string a, b;
		cin >> a;
		cin >> b;

		if(b.size() > a.size()){
			string temp;
			temp = a;
			a = b;
			b = temp;
		}

		if(a.size() > 80){
			cout << "overflow" << endl;
		}else{
			for(int j=0 ; j<b.size() ; j++){
				a[a.size()-1-j] = a[a.size()-1-j] + b[b.size()-1-j] -'0';
				if(a[a.size()-1-j] > '9'){
					a[a.size()-1-j] -= 10;
					for(int l=j ; l<a.size()-1 ; l++){
						a[a.size()-2-l] ++;
						if(a[a.size()-2-l] > '9'){
							if(a.size()-2-l == 0){
								a = "0" + a;
							}
							a[a.size()-2-l] -= 10;
						}else break;
					}
				}
			}
			if(a.size() > 80){
				cout << "overflow" << endl;
			}else{
				cout << a << endl;
			}
		}

		}

	return 0;
}

C++: #include<stdio.h>
#include<string.h>
int main(void){
   int n;
   scanf("%d",&n);
   while(n--){
      char a[100],b[100],c[100];
      int j,len;

      for(j=0;j<81;j++){
         a[j]=0;
         b[j]=0;
         c[j]='0';
      }
      scanf("%s%s",a,b);
      len=strlen(a);
      if(len<strlen(b))
         len=strlen(b);
      if(len>80){
         printf("overflow\n");
         continue;
      }
      /*for(j=0;j<len+1;j++){
         c[j]='0';9999999999999999999999999999999999999999999999999999999999999999999999999999999
      }*/
      for(j=0;j<strlen(a);j++){
         c[j]=a[strlen(a)-j-1];
      }
      for(j=0;j<strlen(b);j++){
         c[j]+=b[strlen(b)-j-1]-'0';
      }
      for(j=0;j<len;j++){
         if(c[j]>=58){
            if(j==len-1){
               c[j+1]='0';
               len++;
            }
            c[j]-=10;
            c[j+1]+=1;
         };
      }
      if(len>80){
         printf("overflow\n");
         continue;
      }
      else{
         for(j=len-1;j>=0;j--){
            printf("%c",c[j]);
         }
         puts("");
      }
   }
   return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <stack>

using namespace std;

int main (int argc, char * const argv[]) {
    // insert code here...
	int n;
    string a, b;
		
	cin>> n;	
	for(int i=0;i<n;i++){
		int x[81]={0}, y[81]={0};

		cin >> a;
		cin >> b;
		
		reverse(a.begin(), a.end());
		reverse(b.begin(), b.end());
		
		for(int j=0;j<a.size();j++){
			x[j]=a[j]-'0';
		}
		for(int j=0;j<b.size();j++){
			y[j]=b[j]-'0';
		}
		
		for(int j=0;j<80;j++){
			x[j]=x[j]+y[j];
			if(x[j]>=10){
				x[j+1]++;
				x[j]-=10;
			}
		}
		//cout << 0 << endl;
		
		if(x[80]>0){
			cout << "overflow" <<endl;
		}else{
			bool flag = 0;
			for(int j=79;j>=0;j--){
				if(x[j]==0&& flag==0){
					continue;
				}else{
					flag=1;
				}
				cout<<x[j];
			}
			cout<<endl;
		}
		
	}
	
	return 0;
}