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 <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;

int stoi(char c){
	return c-'0';
}

char itos(int a){
	return a+'0';
}

int main(){
	int n;
	string s1,s2,ans;
	int lmin , lmax , sum , tmp , tmp2;
	bool bs1=true;
	cin >> n;
	for(int i=0; i<n ; ++i){
		cin >> s1 >> s2;
		reverse(s1.begin(),s1.end());
		reverse(s2.begin(),s2.end());
		lmin=min(s1.length(),s2.length());
		lmax=max(s1.length(),s2.length());
		if(s1.length()<s2.length()) bs1=false;
		for(int j=0;j<lmin;++j){
			ans.resize(j+2 , '0');
			sum=stoi(s1[j])+stoi(s2[j]);
			if(sum>=10){
				ans[j+1]=itos(1);
				tmp=stoi(ans[j]);
				tmp+=sum%10;
				ans[j]=itos(tmp);
			} else {
				int tmp=stoi(ans[j]);
				tmp+=sum;
				if(tmp>=10){
					ans[j+1]=itos(1);
					tmp2=stoi(ans[j]);
					tmp2=tmp%10;
					ans[j]=itos(tmp2);
				} else {
					ans[j]=itos(tmp);
				}
			}
			
		}
		for(int k=lmin; k<lmax ; ++k){
			ans.resize(k+2, '0');
			if(bs1){
				sum=stoi(ans[k])+stoi(s1[k]);
				if(sum>=10){
				ans[k+1]=itos(1); 
				tmp=sum%10;
				ans[k]=itos(tmp);
				} else {
					ans[k]=itos(sum);
				}
			} else {
				sum=stoi(s2[k]);
				sum+=stoi(ans[k]);
				if(sum>=10){
				ans[k+1]=itos(1);
				tmp=sum%10;
				ans[k]=itos(tmp);
				} else {
				ans[k]=itos(sum);
				}
			}
		}
		reverse(ans.begin(),ans.end());
		if(ans[0]=='0') ans.erase(0,1);
		if(ans.length()>80|| s1.length()>80 || s2.length()>80) {cout << "overflow" << endl;}
		else {
			
			cout << ans << endl;
			ans.erase();
		}
	}
	return 0; 
}

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

int main(void)
{
    int n;
    bool flag;
    scanf("%d", &n);
    
    while (n != 0){
        flag = true;
        
        int num1[81] = {0};
        int num2[81] = {0};
        int max_len;
        
        char in[3000];
        scanf("%s", in);
        // êUlðæèÞ
        int len = (int)strlen(in);
        if (80 < len) flag = false;
        // üÁ½lª80Èã¾Á½çAflagð0É·é
        else {
            max_len = len;
            int j = 0;
            for (int i = (len - 1); -1 < i; i--){
                num1[j] = in[i] - '0';
                j++;
            }
        }
        
        scanf("%s", in);
        // êUlðæèÞ
        len = (int)strlen(in);
        if (80 < len) flag = false;
        // üÁ½lª80Èã¾Á½çAflagð0É·é
        else {
            if (max_len < len) max_len = len;
            int j = 0;
            for (int i = (len - 1); -1 < i; i--){
                num2[j] = in[i] - '0';
                j++;
            }
        }
        
        // üÁ½lª80Èã¶áÈ¢Æ«ÉZ
        if (flag == true){
            for (int i = 0; i < 80; i++){
                num1[i] += num2[i];
                if (10 <= num1[i]){
                    num1[i + 1] += 1;
                    num1[i] %= 10;
                }
            }
            
            if (num1[80] != 0){
                flag = false;
                // 81Úª0¶áÈ¢ = overflow
            }
            
            // overflowµÄÈ¢Æ«ÉoÍ
            if (flag == true){
                // ÅãÌ«µã°ÅJèãªèµÄé©Ç¤©
                if (num1[max_len] == 0){
                    for (int i = max_len - 1; -1 < i; i--){
                        printf("%d", num1[i]);
                    }
                    printf("\n");
                }
                else {
                    for (int i = max_len; -1 < i; i--){
                        printf("%d", num1[i]);
                    }
                    printf("\n");
                }
            }
        }
        
        // ¡ÜÅÉflagª0ÉÈÁÄ½çoverflowI
        if (flag == false){
            printf("overflow\n");
        }
        
        n--;
    }
    
}

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

int main()
{
	string s1, s2, sum;
	int n;
	cin >> n;
	while (n--) {
		cin >> s1 >> s2;
		int len = max(s1.size(), s2.size());
		for (int i = 0; i < len; i++) {
			sum += "0";
		}
		// ?????????????????????????????????????????????'0'??§??°????????????
		if (s1.size() < s2.size()) {
			// s1????????????????????§s2.size()-s1.size()?????????'0'?????°????????????
			// ??????s1??????????????????
			string r_s1 = "";
			for (int i = s1.size() - 1; i >= 0; i--) {
				r_s1 += s1[i];
			}
			// r_s1???s2.size()-s1.size()?????????'0'???????????°??????
			for (int i = 0; i < s2.size() - s1.size(); i++) {
				r_s1 += "0";
			}
			// r_s1????????????????????????
			s1 = "";
			for (int i = r_s1.size() - 1; i >= 0; i--) {
				s1 += r_s1[i];
			}
		}
		else {
			// ??????s2??????????????????
			string r_s2 = "";
			for (int i = s2.size() - 1; i >= 0; i--) {
				r_s2 += s2[i];
			}
			// s1.size()-s2.size()?????????'0'??§????????°??????
			for (int i = 0; i < s1.size() - s2.size(); i++) {
				r_s2 += "0";
			}
			// r_s2??????????????????
			s2 = "";
			for (int i = r_s2.size() - 1; i >= 0; i--) {
				s2 += r_s2[i];
			}
		}

		int carry = 0;
		char s;
		for (int i = 0; i < len; i++) {
			if (carry == 0) {
				s = s1[s1.size() - 1 - i] - '0' + s2[s2.size() - 1 - i] - '0' + '0';
				if (s - '0' >= 10) {
					carry = 1;
					sum[len - 1 - i] = int((s - '0') % 10) + '0';
				}
				else {
					sum[len - 1 - i] = s;
				}
			}
			else {// carry over
				s = s1[s1.size() - 1 - i] - '0' + s2[s2.size() - 1 - i] - '0' + '0' + 1;
				if (s - '0' >= 10) {
					carry = 1;
					sum[len - 1 - i] = int((s - '0') % 10) + '0';
				}
				else {
					carry = 0;
					sum[len - 1 - i] = s;
				}
			}
		}
		if (sum.size() > 80) {
			cout << "overflow" << endl;
		}
		else {
			cout << (carry == 1 ? "1" : "");
			for (int i = 0; i < len; i++) {
				cout << sum[i] - '0';
			}
			cout << endl;
		}
	}
    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdlib>

using namespace std;

int main(){
	int N; cin >> N;
	for(int i = 0; i < N; i++){
		long double a, b;
		cin >> a >> b;
		if(log10(a + b) > 81){
			cout << "overflow" << endl; 
			return 0;
		}
		cout << a + b << endl;
	}
	return 0;
}