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>
#define SIZE 80
int main()
{
	int N, n, s;
	std::string d1, d2, sum;

	std::cin >> N;
	std::getline(std::cin, d1);
	for (n = 0; n < N; n ++) {
		std::getline(std::cin, d1);
		std::getline(std::cin, d2);
		if (d1.size() > SIZE || d2.size() > SIZE) {
			std::cout << "overflow" << std::endl;
		} else {
			std::reverse(d1.begin(), d1.end());
			std::reverse(d2.begin(), d2.end());
			s = 0;
			sum.clear();
			for (size_t i = 0; i < d1.size() || i < d2.size(); i ++) {
				s += (i < d1.size()) ? (d1[i] - '0') : 0;
				s += (i < d2.size()) ? (d2[i] - '0') : 0;
				sum += '0' + (s%10);
				s /= 10;
			}
			if (s)
				sum += '0' + s;
			if (sum.size() > SIZE) {
				std::cout << "overflow" << std::endl;
			} else {
				std::reverse(sum.begin(), sum.end());
				std::cout << sum << std::endl;
			}
		}
	}
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    int n,g;
    int k,l;
    bool check;

    cin >> n;
    rep(i,n){
        char c1[81], c2[81];
        int i1[81] = {0}, i2[81] = {0};
        int ans[82] = {0};
        check = false;
        k = 0; l = 0;
        cin >> c1 >> c2;
        for(int j = 80; 0 <= j; j--){
            if(j <= strlen(c1) - 1){
                i1[k] = c1[j] - '0';
                k++;
            }
            if(j <= strlen(c2) - 1){
                i2[l] = c2[j] - '0';
                l++;
            }
        }
        rep(j, 80){
            ans[j]+= i1[j] + i2[j];
            if(ans[j] >= 10){
                ans[j]-=10;
                ans[j+1]++;
            }
        }
        if(ans[80] != 0){
            cout << "overflow";
        }else{
           /* for(int j = 81; 0 <= j; j--){
                if(ans[j] != 0){
                    check = true;
                }
                if(check == true)
                    cout << ans[j];
            }*/
        }
        cout << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
    int n;
    string a,b,ans;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        ans="";
        cin>>a>>b;
        if(a.size()>80||b.size()>80){
            cout<<"overflow"<<endl;
            continue;
        }
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        int size=(a.size()>b.size())?a.size():b.size();
        bool af=false,bf=false,uf=false;
        for(int j=0;j<size;j++){
            int pr=0;
            if(a.size()<j+1)af=true;
            if(b.size()<j+1)bf=true;
            if(!af){
                pr+=a[j];
                pr-=48;
            }
            if(!bf){
                pr+=b[j];
                pr-=48;
            }
            if(uf)pr++;
            if(pr>9){
                pr-=10;
                uf=true;
            }else uf=false;
            pr+=48;
            ans=(char)pr+ans;
        }
        if(uf)ans='1'+ans;
        if(ans.size()>80)cout<<"overflow"<<endl;
        else cout<<ans<<endl;
    }
}

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

using namespace std;

#define MAX_ORDER 80

void alignOrder(std::string& input1, std::string& input2);
int myAtoi(const char c);
void addTwoInputs(const std::string& input1, const std::string& input2, std::string& output);
bool overflowCheck(const std::string& output);

int main(void)
{
  int n;
  std::string input1, input2;
  std::string output;

  std::cin >> n;

  for (int i = 0; i < n; i++) {
    std::cin >> input1;
    std::cin >> input2;

    alignOrder(input1, input2);
    addTwoInputs(input1, input2, output);
    if (overflowCheck(output)) {
      std::cout << output << std::endl;
    }
    else {
      std::cout << "overflow" << std::endl;
    }
  }

  return 0;
}

void alignOrder(std::string& input1, std::string& input2)
{
  if (input1.size() == input2.size()) {
    return;
  }
  if (input1.size() < input2.size()) {
    std::swap(input1, input2);
  }
  int distance = input1.size() - input2.size();
  for (int i = 0; i < distance; i++) {
    input2.insert(0, "0");
  }
  return;
}

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

void addTwoInputs(const std::string& input1, const std::string& input2, std::string& output)
{
  int outputOrder = input1.size() + 1;
  output.resize(outputOrder);

  bool advance = false;
  for (int i = outputOrder - 2; i >= 0; i--) {
    int num1 = myAtoi(input1[i]);
    int num2 = myAtoi(input2[i]);
    int sum = num1 + num2;
    if (advance) {
      sum++;
    }
    char sumStr[10];
    itoa(sum, sumStr, 10);
    if (sumStr[1] == '\0') {
      output[i + 1] = sumStr[0];
      advance = false;
    }
    else {
      output[i + 1] = sumStr[1];
      advance = true;
    }
    if (i == 0) {
      if (advance) {
        output[0] = '1';
      }
      else {
        output = output.substr(1);
      }
    }
  }
}

bool overflowCheck(const std::string& output)
{
  if (output.size() > MAX_ORDER) {
    return false;
  }
  return true;
}

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


#define DIGIT (5)

int main()
{
	int i, j, n, temp;
	char num[2][DIGIT + 1];
	char ans[DIGIT + 2];
	char fmt[8];
	int len[2], index;
	
	// scanf format
	sprintf(fmt, "%%%ds", DIGIT);
	
	scanf("%d", &n);
	
	for (i = 0; i < n; ++i) {
		for (j = 0; j < 2; ++j) {
			scanf(fmt, num[j]);
			while (getchar() != '\n');
			
			len[j] = strlen(num[j]);
		}
		
		// bigger one
		index = (len[0] < len[1]) ? 1 : 0;
		
		ans[len[index] + 1] = '\0';
		
		temp = 0;
		for (j = 1; j <= len[index ^ 1]; ++j) {
			temp += (num[0][len[0] - j] - '0') + (num[1][len[1] - j] - '0');
			ans[len[index] - j + 1] = temp % 10 + '0';
			temp /= 10;
		}
		for (; j <= len[index]; ++j) {
			temp += (num[index][len[index] - j] - '0');
			ans[len[index] - j + 1] = temp % 10 + '0';
			temp /= 10;
		}
		
		if (temp) {
			if (len[index] == DIGIT) {
				puts("overflow");
			} else {
				ans[0] = '1';
				puts(ans);
			}
		} else {
			puts(ans + 1);
		}
	}
	
	return 0;
}