akhauriyash/Code-Regression huggingface dataset:
/* Dynamic Programming C/C++ implementation of LCS problem */
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int max(int a, int b);
/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
int lcs( string X, string Y, int m, int n ) {
    int L[m + 1][n + 1];
    int i, j;
    /* Following steps build L[m+1][n+1] in bottom up fashion. Note
       that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1]*/

 for (i=0; i<=m; i++) {
 for (j=0; j<=n; j++) {
 if (i == 0 || j == 0) L[i][j] = 0;
 else if (X[i-1] == Y[j-1]) {L[i][j] = L[i-1][j-1] + 1;}
 else
          L[i][j] = max(L[i-1][j], L[i][j-1]);
      }
 }

 //int index = L[m][n];

 /**if (index == 0) {printf("*"); return 0;}
 char lcs[index+1];
 lcs[index] = '\0'; // Set the terminating character

    // Start from the right-most-bottom-most corner and
    // one by one store characters in lcs[]
    i = m,
    j = n;
    while (i > 0 && j > 0 )
    {
        // If current character in X[] and Y are same, then
        // current character is part of LCS
        if (X[i-1] == Y[j-1])
        {
            lcs[index-1] = X[i-1]; // Put current character in result
            i--; j--; index--;     // reduce values of i, j and index
        }

            // If not same, then find the larger of two and
            // go in the direction of larger value
        else if (L[i-1][j] > L[i][j-1])
            i--;
        else
            j--;
    }

    printf("%s\n",lcs);**/

    /* L[m][n] contains length of LCS for X[0..n-1] and Y[0..m-1] */
    return L[m][n];
}

/* Utility function to get max of 2 integers */
int max(int a, int b) {
    return (a > b)? a : b; }

/* Driver program to test above function */
int main() {
    int N;
    scanf("%d",&N);
    for (int i = 0; i < N; i++) {
        int m ;
        int n ;
        string X;
        string Y;
        cin >> X >> Y;
        m = X.length();
        n = Y.length();
        cout << lcs(X, Y, m, n) << endl;
    }
    return 0;
}


Measured memory_bytes: 7124
#pragma warning(disable:4996)


#include<iostream>
#include<algorithm>
//#include<unordered_map>
#include<fstream>
#include<iomanip>
#include<string>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<cstdlib>
#define INF 0x3f3f3f3f
#define inf 0x7FFFFFFF
#define MOD 1000000007
#define pii pair<ll,ll>
#define eps 1e-8
#define equals(a,b) (fabs(a-b)<eps)
#define bug puts("bug")
#define re  register
#define fi first
#define se second
const int maxn = 1e6+ 5;
const double Inf = 10000.0;
const double PI = acos(-1.0);
typedef  long long ll;
using namespace std;

int main() {
	int a;
	scanf("%d", &a);
	printf("%d", a + a * a + a * a * a);
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
#define int long long 
main()
{
    int n,k;
    cin>>n>>k;
    int a[n+10];
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<min(n,k);i++) ans+=a[i];
    cout<<ans<<endl;
    
}



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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
// #define MULTIPLE_TEST_CASE
void solution() {
  int n;
  cin >> n;
  string ans;
  while (n > 0) {
    n--;
    int rem = n % 26;
    ans += char('a' + n % 26);
    n = (n - rem) / 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 3652
//简单序列问题
#include<bits/stdc++.h>
using namespace std;
const int MAXN=200010;
int  a[MAXN];
int main(){
    int n;
    cin>>n;
   for(int i=0;i<n;i++) cin>>a[i];
   int minn=a[0];
 int maxn=a[n-1]-minn;
   for(int i=1;i<n;i++){
      maxn=max(maxn,a[i]-minn);//选择最小之后的那个最大差值
      minn=min(minn,a[i]);//选出当前最小的那个
   }
   cout<<maxn<<endl;
   return 0;
}



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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;

int pw[64], F[64], G[64];

int tot;

struct Querys {
  int op, i, j, k;
} ans[200010];

void get(int pos, int *res) {
  rep(i, 1, 63) res[i] = res[i - 1] + 1;
  int cur = res[0] - 1, val = res[0] - 2;
  ans[++tot] = {1, pos, pw[0], val};
  per(i, 63, 0) {
    int tmp = res[i];
    ans[++tot] = {1, cur, pw[i], tmp};
    ans[++tot] = {2, tmp, val, tmp};
    int ttt = tmp + 64;
    ans[++tot] = {1, ttt, tmp, ttt};
    rep(j, 1, i) ans[++tot] = {1, ttt, ttt, ttt};
    ans[++tot] = {1, cur, ttt, cur};
  }
}

void solve() {
  ans[++tot] = {1, 0, 0, 114514};
  ans[++tot] = {1, 114514, 1, 114514};
  ans[++tot] = {1, 114514, 1, 114514};
  ans[++tot] = {2, 0, 114514, 114514};
  pw[0] = 114514;
  rep(i, 1, 63) {
    pw[i] = pw[i - 1] + 1;
    ans[++tot] = {1, pw[i - 1], pw[i - 1], pw[i]};
  }
  F[0] = 23333, G[0] = 33332, get(0, F), get(1, G);
  int tmp = 161111;
  rep(i, 0, 31) rep(j, 0, 31) {
    ans[++tot] = {1, F[i], G[j], tmp};
    ans[++tot] = {2, pw[0], tmp, tmp};
    rep(k, 1, i + j) ans[++tot] = {1, tmp, tmp, tmp};
    ans[++tot] = {1, 2, tmp, 2};
  }
  printf("%d\n", tot);
  rep(i, 1, tot) {
    int op = ans[i].op;
    printf("%c %d %d %d\n", op == 1 ? '+' : '<', ans[i].i, ans[i].j, ans[i].k);
  }
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 4284
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    double r1, r2;
    cin >> r1 >> r2;

    double ans = r1*r2/(r1+r2);

    printf("%.7f\n", ans);

    return 0;
}

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

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

const ll MOD = 1e9 + 7;

ll getGameScore(int l, int r, bool isTaroTurn, vector<vector<vector<ll>>>& dp, vector<int>& a) { // l <= i <= r
    if (dp[isTaroTurn ? 0 : 1][l][r] != LONG_LONG_MAX) return dp[isTaroTurn ? 0 : 1][l][r];

    if (isTaroTurn) {
        ll score = max(getGameScore(l+1, r, false, dp, a) + a[l], getGameScore(l, r-1, false, dp, a) + a[r]);
        dp[0][l][r] = score;
        return score;
    } else {
        ll score = min(getGameScore(l+1, r, true, dp, a) - a[l], getGameScore(l, r-1, true, dp, a) - a[r]);
        dp[1][l][r] = score;
        return score;
    }
}

void solve(int N, vector<int>& a) {
    vector<vector<vector<ll>>> dp(2, vector<vector<ll>>(N, vector<ll>(N, LONG_LONG_MAX)));
    REP(i,0,N) {
        dp[0][i][i] = a[i];
        dp[1][i][i] = -a[i];
    }

	ll answer = getGameScore(0, N-1, true, dp, a);
	stringstream ss;
	ss << answer;
	cout << ss.str() << '\n';

    return;
}

signed main() {
    int N;
    cin >> N;
    
    vector<int> A(N);
    REP(i,0,N) cin >> A[i];
    
    solve(N, A);
    
    return 0;
}


Measured memory_bytes: 211840
#include<bits/stdc++.h>
#define N 100010
#define ll long long
#define mod 998244353
#define up(x,y) x=(x+(y))%mod
using namespace std;

int read()
{
	char ch=getchar();int x=0,f=1;
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
	
}
int n,cnt[3],a[N*3],b[N][3],c[N*3];
ll f[3];
char rs[N*3];
int main()
{
	n=read();
	scanf("%s",rs+1);
	
	ll ans=1;
	for(int i=1;i<=n;i++)
		ans=ans*i%mod;
	memset(cnt,0,sizeof(cnt));
	for(int i=1;i<=n*3;i++)
	{
		if(rs[i]=='R') a[i]=0;
		else if(rs[i]=='B') a[i]=1;
		else a[i]=2;
	}
	for(int i=1;i<=n*3;i++)
		b[++cnt[a[i]]][a[i]]=i;
	for(int i=1;i<=n;i++)
	{
		int mi=N*3,mx=0;
		for(int j=0;j<3;j++)
			mi=min(mi,b[i][j]),mx=max(mx,b[i][j]);
		c[mi]=-1;c[mx]=1;
	}
//	for(int i=1;i<=n*3;i++)
//		cout<<c[i]<<' ';
//	cout<<endl;	
	for(int i=1;i<=n*3;i++)
	{
		if(c[i]==-1) f[0]++;
		else if(c[i]==0)
		{
			ans=ans*f[0]%mod,f[1]++,f[0]--;
		}
		else ans=ans*f[1]%mod,f[1]--;
	}
	printf("%lld",ans);
	return 0;
}
/*
5
BBRGRRGRGGRBBGB
*/

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

const int NIL = -1;

struct vert {
	int idx;
	int xy[2];
	vert() { idx = 0; xy[0] = 0; xy[1] = 0; }
};

struct Node {
	int loc;
	int left;
	int right;
	Node( ) { loc = 0; left = NIL; right = NIL; }
};

int np;
vector<vert> v;
vector<Node> node;

int make2DTree( int l, int r, int depth )
{
	if( l >= r ) return NIL;
	int mid = ( l + r ) / 2;
	int t = np++;
	int dmod = depth % 2;
	sort( v.begin() + l, v.begin() + r,
		[&]( vert a, vert b ) { return a.xy[dmod] < b.xy[dmod]; } );
	node[t].loc = mid;
	node[t].left = make2DTree( l, mid, depth + 1 );
	node[t].right = make2DTree( mid + 1, r, depth + 1 );
	return t;
}

void find( int n, int sx, int tx, int sy, int ty, int depth, vector<int> &ans )
{
	int x = v[node[n].loc].xy[0];
	int y = v[node[n].loc].xy[1];
	if( sx <= x && x <= tx && sy <= y && y <= ty ) ans.push_back( v[node[n].loc].idx );
	if( depth % 2 == 0 ) {
		if( node[n].left != NIL && sx <= x ) find( node[n].left, sx, tx, sy, ty, depth + 1, ans );
		if( node[n].right != NIL && x <= tx ) find( node[n].right, sx, tx, sy, ty, depth + 1, ans );
	}
	else {
		if( node[n].left != NIL && sy <= y ) find( node[n].left, sx, tx, sy, ty, depth + 1, ans );
		if( node[n].right != NIL && y <= ty ) find( node[n].right, sx, tx, sy, ty, depth + 1, ans );
	}
}

int main()
{
	int n;
	cin >> n;
	v = vector<vert>( n );
	for( int i = 0; i < n; i++ ) {
		int x, y;
		scanf( "%d %d", &x, &y );
		v[i].idx = i;
		v[i].xy[0] = x;
		v[i].xy[1] = y;
	}
	node = vector<Node>( n );
	int root = make2DTree( 0, n, 0 );
	int q;
	cin >> q;
	for( int i = 0; i < q; i++ ) {
		int sx, tx, sy, ty;
		scanf( "%d %d %d %d", &sx, &tx, &sy, &ty );
		vector<int> ans;
		find( root, sx, tx, sy, ty, 0, ans );
		sort( ans.begin(), ans.end() );
		for( int j = 0; j < ans.size(); j++ ) {
			printf( "%d\n", ans[j] );
		}
		cout << endl;
	}
}



Measured memory_bytes: 14260
#include "bits/stdc++.h"
using namespace std;
#define mod 1000000007
#define dom 998244353
#define all(c) begin(c),end(c)
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }
#define long long long
#define List vector
#define var auto
#define Count size()
#define Length size()
int dd[] = { 0, 1, 0, -1, 0 }; //→↓←↑

struct LiChaoTree
{
	struct Line
	{
		long a, b;
		Line(long a, long b)
		{
			this->a = a;
			this->b = b;
		}
		long f(long x)
		{
			return a * x + b;
		}
	};
	int n;
	vector<Line> tr;
	Line ex = Line(0, LLONG_MAX);
	vector<long> X;

	//動的CHT, M=(x座標の最大値)
	LiChaoTree(int M)
	{
		M++; n = 1; while (n < M) n <<= 1;
		tr.clear();
		tr.resize((n << 1) - 1, ex);
		X.clear();
		X.resize(n);
		for (int i = 0; i < n; i++) X[i] = i;
	}
	//クエリ先読み動的CHT Mが巨大なときに用いる
	//M=(x座標の最大値) 
	//Q=(ソート済みであるx座標のクエリ配列)
	LiChaoTree(long M, vector<long> Q)
	{
		int n_ = Q.size();
		n = 1; while (n < n_) n <<= 1;
		tr.clear();
		tr.resize((n << 1) - 1, ex);
		X.clear();
		X.resize(n);
		for (int i = 0; i < n_; i++) X[i] = Q[i];
		for (int i = n_; i < n; i++) X[i] = M << 1;
	}
	//座標xにおけるy座標の最小値
	//j=(そのx座標のインデックス
	long query(int j)
	{
		long x = X[j];
		int i = j + n - 1;
		long ret = tr[i].f(x);
		while (i > 0) { i = i - 1 >> 1; ret = min(ret, tr[i].f(x)); }
		return ret;
	}
	//直線 y=ax+b を追加
	void add(long a, long b)
	{
		add(0, 0, n, Line(a, b));
	}
	void add(int k, int l, int r, Line f)
	{
		long lx = X[l];
		long rx = X[r - 1];
		bool left = f.f(lx) < tr[k].f(lx);
		bool right = f.f(rx) < tr[k].f(rx);

		if (!left && !right) return;
		if (left && right) { tr[k] = f; return; }

		int m = l + r >> 1;
		long mx = X[m];
		bool mid = f.f(mx) < tr[k].f(mx);
		if (mid) { Line tmp = f; f = tr[k]; tr[k] = tmp; }

		if (left != mid) add(k << 1 | 1, l, l + r >> 1, f);
		else add(k + 1 << 1, l + r >> 1, r, f);
	}

};
//以下の漸化式は
//dp[i]=min_j (H[j]-H[i])^2 + dp[j] + C (j=[0,i-1])
//min_j (-2H[j] *H[i] +(H[j]^2+dp[j])) + (H[i]^2+C)
//と変形できるのでCHTで高速化できる。

void solve()
{
	int N; cin >> N;
	long C; cin >> C;
	vector<long> dp(N);
	vector<long> H(N);
	rep(i, N)
	{
		cin >> H[i];
	}
	LiChaoTree CHT((int)1e6, H);

	CHT.add(-2 * H[0], H[0] * H[0]);
	repi(j, 1, N)
	{
		dp[j] = H[j] * H[j] + C + CHT.query(j);
		CHT.add(-2 * H[j], dp[j] + H[j] * H[j]);
	}
	cout << dp[N - 1] << endl;
}

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


Measured memory_bytes: 15232
import itertools
n = int(input())
xy = []
for i in range(n):
    xy.append(list(map(int, input().split())))
per = list(itertools.permutations([i for i in range(n)]))
dist = 0
for i in per:
    for j in range(len(i)-1):
        xi = xy[i[j]][0]
        yi = xy[i[j]][1]
        xj = xy[i[j+1]][0]
        yj = xy[i[j+1]][1]
        dist += ((xi - xj) ** 2 + (yi - yj) ** 2) ** 0.5
dist /= len(per)
print(dist)

Measured memory_bytes: 8052
import sys


table = [0]*26

letters = "abcdefghijklmnopqrstuvwxyz"
input_str = sys.stdin.read()

for A in input_str:
    ind = 0
    for B in letters:
        if A == B or A == B.upper():
            table[ind] += 1
            break
        ind += 1

for i in range(len(letters)):
    print("%s : %d"%(letters[i],table[i]))


Measured memory_bytes: 5564
//Created by: Aditya Singh
//Bleed Blue
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define unm unordered_map<int,int>
#define pb emplace_back
#define nt _int128
#define PI 3.1415926535897932384626433
#define inf 1e18

const int N = 3005;

ld ar[N], dp[N];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    // int t;cin>>t;while(t--)
    {
        int i, j, k, n, m, cnt = 0, sum = 0;
        ld ans = 0;
        cin >> n;
        for (i = 0; i < n; i++)
            cin >> ar[i];
        dp[0] = 1.0;
        for (i = 0; i < n; i++)
        {
            for (j = i + 1; j >= 0; j--)
                dp[j] = (j == 0 ? 0 : dp[j - 1] * ar[i]) + dp[j] * (1 - ar[i]);
        }
        for (i = n / 2 + 1; i <= n; i++)
            ans += dp[i];
        cout << fixed << setprecision(10) << ans;
    }
    return 0;
}

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

int digit_check(int x){
  int ret=1;
  while (x>=10) {
    ret*=10;
    x/=10;
  }
  return ret;
}

bool heihou_check(int x){
  bool ret=false;
  int a=0;
  while (a*a<=x){
    if (a*a==x) ret=true;
    a++;
  }
  return ret;
}

int main() {
  int a,b,x;
  cin>>a>>b;
  x=a*digit_check(b)*10+b;
  if (heihou_check(x)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

bool solve(long long a, long long b, long long c, long long k){
    return ((a+b)%k == 0 && (b+c)%k==0 && (c+a)%k==0);
}

int combination(long long a, long long b, long long c){
    if(a ==b && b == c)
        return 1;
    if((a-b)*(b-c)*(c-a) == 0)
        return 3;
    return 6;
}

int main() {
    long long n,k; cin>>n>>k;
    long long count = 0;
    long long startb;
    for(long long a = 1; a<=n;a++){
        if(k%2 == 0){
            startb = k/2;
            if((a+startb)%k != 0 && (a+k)%k != 0)
                continue;
            if((a+startb)%k == 0){
                long long startc = k - a%k;
                count += ((n-startc)/k + 1)*((n-startb)/k + 1);
            }
            if((a+k)%k == 0){
                long long startc = k - a%k;
                count += ((n-startc)/k + 1)*((n-k)/k + 1);
            }


            // for(long long b = startb;b<=n;b+=k/2){
            //     if ((a+b)%k != 0 || abs(a-b)%k != 0)
            //         continue;
            //     long long startc = k - a%k;
            //     count += (n - startc)/k + 1;
            //     cout << a << " " << b << " add ->" << (n-startc)%k + 1 << endl;
            // }
        } else{
            if(a%k !=0)
                continue;
            count += ((n-k)/k + 1)*((n-k)/k + 1);
            // startb = k;
            // if ((a+startb)%k !=0)
            //     continue;
            // long long startc = k - a%k;
            // count += ((n - startc)/k + 1)*((n-startb)/k + 1);
        }
    }
    cout << count << endl;
}


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

const int M = 4e6;
bitset <M + 7> sumy;

int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  sumy[0] = true;

  int s = 0;  
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    s += a;
    sumy = sumy | (sumy << a);
  }
  
  for (int i = 0; i <= s; ++i) {
    if (sumy[i] && 2 * i >= s) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
} 

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <string>
#include <unordered_map>
using namespace std;


int main() {

    long N, K;
    cin >> N >> K;

    long H[N];
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }

    if(N <= K){
        cout << 0 << endl;
        return 0;
    }

    long rest = N - K;

    sort(H, H+N);
    long answer = 0;
    for(int i = 0; i < rest; i++){
        answer += H[i];
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 1792
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))

bb=[[0]*w for i in range(h)]
idx=0
kk=0
for i in range(h):
    if i%2==0:
        wst=0
        wed=w
        wpt=1
    else:
        wst=w-1
        wed=-1
        wpt=-1
        
    for j in range(wst,wed,wpt):
        if kk>=a[idx]:
            idx+=1
            kk=0
        bb[i][j]=str(idx+1)
        kk+=1
        
for i in range(h):
    print(" ".join(bb[i]))    
            

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

int main(){
  int n;
  cin >> n;
  int tmp=0,co0=0,co1=0,co2=0;
  rep(i,n){
    cin >> tmp;
    if(tmp%2!=0)
      co0++;
    else if(tmp%4==0)
      co2++;
    else
      co1++;
  }
  

  if(co2>=co0 || (co1==0 && co0-co2==1)) 
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int N, X, A[10009], minx = 1000000;

int main() {
	cin >> N >> X;
	for (int i = 1; i <= N; i++) {
		cin >> A[i]; minx = min(minx, A[i]); X -= A[i];
	}
	cout << N + (X / minx) << endl;
	return 0;
}

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

int a[100000];

int main(void) {
  int i, n, ma = -1, mi = 1e9, A, single, group;
  scanf("%d",&n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    ma = max(a[i], ma); mi = min(a[i], mi);
  }

  if ((ma - mi) >= 2) {printf("No\n"); return 0;}
  if ((ma - mi) == 0) {
    if ((a[0] == (n-1)) || ((2 * a[0]) <= n)) printf("Yes\n");
    else printf("No\n");
  }

  else if ((ma - mi) == 1) {
    single = 0; group = 0; A = ma;
    sort(a, a+n);
    for (i = 0; i < n; ++i) if (a[i] == ma) group++; else single++;

    if ((single < A) && ((2 * (A - single)) <= group)) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#define rep(i, n) for(int i=0;i<n;i++)
#define N 16
#define SQRTN 4
#define LIMIT 100
using namespace std;

int limit;
int searchV[4][2] = {{0, 1},{1, 0},{0, -1},{-1, 0}};

struct Board{
  int b[N], h;
  int calcHeust(void){
    h = 0;
    for(int i = 0; i < SQRTN; i++){
      for(int j = 0; j < SQRTN; j++){
        if(b[i*SQRTN + j] == N-1) continue;
        h += abs(b[i*SQRTN + j]/SQRTN-i) + abs(b[i*SQRTN + j]%SQRTN-j);
      }
    }
    return h;
  }
};

void printBoard(Board b){
    rep(i, SQRTN){
     rep(j, SQRTN){
       cout << b.b[i*SQRTN + j];
     }
     cout << endl;
    }
}


Board currentState;

bool dfs(int depth, int prev, int cbX, int cbY){
  currentState.calcHeust();
  if ( currentState.h == 0) return true;
  if ( depth + currentState.h > limit ) return false;
  
  for (int d = 0 ; d < 4 ; d++ ){
    int sx = cbX + searchV[d][0];
    int sy = cbY + searchV[d][1];
    if ( abs(d - prev) == 2 ) continue;
    if ( sx < 0 || sy < 0 || sx >= SQRTN || sy >= SQRTN) continue;

    swap(currentState.b[cbY*SQRTN + cbX], currentState.b[sy*SQRTN + sx]);
    if (dfs(depth+1, d, sx, sy)) return true;
    swap(currentState.b[cbY*SQRTN + cbX], currentState.b[sy*SQRTN + sx]);
  }
  
  return false;
}

int idastar(Board in, int px, int py){
  for (limit=0;limit < LIMIT;limit++){
    currentState = in;
    if (dfs(0, 100, px, py)) return limit;
  }
  return -1;
}

int main(void){
  Board init;
  int p0x, p0y;
  rep(i, N){
    cin >> init.b[i];
    if (init.b[i]==0){
      init.b[i] = N;
      p0y = i/SQRTN;
      p0x = i%SQRTN;
    }
    init.b[i]--;
  }
  cout << idastar(init, p0x, p0y) << endl;;
}



Measured memory_bytes: 3116
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int n;
    cin >> n;
    bool ans = false;
    for(int i = 0 ; i <= n/4 ; i++){
        if((n-(4*i))%7 == 0){
            ans = true;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define A 0
#define T 1
#define G 2
#define C 3
#define BASE 4
#define l_ength size
using ll = long long;
using namespace std;

int genom[123][BASE][BASE][BASE];

int main(){
	int n; cin >> n;
	for( int i = A; i < BASE; ++i ){
		for( int j = A; j < BASE; ++j ){
			for( int k = A; k < BASE; ++k ){
				if(
					( i != A || j != G || k != C )
					&&
					( i != G || j != A || k != C )
					&&
					( i != A || j != C || k != G )
				){
					++genom[3][i][j][k];
				}
			}	
		}
	}
	for( int s = 4; s <= n; ++s ){
		for( int i = A; i < BASE; ++i ){
			for( int j = A; j < BASE; ++j ){
				for( int k = A; k < BASE; ++k ){
					for( int l = A; l < BASE; ++l ){
						if(
							( j != A || k != G || l != C )
							&&
							( j != G || k != A || l != C )
							&&
							( j != A || k != C || l != G )
							&&
							( i != A || j != G || k != T || l != C )
							&&
							( i != A || j != G || k != G || l != C )
							&&
							( i != A || j != T || k != G || l != C )
						){
							genom[s][j][k][l] += genom[s-1][i][j][k];
							genom[s][j][k][l] %= MOD;
						}
					}
				}	
			}
		}
	}
	int ans = 0;
	for( int i = A; i < BASE; ++i ){
		for( int j = A; j < BASE; ++j ){
			for( int k = A; k < BASE; ++k ){
				ans += genom[n][i][j][k];
				ans %= MOD;
			}	
		}
	}
	cout << ans << endl;
	return 0;
}

/*
愚直解によるシミュレーション
int n;
int ans = 0;
vector<string> vs = {
	"AGCA", "AGCG", "AGCC", "AGCT",
	"ACGA", "ACGG", "ACGC", "ACGT",
	"GACA", "GACG", "GACC", "GACT",
	"AAGC", "GAGC", "CAGC", "TAGC",
	"AACG",         "CACG", "TACG",
	"AGAC", "GGAC", "CGAC", "TGAC",
	"AGTC", "AGGC", "ATGC"	
};
	
void dfs( string str, int k ){
	if( k == n ){
		bool flag = false;
		for( int l = 0; l+4 <= n ; ++l ){
			string tmp = str.substr(l, 4);
			for( auto s : vs ){
				if( tmp == s ){
					flag = true;
					break;
				}
			}
			if( flag ) break;
		}
		if( !flag ){
			++ans;
		}
	} else {
		dfs( str + 'A', k+1 );
		dfs( str + 'G', k+1 );
		dfs( str + 'C', k+1 );
		dfs( str + 'T', k+1 );
	}
}

int main(){
	cin >> n;
	if( n > 8 ) return 0;
	dfs( "", 0 );
	if( n == 3 ) ans = 61;
	cout << ans << endl;
	return 0;
}
*/

Measured memory_bytes: 256
#dp[i][j][0,1,2,3] 上からi桁目までみた j 01 未確定確定 k でてきてない　３　５　７ 
dic = {7:4,5:2,3:1}
def getdic(n):
    return dic.get(n,0)
N = list(map(int,list(input())))

dp = [[[0]*8 for j in range(0,2,1)]for i in range(0,len(N),1)]

if N[0] in {3,5,7}:
    dp[0][0][getdic(N[0])] = 1
for i in (set(range(0,N[0]))&{3,5,7}):
    dp[0][1][getdic(i)] = 1

for i in range(1,len(N),1):
    dp[i-1][1][0]=1
    #確定から確定
    for k in range(0,8,1):
        dp[i][1][1|k] += dp[i-1][1][k]
        dp[i][1][2|k] += dp[i-1][1][k]
        dp[i][1][4|k] += dp[i-1][1][k]
    #未確定から確定
    for k in range(1,8,1):
        for n in (set(range(0,N[i]))&{3,5,7}):
            dp[i][1][getdic(n)|k] += dp[i-1][0][k]
    #未確定から未確定
    if N[i] in {7,5,3}:
        for k in range(0,8,1):
            dp[i][0][getdic(N[i])|k] += dp[i-1][0][k]

print(dp[len(N)-1][0][7]+dp[len(N)-1][1][7])


Measured memory_bytes: 62392
#include <bits/stdc++.h>
#define MOD 998244353

using namespace std;

typedef long long ll;

char str[300005];

int main() {
  int n;
  scanf("%d%s",&n,str+1);
  ll ans=1;
  int s1=0,s2=0,s3=0,s4=0;
  for(int i=1;i<=3*n;i++)
    if (str[i]=='R') {
    	if (s1&&s2) {
    		ans=ans*s4%MOD;
    		s1--;s2--;s4--;
		}
		else if (s1>s4) {
			ans=ans*(s1-s4)%MOD;
			s3++;s4++;
		}
		else if (s2>s4) {
			ans=ans*(s2-s4)%MOD;
			s3++;s4++;
		}
		else s3++;
	}
	else if (str[i]=='G') {
    	if (s1&&s3) {
    		ans=ans*s4%MOD;
    		s1--;s3--;s4--;
		}
		else if (s1>s4) {
			ans=ans*(s1-s4)%MOD;
			s2++;s4++;
		}
		else if (s3>s4) {
			ans=ans*(s3-s4)%MOD;
			s2++;s4++;
		}
		else s2++;
	}
	else {
    	if (s2&&s3) {
    		ans=ans*s4%MOD;
    		s2--;s3--;s4--;
		}
		else if (s2>s4) {
			ans=ans*(s2-s4)%MOD;
			s1++;s4++;
		}
		else if (s3>s4) {
			ans=ans*(s3-s4)%MOD;
			s1++;s4++;
		}
		else s1++;
	}
  for(int i=1;i<=n;i++) ans=ans*i%MOD;
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};

int main(){
    int N,M; cin >> N >> M;
    ll a,b;
    vector<vector<int> > g(N);
    vector<int> dist(N,MM);
    for (int i = 0; i < M; i++){
        cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    while(que.size()){
        int Top = que.front();
        que.pop();
        for (auto e : g[Top]){
            if (dist[e] == MM){
                dist[e] = dist[Top]+1;
                que.push(e);
            }
        }
    }
    if (dist[N-1] == 2){
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 13168
import std.stdio, std.algorithm, std.string, std.conv, std.array;

int read_num() {return readln.chomp.to!(int);}

void main() {
  while(true) {
    int[] line = readln.chomp.split(" ").map!(to!(int)).array;
    int times = line[0];
    int len = line[1];
    int[100000] arr;

    if (times == 0 && len == 0) break;
  
    foreach(i; 0..times)
      arr[i] = read_num;

    int max, sum;
    int next = 0;
    foreach(x; arr[0..len])
      max += x;
    sum = max;
    
    foreach(int i, x; arr[len..times]) {
      sum += x;
      sum -= arr[i];
      if (sum > max) max = sum;
    }
    writeln(max);
  }
}

Measured memory_bytes: 2284
fn abs(a: i64, b: i64) -> i64 {
    if a < b {
        b - a
    } else {
        a - b
    }
}
fn main() {
    let mut dp_table: Vec<i64> = vec![1 << 60; 100010];

    let n = get_i64_from_stdin_line().unwrap();
    let h = get_int_vector_from_stdin_line().unwrap();

    dp_table[0] = 0;

    for idx in 1..n as usize {
        let mut past: i64;

        past = dp_table[idx - 1] + abs(h[idx], h[idx - 1]);
        change_minimum(&mut dp_table[idx], past);

        if idx > 1 {
            past = dp_table[idx - 2] + abs(h[idx], h[idx - 2]);
            change_minimum(&mut dp_table[idx], past);
        }
    }

    println!("{}", dp_table[(n as usize) - 1]);
}

fn get_i64_from_stdin_line() -> Result<i64, Box<std::error::Error>> {
    // 一行読み込み
    let mut s = String::new();
    std::io::stdin().read_line(&mut s)?;

    Ok(s.trim().parse::<i64>()?)
}

fn get_int_vector_from_stdin_line() -> Result<Vec<i64>, Box<std::error::Error>> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s)?;

    let v = s
        .trim()
        .split_whitespace()
        .map(|elem| elem.parse::<i64>().unwrap())
        .collect::<Vec<i64>>();

    Ok(v)
}

fn change_minimum<T: PartialOrd>(a: &mut T, b: T) -> bool {
    if *a > b {
        *a = b;
        return true;
    }
    false
}

Measured memory_bytes: 6396
#include <stdio.h>
int main() {
	int a = 0;
	int d = 0;
	int e = 0;
	int b[20];
	int c[20];
	int count = 0;
	int ans = 0;
	scanf("%d", &a);
	for (int i = 0; i<a; i++) {
		scanf("%d", &b[i]);
	}
	for (int i = 0; i<a; i++) {
		scanf("%d", &c[i]);
	}
	for (int i = 0; i<a; i++) {
		if (b[i] - c[i] >= 0) {
			d = d + b[i];
			e = e + c[i];
		}
	}
	ans = d - e;
	printf("%d", ans);
	return 0;
}



Measured memory_bytes: 128
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> mp;

    ll ans = 0;
    rep(0, i, N)
    {
        cin >> A.at(i);
        mp[A.at(i)]++;
        ans += A.at(i);
    }

    ll Q;
    cin >> Q;
    ll b, c;
    vector<ll> num(Q);
    rep(0, i, Q)
    {
        cin >> b >> c;
        ans -= b * mp[b];
        ans += c * mp[b];
        mp[c] += mp[b];
        mp[b] = 0;
        num.at(i) = ans;
    }

    rep(0, i, Q)
    {
        cout << num.at(i) << endl;
    }
}

Measured memory_bytes: 10472
/*ex4_3
  TKC001*/

#include<stdio.h>

int main(void){
     /*west:a
       east:b
       diff:b-a,eastの塔が西から何番目か
east_height:東側の塔の高さ
       snow:積雪*/
    int west, east, diff, east_height, snow;

    scanf("%d%d", &west, &east);

    diff = east - west;
    east_height = diff*(diff+1) / 2;

    snow = east_height - east;

    printf("%d", snow);

    return 0;

}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in).useDelimiter("[\n ,]");
		int a, b, angle = 0;
		double ax = 0.0, by = 0.0;
		while (true) {
			a = sc.nextInt();
			b = sc.nextInt();

			if (a == 0 & b == 0)
				break;
			ax += Math.sin((Math.PI * angle) / 180) * a;
			by += Math.cos((Math.PI * angle) / 180) * a;
			angle += b;
		}
		System.out.printf("%d\n%d\n", (int) ax, (int) by);
		sc.close();
	}
}

Measured memory_bytes: 17196
S = [input() for _ in range(3)]
num = [0]*3
next = 0
flag = True
while(flag):
    if(num[next]==len(S[next])):
        break
    a = S[next][num[next]]
    num[next]+=1
    next = ord(a)-97

print(chr(next+ord('A')))


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    ld a,b,c;
    cin>>a>>b>>c;
    if(sqrt(a*b)<(c-a-b)/2){
        fin("Yes");
    } else fin("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    double N;
    cin >> N;
    int X[110];
    double sum = 0;
    for(int i = 0;i < N;i++){
        cin >> X[i];    
        sum += X[i];
    }
    double ave = sum / N;
    ave = round(ave);
    int ans = 0;
    for(int i = 0;i < N;i++){
        ans += (X[i] - ave) * (X[i] - ave);
    }
    cout << ans;
}

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

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char>> bomb(H, vector<char>(W));
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            char c;
            cin >> c;
            bomb.at(i).at(j) = c;
        }
    }
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (bomb.at(i).at(j) == '.'){
                char count = '0';
                for (int k = -1; k <= 1; k++){
                    for (int l = -1; l <= 1; l++){
                        if (i+k >=0 && i+k < H && j+l >=0 && j+l <W){
                            if (bomb.at(i+k).at(j+l) == '#'){
                                count++;
                            }
                        }
                    }
                }
                bomb.at(i).at(j) = count; 
            }
        }
    }
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cout << bomb.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = LLONG_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(50, vector<ll>(50, INF));

int main() {
	cin >> h >> w;
	REP(i,h)
		REP(j, w) {
		cin >> s;
		if (s == "snuke") {
			cout << static_cast<char>(j + 65) << i + 1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  string S;
  long K;
  cin >> S >> K;
  int pos = -1;
  for (int i = 0; i < S.length(); i++)
  {
    if (S[i] == '1')
      pos = i;
    else
      break;
  }
  char ans;
  if (pos < 0)
    ans = S[pos + 1];
  else
  {
    if (K <= pos + 1)
      ans = '1';
    else
      ans = S[pos + 1];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int main()
{
	cin>>n;
	for(;n--;)
	{
		string s,t,u="";cin>>s>>t;
		if(s.size()<t.size())swap(s,t);
		int a=0;
		for(int i=0;i<s.size();i++)
		{
			a+=s[s.size()-i-1]-48;
			if(i<t.size())a+=t[t.size()-i-1]-48;
			u+=a%10+48;
			a/=10;
		}
		if(a)u+=a+48;
		if(u.size()>80)
		{
			cout<<"overflow"<<endl;
		}
		else
		{
			for(int i=u.size();i--;)cout<<u[i];
			cout<<endl;
		}
	}
}




Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int main() {
	int X;

	cin >> X;

	for (int A = -118; A < 120; A++) {
		for (int B = -119; B < 119; B++) {
			long long test = pow(A, 5) - pow(B, 5);
			if (pow(A, 5) - pow(B, 5) == X) {
				cout << A << " " << B << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4028
#include<iostream>
using namespace std;
int main(void){
  int n,a,b,m=0,ans;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    if(a>m){
      ans=a+b;
      m=a;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  cout << n - k + 1 << '\n';
}

Measured memory_bytes: 256
H, W, D = map(int, input().split())
 
A = [list(map(int, input().split())) for i in range(H)]
rA = [[0 for j in range(2)] for i in range(H * W + 1)]
S = [0 for i in range(H * W + 1)]
for i in range(H):
	for j in range(W):
		rA[A[i][j]][0] = i
		rA[A[i][j]][1] = j
 
Q = int(input())
for i in range(Q):
	L, R = map(int, input().split())
	ans = 0
	for j in range(H * W) [L::D]:
		if j + D > H * W:
			break
		if S[j]:
			ans += S[j]
			break
		S[j] -= ans
		ans += abs(rA[j + D][1] - rA[j][1]) + abs(rA[j + D][0] - rA[j][0])
	for j in range(H * W)[L::D]:
		if S[j] > 0:
			break
		if j + D > H * W:
			break
		S[j] += ans
	print(S[L] - S[R])


Measured memory_bytes: 23536
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,K;
    cin>>n>>K;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    vector<bool> dp(K+1);
    for(int i=0;i<=K;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(arr[j]<=i && (!dp[i-arr[j]])) dp[i]=true;
        }
    }
    if(dp[K]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
   
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    while(true){
      int H = sc.nextInt();
      int W = sc.nextInt();
      if(H == 0 && W == 0){
        break;
      }
      for(int x = 0; x < H; x++){
        for(int y = 0; y < W; y++){
          if(x%2 == 0 && y%2 == 0 || x%2 == 1 && y%2 == 1){
            System.out.print("#");
          }else{
            System.out.print(".");
          }
        }
        System.out.println("");
      }
      System.out.println("");
    }
  }
}


Measured memory_bytes: 32640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long ans = 0;
    long c = 0;
    if(a % 2 == 0) {
      if(b % 2 == 0) {
        c = b - a;
        c /= 2;
        if(c % 2 == 0) {
          ans = b;
        } else {
          ans = b ^ 1;
        }
      } else {
        c = b - a + 1;
        c /= 2;
        if(c % 2 == 0) {
          ans = 0;
        } else {
          ans = 1;
        }
      }
    } else {
      if(b % 2 == 0) {
        c = b - a - 1;
        c /= 2;
        if(c % 2 == 0) {
          ans = a ^ b;
        } else {
          ans = (a ^ b) ^ 1;
        }
      } else {
        c = b - a;
        c /= 2;
        if(c % 2 == 0) {
          ans = a;
        } else {
          ans = a ^ 1;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
x = [int(input()) for i in range(6)]
hantei = False
for i in range(5):
    for j_ in range(1,5-i):
        j = i + j_
        if x[j]-x[i] > x[5] : 
            hantei = True
if hantei :
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3060
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// C - Write and Erase
int N;
map<int, int> A;
int ans = 0;

int main(){
    cin >> N;
    rep(i, 0, N){
        int tmp;
        cin >> tmp;
        ++A[tmp];
    }

    for(auto itr = A.begin();itr != A.end();++itr){
        if(itr->second %2 == 1) ++ans;
    }

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




Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<double> p(n);
	rep(i,n) cin >> p.at(i);
	vector<vector<double>> dp(n + 1, vector<double>(n + 2));
	dp[0][0] = 1;
	rep(i,n){
		rep(j,n){
			dp[i + 1][j + 1] += dp[i][j] * p.at(i);
			dp[i + 1][j] += dp[i][j] * (1 - p.at(i));
		}
	}
	double ans = 0;
	for(int i = n / 2 + 1; i <= n; i++){
		ans += dp[n][i];
	}
	cout << setprecision(20) << fixed << ans << endl;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main() {
    ll N;
    cin >> N;
    ll a ,b;
    cin >> a >>b;
    for(int i=1;i<N;i++){
        ll T,A;
        cin >> T >> A;
        ll x = max(ceil(((long double)a)/T ),ceil(((long double)b)/A));
        // cerr << x << endl;
        a = T*x;
        b = A*x;
    }
    cout << a+b << endl;

    return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main{
	public static class FastReader {
		BufferedReader br;
		StringTokenizer root;
		
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (root == null || !root.hasMoreTokens()) {
				try {
					root = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return root.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static long cf = 998244353;
    static final int MAX = 100000;
   // public static List<Integer>[] edges;
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = Math.max(0, a-2*b);
		out.println(ans);
	    out.close();
	}
	
}

Measured memory_bytes: 22484
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;
using namespace std;


void solve(long long N, long long K, std::vector<long long> H){
    // ソート数r
    sort(H.begin(), H.end());
    // Kこまでのスキップ数r 
    if(K >= N) {
        cout << 0 << endl;
        return;
    }


    ll res = 0;
    FORD(i, H.size()-1-K, 0) {
        res += H[i];
    }
    cout << res << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, K, std::move(H));
    return 0;
}


Measured memory_bytes: 1792