akhauriyash/Code-Regression huggingface dataset:
#define _AOJ_
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long long lint;
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,a,b) for(int i=a;i<b;++i)

int main(){
	lint h,w;
	char c;
	cin>>w>>h>>c;
	vector<string> ans(h);
	rep(i,h)ans[i].resize(w);
	rep(i,h)rep(j,w)ans[i][j]='.';
	rep(i,h)ans[i][0]=ans[i][w-1]='|';
	rep(j,w)ans[0][j]=ans[h-1][j]='-';
	ans[0][0]=ans[0][w-1]=ans[h-1][0]=ans[h-1][w-1]='+';
	ans[h/2][w/2]=c;
	rep(i,h)cout<<ans[i]<<endl;
}
//sub-EOF


Measured memory_bytes: 3124
N = 5

dish_list = []
d1_list = []

for i in range(N):
    tmp = int(input())
    dish_list.append(tmp)
    if tmp%10 == 0:
        d1_list.append(10)
    else:
        d1_list.append(tmp%10)

time = 0
for i in range(N):
    max_index = d1_list.index(max(d1_list))
    if i == 4:
        time += dish_list[max_index]
    else:
        time += (dish_list[max_index]//10) * 10
        if dish_list[max_index]%10 != 0:
            time += 10

    del dish_list[d1_list.index(max(d1_list))]
    del d1_list[d1_list.index(max(d1_list))]

print(time)




Measured memory_bytes: 3064
S = input()
T = input()
new = list(S)
main = list(T)

thelist = []

for i in range(len(new)):
    if len(new[i:i+len(main)]) < len(main):
        break
    thelist += [new[i:i+len(main)]]

counter = 0

for lists in thelist:
    second_counter = 0
    for i in range(len(main)):
        if main[i] != lists[i]:
            second_counter += 1
    if counter == 0:
        counter = second_counter
    elif second_counter < counter:
        counter = second_counter
print(counter)

Measured memory_bytes: 10820
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

void solve(){
    ll H,W,h,w; cin>>H>>W>>h>>w;

    ll ans = H*W - h*W - w*H + h*w;
    cout<<ans<<endl;    
}

signed main(){

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    FastRead;

    int t;
    t = 1;
    // cin>>t;
    
    while(t--) solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b == c) cout << 1 << endl;
  else if(a == b) cout << 2 << endl;
  else if(a == c) cout << 2 << endl;
  else if(b == c) cout << 2 << endl;
  else cout << 3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int n, m;
    cin >> n >> m;
    vi s(m), c(m);
    string res = "";
    rep(i, n) res += "?";
    bool can = true;
    rep(i, m) {
        int s; char c;
        cin >> s >> c;
        s--;
        if(res[s]!='?' && res[s]!=c) {
            can = false;
        } else {
            res[s] = c;
        }
    }

    rep(i, n) {
        if(i==0 && n!=1) {
            if(res[i]=='0') can = false;
            if(res[i]=='?') res[i] = '1';
        } else {
            if(res[i]=='?') res[i] = '0';
        }
    }

    if(can) cout << res << endl;
    else cout << -1 << endl;


    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

int n, q;
vector<int> ki[200001];
vector<ll> num(200001);
vector<ll> ans(200001);
vector<bool> searched(200001);

void dfs(int from, ll coun){
	for (int i = 0; i < ki[from].size(); i++){
		int to = ki[from][i];
		if (!searched[to]){
			searched[to] = true;
			ans[to] = coun + num[to];
			dfs(to, ans[to]);
		}
	}
	return;
}

int main(){
	cin >> n >> q;
	ki[0].push_back(1);
	for (int i = 0; i < n-1; i++){
		int a, b;
		cin >> a >> b;
		ki[a].push_back(b);
		ki[b].push_back(a);
	}
	for (int i = 0; i < q; i++){
		int p, x;
		cin >> p >> x;
		num[p] += x;
	}
	dfs(0, 0);
	for (int i = 1; i <= n; i++){
		cout << ans[i] << " ";
	}
	cout << endl;
 	return 0;
}



Measured memory_bytes: 25856
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

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

    int ans = 1e9;
    for(int i = -100; i <= 100; i++){
        int cost = 0;
        for(int j = 0; j < N; j++){
            int diff = a[j] - i;
            cost += diff * diff;
        }
        ans = min(ans, cost);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// Problem : B - Go to Jail
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin>>N;
	vector<bool> v(N);
	F0R(x,N)
	{
		int a,b;
		cin>>a>>b;
		if(a==b)
			v[x]=true;
		else
			v[x]=false;
	}
	F0R(x,N-2)
	{
		if(v[x]&&v[x+1]&&v[x+2])
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(pos, len) for(int pos=0;pos<len;pos++)
#define repp(pos, len) for(int pos=1;pos<=len;pos++)

#define INF 987654321
#define IINF 2987654321987654321
#define MOD 998244353

ll inverse(ll a, ll m) {
	ll m0 = m, t, q;
	ll x0 = 0, x1 = 1;
	if(m == 1) return 0;
	while(a > 1) {
		// q is quotient
		q = a/m, t = m;
		// m is remainder now
		m = a % m, a = t;
		t = x0;
		x0 = x1 - q * x0;
		x1 = t;
	}
	// Make x1 positive
	if(x1 < 0) x1 += m0;
	return x1;
}

inline ll madd(ll a, ll b) { return (a+b)%MOD; }
inline ll msub(ll a, ll b) { return (a-b+MOD)%MOD; }
inline ll mmul(ll a, ll b) { return (a*b)%MOD; }
inline ll mdiv(ll a, ll b) { return (a*inverse(b, MOD))%MOD; }

const int MAXN = 2050;
ll C[2*MAXN][2*MAXN];
void preprocess() {
	C[0][0] = 1;
	for(int n = 1; n < 2*MAXN; n++) {
		C[n][0] = 1;
		for(int k = 1; k <= n; k++)
			C[n][k] = madd(C[n-1][k-1], C[n-1][k]);
	}
}

inline ll H(ll n, ll r) { 
	if(r < 0) return 0;
	else return C[n+r-1][r];
}

ll n, k;
void readInput() {
	scanf("%lld%lld", &k, &n);
}

ll f(ll n, ll k, ll t) {
	ll ans = H(k, n);
	for(ll i = 1; i <= t; i++) {
		ll val = mmul(C[t][i], H(k, n-2*i));
		if(i&1) ans = msub(ans, val);
		else ans = madd(ans, val); 
	}
	return ans;
}

void solve() {
	if(k == 1) {
		printf("0\n");
		return;
	}

	for(int x = 2; x <= 2*k; x++) {
		if(x&1) {
			ll t = (x-1 <= k) ? x/2 : k-(x/2);
			printf("%lld\n", f(n, k, t));
		} else {
			ll t, y = x/2;
			if(k >= 2*y-1) t = y-1;
			else if(k > y) t = k-y;
			else t = 0;
			printf("%lld\n", madd(f(n, k-1, t), f(n-1, k-1, t)));
		}
	}
}

int main() {
	//freopen("output.txt", "w", stdout);
	preprocess();
	readInput();
	solve();
}

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

int h, w, k;

string s[310];
int ans[310][310] = {};

void nuri(int y, int &kk){

    int old = 0;
    for(int x = 0;x < w;x++){
        if(s[y][x] == '#'){
            for(int i = old;i <= x;i++){
                ans[y][i] = kk;
            }
            kk++;
            old = x+1;
        }
    }

    for(int i = old;i < w;i++){
        ans[y][i] = kk-1;
    }

    return;
}

int main(){
    cin >> h >> w >> k;

    int st = -1;
    for(int i = 0;i < h;i++){
        cin >> s[i];

        for(int j = 0;j < w;j++){
            if(s[i][j] == '#'){
                st = i;
            }
        }
    }

    int kk = 1;
    int old = 0;
    nuri(st, kk);

    for(int i = st-1;i >= 0;i--){
        if(s[i].find('#') != string::npos){
            nuri(i, kk);
        }else{
            for(int j = 0;j < w;j++){
                ans[i][j] = ans[i+1][j];
            }
        }
    }

    for(int i = st+1;i < h;i++){
        if(s[i].find('#') != string::npos){
            nuri(i, kk);
        }else{
            for(int j = 0;j < w;j++){
                ans[i][j] = ans[i-1][j];
            }
        }
    }

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cout << ans[i][j];
            if(j < w-1){
                cout << " ";
            }else{
                cout << endl;
            }
        }
    }

    return 0;
}

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

int main(){
  int n;

  while(1){
    cin >> n;
    if( n == 0) break;
    for(int i = 0; i < n; i++){
      int m,e,j;
      cin >> m >> e >> j;
      double a = (m+e+j)/3;
      //      cout << "average " << a << endl;

      if(m == 100 || e == 100 || j == 100){
	cout << "A" << endl;
      }
      else if( double((m+e))/2 >= 90){
	cout << "A" << endl;
      }
      else if(a >= 80 ){
	cout << "A" << endl;
      }
      else if(a >=70 ){
	cout << "B" << endl;
      }
      else if(a >=50 ){
	if(m >= 80 || e >= 80){
	  cout << "B" << endl;
	}
	else{
	  cout << "C" << endl;
	}
      }
      else{
	cout << "C" << endl;
      }
    }

  }


  return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <string.h>

char s[105];
int t=1;

int main()
{
	scanf("%s",s);
	for (int i=0; i<=strlen(s)-1; i++)
	{
		if (i%2==0 && s[i]=='L')
		{
			t=0;
			break;
		}
		if (i%2==1 && s[i]=='R')
		{
			t=0;
			break;
		}
	}
	if (t)
		printf("Yes");
	else printf ("No");
	return 0;
}

Measured memory_bytes: 128
def main():
  A, B, K = map(int, input().split())

  if K - A <= 0:
      print('{} {}'.format(A-K, B))
  else:
      if (B - (K - A)) >= 0:
          print('{} {}'.format(0, (B - (K - A))))
      else:
          print('{} {}'.format(0, 0))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, k;
int vw[2005][2005];
int vb[2005][2005];
int wsum[2005][2005];
int bsum[2005][2005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k;

  int sum = 0, black = 0;
  REP(i, n) {
    int a, b;
    char c;
    cin >> a >> b >> c;

    if(c == 'W') vw[b % (2 * k)][a % (2 * k)]++, sum++;
    else vw[b % (2 * k)][(a) % (2 * k)]--, sum--, black++;
  }

  REP(i, 2 * k) {
    ll tmpw = 0;
    REP(j, 2 * k) {
      tmpw += vw[i][j];
      wsum[i + 1][j + 1] = tmpw;
    }
  }

  REP(i, 2 * k) {
    ll tmpw = 0;
    REP(j, 2 * k) {
      tmpw += wsum[j + 1][i + 1];
      wsum[j + 1][i + 1] = tmpw;
    }
  }

  ll ans = 0;
  REP(i, k + 1) REP(j, k + 1) {
    ll a = wsum[k + i][k + j] - wsum[i][k + j] - wsum[k + i][j] + wsum[i][j];
    ll b = wsum[i][j];
    ll c = wsum[k * 2][j] - wsum[k + i][j];
    ll d = wsum[i][k * 2] - wsum[i][k + j];
    ll e = wsum[k * 2][k * 2] - wsum[k + i][k * 2] - wsum[k * 2][k + j] + wsum[k + i][k + j];
    ll tmp = a + b + c + d + e;
    ans = max(ans, max(tmp, sum - tmp));
  }
  ans += black;
  cout << ans << endl;
}


Measured memory_bytes: 34432
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
using namespace std;

int LIS(vector<int> elem)
{
    int i;
    list<int> lis;

    lis.push_back(elem[0]);

    for (i = 1; i < elem.size(); i++) {
        if (lis.back() < elem[i]) {
            lis.push_back(elem[i]);
        }
        else {
            *(lower_bound(lis.begin(), lis.end(), elem[i])) = elem[i];
        }
    }

    return(lis.size());
}

int main(void)
{
    int i, tmp;
    int num;
    int ret;
    vector<int> elem;

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        scanf("%d", &tmp);
        elem.push_back(tmp);
    }

    ret = LIS(elem);

    printf("%d\n", ret);

    return 0;
}

Measured memory_bytes: 4956
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

const int MAX = 3000005;
int fac[MAX], inv[MAX], finv[MAX];

void pre(){
  inv[1]=1;
  for (int i = 2; i <MAX ; i++)
  {
    inv[i]=inv[mod%i]*(mod-mod/i)%mod;
  }
  fac[0]=finv[0]=1;
  for (int i = 1; i < MAX; ++i)
  {
    fac[i]=fac[i-1]*i%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
int ncr(int n, int r){
  if(r<0||r>n)return 0;
  return fac[n]*finv[r]%mod*finv[n-r]%mod;
}

signed main(){
    pre();
    
    int r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    int ans = 0;

    for(int i = r1; i<=r2;i++){
        int cur = (c2+1)*ncr(i+c2+1, c2+1)%mod - (c1)*ncr(c1+i,c1)%mod;
        cur = (cur+mod)%mod;
        cur = cur*inv[i+1]%mod;
        ans = (ans+cur)%mod;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 70528
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;


int main(){
    int n; cin>>n;
    if(n==3 || n==5 || n==7) cout<<"YES";
    else cout<<"NO";
}

Measured memory_bytes: 256
import sys
N,M=list(map(int, input().split()))

s=[list(map(int, input().split())) for _ in range(M)]

a=["a" for _ in range(N)]

if len(s)==0 and N==1:
    print(0)
    sys.exit()
    
elif len(s)==0:
    print(10**(N-1))
    sys.exit()

for i in s:
    if i[1]==0 and i[0]==1 and N!=1:
        print(-1)
        sys.exit()
   
    if a[i[0]-1]=="a":
        a[i[0]-1]=str(i[1])
    
    elif a[i[0]-1]!="a" and a[i[0]-1]==str(i[1]):
        continue
        
    elif a[i[0]-1]!="a" and a[i[0]-1]!=str(i[1]):
        print(-1)
        sys.exit()

num=[int(i) if i!="a" else 0 for i in a ]
    
if N==1:
    print(int(num[-1]))
elif N==2:
    ans=10*int(num[0])+int(num[1])
    if ans//10==0:
        ans+=10
    print(ans)
elif N==3:
    ans=100*int(num[0])+10*int(num[1])+int(num[2])
    
    if ans//100==0:
        ans+=100
    print(ans) 

        
        
    

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

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

    string a, b;
    cin >> a >> b;

    a += b;

    int x = atoi(a.c_str());

    for(int i = 1; i < 400; i++) {
        if(i * i == x) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
import Data.List

main = do
  [x,y,z,k] <- readWordsLn
  as <- readWordsLn
  bs <- readWordsLn
  cs <- readWordsLn
  putStr $ solve x y z k as bs cs

solve x y z k as' bs' cs' = unlines.map show$take k ans
  where
  ans = sortBy (flip compare)
    [ as!!(a-1) + bs!!(b-1) + cs!!(c-1)
    | a <- [1..min k x]
    , b <- [1..min (div k a) y]
    , c <- [1..min (div k (a*b)) z] ]
  [as,bs,cs] = map (sortBy $ flip compare) [as',bs',cs']

readWordsLn = map read.words<$>getLine

Measured memory_bytes: 12668
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int N;
    cin >> N;
    int a[100010];
    int amin[100010];
    int amax[100010];
    vector<int> x(100010, 0);
    int X = 0;
    int countx = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i]; 
        amin[i] = a[i] - 1;
        amax[i] = a[i] + 1;  
    }

    for(int i = 0; i < N; i++){

        if(amin[i] >= 0)
            x[amin[i]]++;

        x[a[i]]++;
        x[amax[i]]++;
    }
    X = max_element(x.begin(), x.end()) - x.begin();
    for(int j = 0; j < N; j++){
        if(-1+X <= a[j] && a[j] <= X+1){
            countx++;
        }
    }

    cout << countx << endl;
    
    return 0;
}

Measured memory_bytes: 4796
from functools import lru_cache


def mod(x):
    return x % (10 ** 9 + 7)


@lru_cache(maxsize=None)
def dp(i, j, k):
    if i == 0:
        if k == 0 and j == 0:
            return 1
        else:
            return 0
    elif k < 0 or j < 0 or i < j:
        return 0
    else:
        return mod(
            (2 * j + 1) * dp(i - 1, j, k - 2 * j)
            + (j + 1) * (j + 1) * dp(i - 1, j + 1, k - 2 * j)
            + dp(i - 1, j - 1, k - 2 * j)
        )


n, k = map(int, input().split())
print(dp(n, 0, k))


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

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); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N, K; cin >> N >> K;
	vll A(N), F(N); cin >> A >> F;

	sort(begin(A), end(A));
	sort(rbegin(F), rend(F));
	ll ng = -1, ok = 1e15;
	while (abs(ng - ok) > 1) {
		ll x = (ng + ok) >> 1;
		vll dp(N+1, LLINF);
		dp[0] = 0;
		for (int i = 0; i < N; i++) {
			ll val = x / F[i];
			chmin(dp[i+1], dp[i] + max(0ll, A[i] - val));
		}
		if (dp[N] <= K) ok = x;
		else ng = x;
	}
	cout << ok << endl;		
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int n;
	cin >> n;
	int hmax=0,h,ret=0;
	REP(i,n){
		cin >> h;
		if(hmax <= h){
			ret++;
		}
		hmax = max(hmax,h);
	}
	println(ret);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<climits>
#include<algorithm>
#include<utility>
using namespace std;

int main(void)
{
	int N, K;
	cin >> N >> K;

	string S;
	cin >> S;

	vector<pair<int, int>> s;
	for (int i = 0; i < N; i++) {
		int cnt = 1;
		for (; i + 1 < N && S[i + 1] == S[i]; i++)
			cnt++;

		int state = (S[i] == '1');
		s.push_back(make_pair(state, cnt));
	}

	vector<int> imos(s.size() + 1, 0);
	for (int i = 0; i < (int)s.size(); i++)
		imos[i + 1] += imos[i] + s[i].second;

	int ans = 0;
	for (int i = 0; i < (int)s.size(); i++) {
		int j;
		if (s[i].first == 0) {
			j = min((int)imos.size() - 1, i + 2 * K);
		}
		else {
			j = min((int)imos.size() - 1, i + 2 * K + 1);
		}
		
		ans = max(ans, imos[j] - imos[i]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String[] nums = {"0","0"};
      int[] matChain = new int[n+1];

      for(int i=0; i<n; i++) {
        nums = br.readLine().split(" ");
        matChain[i] = Integer.parseInt(nums[0]);
      }
      matChain[n] = Integer.parseInt(nums[1]);


      System.out.println( matrixChainMultiplication(matChain) );
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }

  private int matrixChainMultiplication(int[] p) {
    int n = p.length-1;
    int[][] m = new int[n+1][n+1];
    // for(int i=1; i<=n; i++) {
    //   m[i][i] = 0;
    // }

    for(int l=2; l<=n; l++) {
      for(int i=1,j=0; i<=n-l+1; i++) {
        j = i+l-1;
        m[i][j] = Integer.MAX_VALUE;
        for(int k=i,c=0; k<=j-1; k++) {
          c = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
          m[i][j] = m[i][j] < c ? m[i][j] : c;
        }
      }
    }

    return m[1][n];
  } 
}


Measured memory_bytes: 24364
/*
useful stl
array<ll,size> ar;         //size(),front(),back(),fill(),empty()
deque<ll> d                //push_back(),push_front(),pop_front(),pop_back()
vector<ll> v(size,val);    //push_back(),*max_element(v.begin(),v.end()),accumulate(v.begin(),v.endaa(),0),pop_back()
stack<ll> g;               //push(),pop(),top(),size(),empty()         LIFO
queue<ll> q;               //push(),size(),front(),back(),empty()      FIFO
priority_queue<ll> pq
*/
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

const long long mod = 1e7+9;

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

    long long k,a,b;
    cin>>k>>a>>b;
    long long q=b/k;
    if(q*k <a || q*k>b)
        cout<<"NG";
    else
        cout<<"OK";

    return 0;
}

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

int main() {
    int n,y;
    cin >> n >> y;
    y/=1000;
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= n; j++) {
            if(n-i-j>=0 && 10*i+5*j+n-i-j==y){
                cout << i << ' ' << j << ' ' << n-i-j << endl;
                return 0;
            }
        }
    }
    cout <<"-1 -1 -1" << endl;


    return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, r, p;
string s, t;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
}

int main() {
	fastio; randomINT;
	//cin>>t;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 238028
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
using namespace std;
typedef long long ll;

int main()
{
    string S;
    cin >> S;
    if (S.at(0) == '9' || S.at(1) == '9')
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main (){
	long long x;cin>>x;
	long long ans=x/11;
	ans*=2;
	if(x%11>6){
		ans+=2;
	}else if(x%11<=6&&x%11>0){
		ans+=1;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		// practice contest

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int answer = 0;

		if ((a >= 1 && a <= 9) && (b >= 1 && b <= 9)) {
			answer = a * b;
			System.out.println(answer);
		} else {
			System.out.println(-1);
		}
	}
}


Measured memory_bytes: 23252
S = input()

max_len = 0

for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        bs = S[i:j]
        is_acgt = True
        for c in 'BDEFHIJKLMNOPQRSUVWXYZ':
            if c in bs:
                is_acgt = False

        if is_acgt:
            length = len(bs)
            if length > max_len:
                max_len = length

print(max_len)

Measured memory_bytes: 9008
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int MOD = 1e9 + 7;

ll N,M,K,H,W;

int main(){
	cin >> N >> M >> K;
	if(N-K < 0) cout << 0 << " " << max(0LL, N+M-K);
	else cout << N-K << " "<< M;
	return 0;
}




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

int getN(string N, int K, bool noLimit){
    int n = N.size();
    if(n<K) return 0;
    int m = noLimit? 9 : stoi(N.substr(0, 1));
    if(n==1 && K==1) return m;
    N = N.substr(1);
    int res = 0;
    if(m==0){
        res += getN(N, K, false);
    }else{
        res += getN(N, K, true);
    }
    if(K==1){
        res += m;
    }else{
        if(noLimit){
            res += 9 * getN(N, K-1, true);
        }else{
            if(m>0){
                res += (m-1) * getN(N, K-1, true);
                res += getN(N, K-1, false);
            }
        }
    }
    return res;
}

int main()
{
    string N;
    cin >> N;
    int K;
    cin >> K;
    auto res = getN(N, K, false);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(void){
  int n,i,j,k,v,A[N];

  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d",&A[i]);

  for(j=1;j<=n;j++){
      v = A[j];
      i = j-1;
      while(i>0 && A[i]>v){
          A[i+1]=A[i];
          i--;
        }
      A[i+1] = v;
      for(k=1;k<=n;k++){
        if(k == n)printf("%d\n",A[k]);
        else printf("%d ",A[k]);
      }
    }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    string S;
    cin >> S;
    Yes(1 <= character_count(S, 'A') && character_count(S, 'A') <= 2);
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <queue>

using namespace std ;

typedef long long LL ;

priority_queue<LL,deque<LL>,greater<LL> > h ;
priority_queue<LL,deque<LL>,greater<LL> > t ;
LL v[2333];
LL a[2333];
LL b[2333];
LL n , k , q ;
LL res;

int main ()
{
	LL i , j ;
	LL x , s ;
	res=9223372036854775807;
	scanf("%lld%lld%lld",&n,&k,&q);
	for ( i=1 ; i<=n ; i++ ) scanf("%lld",a+i),b[i]=a[i];
	sort(b+1,b+n+1);
	for ( s=1 ; s<=n ; s++ ) 
	{
		fill(v+1,v+n+1,0);
		while ( !h.empty() ) h.pop();
		x=b[s];
		LL m=0;
		for ( i=1 ; i<=n ; i++ )
			if ( a[i]<x ) v[++m]=i;
		v[++m]=n+1;
		for ( i=1 ; i<=m ; i++ )
		{
			if ( v[i]-v[i-1]-1<k ) continue;
			for ( j=v[i-1]+1 ; j<v[i] ; j++ ) t.push(a[j]);
			LL tmp=v[i]-v[i-1]-k;
			for ( j=1 ; j<=tmp ; j++ ) h.push(t.top()),t.pop();
			while ( !t.empty() ) t.pop();
		}
		for ( i=1 ; i<q ; i++ )	
		{
			if ( h.empty() ) goto end;
			h.pop();
		}
		if ( h.empty() ) goto end;
		res=min(res,h.top()-x);
		end:;
	}
	printf("%lld\n",res);
	return 0 ;
}

Measured memory_bytes: 384
long a,b,c;o;
main(A){
	b=c=-1e18;
	for(scanf("%*d%d",&a);~scanf(" %c%d",&o,&A);)
		b=o%3?a+=A,fmax(b-A,c+=A):(a=fmax(a-A,c=b+A));
	printf("%ld",a);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
using namespace std;

signed main()
{
	int a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	if(v*t-abs(b-a)>=w*t)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

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

int main() {
    int n, a;
    int max_e = 0, max_o = 0, sec_e = 0, sec_o = 0;
    int e, o, e2, o2;
    cin >> n;
    map<int ,int> even, odd;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        (i % 2 == 1 ? odd : even)[a]++;
    }
    for (pair<int,int> p :even) if (max_e < p.second) max_e = p.second,e = p.first;
    for (pair<int, int> p : even) {
        if (p.first == e)continue;
        if (sec_e < p.second)sec_e = p.second, e2 = p.first;
    }
    
    for (pair<int, int> p : odd) if (max_o < p.second)max_o = p.second, o = p.first;
    for (pair<int, int> p : odd) {
        if (p.first == o) continue;
        if (sec_o < p.second) {
            sec_o = p.second;
            o2 = p.first;
        }
    }
    
    cout << (e != o ? ((n / 2) - max_e) + ((n + 1) / 2 - max_o) : min((((n / 2) - sec_e) + ((n + 1) / 2 - max_o)),
                                                                      (((n / 2) - max_e) + ((n + 1) / 2 - sec_o))))
         << endl;
}


Measured memory_bytes: 4992
import qualified Data.ByteString.Char8 as C
import Data.List

main = do
    n <- readLn
    (a,b,c) <- loop n (0,0,0)
    print $ max a (max b c)

loop 0 (a,b,c) = return (a,b,c)
loop n (a,b,c) = do
    [a',b',c'] <- unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine
    loop (n-1) (max b c + a', max a c + b', max a b + c')

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

const int N = 1e5;
vector <int> G[N + 7];
int n, m;
int odw[N + 7];
int x, y;
vector <int> resx;
vector <int> resy;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 1; i <= m; ++i) {
		int a, b;
		cin >> a >> b;
		x = a;
		y = b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	odw[x] = odw[y] = 1;
	resx.push_back(x);
	resy.push_back(y);
	
	while(1) {
		int ny = 0;
		for(auto u : G[y]) {
			if(!odw[u]) ny = u;
		}
		if(!ny) break;
		resy.push_back(ny);
		y = ny;
		odw[y] = 1;
	}	
	
	while(1) {
		int nx = 0;
		for(auto u : G[x]) {
			if(!odw[u]) nx = u;
		}
		if(!nx) break;
		resx.push_back(nx);
		x = nx;
		odw[x] = 1;
	}	
	
	int wyn = resx.size() + resy.size();
	cout << wyn << endl;
	for(auto u = resx.rbegin(); u != resx.rend(); ++u) cout << *u << ' ';
	for(auto u : resy) cout << u << ' ';
	cout << endl;
	return 0;	
}

Measured memory_bytes: 7160
import java.math.BigInteger;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int c=sc.nextInt();
		for(int i =0;i<c;i++){
			String a = sc.next();
			String b = sc.next();
			if(a.length()>80||b.length()>80){
				System.out.println("overflow");
				continue;
			}
			BigInteger x = new BigInteger(a).add(new BigInteger(b));
			String str = x.toString();
			if(str.length()>80){
				System.out.println("overflow");
				continue;
			}
			System.out.println(x);
		}
		

		}
	}	

Measured memory_bytes: 26396
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int x[] = {a,b,c};
    sort(x,x+3);
    cout << x[0] + x[1] << endl;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s;
  cin >> s;

  bool ok = false;

  if(s == "keyence"){
    cout << "YES" << endl;
    return 0;
  }

  for(int i = 0; i < s.length(); i++){
    for(int j = i; j < s.length(); j++){
      string t = "";
      for(int k = 0; k < s.length(); k++){
        if(k < i || k > j){
          t += s[k];
        }
      }
      if(!ok && t == "keyence"){
        ok = true;
        cout << "YES" << endl;
        break;
      }
    }
  }

  if(!ok){
    cout << "NO" << endl;
  }

  return 0;
}


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

vector< int > vint;
vector< string > vstr;
vector< pair< int,int > > vint_p;

set< int > si;
set< string > ss;
set< pair< int,int > > si_pair;

int main(){
  int n,num[4],cnt=0;
  cin >> n;

  num[0]=n%10;
  n/=10;
  num[1]=n%10;
  n/=10;
  num[2]=n%10;
  n/=10;
  num[3]=n%10;
  n/=10;

  if(num[0] == num[1] && num[1] == num[2]) cout << "Yes" << endl;
  else if(num[1] == num[2] && num[2] == num[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> a(M);

    int sum = 0;
    for(int i=0; i<M; ++i) cin >> a[i];

    for(int i=0; i<M; ++i){
        sum += a[i];
    }
    int res = N -sum;
    if(res < 0) res = -1;

    cout << res << endl;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr int INF = 1'001'001'001;
int N, T;
std::vector<P> v;
int A[3100], B[3100];
int dp[3100][3100];

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

  std::cin >> N >> T;

  for(int i=0;i<N;++i){
      int a, b;
      std::cin >> a >> b;

      v.emplace_back(a, b);
  }

  std::sort(v.begin(), v.end());

  for(int i=0;i<N;++i){
      std::tie(A[i], B[i]) = v[i];
  }

  std::fill(&dp[0][0], &dp[0][0] + 3100 * 3100, -INF);
  dp[0][0] = 0;

  for(int i=0;i<N;++i){
      for(int j=0;j<=T;++j){
          dp[i+1][j] = std::max(dp[i+1][j], dp[i][j]);

          if(j < T){
              int t = std::min(j + A[i], T);

              dp[i+1][t] = std::max(dp[i+1][t], dp[i][j] + B[i]);
          }
      }
  }

  int res = *std::max_element(dp[N], dp[N] + T + 1);
  std::cout << res << std::endl;
}


Measured memory_bytes: 38016
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

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();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef pair<int, TIII> QIIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b,c))
#define MQ(a,b,c,d) MP(a, MT(b,c,d))
#define Q1 first
#define Q2 second.first
#define Q3 second.second.first
#define Q4 second.second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1e-8
#define MOD 1000000007

int solve(int p, int q, int r, int a, int n){
	if(n==0)return 0;
	int ret = 0;
	for(int i=r; i<=a; i++){
		int np = i*p-q;
		int nq = i*q;
		if(np<0)continue;
		else if(np==0)ret++;
		else ret += solve(np, nq, i, a/i, n-1);
	}
	return ret;
}

int main(){
	int p,q,a,n;
	while(cin>>p>>q>>a>>n, p)cout << solve(p,q,1,a,n)<<endl;
	return 0;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<string> temp (N);
	vector<string> test (M);
	for(int i = 0;i < N;i++){
		cin >> temp.at(i);
	}
	for(int i = 0;i < M;i++){
		cin >> test.at(i);
	}
	
	for(int i = 0;i < (N-M+1)*(N-M+1);i++){
		for(int j = 0;j <= M*M;j++){
			if(j == M*M){
				cout << "Yes" << endl;
				return 0;
			}
			else{
				if(test.at(j/M).at(j%M) != temp.at(i/(N-M+1)+j/M).at(i%(N-M+1)+j%M)){
					break;
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print("{} {}".format(i+1, i+2))
        exit()
    if i < len(s) - 2:
        if s[i] == s[i+2]:
            print("{} {}".format(i+1, i+3))
            exit()
print("{} {}".format(-1,-1))

Measured memory_bytes: 39536
#include<bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<ll,ll> pi;

ll fastSum(ll n){
    return (n*(n+1ll))>>1;
}

int main(){
    int n,m;
    scanf(" %d %d",&n,&m);
    printf("%lld\n",fastSum(max(n-1,0))+fastSum(max(m-1,0)));
    return 0;
}


Measured memory_bytes: 256
import Data.List

deflist :: [Int] -> [Int] -> [Int]
deflist [] [] = []
deflist [] _ = error "deflistError"
deflist _ [] = error "deflistError"
deflist (a:as) (b:bs) = (a-b) : (deflist as bs)

check :: Int -> [Int] -> Int
check _ [] = error "checkError"
check m (p:ps) = if m == 0 then 0
   else if (m+p) >= 0 then 1 else 1 + (check (m+p) ps)

main :: IO ()
main = do
   getLine
   as  <- map read.words <$> getLine
   bs  <- map read.words <$> getLine
   let defs = deflist as bs
       ms = filter (< 0) defs
       ps = reverse $ sort $ filter (> 0) defs
   if sum as < sum bs then print (-1)
     else do
       putStrLn $ show $ (check (sum ms) ps) + (length ms)


Measured memory_bytes: 101756
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,long double> Pi;
typedef pair <long double,int> Pd;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
vector<P> seg(n);
ll m=0;
P p;
for(int i=0;i<n;i++){
    cin>>seg[i].fi>>seg[i].se;
    if(chmax(m,seg[i].se-seg[i].fi+1)){
        p.fi=seg[i].fi;
        p.se=-seg[i].se;
    }
    seg[i].se=-seg[i].se;
}
sort(all(seg));
vector<ll> lsum(n,0),rsum(n,0);
ll l=0,r=-inf;
ll tmp=0;
for(int i=0;i<n;i++){
    chmax(l,seg[i].fi);
    chmax(r,seg[i].se);
    if(l>-r){
        tmp=0;
        break;
    }
    lsum[i]=(-r-l)+1;
    if(p!=seg[i])tmp=(-r-l)+1;
}
l=0,r=-inf;
for(int i=n-1;i>=0;i--){
    chmax(l,seg[i].fi);
    chmax(r,seg[i].se);
    if(l>-r)continue;
    rsum[i]=(-r-l)+1;
}
ll ans=0;
for(int i=0;i<n-1;i++){
    ans=max(ans,lsum[i]+rsum[i+1]);
    //cout<<lsum[i]<<" "<<rsum[i]<<" "<<lsum[i]+rsum[i]<<endl;
}
chmax(ans,tmp+m);
cout<<ans<<endl;
}



Measured memory_bytes: 3456
<?php
  
$x = trim(fgets(STDIN));

while($ans == 0){
  $c = 0;
  for($j=$x; $j>1; $j--){
    if ($x%$j==0) $c++;
    if ($c > 1) break;
  }
  if ($c == 1){
    $ans = $x;
    break;
  }
  $x++;
}

echo $ans;
  
?>

Measured memory_bytes: 4728