akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

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

constexpr int MOD = 998244353;
constexpr ll inf = 1LL << 60;

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////

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

ll ans=0;
COMinit();

for(ll i=0;i<=k;i++){
ll notc=n-1-i;
ll val=1;
  val*=m;
  if(notc!=0){
val*=modpow(m-1,notc,MOD);}
else{val*=1;}
val%=MOD;
val*=COM(n-1,i);
val%=MOD;
ans+=val;
ans%=MOD;
}



cout<<ans<<endl;


}


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

bool is_uniq(string s) {
  rep(i,s.size()) {
    if(s[i]!=s[0])
      return false;
  }
  return true;
}

int sim(string s, char ch) {
  int c=0;
  while(!is_uniq(s)) {
    stringstream ss;
    rep(i,s.size()-1) {
      if(s[i]==ch||s[i+1]==ch) {
        ss<<ch;
      } else ss<<s[i];
    }
    s = ss.str();
    c++;
  }
  return c;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  string s;
  cin>>s;
  set<char> chars;
  for(auto&ch:s) {
    chars.insert(ch);
  }
  int ans=s.size()-1;
  for(auto&ch:s) {
    ans=min(ans,sim(s,ch));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 200005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll a, b;
ll K = 0;
ll t;
ll ret = 0;
string s;

ll fact[ARRAY];
ll inv_fact[ARRAY];
ll inv[ARRAY];

//準備
void combiInit() {
  fact[0] = fact[1] = 1;
  inv_fact[0] = inv_fact[1] = 1;
  inv[1] = 1;
  FOR(i, 2, ARRAY) {
    fact[i] = fact[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    inv_fact[i] = inv_fact[i-1] * inv[i] % MOD;
  }
}

//combiInitを実行した後はこれでnCrが取れる
ll combi(ll n, ll r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;

  ll P = 1;
  FOR(i, n-r+1, n+1) {
    P *= i;
    P %= MOD;
  }

  return (P * inv_fact[r]) % MOD;
}

ll modPow(ll x, ll y) {
  if (y == 1) return x;
  else if (y % 2 == 0) return modPow((x * x) % MOD, y / 2);
  else if (y % 2 == 1) return (x * modPow((x * x) % MOD, y / 2)) % MOD;
  return 0;
}

void input() {
  IN(N);
  IN(a);
  IN(b);
}

void solve() {
  combiInit();
  ll X = modPow(2, N) - 1;
  ll A = combi(N, a);
  ll B = combi(N, b);
  ret = (X - ((A + B) % MOD)) % MOD;
  if (ret < 0) ret += MOD;
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

map<string,int> m;
string s,t,u;
int a,b;

int main()
{
    cin>>s>>t>>a>>b>>u;
    m[s]=a;
    m[t]=b;
    m[u]--;
    cout<<m[s]<<" "<<m[t];
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;

int n,m,p,res;
int d[10001];

int main(void){
	scanf("%d%d%d",&n,&m,&p);
	for(int i=0;i<m;i++)scanf("%d",&d[i]);
	d[m]=114514;
	sort(d,d+m);
	res=11451419;
	int bg=lower_bound(d,d+m+1,p)-d;
	for(int i=0;i<m;i++){
		if(d[i]<p){
			if(d[i+1]>p)res=min(res,n-p+d[i]);
			else res=min(res,2*(n-p+d[i])+p-d[i+1]);
		}
		if(d[i]>p){
			if(i+1<m)res=min(res,2*(d[i]-p)+p+n-d[i+1]);
			else res=min(res,d[i]-p+d[i]-d[0]);
		}
	}
	
	for(int i=0;i<m;i++){
		if(d[i]<p){
			if(i>0)res=min(res,2*(p-d[i])+n-p+d[i-1]);
			else res=min(res,2*(p-d[i])+d[m-1]-p);
		}
		if(d[i]>p){
			if(i>0){
				if(d[i-1]<p)res=min(res,p+n-d[i]);
				else res=min(res,2*(p+n-d[i])+d[i-1]-p);
			}else res=min(res,p+n-d[0]);
		}
	}
	
	printf("%d\n",res*100);
	return 0;
}

Measured memory_bytes: 1076
#include <iostream>

using namespace std;

int main() {
    char c;
    cin >> c;
    bool flag=false;
    char vs[5]={'a', 'e', 'i', 'o', 'u'};
    for(int i=0; i<5; i++) {
        if(vs[i]==c) {
            flag=true;
            break;
        }
    }
    if(flag) {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }



    return 0;
    
    
}

Measured memory_bytes: 256
#union-find
from collections import Counter

n , q = map(int, input().split())

par = [0] * n
rank = [0] * n

#初期化
for i in range(n):
    par[i] = i
    rank[i] = 0

#判定(一番上野根を求める)
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
    
#結合
def unite(x , y):
    rx = find(x)
    ry = find(y)
    
    if rx == ry:
        return
    
    if rank[rx] < rank[ry]:
        par[rx] = ry
    elif rank[rx] > rank[ry]:
        par[ry] = rx
    else:
        par[ry] = x
        rank[rx] += 1
        
for i in range(q):
    a,b = map(int,input().split())
    unite(a-1,b-1)

ans = [0]*n
for i in range(n):
    ans[i] = find(i)
    
b = Counter(ans)
print(b.most_common(1)[0][1])

Measured memory_bytes: 108660
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;


public class Main
{
    int a, b, c;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	boolean flg = false;
	int r = a % b;
	if(r == c) flg = true;
	for(int i = 2; r * i % b != r; i++) {
	    if(r * i % b == c) flg = true;
	}
	
	if(flg) out("YES");
	else    out("NO");
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);

	a = sc.nextInt();
	b = sc.nextInt();
	c = sc.nextInt();
    }

    void out()
    {
	
    }
    
    void out(int ans)
    {
	System.out.println(ans);
    }
    
    void out(String ans)
    {
	System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
int f[5][5],i,j,a;
int main()
{
	for(;i<9;++i){
		char s[6];
		scanf("%s",s);
		for(j=0;j<4+i%2;++j){
			a=s[j]-48;
			f[i/2][j]|=a<<(1+i%2);
			f[i/2+i%2][j+!(i%2)]|=a<<3-i%2*3;
		}
	}

	printf("R");
	int y=0,x=1,p=1;
	do{
		p=(p+2)%4;
		int d=p;
		do
			d=(d+1)%4;
		while(!((f[y][x]>>d)&1));
		p=d;
		putchar("URDL"[d]);
		int dx[] = {0, 1, 0, -1};
		int dy[] = {-1, 0, 1, 0};
		x+=dx[d];
		y+=dy[d];
	}while(y!=0||x!=0||f[0][0]==6&&p==3);
	puts("");
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

std::vector<int > ReturnBit(long long val){
  std::vector<int > bit(45, 0);
  int counter = 0;
  while(val>0){
    bit[counter]=val%2;
    //printf("bit[%d]=%d\n",counter,bit[counter]);
    val = val/2;
    counter++;
  }
  return bit;
}

int main(){
  int N;
  long long K;
  scanf("%d",&N);
  scanf("%lld",&K);
  std::vector<long long > A(N);
  std::vector<int > count(45, 0);
  std::vector<int > returnbit;
  for (int i=0; i<N; i++){
    scanf("%lld", &A[i]);
    returnbit = ReturnBit(A[i]);
    for (int j=0; j<45; j++){
      count[j]+=returnbit[j];
      //printf("returnbit[%d]=%d\n",j,returnbit[j]);
    }
  }
  long long ans = 0;
  std::vector<int > mainbit = ReturnBit(K);
  int counter = 44;
  while(mainbit[counter]==0 && counter>0){
    counter--;
  }
  int select;
  long long current_sum = 0;
  //printf("counter=%d\n",counter);
  for (int i = 44; i>=0; i--){
    long long compval = (long long)1 << i;
    //printf("count[%d]=%d\n",i,count[i]);
    //printf("1 << %d = %lld\n",i,((long long)1<<i));
    if (compval+current_sum > K){
      select = count[i]; // select 0
    } else {
      select = std::max(count[i], N-count[i]);
      if (count[i]<N-count[i]){ // 1を選んだ時
        current_sum += compval;
      }
    }
    //printf("select=%d\n",select);
    //printf("ans+=%lld * %d\n",compval,select);
    ans += compval*select;
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
elems = []
pref = []
raw = input().split(" ")
idx = 0
while(idx < n):
    elem = int(raw[idx]);
    elems.append(elem)
    if(idx == 0):
        pref.append(elems[idx])
    else:
        pref.append(pref[idx - 1] + elem)
    idx += 1

sum = 0
for idx in range(n):
    sum += elems[idx] * (pref[n - 1] - pref[idx])

print(sum%1000000007)


Measured memory_bytes: 44908
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <algorithm>
#include <math.h>
#include<string>
#include<vector>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin >> n;
    ll b;
    ll ans[n];
    for (ll i = 0 ; i < n; i ++){
        ans[i] = 0;
    }
    for (ll i = 0 ; i < n - 1; i ++)   {
        cin >> b;
        ans[b-1] ++;
    }
    for (ll i = 0 ; i < n; i ++){
        cout << ans[i] << endl;
    }
}

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

vector<string> a;

const int MAXN = 190;

uint8_t xb_max[MAXN][MAXN][MAXN][2];
uint8_t yb_max[MAXN][MAXN][MAXN][2];

int main(){
	int n, m;
	cin >> n >> m;
	a.resize(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int _q = 0; ; _q++){
		int q = _q & 1;
		for(int xa = n; xa >= 0; xa--){
			for(int ya = m; ya >= 0; ya--){
				for(int xb = xa; xb <= n; xb++){
					if(_q == 0){
						if(ya == m || xb == xa){
							yb_max[xa][ya][xb][q] = m;
						} else if(xb == xa+1){
							yb_max[xa][ya][xb][q] = yb_max[xa][ya+1][xb][q];
							if(ya + 1 < m && a[xa][ya] != a[xa][ya+1]){
								yb_max[xa][ya][xb][q] = ya + 1;
							}
						} else {
							yb_max[xa][ya][xb][q] = min(
								yb_max[xa][ya][xb-1][q],
								yb_max[xa+1][ya][xb][q]);
							if(a[xa][ya] != a[xa+1][ya]){
								yb_max[xa][ya][xb][q] = ya;
							}
						}
					} else {
						int v = yb_max[xa][ya][xb][q^1];
						yb_max[xa][ya][xb][q] = yb_max[xa][v][xb][q^1];
					}
				}
				for(int yb = ya; yb <= m; yb++){
					if(_q == 0){
						if(xa == n || yb == ya){
							xb_max[xa][ya][yb][q] = m;
						} else if(yb == ya + 1){
							xb_max[xa][ya][yb][q] = xb_max[xa+1][ya][yb][q];
							if(xa + 1 < n && a[xa][ya] != a[xa+1][ya]){
								xb_max[xa][ya][yb][q] = xa + 1;
							}
						} else {
							xb_max[xa][ya][yb][q] = min(
								xb_max[xa][ya][yb-1][q],
								xb_max[xa][ya+1][yb][q]);
							if(a[xa][ya] != a[xa][ya+1]){
								xb_max[xa][ya][yb][q] = xa;
							}
						}
					} else {
						int v = xb_max[xa][ya][yb][q^1];
						xb_max[xa][ya][yb][q] = xb_max[v][ya][yb][q^1];
					}
				}
				// merge here
				uint8_t cury = ya;
				for(int xb = n; xb >= xa; xb--){
					while(cury < m && xb_max[xa][ya][cury+1][q] >= xb){
						cury++;
					}
					yb_max[xa][ya][xb][q] = max(yb_max[xa][ya][xb][q], cury);
				}
				uint8_t curx = xa;
				for(int yb = m; yb >= ya; yb--){
					while(curx < n && yb_max[xa][ya][curx+1][q] >= yb){
						curx++;
					}
					xb_max[xa][ya][yb][q] = max(xb_max[xa][ya][yb][q], curx);
				}
			}
		}
		if(yb_max[0][0][n][q] == m){
			cout << _q << '\n';
			break;
		}
	}
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] * m * 4 >= sum) ++cnt;
    }
    if (cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
x,k,d=gets.split.map(&:to_i)
x=x.abs
ans1=x%d
ans2=ans1-d
ans=0
if ans1<=x-k*d
  ans=x-k*d
elsif x%d==0
  kai=(x)/d
  if k%2==0
    if kai%2==0
      ans=ans1
    else
      ans=ans2
    end
  else
    if kai%2==0
      ans=ans2
    else
      ans=ans1
    end
  end
elsif k%2==0
  kai=(x+ans2.abs)/d
  if kai%2==0
    ans=ans2
  else
    ans=ans1
  end
else
  kai=(x+ans2.abs)/d
  if kai%2==0
    ans=ans1
  else
    ans=ans2
  end
end
puts ans.abs


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

using namespace std;
using ll = long long;

int main(void) {
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  bool f = true;
  for (int i = 0; i < n - 1; i++) {
    if (v[i] == v[i + 1]) {
      f = false;
    }
  }
  if (f) cout << "YES" << endl;
  else cout << "NO" << endl;
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;
ll pow_mod(ll n, ll k, ll m) {
    if (k == 0) {
        return 1;
    }
    else if (k % 2 == 1) {
        return pow_mod(n, k - 1, m) * n % m;
    }
    else {
        ll t = pow_mod(n, k / 2, m);
        return t * t % m;
    }
}

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

    ll ans = 0;
    vector<ll> A(K + 1, 0);

    for (ll i = K; i >= 1; i--) {
        ll tmp = pow_mod(K / i, N, MOD);
        for (ll j = 2 * i; j <= K; j += i) {
            tmp -= A[j];
            if (tmp < 0) tmp += MOD;
        }
        A[i] = tmp;
        ans += tmp * i;
        ans %= MOD;
    }

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

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n, m; cin >> n >> m;
    vector<pair<int, int>> res;
    if (n % 2 == 1) {
        //奇数
        for (int l = 1, r = n - 1; l < r; ++l, --r) {
            res.push_back(make_pair(l, r));
        }
    } else {
        //偶数
        bool over = false;
        for (int l = 1, r = n - 1; l < r; ++l, --r) {
            if (!over && r - l <= n / 2) {
                ++l;
                over = true;
            }

            res.push_back(make_pair(l, r));
        }
    }

    for (int i = 0; i < m; ++i) {
        cout << res[i].first << ' ' << res[i].second << endl;
    }
}

Measured memory_bytes: 4228
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long ,long long>pll;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

 long long modpow(long long n, long long k,long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

vector<vector<int>>adj(1e5+10);
void dfs(int v,int prev,vector<int>&depth){
     for(auto vi : adj[v])
     {
        if(vi==prev) continue;
        depth[vi] = depth[v]+1;
        dfs(vi,v,depth);
     }
}
void solve(){
    int n,a,b;cin >> n >> a >> b;
    for(int i = 0;i<n-1;i++)
    {
        int v,u;cin >> v >> u;
        v--;u--;
        adj[v].push_back(u);
        adj[u].push_back(v);
    }
    vector<int>depth1(1e5+10,0);
    vector<int>depth2(1e5+10,0);
    dfs(a-1,-1,depth1);
    dfs(b-1,-1,depth2);
    int ans = 0;
    for(int i = 0;i<n;i++)
    {
        if(depth1[i]<=depth2[i])
            ans = max(ans,depth2[i]-1);
    }
    cout << ans;
}

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

Measured memory_bytes: 15792
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()

  n, e := strconv.Atoi(sc.Text())
  if e != nil {
    panic(e)
  }

  v := make([]int, n)

  max := 0

  for i := 0; i < n; i++ {
    sc.Scan()
    a, e := strconv.Atoi(sc.Text())
    if e != nil {
      panic(e)
    }
    v[i] = a
  }

  for i := 0; i < n; i++ {
    sc.Scan()
    a, e := strconv.Atoi(sc.Text())
    if e != nil {
      panic(e)
    }
    if v[i] > a {
      max += v[i] - a
    }
  }

  fmt.Println(max)
}


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

int main() {
	int A, B, C, D;

	cin >> A >> B >> C >> D;

	int x = A * B;
	int y = C * D;

	if( x >= y ) {
		cout << x << endl;
	}
	else {
		cout << y << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, M: int, A: "List[int]"):
    A.sort(reverse=True)
    cs = [0, 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ]
    dp = [-float('inf')] * (N + 1)

    dp[0] = 0
    for i in range(1, len(dp)):
        for a in A:
            c = cs[a]
            if 0 <= i - c:
                dp[i] = max(dp[i], dp[i-c] + 1)
    i = N
    ret = 0
    while 0 < dp[i]:
        for a in A:
            c = cs[a]
            if (0 <= i - c) and (dp[i] == (dp[i - c] + 1)):
                i -= c
                ret = 10 * ret + a
                break
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    result = solve(N, M, A)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5432
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll power(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)

//your code here!

int main(void){
    ll A, B;
    scanf("%lld %lld", &A, &B);
    printf("%lld\n", (A+B)%24);
    return 0;
}

Measured memory_bytes: 128
// Author : Syed Mujtaba
// Seek knowledge from the Cradle to the Grave !!
// https://www.linkedin.com/in/syed-mujtaba-064a5016a 

#include <bits/stdc++.h>
using namespace std;
#define int     long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

signed main()
{
	fast_io
	string s, t;
	cin >> s >> t;
	int dp[s.size() + 2][t.size() + 2] = {0};
	if(s[0] == t[0])
		dp[1][1] = 1;
	else
		dp[1][1] = 0;
	for(int i = 0; i <= s.size(); i++)
	{
		for(int j = 0; j <= t.size(); j++)
		{
			if(i == 0 || j == 0)
				dp[i][j] = 0;
			else if(s[i - 1] == t[j - 1])
			{
				dp[i][j] = 1 + dp[i - 1][j - 1];
			}
			else
			{
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	int i = s.size();
	int j = t.size();
	string ans;
	while(i > 0 && j > 0)
	{
		if(s[i - 1] == t[j - 1])
		{
			ans.push_back(s[i - 1]);
			i--;
			j--;
		}
		else if(dp[i - 1][j] > dp[i][j - 1])
			i--;
		else
			j--;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 605;
int n, m, s, t, sz[MX];
vector<int> G[MX], rG[MX];
double p[MX], d[MX], ans;
int main(){
	scanf("%d%d", &n, &m);
	rep(i,m){
		scanf("%d%d", &s, &t);
		s--; t--;
		sz[s]++;
		G[s].push_back(t);
		rG[t].push_back(s);
	}
	for(int i = n-1; i >= 0; i--){
		if(i != n-1) p[i] += 1;
		for(int pr: rG[i]) p[pr] += p[i] / sz[pr];
	}
	for(int i = n-2; i >= 0; i--){
		double dd[MX] = {};
		dd[i] = 1;
		for(int j = i; j >= 0; j--){
			for(int pr: rG[j]) dd[pr] += dd[j] / sz[pr];
		}
		d[i] = dd[0];
	}
	ans = p[0];
	rep(i,n) if(sz[i] > 1){
		for(int nx: G[i]){
			double np = ((p[i] - 1) * sz[i] - p[nx]) / (sz[i]-1) + 1;
			ans = min(ans, p[0] + (np - p[i]) * d[i]);
		}
	}
	printf("%.9f\n", ans);
}

Measured memory_bytes: 2560
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n, m ; 
    cin >> n >> m ; 
    vi  a(m),b(m) ; 
    vector <vi>  key(m+1, vi(15, 0)) ; 
    for (int i=0;i<m;i++){
    	cin >> a[i] >> b[i] ; 
    	for (int j=0;j<b[i];j++) {
    		cin >> key[i][j] ; 
    		key[i][j]-- ; 
    	}
    }
    vi  dp( 1<<n, 1e9 ) ; 
    dp[0] = 0 ; 
    for (int i=0;i<m;i++){ 
    	int now = 0 ; 
    	for (int j=0;j<b[i];j++){ 
    		now |= (1 << (key[i][j]) ) ; 
    	} 
    	for (int  bit = 0; bit < (1<<n) ; bit++ ) { 
    		dp[bit | now] = min(dp[bit | now], dp[bit]+a[i]) ; 
    	} 
    } 
    if (dp[ (1<<n) - 1 ] == 1e9) dp[(1<<n)-1] = -1 ; 
    co (dp[(1<<n)-1]) ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3808
class Dice
  attr_accessor :v, :h
  def initialize(pips)
    pips = pips.split.map(&:to_i)
    @v = [pips[0], pips[1], pips[5]]
    @h = [pips[3], pips[2], pips[4]]
  end

  def rotate(dir)
    tmp = @v[0]
    case dir
    when 'E'
      @v[0] = @h[0]
      @h[0] = @v[2]
      @v[2] = @h[1]
      @h[1] = tmp
    when 'W'
      @v[0] = @h[1]
      @h[1] = @v[2]
      @v[2] = @h[0]
      @h[0] = tmp
    when 'S'
      @v[0] = @h[2]
      @h[2] = @v[2]
      @v[2] = @v[1]
      @v[1] = tmp
    when 'N'
      @v[0] = @v[1]
      @v[1] = @v[2]
      @v[2] = @h[2]
      @h[2] = tmp
    end
  end

  def pip
    @v[0]
  end
end

d = Dice.new gets
gets.chomp.each_char do |c|
  d.rotate(c)
end
puts d.pip

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

int main(){
	int x, y, a, b, c;
	std::cin>> x>> y>> a>> b>> c;

	std::vector<long long> aList(a);
	std::vector<long long> bList(b);
	std::vector<long long> cList(c);

	std::vector<long long> xList;

	for(int i=0; i<a; i++)
		std::cin>>aList[i];

	for(int i=0; i<b; i++)
		std::cin>>bList[i];

	for(int i=0; i<c; i++)
		std::cin>>cList[i];

	std::sort(aList.begin(), aList.end(), [](long long s, long long t){return s > t;});
	std::sort(bList.begin(), bList.end(), [](long long s, long long t){return s > t;});
	std::sort(cList.begin(), cList.end(), [](long long s, long long t){return s > t;});

	int cIdx= 0;

	if(x<=a){
		for(int i=0; i< x; i++)
			xList.push_back(aList[i]);
	}else{
		for(int i=0; i< a; i++)
			xList.push_back(aList[i]);

		for(int i=0; i< x-a; i++, cIdx++){
			xList.push_back(cList[cIdx]);
		}
	}

	if(y<=b){
		for(int i=0; i< y; i++)
			xList.push_back(bList[i]);
	}else{
		for(int i=0; i< b; i++)
			xList.push_back(bList[i]);

		for(int i=0; i< y-b; i++, cIdx++){
			xList.push_back(cList[cIdx]);
		}
	}

	std::sort(xList.begin(), xList.end(), [](long long s, long long t){return s < t;});

	for(int i=0; cIdx< c && i< x+y; i++, cIdx++){
		if(xList[i]< cList[cIdx])
			xList[i]= cList[cIdx];
	}

	long long ans=0;
	for(int i=0; i< x+y; i++)
		ans+= xList[i];

	std::cout<<ans<<std::endl;

}

Measured memory_bytes: 4724
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<string>
#include<list>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通

int N;
int c = 0;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a % 2 == 1) c++;
	}
	if (c % 2 == 1) cout << "NO";
	else cout << "YES";
	return 0;
}

Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    x = [[aa, 1] for aa in a]
    for i in range(m):
        b, c = map(int, input().split())
        x += [[c, b]]

    x = sorted(x, reverse=True)
    count = 0
    sum = 0
    for i in range(n):
        count += x[i][1]
        if count <= n:
            sum += x[i][0] * x[i][1]
        else:
            sum += x[i][0] * (x[i][1] - (count - n))
            break
    print(sum)

if __name__ == '__main__':
    main()


Measured memory_bytes: 36224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	//	  System.setIn(B083.class.getResourceAsStream("input.txt"));
		  Scanner in = new Scanner(System.in);

		  int n = in.nextInt();
		  int a = in.nextInt();
		  int b = in.nextInt();
		  int total = 0;


		  for(int i = 0; i <= n; i++) {
			  int sum = findSumOfDigits(i);
			  if(sum >= a && sum <= b) {
				  total += i;
			  }
		  }
		  System.out.println(total);
		  in.close();
	}

	public static int findSumOfDigits(int n) {
		  int sum = 0;

		  while(n > 0) {
			  sum += n % 10;
			  n /= 10;
		  }
		  return sum;
	}
}


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

using namespace std;

const int P = 1e9 + 7;

int f[41][(1 << 17) + 1];

void add(int &x, int y) {
    x += y;
    if (x >= P) x -= P;
}

int main() {
    int n, x, y, z;
    scanf("%d%d%d%d", &n, &x, &y, &z);
    f[0][0] = 1;
    int m = 1 << (x + y + z);
    int tans = (1 << (z - 1)) | (1 << (y + z - 1)) | (1 << (x + y + z - 1));
    for (int i = 0; i < n; ++i) {
        for (int mask = 0; mask <= m; ++mask) {
            if (!f[i][mask]) continue;
            for (int j = 1; j <= 10; ++j) {
                if (mask == m) {
                    add(f[i + 1][m], f[i][m]);
                    continue;
                }
                int nmask = (mask << j | (1 << (j - 1))) & (m - 1);
                if ((nmask & tans) == tans) nmask = m;
                add(f[i + 1][nmask], f[i][mask]);
            }
        }
    }
    printf("%d\n", f[n][m]);
    return 0;
}



Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_ ; ++i)
#define drep(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_ ; --i)
#define clear(a, b) memset((a), (b), sizeof(a))
typedef long long LL;
int read() {
	int x = 0, flag = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') flag = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = (x << 3) + (x << 1) + (ch - 0x30);
		ch = getchar();
	}
	return flag * x;
}
 
#define Maxn 200009
int n, a[Maxn];
int _left[Maxn], _right[Maxn];
int main() {
#ifdef Qrsikno
	freopen("d.in","r",stdin);
	freopen("d.out","w",stdout);
#endif
	n = read();
	rep(i, 1, n) a[i] = read();
	_left[1] = 0;
	rep(i, 2, n) 
		if(a[i - 1] < a[i]) _left[i] = i - 1;
		else {
			int now = i - 1;
			while(a[now] >= a[i]) now = _left[now];
			_left[i] = now;
		}
	_right[n] = n + 1;
	drep(i, n - 1, 1) 
		if(a[i + 1] < a[i]) _right[i] = i + 1;
		else {
			int now = i + 1;
			while(a[now] >= a[i]) now = _right[now];
			_right[i] = now;
		}
	LL ans = 0;
	rep(i, 1, n)
		ans += 1ll * a[i] * (i - _left[i]) * (_right[i] - i);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2560
#define  _CRT_SECURE_NO_WARNINGS
	#include <algorithm>
	#include <iostream>
	#include <iterator>
	#include <numeric>
	#include <sstream>
	#include <fstream>
	#include <cassert>
	#include <climits>
	#include <cstdlib>
	#include <cstring>
	#include <string>
	#include <cstdio>
#include<algorithm>
	#include <vector>
	#include <math.h>
	#include <queue>
	#include<memory>
	#include <deque>
	#include <stack>
	#include <list>
	#include <map>
	#include <set>
	#include <cmath>
	#include <bitset>
	#include<list>
	#include <iomanip>
	using namespace std;

	int solve()
	{

		size_t N, W, weight, value, V = 1000 * 1000 + 1;
		std::cin >> N >> W;

		std::vector<std::vector<size_t>> dp(2);
		dp[0] = std::vector<size_t>(V, W + 1);
		dp[1] = std::vector<size_t>(V, W + 1);
		dp[0][0] = 0;
		unsigned ans = 0;
		for (unsigned i = 0; i < N; ++i)
		{
			std::cin >> weight >> value;
			for (unsigned j = 0; j < V; ++j)
			{
				if (j >= value)
				{
					dp[1][j] = std::min(dp[0][j], dp[0][j - value] + weight);
				}
				else
				{
					dp[1][j] = dp[0][j];
				}
				if (dp[1][j] <= W)
				{
					ans = std::max(ans, j);
				}
			}
			dp[0].swap(dp[1]);
		}
		std::cout << ans;
	}

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

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

int main() {
	
	string str;
	cin >> str;
	int ans = 0;
	for (int i = 0;i < 8;i++) {
		bitset<3> b(i);

		ans = str[0] - '0';
		for (int j = 0;j < 3;j++) {
			if (b.test(j)) {
				ans += str[j+1] - '0';
			}
			else {
				ans -= str[j + 1] - '0';
			}
		}
		
		if (ans == 7) {
			cout << str[0];
			for (int j = 0;j < 3;j++) {
				if (b.test(j)) {
					cout << "+";
				}
				else {
					cout << "-";
				}
				cout << str[j + 1];
			}
			cout << "=7\n";
			return 0;
		}

	}

	return 0;
}

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

int main(void){
    int a,b,c;
    cin >> a;
    
    cin >> b;
    cin >> c;
    if (a < b && b < c) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    cout  << endl;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <fstream>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  os << "--------" << std::endl;
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

void solve()
{
  int H, W, N;
  std::cin >> H >> W >> N;

  int p = std::max(H, W);
  int ans = (N + p - 1) / p;
  print(ans);

  return;
}

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

  solve();
  return 0;
}



Measured memory_bytes: 256
a, b, c, x, y = [int(arg) for arg in input().split()]

default = a * x + b * y
if x < y:
    print(min(default, c*2*x+b*(y-x), c*2*y))
else:
    print(min(default, c*2*y+a*(x-y), c*2*x))


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main
{
  public static void main (String args[])
  {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    
    int dp[] = new int[N+1];
    int H[] = new int[N+1];
    for (int i = 1; i <= N; i++)
    {
      H[i] = in.nextInt();
    }
    dp[1] = 0;
    dp[2] = Math.abs(H[1] - H[2]);
    for (int i = 3; i <= N; i++)
    {
      dp[i] = Math.min(dp[i-2] + Math.abs(H[i] - H[i-2]), 
                      dp[i-1] + Math.abs(H[i] - H[i-1]));
    }
    System.out.println(dp[N]);
  }
}

Measured memory_bytes: 51244
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s << endl;
}

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

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;
//int t[10010];

int main()
{

    int n;
    cin >> n;
    vector<int> p(n);
    REP(i, n)
    cin >> p[i];

    sort(p.rbegin(), p.rend());

    int sum = 0;
    for (int i = 1; i < n; i++)
    {
        sum += p[i];
    }
    sum += p[0] / 2;
    Cout(sum);

    return 0;
}

Measured memory_bytes: 256
N,T = map(int,input().split())
import numpy as np
A,B = np.array([list(map(int,input().split())) for _ in range(N)]).T
dp1 = np.array([[0]*T for _ in range(N+1)])
rev_A,rev_B = A[::-1],B[::-1]
dp2 = np.array([[0]*T for _ in range(N+1)])


for i in range(1,N+1):
  a = A[i-1]
  rev_a = rev_A[i-1]
  b = B[i-1]
  rev_b = rev_B[i-1]
  
  dp1[i,:a] = dp1[i-1,:a]
  dp2[i,:rev_a] = dp2[i-1,:rev_a]
  dp1[i,a:] = np.fmax(dp1[i-1,a:],dp1[i-1,:-a]+b)
  dp2[i,rev_a:] = np.fmax(dp2[i-1,rev_a:],dp2[i-1,:-rev_a]+rev_b)

      
lis = [0]*N
for i in range(1,N+1):
  lis[i-1] = (np.max(dp1[i-1]+dp2[N-i][::-1]) + B[i-1])
 
    
print(max(lis))

Measured memory_bytes: 223584
import java.util.*;
import java.io.*;
public class Main{

 static class Reader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public Reader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
       
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e){ 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt(){ 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong(){ 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble(){ 
            return Double.parseDouble(next()); 
        } 
        
        String nextLine(){ 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } 
            catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 


  
    public static void main(final String [] args)throws IOException{
       Reader sc=new Reader();
       long n=sc.nextLong();
       String s="";

       while(n>0){
         n=n-1;
         s=(char)('a'+(n%26))+s;
         n=n/26;
       }
       System.out.println(s);


    }
}




Measured memory_bytes: 37004
N, M = map(int, input().split())
H = [0] + list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

h = [0] * (N + 1)
for i in range(M):
    h[AB[i][0]] = max(h[AB[i][0]], H[AB[i][1]])
    h[AB[i][1]] = max(h[AB[i][1]], H[AB[i][0]])

ans = 0
for i in range(N + 1):
    if h[i] < H[i]:
        ans += 1

print(ans)


Measured memory_bytes: 97068
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    string a,b;
    set<int> aa;
    rep(i,1000){
        aa.insert(i*i);
    }
    cin>>a>>b;
    a+=b;
    if(aa.find(stoi(a))!=aa.end())cout << "Yes" << endl;
    else cout <<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
ps = gets.chomp.split.map(&:to_i)
m = []
n.times do |i|
  if i != 0
    m << [m[-1], ps[i]].min
  else
    m << ps[i]
  end
end
puts (0...n).to_a.count {|i| ps[i] == m[i] }

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

using namespace std;
vector<long long> factors;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
int n;
vector<vector<int>> matrix;
vector<vector<ll>> dp;

ll count(int k, int mask)
{
	if (dp[k][mask] == -1)
	{
		dp[k][mask] = 0;
		for (int i = 0; i < n; ++i)
		{
			if (mask & (1 << i))
			{
				dp[k][mask] += count(k - 1, mask & ~(1 << i)) * matrix[i][k - 1];
				dp[k][mask]%=MOD;
			}
		}
	}
	return dp[k][mask];
}

int main()
{
	IOS
	cin >> n;
	matrix.assign(n + 1, vector<int>(n + 1));
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			cin >> matrix[i][j];
		}
	}

	dp.assign(n + 1, vector<ll>((1 << (n + 1)) + 5, -1));
	int mask = 0;
	for (int i = 0; i < n; ++i)
	{
		mask |= (1 << i);
	}
	for(int i =0;i < (1 << (n + 1)) + 5; ++i){
		dp[0][i] = 1;
	}
	cout << count(n,mask);

	return 0;
}


Measured memory_bytes: 754176
h,w=map(int,input().split())
A=[]
ans=[]
for i in range(h):
  A.append(list(input()))
for a in A:
  if a != ['.']*w:
    ans.append(a)
counter=[]
for i in range(w):
  flag=0
  for j in range(len(ans)):
    if ans[j][i]=='#':
      flag=1
      break
  if flag==1:
    counter.append(i)

for a in ans:
  tmp=''
  for i in counter:
    tmp=tmp+a[i]
  print(tmp)

Measured memory_bytes: 9132
S = input()
S_h = ''
S_t = ''
Q = int(input())

def add_car(S_h,S_t,s,is_left,is_rev):
    if is_rev:
        is_left = not(is_left)
    if is_left:
        S_h = ''.join([S_h,s])
    else:
        S_t = ''.join([S_t,s])
    return S_h,S_t

is_rev = False
for q in range(Q):
    x = input().split(' ')
    if len(x) == 1:
        is_rev = not is_rev
    else:
        S_h,S_t = add_car(S_h,S_t,x[2],x[1]=='1',is_rev)

if is_rev:
    S_t = ''.join(list(reversed(S_t)))
    S = ''.join(list(reversed(S)))
    print(''.join([S_t,S,S_h]))
else:
    S_h = ''.join(list(reversed(S_h)))
    print(''.join([S_h,S,S_t]))

Measured memory_bytes: 4852
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long int ll;
int main(){
  string n;
  cin >>n;
  int cnt=0;
  for(int i=0;i<4;i++){
    if(n[i]=='2') cnt++;
  }
  cout <<cnt<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int w = sc.nextInt();
        //String ans = "x";
        StringBuilder sb = new StringBuilder();
        int i=0;
        while(i<S.length()){
            if(i%w==0) sb.append(S.charAt(i));
            i++;
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 23508
n = int(input())
mod = 998244353
count = [0]*(10**5+1)
L = list(map(int,input().split()))
M = max(L)
ans = 0
for i in range(n):
  count[L[i]] += 1
for i in range(M+1):
  if count[i] == 0:
    ans = 0
    break
  else:
    if i == 0:
      if count[i] != 1:
        ans = 0
        break
      else:
        ans = 1
    else:
      ans = ans*((count[i-1]**count[i])%mod)
      ans = ans%mod
if L[0] == 0:
  print(ans)
else:
  print(0)

Measured memory_bytes: 15164
import sys
import math

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, H, M = [int(x) for x in input().split()]

    kakudo1 = M * 6
    kakudo2 = 30 * (H % 12) + M * 0.5

    x = min(abs(kakudo2 - kakudo1), abs(kakudo1 - kakudo2))

    x = min(x, abs(x - 360))


    c = A * A + B * B  - A * B * 2 * math.cos(math.radians(x))
    print(math.sqrt(c))


if __name__ == '__main__':
    main()


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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define fill(a,p) memset(a,p,sizeof(a))
#define pb push_back
#define mod 1000000007
#define N 200005
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>
#define endl "\n"

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =2005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll minim(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;      
     x = x % p;    
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
            y = y>>1;  
            x = (x*x) % p;   
    } 
    return res; 
}

ll modInverse(ll n,ll p) 
{ 
    return power(n, p-2, p); 
} 


ll lcm(ll a,ll b){
  return (a*b)/__gcd(a,b);
}

bool comp(const point &p1,const point &p2){
	if(p1.first!=p2.first)return p1.first<p2.first;
	else return p1.second<p2.second;
}

int main()
{
	fio;
	ll n,w;cin>>n>>w;
	vl wei(n),value(n);
	f(n){
		cin>>wei[i]>>value[i];
	}
	vl dp(w+1,0);
	for(ll i=0;i<n;i++){
		for(ll j=w-wei[i];j>=0;j--){
			dp[j+wei[i]]=max(dp[j+wei[i]],dp[j]+value[i]);
		}
	}
	cout<<dp[w]<<endl;
}

Measured memory_bytes: 1024
/**
*    author:  Dooloper
*    created: 17.09.2020 23:50:27
**/

#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define repn(i,n) for(int i = 1; i <= (n); i++)
#define pb push_back
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

const double PI = acos(-1);
const int mod = 1000000007;
class mint {
   long long x;
public:
   mint(long long x=0) : x((x%mod+mod)%mod) {}
   mint operator-() const {
     return mint(-x);
   }
   mint& operator+=(const mint& a) {
       if ((x += a.x) >= mod) x -= mod;
       return *this;
   }
   mint& operator-=(const mint& a) {
       if ((x += mod-a.x) >= mod) x -= mod;
       return *this;
   }
   mint& operator*=(const  mint& a) {
       (x *= a.x) %= mod;
       return *this;
   }
   mint operator+(const mint& a) const {
       mint res(*this);
       return res+=a;
   }
   mint operator-(const mint& a) const {
       mint res(*this);
       return res-=a;
   }
   mint operator*(const mint& a) const {
       mint res(*this);
       return res*=a;
   }
   mint pow(ll t) const {
       if (!t) return 1;
       mint a = pow(t>>1);
       a *= a;
       return a;
   }
   // for prime mod
   mint inv() const {
       return pow(mod-2);
   }
   mint& operator/=(const mint& a) {
       return (*this) *= a.inv();
   }
   mint operator/(const mint& a) const {
       mint res(*this);
       return res/=a;
   }

   friend ostream& operator<<(ostream& os, const mint& m){
       os << m.x;
       return os;
   }
};
#pragma endregion

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int k;
  cin >> k;
  vector<int> a(k+5);
  a[0] = 7 % k;
  for(int i = 1; i <= k; i++)a[i] = (a[i-1]*10 + 7) % k;
  for(int i = 0; i <= k; i++){
    if(a[i] == 0){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
  return 0;
}

Measured memory_bytes: 7124