akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#ifdef DEBUG
    #include "debug.hpp"
#endif

using namespace std;

#define all(c) (c).begin(), (c).end()
#define traverse(c, it) for(auto it = (c).begin(); it != (c).end(); it++)
#define rep(i, N) for(int i = 0; i < (N); i++)
#define rep1(i, N) for(int i = 1; i <= (N); i++)
#define rep2(i, s, e) for(int i = (s); i <= (e); i++)
#define rep3(i, s, e, d) for(int i = (s); (d) >= 0 ? i <= (e) : i >= (e); i += (d))
#define pb push_back


#ifdef DEBUG
    #define debug(x...) {dbg::depth++; string dbg_vals = dbg::to_string(x); dbg::depth--; dbg::fprint(__func__, __LINE__, #x, dbg_vals);}
    #define light_debug(x) {dbg::light = 1; dbg::dout << __func__ << ":" << __LINE__ << "  " << #x << " = " << x << endl; dbg::light = 0;}
#else
    #define debug(x...)
    #define light_debug(x) 
#endif


using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

ll A[200005];

signed main(){

    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    #ifdef DEBUG
        freopen("debug", "w", stderr);
    #endif
    
    int N, K;
    cin >> N >> K;

    rep(i, N) cin >> A[i];

    auto chk = [&](ll len){
        ll k = 0;
        for(ll a : A)
            k += (a - 1) / len;
        return k <= K;
    };
    
    ll s = 1, e = 1000000001LL;
    while(s < e){
        ll m = (s + e) >> 1;
        if(!chk(m))
            s = m + 1;
        else
            e = m;
    }

    cout << s << '\n';

    #ifdef DEBUG
        dbg::dout << "\nExecution time: " << clock() << "ms\n";
    #endif

    return 0;
}
 

Measured memory_bytes: 5124
N, M = map(int, input().split())
A  = []

for _ in range(M):
    a = int(input())
    A.append(a)

def is_enabled():
    _a = -1
    for a in A:
        if _a + 1 == a:
            return False
        _a = a
        
    return True


X =[1, 2]
BAD = [-1] + A + [N+1]

def pattern(a, b):
    a_b = b-a
    if a_b == 0:
        return 1
    if len(X) >= a_b:
        return X[a_b-1]
    else:
        while len(X) <= a_b:
            X.append(X[-1]+X[-2])
        return X[a_b-1]


if is_enabled() == False:
    print(0)
else:
    ans = 1
    for a, b in zip(BAD[:-1], BAD[1:]):
        ans *= pattern(a+1, b-1)
        
    ans = ans %  1000000007
    print(ans)
 
    
    

Measured memory_bytes: 471688
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;

bool flag = true;

void bai(int N){
	if(N%3==0) {
		cout << ' ' << N;
		flag = false;
	}
}

void three(int N){
	int x=N;
	while(true){
		if (x%10 == 3) {
			cout << ' ' << N;
			break;
		}
		
		x /= 10;
		if (x==0) break;
	}
}


int main(){
	int n;
	cin >> n;
	
	for (int i=1; i<=n; i++){
		bai(i);
		if(flag) three(i);
		flag = true;
	}
	cout << endl;
}

Measured memory_bytes: 3068
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

#define INF 100000000
#define x first
#define y second
#define f first
#define s second

using namespace std;

typedef pair<int,int>P;
typedef pair<P,int>P3;

string grid[20];
int g[11][11],cost[21][21],h,w;
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
vector<P>v;

void bfs(P st,int id){
	
	queue<P3>que;
	que.push(P3(st,0));
	while(!que.empty()){
		P3 now=que.front();
		que.pop();
		if(cost[now.f.y][now.f.x]<=now.s)continue;
		
		cost[now.f.y][now.f.x]=now.s;
	
		if(grid[now.f.y][now.f.x]=='*')
			for(int i=0;i<v.size();i++)
				if(v[i]==now.f)g[id][i]=now.s;
		
		for(int i=0;i<4;i++){
			int nx=now.f.x+dx[i],ny=now.f.y+dy[i];
			if(nx<0 || ny<0 || w<=nx || h<=ny || grid[ny][nx]=='x')continue;
			que.push(P3(P(nx,ny),now.s+1));
		}
	}
}

int main(void){
	
	while(cin >> w >> h,h|w){
		
		for(int i=0;i<h;i++)cin >> grid[i];
		fill(g[0],g[11],INF);
		v.clear();
		P st;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(grid[i][j]=='o')st.x=j,st.y=i,v.push_back(st);
				if(grid[i][j]=='*')v.push_back(P(j,i));
			}
		}
		
		for(int i=0;i<v.size();i++){
			fill(cost[0],cost[21],INF);
			bfs(v[i],i);
		}
		
		vector<P3>tmp;
		int stid;
		for(int i=0;i<v.size();i++){
			if(v[i]!=st)tmp.push_back(P3(v[i],i));
			else if(v[i]==st)stid=i;
		}
		
		sort(tmp.begin(),tmp.end());
		int ans=INF;
		do{
			int cnt=0;
			for(int i=0;i<tmp.size()-1;i++)cnt+=g[tmp[i].s][tmp[i+1].s];
			ans=min(ans,g[stid][tmp[0].s]+cnt);
		}while(next_permutation(tmp.begin(),tmp.end()));
		if(ans>=INF)cout << -1 << endl;
		else cout << ans << endl;
	}
	
	
	return 0;
}

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

int main(){
  int r,c,i,j,temp=0;
  cin>>r>>c;
  int a[r+1][c+1];
  for (i=0;i<r;i++){
    for (j=0;j<c;j++)cin>>a[i][j];
  }
  for (i=0;i<r;i++){
    for (j=0;j<c;j++){
      temp+=a[i][j];
    }
    a[i][c]=temp;
    temp=0;
  }
  for (j=0;j<c+1;j++){
    for (i=0;i<r;i++){
      temp+=a[i][j];
    }
    a[r][j]=temp;
    temp=0;
  }
  for (i=0;i<r+1;i++){
    for (j=0;j<c+1;j++){
      if (j)cout<<' ';
      cout<<a[i][j];
    }
    cout<<endl;
  }
}



Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<queue>
#define ll long long
using namespace std;

const int N=100005;

struct node{
	int a,b,c;
	node(){}
	node(int a,int b,int c):a(a),b(b),c(c){}
}h[N];
int n,x,y,z,w;
ll ans,sum;
ll f[N],g[N];
priority_queue<int,vector<int>,greater<int> > q;

bool cmp(node x,node y){
	return x.a-x.b<y.a-y.b;
}

int main(){
	int i;
	scanf("%d%d%d",&x,&y,&z); n=x+y+z;
	for (i=1;i<=n;i++) scanf("%d%d%d",&h[i].a,&h[i].b,&h[i].c);
	for (i=1;i<=n;i++) sum+=1ll*h[i].c;
	sort(h+1,h+1+n,cmp);
	for (i=1;i<=y;i++) ans+=1ll*(h[i].b-h[i].c),q.push(h[i].b-h[i].c);
	f[y]=ans;
	for (i=y+1;i<=n-x;i++){
		w=q.top(); q.pop();
		if (h[i].b-h[i].c>w){
			ans-=1ll*w;
			w=h[i].b-h[i].c;
			ans+=1ll*w;
		}
		q.push(w);
		f[i]=ans;
	}
	while (!q.empty()) q.pop(); ans=0;
	for (i=n-x+1;i<=n;i++) ans+=1ll*(h[i].a-h[i].c),q.push(h[i].a-h[i].c);
	g[n-x+1]=ans;
	for (i=n-x;i;i--){
		w=q.top(); q.pop();
		if (h[i].a-h[i].c>w){
			ans-=1ll*w;
			w=h[i].a-h[i].c;
			ans+=1ll*w;
		}
		q.push(w);
		g[i]=ans;
	}
	ans=0;
	for (i=y;i<=n-x;i++) ans=max(ans,f[i]+g[i+1]+sum);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2808
#include<iostream>
#include<math.h>
using namespace std;

int main() {
	int N;
	int K;
	cin >> N >> K;
	int ans = K;
	for (int i = 0; i < N - 1; i++) {
		ans *= (K - 1);
	}
	cout << ans << endl;
	return 0;
	}














Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    if((a-b)*(b-c)*(c-a)) cout << 3 << endl;
    if(a==b){
        if(a==c) cout << 1 << endl;
        else cout << 2 << endl;
    }
    else if(b==c) cout << 2 << endl;
    else if(a==c) cout << 2 <<endl;
    return 0;
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, a;
	cin >> n;
	int subs[n+1]{0};
	for (int i = 0; i < n-1; i++) {
		cin >> a;
		subs[a]++;
	}

	for (int i = 1; i <= n; i++) {
		cout << subs[i] << "\n";
	}
}

Measured memory_bytes: 4396
#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main(void){
  
    int l[15];
    int i,a,b;
  
    while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&a,&b)!=EOF){
  
        double sum=0;
        for(i=0;i<10;i++){
            sum+=(double)l[i];
        }
  
    double c=0,d=0;
    for(i=0;i<10;i++){
        c+=l[i];
        d+=(double)l[i]/a*b;
        if(c+d>=sum)break;
    }
    cout<<i+1<<endl;
  
    }
    return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int D,G,sum=0,ans=1000000000;
  cin>>D>>G;
  int p[10],c[10];
  for(int i=0;i<D;i++){
    cin>>p[i]>>c[i];
  }
  for(int i=0;i<(1<<D);i++){
    int count=0;
    int unused =0;
    sum=0;
    for(int k=0;k<D;k++){
      if(i & 1<<k){
        sum=sum+100*(k+1)*p[k];
        sum=sum+c[k];
        count += p[k];
      } else {
        unused = k;
      }
    }
    for(int k = 0; k<=p[unused];k++){
      if(sum<G){
        sum += 100*(unused+1);
        count++;
      }else{
        break;
      }
    }
    //cout<<count<<endl;
    if(sum>=G){
      ans=min(count,ans);
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
int main(){
int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
int A,B,C,D,E;
  A = a%10;
  B = b%10;
  C = c%10;
  D = d%10;
  E = e%10;
  int vector[5] = {A,B,C,D,E};
  int ans = 10;
  int n = 0;
  for(int i = 0;i<5;i++){
  if(vector[i]==0){
    n++;
  }
    else  if(vector[i]<ans){
      ans = vector[i];
    }
  }
  cout<<a+b+c+d+e-A-B-C-D-E+40+ans-10*n;
}

Measured memory_bytes: 256
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i+5000*j+1000*(n-i-j)==y:
            print("%d %d %d"%(i,j,n-i-j))
            exit()
print(-1,-1,-1)


Measured memory_bytes: 2940
main = do
  [n, k] <- map read . words <$> getLine
  as <- map read . words <$> getLine
  print $ solve k n as

solve k n as = solve' k l m
  where
    l = length $ takeWhile (/= 1) as
    m = n - l - 1

solve' k l m
  | l + m <= k - 1 = 1
  | l >= k = 1 + solve' k (l - k + 1) m
  | m >= k = 1 + solve' k l (m - k + 1)
  | otherwise = 2


Measured memory_bytes: 18812
#include<stdio.h>
#include<math.h>
int main(void)
{
  long int n,i,j,a,b,c,p,d;
  scanf("%ld",&n);
  if(n%2==1){
    printf("0\n");
  }
  a=0;
  if(n%2==0){
    b=n;
    p=1;
    while(p*10<=n){
      d=b-(b%(10*p));
      a=a+(d/(10*p));
      /*printf("%ld\t",a);*/
      p=p*5;
      /*printf("%ld\n",p*10);*/
    }
  printf("%ld\n",a);
  }
  return 0;
}

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

int main()
{
   string s; int w;
   vector<string> v;
   cin >> s >> w;
   for (int i = 0; i < s.size(); i+=w) {
    v.push_back(s.substr(i, i+w));
   }
   for (int i = 0; i < v.size(); i++)
    cout << v[i][0];


    return 0;
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
int main(){
  //入力準備
  int D, G, p[11], c[11];
  cin >> D >> G;
  for(int i = 0; i < D; ++i){
    cin >> p[i] >> c[i];
  }
  
  int ans = 1e9;

  for(int bit = 0; bit < (1 << D); bit++){
    int s = 0, num = 0, rest_max = -1;
    //方針はビット全探索　１箇所以外は全入れまたは無視が効率的
    for(int i = 0; i < D; i++){
      if(bit >> i & 1){
	//各項目のボーナス含む全入れの数値
	s += 100 * (i+1) * p[i] + c[i];
	
	num += p[i];
      }else{
	rest_max = i;
      }
    }
    if(s < G){
      int s1 = 100 * (rest_max + 1);
      int need = (G - s + s1 - 1) / s1;
      if(need >= p[rest_max]){
	continue;
      }
      num += need;
    }
    ans = min(ans, num);
  }

  //出力準備
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 3608
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static class Problem implements Comparable<Problem>{
		int cost;
		int limit;
		
		public Problem(int cost, int limit) {
			super();
			this.cost = cost;
			this.limit = limit;
		}

		@Override
		public int compareTo(Problem arg0) {
			return this.limit - arg0.limit;
		}
	}
	
	public static final int INF = Integer.MAX_VALUE / 2 - 1;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		Problem[] array = new Problem[N];
		for(int i = 0; i < N; i++){
			array[i] = new Problem(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(array);
		/*
		for(int i = 0; i < N; i++){
			System.out.println(array[i].cost + " " + array[i].limit);
		}
		*/
		int[][] DP = new int[N + 1][N + 1];
		for(int i = 0; i < N + 1; i++){
			for(int j = 0; j < N + 1; j++){
				DP[i][j] = INF;
			}
		}
		
		DP[0][0] = 0;
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				if(DP[i][j] + array[i].cost <= array[i].limit){
					//System.out.println(DP[i][j] + " " + array[i].cost + " " + DP[i][j + 1]);
					DP[i + 1][j + 1] = Math.min(DP[i][j] + array[i].cost, DP[i][j + 1]);
				}
				
				DP[i + 1][j] = Math.min(DP[i + 1][j], DP[i][j]);
			}
		}
		/*
		for(int i = 0; i < N + 1; i++){
			for(int j = 0; j < N + 1; j++){
				System.out.print(DP[i][j] + " ");
			}
			System.out.println();
		}
		*/
		int max = Integer.MIN_VALUE;
		for(int i = 0; i < N + 1; i++){
			for(int j = 0; j < N + 1; j++){
				if(DP[i][j] < INF){
					max = Math.max(max, j);
				}
			}
		}
		
		System.out.println(max);
	}

}

Measured memory_bytes: 17392
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n), cum(n + 1, 0);
  rep(i, n) cin >> a[i];
  sort(all(a));
  rep(i, n) cum[i + 1] = cum[i] + a[i];
  vl dp(n, 1);
  rep(i, n - 1) if(cum[i + 1] * 2 >= a[i + 1]) dp[i + 1] += dp[i];
  cout << dp[n - 1] << endl;
}

Measured memory_bytes: 5616
/*
000000000011111111112222222222333333333344444444
012345678901234567890123456789012345678901234567
TfefirstemampleistrivivlTfefirstemampleistrifivl
                                   .        . .
len = 18 sp = 3
len = 15 sp = 11
len = 12 sp = 22
len = 12 sp = 35
mfv
  
000000000011111111112222222222
012345678901234567890123456789
aabbccbbccaabbaacceeddffccaabb
       . ..
  
len = 4 sp = 1
  
abc
  
*/
  
#include<set>
#include<iostream>
#include<cmath>
#include<cstdio>
  
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
  
using namespace std;
  
void compute(string text,string S)
{
  int nt = text.size(),nS = S.size();
  int mlen = inf;
  string ans;
  set<string> all;
  bool found[nS];
  int CNT = 0;
  int fpos[nS];
  rep(i,nS)found[i] = false;
  
  rep(i,nt)
    {
      bool update = false;
      int cnt = 0,mn,mx;
      mn = inf,mx = -inf;
      rep(j,nS)
    {
      if(S[j] == text[i])
        {
          update = true;
          found[j] = true;
          fpos[j] = i;
        }
      if(found[j])
        {
          cnt++;
          mn = min(mn,fpos[j]);
          mx = max(mx,fpos[j]);
        }
    }
      if(cnt == nS)
    {
      int cost = mx - mn + 1;
      if(cost < mlen)
        {
          mlen = cost;
          ans = text.substr(mn,cost);
          all.clear();
          CNT = 1;
          all.insert(text.substr(mn,cost));
        }
      else if(cost == mlen)
        {
          if(update)CNT++;
          all.insert(text.substr(mn,cost));
        }
    }
    }
  cout << CNT << endl << endl;
  //printf("%d\n\n",(int)all.size());
   
  if(all.empty())
    {
      return;
    }
 
  rep(i,ans.size())
    if((i+1)%72 == 0 && i != 0)
      printf("%c\n",ans[i]);
    else
      printf("%c",ans[i]);
  if(ans.size()%72 != 0)puts("\n");
  else puts("");
}
  
int main()
{
  string blank;
  while(getline(cin,blank))
    {
      string text,S;
      text += blank;
      while(getline(cin,blank))
    {
      if(blank.empty())break;
      text += blank;
    }
      if(text.empty())goto Fin;
      while(getline(cin,blank))
    if(blank.empty())break;
    else S += blank;
      compute(text,S);
    }
 Fin:;
  return 0;
}

Measured memory_bytes: 2652
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

/* --------------------------------------- */
ll dp[40][(1ll << 17)];
ll n, x, y, z;

ll rec(ll idx, ll bit) {
	if(idx == n) return 1;
	if(dp[idx][bit] != -1) return dp[idx][bit];
	bitset<17> bi(bit);
	ll ret = 0;
	for(ll i = 1; i <= 10; i++) {
		if(i <= z && bi[x + y + z - i - 1]) continue;
		bitset<17> arg(0);
		REP(j, x + y + z - 1) {
			if(!bi[j]) continue;
			if(j < x - 1) {
				if(j + i <= x - 1) arg[j + i] = 1;
			} else if(j < x + y - 1) {
				if(j + i <= x + y - 1) arg[j + i] = 1;
			} else {
				if(j + i < x + y + z - 1) arg[j + i] = 1;
			}
		}
		if(i <= x) arg[i - 1] = 1;
		ret += rec(idx + 1, arg.to_ullong());
		ret %= MOD;
	}
	return dp[idx][bit] = ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> x >> y >> z;
	REP(i,40) REP(j,(1ll << 17)) dp[i][j] = -1;
	ll univ = 1;
	REP(i,n) {
		univ *= 10;
		univ %= MOD;
	}
	cout << ((univ - rec(0, 0)) % MOD + MOD) % MOD << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 41344
while True:
    input_state = input()
    if input_state == "?":
        break
    else:
        ans = []
        (a, op, b) = map(str, input_state.split())
        if op == "+":
            ans = int(a) + int(b)
        elif op == "-":
            ans = int(a) - int(b)
        elif op == "*":
            ans = int(a) * int(b)
        elif op == "/":
            ans = int(int(a)/int(b))
        else:
            break
        print("{0}".format(int(ans)))


Measured memory_bytes: 5600
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

#include <iostream>

int main()
{
	int X,Y;
	cin >> X>>Y;

	cout << X + Y / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#define ll long long
using namespace std;
ll mina=1,minb=1;	


//找到符合mina:minb 等于 a2:b2 ，且mina>a1,minb>b1的最小的ab对 
void multiAB(ll a1,ll b1,ll a2,ll b2){
//	cout<<"multiAB("<<a1<<","<<b1<<","<<a2<<","<<b2<<")\n";
	ll multia=a1/a2;
	if(multia*a2<a1){
		multia++;
	}
	ll multib=b1/b2;
	if(multib*b2<b1){
		multib++;
	}
	ll multi=1;
	if(multia>multib){
		multi=multia;
	}else{
		multi=multib;
	}
	mina=a2*multi;
	minb=b2*multi;
//	cout<<mina<<"----"<<minb<<"----"<<multi<<endl; 
	
	/* 
	 while(true){
	 	mina=a2*multi;
	 	minb=b2*multi;
	 //	cout<<"mina"<<mina<<"minb"<<minb<<endl;
	 	if(mina>=a1 && minb>=b1 ){
	 		return ; 
		 }
		 multi++;
	 	
	 }
	*/
	
} 

int main(){
	
	int n;
	cin>>n;
	long long a[n],b[n];
	//ll mina,minb;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i]; 
	}
	
	mina=a[0];
	minb=b[0];
	for(int i=1;i<n;i++){
//		int multi = multiAB(mina,minb,a[i],b[i]); 
		multiAB(mina,minb,a[i],b[i]); 
//		mina=a[i]*multi;
//		minb=b[i]*multi;
	//	cout<<mina<<"--"<<minb<<endl;
//		minb=result[1];
	}
	cout<<mina+minb;
	
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long int
#define pb push_back
#define all(a) a.begin(),a.end()

signed main(){
	IOS;
	int n,l;
	cin>>n>>l;
	int pie=0;
	int a[n+1]={0};
	for(int i=1;i<=n;i++){
		pie+=(l+i-1);
		for(int j=1;j<=n;j++){
			if(i!=j) a[j]+=(l+i-1);
		}
	}
	int mini=1000000000,ans=0;
	for(int i=1;i<=n;i++){
		if(abs(pie-a[i])<mini){
			mini = abs(pie-a[i]);
			ans = a[i];
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
n=int(input())
t=list(map(int,input().split()))
v=list(map(int,input().split()))+[0]
for i in range(n-1,-1,-1):
    v[i]=min(v[i],v[i+1]+t[i])
ans=0
v0=0
for i in range(n):
    if v[i]<=v[i+1]:
        if v[i]-v0>t[i]:
            ans+=(2*v0+t[i])*t[i]/2
            v0=v0+t[i]
        else:
            ans+=t[i]*v[i]-(v[i]-v0)**2/2
            v0=v[i]
    else:
        if v[i]*2-v0-v[i+1]<t[i]:
            ans+=t[i]*v[i]-(v[i]-v0)**2/2-(v[i]-v[i+1])**2/2
            v0=v[i+1]
        elif v[i+1]-v0>t[i]:
            ans+=(2*v0+t[i])*t[i]/2
            v0=v0+t[i]
        else:
            d=abs(v0-v[i+1])
            ans+=max(v0,v[i+1])*t[i]-d**2/2+(t[i]-d)**2/4
            v0=v[i+1]
print(ans)

Measured memory_bytes: 3064
N = int(input())
A,B = list(map(int, input().split()))
takahashi = list(range(A, B+1))
d_list=[]
for i in takahashi :
    if i % N == 0:
        d_list.append(1)
    else:
        d_list.append(0)
if 1 in d_list:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9176
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#define ll long long
#define rg register
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define OJ
//#define Debug
using namespace std;
template <typename T> inline void read(rg T &b){
	rg char ch;rg T sum=0;rg bool f=1;
	while(ch=getchar(),ch<'0' || ch>'9') if(ch=='-') f=0;
	while(ch>='0' && ch<='9') sum=sum*10+ch-'0',ch=getchar();
	b=f?sum:-sum;
}
const int MAXN=4005;
const int mod = 924844033;
int f[MAXN][MAXN][2],g[MAXN],A[MAXN],fac[MAXN];
inline void add(int &x,int y) {x+=y;if(x>=mod)x-=y;}
int n,k,ans,cnt=0;
signed main() {
	#ifndef OJ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
	#endif 
    read(n),read(k);
     for(rg int i=1;i<=k;++i){
        for(rg int j=i;j<=n;j+=k) A[++cnt]=(i==j);
        for(rg int j=i;j<=n;j+=k) A[++cnt]=(i==j);
    }
    f[0][0][0] = 1;
    for (rg int i=1;i<=(n<<1);++i) 
        for (rg int j=0;j<=i;++j) {
            add(f[i][j][0],(f[i-1][j][0]+f[i-1][j][1])%mod);
            if (!A[i]&&j) add(f[i][j][1],f[i-1][j-1][0]);
        }
    fac[0]=1;
    for (rg int i = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
    for (rg int i = 0; i <= n; ++i) {
        rg int res=(f[n<<1][i][0]+f[n<<1][i][1])%mod;
        ans+=1LL*(i&1?-1:1)*res*fac[n-i]%mod;
        ans=(ans%mod+mod)%mod;
    }
   	printf("%d",ans);
    return 0;
}

Measured memory_bytes: 123776
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,K;
    cin >> N >> K;
    int R = 1;
    for(int i = 0; i < N; i++){
        if(R < K) R *= 2;
        else R += K;
    }
    cout << R << endl;
}


Measured memory_bytes: 256
# from math import factorial
# from collections import defaultdict, deque
#  from heapq import heappush, heappop, heapify

# A, B = [int(i) for i in input().split(" ")]
# A = int(input())
# As = [int(i) for i in input().split(" ")]
# Ss = ["".join(sorted(input())) for _ in range(N)]
# edges = defaultdict(list)
# for _ in range(N - 1):
#     a, b = [int(i) for i in input().split(" ")]
#     edges[a-1].append(b-1)
import math

A, B = [int(i) for i in input().split(" ")]

def solve(n):
    ans, i = [], 1
    while i * i <= n:
        div, mod = divmod(n, i)
        if mod == 0:
            ans.append(i)
            if i != div:
                ans.append(div)
        i += 1
    return list(sorted(ans))  # 順番気にしないならソートせずにより高速

a = solve(A)
b = solve(B)
c = list(sorted(set(a) & set(b)))
# print(c)

ans = []
for i in c:
   for a in ans:
       if a == 1: continue
       if i % a == 0:
          break
   else:
      ans.append(i) 
# print(ans)
print(len(ans)) 


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

using namespace std;
typedef pair<int, int> P;
static const int INF = 9999999;


void solve()
{
	int step = 1;
	int N;
	while(cin >> N, N)
	{
		cout << "Case " << step << ":" << endl;
		++step;
		vector< vector<int> > Vec(N + 2, vector<int>(N + 2));
		for(int i = 0; i < N + 2; ++i)
		{
			Vec[0][i] = INF;
			Vec[N + 1][i] = INF;
			Vec[i][0] = INF;
			Vec[i][N + 1] = INF;
		}
		int count = 0;
		int num = 1;
		Vec[1][1] = num;
		P p(2, 1);
		bool IsOdd = true;
		while(count != N)
		{
			while(Vec[p.second][p.first] != INF)
			{
				++num;
				Vec[p.second][p.first] = num;
				if(IsOdd)
				{
					p.first -= 1;
					p.second += 1;
				}
				else
				{
					p.first += 1;
					p.second -= 1;
				}
			}
			//FieldàÉß·
			if(IsOdd)
			{
				p.first += 1;
			}
			else
			{
				p.second += 1;
			}
			++count;
			IsOdd = !IsOdd;
		}
		if(N % 2)
		{
			p.first -= 2;
			++p.second;
		}
		else
		{
			++p.first;
			p.second -= 2;
		}
		while(count != 0)
		{
			while(Vec[p.second][p.first] != INF)
			{
				++num;
				Vec[p.second][p.first] = num;
				if(IsOdd)
				{
					p.first += 1;
					p.second -= 1;
				}
				else
				{
					p.first -= 1;
					p.second += 1;
				}
			}
			//FieldàÉß·
			if(IsOdd)
			{
				p.first -= 1;
				p.second += 2;
			}
			else
			{
				p.first += 2;
				p.second -= 1;
			}
			--count;
			IsOdd = !IsOdd;
		}
		for(int i = 1; i < N + 1; ++i)
		{
			for(int j = 1; j < N + 1; ++j)
			{
				printf("%3d", Vec[i][j]);
			}
			cout << endl;
		}
	}
}

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

Measured memory_bytes: 0
/*                                                                                 
	Author :- Gaurang_Kothiya
	
	Quote :- " Practice makes a man perfect. "		
*/  
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9;
const int inf64= 1e18;
const int MOD= 1e9 +7;


void Solve()
{
	int n;
	cin>>n;
	m(string,int) mp;
	string s;
	f(i,1,n)
	{
		cin>>s;
		mp[s]++;
	}
	cout<< "AC x "<< mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
}
 
signed main() 
{
	speed		

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

Measured memory_bytes: 3656
n,m = map(int,input().split())
AB = {}
ans = 'IMPOSSIBLE'
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        if b in AB:
            if AB[b] == n:
                ans = 'POSSIBLE'
                break
        else:
            AB[b] = 1


    if b == n:
        if a in AB:
            if AB[a] == 1:
                ans = 'POSSIBLE'
                break
        else:
            AB[a] = n
print(ans)

Measured memory_bytes: 27068
import java.util.*;
public class Main{
    static long[] dp = new long[1000000];
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Arrays.fill(dp, Long.MAX_VALUE);
        dp[0] = 0;
        
        int n = sc.nextInt();
        int h[] = new int[n];

        for(int i=0; i<n; i++) h[i] = sc.nextInt();

        dp[1] = Math.abs(h[0]-h[1]);
        for(int i=2; i<n; i++){
            dp[i] = Math.min(dp[i-2]+Math.abs(h[i]-h[i-2]), dp[i-1]+Math.abs(h[i]-h[i-1]));
        }
        System.out.println(dp[n-1]);
        
    }
    
}


Measured memory_bytes: 68896
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int N,M;cin>>N>>M;
    vector<pair<pair<int,int>,int>> c(M);
    vector<int> n(N,1);
    vector<string> ans(M);
    REP(i,M){
        int p,y;cin>>p>>y;
        c[i].first.first=y;
        c[i].first.second=p;
        c[i].second=i;
    }
    sort(All(c));
    REP(i,M){
        string a="";
        string p=to_string(c[i].first.second);
        REP(i,6-p.size())a+="0";
        a+=p;
        string x=to_string(n[c[i].first.second-1]);
        n[c[i].first.second-1]++;
        REP(i,6-x.size())a+="0";
        a+=x;
        ans[c[i].second]=a;
    }
    REP(i,M)cout<<ans[i]<<endl;
    
    
}


Measured memory_bytes: 9728
#include<iostream>
#include<vector>
using namespace std;
const int MAX = 20;
char map[MAX][MAX];
bool book[MAX][MAX];
struct Point
{
	int x;
	int y;
	Point(int x = 0, int y = 0) :x(x), y(y) {}
}start;
int sum = 0;
void depthFSearch(int H, int W, Point start)
{
	int next[4][2] = { {0,1},{1,0},{0,-1},{-1,0} };
	for (int k = 0; k <= 3; k++)
	{
		int nx = start.x + next[k][0];
		int ny = start.y + next[k][1];
		if (nx < 0 || nx >= H || ny < 0 || ny >= W||map[nx][ny]=='#')
			continue;
		if (!book[nx][ny] && map[nx][ny] == '.')
		{
			book[nx][ny] = true;
			Point p(nx, ny);
			sum++;
			depthFSearch(H, W, p);
		}
	}
	return;
}
int main()
{
	while (true)
	{
		int H, W;
		cin >> W >> H;
		if (!H && !W)
			break;
		for (int i = 0; i < H; i++)
			for (int j = 0; j < W; j++)
			{
				cin >> map[i][j];
				book[i][j] = false;
				if (map[i][j] == '@')
					start = Point(i, j);
			}
		book[start.x][start.y] = true;
		sum = 1;
		depthFSearch(H, W, start);
		cout << sum << endl;
	}
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
typedef long long ll;
typedef pair<ll, ll> P;
 
const int MAX = 55;
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
int N;
 
int main(){
    cin >> N;
    vector<double> v(N);
    rep(i, N) cin >> v[i];
 
    while(1 < v.size()){
        sort(v.begin(), v.end());
        double a, b;
        a = v[0];
        b = v[1];
        v.erase(v.begin(), v.begin() + 2);
        v.push_back((a + b) / 2.0);
    }
 
    cout << v[0] << endl;
}

Measured memory_bytes: 256
#include<fstream>
#include<string>
#include<iostream>
#include<sstream>
#include<iterator>
#include<cmath>
#include<stdio.h>

using namespace std;

int main(){
string txt;
 cin >> txt;
 int n = txt.length();
 int i;
 char c;
 int t = 0;
 for(i=0;i<n;i++){
  c = txt[i];
  if((i%2==0 && c=='L') || (i%2==1 && c=='R')){
      cout << "No" << endl;
      t++;
      break;
  }}
  if(t==0)cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int H, W, K;
char C[10][10];

int countB(int bi, int bj){
    int ret = 0;
    REP(i, H){
        if(bi & (1 << i)) continue;
        REP(j, W){
            if(bj & (1 << j)) continue;
            if(C[i][j] == '#') ret++;
        }
    }
    return ret;
}

signed main(){
    cin >> H >> W >> K;
    REP(i, H){
        REP(j, W){
            cin >> C[i][j];
        }
    }
    ll ans = 0;
    REP(i, 1 << H){
        REP(j, 1 << W){
            if(countB(i, j) == K) ans++;
        }
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3604
package main
import "fmt"
func main() {
  var n int
  var u,w,v int64
  fmt.Scan(&n,&u)
  dp := map[int64]int64{0:0}
  for i:=0;i<n;i++ {
    fmt.Scan(&w,&v)
    tmp := map[int64]int64{0:0}
    for key,val := range dp {
      if tmp[key] < val { tmp[key] = val }
      if key+w <= u && tmp[key+w] < val+v { tmp[key+w] = val+v }
    }
    dp = tmp
  }
  var max int64
  for _,val := range dp {
    if max < val { max = val }
  }
  fmt.Println(max)
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int h, w, n; scanf("%d%d%d", &h, &w, &n);
  printf("%d", (n+max(h, w)-1)/max(h, w));
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3848
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;
const int num = 1000000007;

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

    int n, m;
    cin >> n >> m;
    vector<int> dp(n + 2), a(n + 1);
    rep(i, m) {
      int b;
      cin >> b;
      a[b] = 1;
    }
    dp[n] = 1;
    for (int i = n - 1; i >= 0; --i) {
      if (a[i]) {
        dp[i] = 0;
      } else {
        dp[i] = (dp[i + 1] + dp[i + 2]) % num;
      }
    }

    cout << dp[0] << '\n';

    return 0;
}


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

int main() {
 string s;
  cin >> s;
  
  int n = s.size();
  for(int i=0; i<n/2; i++) {
    if(s[i] != s[n-i-1]) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  for(int i=0; i<n/4; i++) {
    if(s[i] != s[(n/2)-i-1]) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  int j=n-1, i=(n/2)+1;
  for(; i < j; i++, j--) {
    if(s[i] != s[j]) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S() 
    y, m, d = s.split('/')
    y, m, d = int(y), int(m), int(d)
    if m < 4:
        print('Heisei')
    elif m > 4:
        print('TBD')
    else:
        # 4
        if d <= 30:
            print('Heisei')
        else:
            print('TBD')



if __name__ == "__main__":
    main()


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rep1r(i, n) for (int i = ((int)(n)); i > 0; --i)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n + 1; i++) {
        cin >> a[i];
    }
    ll b[n];
    rep(i, n) { cin >> b[i]; }

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        ll temp = 0;
        if (b[i] > a[i]) {
            temp = b[i] - a[i];  // 隣を殺せる数
            if (a[i + 1] > temp) {
                sum += a[i] + temp;  // i+1を一部やっつける
                a[i + 1] -= temp; //一部だけ殺した
            } else {
                sum += a[i] + a[i + 1];  // i+1も全部やっつける
                a[i + 1] = 0; //全部殺したから0
            }
        } else {          // b<a
            sum += b[i];  // bだけやっつける。隣町は行かない
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int A,B;
  cin >> A;
  cin >> B;
  int sum,sa,mul;
  sum = A+B;
  sa = A-B;
  mul = A*B;
  if(sum >= sa && sum >= mul) cout << sum << endl;
  else if(sa >= mul && sa >= sum) cout << sa << endl;
  else cout << mul << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    maxv = 0
    ans = 0
    for a in A:
        if maxv > a:
            ans += maxv - a
        else:
            maxv = a  
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 32200
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define M 2005
#define N 1005
#define ll long long
#define mod 1000000007
int A[M], B[M], C[M], idx[M];
int fir[N], nex[M << 1], tar[M << 1], len[M << 1], cnt;
int dep[N], bel[N], vis[M];
int m, n, f[15][N], g[15][N];
ll s;
bool E[M];
bool cmp(int u, int v){return C[u] < C[v];}
int Getbel(int x){return bel[x] ? bel[x] = Getbel(bel[x]) : x;}
void Add(int a, int b, int c)
{
	++cnt;
	tar[cnt] = b;
	nex[cnt] = fir[a];
	len[cnt] = c;
	fir[a] = cnt;
}
void Dfs(int r)
{
	for (int i = fir[r]; i; i = nex[i])
	{
		int v = tar[i];
		if (v != f[0][r])
		{
			dep[v] = dep[r] + 1;
			f[0][v] = r;
			g[0][v] = len[i];
			Dfs(v);
		}
	}
}
int main()
{
	scanf("%d%d%lld", &n, &m, &s);
	for (int i = 1; i <= m; i++)
	{
		scanf("%d%d%d", &A[i], &B[i], &C[i]);
		idx[i] = i;
	}
	sort(idx + 1, idx + m + 1, cmp);
	for (int i = 1; i <= m; i++)
	{
		int x = Getbel(A[idx[i]]), y = Getbel(B[idx[i]]);
		if (x != y)
		{
			vis[idx[i]] = 1;
			s -= C[idx[i]];
			bel[x] = y;
			Add(A[idx[i]], B[idx[i]], C[idx[i]]);
			Add(B[idx[i]], A[idx[i]], C[idx[i]]);
		}
	}
	Dfs(1);
	for (int i = 1; i <= 12; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			f[i][j] = f[i - 1][f[i - 1][j]];
			g[i][j] = max(g[i - 1][j], g[i - 1][f[i - 1][j]]);
		}
	}
	int x = s ? 0: n - 2, y = 1;
	for (int i = 1; i <= m; i++)
		if (!vis[i])
		{
			int u = A[i], v = B[i], mx = 0;
			if (dep[u] < dep[v])
				swap(u, v);
			for (int j = 0; j <= 12; j++)
				if ((dep[u] - dep[v]) & (1 << j))
					mx = max(mx, g[j][u]), u = f[j][u];
			if (u == v)
			{
				if (s == C[i] - mx)x++;
				if (s < C[i] - mx)y++;
				continue;
			}
			for (int j = 12; j >= 0; j--)
				if (f[j][u] != f[j][v])
				{
					mx = max(mx, max(g[j][u], g[j][v]));
					u = f[j][u], v = f[j][v];
				}
			mx = max(mx, max(g[0][u], g[0][v]));
			if (s == C[i] - mx)x++;
			if (s < C[i] - mx)y++;
		}
	int ans = 0;
	for (int i = 0; i < x; i++)
		ans = (ans * 2ll + 1) % mod;
	for (int i = 0; i < y; i++)
		ans = (ans * 2ll) % mod;
	printf("%d\n", ans);
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	m, _ := strconv.Atoi(Scanner())
	to := make([][][]int, n)
	node := make([]int, n)
	inf := -1000000007
	for i := 0; i < n; i++ {
		to[i] = make([][]int, 0)
		node[i] = inf
	}
	lrd := make([][]int, m)
	for i := 0; i < m; i++ {
		l, _ := strconv.Atoi(Scanner())
		r, _ := strconv.Atoi(Scanner())
		d, _ := strconv.Atoi(Scanner())
		l--
		r--
		to[l] = append(to[l], []int{r, d})
		to[r] = append(to[r], []int{l, -d})
		lrd[i] = []int{l, r, d}
	}
	for i := 0; i < n; i++ {
		if node[i] == inf {
			q := []int{i}
			node[i] = 0
			for len(q) != 0 {
				x := q[0]
				q = q[1:]
				for _, v := range to[x] {
					if node[v[0]] == inf {
						node[v[0]] = node[x] + v[1]
						q = append(q, v[0])
					}
				}
			}
		}
	}
	f := true
	for i := 0; i < m; i++ {
		l, r, d := lrd[i][0], lrd[i][1], lrd[i][2]
		if node[r]-node[l] != d {
			f = false
			break
		}
	}
	if f {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 46592
import sys
import numpy as np

input = input()
s = np.array([c for c in input])
ans = 0
for i in range(1, s.size):
    if s.size - i % 2 is not 0:
        if ''.join(np.array_split(s[0:s.size - i], 2)[0]) == ''.join(np.array_split(s[0:s.size - i], 2)[1]):
            ans = max(ans, s.size - i)
print(ans)


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

#define ll long long int
#define MP make_pair
#define pb push_back
#define PLL pair<ll,ll>

int main()
{
  ll n;
  cin >> n;
  string s[n];

  ll i,ca=0,ct=0,cr=0,cw=0;

  for(i=0;i<n;i++)
  {
    cin >> s[i];
    if(s[i][0]=='A')
    ca++;
    else if(s[i][0]=='R')
    cr++;
    else if(s[i][0]=='T')
    ct++;
    else
    cw++;
  }


  cout << "AC"<<" x "<<ca <<'\n';
  cout << "WA"<<" x "<<cw <<'\n';
  cout << "TLE"<<" x "<<ct <<'\n';
  cout << "RE"<<" x "<<cr <<'\n';

}


Measured memory_bytes: 6700
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val x = (1..n).map { sc.nextInt() }

  val xx = x.sorted()
  val mid = n / 2 - 1


  val m1 = xx[mid]
  val m2 = xx[mid+1]

  var ans = mutableListOf<Int>()
  for (xi in x) {
    if (xi <= m1) {
      ans.add(m2)
    } else {
      ans.add(m1)
    }
  }


  println(ans.joinToString("\n"))

}

Measured memory_bytes: 72972
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<int> ga[100010];
int x,y;
int dp[100010];
int sol(int u){
	if(~dp[u])
	   return dp[u];
	if(ga[u].empty())
	   return dp[u]=0;
	for(int i=0;i<ga[u].size();i++){
		int v=ga[u][i];
		dp[u]=max(dp[u],sol(v)+1);
	}
	return dp[u];
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		ga[x].push_back(y);
	}
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++)
	   sol(i);
	int ans=0;
	for(int i=1;i<=n;i++)
	   ans=max(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
54 65
)");
#define cin input
#endif

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

	int n = 0;
	REP (i, b - a)
		n += i;

	cout << n - a << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define FOR(x, to) for(x=0; x<(to); x++)

int main(){
    int N, K;
    cin >> N >> K;
    long double ans = 0;
    
    for(int i=1; i<=N; i++){
        int num = 0, tmp = i;
        while(tmp <= K-1){
            tmp *= 2;
            num++;
        }
        ans += pow(0.5, num) * (1.0 / N);
    }

    cout << setprecision(13) << ans << endl;

    return 0;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	ll n , y;
	cin >> n >> y;
	
	rep(i,n+1){//1000円
		for(int j = 0 ; j + i <= n ; j++){//5000円
			int man = n - i - j ;//円
			if(1000*i + 5000*j + 10000*man == y){
				cout << man << " " << j <<" "<<i<<endl;
				return 0;
			}
		}
	}
	cout << -1 <<" ";
	cout << -1 <<" ";
	cout << -1 << endl;

}


Measured memory_bytes: 256