akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;
struct Edge {
    int to; double cost;
};
const double INF = 1<<29;

int main()
{
    while (1) {
        int n, m, p, a, b; cin >> n >> m >> p >> a >> b;
        a--, b--;
        if (!n) break;

        vector<int> t(n);
        loop (n, i) cin >> t[i];

        vector<vector<Edge>> G(m);
        loop (p, i) {
            int x, y; double z; cin >> x >> y >> z;
            x--, y--;
            G[x].push_back({ y, z });
            G[y].push_back({ x, z });
        }

        double dp[300][31] = {};
        fill(dp[0], dp[299]+31, INF);
        dp[0][a] = 0;
        loop (n, i) {
            loop (1<<n, crr) if (__builtin_popcount(crr) == i) {
                loop (n, k) {
                    int nxt = crr | (1<<k);
                    if (nxt == crr) continue;
                    loop (m, from) {
                        for (auto e : G[from]) {
                            dp[nxt][e.to] = min(
                                dp[nxt][e.to],
                                dp[crr][from] + e.cost / t[k]
                            );
                        }
                    }
                }
            }
        }

        double ans = INF;
        loop (300, i) ans = min(ans, dp[i][b]);
        if (ans == INF) cout << "Impossible" << endl;
        else cout << setprecision(8) << fixed << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3364
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;
#define mod 1000000007
LL N,M,x[200010],y[200010];

int main(){
    cin >> N >> M;

    int i;
    for (i=1; i<=N; i++) cin >> x[i];
    for (i=1; i<=M; i++) cin >> y[i];

    sort(x+1,x+N+1);
    sort(y+1,y+M+1);

    LL sum=0,sumx=0,sumy=0;
    for (i=1; i<=N; i++){
        sumx=(sumx+(i-1)*x[i]-sum)%mod;
        sum=(sum+x[i])%mod;
    }

    sum=0;
    for (i=1; i<=M; i++){
        sumy=(sumy+(i-1)*y[i]-sum)%mod;
        sum=(sum+y[i])%mod;
    }

    LL res=(sumx*sumy)%mod;
    res=(res+mod)%mod;
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 1792
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
ans=[0 for _ in range(h*w)]
i=0
c=1
for x in a:
  while x>0:
    ans[i]=c
    x-=1
    i+=1
  c+=1

for i in range(h):
  grd=ans[w*i:w*(i+1)]
  if i%2==1:
    grd=grd[::-1]
  print(*grd)


#print(ans)

Measured memory_bytes: 3828
#!/usr/bin/env python3

n = int(input())
a = list(map(int, input().split()))

count = 1
ans_list = []
for i in range(n):
    if a[i] == count:
        count += 1
        ans_list.append(count)

if len(ans_list) == 0:
    print(-1)
else:
    print(n-len(ans_list))


Measured memory_bytes: 26268
mod = 10**9+7
n = int(input())
l = list(map(int, input().split()))

from functools import reduce

def gcd(x, y):
  while y:
    x , y = y, x % y
  return x

lcm = l[0]
ans = 1

for i in range(1, n):
  g = gcd(lcm, l[i])
  s = lcm // g
  t = l[i] // g
  lcm = s * t * g
  ans = (ans * t + s) % mod
print(ans)

Measured memory_bytes: 4208
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<sys/time.h>
#define hsize 4194304 //must be 2^N

unsigned long long seed;

unsigned long long xorshift(){
  seed=seed^(seed<<13);
  seed=seed^(seed>>7);
  seed=seed^(seed<<17);
  return seed;
}

long long hash[hsize];
long long inhfl=1;
bool hashfl[hsize]={0};

long long hbase[8][256];

long long reshash(){
  srand(time(0));
  struct timeval tv;
  gettimeofday(&tv, NULL);
  seed=(tv.tv_sec*1000000+tv.tv_usec);
  long long i,j;
  for(i=0;i<100;i++){xorshift();}
  for(i=0;i<8;i++){
    for(j=0;j<256;j++){
      hbase[i][j]=((xorshift()%hsize)^(rand()%hsize));
    }
  }
  if(inhfl==0){for(i=0;i<hsize;i++){hashfl[i]=false;}}
  inhfl=0;
}

long long gbhash(long long x){
  long long r=0,i;
  for(i=0;i<8;i++){
    r^=hbase[i][(x&(255ll))];
    x>>=8;
  }
  return r;
}

long long access(long long x){
  long long p=gbhash(x);
  while(1){
    if((!hashfl[p]) || hash[p]==x){
      hash[p]=x;
      hashfl[p]=true;
      return p;
    }
    p++;
    if(p==hsize){p=0;}
  }
}

int main(){
  reshash();
  long long n,a[131072],q,b,c,s=0,i,j;
  long long mpb[hsize]={0};
  long long bh,ch;
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
    s+=a[i];
    mpb[access(a[i])]++;
  }
  scanf("%lld",&q);
  for(i=0;i<q;i++){
    scanf("%lld%lld",&b,&c);
    bh=access(b);
    ch=access(c);
    s-=b*mpb[bh];
    s+=c*mpb[bh];
    mpb[ch]+=mpb[bh];
    mpb[bh]=0;
    printf("%lld\n",s);
  }
  return 0;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<vector<int> > dp(n, vector<int>(3, 0));
    vector<int> arr(3);
    for (int i = 0; i < n; i++) {
        cin >> arr[0] >> arr[1] >> arr[2];
        if (i == 0) {
            dp[0][0] = arr[0]; dp[0][1] = arr[1]; dp[0][2] = arr[2];
            continue;
        } else if (i == 1) {
            dp[1][0] = max(dp[0][2], dp[0][1]) + arr[0];
        }
        for (int j = 0; j < 3; j++) {
            if (i == 1) {
                dp[i][j] = max(dp[i - 1][j],
                               max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]) + arr[j]);

            } else {
                dp[i][j] = max(dp[i - 2][j],
                           max(dp[i - 1][(j + 1) % 3],
                               dp[i - 1][(j + 2) % 3])) + arr[j];
            }
        }
    }

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
    return 0;
}


Measured memory_bytes: 5760
n, m = map(int, input().split())

submit = []
for i in range(m):
    temp = [x for x in input().split()]
    submit.append(temp)

ac = [0] * (n + 1)
wa = [0] * (n + 1)

for i in range(m):
    result = submit[i][1]
    question = int(submit[i][0])

    if result == 'AC' and ac[question] == 0:
        ac[question] = 1
    elif result == 'WA' and ac[question] == 0:
        wa[question] += 1

for i in range(n + 1):
    if ac[i] != 1:
        wa[i] = 0

print(sum(ac), sum(wa))


Measured memory_bytes: 27404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int a,b; cin>>a>>b;
    if(a+b<24) cout<<a+b<<endl;
    else cout<<a+b-24<<endl;
}


Measured memory_bytes: 256
<?php
  
try{
  $input = explode(" ", fgets(STDIN));
  // NとRに分割
  $n = $input[0];
  $r = $input[1];

  // 0未満は弾く
  if($n < 0 || $r < 0){
    echo("input error.");
    exit;
  }

  // 内部レーティング出す
  if($n < 10){
    $ir = 100 * (10 - $n) + $r;
  }else{
    $ir = $r;
  }

  print_r($ir);
  exit;
}catch(Exception $e){
  echo("input is invalid.");
}

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

int main()
{

	int a, b, c, n, r;

	while (cin >> a >> b >> c)
	{
		if ((a == 0) && (b == 0) && (c == 0)) break;

		double ab, bc, ac, taikaku;
		ab = sqrt(pow(a, 2) + pow(b, 2));
		bc = sqrt(pow(b, 2) + pow(c, 2));
		ac = sqrt(pow(a, 2) + pow(c, 2));
		taikaku = ab;
		if (taikaku>bc)
		{
			taikaku = bc;
		}
		else if (taikaku>ac)
		{
			taikaku = ac;
		}

		cin >> n;
		for (int i = 0; i < n; i++)
		{
			cin >> r;
			if (r*2>taikaku)
			{
				cout << "OK" << endl;
			}
			else
			{
				cout << "NA" << endl;
			}
		}

	}
	return 0;
}

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

using namespace std;

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

const long long INF = 1LL << 60;

int main(void){
  long long N, M, MOD = 1000000007;
  
  cin >> N >> M;
  
  int a[M];
  long long DP[N+10];
  vector <long long> check(100010, 0);
  
  for(int i = 0; i < M; i++){
    cin >> a[i];
    check[a[i]] = 1;
  }
  
  for(int i = 0; i < N; i++){
    DP[i] = 0;
  }
  
  DP[N] = 0;
  DP[0] = 1;
  
  if(check[1] == 0) DP[1] = 1;
  
  for(int i = 2; i < N + 1; i++){
    if(check[i] == 1)continue;
    DP[i] += DP[i-1] + DP[i-2];
    DP[i] %= MOD;
  }
  
  cout << DP[N] << endl;
  return 0;
}



Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int n, k;
const int N = 200000;
const int INF = 10000000;
int L[N], R[N];
vector <int> bi[N];
int ai[N], r;
void dfs1(int t, int f, int d)
{
    if (ai[t] != -1 && ((ai[t] & 1) ^ d)) puts("No"), exit(0);
    L[t] = 0; R[t] = INF; if (ai[t] != -1) L[t] = R[t] = ai[t];
    for (int i = 0; i < bi[t].size(); ++ i) if (bi[t][i] != f)
    {
        dfs1(bi[t][i], t, !d);
        L[t] = max(L[t], L[bi[t][i]] - 1);
        R[t] = min(R[t], R[bi[t][i]] + 1);
    }
}
void dfs2(int t, int f, int l, int r)
{
    L[t] = max(L[t], l - 1);
    R[t] = min(R[t], r + 1);
    for (int i = 0; i < bi[t].size(); ++ i) if (bi[t][i] != f)
        dfs2(bi[t][i], t, L[t], R[t]);
}
void dfs3(int t, int f, int d)
{
    ai[t] = d;
    for (int i = 0; i < bi[t].size(); ++ i) if (bi[t][i] != f)
        dfs3(bi[t][i], t, (d - 1 < L[bi[t][i]]? d + 1: d - 1));
}
int main()
{
    scanf("%d", &n);
    for (int i = 1; i < n; ++ i)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        bi[a].push_back(b);
        bi[b].push_back(a);
    }
    for (int i = 1; i <= n; ++ i) ai[i] = -1;
    scanf("%d", &k);
    for (int i = 1; i <= k; ++ i)
    {
        int v, p;
        scanf("%d%d", &v, &p);
        if (i == 1) r = v;
        ai[v] = p;
    }
    dfs1(r, 0, ai[r] & 1);
    dfs2(r, 0, 0, INF);
    for (int i = 1; i <= n; ++ i)
        if (L[i] > R[i])
            return puts("No"), 0;
    dfs3(r, 0, ai[r]);
    puts("Yes");
    for (int i = 1; i <= n; ++ i) printf("%d\n", ai[i]);
}


Measured memory_bytes: 18048
#include <iostream>

using namespace std;

int main()
{
	unsigned int h, w;

	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0)
			return 0;
		for (unsigned int i = 0; i < h; ++i) {
			for (unsigned int j = 0; j < w; ++j)
				cout << "#";
			cout << endl;
		}
		cout << endl;
	}
}



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


int main (){
    ll N;
    cin>>N;
    if(N%2==0){
        ll NN=N;
        ll Sum=0;
        while(NN>4){
          	NN/= 5;
            Sum += NN/2;
            
        }
        cout<<Sum;
    }
    else{
       
        cout<<0;
    }
}

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

long long n;

int main(){
    cin >> n;
    long long sqr = pow(n, 0.5);
    // cout << sqr; 

    // look decreasing from square
    long long i = sqr + 1;
    while (n % i){
        i--; 
    }
    long long p = n / i; 

    cout << p + i - 2;


}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
	int h, w, i, j;
	while(scanf("%d %d", &h, &w)){
		if(h == 0 && w == 0)
			return 0;
			
		for(i=0;i<h;i++) {
			for(j=0;j<w;j++) {
				if((i+j)%2==0) {
					printf("#");
				} else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;
typedef pair<int, int> pii;

#define S 'S'
#define X 'X'

#define W_MAX 1000

char map[W_MAX][W_MAX];
bool visited[W_MAX][W_MAX];

int main(){
  int H, W, N;
  cin >> H >> W >> N;

  pii pos; //rat position

  for(int i=0; i<H; i++){
    getchar();
    for(int j=0; j<W; j++){
      scanf("%c", &map[i][j]);
      if(map[i][j]==S){
	pos = make_pair(i,j);
      }
    }
  }

  int dx[] = {0, -1, 0 ,1}; int dy[] = {-1, 0, 1, 0};
  int ans=0;
  int next = 1; //next target num

  while(next <= N){
    for(int i=0; i<H; i++)
      for(int j=0; j<W; j++)
	visited[i][j]=false;

    queue<pair<pii, int> > q; //<pos, depth>
    q.push(make_pair(pos, 0));

    while(true){
      pair<pii, int> p = q.front(); q.pop();
      bool found = false;
      visited[p.first.first][p.first.second] = true;
      for(int i=0; i<4; i++){
	int nx = p.first.first + dx[i], ny=p.first.second + dy[i];
	if(nx>=0 && nx<H && ny>=0 && ny<W && visited[nx][ny]==false){
	  visited[nx][ny]= true;
	  if(map[nx][ny] == '0' + next){
	    found = true;
	    pos = make_pair(nx, ny);
	    break;
	  } else if(map[nx][ny]!=X){
	    q.push(make_pair(make_pair(nx, ny), p.second+1));
	  }
	}
      }
      if(found){
	ans += p.second+1;
	next++;
	break;
      }
    }
    while(!q.empty()) q.pop();
  }

  cout << ans << endl;

}

Measured memory_bytes: 3200
#include<iostream>
#include<vector>
using namespace std;
int c=0;
vector<int> merge(vector<int> A, vector<int> B){
  vector<int> res;
  int i=0,j=0;
  while(i<(int)A.size()||j<(int)B.size()){
    if(i<(int)A.size()&&j<(int)B.size()){
      if(A[i]<=B[j])res.push_back(A[i++]);
      else res.push_back(B[j++]);
    }
    else if(i<(int)A.size())res.push_back(A[i++]);
    else if(j<(int)B.size())res.push_back(B[j++]);
    c++;
  }
  return res;
}

vector<int> mergesort(vector<int> A){
  if(A.size()<2)return A;
  int mid=(A.size())/2;
  vector<int> left;
  vector<int> right;
  for(int i=0;i<(int)A.size();i++){
    if(i<mid)left.push_back(A[i]);
    else right.push_back(A[i]);
  }
  left=mergesort(left);
  right=mergesort(right);
  return merge(left,right);
}
 
 
int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  v=mergesort(v);
  for(int i=0;i<(int)v.size()-1;i++){
    cout<<v[i]<<" ";
  }
  cout<<v[n-1]<<endl<<c<<endl;
  return 0;
}


Measured memory_bytes: 15524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  int x[3],y[3];
  db r[3],R,a[3],s,b;
  fr(i,3) cin>>x[i]>>y[i];
  Fr(i,3) a[i-1]=sqrt((x[i%3]-x[i-1])*(x[i%3]-x[i-1])+(y[i%3]-y[i-1])*(y[i%3]-y[i-1]));
  s=(a[0]+a[1]+a[2])/2;
  R=sqrt((s-a[0])*(s-a[1])*(s-a[2])/s);
  b=max(a[0],max(a[1],a[2]));
  printf("%.12f\n",b*R/(b+2*R));
}

Measured memory_bytes: 256
/*template date:2019/12/27*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
#include<limits.h>
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
double to_deg(double r){return r*180.0/(atan(1.0)*4.0);}
typedef struct{
    int x;
    int y;
}pair_t;
int asc_cmp_t(const void* X,const void* Y){int x=(*(pair_t*)X).x,y=(*(pair_t*)Y).y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp_t(const void* X,const void* Y){int x=(*(pair_t*)X).x,y=(*(pair_t*)Y).y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
int main(){
    int x;scanf("%d",&x);
    if(x==2){
        printf("%d\n",x);
        return 0;
    }
    static int table[1000000]={};
    int flg=0;
    for(int i=x;1;i++){
        if(i%2==0)continue;
        flg=0;
        for(int j=3;j<sqrt((double)i);j+=2){
            if(i%j==0){
                flg=1;
                break;
            }
        }
        if(!flg){
            printf("%d\n",i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char b;
	cin>>b;
	if(b=='A')  cout<<"T";
	if(b=='T')   cout<<"A";
	if(b=='C')   cout<<"G";
	if(b=='G')   cout<<"C";
	return 0;
 } 

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a[3], b[2], c[2], answer;
	scanf("%d%d%d%d%d",&a[0],&a[1],&a[2],&b[0],&b[1]);
	if (a[0]>a[1]){
		c[0] = a[1];	
	}
	else{
		c[0] = a[0];
	}

	if (c[0]>a[2]){
		c[0] = a[2];
	}

	if (b[0]>b[1]){
		c[1] = b[1];
	}
	else{
		c[1] = b[0];
	}
	answer = c[0] + c[1] - 50;
	printf("%d\n",answer);
	
return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

bool IsPrime[1010];
vector<int> Prime;
void Eratosthenes(int N){
	for(int i = 0; i < N; i++){
		IsPrime[i] = 1;
	}
	for(int i = 2; i < sqrt(N); i++){
		if(IsPrime[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				IsPrime[i *(j + 2)] = 0;
			}
		}
	}
    for (int i = 2; i < N; i++) if(IsPrime[i]) Prime.push_back(i);
}

int main(){
    int n;
    cin >> n;
    Eratosthenes(1000);
    int divisor[1010] = {0};
    for (int i = 1; i <= n; i++) {
        int tmp = i;
        for (int j = 0; j < Prime.size(); j++) {
            int p = Prime[j];
            while(tmp % p == 0){
                tmp /= p;
                divisor[p]++;
            }
        }
    }
    ll ans = 1;
    for (int i = 1; i < 1000; i++) {
        ans = ans * (divisor[i] + 1) % 1000000007;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
X = int(input())

if X < 100:
    ans = 0
else:
    a = str(X)
    a = int(a[:-2])
    b = X - a*100

    if a >= 20:
        ans = 1

    else:
        if a*5 >= b:
            ans = 1
        else:
            ans = 0

print(ans)



Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int n,p;

int main(){
	int i;
	while( cin >> n >> p ){
		if(!n)break;
		
		int table=p;
		int temoto[50] = {0};
		int cor=0;
		
		while(1){
			int cnt=0;
			if( table == 0 ){
				table = temoto[cor];
				temoto[cor] = 0;
			}
			else{
				table--;
				temoto[cor]++;
			}
			if( table == 0 ){
				for( i = 0; i < n; i++ ){
					if( temoto[i] ){
						cnt++;
					}
				}
				if( cnt <= 1 ){
					cout << cor << endl;
					break;
				}
			}
			cor++;
			if( cor == n )
				cor = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
n, k = gets.chomp.split.map(&:to_i)
sunukes = Array.new(n, 0)

k.times do
  d = gets.chomp.to_i
  a_array = gets.chomp.split.map(&:to_i)
  a_array.each do |a|
    sunukes[a - 1] += 1
  end
end

puts sunukes.count(0)

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

int main()
{
    int n,m;
    cin>>n>>m;
    int count[n+1];
    for(int i=0; i<n+1; i++) count[i]=0;

    int ac = 0;
    int nifty = 0;
    for(int i=0; i<m; i++)
        {
        int p;
        string s;
        cin>>p>>s;
        if(s=="AC" && count[p]!=-1)
         {
            ac++;
            nifty += count[p];
            count[p] = -1;
        }
        if(s=="WA" && count[p]!=-1) 
        {
            count[p]++;
        }
    }

    cout<<ac<<' '<<nifty<<endl;

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int l;
    int d = 0;
    int t = 1;
    for(int a = 0; a < n; a++){
      l = sc.nextInt();
      d = d + l;
      if(d <= x){
        t++;
      }        
    }
    System.out.println(t);
  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n;
	int v[100005];
	int v1[100005];
	int v2[100005];
	int c1[100005]={0};
	int c2[100005]={0};
	cin>>n;
	int cnt1=0;
	int cnt2=0;
	for(int i=0;i<n;i++){
		int t=0;
		cin>>t;
		v[i]=t;
		if(i%2==0){v1[cnt1++]=t;c1[t]++;}
		else {v2[cnt2++]=t;c2[t]++;}
	}
	int ans=0;	
	for(int i=0;i<n;i++)
		if(v[0]==v[i])ans++;
	if(ans==n){cout<<n/2<<endl;return 0;}
	int first1 = c1[0];
    int second1 = c1[0];
    for(int i=0;i<100001;i++)
    {
        if(first1 < c1[i])
        {
            second1 = first1;
            first1 = c1[i];
        }
        else if(second1 < c1[i])
        {
            second1 = c1[i];
        }
	}
	int first2 = c2[0];
    int second2 = c2[0];
    for(int i=0;i<100001;i++)
    {
        if(first2 < c2[i])
        {
            second2 = first2;
            first2 = c2[i];
        }
        else if(second2 < c2[i])
        {
            second2 = c2[i];
        }
	}
	int ffirst1,fsecond1;
	int ffirst2,fsecond2;
	for(int i=0;i<100001;i++)
		if(c1[i]==first1){
			ffirst1=i;break;
		}
	for(int i=0;i<100001;i++)
		if(c1[i]==second1){
			fsecond1=i;break;
		}
	for(int i=0;i<100001;i++)
		if(c2[i]==first2){
			ffirst2=i;break;
		}
	for(int i=0;i<100001;i++)
		if(c2[i]==second2){
			fsecond2=i;break;
		}		
	//cout<<first1<<" "<<second1<<endl;
	//cout<<first2<<" "<<second2<<endl;
	if(ffirst1!=ffirst2){
		int cnt1=0;
		for(int i=0;i<n/2;i++)
			if(ffirst1==v1[i])cnt1++;
		int cnt2=0;
		for(int i=0;i<n/2;i++)
			if(ffirst2==v2[i])cnt2++;
		cout<<(n/2-cnt1)+(n/2-cnt2)<<endl;		
	}else{
		int ans1,ans2;
		//if(ffirst1!=fsecond2)
		{
			int cnt1=0;
			for(int i=0;i<n/2;i++)
				if(ffirst1==v1[i])cnt1++;
			int cnt2=0;
			for(int i=0;i<n/2;i++)
				if(fsecond2==v2[i])cnt2++;
			ans1=(n/2-cnt1)+(n/2-cnt2);
		}	
		//if(fsecond1!=ffirst2)
		{
			cnt1=0;
			for(int i=0;i<n/2;i++)
				if(fsecond1==v1[i])cnt1++;
			cnt2=0;
			for(int i=0;i<n/2;i++)
				if(ffirst2==v2[i])cnt2++;
			ans2=(n/2-cnt1)+(n/2-cnt2);
		}
		cout<<min(ans1,ans2)<<endl;		
	}	
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

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

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  string s;
  cin >> s;

  string a, b;

  if (n % 2) {
    cout << "No" << endl;
    return 0;
  }

  a = s.substr(0, n / 2);
  b = s.substr(n / 2);

  if (a == b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> Q;

ll mod = 1000000007;
int a[100010], n, m, b, c;
ll ans;
vector<P> vec;

int po(int x, int y)
{
	if (y == 0) return 1;
	return po(x, y - 1) * x;
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b >> c;
		vec.push_back(P(c, b));
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	sort(a, a + n);
	int u = 0;
	for (int i = 0; i < n; i++)
	{
		if (vec[u].first > a[i])
		{
			a[i] = vec[u].first;
			vec[u].second--;
			if (vec[u].second == 0)
			{
				if (u == m - 1)
				{
					break;
				}
				else
				{
					u++;
				}
			}
		}
		else
		{
			break;
		}
	}
	for (int i = 0; i < n; i++)
	{
		ans += a[i];
	}
	cout << ans << endl;
	cin >> m;
}

Measured memory_bytes: 1784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
#define True    1
#define False   0
//#define max(x,y) (((x)<(y))?y:x)
//============================================================================
#define MAX_BUFFER  102
struct graph{
    unsigned char node;
    unsigned char hands;
    unsigned char first;
    unsigned char last;
    struct graph **gary;
};
typedef struct graph TGraph;
//============================================================================
unsigned char Ybuffer[MAX_BUFFER];
char Zbuffer[MAX_BUFFER][MAX_BUFFER];
short Stamp;
//============================================================================
void prnnode(TGraph *gptr)
{
    short j;

    printf("node=%d, hands=%d, ", gptr->node, gptr->hands);
    for (j=0; j<gptr->hands; j++)
        printf("%d", gptr->gary[j]->node);
    printf("\n");
}
//----------------------------------------------------------------------------
void search(TGraph *gptr)
{
    short i;

#ifdef DESKTOP
    prnnode(gptr);
#endif
    if (gptr->first)
        return;
    gptr->first=++Stamp;
    if (gptr->hands)
    for (i=0; i<gptr->hands; i++)
        search(gptr->gary[i]);
    if (!gptr->last)
        gptr->last=++Stamp;
}
//----------------------------------------------------------------------------
void input(FILE *file)
{
    short i,j,n,k,u,c; char buffer[20]; TGraph *graphary,*gptr;

    fgets(buffer, sizeof(buffer)-1, file);
    sscanf(buffer, "%d", &n);
    graphary=malloc(n*sizeof(TGraph));
    memset(graphary, 0, sizeof(TGraph));
    for (i=Stamp=0; i<n; i++){
        fscanf(file, "%hd", &u);
        fscanf(file, "%hd", &k);
        gptr=&graphary[pred(u)];
        gptr->node=u;
        gptr->hands=k;
        gptr->gary=malloc(k*sizeof(TGraph*));
        for (j=0; j<k; j++){
            fscanf(file,"%hd", &c);
            gptr->gary[j]=&graphary[pred(c)];
        }
    }
#ifdef DESKTOP
    for (i=0; i<n; i++){
        prnnode(&graphary[i]);
    }
#endif
    for (i=0; i<n; i++)
        search(&graphary[i]);
    for (i=0; i<n; i++){
        gptr=&graphary[i];
        if (gptr->node)
            printf("%d %d %d\n", gptr->node, gptr->first, gptr->last);
    }

}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

template<class T> inline bool chmin(T& a, const T b) { if (a>b) { a=b; return true; } return false; }
template<class T> inline bool chmax(T& a, const T b) { if (a<b) { a=b; return true; } return false; }


int n;

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

    double div = n/3.f;
    double mo =fmod((double)n, (div*3.f));
    double ans = div*div*(div+mo);
    //DEBUG2(div,mo);
    //cout << fixed <<  setprecision(10) << ans << endl;
    cout << fixed <<  setprecision(10) << div*div*div << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll(i) = 0; i < (ll)(n); ++(i))
#define INF 10e12
#define MOD 1000000000 + 7
#define MX 51000
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))

using namespace std;

struct nap
{
    ll w;
    ll v;
};

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, W;
    cin >> N >> W;
    ll takadaka = 1000 * N + 1;
    vector<ll> w(N);
    vector<ll> v(N);
    for (ll i = 0; i < N; ++i)
        cin >> w[i] >> v[i];
    vector<vector<ll>> dp(N + 1, vector<ll>(takadaka + 1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int sum_v = 0; sum_v < takadaka; ++sum_v)
        {

            // i 番目の品物を選ぶ場合
            if (sum_v - v[i] >= 0)
                dp[i + 1][sum_v] = min(dp[i][sum_v], dp[i][sum_v - v[i]] + w[i]);

            // i 番目の品物を選ばない場合
            else
                dp[i + 1][sum_v] = dp[i][sum_v];
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < takadaka; ++sum_v)
    {
        if (dp[N][sum_v] <= W)
            res = sum_v;
    }
    cout << res << endl;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

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

int main(){
    int k;
    ll sum = 0;
    cin >> k;
    for(int i = 1;i<= k; i++){
        for(int j= 1; j<= k; j++){
            for(int l=1;l<= k; l++){
                sum += gcd(l, gcd(i,j));
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3624
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.B
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int n = cin.nextInt();
			int[] d = cin.ArrayInt(n);

			Console.WriteLine(d.Distinct().ToArray().Length);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13280
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<ll>a(n),b(n);
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  ll res=0LL;
  rep(d,29)
  {
    ll dd=1LL<<d;
    auto ta=a,tb=b;
    rep(i,n)ta[i]%=dd*2;
    rep(i,n)tb[i]%=dd*2;
    sort(all(tb));
    int cnt=0;
    rep(i,n)
    {
      cnt+=lower_bound(all(tb),dd*2-ta[i])-lower_bound(all(tb),dd-ta[i]);
      cnt+=lower_bound(all(tb),dd*4-ta[i])-lower_bound(all(tb),dd*3-ta[i]);
    }
    if(cnt%2)res|=dd;

  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 8560
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define INF 1000000007
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define CLR(a) memset((a), 0, sizeof(a))

using ll = long long;
using namespace std;

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

int main(void){

    int n;
    cin >> n;

    ll a[n];
    FOR(i,0,n)cin >> a[i];

    sort(a, a+n);

    ll ans = 1;
    ll sum = a[0];
    FOR(i,1,n){
        //cout << "sum=" << sum << ": a[i]=" << a[i] <<": ans=" << ans << endl;
        if(sum*2<a[i])ans = 1;
        else ans++;
        sum += a[i];
    }

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


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] s = br.readLine().trim().split(" ", 0);
		
		
		if( s[0].charAt(s[0].length()-1) == s[1].charAt(0) ) {
			if( s[1].charAt(s[1].length()-1) == s[2].charAt(0) ) {
		        System.out.println("YES");
		        return;
				
			}
		}

        //System.out.println(s[0].charAt(s[0].length()-1));
        System.out.println("NO");
        return;
    }
    //-----------------------------------------------------------------
    // Debug.Print
    static void dp(String s) {
		System.out.println(s);
	}
    static void dp(StringBuilder s) { dp(s.toString()); }
    static void dp(int i) { dp(String.valueOf(i)); }
    static void dp(long i) { dp(String.valueOf(i)); }


	//-----------------------------------------------------------------
	// 入力値確認：リスト
	static void checkInput(List l) { System.out.println(l); }
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、float型
	//   ＜使い方＞
	//     float[] f = new float[N];
	//     checkInput(f);
	static void checkInput(float[] i1) {
		StringBuilder sb = new StringBuilder();
		for(float i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、1次元、int型
	//   ＜使い方＞
	//     int[] c = new int[N];
	//     checkInput(c);
	static void checkInput(int[] i1) {
		StringBuilder sb = new StringBuilder();
		for(int i: i1) sb.append("[" + i + "]");
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(int[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(int[] i1: i2){
			for(int i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}
	//-----------------------------------------------------------------
	// 入力値確認：配列、二次元、int型
	static void checkInput(long[][] i2) {
		StringBuilder sb = new StringBuilder();
		for(long[] i1: i2){
			for(long i: i1) sb.append("[" + i + "]");
			sb.append(System.getProperty("line.separator"));
		}
		System.out.println(sb);
	}

}

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

int main(){
    string s; cin >> s;
    long long n = (long long)s.length();
    long long ans = n * (n + 1) / 2;
    for (auto p : lcp_array(s, suffix_array(s))) ans -= p;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 15604
N, K = map(int, input().split())
P = list(map(int, input().split()))

S = [0]
sum_ = 0
for i, p in enumerate(P):
  sum_ += p
  S.append(sum_)


max_sum = 0
for i in range(N-K+1):
  max_sum = max(max_sum, S[i+K] - S[i])

res = (max_sum + K) / 2

print(res)

Measured memory_bytes: 32164
import itertools
def main():
    n = int(input())
    p = tuple(map(int,input().split(' ')))
    q = tuple(map(int,input().split(' ')))
    for i,seq in enumerate(itertools.permutations(range(1,n+1))):
        if p==seq:
            a = i
        if q==seq:
            b = i
    print(abs(a-b))
    return 


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
s = gets.chomp.chars
array = []
ans = Array.new(s.size,0)
current = s[0]
s.each_with_index do |c,i|
  if current == "R" && c == "L"
    array << i
  end
  current = c
end
current = s[0]
s.shift
rc = 1
lc = 0
ans[array[0]-1] += 1
s.each do |c|
  if current == "R" && c == "R"
    rc += 1
    if rc.even?
      ans[array[0]] += 1
    else
      ans[array[0]-1] += 1
    end
  elsif current = "R" && c == "L"
    rc = 0
    lc += 1
    if lc.odd?
      ans[array[0]] += 1
    else
      ans[array[0]-1] += 1
    end
  elsif current = "L" && c == "R"
    lc = 0
    rc += 1
    array.shift
    if rc.even?
      ans[array[0]] += 1
    else
      ans[array[0]-1] += 1
    end
  elsif current = "L" && c == "L"
    lc += 1
    if lc.odd?
      ans[array[0]] += 1
    else
      ans[array[0]-1] += 1
    end
  end
  current = c
end
puts ans.join(" ")
 

Measured memory_bytes: 11260
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

struct Point{
	double x, y;
};


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

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (a * b < c * d) {
		cout << c * d << endl;
	} else {
		cout << a * b << endl;
	}
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if(s == "SUN") cout << 7 << endl;
  if(s == "MON") cout << 6 << endl;
  if(s == "TUE") cout << 5 << endl;
  if(s == "WED") cout << 4 << endl;
  if(s == "THU") cout << 3 << endl;
  if(s == "FRI") cout << 2 << endl;
  if(s == "SAT") cout << 1 << endl;
}


Measured memory_bytes: 256
<?php
$N = fgets(STDIN);
$func = explode(" ",fgets(STDIN));
$H = explode(" ",fgets(STDIN));
$near = 10000;
$i = 0;
while($i<$N){
$temp = $func[0]-0.006*$H[$i];
$ans[$i] = abs($temp-$func[1]);
//$ans[$i] = abs($ans[$i]);
if($near>$ans[$i]){
$answer = $i;
$near = $ans[$i];
}

$i++;
}
echo $answer+1;

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

using namespace std;

typedef pair<int, int> P;
const int inf = 1000000007;

int h, w;
char field[55][55];
int d[55][55];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int blackcount = 0;

void bfs() {
    cin >> h >> w;
    queue<P> que;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> field[i][j];
            if (field[i][j] == '#') ++blackcount;
            if (i == 0 && j == 0) {
                que.push(P(i, j));
                d[i][j] = 1;
            } else {
                d[i][j] = inf;
            }
        }
    }
    while (!que.empty()) {
        P p = que.front();
        que.pop();
        for (int i = 0; i < 4; ++i) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if (nx >= 0 && nx < h && ny >= 0 && ny < w && d[nx][ny] == inf && field[nx][ny] == '.') {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    cout << max(h * w - d[h - 1][w - 1] - blackcount, -1) << '\n';
}

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


Measured memory_bytes: 256
//q014.cpp
//Wed Sep 23 23:02:45 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#include <bitset>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,k;
	cin >> n >> k;

	ll a[n];
	rep(i,n) cin >> a[i];

	ll ans = 1e12;
	rep(i,1<<n){
		ll tmp = 0;
		int z = bitset<32>(i).count();
		if (z<k)continue;
		ll cur = 0;
		rep(j,n){
			if (i>>j & 1){
				tmp += max(cur-a[j]+1,0LL);
				cur = max(cur+1,a[j]);
			}else {
				cur = max(cur,a[j]);
			}
		}
		ans = min(ans,tmp);
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	while (cin >> n){
		if (n == 0)return 0;
		int    e;
		int d, a, c, f;
		int    b;
		//??????????±???????
		a = 1; b = 2; c = 3; d = 4; e = 5; f = 6;
		int sum = a;
		for (int i = 0; i < n; i++){
			string s;
			cin >> s;
			int tmp;
			if (s == "North") {
				tmp = a;
				a = b;
				b = f;
				f = e;
				e = tmp;
			}
			else if (s == "East") {
				tmp = a;
				a = d;
				d = f;
				f = c;
				c = tmp;
			}
			else if (s == "West") {
				tmp = a;
				a = c;
				c = f;
				f = d;
				d = tmp;
			}
			else if (s == "South") {
				tmp = a;
				a = e;
				e = f;
				f = b;
				b = tmp;
			}
			else if (s == "Right") {
				tmp = b;
				b = c;
				c = e;
				e = d;
				d = tmp;
			}
			else if (s == "Left") {
				tmp = b;
				b = d;
				d = e;
				e = c;
				c = tmp;
			}
			sum += a;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3048
// G++ MACRO.CPP -STD=C++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<ll,ll>
#define V vector<ll>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define str string

#define pb(a) push_back(a)
#define mp make_pair


int main(){
  CIN(n,k);VC1(n,a);
  M map_;REP(i,n)map_[a[i]]++;
  M map_2;FOREACH(xx,map_)map_2[xx.second]++;
  int count = map_.size() - k;
  ll num=0;
  FOREACH(xx,map_2){
    if(count<=0)break;
    if(xx.second >= count){
      num+=xx.first * count;
      break;
    }
    num+=xx.first * xx.second;
    count -= xx.second;
  }
  COUT(num);
 
  return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;

int main(){
	cin.sync_with_stdio(false);
	while(1){
		cin>>n;
		if(n==0)break;
		int res=0;
		rep(i,n)repl(j,i+1,n){
			if(j*(j+1)/2-i*(i+1)/2==n)res++;
		}
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int n, m, a, b, c, d, ans;
string str;
int main(void)
{

	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> str;
	if (str == "SUN")
	{
		cout << 7 << endl;
	}
	else if (str == "MON")
	{
		cout << 6 << endl;
	}
	else if (str == "TUE")
	{
		cout << 5 << endl;
	}
	else if (str == "WED")
	{
		cout << 4 << endl;
	}
	else if (str == "THU")
	{
		cout << 3 << endl;
	}
	else if (str == "FRI")
	{
		cout << 2 << endl;
	}
	else if (str == "SAT")
	{
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256