akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N,K;
vector<LL>v;

int main(){
	cin>>N>>K;
	REP(i,N){
		LL a;
		cin>>a;
		v.push_back(a);
	}
	sort(v.begin(),v.end());
	LL ans=1e12;
	for(int i=K-1;i<N;i++){
		ans=min(ans,v[i]-v[i-K+1]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1400
N, Q = map(int, input().split())
S = input()
TX = [list(input().split()) for _ in range(Q)]
def checkl(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i < 0:
            return False
        if i == N:
            i = N - 1
    return True
def checkr(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i > N - 1:
            return False
        if i == -1:
            i = 0
    return True

ok = N
ng = -1
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkl(med):
        ok = med
    else:
        ng = med
L = ok
ok = -1
ng = N
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkr(med):
        ok = med
    else:
        ng = med
R = ok
print(max(0, R - L + 1))


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

#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++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, long long K, string S){
    VI memo;
    char ch = S[0];
    int idx = 0;
    while(idx != S.length()) {
        int cnt = 0;
        while(idx != S.length() && ch == S[idx]) {
            cnt++;
            idx++;
        }
        memo.PB(ch == '0' ? cnt * -1 : cnt);
        ch = S[idx];
    }

    int zero_cnt = 0;
    int now_score = 0;
    int max_score = 0;

    int l = 0, r = 0;
    while(l < memo.size()) {
        if(r != memo.size() && (zero_cnt < K || (zero_cnt == K && 0 <= memo[r]))){
            
            now_score += (0 < memo[r] ? memo[r] : memo[r] * -1);
            zero_cnt += memo[r] < 0;
            r++;
        } else {
            now_score -= (0 < memo[l] ? memo[l] : memo[l] * -1);
            zero_cnt -= memo[l] < 0;
            l++;
        }

        max_score = max(max_score, now_score);
    }

    cout << max_score << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    string S;
    cin >> S;
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 1148
A, B = map(int, input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

GCD = gcd(A, B)
print(len(set(prime_factorize(GCD)))+1)

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int main()
{
  int N, Q;
  cin >> N >> Q;
  vector<int> a(N - 1, 0);
  vector<int> b(N - 1, 0);
  vector<int> p(Q, 0);
  vector<int> x(Q, 0);
  vector<int> ans(N, 0);
  vector<pair<int, int>> nood(N-1);
  vector<pair<int, int>> data(Q);

  for (int i = 0; i < N-1;i++){
    cin >> a[i] >> b[i];
    nood[i] = make_pair(b[i], a[i]);
  }
  for (int i = 0; i < Q; i++)
  {
    cin >> p[i] >> x[i];
    data[i] = make_pair(p[i], x[i]);
  }

  sort(nood.begin(), nood.end());
  sort(data.begin(), data.end());

  int d = 0;
  while(data[d].first<=1){
    if (data[d].first==1)
      ans[0]+=data[d].second;
    d++;
  }

  for (int i = 1; i < N;i++){
    ans[i] += ans[nood[i - 1].second-1];
    //cout<<nood[i - 1].second<<endl;
    while (data[d].first <= i + 1)
    {
      if (data[d].first == i+1)
        ans[i] += data[d].second;
      d++;
    }
  }
  for (int i = 0; i < N ; i++)
  {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 9472
H,W = map(int,input().split())
t = []
Hcut = []
Wcut = []
count = 0
for i in range(H):
  t.append(input())
  
#削除するべき行の検出  
for i in range(H):
  for j in range(W):
    if t[i][j] == "#":
      count += 1
      break
  if count == 0:
    Hcut.append(i)
  count = 0
  
#削除するべき列の検出
for i in range(W):
  for j in range(H):
    if t[j][i] == "#":
      count += 1
      break
  if count == 0:
    Wcut.append(i)
  count = 0

#出力
for i in range(H):
  judge = 0
  for j in range(W):
    if i in Hcut or j in Wcut:
      continue
    else:
      print(t[i][j],end="")
      judge = 1
  if judge == 1:
    print()
  
  

Measured memory_bytes: 4468
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>
#include <atcoder/all>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;
using namespace atcoder;

int main(void){
    ll N, M;
    cin>>N>>M;
    ll a, b;
    dsu d(N);
    rep(i, M){
        cin>>a>>b;
        d.merge(a-1, b-1);
    }
    cout<<(d.groups().size())-1<<endl;
    return 0;
}


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

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ld long double

int main()
{
	IOS;
	string str;
	cin >>str;
	set<char> s;
	for(int i=0;i<4;i++)
	{
		s.insert(str[i]);
	}
	if(s.size()==2)
		cout <<"Yes";
	else cout <<"No";
	cout <<"\n";
	return 0;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
S=["."+input()+"." for i in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
flag=0
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            if S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
                flag=1
print("Yes" if flag==0 else "No")

Measured memory_bytes: 39024
from itertools import product
from collections import defaultdict
n = int(input())
s = input()
sa, sb = s[:n], s[n:][::-1]
a, b, ans = defaultdict(int), defaultdict(int), 0
for p in product(range(2), repeat=n):
    word_a_1, word_b_1, word_a_2, word_b_2 = "", "", "", ""
    for j in range(n):
        if p[j]:
            word_a_1 += sa[j]
            word_b_1 += sb[j]
        else:
            word_a_2 += sa[j]
            word_b_2 += sb[j]
    a[(word_a_1, word_a_2)] += 1
    b[(word_b_1, word_b_2)] += 1
while a:
    key, value = a.popitem()
    ans += value * b[key]
print(ans)


Measured memory_bytes: 150652
syllables = list(map(int, input().split()))
cnt5 = 0
cnt7 = 0
for i in syllables:
    if i == 5:
        cnt5 += 1
    elif i == 7:
        cnt7 += 1
    else:
        print('NO')
if cnt5 == 2 and cnt7 == 1:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int a,b,k,sx,sy,fx,fy;
vec<str> m;
vec<vec<int>> us;

int main() {
    fast;
    cin>>a>>b>>k;
    cin>>sx>>sy>>fx>>fy;
    sx--, sy--, fx--, fy--;
    m = vec<str>(a);
    us = vec<vec<int>>(a, vec<int>(b));
    for(int q=0; q<a; q++){
        cin>>m[q];
        for(int w=0; w<b; w++) if(m[q][w]=='@') us[q][w] = -1;
    }

    vec<pii> n1 = {{sx,sy}}, n2;
    us[sx][sy] = 1;
    for(; n1.size()+n2.size();){
        if(n1.empty()) swap(n1, n2);
        pii p = n1.back(); n1.pop_back();
        int x = p.F, y = p.S;
        for(int nx=x+1, i=1; nx<a && i<=k; i++, nx++){
            if(us[nx][y] && us[nx][y]<=us[x][y]) break;
            if(us[nx][y]) continue;
            us[nx][y] = us[x][y]+1;
            n2.pb({nx,y});
        }
        for(int nx=x-1, i=1; nx>=0 && i<=k; i++, nx--){
            if(us[nx][y] && us[nx][y]<=us[x][y]) break;
            if(us[nx][y]) continue;
            us[nx][y] = us[x][y]+1;
            n2.pb({nx,y});
        }
        for(int ny=y+1, i=1; ny<b && i<=k; i++, ny++){
            if(us[x][ny] && us[x][ny]<=us[x][y]) break;
            if(us[x][ny]) continue;
            us[x][ny] = us[x][y]+1;
            n2.pb({x,ny});
        }
        for(int ny=y-1, i=1; ny>=0 && i<=k; i++, ny--){
            if(us[x][ny] && us[x][ny]<=us[x][y]) break;
            if(us[x][ny]) continue;
            us[x][ny] = us[x][y]+1;
            n2.pb({x,ny});
        }
    }
    cout<<us[fx][fy]-1;
}

Measured memory_bytes: 11144
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n,k;
  cin>>n>>k;
  if(k%2==0){
    ll a=n/k;
    ll b=n/(k/2)-a;
    cout<<a*a*a+b*b*b<<endl;
  }
  else {
    ll a=n/k;
    cout<<a*a*a<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

ll cnt_x, cnt_y, cnt_z;
ll a1, a2, a3, m1, m2, m3;

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

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

int main(void){

  while(cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3, a1 + a2 + a3 + m1 + m2 + m3){
    cnt_x = 1, cnt_y = 1, cnt_z = 1;
    ll x = a1 % m1, y = a2 % m2, z = a3 % m3;
    while(x != 1){
      cnt_x++;
      x = a1*x % m1;
    } 
    while(y != 1){
      cnt_y++;
      y = a2*y % m2;
    }
    while(z != 1){
      cnt_z++;
      z = a3*z % m3;
    }
    cout << lcm(lcm(cnt_x, cnt_y), cnt_z) << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
C = [list(map(lambda x:int(x),input().split())) for i in range(3)]
#print(C)
a,b,c = C[0],C[1],C[2]
if ((a[0]-a[1])==(b[0]-b[1]) and (b[0]-b[1])==(c[0]-c[1])) and\
   ((a[2]-a[1])==(b[2]-b[1]) and (b[2]-b[1])==(c[2]-c[1])):
    print("Yes")
else:
    print("No")

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

#define int long long
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) otp(v[i]) cte
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int k,s,ans;

main() {
    cin >> k >> s;
    rep(i,k+1) rep(j,k+1) if (s-i-j <= k && s >= i+j) ans++;
    ct(ans)
}


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

using namespace std;

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

  if (N % 2 == 0) {
    cout << 0.5 << endl;
  } else {
    cout << ((N+1)/2) / (double)N << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
int fir[200010],dis[400010],nxt[400010],id;
void link(int a,int b){nxt[++id]=fir[a],fir[a]=id,dis[id]=b;}
int dep[200010],cnt[2],col[200010];
void dfs(int x,int fa=-1){
	++cnt[dep[x]&1];
	for(int i=fir[x];i;i=nxt[i]){
		if(dis[i]==fa)continue;
		dep[dis[i]]=dep[x]+1;
		dfs(dis[i],x);
	}
}
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi(),a,b;
	for(int i=1;i<n;++i)a=gi(),b=gi(),link(a,b),link(b,a);
	dep[1]=1;dfs(1);
	int C[3]={n/3,n/3,n/3};
	if(n%3>=1)++C[1];
	if(n%3>=2)++C[2];
	memset(col,-1,sizeof col);
	if(cnt[0]<=C[0]||cnt[1]<=C[0]){
		int p=cnt[1]<=C[0];
		for(int i=1;i<=n;++i)if(dep[i]+p+1&1)col[i]=0,--C[0];
		for(int i=1;i<=n;++i)if(col[i]==-1)for(int j=0;j<3;++j)if(C[j]){C[j]--;col[i]=j;break;}
	}else{
		for(int i=1;i<=n;++i)
			if(dep[i]&1){
				if(!C[1])col[i]=0,--C[0];
				else col[i]=1,--C[1];
			}else{
				if(!C[2])col[i]=0,--C[0];
				else col[i]=2,--C[2];
			}
		for(int i=1;i<=n;++i)if(col[i]==-1)for(int j=0;j<3;++j)if(C[j]){C[j]--;col[i]=j;break;}
	}
	int r[]={3,1,2};
	for(int i=1;i<=n;++i)printf("%d ",r[col[i]]),r[col[i]]+=3;
	return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int a, b;
  cin >> a >> b;
  if (a == 1) a = 14;
  if (b == 1) b = 14;
  if (a > b) cout << "Alice" << '\n';
  else if (a < b) cout << "Bob" << '\n';
  else cout << "Draw" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3644
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<int> c(m),a(n+1);
	rep(i,m){
		cin>>c[i];
	}
	a[0]=0;
	FOR(i,1,n+1){
		int mi=INF;
		rep(j,m){
			if(i-c[j]>=0){
				if(a[i-c[j]]<mi){
					mi=a[i-c[j]];
				}
			}
		}
		a[i]=mi+1;
	}
	cout<<a[n]<<endl;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int MAX = 510000;
const int MOD = 1000000007;

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

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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    COMinit();

    ll res = 0;
    // calc max
    for (int i = k - 1; i < n; ++i) {
        res += (a[i] * COM(i, k - 1)) % MOD;
    }

    // calc min
    for (int i = 0; i < n - k + 1; ++i) {
        res = ((res - (a[i] * COM(n - 1 - i, k - 1)) % MOD) + MOD) % MOD;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 13056
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
 
using namespace std;
 
int N;
double ans = 0.0;
std::vector<std::vector<double>> dp(3000, std::vector<double>(3000, -1.0));
 
double coins(vector<double>& v, int i, int tail_size)
{
  if (i == v.size())
  {
    return 1.0;
  }
  dp[i+1][tail_size] = (dp[i+1][tail_size] == -1.0 ? coins(v, i+1, tail_size) : dp[i+1][tail_size]);
  double ans = v[i] * dp[i+1][tail_size];
  if (tail_size < N/2)
  {
    dp[i+1][tail_size+1] = (dp[i+1][tail_size+1] == -1.0 ? coins(v, i+1, tail_size+1) : dp[i+1][tail_size+1]);
    ans += (1.0 - v[i]) * dp[i+1][tail_size+1];
  }
  return ans;
}
 
int main()
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
 
  std::cin >> N;
 
  vector<double> head(N, 0.0);
 
  for (auto& p : head)
  {
    std::cin >> p;
  }
 
  auto ans = coins(head, 0, 0); 
 
  std::cout << std::setprecision(10) << ans;
 
  return 0;
}

Measured memory_bytes: 70912
fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let c: i32 = read();
    let x: i32 = read();

    let mut ans = 0;
    for i in 0..a+1 {
        for j in 0..b+1 {
            for k in 0..c+1 {
                if 500*i + 100*j + 50*k == x {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}

// 以下関数


use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max()

int main() {
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double ha = h * 30;
	double ma = m * 6;
	double angle = abs(0.5 * (60*h - 11 *m));
	angle = angle * pi;
	angle = angle / 180.0;
	double ans = a * a + b * b - (2 * a * b * cos(angle));
	ans = sqrt(ans);
	cout.precision(11);
	cout << ans << endl;
	
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	
	int n;
	cin >> n;
	vector<string> s(2);
	for (int i = 0; i < 2;i++) {
		cin >> s[i];
	}

	ll ans = 1;
	bool isLastV = false;
	bool isLastH = false;
	for (int i = 0; i < n; i++) {
		
		if (i < n-1 && s[0][i] == s[0][i + 1]) {
			if (isLastV) {
				ans = (ans * 2) % MOD_CONST;
			}
			else if (isLastH) {
				ans = (ans * 3) % MOD_CONST;
			}
			else {
				ans = (ans * 6) % MOD_CONST;
			}
			isLastH = true;
			isLastV = false;
			
		}

		if (s[0][i] == s[1][i]) {
			if (isLastV) {
				ans = (ans * 2) % MOD_CONST;
			}
			else if (isLastH) {
				ans = (ans * 1) % MOD_CONST;
			}
			else {
				ans = (ans * 3) % MOD_CONST;
			}
			isLastH = false;
			isLastV = true;

			
		}
		
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define N 102
#define white 0
#define gray 1
#define black 2

int n,color[N],d[N],f[N],S[N],top=0,t=0,nt[N],a[N][N];

void push(int x){
  if(top==N){
    printf("Stack overflow!\n");
    exit(2);
  }
  S[++top]=x;
}

int pop(void){
  if(top==0){
    printf("Stack is empty!\n");
    exit(3);
  }
  top--;
  return S[top+1];
}

int next(int u){
  int v;
  for(v=nt[u];v<=n;v++){
    nt[u]=v+1;
    if(a[u][v]) return v;
  }
  return -1;
}

void dfs(int r){
  int i;
  for(i=1;i<=n;i++) nt[i]=0;

  push(r);
  color[r]=gray;
  d[r]=++t;

  while(S[top]!=0){
    int u=S[top],v=next(u);

    if(v!=-1){
    if(color[v]==white){
      color[v]=gray;
      d[v]=++t;
      push(v);
    }
    }
    else {
      pop();
      color[u]=black;
      f[u]=++t;
    }
  }
}

void dfs_init(){
  int i,u;
  for(i=1;i<=n;i++){
    color[i]=white;
  }
  t=0;

  for(u=1;u<=n;u++){
    if(color[u]==white) dfs(u);
  }

}

void print(){
  int i;
  for(i=1;i<=n;i++) printf("%d %d %d\n",i,d[i],f[i]);
}

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      a[i][j]=0;
    }
  }

  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v);
      a[u][v]=1;
    }
  }

  dfs_init();
  print();


  return 0;
}


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

int main() {

	string S;
	cin >> S;

	if (S == "Sunny") {
		cout << "Cloudy" << endl;
	}
	else if (S == "Cloudy") {
		cout << "Rainy" << endl;
	}
	else {
		cout << "Sunny" << endl;
	}

	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:

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

	if (a == b) {
		cout << 1 << endl;
		return 0;
	}

	ll r = -1LL;
	rrep(i, 62) {
		const ll ai = (a >> i) & 1;
		const ll bi = (b >> i) & 1;
		if (ai != bi) {
			r = (1LL << (i + 1) );
			a &= (r - 1LL), b &= (r - 1LL);
			break;
		}
	}

	ll ans = r / 2LL - a;

	ll al = r / 2LL + a , ar = r;

	b &= (r / 2LL) - 1;
	ll bl = r / 2LL, br = r / 2LL;

	rrep(i, 62) {
		const ll bi = (b >> i) & 1;
		if (bi == 1) {
			br += (1LL << (i + 1));
			break;
		}
	}
	
	if(bl == br) br++;

	ll abl = max(al, bl), abr = min(ar, br);

	ans += ar - al;
	ans += br - bl;
	if(abl <= abr) ans -= abr - abl;

	cout << ans << endl;

	return 0;
}

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

void insertionSort(int n, int a[]) {
  for (int i=0;i<n-1;i++)
      cout << a[i] << " ";
    cout << a[n-1] << endl;
  for (int i=1;i<=n-1;i++) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
    for (int i=0;i<n-1;i++)
      cout << a[i] << " ";
    cout << a[n-1] << endl;
  }
}

int main() {
  int n, a[100];
  cin >> n;
  for (int i=0;i<n;i++)
    cin >> a[i];

  insertionSort(n, a);
}



Measured memory_bytes: 3108
LIST = list(("#", ".")*151)
while True:
  h, w = list(map(int, input().split()))
  if h == w == 0:
    break
  for i in range(h):
    if i % 2 == 0:
      print("".join(LIST[0:w]))
    else:
      print("".join(LIST[1:w+1]))
  print("")


Measured memory_bytes: 5624
using System;
using System.Collections.Generic;
using System.Linq;
 
static class MainClass {
 
  public struct City{
    public long num;
    public City(long n){
      num = n;
    }
 
  }
 
  public static void Main (string[] args) {
    var cube = Console.ReadLine().ToCharArray();
    var ans = 0;

    if(cube.Contains('0') && cube.Contains('1')) ans = cube.GroupBy(g => g).Select(x => x.Count()).Min() * 2;
    Console.WriteLine(ans);
  }
  public static long Euclidean(long a, long b){
    if(a % b == 0){return b;}
    return Euclidean(b, a % b);
  }
}

Measured memory_bytes: 13536
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<map>

using namespace std;

int main(){
    long long int n, m, p[100009], y[100009];
    vector<long long> v[100009];
    map<long long, int> mp[100009];
    cin >> n >> m;
    for(int i=0;i<m;i++){
        cin >> p[i] >> y[i];
        v[p[i]].push_back(y[i]);
    }
    for(int i=1;i<=n;i++){
        sort(v[i].begin(), v[i].end());
        for(int j=0;j<v[i].size();j++){
            mp[i][v[i][j]] = j+1;
        }
    }
    for(int i=0;i<m;i++){
        printf("%06lld%06d\n", p[i], mp[p[i]][y[i]]);
    }
}

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

int main(void) {
      int n;
      bool mark = false;
      cin >> n;

      for (int i = 0; i < n; i++) {
            char color;
            cin >> color;
            if ( color == 'Y') {
                  mark = true;
                  break;
            }
      }
      if ( mark ) {
            cout << "Four" << endl;
      }
      else {
            cout << "Three" << endl;
      }
      return 0;
}


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

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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


    int n;
    cin >> n;
    vector<string> vs(n);
    rep(i, n){
        cin >> vs[i];
    }
    sort(all(vs));
    vs.push_back(" ");

    int cnt = 0;
    int m = 0;
    rep(i, n){
        if(vs[i] == vs[i+1]){
            cnt ++;
        }else{
            m = max(m, cnt);
            cnt = 0;
        }
    }

    cnt = 0;
    rep(i, n){
        if(vs[i] == vs[i+1]){
            cnt++;
        }else{
            if(cnt == m){
                cout << vs[i] << endl;
            }
            cnt = 0;
        }
    }


    return 0;
}


Measured memory_bytes: 14308
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)

#define X first
#define Y second

using namespace std; 
typedef pair<int,int> pii;
const int INF = 1e9;

int main(){
	int N, M, H, K;
	while(cin>>N>>M>>H>>K, N|M|H|K){
		vector<pii> edge[105];
		int cost[505], in_h[505], in_r[505];
		int S, T, P, pd[1<<8], pk[1<<8];
		fill(pd, pd+(1<<8), INF);

		rep(i,M){
			int a,b,c,h,r;
			cin >> a >> b >> cost[i] >> in_h[i] >> in_r[i];
			in_r[i]--;
			edge[a].emplace_back(b, i);
			edge[b].emplace_back(a, i);
		}
		cin >> S >> T >> P;
		rep(i,P){
			int l, d, k, s=0;
			cin >> l >> d;
			rep(j,l){
				cin >> k;
				k--;
				s |= (1<<k);
			}
			pk[i] = s;
			pd[i] = d;
		}

		int pass[1<<8];
		fill(pass, pass+(1<<8), INF);
		pass[0] = 0;
		rep(i,1<<K) rep(j,P){
			pass[i | pk[j]] = min( pass[i|pk[j]], pass[i] + pd[j] );
		}
		//rep(i,1<<K) cout << pass[i] << " "; cout << endl;

		int ans = INF;
		rep(k,1<<K){
			if( pass[k] == INF ) continue;
			int d[105][30];
			fill( d[0], d[0]+105*30, ans - pass[k] );
			priority_queue<pair<int,pii>> que;
			d[S][0] = 0;
			que.push({0,{S,0}});
			while( !que.empty() ){
				int dd = que.top().X;
				int dn = que.top().Y.X;
				int dh = que.top().Y.Y;
				que.pop();
				if( dd > d[dn][dh] ) continue;
				for(auto t: edge[dn]){
					int nx = t.X;
					int nh = dh + in_h[t.Y];
					int ct = d[dn][dh];
					int r  = in_r[t.Y];
					if( !( (1<<r)&k ) ) ct += cost[t.Y];
					if( nh <= H && ct < d[nx][nh] ){
						for(int i=nh; i<=H; i++) d[nx][i] = min(d[nx][i], ct);
						que.push({ct, {nx,nh}});
					}
				}
			}
			int ret = INF;
			rep(h, H+1) ret = min(ret, d[T][h]);
			ans = min(ans, pass[k] + ret);
		}

		cout << (ans==INF ? -1 : ans) << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main(){
	int w, h; cin >> w >> h;
	vector<ll> p(w), q(h);
	rep(i, 0, w) cin >> p[i];
	rep(i, 0, h) cin >> q[i];
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	p.push_back(1e9);
	q.push_back(1e9);
	ll ws = 0, wg = w+1, hs = 0, hg = h+1;
	ll ans = 0;
	while ((ws < w) || (hs < h)) {
		if (p[ws] < q[hs]) {
			ans += hg * p[ws];
			wg--; ws++;
		}
		else {
			ans += wg* q[hs];
			hg--; hs++;
		}
	}
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 2688
#include <stdio.h> 
 int main(){ 
     int h, w; 
     int i, j; 
     while(1){ 
         scanf("%d %d ", &h, &w); 
         if(h==0&&w==0)break; 
         for(i=0;i<h;i++){ 
             for(j=0;j<w;j++){ 
                 printf("#"); 
             } 
             printf("\n"); 
         } 
         printf("\n"); 
     }  
     return 0; 
 } 



Measured memory_bytes: 2144
#include <stdio.h>

int main(void){
	double x1, y1, x2, y2, xq, yq, x, y;
	
	while( scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &xq, &yq) != EOF) {
		if(y1 == y2) {
			x = xq;
			y = y1-(yq-y1);
		}
		else if(x1 == x2){
			y = yq;
			x = x1-(xq-x1);
		}
		else{
			double dx=x1, dy=y1;
			//(x1,y1)が原点に来るように平行移動	
			x1 = 0;
			y1 = 0;
			x2 -= dx;
			y2 -= dy;
			xq -= dx;
			yq -= dy;
			
			//printf("now:%lf,%lf,%lf,%lf,%lf,%lf\n", x1, y1, x2, y2, xq, yq);
			
			double m = (y2-y1)/(x2-x1);
			double b = xq/m + yq;
			
			//printf("m=%lf,b=%lf\n",m,b);
			
			double xc = m*b/(m*m+1);
			double yc = -xc/m +b;
			
			x = xq + 2*(xc-xq);
			y = yq + 2*(yc-yq);
			
			
			x+=dx;
			y+=dy;
		}
	
		printf("%lf %lf\n", x, y);
	
	}

	return 0;
}

Measured memory_bytes: 652
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

//DFS
vector<vector<int>> g;
const int N = 2e5;
int used[N];
int col[N];
ll n;



void dfs(int i, int c) {
  if(used[i]) return;
  used[i] = 1;
  col[i] = c;
  for(auto to : g[i]) {
    dfs(to, (c+1)%2);
  }
}



int main(){
  ll ans=0;
  cin >> n;
  g.resize(n);
  ll a,b;
  REP(i,n-1){
    cin>>a>>b;
    a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  

  if (n==2){
    cout<<"1 2"<<endl;
    return 0;
  }
  if (n==3){
    cout<<"1 2 3"<<endl;
    return 0;
  }

  dfs(0, 0);

  ll kz1=0;
  ll kz2=0;
  for(ll i=0;i<n;i++){
    col[i]++;
    if (col[i]==1)kz1++;
    if (col[i]==2)kz2++;
  }


  if (kz1<kz2){
    ll tmp=kz2;
    kz2=kz1;
    kz1=tmp;
    for(ll i=0;i<n;i++){
      col[i]=3-col[i];
    }
  }

  ll need0kz=n/3;
  ll need1kz=n/3+(n%3!=0);
  ll need2kz=n/3+(n%3==2);

  if (kz2>=need2kz){
    ll w=0;
    for(ll i=0;i<n;i++){
      if (col[i]==2){
        if (w==kz2-need2kz)break;
        col[i]=0;
        w++;
      }
    }

    w=0;
    for(ll i=0;i<n;i++){
      if (col[i]==1){
        if (w==kz1-need1kz)break;
        col[i]=0;
        w++;
      }
    }

  }else{
    for(ll i=0;i<n;i++){
      if (col[i]==2){
        col[i]=0;
        need0kz--;
      }
    }
    ll w=0;
    for(ll i=0;i<n;i++){
      if (col[i]==1){
        if (w==need2kz)break;
        col[i]=2;
        w++;
      }
    }

    w=0;    
    for(ll i=0;i<n;i++){
      if (col[i]==1){
        if (w==need0kz)break;
        col[i]=0;
        w++;
      }
    }



  }





  ll w=1;
  for(ll i=0;i<n;i++){
    if (col[i]%3==0){
      col[i]+=3*w;
      w++;
    }
  }
  
  w=0;
  for(ll i=0;i<n;i++){
    if (col[i]%3==1){
      col[i]+=3*w;
      w++;
    }
  }


  w=0;
  for(ll i=0;i<n;i++){
    if (col[i]%3==2){
      col[i]+=3*w;
      w++;
    }
  }



  REP(i,n){
    cout<<col[i]<<" ";
  }


  return 0;
}


Measured memory_bytes: 15488
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

void fail() {
    std::cout << "No" << std::endl;
    std::exit(0);
}

int main() {
    Int n;
    std::cin >> n;
    Vector<Int> h(n);
    for (auto& x : h) std::cin >> x;
    h.push_back(INF);

    for (Int i = n - 1; i >= 0; --i) {
        if (h[i] > h[i + 1]) --h[i];
        if (h[i] > h[i + 1]) fail();
    }

    std::cout << "Yes" << std::endl;
    return 0;
}


Measured memory_bytes: 1792
import sys
from heapq import heappush, heappop


class Dijkstra:

    class Edge:
        def __init__(self, end, cost):
            self.to = end
            self.cost = cost

    def __init__(self, node_size, inf):
        self._node = node_size
        self._graph = [[] for _ in range(self._node)]
        self.inf = inf
        self.dist = [self.inf for _ in range(self._node)]

    def add_edge(self, st, ed, cs):
        self._graph[st].append(self.Edge(ed, cs))

    def solve(self, start):
        que = []
        self.dist[start] = 0
        heappush(que, (0, start))
        while que:
            cur_cost, cur_vertex = heappop(que)
            if self.dist[cur_vertex] < cur_cost:
                continue
            for e in self._graph[cur_vertex]:
                if self.dist[e.to] > cur_cost + e.cost:
                    self.dist[e.to] = cur_cost + e.cost
                    heappush(que, (self.dist[e.to], e.to))


if __name__ == '__main__':
    V, E, r = map(int, sys.stdin.readline().split())
    dk = Dijkstra(V, 10 ** 10)
    for i in range(E):
        s, t, d = map(int, sys.stdin.readline().split())
        dk.add_edge(s, t, d)
    dk.solve(r)
    for value in dk.dist:
        if value == dk.inf:
            print("INF")
        else:
            print(value)


Measured memory_bytes: 139716
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;

vector<int> v;
int a[3]={3,5,7};
int ans;
int n;

bool judge(int N){
  bool flag[3];
  rep(i,3)flag[i]=false;
 while(N>0){
  rep(i,3){
   if(N%10==a[i])flag[i]=true; 
  }
   N/=10;
 }
  if(flag[0]&&flag[1]&&flag[2])return true;
  else return false;
}

int main()
{
  cin >> n;
  rep(i,3)v.push_back(a[i]);
  vector<int> nv;
 int count=0;
  while(count<10){
    nv.clear();
   rep(i,v.size()){
     if(judge(v[i])&&v[i]<=n)ans++;
    rep(k,3){
     nv.push_back(10*v[i]+a[k]); 
    }
   }
    v.swap(nv);
    count++;
  }
  cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1600
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin>>n,n!=0){
    vector<int> a(n);
    for(int i=0;i<n;i++)
      cin>>a[i];
    long long ans=0;
    sort(a.begin(),a.end()/*,greater<int>()*/);
    for(int i=0;i<n;i++){
      ans+=a[i]*(n-1-i);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3080
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int AA[3];
    REP(i,3)R(AA[i]);
    sort(AA,AA+3);
    W(AA[0]==AA[2]?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
string str;
int main() {
	cin >> str;
	ll cnt[26];
	memset(cnt,0,sizeof(cnt));
	int n = str.size();
	for ( int j = 0; j < n; j++ )
		cnt[str[j] - 'a']++;
	ll ans = 0, l = 0;
	for ( int j = 0; j < 26; j++ )
		l +=   cnt[j] * ( cnt[j] - 1 )  / 2 ;
	ans = 1LL*n * ( n - 1 ) / 2;
	ans = 1 + ans - l;
	cout << ans;
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    
    map<int, int> subs_by_boss;
    for (int i = 1; i <= n; ++i) {
        subs_by_boss[i] = 0;
    }
    
    for (int i = 2; i <= n; ++i) {
        int x;
        cin >> x;
        
        ++subs_by_boss[x];
    }
    
    for (auto [b, c] : subs_by_boss) {
        cout << c << '\n';    
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 12976
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N, K;
int H[301];
ll dp[301][301];

int main() {
	cin >> N >> K;
	REP(i, N) scanf("%d", H + i + 1);
	
	fill(dp[0], dp[N + 1], longINF);
	dp[0][0] = 0;
	REP(i, N) REP(j, N - K + 1) {
		if (dp[i][j] == longINF) continue;
		FOR(k, i + 1, N + 1) {
			chmin(dp[k][j + 1], dp[i][j] + max(0, H[k] - H[i]));
		}
	}
	
	ll ans = longINF;
	REP(i, N + 1) chmin(ans, dp[i][N - K]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 896
function Main(input){
	input = input.split("");
  var sum = 0;
  for(var i = 0; i < 4;i++){
  	input[i]=="+"?sum++:sum--;
  }
  return sum
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
-+--
`);

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define yes "Yes"
#define no "No"
typedef long long ll;
typedef pair<ll,ll> pint;

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

int main(){
    int n;cin>>n;
    vector<pair<int,int> >ta(n);
    rep(i,n) cin>>ta[i].first>>ta[i].second;
    ll anst=1;
    ll ansa=1;
    rep(i,n){
        ll t=ta[i].first;
        ll a = ta[i].second;
        ll n1=max((anst+t-1)/t,(ansa+a-1)/a);
        if(n1<1)n1=1;
        anst=n1*t;
        ansa=n1*a;
    }
    cout<<anst+ansa;
}

Measured memory_bytes: 256