akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}
const int FACT_SIZE=1111111;
int fact[FACT_SIZE];
int inv[FACT_SIZE];
struct fact_exec{
    fact_exec(){
        fact[0]=1;
        for(int i=1;i<FACT_SIZE;i++)fact[i]=fact[i-1]*i%mod;
        inv[FACT_SIZE-1]=mpow(fact[FACT_SIZE-1],mod-2);
        for(int i=FACT_SIZE-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
    }
}factexec;
int nCk(int n,int k){
    if(n<0|k<0||k>n)return 0;
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}
int nPk(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*inv[n-k]%mod;
}


int F[100];

pint solve(int X,int Y){
    int k=0;
    while(F[k+1]<=X&&F[k+2]<=Y)k++;


    int ans=0;
    for(int i=2;i<k;i++){
        int x=F[k]+F[i]*F[k-i];
        int y=F[k+1]+F[i]*F[k-i+1];
        if(x>X||y>Y)continue;
        add(ans,((Y-y)/x+1)%mod);
    }
    add(ans,((Y-F[k+1])/F[k]+1)%mod);
    return {k-1,ans};
}


signed main(){
    F[0]=0;
    F[1]=1;
    for(int i=2;i<100;i++)F[i]=F[i-1]+F[i-2];
    int Q;cin>>Q;
    while(Q--){
        int X,Y;
        cin>>X>>Y;

        if(X>Y)swap(X,Y);

        if(X==1){
            cout<<1<<" "<<Y%mod<<endl;
            continue;
        }

        pint p,q;
        p=solve(X,Y);
        q=solve(X,X);
        if(p.fi==q.fi)add(p.se,q.se);

        if(p.fi==1){
            cout<<1<<" "<<4<<endl;
        }
        else{
            cout<<p.fi<<" "<<p.se<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 21376
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;

template<int MOD>
struct ModInt {
    using M = ModInt;
    long long val;
    ModInt(long long v = 0) {
        set_val(v % MOD + MOD);
    }
    M& set_val(unsigned int v) {
        val = v<MOD ? v : v - MOD;
        return *this;
    }
    explicit operator bool() const {return val != 0;}
    M operator-() const {return M() - *this;}
    M operator+(const M& r) const {return M().set_val(val + r.val);}
    M operator-(const M& r) const {return M().set_val(val + MOD - r.val);}
    M operator*(const M& r) const {return M().set_val(val * r.val % MOD);}
    M operator/(const M& r) const {return *this * r.inverse();}
    M& operator+=(const M& r) {return *this = *this + r;}
    M& operator-=(const M& r) {return *this = *this - r;}
    M& operator*=(const M& r) {return *this = *this * r;}
    M& operator/=(const M& r) {return *this = *this / r;}
    bool operator==(const M& r) const {return val == r.val;}
    M pow(long long n) const {
        M x = *this, r = 1;
        while(n>0) {
            if(n & 1) r *= x;
            x *= x;
            n >> 1;
        }
        return r;
    }
    M inverse() const {
        int a = val, b = MOD, u = 1, v = 0, t;
        while(b>0) {
            t = a/b;
            swap(a-=t*b, b);
            swap(u-=t*v, v);
        }
        return ModInt(u);
    }
    friend istream& operator<<(istream& i, const M& r) {
        long long tmp; i >> tmp;
        r = M(i);
        return i;
    }
    friend ostream& operator<<(ostream& os, const M& r) {
        return os << r.val;
    }
};

template<typename M>
struct BinomialCoefficients {
    vector<M> fact, finv, inv;
    BinomialCoefficients() {};
    BinomialCoefficients(int n) : fact(n+1), finv(n+1), inv(n+1) {
        init(n);
    }
    void init(int n) {
        fact[0] = finv[n] = inv[0] = 1;
        for(int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i;
        finv[n] /= fact[n];
        for(int i = n-1; i >= 0; --i) finv[i] = finv[i+1] * (i+1);
        for(int i = 1; i<= n; ++i) inv[i] = finv[i]*fact[i-1];
    }
    M C(int n, int k) {
        if(n<k || k<0) return 0;
        return fact[n]*finv[n-k]*finv[k];
    }
    M P(int n, int k) {
        if(n<k || k<0) return 0;
        return fact[n]*finv[n-k];
    }
    M H(int n, int k) {
        if(n<0 || k<0) return 0;
        return k == 0 ? 1 : C(n+k-1,k);
    }
};

template<typename T>
map<T, T> primeFactor(T n) {
    map<T,T> res;
    for(T i = 2; i*i<=n; ++i) {
        while(n%i==0) {
            res[i] ++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    using mint = ModInt<MOD>;
    BinomialCoefficients<mint> bc(n+100);
    mint ans = 1;
    for(auto x : primeFactor(m)) {
        ans *= bc.C(x.second+n-1, n-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl;

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1)a = 100;
	if (b == 1)b = 100;

	if (a == b) {
		print("Draw");
	}
	else if (a > b){
		print("Alice");
	}
	else print("Bob");








	return 0;
}

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

int N;
int a[100000];

signed main()
{
	cin >> N;
	rep(i,N) {
		cin >> a[i];
		a[i]--;
	}

	int ans = 0;
	rep(i,N) {
		if (a[a[i]] == i) {
			ans++;
		}
	}

	cout << ans / 2 << endl;
}



Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;


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

	int n;
	cin >> n;
	
	int p[n];
	int n0=0,n2=0,n13=0;
	for(int i=0;i<n;i++){
		cin >> p[i];
		p[i] %= 4;
		if(p[i] == 0) n0++;
		else if(p[i] == 2) n2++;
		else		n13++;
	}
	if(n13==0) cout << "Yes\n";
	else{
		if(n2 >= 1) n13++;
		if(n0+1 >= n13) cout << "Yes\n";
		else			cout << "No\n";
	}
				
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define change(a,b) do{ll c=a; a=b; b=c;}while(0)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        change(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N,M;
  cin>>N>>M;
  if(N!=1&&M!=1){
    cout<<(N*M+1)/2<<endl;
  }
  else cout<<1<<endl;
}


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

using namespace std;
typedef long long ll;
const int MAXN = 2100;

int N;
string S;
vector <int> edge[MAXN];
int nnode[MAXN];
int ddep[MAXN];
int dmin[MAXN];
int ans;

void flood (int cloc, int last)
{
    int ntot = 0;
    int nbest = 0;
    int nmin = 0;
    nnode[cloc] = S[cloc] - '0';
    ddep[cloc] = 0;
    for (int neigh : edge[cloc])
    {
        if (neigh == last) continue;
        flood (neigh, cloc);

        nnode[cloc] += nnode[neigh];
        int nb = ddep[neigh] + nnode[neigh];
        ddep[cloc] += nb;
        ntot += nb;
        if (nb > nbest)
        {
            nbest = nb;
            nmin = dmin[neigh] + nnode[neigh];
        }
    }

    dmin[cloc] = max (0, nbest + nmin - ntot);
}

void solve_root (int x)
{
    flood (x, -1);
    if (dmin[x] == 0 && ddep[x] % 2 == 0)
    {
        //cout << x << " " << ddep[x] << "\n";
        ans = min (ans, ddep[x]);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N >> S;
    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    ans = 1e9;
    for (int i = 0; i < N; i++)
    {
        solve_root (i);
    }
    if (ans > 1e8)
        cout << "-1\n";
    else
        cout << ans / 2 << "\n";
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int card[550][550];

int main(){
	
	int N, K;
	cin >> N >> K;
	
	for(int i = 0; i < K; i++){
		for(int j = 0; j < N / 2; j++){
			cin >> card[i][j];
			card[i][j]--;
		}
	}
	
	int ans[1100];
	
	while(true){
		for(int i = 0; i < N; i++){
			ans[i] = rand() % 2;
		}
		bool flag = true;
		for(int i = 0; i < K; i++){
			int cnt = 0;
			for(int j = 0; j < N / 2; j++){
				cnt += ans[card[i][j]];
			}
			if(cnt < N / 8 || cnt > 3 * N / 8){
				flag = false;
				break;
			}
		}
		if(flag){
			break;
		}
	}
	
	for(int i = 0; i < N; i++){
		cout << ans[i];
	}
	cout << endl;
	
	return 0;
}



Measured memory_bytes: 4128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};


int main(void) {
  int n;
  cin >> n;
  if(n%2 == 0) cout << n/2 << endl;
  else cout << n/2 + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

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

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

int main(){
    ll n ; cin>>n;
    string s; cin>>s;
    ll ans = 0;
    for(ll i= 0;i<n-2;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  for (int i = 0; i < m; ++i) {
    cin >> p[i] >> s[i];
    p[i]--;
  }
  vector<ll> ac_cnt(n);
  vector<ll> wa_cnt(n);
  for (int i = 0; i < m; ++i) {
    if (s[i] == "AC") {
      ac_cnt[p[i]]++;
    } else {
      if (ac_cnt[p[i]] == 0) {
        wa_cnt[p[i]]++;
      }
    }
  }
  ll ans1 = 0, ans2 = 0;
  for (int i = 0; i < n; ++i) {
    if (ac_cnt[i]) {
      ans1++;
      ans2 += wa_cnt[i];
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}

Measured memory_bytes: 7680
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"; exit $?
exit 0
'''
import sys

def _s(): return sys.stdin.readline().strip()

s = _s()
n = len(s)
mid = n//2
if len(s)%2==0:
    nh = mid
    s1= s[0:mid]
    s2= s[mid:][::-1]
else:
    nh = mid + 1
    s1= s[0:nh]
    s2= s[mid:][::-1]
#
cnt = 0
for i in range(nh):
    if s1[i]!=s2[i]: cnt+=1
print(cnt)


Measured memory_bytes: 38408
#include <stdio.h>
#include <iostream>
#define Re register int
#define mod int(1e9+7)

char map[1005][1005];
int H,W,f[1005][1005];

template <typename T> inline void read(T &var)
{
	T x=0; int w=0; char ch=0;
	while (!isdigit(ch)) w|=ch=='-',ch=getchar();
	while (isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	var=w?-x:x;
}
int main(int argc, char const *argv[])
{
	read(H),read(W); f[1][1]=1;
	for (Re i=1; i<=H; ++i)
		scanf("%s",map[i]);
	for (Re i=1; i<=H; ++i)
		for (Re j=1; j<=W; ++j)
			if (map[i][j-1]=='.') (f[i][j]+=f[i-1][j]+f[i][j-1])%=mod;
	printf("%d\n",f[H][W]);
	return 0;
}

Measured memory_bytes: 5120
n,a=int(input()),sorted(list(map(int,input().split())));b=set(a);l=len(b);print("Yes"if(l==3and b.pop()^b.pop()==b.pop()and n%3==0and a[n//3-1]!=a[n//3]and a[n//3*2-1]!=a[n//3*2])or(l==1and a[0]==0)or(l==2and a[0]==0and n%3==0and a[n//3-1]!=a[n//3])else"No")

Measured memory_bytes: 14212
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
void rle(string s,vector<char> &cha,vector<ll> &num){
    ll a=0,cnt=0;
    string t;char x=s[0];
    while(a<s.size()){
        if(x==s[a])cnt++;
        else{
            cha.pb(x);num.pb(cnt);
            x=s[a];cnt=1;
        }
        a++;
    }
    cha.pb(x);num.pb(cnt);
}

int main(){
    string s;cin >> s;
    vector<char> cha;
    vector<ll> num;
    rle(s,cha,num);
    ll sum=0;
    ll t=cha.size();
    rep(i,t){
        if(i==0&&cha[0]=='>'){
            sum+=num[0]*(num[0]+1)/2;
            continue;
        }
        if(cha[i]=='>'){
            ll a=num[i-1],b=num[i];
            sum+=a*(a-1)/2;
            sum+=b*(b-1)/2;
            sum+=max(a,b);
        }
    }
    if(cha[t-1]=='<')sum+=num[t-1]*(num[t-1]+1)/2;
    cout << sum <<endl;
}

Measured memory_bytes: 6564
#include <stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    long long  a,b,c;
    cin>>a>>b>>c;
    long long ans=min((a%2)*b*c,a*(b%2)*c);
    long long ans1;
    ans1=min(ans,a*b*(c%2));
    printf("%lld\n",ans1);
    return 0;
}

Measured memory_bytes: 256
while True:
    try:
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
        hit = sum(1 for x, y in zip(a, b) if x == y)
        hits = [x for x, y in zip(a, b) if x == y]
        blow = sum(1 for x in a if x in b and x not in hits)
        print(hit, blow)
    except:
        break

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, x, y; cin >> n >> x >> y;
    x--;
    y--;
    vector<int> ans(n);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int dist = min(abs(x - i) + 1 + abs(y - j), j - i);
            ans[dist]++;
        }
    }
    for(int i=1;i<n;i++){
        cout << ans[i] << endl;
    }
}

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

int main(void){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  int d = 0;
  if(a == 5){
    if(b == 7 && c == 5){
      d = 1;
    }
    if(b == 5 && c == 7){
      d = 1;
    }
  }else if(a == 7){
    if(b == 5 && c == 5){
      d = 1;
    }
  }
  if(d == 1){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
}


Measured memory_bytes: 128
/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(ll i=(a);i<=(b);++i)
#define rf(i,a,b) for(ll i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
ll n,cnt;
int main(){
    read(n);
    fr(i,1,sqrt(n-1)){
    	if((n-1)%i==0){
    		cnt+=2;
    		if(i==(n-1)/i)--cnt;
		}
	} 
	fr(i,2,sqrt(n))if(n%i==0){
		ll n1=n;
		while(n1%i==0)n1/=i;
		if(n1%i==1)++cnt;
	}
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<deque>
using namespace std;
int main(){
	deque<int> a,b;
	int x;
	for(int i=0;i<10;i++){
		cin>>x;
		a.push_back(x);
	}
	for(int i=0;i<10;i++){
		cin>>x;
		b.push_back(x);
	}
	sort(a.begin(),a.end(),greater<int>());
	sort(b.begin(),b.end(),greater<int>());
	cout<<a[0]+a[1]+a[2]<<' '<<b[0]+b[1]+b[2]<<endl;
return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	int m, n;
	cin >> m >> n;
	vector<vi> graph(m, vi(m));
	vector<vector<pii>> v(m, vector<pii>(n, pii(0, INF)));
	REP(i, m)
	{
		int k; cin >> k;
		REP(j, k)
		{
			int s, t; string con;
			cin >> s >> con >> t;
			s--;
			if (con == "<=") chmin(v[i][s].second, t);
			else chmax(v[i][s].first, t);
		}
	}
	bool ans = false;
	bool ff = true;
	REP(i, m)REP(j, n)
	{
		if (v[i][j].first > v[i][j].second) ff = false;
	}
	if (ff)
	{
		REP(i, m)REP(j, m)
		{
			if (i == j) continue;
			bool f = true;
			REP(k, n)
			{
				if (v[i][k].second < v[j][k].first) f = false;
			}
			if (f) graph[j][i] = 1;
		}

		set<int> st;
		REP(j, m) st.insert(j);
		while (st.size())
		{
			bool up = false;
			for (auto j : st)
			{
				bool f = true;
				for (auto k : st)
				{
					if (j == k) continue;
					if (graph[j][k] == 0) f = false;
				}
				if (f)
				{
					st.erase(j);
					up = true;
					break;
				}
			}
			if (!up) break;
		}
		if (st.size() == 0) ans = true;
	}
	puts(ans ? "Yes" : "No");
	return 0;
}

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

int main(){
  constexpr int Ndig= 10;
  int N;
  string S;
  cin >> N >> S;

  vector<vector<int>> positions(Ndig);
  for(int i=0; i<N; i++){
    int d= stoi(S.substr(i,1));
    positions.at(d).emplace_back(i);
  }

  vector<int> existdig;
  for(int d=0; d<Ndig; d++){
    if(!positions.at(d).empty()){
      existdig.emplace_back(d);
    }
  }

  int ans= 0;
  for(auto head:existdig){
    for(auto tail:existdig){
      int pos_head= positions.at(head).at(0);
      int pos_tail= positions.at(tail).back();
      if(pos_head < pos_tail){
        for(auto mid:existdig){
          auto itr0= upper_bound(positions.at(mid).begin(), positions.at(mid).end(), pos_head);
          auto itr1= lower_bound(positions.at(mid).begin(), positions.at(mid).end(), pos_tail)- 1;
          
          if(distance(itr0, itr1) >= 0){
            ans++;
          }
        }
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3844
import java.util.Scanner;


public class Main {

	private void doit(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n-- > 0){
			int y = sc.nextInt();
			int m = sc.nextInt();
			int d = sc.nextInt();
			int sum = calc(1000,1,1);
			int sum1 = calc(y,m,d);
			//System.out.println(sum + " " + sum1);
			System.out.println(sum - sum1);
		}
	}

	private int calc(int y, int m, int d) {
		int sum = 0;
		for(int i=1; i < y;i++){
			int nowday;
			if(i % 3 == 0){
				nowday = 20 * 10;
			}
			else{
				nowday = 20 * 5 + 19 * 5;
			}
			sum += nowday;
		}

		//month
		for(int i = 1; i <m; i++ ){
			int nowday;
			if(y % 3 == 0){
				nowday = 20;
			}
			else if(i % 2 == 0){
				nowday = 19;
			}
			else{
				nowday = 20;
			}
			sum += nowday;
		}

		sum += d;
		return sum;
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}

}

Measured memory_bytes: 12000
#include<stdio.h>
int main(void){
	int n,a,i,cnt=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		while(1){
			if(a%2){
				break;
			}
			else{
				a/=2;
				cnt++;
			}
		}
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define f first
#define s second
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%I64d",&x)
#define CLR(x)  memset(x,0,sizeof(x))
#define RESET(x,a) memset(x,a,sizeof(x))
#define pi pair<int,int>
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<">value ("<<#x<<") : "<<x<<endl;

const int N=405;
int a[N][4]; //tile
ll val[N];   //hash of tile
int p[4];
int sym[4];
ll g[4];
ll ans[16];
int n;

inline ll h(int p[4],int k)
{
    ll res=0LL;
    for(int i=k;i<4;i++)
        res = res<<10LL | (ll)p[i];
    for(int i=0;i<k;i++)
        res = res<<10LL | (ll)p[i];
    return res;
}

ll normalise(int p[4])
{
    return min(h(p,0),min(h(p,1),min(h(p,2),h(p,3))));
}

ll way(int x, int y, int r)
{
    int i,j,k,b[4];
    for(i=0;i<4;i++)
        b[i]=a[y][ (i+r)%4 ];
    ll e,f,c,d;
    sym[0]=sym[1]=sym[2]=sym[3]=1;
    p[0]=b[1];   p[1]=b[0];
    p[2]=a[x][1];   p[3]=a[x][0];
    e=h(p,0); f=h(p,1); c=h(p,2); d=h(p,3);
    if(e==f)sym[0]=4;
    else if(e==c)sym[0]=2;
    g[0]=min(e,min(f,min(c,d)));

    p[0]=b[0];   p[1]=b[3];
    p[2]=a[x][2];   p[3]=a[x][1];
    e=h(p,0); f=h(p,1); c=h(p,2); d=h(p,3);
    if(e==f)sym[1]=4;
    else if(e==c)sym[1]=2;
    g[1]=min(e,min(f,min(c,d)));

    p[0]=b[2];   p[1]=b[1];
    p[2]=a[x][0];   p[3]=a[x][3];
    e=h(p,0); f=h(p,1); c=h(p,2); d=h(p,3);
    if(e==f)sym[2]=4;
    else if(e==c)sym[2]=2;
    g[2]=min(e,min(f,min(c,d)));

    p[0]=b[3];   p[1]=b[2];
    p[2]=a[x][3];   p[3]=a[x][2];
    e=h(p,0); f=h(p,1); c=h(p,2); d=h(p,3);
    if(e==f)sym[3]=4;
    else if(e==c)sym[3]=2;
    g[3]=min(e,min(f,min(c,d)));

    CLR(ans);
    ans[0]=1;
    for(i=x+1;i<n;i++)
    {
#define F(j,k) if ( !((j>>k)&1) && val[i]==g[k] ) ans[j|(1<<k)]+=sym[k]*ans[j]
        if(i==y)continue;
        F(14,0); F(14,1); F(14,2); F(14,3);
        F(13,0); F(13,1); F(13,2); F(13,3);
        F(12,0); F(12,1); F(12,2); F(12,3);
        F(11,0); F(11,1); F(11,2); F(11,3);
        F(10,0); F(10,1); F(10,2); F(10,3);
        F(9,0); F(9,1); F(9,2); F(9,3);
        F(8,0); F(8,1); F(8,2); F(8,3);
        F(7,0); F(7,1); F(7,2); F(7,3);
        F(6,0); F(6,1); F(6,2); F(6,3);
        F(5,0); F(5,1); F(5,2); F(5,3);
        F(4,0); F(4,1); F(4,2); F(4,3);
        F(3,0); F(3,1); F(3,2); F(3,3);
        F(2,0); F(2,1); F(2,2); F(2,3);
        F(1,0); F(1,1); F(1,2); F(1,3);
        F(0,0); F(0,1); F(0,2); F(0,3);
//        for(j=14;j>=0;j--)
//        {
//            for(k=0;k<4;k++)
//            {
//                if(j&(1<<k))continue;
//                if(val[i]==g[k])
//                    ans[j|(1<<k)] += sym[k]*ans[j];
//            }
//        }
    }
    return ans[15];
}

int main()
{
    int i,j,k;
    si(n);
    for(i=0;i<n;i++)
    {
        for(j=0;j<4;j++)
            si(a[i][j]);
        val[i] = normalise(a[i]);
    }
    ll ans=0LL;
    for(i=0;i<n;i++)
        for(j=i+1;j<n;j++)
            for(k=0;k<4;k++)
                ans+=way(i,j,k);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;


int main(){
  int h,w,a,b;
  while(cin >> h >> w >> a >> b){
    vector<string> ans(h, string(w, '0'));

    REP(i,b){
      REP(j,a){
        ans[i][j] = '1';
      }
    }

    FOR(i,b,h){
      FOR(j,a,w){
        ans[i][j] = '1';
      }
    }
    
    

    REP(i,h){
      cout << ans[i] << endl;
    }
  }

  return 0;
}


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

int check(int n,long long P,int k,vector<int> w){
  int i = 0;
  for(int j=0;j<k;++j){
    long long s = 0;
    while(s + w.at(i) <= P){
      s += w.at(i);
      i++;
      if(i == n) return n;
    }
  }
  return i;
}

long long solve(int n,int k,vector<int> w){
  long long left = 0;
  long long right = n * 10000;
  long long mid;

  while(right - left > 1){
    mid = (left + right) / 2;
    int v = check(n,mid,k,w);
    if(v >= n){
      right = mid; 
    }else{
      left = mid; 
    }
  }
  return right;
}

int main(){
  int n,k;
  long long ans;
  cin >> n >> k;
  vector<int> w(n);
  for(int i=0;i<n;++i){
    cin >> w.at(i);
  }
  ans = solve(n,k,w);
  cout << ans << endl;
  return 0;
}



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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for (int i=0; i<=a; ++i) {
    int y = x - 500*i;
    if (y < 0) break;
    for (int j=0; j<=b; ++j) {
      int z = y - 100*j;
      if (z < 0) break;
      if (z/50 <= c) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
  int w, h, n;
  cin >> w >> h >> n;
  int x = 0, y = 0;
  int a[n], b[n], c[n];
  rep(i, n) cin >> a[i] >> b[i] >> c[i];
  rep(i, n){
    if(c[i] == 1){
      if(x <= a[i]) x = a[i];
    }
    else if(c[i] == 3){
      if(y <= b[i]) y = b[i];
    }
    else if(c[i] == 2){
      if(w >= a[i]) w = a[i];
    }
    else{
      if(h >= b[i]) h = b[i];
    }
  }
  int ws = (w - x >= 0 ? w - x : 0);
  int hs = (h - y >= 0 ? h - y : 0);
  cout << ws * hs << endl;
      
  
  

  return 0;
}

Measured memory_bytes: 3604
import scala.io.StdIn.readLine

object Main{
  def main(args: Array[String]) {
    val input = readLine().split(" ").map(_.toInt)
    val a: Int = input(0)
    val b: Int = input(1)

    if(a > b) {
      println("a > b")
    } else if(a < b) {
      println("a < b")
    } else {
      println("a == b")
    }
  }
}

Measured memory_bytes: 43696
/****************************************************************************
 \file      ITP1_1_B.c
 \author    SENOO, Ken
 \copyright CC0
 \date      created date: 2016-03-05T15:38+09:00
 \date      updated date: 2016-03-05T16:04+09:00
 ****************************************************************************/

#include <stdio.h>

int main(){
  int i;
  scanf("%d", &i);
  printf("%d\n", i*i*i);
  return 0;
}

Measured memory_bytes: 596
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = []
x = [0] * n
x.append(0)
v = 1
c = 1
l = 0
while x[v] == 0:
    x[v] = len(s)
    s.append(v)
    v = a[v-1]
c = len(s) - x[v]
l = x[v]


if k < l:
    print(s[k])
else:
    k -= l
    k = k % c
    print(s[l+k])


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int n = read();
  map<string, int> s;
  REP(i, n) {
    string tmp = readString();
    s[tmp] += 1;
  }
  int m = read();
  REP(i, m) {
    string tmp = readString();
    s[tmp] -= 1;
  }
  int ans = 0;
  for (auto p : s) {
    chmax(ans, p.second);
  }
  print(ans);
}


Measured memory_bytes: 2304
import java.util.*;
import java.util.Scanner;

class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        int[] H = new int[N];

        for(int i=0;i<N;i++){
            H[i]=sc.nextInt()-1;
        }

        for(int i=0;i<N-1;i++){
            if(H[i]>H[i+1]){
                H[i+1]++;
                if(H[i]>H[i+1]){
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}

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

int main(){

    int N;
    int mypow = 10;
    int total = 0;

    cin >> N;
    int N_org = N;

    for(int i = 1; i <=8; i++){
        total += N % mypow;
        N = N / mypow;
    }
    if(  N_org % total == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;
int main() {
  int n;
  cin >> n;
  int num[n];
  for (int i = 0; i < n; i++) {
    cin >> num[i];
  }

  int cnt = 0;
  for (int i = 0; i < n - 2; i++) {
    int maxNum = max({num[i], num[i + 1], num[i + 2]});
    int minNum = min({num[i], num[i + 1], num[i + 2]});
    if (num[i + 1] != maxNum && num[i + 1] != minNum) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

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

  if ((a + b) < (c + d)) {
    cout << "Right" << endl;
  }else if ((a + b) > (c + d)) {
    cout << "Left" << endl;
  }else {
    cout << "Balanced" << endl;
  }
}

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

int main(){
   int a,b,c;
   ll k;
   cin >> a >> b >> c >> k;
   ll ans = (k % 2 == 0)?a-b:b-a;
   if(ans > upperLimit)cout << "Unfair" << endl;
   else cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left, bisect_right
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)


def main():
    from builtins import int, map
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    # AとBの累積和
    cA = [0] * (N + 1)
    cB = [0] * (M + 1)
    for k in range(N):
        cA[k + 1] = cA[k] + A[k]
    for k in range(M):
        cB[k + 1] = cB[k] + B[k]

    # 読むAの冊数
    ans = -1
    for a in range(N + 1):
        rem = K - cA[a]
        if rem < 0:
            break
        bli = bisect_left(cB, rem)
        bri = bisect_right(cB, rem)
        ans_a = None
        if bli == bri:
            ans_a = a + bli - 1
        else:
            ans_a = a + bli
        # print(a, rem, bli, bri, ans_a)
        ans = max(ans, ans_a)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 114240
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b)){
		cout<<"B"<<endl;
	}
	else{
		cout<<"A"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 4e5+5;

int n;
int f[N];
int s[N];

int main() {
    cin >> n;
    vector < int > pr;
    long long fact = 1;
    for(int i = 1; i <= n; i++){
        cin >> f[i] >> s[i];
        pr.push_back(i);
        fact *= i;
    }
    double AV = 0;
    do{
       for(int i = 0; i < pr.size(); i++){
           if(i == 0)
              continue;
           long long A = f[pr[i]] - f[pr[i-1]];
           A *= A;
           long long B = s[pr[i]] - s[pr[i-1]];
           B *= B;
           AV += sqrt(1.0000000*A + 1.0000*B);
       }
    } while(next_permutation(pr.begin() , pr.end()));
    AV /= fact;
    cout << fixed << setprecision(10) << AV << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db long double

using namespace std;

int n, x;
db d, sum;

db solve(int n, db d, db x)
{
	if (n == 1)
	{
		return (2 * d + x) / 2;
	}
	return solve(n - 1, d * (n + 1) / n + x * 5 / n / 2, x * (n + 2) / n) + (2 * d + (n * 2 - 1) * x) / 2;
}

int main()
{
	cin >> n >> d >> x;
	cout << fixed << setprecision(10) << solve(n, d, x) << endl;
	return 0;
}


Measured memory_bytes: 22144
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	x, _ := strconv.Atoi(scanner.Text())
	if x >= 30 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}

Measured memory_bytes: 1772
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class MyScanner {
    BufferedReader br;

    MyScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public int intLine() throws IOException {
        return Integer.parseInt(br.readLine());
    }

    public String line() throws IOException {
        return br.readLine();
    }

    public int[] intArray() throws IOException {
        String[] in = br.readLine().split(" ");
        int n = in.length;
        int[] res = new int[n];
        for(int i = 0; i < n; i++) {
            res[i] = Integer.parseInt(in[i]);
        }
        return res;
    }
}

public class Main {
    public static void main(String[] args) throws IOException {
        MyScanner sc = new MyScanner();

        int n = sc.intLine();
        int[] a = sc.intArray();

        /*
        int min = 2019;
        boolean minIsR = true;
        int max = 0;
        boolean maxIsL = true;
        for(int i = l; i <= r; i++) {
            int remainder = i % 2019;
            if(min >= remainder) {
                min = remainder;
                minIsR &= (i == r);
            }
            if(max <= remainder) {
                max = remainder;
                maxIsL &= (i == l);
            }
        }
        if(min == 0) {
            System.out.println(0);
        }else {
            int ans = 2019;
            if(!minIsR) {
                ans = Math.min(ans, (min * (min + 1)) % 2019);
            }
            if(!maxIsL) {
                ans = Math.min(ans, (max * (max - 1)) % 2019);
            }
            System.out.println(ans);
        }
        */

        int[] ans = new int[n];
        for(int i = 0; i < n; i++) {
            if(i % 2 == 0) ans[0] += a[i];
            else ans[0] -= a[i];
        }

        for(int i = 1; i < n; i++) {
            ans[i] = -ans[i - 1] + 2 * a[i - 1];
        }

        StringBuilder sb = new StringBuilder();
        sb.append(ans[0]);
        for(int i = 1; i < n; i++) {
            sb.append(' ').append(ans[i]);
        }
        System.out.println(sb);

        sc.br.close();
    }
}

Measured memory_bytes: 44372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int a,b;
int main(){
	a=read(),b=read();
	if(a>b)puts("safe");
	else puts("unsafe");
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

long long beki(int a, long long b)
{
    if(b == 0){
        return 1;
    }
    long long ans = beki(a, b / 2);
    ans = ans * ans;
    if(b % 2 == 1){
        ans *= a;
    }
    return ans;
}

long long S(long long n)
{
    if(n < 10){
        return n;
    }
    return (n % 10) + S(n / 10);
}

int main() {
    //cout.precision(10);
    stack<long long> ans;
    double checker = 10000000000000000000000.0;
    for(long long l = 10; l >= 0; l--){
        for(long long k = 100000; k >= 10001; k--){
            long long check = beki(10, l) * k - 1;
            if((double)check / (double)S(check) <= checker){
                ans.push(check);
                checker = (double)check / (double)S(check);
            }
        }
    }
    for(long long k = 9999; k >= 1; k--){
            if((double)k / (double)S(k) <= checker){
                ans.push(k);
                checker = (double)k / (double)S(k);
            }
    }
    long long q;
    cin >> q;
    for(int i = 1; i <= q; i++){
        long long out = ans.top();
        ans.pop();
        cout << out << endl;
        if(ans.empty()){
            break;
        }
    }
    return 0;
}


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

int flag[10];

long calc(char s[11],int p,long a,int n){
  if(p==n-1)
    return a*10+s[p]-'0';
  if(flag[p])
    return a*10+s[p]-'0'+calc(s,p+1,0,n);
  else
    return calc(s,p+1,10*a+s[p]-'0',n);
}
long dfs(char s[11],int n,int m){
  long ans=0;
  if(n-m>1){
    flag[m]=0;
    ans=dfs(s,n,m+1);
    flag[m]=1;
    ans+=dfs(s,n,m+1);
  }
  else
    ans=calc(s,0,0,n);
  return ans;
}

int main(){
  char s[11];
  int n;
  scanf("%s",s);
  n=strlen(s);
  printf("%ld\n",dfs(s,n,0));
}

Measured memory_bytes: 128
N, K = map(int, input().split())
A = list(map(int, input().split()))

expect = [(e + 1) / 2 for e in A]
window = sum(expect[0:K])
max_s = window
for i in range(N - K):
    window -= expect[i]
    window += expect[i + K]
    if window > max_s:
        max_s = window
print(max_s)

Measured memory_bytes: 25060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int H,W;cin>>H>>W;
    int N;cin>>N;
    vector<int> a(N);
    REP(i,N)cin>>a[i];
    int now=0;
    vector<vector<int> > grid(H,vector<int>(W,0));
    REP(i,N){
        REP(j,a[i]){
            grid[now/W][now%W]=i+1;
            now++;
        }
    }
    for (int i=0;i<H;i+=2){
        reverse(all(grid[i]));
    }
    REP(i,H){
        REP(j,W){
            if(j)cout<<" ";
            cout<<grid[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ct = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if (500 * i) + (100 * j) + (50 * k) == X:
                ct += 1
print(ct)

Measured memory_bytes: 3060
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(998244353)
#define INF (1e15)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

bool check(int n,int a,int b,vector<int> &v){
	int now=0;
	for(auto &i:v){
		int r=max(0ll,i-b*n);
		now+=(r+a-1)/a;
	}
	if(now<=n) return true;
	return false;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n,a,b; cin>>n>>a>>b;
	a-=b;
	vector<int> v(n);
	for(auto &i:v)
		cin>>i;
	int hi=1e9+10,lo=0;
	while(hi-lo>1){
		int m=(hi+lo)/2;
		if(check(m,a,b,v)) hi=m;
		else lo=m;
	}
	cout<<hi<<"\n";
	return 0;
}

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

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

int main(void){

    int N; cin >> N;
    N %= 1000;
    N = 1000 - N;
    if(N == 1000) N = 0;
    cout << N << endl;

    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define  sci(x)   scanf("%d", &x)
#define  scl(x)   scanf("%lld", &x)
#define  scd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)


int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	//CODE TONOY
	ll n;
	cin >> n;
	string s;
	cin >> s;
	if ((ll)s.length() <= n) {cout << s << endl; return 0;}
	if ((ll)s.length() > n)
	{
		for (int i=0 ; i<n ; i++)
		cout << s[i];
	}
	cout << "...";
	return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <iomanip>
#include <cmath>
#include <complex>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

typedef double D;
typedef complex<D> P;
typedef pair<D,int> pdi;

D pi;
D smax, smin, tmax, tmin;
vector<P> ps;

D dot(const P &a, const P &b){
	return real(a) * real(b) + imag(a) * imag(b);
}

P check(D t){
	while(t < 0.0){ t += pi; }
	while(t >= pi){ t -= pi; }
	t += 0.0;
	
	int n = ps.size();
	P a = polar(D(1.0), 0.5 * pi - t);
	vector<pdi> v(2 * n);
	for(int i = 0; i < n; ++i){
		D z = dot(ps[i], a);
		v[2 * i] = pdi(z - 1.0, i);
		v[2 * i + 1] = pdi(z + 1.0, ~i);
	}
	sort(v.begin(), v.end());
	int cnt = 0;
	D sum = 0.0;
	P ret;
	for(int i = 0; i < 2 * n; ++i){
		if(cnt){ sum += v[i].first - v[i - 1].first; }
		if(v[i].second >= 0){
			if(!cnt++){ ret -= ps[v[i].second]; }
		}
		else{
			if(!--cnt){ ret += ps[~v[i].second]; }
		}
	}
	
	if(sum > smax){
		smax = sum;
		tmax = t;
	}
	if(sum < smin){
		smin = sum;
		tmin = t;
	}

	return ret;
}

int main(){
	pi = acos(D(-1.0));
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int n;
	while(cin >> n, n){
		smax = -1e300;
		smin = 1e300;
	
		ps.resize(n);
		for(int i = 0; i < n; ++i){
			int x, y;
			cin >> x >> y;
			ps[i] = P(x, y);
		}

		check(0);

		vector<D> cand;
		for(int i = 0; i < n; ++i)
		for(int j = 0; j < i; ++j){
			D a = -arg(ps[j] - ps[i]);
			D b = asin(2.0 / abs(ps[j] - ps[i]));
			cand.push_back(a);
			cand.push_back(a - b);
			cand.push_back(a + b);
		}
		for(size_t i = 0; i < cand.size(); ++i){
			while(cand[i] < 0.0){ cand[i] += pi; }
			while(cand[i] > pi){ cand[i] -= pi; }
			check(cand[i]);
		}
		sort(cand.begin(), cand.end());
		for(size_t i = 1; i < cand.size(); ++i){
			if(cand[i - 1] != cand[i]){
				P ret = check(0.5 * (cand[i - 1] + cand[i]));
				check(0.5 * pi - arg(ret));
			}
		}
		cout << tmin << '\n' << tmax << '\n';
	}
}

Measured memory_bytes: 1552
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
c=0
A.insert(0,0)
B.insert(0,0)
import numpy as np
A=np.array(A).cumsum()
B=np.array(B).cumsum()

for i in range(N+1):
  d=K-A[i]
  for j in reversed(range(M+1)):
    if d-B[j]>=0:
      if c<i+j:
        c=i+j
      M=j
      break
print(c)

Measured memory_bytes: 45860
let find x a n =
  let rec doit i =
    if i = n then exit 1
    else if a.(i) = x then i
    else doit (i + 1)
  in doit 0

let () =
  let open Queue in
  let n = read_int () in
  let preorder = create () in
  let rec read i =
    if i < n then (add (Scanf.scanf "%d " (fun i -> i)) preorder; read (i + 1))
  in read 0;
  let inorder = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let postorder = create () in
  let rec doit l r =
    if l < r then begin
      let root = take preorder in
      let m = find root inorder n in
      doit l m;
      doit (m + 1) r;
      add root postorder
    end in
  doit 0 n;
  print_int (take postorder);
  iter (fun e -> Printf.printf " %d" e) postorder;
  print_newline ()

Measured memory_bytes: 2424