akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define fof(i,a,b) for(int i=a;i<=b;i++)
#define off(i,a,b) for(int i=a;i>=b;i--)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define stl(i,x) for(auto i=x.begin(); i!=x.end();i++)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define nl endl

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}
ll pw(ll a, ll b)
{
    ll ans = 1;
    for(ll i = 1; i <= b; ++i)
        ans = (ans * a);
    return ans;
}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    ll n;cin>>n;
    ll a[n];
    vector<pair<ll,ll>>vp;
    //fil(cnt);
    fo(i,n){
        cin>>a[i];
    }
    vp.pb({a[n-1],0});
    int c=0;
    for(int i=n-2;i>=0;i--)
    {
        if(a[i]<a[i+1]){
            c++;
            vp.pb({a[i],c});
        }
        else{
            c=0;
            vp.pb({a[i],c});
        }
    }
    reverse(all(vp));
    //fo(i,vp.size())cout<<vp[i].first<<" "<<vp[i].second<<endl;

    ll have=1000,stock=0;
    ll k = vp.size();
    for(int i=0;i<k;)
    {
        if(vp[i].second>0){
            stock = have/vp[i].first;
            have = have%vp[i].first;
            //cout<<"stock = "<<stock<<endl;
            i+=vp[i].second;
            have += stock*vp[i].first;
            //cout<<"have = "<<have<<endl;
        }
        else{
            i++;
            continue;
        }
    }
    cout<<have<<endl;
    return 0;
}

///Alhamdulillah


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


bool f(int n) {
  string s = to_string(n);
  string r = s;
  reverse(ALL(r));
  return s == r;
}

int main2() {
  int A, B; cin >> A >> B;
  int ans = 0;
  for (int i = A; i <= B; i++) if (f(i)) ++ans;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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






int main() {
  int a,b;
  cin>>a>>b;
  a=a-1;
  b=b-1;
  cout<<(b+a-1)/a<<endl;
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

VV<int> e;
VV<ll> subsc;
VV<ll> pl,pr;

V<ll> sco;
ll m;

ll dfs1(int now,int prev){
  ll res=1,tmp;
  rep(i,0,siz(e[now])){
    if(e[now][i]!=prev){
      tmp=1+dfs1(e[now][i],now);
      tmp%=m;

      res*=tmp;
      res%=m;
      subsc[now].pb(tmp);
    }else{
      subsc[now].pb(1);
    }
  }
  sco[now]=res;
  return res;
}

void dfs2(int now,int prev,ll usco){
  sco[now]*=usco%m;
  sco[now]%=m;
  rep(i,0,siz(e[now])){
    if(e[now][i]!=prev){
      dfs2(e[now][i],now,(((pl[now][i]*pr[now][i+1])%m)*usco +1+m)%m);
    }
  }
  
  return ;
}


signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n;cin>>n>>m;
  e.assign(n,V<int>(0));
  sco.assign(n,0);
  subsc.assign(n,V<ll>(0));

  rep(i,0,n-1){
    int x,y;cin>>x>>y;
    x--;y--;
    e[x].pb(y);
    e[y].pb(x);
  }
  
  dfs1(0,-1);

  pl.assign(n,V<ll>(1,1));
  pr.assign(n,V<ll>(1,1));
  rep(i,0,n){
    pl[i].insert(pl[i].begin()+1,all(subsc[i]));
    pr[i].insert(pr[i].begin(),all(subsc[i]));
  }

  rep(i,0,n){
    rep(j,1,siz(pl[i])){
      pl[i][j]*=pl[i][j-1];
      pl[i][j]%=m;
    }
    repr(j,1,siz(pr[i])){
      pr[i][j-1]*=pr[i][j];
      pr[i][j-1]%=m;
    }
  }
  
  dfs2(0,-1,1);

  rep(i,0,n){
    cout<<sco[i]<<ENDL;
  }
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

// EDPC V rerooting

Measured memory_bytes: 30208
a,b,k=map(int,input().split())

cnt=int(b-a+1)

if cnt<=2*k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)

Measured memory_bytes: 9104
n, k = map(int, input().split())
p = list(map(int, input().split()))

num_sum = 0

max_pair = (0, k-1)
for i in range(k):
    num_sum += p[i]
max_sum = num_sum

for i in range(k, len(p)):
    num_sum -= p[i-k]
    num_sum += p[i]
    # print(num_sum, i-k+1,i)
    if num_sum > max_sum:
        max_sum = num_sum
        max_pair = (i-k+1, i)
avg = 0
for i in range(max_pair[0], max_pair[1]+1):
    num = p[i]
    num_sum = round(num *(num+1)/(2*num), 10)
    avg += num_sum
print(avg)

Measured memory_bytes: 25604
N, M, C = [int(s) for s in input().split(' ')]
B = [int(s) for s in input().split(' ')]
solve = 0
for i in range(N):
    A = [int(s) for s in input().split(' ')]
    sum = C
    for j in range(M):
        sum += A[j] * B[j]
    solve += int(sum > 0)
print(solve)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

signed main() {
  int a, b, c, d; cin >> a >> b >> c >> d;
  int ans = max({a*c, a*d, b*c, b*d});
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {
  int k;
  int a, b;
  int judge = 0;
  scanf("%d", &k);
  scanf("%d%d", &a, &b);
  for(int i = a; i <= b; i++) {
    if(i % k == 0) {
      judge = 1;
    }
  }
  if(judge == 1) {
    printf("OK");
  } else {
    printf("NG");
  }
  return 0;
}


Measured memory_bytes: 1732
N, M = gets.split.map(&:to_i)
Xs = gets.split.map(&:to_i)
ans = 0

Xs.sort!
tmp = []
(Xs.length - 1).times{|x|
    tmp[x] = Xs[x+1] - Xs[x]
}
tmp.sort!

if (M-N) > 0
    ans = tmp[0..(tmp.length- 1 - (N-1))].inject{|sum,n| sum+n}
end

puts ans


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


int main(){
	
	long long int N, R=0, W=0, count=0;
	char c;
	vector<int> stones;

	cin >> N;
	rep(i, N){
		cin >> c;
		if(c == 'R'){
			R++;
			stones.push_back(0);
		}else if(c == 'W'){
			W++;
			stones.push_back(1);
		}
	}
	rep(i, R){
		count += stones[i];
	}

	cout << count;	

	return 0;
}

Measured memory_bytes: 4220
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int p[310000];
int t[301000];

int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
		p[i]--;
	}
	for(int i=0;i<a;i++){
		t[p[i]]++;
	}
	std::sort(t,t+a);
	reverse(t,t+a);
	int at=0;
	int ans=a;
	int cur=a;
	for(int i=1;i<=a;i++){
		while(ans){
			while(at<a&&t[at]>ans){
				cur-=t[at];
				at++;
			}
			if(i*ans<=cur+ans*at)break;
			ans--;
		}
		printf("%d\n",ans);
	}

}

Measured memory_bytes: 3072
from sys import stdin


def main():

    N = int(input())

    result = [0] * 4

    for _ in range(N):
        S = stdin.readline()[:-1]
        if S == 'AC':
            result[0] += 1
        elif S == 'WA':
            result[1] += 1
        elif S == 'TLE':
            result[2] += 1
        else:
            result[3] += 1

    print("AC x " + str(result[0]) + "\nWA x " + str(result[1]) + "\nTLE x " + str(result[2]) + "\nRE x " + str(result[3]))

main()

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.141592653589793238
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld n, i;
      lld r;
      cin >> n;
      lld A[n+1];
      foi(i,n+1)
      {
      	A[i]=0;
      }
      foi(i,n-1)
      {
      	cin >> r;
      	A[r]+= 1;
      }
      for(i = 1; i < n+1; i++)
      	cout << A[i] << "\n";
      return 0;
}

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

int main(){
    int n,x;
    cin>>n>>x;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    x-=sum;
    sort(a,a+n);
    cout<<n+(x/a[0]);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *p;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  Node y;
  y=x;
  while(y->left!=NIL) y=y->left;

  return y;

}

Node treeMaximum(Node x){
 Node y;
  y=x;
  while(y->left!=NIL) y=y->right;

  return y;

}

Node treeSearch(Node u, int k){
  Node x;
  x=u;

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

  return x;

}

Node treeSuccessor(Node x){
  Node y;

  if(x->right!=NIL)return treeMinimum(x->right);

  y=x->p;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->p;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

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

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

  if(x!=NIL)x->p=y->p;
  if(y->p==root)root=x;
  else if(y == y->p->left)y->p->left=x;
  else y->p->right=x;

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

}

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

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

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

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

}

void inorder(Node u){
  if (u==NIL)return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
if (u==NIL)return;

 printf(" %d",u->key);
 preorder(u->left);
 preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  Node t;
  scanf("%d", &n);

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

  return 0;
}

Measured memory_bytes: 19364
#include<stdio.h>

int main(void){
        int P, Q, R;
        int SUM[6] = {0};
        int i;
        int minimam = 0;

        scanf("%d %d %d", &P, &Q, &R);
        SUM[0] = P + Q;
        SUM[1] = R + Q;
        SUM[2] = P + R;
        SUM[3] = Q + R;
        SUM[4] = R + P;
        SUM[5] = Q + P;

        minimam = SUM[0];
        for(i=1; i< 6; i++){
                if(minimam > SUM[i]){
                        minimam = SUM[i];
                }
        }
        printf("%d\n", minimam);
        return 0;
}

Measured memory_bytes: 128
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  string s;
  cin >> s;
  int N = s.size();
  int ans = N;
  for (int i = 0; i < N - 1; i++) {
    if (s[i] != s[i + 1]) {
      ans = min(ans, max(i + 1, N - i - 1));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
 
//const long long INF = 1LL << 55;
 
#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main(void){
   int n;cin >> n;
   vector<int> a(n);rep(i,n)cin >> a[i];
   int ans = 0;
   for(int i = 0;i < n - 1;i++){
      for(int j = i + 1;j < n;j++){
         ans += a[i]*a[j];
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

/**
 * Created 2017/06/10.
 */
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    ArrayList<Integer> num = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      int input = sc.nextInt();
      num.add(input);
    }
    Collections.reverse(num);

    //System.out.println(num);
    
    for (int i = 0; i < num.size(); i++) {
      if (i == num.size() - 1) {
        System.out.println(num.get(i));
      } else {
        System.out.print(num.get(i));
        System.out.print(" ");
      }
    }
  }
}

Measured memory_bytes: 25952
def main():
    N, K = map(int, input().split())
    h = [0] + list(map(int, input().split()))
    dp = [float("inf") for _ in range(N + 1)]

    dp[1] = 0
    for i in range(2, N + 1):
        dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(0, i - K), i))

    print(dp[-1])


main()


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

#define PI acos(-1)
#define pb push_back
#define int long long int
#define mp make_pair
#define pi pair<int, int>
#define pii pair<int, pi>
#define fir first
#define sec second
#define MAXN 100001
#define MAXL 20
#define mod 998244353
#define INF 9999999

signed main()
{
  int n;
  cin >> n;
  vector<char> ans;
  while (n > 0)
  {
    int at = n % 26;
    if (at == 0)
    {
      ans.pb('z');
      n--;
    }
    else
    {
      ans.pb((at - 1) + 'a');
    }
    n = n / 26;
  }
  for (int i = ans.size() - 1; i >= 0; i--)
    cout << ans[i];
  cout << endl;
  return 0;
}

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

int main()
{
  int n;
  cin >> n;
  int a[n];
  int sumr = 0, suml = 0, ans = 10005;
  rep(i, n) {
    cin >> a[i];
    sumr += a[i];
  }
  if(n == 2){
    cout << abs(a[0] - a[1]) << endl;
    return 0;
  }
  rep(i, n - 1){
    suml += a[i];
    sumr -= a[i];
    ans = min(ans, abs(suml - sumr));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


string s;

bool f(int m){
  if(s[m]=='A'||s[m]=='C'||s[m]=='G'||s[m]=='T') return true;

  return false;
}

int main(){
  cin>>s;

  int ans=0;

  rep(i,s.size()){
    int j=i;
    while(f(j)&&j<s.size()) j++;
    ans=max(ans,j-i);
  }

  cout<<ans<<endl;
}


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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

ll addmod(ll a,ll b)
{
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a %=mod;
    b%=mod;
    return (a*b)%mod;
}
ll submod(ll a,ll b)
{
    ll x  = a-b;
    if(x<0)x+=mod;
    x%=mod;
    return x;
}
bool comp(pair<pi,ll>a,pair<pi,ll>b)
{
    if(a.fi.fi==b.fi.fi)return a.fi.se<b.fi.se;
    return a.fi.fi<b.fi.fi;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n; cin>>n;
    map<string,ll>mp;
    string s;
    ll ans = 0;
    rep(i,0,n)
    {
        cin>>s;
        mp[s]++;
    }
    for(auto x:mp)ans++;
    cout<<ans<<endl;
    return 0;
}
/*
5 10 10
22 23
17 19
13 17
8 12
2 6
*/


Measured memory_bytes: 19216
//---------- begin union_find ----------
#[allow(dead_code)]
mod union_find {
    pub struct UF {
        p: Vec<i32>,
    }
    impl UF {
        pub fn new(n: usize) -> UF {
            UF {p: vec![-1; n] }
        }
        pub fn init(&mut self) {
            for p in self.p.iter_mut() {
                *p = -1;
            }
        }
        pub fn root(&self, mut x: usize) -> usize {
            while self.p[x] >= 0 {
                x = self.p[x] as usize;
            }
            x
        }
        pub fn same(&self, x: usize, y: usize) -> bool {
            self.root(x) == self.root(y)
        }
        pub fn unite(&mut self, mut x: usize, mut y: usize) -> Option<(usize, usize)> {
            x = self.root(x);
            y = self.root(y);
            if x == y {
                return None;
            }
            if self.p[x] > self.p[y] {
                let s = x;
                x = y;
                y = s;
            }
            self.p[x] += self.p[y];
            self.p[y] = x as i32;
            Some((x, y))
        }
        pub fn get_size(&self, x: usize) -> usize {
            let r = self.root(x);
            (-self.p[r]) as usize
        }
    }
}
//---------- end union_find ----------
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let mut a: Vec<(usize, usize)> = (0..n).map(|k| (it.next().unwrap().parse().unwrap(), k)).collect();
    let mut b: Vec<(usize, usize)> = (0..n).map(|k| (it.next().unwrap().parse().unwrap(), k)).collect();
    a.sort();
    b.sort();
    let mut u = union_find::UF::new(n);
    for (a, b) in a.iter().zip(b.iter()) {
        if a.0 > b.0 {
            println!("No");
            return;
        }
        u.unite(a.1, b.1);
    }
    if u.get_size(0) < n {
        println!("Yes");
        return;
    }
    for i in 1..n {
        if a[i].0 <= b[i - 1].0 {
            println!("Yes");
            return;
        }
    }
    println!("No");
}

fn main() {
    run();
}


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

int main() {
    int n, l;
    cin >> n >> l;
    int s = 0;
    int t = l;
    bool ok = false;
    rep(i,n) {
        if (t == 0) ok = true;
        s += t;
        t++;
    }
    if (ok) cout << s << endl;
    else if (l<0) cout << s-t+1 << endl;
    else cout << s-l << endl;
    return 0;
}


Measured memory_bytes: 3604
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    cout << fixed << setprecision(15);
    int n;cin >> n;
    //string s;cin >> s;
    
    int ans=0;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) {
            for(int k=1;k<=n;k++) {
              ans+=(__gcd(i,__gcd(j,k)));  
            }
        }
    }
    
    cout << ans;
    
    
	return 0;
    
}

Measured memory_bytes: 10680
#include <iostream>
#include <cstdint>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int abs( int a ) { return a < 0 ? -a : a; }

int main() {
	int x, a;
	cin >> x >> a;
	cout << ( x < a ? 0 : 10 ) << endl;
	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<long long> vect(n);
    for(int i=0; i< n ; i++){
        cin >> vect[i];
    }
    sort(vect.begin(),vect.end() );
    long long max = vect[n-1];
    long long up = *upper_bound(vect.begin(), vect.end(), max/2);
    long long low = *(--upper_bound(vect.begin(), vect.end(), max/2));
    if( up*2 - max < max -low*2) {
        cout << max << " " << up << endl;
    } else {
        cout << max << " " << low << endl;
    }
    return 0;

}


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

void Main() {
  string s;
  cin >> s;
  if (s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



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

using namespace std;

int main()
{
    /*int x,a,b,c,i,j,k;
    cin>>a>>b>>c>>x;
    long cnt=0;
    for(i=0;i<=a;i++)
    {
        for(j=0;j<=b;j++)
        {
            for(k=0;k<=c;k++)
            {
                if((500*i+100*j+50*k)==x)
                    cnt++;
            }
        }
    }
    cout<<cnt<<"\n";*/
    int n,i;
    cin>>n;
    int a[n];
    int b[n];
    int c[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
        cin>>b[i];
    for(i=1;i<n;i++)
        a[i]+=a[i-1];
    for(i=n-2;i>=0;i--)
        b[i]+=b[i+1];
    for(i=0;i<n;i++)
        c[i]=a[i]+b[i];
    sort(c,c+n);
    cout<<c[n-1]<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int h,w;
int c[10][10],a[200+5][200+5];
int mp[10];

void solve(int &ini,int cur,int &sum){
	if(sum>=mp[ini])return;
	int s[10];
	for(int i=0;i<10;i++){
		if(i==cur)continue;
		s[i]=(c[cur][i]+sum);
		if(i!=1)solve(ini,i,s[i]);
		else{
			if(s[1]<mp[ini])mp[ini]=s[1];
		}
	}
}

int main(){
	scanf("%d%d",&h,&w);
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++)scanf("%d",&c[i][j]);
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)scanf("%d",&a[i][j]); 
	}
	for(int i=0;i<10;i++)mp[i]=c[i][1];
	for(int i=0;i<10;i++){
		if(i==1)continue;
		int sum=0;
		solve(i,i,sum);
	}
	int count=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(a[i][j]==-1||a[i][j]==1)continue;
			count+=mp[a[i][j]];
		}
	}
	printf("%d",count);
	return 0;
}

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

using namespace std;

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

	vector<int> L;
	for (int i = 0; i < N; i++) {
		int l;
		cin >> l;
		L.push_back(l);
	}

	sort(L.begin(), L.end(), greater<>());

	int sum = 0;
	for (int i = 0; i < K; i++) {
		//cout << L[i] << endl;
		sum = sum + L[i];
	}

	cout << sum << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
	char str[6];
	scanf("%s",str);
	if (str[0] == str[1] && str[1] == str[2] && str[2] == str[3])
		printf("No");
	else if(str[0] == str[1] && str[2] == str[3])
		printf("Yes");
	else if(str[0] == str[2] && str[1] == str[3])
		printf("Yes");
	else if(str[0] == str[3] && str[1] == str[2])
		printf("Yes");
	else
		printf("No");

	return(0);
}


Measured memory_bytes: 128
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let MOD = 1000000007

/// n! (mod p)
/// O(n)
let inline factorial n p =
    if n = LanguagePrimitives.GenericZero then
        1L
    else
        List.fold (fun s x -> s * x % int64 p) 1L [1L .. int64 n]
    |> int

/// x ^ n (mod p)
/// O(log n)
let inline pownMod x n p =
    let rec loop x n p =
        if n = 1L then
            x
        elif n % 2L = 0L then
            loop (x * x % p) (n / 2L) p
        else
            loop (x * x % p) (n / 2L) p * x % p
    loop (int64 x) (int64 n) (int64 p)
    |> int

/// C(n, k) (mod p)
/// O(n + k + log p)
let inline comb n k p =
    let zero = LanguagePrimitives.GenericZero
    let one = LanguagePrimitives.GenericOne
    if n < zero || k < zero || n < k then
        0L
    elif n = zero || k = zero then
        1L
    else
        let a = factorial n p
        let b = factorial k p
        let c = factorial (n - k) p
        let pb = pownMod b (p - one - one) p
        let pc = pownMod c (p - one - one) p
        ((int64 a * int64 pb % int64 p) * int64 pc) % int64 p
    |> int

[<EntryPoint>]
let main _ =
    let [X;Y] = reads int

    if (X + Y) % 3 <> 0 then
        0
    else
        let m = (2 * X - Y) / 3 |> int64
        let n = (-X + 2 * Y) / 3 |> int64
        comb (m + n) n MOD
    |> printfn "%i"

    0

Measured memory_bytes: 61612
#include<stdio.h>
#define MAXLEN 150
int arr[4][MAXLEN];
int dp[4][MAXLEN];
int max(int a,int b)
{
	return a>b?a:b;
}
 int main(void)
 {
 	int i,j,nCol;
 	scanf("%d",&nCol);
 	for(i=1;i<=2;i++)
 	{
 		for(j=1;j<=nCol;j++)
 		{
 			scanf("%d",&arr[i][j]);
		}
	}
	 for(i=nCol;i>=1;i--)
	 {
	 	for(j=2;j>=1;j--)
	 	{
	 		dp[j][i]=max(dp[j][i+1],dp[j+1][i])+arr[j][i];
		 }
	}
	 printf("%d",dp[1][1]);
 	return 0;
  }


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

int n,m,q;
vector<int> a(50),b(50),c(50),d(50);
int ans;

/*数列を作る*/
void dfs(vector<int> A){
    if(A.size() == n){
        /*q個のテストを試し点数をつける*/
        int now = 0;
        for(int i = 0;i < q;i++){
            if(A[b.at(i) - 1] - A[a.at(i) - 1] == c.at(i)){
                now += d.at(i);
            }
        }

        //cout << now << endl;
        ans = max(ans,now);
        return;
    }
        /*数列を作る*/
    A.push_back(A.back());
    while(A.back() <= m){
        dfs(A);
        A.back()++;
    }
}

int main(){
    cin >> n >> m >> q;
    for(int i = 0;i < q;i++){
        cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    }
    /**/
    dfs(vector<int>(1,1));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3576
N = int(input())
a_dic = {}
for i in range(1, N+1):
    a = int(input())
    a_dic[i] = a
lamp = 1
cnt = 0
ans = -1
while(cnt<N):
    if lamp in a_dic:
        lamp = a_dic[lamp]
    else:
        break
    cnt += 1
    if lamp==2:
        ans = cnt
        break
print(ans) 

Measured memory_bytes: 17892
#1_6_B
l = []
n = int(input())
for k in range(n):
    l.append(input())
cards = ['S 1','S 2','S 3','S 4','S 5','S 6','S 7','S 8','S 9','S 10','S 11','S 12','S 13',
    'H 1','H 2','H 3','H 4','H 5','H 6','H 7','H 8','H 9','H 10','H 11','H 12','H 13',
    'C 1','C 2','C 3','C 4','C 5','C 6','C 7','C 8','C 9','C 10','C 11','C 12','C 13',
    'D 1','D 2','D 3','D 4','D 5','D 6','D 7','D 8','D 9','D 10','D 11','D 12','D 13']

x = sorted(set(l) ^ set(cards),key=cards.index)
for i in range(len(x)):
    print(x[i])


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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
  }

  auto allMatch = [](auto p, auto q, int n) {
    for (int i = 0; i < n; i++) {
      if (p[i] != q[i]) return false;
    }
    return true;
  };

  vector<int> iot(n);

  iota(iot.begin(), iot.end(), 1);
  int cntp = 0;
  do {
    if (allMatch(p, iot, n)) break;
    ++cntp;
  } while (next_permutation(iot.begin(), iot.end()));

  iota(iot.begin(), iot.end(), 1);
  int cntq = 0;
  do {
    if (allMatch(q, iot, n)) break;
    ++cntq;
  } while (next_permutation(iot.begin(), iot.end()));

  cout << abs(cntp - cntq) << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int A,B,K;
    cin >>A>>B>>K;
    int cnt = 0;
    int ans = 0;
    for(int i = 1;i <=100;i++){
        if(A % i == 0 && B % i == 0){
            cnt++;
            ans = i;
        }
    }
    int cnt2 = 0;
    for(int i = 1;i <= 100;i++){
        if(A % i == 0 && B % i == 0){
            cnt2++;
            ans = i;
        }
        if(cnt2 == cnt - K + 1){
            cout << ans << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
/* ex3_3
   shu_t */

#include<stdio.h>
#include<math.h>

int main(void){
  //for using pow
  double number,system;
  
  int ans=0;
  //input number and system (double type)
  scanf("%lf %lf",&number,&system);
  while(pow(system,ans) <= number){
    // answer is min(i) (satisfy n<k^i)
    ans += 1;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
H,W = list(map(int,input().split()))
N = int(input())
A = list(map(int,input().split()))
cnt = 0
L = []
i = 1
while cnt<H*W:
    if A[i-1]>0:
        A[i-1]+=-1
        L.append(i)
        cnt+=1
    else:
        i+=1
for i in range(H):
    out = [0]*W
    if i%2==0:
        for j in range(W):
            out[j]=L[W*i+j]
    else:
        for j in range(W):
            out[W-1-j]=L[W*i+j]
    print(*out)

Measured memory_bytes: 74356
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt()*100+sc.nextInt()*10+sc.nextInt();
		if(n%4==0){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
		return;
	}
}

Measured memory_bytes: 20436
s = int(input())

used = set([s])
a = s
for i in range(2, 1000000):
    if a % 2 == 0:
        next = a // 2
    else:
        next = 3 * a + 1

    if next in used:
        print(i)
        break
    else:
        used.add(next)
        a = next


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

int main()
{
    int a, b, c;
    cin >> a >> b;
    c = (a * b) % 2;
    if (c == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

int find(int a, int c){
	return a/c;
}

int range(int a, int b, int c){
	return find(b, c) - find(a-1, c);
}
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int g = __gcd(c, d);
	g = (c*d)/g;
	int x = range(a, b, c) + range(a, b, d) - range(a, b, g);
	cout << b - a + 1 - x;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll T1,T2,A1,A2,B1,B2;
  cin>>T1>>T2>>A1>>A2>>B1>>B2;
  ll X=A1-B1;
  ll Y=A2-B2;
  if(X<0){
    X=-X;
    Y=-Y;
  }
  ll P=X*T1;
  ll Q=Y*T2;
  if(P+Q==0) cout<<"infinity"<<endl;
  else if(P+Q>0) cout<<0<<endl;
  else{
    ll R=P/(-P-Q);
    if(P%(-P-Q)) cout<<2*R+1<<endl;
    else cout<<2*R<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n; 

  vector<ll> p(n);
  rep(i,n){
    cin>>p[i];
  }

  auto q=p;
  auto r=p;

  repo(i,n){
    q[i]=gcd(q[i-1],p[i]);
  }

  for(int i=n-2;i>=0;i--){
    r[i]=gcd(r[i+1],p[i]);
  }

  ll ans=max(q[n-2],r[1]);

  repo(i,n-1){
    chmax(ans,gcd(q[i-1],r[i+1]));
  }

  cout << ans << endl;
}

Measured memory_bytes: 5572
n,k=map(int,input().split())
lists=[0]*n
for i in range(n):
    lists[i]=tuple(map(int,input().split()))
lists=sorted(lists,key=lambda x: x[0])

count=0
num=0
for j in range(n):
    if count<k:
        count=count+lists[j][1]
        num=lists[j][0]

    else:
        break
print(num)

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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define sz(v) ll(v.size())


void solve(ll N, ll Q, string S, vector<ll> l, vector<ll> r){
    vector<ll> a(N);
    fill(a.begin(), a.end(), 0);
    rep(i, N-1) {
        if (S[i] == 'A' && S[i+1] == 'C') a[i] = 1;
    }
    vector<ll> b(N);
    fill(b.begin(), b.end(), 0);
    rep(i, N-1) {
        b[i+1] = b[i] + a[i];
    }
    rep(i, Q) {
        cout << b[r[i]-1] - b[l[i]-1] << endl;
    }
}

int main() {
  ll N;
    scanf("%lld",&N);
    ll Q;
    scanf("%lld",&Q);
    string S;
    cin >> S;
    vector<ll> l(Q);
    vector<ll> r(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&l[i]);
        scanf("%lld",&r[i]);
    }
  solve(N, Q, S, move(l), move(r));
  return 0;
}


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

int main()
{
    double n,var=0,ar[100005];
    cin>>n;

    for(int i=1;i<=n;i++){
        cin>>ar[i];
        var = var+ (1/ar[i]);
    }
    double res = 1/var;
    cout<<res<<endl;

}


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



Measured memory_bytes: 3068
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    double ans;
    ll hasMultiAns = 0;
    ans = (double)(W * H) / 2.0;
    if(x * 2 == W && y * 2 == H){
        hasMultiAns = 1;
    }

    cout << std::fixed << std::setprecision(12) << ans << " " << hasMultiAns << endl;

    return 0;
}


Measured memory_bytes: 3764
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;

int N;
ll d[300][300];
ll ans=0;
int main()
{
  cin>>N;
  rep(i,N) rep(j,N){
    cin>>d[i][j];
  }
  rep(i,N) for(int j=i+1;j<N;j++){
    ans+=d[i][j];
    rep(k,N){
      if(d[i][j]>d[i][k]+d[k][j]){
        cout<< -1 <<endl;
        return 0;
      }
    }
  }
  rep(i,N) for(int j=i;j<N;j++){
    rep(k,N){
      if(k != i && k != j && d[i][j] == d[i][k] + d[k][j] ){
        ans -= d[i][j];
        break;
      }
    }
  }
  cout<<ans<<endl;
}


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

int main() {
  
  int N; cin >> N;
  
  vector<int> vec(N); int64_t ans = 10000001;
  
  for (int i = 0; i < N; i++) cin >> vec[i];
  
  for (int i = -100; i <= 100; i++) {
    
    int64_t tmp = 0;
    
    for (int j = 0; j < N; j++) {
      
      int dif = vec[j] - i;
      
      tmp += dif * dif;
      
    }
    
    ans = min(ans, tmp);
    
  }
  
  cout << ans << endl;
  
}

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

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

    map<string, int> count;
    string S_i;
    for (int i = 0; i < N; i++)
    {
        cin >> S_i;
        count[S_i] += 1;
    }

    int max = 0;
    for (auto &&i : count)
    {
        if (i.second > max)
        {
            max = i.second;
        }
    }
    
    for (auto &&i : count)
    {
        if (i.second == max)
        {
            cout << i.first << endl;
        }
    }
}

Measured memory_bytes: 25216
import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner (System.in);
        
        int n = sc.nextInt();
        String[] array = new String[n];
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        
        for (int i = 0; i < n; i++) {
            array[i] = sc.next();
            
            if (array[i].equals("AC")) {
                ac++;
            } else if (array[i].equals("WA")) {
                wa++;
            } else if (array[i].equals("TLE")) {
                tle++;
            } else if (array[i].equals("RE")) {
                re++;
            }
        }
            
            System.out.println("AC x " + ac);
            System.out.println("WA x " + wa);
            System.out.println("TLE x " + tle);
            System.out.println("RE x " + re);
        
        
        
        
    }
}

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

int main() {
	int N;
  	int l;
  	int r;
  	int sum = 0;
  	cin >> N;
  	for (int i = 0; i < N; i++) {
    	cin >> l >> r;
      	sum += r - l + 1;
    }
  	cout << sum << endl;
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

ll dp[100001];
int main(){
  int N, W;
  cin >> N >> W;
  rep(i, N){
    ll w, v;
    cin >> w >> v;
    rrep(j, W){
      if(j + w > W) continue;
      dp[j + w] = max(dp[j + w], dp[j] + v);
    }
  }
  ll ans = 0;
  rep(i, W + 1){
    ans = max(ans, dp[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
li=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(li[k-1])

Measured memory_bytes: 3060