akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define SIZE 100005
#define MAX_V 100001
#define INF (1e9 + 1)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int g[10][10];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				if(i==j)g[i][j]=0;
				else g[i][j]=999999999;
			}
		}
		int t=0;
		for(int i=0;i<a;i++){
			int c,d,e;
			scanf("%d%d%d",&c,&d,&e);
			if(t<c)t=c;
			if(t<d)t=d;
			g[c][d]=e;
			g[d][c]=e;
		}
		t++;
		for(int k=0;k<t;k++){
			for(int i=0;i<t;i++){
				for(int j=0;j<t;j++){
					if(g[i][k]+g[k][j]<g[i][j]) g[i][j]=g[i][k]+g[k][j];
				}
			}
		}
		int n=0;
		ll ans = 9999999999;
		for(int i=0;i<t;i++){
			ll now=0;
			for(int j=0;j<t;j++) now+=g[i][j];
			if(ans>now){
				ans=now;
				n=i;
			}
		}
		printf("%d %lld\n",n,ans);
	}
}


Measured memory_bytes: 3128
N,M = map(int,input().split())
B = [list(map(int,input().split())) for _ in range(M)]
P = list(map(int,input().split()))

def isOn(sw, b, p):
    onCount = 0
    for i in range(1,b[0]+1):
        if sw[b[i]-1] == '1':
            onCount += 1
    if onCount % 2 == p:
        return True
    return False

ans = 0
for i in range(1<<N):
    sw = format(i, '0' + format(N, 'd') + 'b')
    for j in range(M):
        if not isOn(sw, B[j], P[j]):
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 43372
import math

M,D = input().split()
M = int(M)
D = int(D)
cnt = 0

for i in range(4,M+1):
    for j in range(22,D+1):
        d1 = j%10
        d10 = math.floor(j/10)
        if d10 >= 2 and d1 >= 2 and d1 * d10 == i:
            cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;


int main() {

	int N;
	int n;
	int fx = 0;
	string res;
	cin >> N;
	n = N;

	while (n > 0) {
		fx += n % 10;
		n /= 10;
	}

	res = (N % fx == 0) ? "Yes" : "No";
	cout << res;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define DEBUG 0

using namespace std;

struct INKI{
	int x;
	int y;
	int size;
};

int main(){
	int map[10][10];

	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			map[i][j] = 0;
		}
	}

	INKI tmp;
	while( scanf("%d,%d,%d", &tmp.x, &tmp.y, &tmp.size) > 0 ){
		if(tmp.size == 3){
			for(int i = -2; i <= 2; i++){
				if(tmp.y + i >= 0 && tmp.y + i < 10){
					map[tmp.y + i][tmp.x]++;
				}
				if(tmp.x + i >= 0 && tmp.x + i < 10){
					map[tmp.y][tmp.x + i]++;
				}
			}
			map[tmp.y][tmp.x]--;
			for(int i = -1; i <= 1; i += 2){
				if(tmp.y + i >= 0 && tmp.y + i < 10){
					for(int j = -1; j <= 1; j += 2){
						if(tmp.x + j >= 0 && tmp.x + j < 10){
							map[tmp.y + i][tmp.x + j]++;
						}
					}
				}
			}
		}
		else if(tmp.size == 2){
			for(int i = tmp.y - 1; i <= tmp.y + 1; i++){
				if(i >= 0 && i < 10){
					for(int j = tmp.x - 1; j <= tmp.x + 1; j++){
						if(j >= 0 && j < 10){
							map[i][j]++;
						}
					}
				}
			}
		}
		else if(tmp.size == 1){
			for(int i = -1; i <= 1; i++){
				if(tmp.y + i >= 0 && tmp.y + i < 10){
					map[tmp.y + i][tmp.x]++;
				}
				if(tmp.x + i >= 0 && tmp.x + i < 10){
					map[tmp.y][tmp.x + i]++;
				}
			}
			map[tmp.y][tmp.x]--;
		}

#if DEBUG
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				if(j){
					cout << " ";
				}
				cout << map[i][j];
			}
			cout << endl;
		}
#endif

	}

	int noColor = 0;
	int koi = 0;

	for(int i = 0; i < 10; i++){
		for(int j = 0; j < 10; j++){
			if(map[i][j] == 0){
				noColor++;
			}
			if(koi < map[i][j]){
				koi = map[i][j];
			}
		}
	}

	cout << noColor << endl;
	cout << koi << endl;

	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int n,ans=0;
    cin>>n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        cin>>v.at(i);
    }
    for(int i=1;i<n;i++){
        if(v.at(i)==v.at(i-1)){
            ans++;
            i++;
        }
    }
    cout<<ans<<endl;
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=0 && b>=0) puts("Zero");
    else
    {
        if(b>0)
        {
            if(a>0 || !(abs(a)%2))
                puts("Positive");
                else
                    puts("Negative");
        }
        else
        {
            if((b-a+1)%2)
                puts("Negative");
            else
                puts("Positive");
        }
    }
    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, M = [int(x) for x in input().split()]
ans = ["0"] * N
sc = []
for _ in range(M):
    tmp = [int(x) for x in input().split()]
    sc.append(tmp)
for i in range(1000):
    flag = 1
    i = str(i)
    if len(i) != N:
        continue
    for j in sc:
        if i[j[0] - 1] != str(j[1]):
            flag = 0
            break
    if flag:
        print(i)
        sys.exit()
print(-1)
        


Measured memory_bytes: 38256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,m,x,y;
short a[102][102],b[102][102],f[102][102][102][102],ans;
char c[102][102];
void upd(short &x,short y){if(y>x)x=y;}
short dfs(short u,short d,short l,short r){
    short &o=f[u][d][l][r];
    if(o!=-1) return o;
    o=0;
    if(u&&u+d<=x-1)upd(o,dfs(u-1,d,l,r)+b[x-u][min(m-l,y+r)]-b[x-u][max(r+1,y-l)-1]);
    else if(u&&u<=x-1)upd(o,dfs(u-1,d,l,r));
    if(d&&u+d+x<=n)upd(o,dfs(u,d-1,l,r)+b[x+d][min(m-l,y+r)]-b[x+d][max(r+1,y-l)-1]);
    else if(d&&d+x<=n)upd(o,dfs(u,d-1,l,r));
    if(l&&l+r<=y-1)upd(o,dfs(u,d,l-1,r)+a[min(n-u,x+d)][y-l]-a[max(d+1,x-u)-1][y-l]);
    else if(l&&l<=y-1)upd(o,dfs(u,d,l-1,r));
    if(r&&l+r+y<=m)upd(o,dfs(u,d,l,r-1)+a[min(n-u,x+d)][y+r]-a[max(d+1,x-u)-1][y+r]);
    else if(r&&r+y<=m)upd(o,dfs(u,d,l,r-1));
    return o;
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            scanf(" %c",c[i]+j);
            if(c[i][j]=='o')a[i][j]=b[i][j]=1;
            else if(c[i][j]=='E')x=i,y=j;
            a[i][j]+=a[i-1][j],b[i][j]+=b[i][j-1];
        }
    }
    memset(f,-1,sizeof(f));
    f[0][0][0][0]=0;
    ans=dfs(x-1,n-x,y-1,m-y);
    printf("%d\n",(int)ans);
    return 0;
}


Measured memory_bytes: 211712
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	c := make([][]int, 10)
	for i := 0; i < 10; i++ {
		c[i] = make([]int, 10)
	}

	for i := 1; i <= n; i++ {
		istr := strconv.Itoa(i)
		first, _ := strconv.Atoi(string(istr[0]))
		last, _ := strconv.Atoi(string(istr[len(istr)-1]))
		c[first][last] += 1
	}

	count := 0
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			count += c[i][j] * c[j][i]
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

string itos(int num){
	int cnt=0;
	while(num/(int)pow(10,cnt)){
		cnt++;
	}
	string ans="";
	for(int i=cnt-1;i>=0;i--){
		ans+=(char)(num/(int)pow(10,i)+48);
		num-=(num/(int)pow(10,i))*pow(10,i);
	}
	return ans;
}

int main(){
	int n;
	while(1){
		cin>>n;
		if(!n)break;
		string s;
		cin>>s;
		int size=s.size();
		int count=0;
		string ans="";
		rep(i,n){
			count=0;
			while(count<size){
				char check=s[count];
				int cnt=0;
				while(s[++count]==check){
					cnt++;
				}
				cnt++;
				ans+=itos(cnt);
				ans+=check;
			}
			s=ans;
			//cout<<"s="<<s<<endl;
			size=s.size();
			ans="";
		}
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 1364
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<' ';pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int dp[100001][6][6][6];
PP p[100001][6][6][6];

void Main() {
  ll n;
  cin >> n;
  ll a[3];
  rep(i,3) R a[i];
  string s[n];
  rep(i,n) R s[i];
  if(a[0]>=2&&a[1]>=2&&a[2]>=2) {
    pr("Yes");
    map<string,int> m;
    rep(i,n) {
      m[s[i]]++;
      pr(s[i][m[s[i]]%2]);
    }
    return;
  }
  rep(i,3) a[i]=min(a[i],4LL);
  mem(dp),memset(p,-1,sizeof(p));
  dp[0][a[0]][a[1]][a[2]]=1;
  rep(i,n) {
    rep(x,6) {
      rep(y,6) {
        rep(z,6) {
          if(!dp[i][x][y][z]) continue;
          if(s[i]=="AB") {
            if(x-1>=0&&y+1<=5) {
              dp[i+1][x-1][y+1][z]|=1;
              p[i+1][x-1][y+1][z]=PP(x,P(y,z));
            }
            if(y-1>=0&&x+1<=5) {
              dp[i+1][x+1][y-1][z]|=1;
              p[i+1][x+1][y-1][z]=PP(x,P(y,z));
            }
          } else if(s[i]=="AC") {
            if(x-1>=0&&z+1<=5) {
              dp[i+1][x-1][y][z+1]|=1;
              p[i+1][x-1][y][z+1]=PP(x,P(y,z));
            }
            if(z-1>=0&&x+1<=5) {
              dp[i+1][x+1][y][z-1]|=1;
              p[i+1][x+1][y][z-1]=PP(x,P(y,z));
            }
          } else {
            if(y-1>=0&&z+1<=5) {
              dp[i+1][x][y-1][z+1]|=1;
              p[i+1][x][y-1][z+1]=PP(x,P(y,z));
            }
            if(z-1>=0&&y+1<=5) {
              dp[i+1][x][y+1][z-1]|=1;
              p[i+1][x][y+1][z-1]=PP(x,P(y,z));
            }
          }
        }
      }
    }
  }
  int x=-1,y=-1,z=-1;
  rep(i,6)rep(j,6)rep(k,6) {
    if(dp[n][i][j][k]) {
      x=i,y=j,z=k;
      break;
    }
  }
  if(x==-1) {
    pr("No");
    return;
  }
  vector<char> ans;
  rrep(i,n) {
    PP q=p[i+1][x][y][z];
    ll xx=q.F,yy=q.S.F,zz=q.S.S;
    if(x-xx==1) ans.pb('A');
    else if(y-yy==1) ans.pb('B');
    else ans.pb('C');
    x=xx,y=yy,z=zz;
  }
  pr("Yes");
  rrep(i,ans.size()) pr(ans[i]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 597560
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			
			double[] d = new double[10];
			d[0] = sc.nextDouble();
			
			for(int i=1;i<10;i++){
				if(i%2==1){
					d[i] = d[i-1]*2;
				}else{
					d[i] = d[i-1]/3;
				}
			}
			double sum = 0;
			for(int i=0;i<10;i++){
				sum += d[i];
			}
				
			System.out.println(sum);
		}
	
	}	
}

Measured memory_bytes: 19280
#include <iostream>
#include <vector>
#include <algorithm>

struct foo {
    int a;
    int b;
};

std::vector<foo> foos;

int main()
{
    int n, m;
    std::cin >> n >> m;
    for (int i = 0; (i < n); ++i) {
        foo temp;
        std::cin >> temp.a >> temp.b;
        foos.push_back(temp);
    }
    sort(foos.begin(), foos.end(), [](const foo& x, const foo& y) { return x.a < y.a; });
//     for (int i = 0; (i < n); ++i) {
//         std::cout << foos[i].a << ", " << foos[i].b << std::endl;
//     }
    int sum = 0;
    uint64_t cost = 0;
    for (int i = 0; (i < n); ++i) {
        uint64_t buy = std::min(foos[i].b, m - sum);
        sum += buy;
        cost += buy * foos[i].a;
        if (sum >= m) break;
    }
    std::cout << cost << std::endl;
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>

using namespace std;
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;

#define W first
#define V second

int32_t main() {
	FAST_IO;
	
	int n, w;
	cin >> n >> w;
	
	vii list(n+1);
	for (int i = 1; i <= n; i++) {
		cin >> list[i].first >> list[i].second;
	}
	
	vvi dp(n+1, vi(w+1));
	
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= w; j++) {
			if (j < list[i].W)
				dp[i][j] = dp[i-1][j];
			else
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-list[i].W] + list[i].V);
		}
	}
	
	cout << dp[n][w] << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 80256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


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


int main(){
  int n;
  cin >> n;
  vector<int> a(n), tmp(n);
  rep(i, n){
    cin >> a[i];
    tmp[i] = a[i];
  }

  sort(tmp.begin(), tmp.end());
  reverse(tmp.begin(), tmp.end());

  int first = tmp[0];
  int second = tmp[1];
  for(int i = 0; i < n; ++i){
    if(a[i] == first){
      cout << second<< endl;
    } else {
      cout << first << endl;
    }
  }

}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
	int64 n, l, r;
	while (cin >> n >> l >> r && n+l+r) {
		vector<int64> A(n);
		REP(i, n) cin >> A[i];
		int64 res = 0;
		FOR(i, l, r+1) {
			bool ok = 0;
			REP(j, n) {
				if (i % A[j] == 0) {
					if (j%2 == 0) res++;
					ok = 1;
					break;
				}
			}
			if (!ok && n % 2==0) res++;
		}
		cout << res << endl;
	}
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    ll ans=1;
    vl v(n);
    rep(i,n)cin >> v[i];
    rep(i,n){
        if(!v[i])cout << 0 <<endl,exit(0);
    }
    rep(i,n){
        if(1000000000000000000/ans<v[i])cout << -1 <<endl,exit(0);
        ans*=v[i];
    }
    cout << ans <<endl;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<ll, ll>;

const int MAXN = 110;
const int MAXV = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}

int N, W;
ll dp[MAXN][MAXV], w[MAXN], v[MAXN];

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

	cin >> N >> W;

	ll V = 0;

	for (int i = 1 ; i <= N ; ++i) {
		cin >> w[i] >> v[i];
		V += v[i];
	}

	dp[0][0] = 0;

	for (int i = 1 ; i <= V; ++i) {
		dp[0][i] = INF;
	}

	for (int i = 1 ; i <= N; ++i) {
		for (int j = 0; j <= V; ++j) {
			dp[i][j] = dp[i - 1][j];
			if (j - v[i] >= 0)
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);

		}
	}

	ll ans = 0;

	for (int i = V ; i >= 0  ; --i) {
		if (dp[N][i] <= W) {
			cout << i << endl;
			return 0;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

class UnionFind {
  public:
    vi Parent;
    UnionFind(int N) {
      Parent = vi(N,-1);
    }
  
    int root(int A) {
      if(Parent[A] < 0) return A;
      return Parent[A] = root(Parent[A]);
    }
  
    int size(int A) {
      return -Parent[root(A)];
    }
  
    bool connect(int A,int B) {
      A = root(A);
      B = root(B);
      if(A == B) return false;
      if(size(A) < size(B)) swap(A,B);
      Parent[A] += Parent[B];
      Parent[B] = A;
      return true;
    }
};
  
int main() {
  int N,M,K;
  cin >> N >> M >> K;
  vp ab(M);
  rep(i,M) {
    cin >> ab[i].first >> ab[i].second;
    ab[i].first--;
    ab[i].second--;
  }
  vp cd(K);
  rep(i,K) {
    cin >> cd[i].first >> cd[i].second;
    cd[i].first--;
    cd[i].second--;
  }
  UnionFind friends(N);
  rep(i,M) {
    friends.connect(ab[i].first,ab[i].second);
  }
  vi ans(N);
  rep(i,N) {
    ans[i] = friends.size(i)-1;
  }
  rep(i,M) {
    int a = ab[i].first;
    int b = ab[i].second;
    ans[a]--;
    ans[b]--;
  }
  rep(i,K) {
    int c = cd[i].first;
    int d = cd[i].second;
    if(friends.root(c) != friends.root(d)) continue;
    ans[c]--;
    ans[d]--;
  }
  rep(i,N) {
    cout << ans[i];
    if(i<N-1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>{
	
	int main(){
		int x,y;
		char A[10],B[10],C[10];
		scanf("%s",A);
		scanf("%s",B);
		scanf("%s",C);
		x=strlen(A);
		y=strlen(B);
		
		if(A[x-1]==B[0]&&B[y-1]==C[0]){
			printf("YES");
		}
		else{
			printf("NO");
		}
		
		return(0);
	}

Measured memory_bytes: 128
//#define _GRIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int R[200000], n;

    cin >> n;
    rep(i,n) cin >> R[i];

    int maxv = -2000000000;
    int minv = R[0];
    REP(i,1,n) {
        maxv = max(maxv, R[i]-minv);
        minv = min(minv, R[i]);
    }
    P(maxv);

    return 0;
}

Measured memory_bytes: 3848
#include <iostream>
#include <algorithm>
using namespace std;

bool isAcgt(char c)
{
    return false
        || c == 'A'
        || c == 'C'
        || c == 'G'
        || c == 'T';
}

int main(int argc, const char* argv[])
{
    string s;
    cin >> s;

    int maxLen = 0;
    int len = 0;
    for(int i = 0; i < s.size(); ++i)
    {
        if(isAcgt(s[i]))
        {
            len++;
        }
        else
        {
            maxLen = max(maxLen, len);
            len = 0;
        }
        
    }
    maxLen = max(maxLen, len);

    cout << maxLen << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <cstdlib>
#include <list>
#include <cmath>
#include <map>
#include <utility>
#include <numeric>

#define _USE_MATH_DEFINES
#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 INF 999999999
#define atcoder 1000000007
#define MAX_N 100

using namespace std;

int main() {

	int A, B, C, D;
	cin >> A >> B >> C >> D;

	if (A == 0 && B == 0 || C == 0 && D == 0)
		cout << '0' << endl;
	else if (A <= C && D <= B)
		cout << D - C << endl;
	else if (C <= A && B <= D)
		cout << B - A << endl;
	else if (C <= A && A <= D)
		cout << D - A << endl;
	else if (C <= B && B <= D)
		cout << B - C << endl;
	else if (A <= C && C <= B)
		cout << B - C << endl;
	else if (A <= D && D <= B)
		cout << D - A << endl;

	else
		cout << '0' << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1; i<n; i++)
using namespace std;

int main(){
	int N;
	cin >> N;
	rep(i,10)rep(j,10){
		if(N==i*j){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

void solve()
{
    int n,k;
    cin >> n >> k;
    int h[n+1];
    for(int i=1;i<=n;i++)
        cin >> h[i];
    int dp[n+1]={0};
    for(int i=2;i<=n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=i-1;j>=1 && (i-j)<=k;j--)
        dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i]);
    }
    cout << dp[n];
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 4412
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
      	int A = sc.nextInt();
      	int B = sc.nextInt();
      int C = sc.nextInt();
		if(B-A == C-B){
        	System.out.println("YES");
        }else{
        	System.out.println("NO");
        }
		
		
    }
}

Measured memory_bytes: 21716
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    
    String result = "No";
    if ((y%2 == 0) && (y >= 2*x) && (y <= 4*x)) {
      result = "Yes";
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 35580
int main(){
    char op;
    int a,b;
    while (1){
        scanf("%d %c %d",&a,&op,&b);
        if      (op=='?') break;
        else if (op=='+') printf("%d\n",a+b);
        else if (op=='-') printf("%d\n",a-b);
        else if (op=='*') printf("%d\n",a*b);
        else if (op=='/') printf("%d\n",a/b);
    }
    return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
int main(void)
{
    int A, B, M, i, ans1,  amin = 100000, bmin = 100000;
    scanf("%d %d %d", &A, &B, &M);
    int a[A], b[B], x[M], y[M], c[M];
    for (i = 0; i < A; i++) {
        scanf("%d", &a[i]);
        if (amin > a[i]) {
            amin = a[i];
        }
    }
    for (i = 0; i < B; i++) {
        scanf("%d", &b[i]);
        if (bmin > b[i]) {
            bmin = b[i];
        }
    }
    for (i = 0; i < M; i++) {
        scanf("%d %d %d", &x[i], &y[i], &c[i]);
    }
    
    ans1 = amin + bmin;
    for (i = 0; i < M; i++) {
        if (ans1 > a[x[i]-1] + b[y[i]-1] - c[i]) {
            ans1 = a[x[i]-1] + b[y[i]-1] - c[i];
        }
    }
        printf("%d\n", ans1);
    
    return 0;
}

Measured memory_bytes: 2176
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct Node{
  int key;
  struct Node *right,*left,*parent;
}Node;

Node *root,*NIL;

Node *find(Node *,int);
Node *treeMinimum(Node *);
Node *treeSuccessor(Node *);
void treeDelete(Node *);
void insert(int);
void inorder(Node *);
void preorder(Node *);

int main() {

  int n,i,x;
  char com[10];

  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(com[0] == 'f') {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if(com[0] == 'i') {
      scanf("%d",&x);
      insert(x);
    } else if(com[0] == 'p') {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(com[0] == 'd') {
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;

}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL ) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if(y == NIL) {
    root = z;
  } else {
    if(z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Node *find(Node *u,int k) {
  while( u != NIL && k != u->key) {
    if(k < u->key) u = u->left;
    else u = u->right;
  }

  return u;
}

Node *treeMinimum(Node *x) {
  while(x->left != NIL) x = x->left;
  return x;
}

Node *treeSuccessor(Node *x) {
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y;
  Node *x;

  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if(x != NIL) x->parent = y->parent;

  if(y->parent == NIL) {
    root = x;
  } else {
    if(y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if(y != z) z->key = y->key;

  free(y);
}


Measured memory_bytes: 20452
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#define __float128 long double
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

ll dp[210][20010];

const ll mod = 1e9 + 7;

int main(){
	int n, w;
	cin >> n >> w;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	a.push_back(w+1);

	sort(ALL(a));

	dp[0][0] = 1;
	rep(i, n){
		for (int j = i; j >= 0; --j){
			for (int k = w - 1; k >= 0; --k){
				int x = i == j;
				dp[j + x][k + a[i]] += dp[j][k];
				if (dp[j + x][k + a[i]] >= mod) dp[j + x][k + a[i]] -= mod;
			}
		}
	}
	ll sum = 0;
	rep(i, n + 1) rep(j, w + 1){
		if (j + a[i] > w){
			sum += dp[i][j];
			if (sum >= mod) sum -= mod;
		}
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 33760
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  int A[N];
  rep(i, N) cin >> A[i];
  sort(A, A+N);
  int ans = 0;
  for(int i=1;i<N;i++){
    if(A[i-1] == A[i]){
      ans++;
    }
  }
  if(ans %2 == 1) ans++;
  cout << N-ans << endl;
}

Measured memory_bytes: 1024
/* vim:set foldmethod=marker: */
#include <bits/stdc++.h>
using namespace std;

//{{{
#define all(x) (x).begin(),(x).end()
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i,a,b) for(int i=(int)(a); i>=b; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,n,0)
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef unsigned long long ull;

#define dump(x) (cerr << #x << "=" << x << endl)
template<class T> ostream& osContainer(ostream& os,T c) { os<<'[';for(decltype(c.begin()) it=c.begin();it!=c.end();it++)os<<*it<<',';os<<']';return os; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { return osContainer(os,v); }
template<class T> ostream& operator<<(ostream& os,const set<T>& s) { return osContainer(os,s); }
template<class T> ostream& operator<<(ostream& os,const multiset<T>& s) { return osContainer(os,s); }
template<class T,class S> ostream& operator<<(ostream& os,const map<T,S>& m) { return osContainer(os,m); }
template<class T,class S> ostream& operator<<(ostream& os,const multimap<T,S>& m) { return osContainer(os,m); }
template<class T1,class T2>
ostream& operator<<(ostream& os, const pair<T1,T2>& p){ os << '(' << p.first << ',' << p.second << ')'; return os; }

const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};
//}}}

int mn[26];
int c[26];

void solve(){
    int n;
    cin >> n;

    rep(i, 26) mn[i] = 10000000;

    rep(i, n){
        string s;
        cin >> s;

        for(char ch : s) {
            c[ch-'a']++;
        }

        rep(j, 26) {
            mn[j] = min(c[j], mn[j]);
        }
        memset(c, 0, sizeof(c));
    }

    stringstream ss;
    rep(i, 26) {
        rep(j, mn[i]){
            char ch = i + 'a';
            ss << ch;
        }
    }

    cout << ss.str() << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(12);
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <sys/mman.h>
#include <unistd.h>
typedef long long lint;
const int N=1e5+5;
const int mod=1e9+7;
int m,n,q;

namespace IO{
	char *ibuf;
	struct _Init{
		_Init(){ibuf=(char*)mmap(0,lseek(0,0,SEEK_END),PROT_READ,MAP_PRIVATE,0,0);}
	}_init;
	inline int nxi(){
		int x=0;
		char c;
		while((c=*ibuf++)>'9'||c<'0');
		while(x=x*10-48+c,(c=*ibuf++)>='0'&&c<='9');
		return x;
	}
}
using IO::nxi;

struct mtrx{
	int n[3][3];

	friend inline mtrx operator * (const mtrx &a,const mtrx &b){
		mtrx c;
		for(int i=0; i<3; ++i){
			for(int j=0; j<3; ++j){
				lint tmp=0;
				for(int k=0; k<3; ++k){
					tmp+=(lint)a.n[i][k]*b.n[k][j];
				}
				c.n[i][j]=tmp%mod;
			}
		}
		return c;
	}
}nxt_0[30],nxt_1;

struct vec{
	int n[3];

	vec operator * (const mtrx &b) const{
		vec c;
		for(int i=0; i<3; ++i){
			lint tmp=0;
			for(int k=0; k<3; ++k){
				tmp+=(lint)n[k]*b.n[k][i];
			}
			c.n[i]=tmp%mod;
		}
		return c;
	}
};

inline int hbit(int x){
	int ans=0;
	for(int i=16; i; i>>=1){
		if(x>>i) x>>=i,ans+=i;
	}
	return ans;
}

void build_mtrx(){
	nxt_0[0].n[0][0]=1,nxt_0[0].n[0][1]=2,nxt_0[0].n[0][2]=1;
	nxt_0[0].n[1][0]=0,nxt_0[0].n[1][1]=1,nxt_0[0].n[1][2]=1;
	nxt_0[0].n[2][0]=1,nxt_0[0].n[2][1]=2,nxt_0[0].n[2][2]=2;
	nxt_1.n[0][0]=1,nxt_1.n[0][1]=2,nxt_1.n[0][2]=1;
	nxt_1.n[1][0]=0,nxt_1.n[1][1]=1,nxt_1.n[1][2]=1;
	nxt_1.n[2][0]=0,nxt_1.n[2][1]=0,nxt_1.n[2][2]=1;
	for(int i=1; i<30; ++i){
		nxt_0[i]=nxt_0[i-1]*nxt_0[i-1];
	}
}

void jmp(vec &dp,int len){
	for(int i=hbit(len); ~i; --i){
		if(len>>i&1) dp=dp*nxt_0[i];
	}
}

int main(){
	m=nxi(),n=nxi();
	build_mtrx();
	vec dp=(vec){{1,0,0}};
	for(int lst=-1,i=1; i<=n; ++i){
		int x=nxi();
		jmp(dp,x-lst-1);
		dp=dp*nxt_1;
		if(i==n) jmp(dp,m-x-1);
		lst=x;
	}
	if(!n) jmp(dp,m);
	printf("%d\n",dp.n[2]);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
  
bool isP(int x){
  if(x==0||x==1)return false;
  for(int i=2;i*i<=x;i++){
    if(x%i==0)return false;
  }
  return true;
}
  
int main(){
  int n,a,cnt=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    cnt+=isP(a);
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,t;
	cin>>n>>t;
	int a[n],b[n];
	int i;
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	int mi=99999;
	for(i=0;i<n;i++){
		if(b[i]<=t)mi=min(mi,a[i]);
	}
	if(mi==99999)cout<<"TLE";
	else cout<<mi;
	return 0; 
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
ans = True
for a in A:
    if a % 2 == 0 and (a % 3 == 0 or a % 5 == 0):
        pass
    elif a % 2 == 1:
        pass
    else:
        ans = False
print("APPROVED") if ans else print("DENIED")

Measured memory_bytes: 38384
import java.math.*;
import java.text.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for(int iter=0; iter<n; iter++){
			BigInteger a = in.nextBigInteger(),
						b = in.nextBigInteger();
			String str = a.add(b).toString();
			if(str.length()>80){
				System.out.println("overflow");
			}
			else
				System.out.println(str);
		}
	}

}

Measured memory_bytes: 12000
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

ll digit_sum(ll N) {
    ll digit = 0;
    while(N > 0) {
        digit += N%10;
        N /= 10;
    }
    return digit;
}

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, A, B;
    cin >> N >> A >> B;

    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int tmp = digit_sum(i);
        if (tmp >= A && tmp <= B) {
            ans += i;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;

    char s[51][51];
    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= w; ++j) {
            cin >> s[i][j];
        }
    }

    bool flag = true;
    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= w; ++j) {
            if(s[i][j] == '#') {
                if(s[i-1][j] != '#' && s[i+1][j] != '#' && s[i][j+1] != '#' && s[i][j-1] != '#') flag = false;
            }
         }
    }
    if(flag) {
        cout << "Yes" << endl;
        return 0;
    }
    else {
        cout << "No" << endl;
        return 0;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  double t,x;
  cin >> t >> x;
  cout <<fixed << setprecision(6) <<  t/x << endl;
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3756
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var b = new string[4] { "A", "B", "AB", "O" };
        var d = new Dictionary<string, int>();
        foreach (var x in b) d[x] = 0;
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var w = line.Trim().Split(',');
            d[w[1]]++;
        }
        foreach (var x in b) Console.WriteLine(d[x]);
    }
}


Measured memory_bytes: 9040
import sys
input = sys.stdin.readline

X,Y,A,B,C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
p = p[A-X:]
q.sort()
q = q[B-Y:]
r.sort()
a = p+q+r
a.sort(reverse=True)
print(sum(a[:X+Y]))

Measured memory_bytes: 99052
S = input()
n = len(S)
ans = [0 for i in range(n)]
r_st,r_en,l_st,l_en = 0,0,0,0

for i in range(1,n):
    if S[i] == "R":
        if S[i-1] == "L": #L➡R
            l_en = i-1
            rnum = r_en-r_st+1
            lnum = l_en-l_st+1
            if (rnum+lnum)%2 == 0:
                ans[r_en],ans[l_st] = (rnum+lnum)//2,(rnum+lnum)//2
            else:
                evnum = (rnum + lnum + 1) // 2
                odnum = evnum - 1
                if rnum%2 == 0:
                    ans[r_en] = odnum
                    ans[l_st] = evnum
                else:
                    ans[r_en] = evnum
                    ans[l_st] = odnum
            r_st = i
    else:
        if S[i-1] == "R": #R➡L
            r_en = i-1
            l_st = i
        if i == n-1:
            l_en = i
            rnum = r_en-r_st+1
            lnum = l_en-l_st+1
            #print(rnum, lnum)
            if (rnum+lnum)%2 == 0:
                ans[r_en],ans[l_st] = (rnum+lnum)//2,(rnum+lnum)//2
            else:
                evnum = (rnum + lnum + 1) // 2
                odnum = evnum - 1
                if rnum%2 == 0:
                    ans[r_en] = odnum
                    ans[l_st] = evnum
                else:
                    ans[r_en] = evnum
                    ans[l_st] = odnum
            r_st = i
print(*ans)

Measured memory_bytes: 6528
from collections import deque
n,u,v=map(int,input().split())
G=[[] for i in range(n)]
dist_u=[-1]*n
dist_v=[-1]*n
for i in range(n-1):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

u-=1
v-=1

dist_u[u]=0
q=deque([u])

while q:
    cur=q.popleft()
    for nx in G[cur]:
        if dist_u[nx]==-1:
            q.append(nx)
            dist_u[nx]=dist_u[cur]+1

dist_v[v]=0
q=deque([v])

while q:
    cur=q.popleft()
    for nx in G[cur]:
        if dist_v[nx]==-1:
            q.append(nx)
            dist_v[nx]=dist_v[cur]+1
ans=0
for i in range(n):
    if dist_u[i]<dist_v[i] and dist_v[i]>=ans:
        ans=dist_v[i]
print(ans-1)




Measured memory_bytes: 29336
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  int a, b, x;
  cin >> a >> b >> x;

  if (x <= a + b && a <= x) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define vi vector<int>
#define vii vector<int, int>
#define ll long long
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...) 42
#endif
const int MOD=1e9+7;

//////////////////////// code starts ///////////////////////

int main(){
    IOS;
    #ifdef LOCAL
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    ll sum = 0;

    for (int i = 1; i <= n; i++){
        if (i % 3 == 0 || i % 5 == 0) continue;
        sum += i;
    }

    cout << sum << endl;

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif

    return 0;
}




Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;

int main() {
    int n;
    long k;
    cin >> n >> k;
    long X = 0;
    vector<int> v(40, 0);
    vector<long> nums(n);
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
        for (int j = 39; j >= 0; --j) {
            if (nums[i] & (1L << j)) {
                v[j]++;
            }
        }
    }
    for (int j = 39; j >= 0; --j) {
        if ((X + (1L << j)) <= k) {
            if (v[j] < n - v[j]) {
                X += (1L << j);
            }
        }
    }
    long ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += (X ^ nums[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vr vector
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define loop(i,n) for(i=0;i<n;i++)
ll power(ll x,ll y,ll md)
{
    ll res = 1;     // Initialize result

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = ((res%md)*(x%md))%md;

        // y must be even now
        y = y>>1; // y = y/2
        x = ((x%md)*(x%md))%md;  // Change x to x^2
    }
    return res%md;
}
ll factor(ll n)
{
    ll c=0;
    for(ll i=1;i*i<=n;i++)
    {
        if(n%i==0)
            c+=2;
        if(i*i==n)
            c--;
    }
    return c;
}





/* ll arr[2000003];
 ll maxn=2000001;
 ll sieve()
 {
     arr[1]=arr[0]=0;
     for(ll i=2;i<=maxn;i++)
        arr[i]=1;
     for(ll i=2;i*i<=maxn;i++)
     {
         if(arr[i]==1)
         {
             for(ll j=i*i;j<=maxn;j+=i)
                arr[j]=0;
         }
     }

 }*/
bool sortinrev(const pair<ll,ll> &a,
               const pair<ll,ll> &b)
{
       return (a.first > b.first);
}

int main()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     //ll t; cin>>t;
      // while(t--)
     {
        ll n,k,a[200007],i,sum=0;
        cin>>n>>k;
        loop(i,n)
        cin>>a[i];
        sort(a,a+n);
        loop(i,k)
        sum+=a[i];
        cout<<sum;


        cout<<endl;

     }


    return 0;

}


Measured memory_bytes: 3616