akhauriyash/Code-Regression huggingface dataset:
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,x,y,dp[100010][2];
vector <LL> g[100010];

void dfs(int pos,int no)
{
	rep(i,g[pos].size()) if(g[pos][i]!=no) dfs(g[pos][i],pos);
	dp[pos][0]=dp[pos][1]=1;
	rep(i,g[pos].size())
	{
		if(g[pos][i]==no) continue;
		dp[pos][0]=dp[pos][0]*(dp[g[pos][i]][0]+dp[g[pos][i]][1])%MOD;
		dp[pos][1]=dp[pos][1]*dp[g[pos][i]][0]%MOD;
	}
}

int main()
{
	cin>>n;
	rep(i,n-1)
	{
		scanf("%lld%lld",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1,0);
	cout<<(dp[1][0]+dp[1][1])%MOD<<endl;
	rt0;
}

Measured memory_bytes: 14208
#include<cstdio>
#include<algorithm>
#include<cmath>
typedef long long ll;
const int M = 17;
const ll inf = 0x3f3f3f3f3f3f3f;
int m;
int x[M],y[M],p[M];
ll ans[M];
int q[M],dis[M];
int popc[1 << M];
template<typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
int main(){
    read(m);
    for(int i = 1;i < (1 << m); i++) popc[i] = popc[i >> 1] + (i & 1);
    for(int i = 1;i <= m; i++) read(x[i]), read(y[i]), read(p[i]), ans[i] = inf;
    ans[0] = inf;
    for(int i = 0,cnt;i < (1 << m); i++){
        cnt = 0;
        for(int j = 0;j < m; j++) if((i >> j) & 1) q[++cnt] = j + 1;
        for(int j = 0;j < (1 << cnt); j++){
            for(int k = 1;k <= m; k++) dis[k] = std::min(std::abs(x[k]),std::abs(y[k]));
            for(int k = 0;k < cnt; k++)
                if((j >> k) & 1)
                    for(int l = 1;l <= m; l++) dis[l] = std::min(dis[l],std::abs(x[l] - x[q[k + 1]]));
                else
                    for(int l = 1;l <= m; l++) dis[l] = std::min(dis[l],std::abs(y[l] - y[q[k + 1]]));
            ll sum = 0;
            for(int k = 1;k <= m; k++) sum += 1ll * dis[k] * p[k];
            ans[cnt] = std::min(ans[cnt],sum);
        }
    }
    for(int i = 0;i <= m; i++) printf("%lld\n",ans[i]);
    return 0;
}
/*
3
1 2 300
3 3 600
1 4 800

2900
900
0
0
*/

Measured memory_bytes: 3224
#include <stdio.h>

int main(void)
{
	int a,b,c,num,i;
	scanf("%d",&num);
	
	for(i=0;i<num;i++){
		scanf("%d %d %d",&a,&b,&c);
		
		if(a*a+b*b==c*c||b*b+c*c==a*a||a*a+c*c==b*b)
			printf("YES\n");
		else
			printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int gi() {
	char ch='!'; int res=0, f=0;
	while(ch<'0' || ch>'9') { ch=getchar(); if(ch == '-') f=1; }
	while(ch>='0' && ch<='9') res=res*10+ch-'0', ch=getchar();
	return f?-res:res;
}
const int N=2e5+100;
int n,p[N],val[N],cntx,cnty,Hx,Hy,tot;
char str[N];
struct segment_tree {
#define ls (k<<1)
#define rs (k<<1|1)
	int mx[N<<2];
	segment_tree() { memset(mx,0xcf,sizeof(mx)); }
	void mdf(int k,int tar,int val,int l=1,int r=n) {
		if(l == r) { mx[k]=val; return; }
		int mid=(l+r)>>1;
		tar <= mid ? mdf(ls,tar,val,l,mid):mdf(rs,tar,val,mid+1,r);
		mx[k]=max(mx[ls],mx[rs]);
	}
	int qry(int k,int ql,int qr,int l=1,int r=n) {
		if(ql <= l && r <= qr) return mx[k];
		int mid=(l+r)>>1,res=mx[0];
		if(ql <= mid) res=max(res,qry(ls,ql,qr,l,mid));
		if(qr > mid) res=max(res,qry(rs,ql,qr,mid+1,r));
		return res;
	}
} s[2];
bool check(int val,int t) {
	if(val<0) return 0;
	if(t == n) return val == 0;
	return s[val&1].qry(1,t+1,n)>=val;
}
int main() {
	n=gi();
	for(int i=1,mx=0;i<=n;++i) {
		p[i]=gi();
		if(p[i]>mx) mx=p[i], val[i]=2, ++tot;
		else val[i]=1;
	}
	for(int i=n;i>=1;--i) {
		int mx0=max(s[0].qry(1,p[i],n),0), mx1=s[1].qry(1,p[i],n);
		if(val[i] == 1)
			s[0].mdf(1,p[i],mx1+1), s[1].mdf(1,p[i],mx0+1);
		else
			s[0].mdf(1,p[i],mx0+2), s[1].mdf(1,p[i],mx1+2);
	}
	for(int i=1,mx=0;i<=n;++i) {
		s[0].mdf(1,p[i],s[0].mx[0]), s[1].mdf(1,p[i],s[1].mx[0]);
		if(p[i]>mx) mx=p[i], --tot;
		//try:0
		if(check(cntx-cnty+tot+(p[i]>Hx),Hy) || check(cnty-cntx+tot-(p[i]>Hx),Hx))
			str[i]='0', cntx += (p[i]>Hx), Hx=max(Hx,p[i]);
		//try:1
		else str[i]='1', cnty += (p[i]>Hy), Hy=max(Hy,p[i]);
	}
	if(cntx != cnty) puts("-1");
	else puts(str+1);
	return 0;
}

Measured memory_bytes: 11652
using namespace std;
#include <stdio.h>
int main()
{
	char str[101], p[101];
	int i, j, a, b, Bool = 0;
	for (i = 0;; i++){ str[i] = getchar(); if (str[i] == '\n')break; }
	a = i;
	for (j = 0;; j++){ p[j] = getchar(); if (p[j] == '\n')break; }
	b = j;
	for (i = 0; i < a; i++){
		for (j = 0; j < b; j++){
			if (str[(i + j) % a] != p[j])break;
			else if (p[j + 1] == '\n')Bool = 1;
		}
	}
	if (Bool) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 916
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <utility>
using P = pair<int, int>;

#include <queue>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s += "#";
    // count, len
    vector<P> len;
    {
        len.emplace_back(0, 1);
        int cnt = 1;
        REP(i, 0, n) {
            if (s[i] != s[i + 1]) {
                len.emplace_back(cnt, s[i] - '0');
                cnt = 0;
            }
            cnt++;
        }
    }
    len.emplace_back(0, 1);
    ll ans = 0;
    ll sum = 0;
    queue<int> q;
    REP(i, 0, len.size()) {
        sum += len[i].first;
        if (len[i].second == 0) {
            q.emplace(i);
            if (q.size() > k) {
                int j = q.front();
                sum -= (len[j].first + len[j - 1].first);
                q.pop();
            }
        } else {
            chmax(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1528
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
#define MAXA 100000
#define MAX 2000000000
#define s(i) scanf("%d", &(i))
#define p(i) printf("%d", (i))
#define ps() printf(" ") 
#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))
using namespace std;
int main(){
	int i, n;
	cin >> n;
	if(n==1){
		cout << 0 << endl;
	}else{
		long long sum = 0, t = 1;
		rer(i,1,n){
			sum+=t;
			t++;
		}
		cout << sum << endl;
	}
	return 0;
} 


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

int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    bool flag = false;
    int count = 0;
    int ret[N];
    for (int i = N-1; i >= 0; i--) {
        char c = S[i];
        if (c == 'C') {
            flag = true;
        } else if (c == 'A') {
            if (flag) {
                count++;
            }
            flag = false;
        } else {
            flag = false;
        }
        ret[i] = count;
    }

    for (int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        cout << ret[l-1]-ret[r-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define mod (1e9 + 7)
#define pb push_back
#define ll long long int
using namespace std;
typedef pair<int,int> pii;

int main(){

  int N;
  cin>>N;

  vector<int> p1,p2;
  int t;
  for(int i=0;i<N;i++){
    cin>>t;
    p1.pb(t);
    p2.pb(t);
  }

  sort(p2.begin(),p2.end());

  t=0;
  for(int i=0;i<N;i++){
    if(p1[i]!=p2[i])t++;
    if(t>2) break;
  }

  if(t<=2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	char s[100000];
	scanf("%s", s);
	int n=strlen(s);
	if(s[0]==s[n-1]){
		if(n%2==0){
			printf("%s\n", "First");
		}else{
			printf("%s\n", "Second");
		}
	}else{
		if(n%2!=0){
			printf("%s\n", "First");
		}else{
			printf("%s\n", "Second");
		}
	}
	return 0;
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	ll T, A; cin >> T >> A;
	REP(i, N-1)
	{
		ll t, a; cin >> t >> a;
		ll T1, A1, T2, A2;
		T1 = ((T/t) + (T % t != 0)) * t;
		A1 = (T1/t) * a;
		A2 = ((A/a) + (A % a != 0)) * a;
		T2 = (A2/a) * t;

		if (T <= T1 && A <= A1)
		{
			T = T1;
			A = A1;
		}
		else
		{
			T = T2;
			A = A2;
		}
	}

	std::cout << A + T << std::endl;
	
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
int n,c=0,m=-1;
cin>>n;
int a[n+1];

for(int i=0; i<n;i++){
    cin>>a[i];
}
a[n]=0;
for(int i=0; i<n;i++){
    if(a[i]>=a[i+1]&&a[i+1]!=0){
        c++;
    }
    else{
        if(c>m){
            m=c;
        }
        c=0;
    }
}
cout<<m;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1,1,1,-1,-1},dy[]={1,0,-1,0,1,-1,1,-1};

int lim,n,m,x;

PI sec[200];
PI sta[200];
ll dp[2001][201];

ll stdpmax[2001][201];

void solve(){
  string name;
  rep(i,n)cin>>name>>sec[i].F>>sec[i].S;
  rep(i,m)cin>>name>>sta[i].F>>sta[i].S;
  memset(dp,0,sizeof(dp));
  for(int i=0;i<m;++i){
    for(int ch=i;ch>=0;--ch){
      for(int man=lim;man>=sta[i].F;--man)
        if(dp[man-sta[i].F][ch] || ch==0)
          dp[man][ch+1]=max(dp[man-sta[i].F][ch]+sta[i].S,dp[man][ch+1]);
    }
    /*
    for(int j=0;j<=m;++j){
      for(int k=0;k<=lim;++k)printf("%2d ",dp[k][j]);
      cout<<endl;
    }
    cout<<endl;
    */
  }
  memset(stdpmax,0,sizeof(stdpmax));
  for(int i=0;i<=lim;++i)
    stdpmax[i][0]=*max_element(dp[i]+x,dp[i]+m+1);

  ll ans=0;



  for(int i=0;i<n;++i){
    for(int ch=min(1,i);ch>=0;--ch){
      for(int man=lim;man>=sec[i].F;--man)
        if(stdpmax[man-sec[i].F][ch])
          stdpmax[man][ch+1]=max(stdpmax[man-sec[i].F][ch]+sec[i].S,stdpmax[man][ch+1]);
    }
    /*
    for(int j=0;j<=2;++j){
      for(int k=0;k<=lim;++k)printf("%2d ",stdpmax[k][j]);
      cout<<endl;
    }
    cout<<endl;
    */

  }

  rep(i,lim+1)ans=max(ans,
                    max(stdpmax[i][1],stdpmax[i][2]));




  cout<<ans<<endl;
}

main(){
  while(cin>>lim>>n>>m>>x,lim)solve();
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

string s;

int main(){
    cin >> s;
    int c = 1;
    bool lf = false;
    bool wf = false;
    for(int i=1;i<s.size();i++){
        if(lf){
            c++;
            lf = false;
            continue;
        }
        if(wf){
            c++;
            lf = true;
            wf = false;
            continue;
        }
        if(s[i] != s[i-1]){
            c++;
        }else{
            wf = true;
        }
    }


    reverse(s.begin(),s.end());
    int d = 1;
    lf = false;
    wf = false;
    for(int i=1;i<s.size();i++){
        if(lf){
            d++;
            lf = false;
            continue;
        }
        if(wf){
            d++;
            lf = true;
            wf = false;
            continue;
        }
        if(s[i] != s[i-1]){
            d++;
        }else{
            wf = true;
        }
    }

    cout << max(c,d) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main()
{

    int len,k,i;
    scanf("%d",&k);
    char str[109]={'\0'};
    scanf("%s",&str);
    len=strlen(str);
    if(len>k){
        for(i=0;i<k;i++)
            printf("%c",str[i]);
        printf("...");
    }
    else
        printf("%s",str);

    return 0;
}


Measured memory_bytes: 1736
n, m = map(int, input().split())
a = []
for i in range(m):
    a.append(int(input()))
a = set(a)
mod = 10 ** 9+ 7

com = [0, 1]
for i in range(n):
    if (i + 1) in a:
        com.append(0)
    else:
        com.append((com[-1] + com[-2]) % mod)
print(com[-1])

Measured memory_bytes: 13216
#include<iostream>
using namespace std;
int main(){
  char c;
  cin>>c;
  if(c=='a'){
    cout<<"b"<<endl;
  }
  else if(c=='b'){
    cout<<"c"<<endl;
  }
  else if(c=='c'){
    cout<<"d"<<endl;
  }
  else if(c=='d'){
    cout<<"e"<<endl;
  }
  else if(c=='e'){
    cout<<"f"<<endl;
  }
  else if(c=='f'){
    cout<<"g"<<endl;
  }
  else if(c=='g'){
    cout<<"h"<<endl;
  }
  else if(c=='h'){
    cout<<"i"<<endl;
  }
  else if(c=='i'){
    cout<<"j"<<endl;
  }
  else if(c=='j'){
    cout<<"k"<<endl;
  }
  else if(c=='k'){
    cout<<"l"<<endl;
  }
  else if(c=='l'){
    cout<<"m"<<endl;
  }
  else if(c=='m'){
    cout<<"n"<<endl;
  }
  else if(c=='n'){
    cout<<"o"<<endl;
  }
  else if(c=='o'){
    cout<<"p"<<endl;
  }
  else if(c=='p'){
    cout<<"q"<<endl;
  }
  else if(c=='q'){
    cout<<"r"<<endl;
  }
  else if(c=='r'){
    cout<<"s"<<endl;
  }
  else if(c=='s'){
    cout<<"t"<<endl;
  }
  else if(c=='t'){
    cout<<"u"<<endl;
  }
  else if(c=='u'){
    cout<<"v"<<endl;
  }
  else if(c=='v'){
    cout<<"w"<<endl;
  }
  else if(c=='w'){
    cout<<"x"<<endl;
  }
  else if(c=='x'){
    cout<<"y"<<endl;
  }
  else cout<<"z"<<endl;
}

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

int main(){
    int k10, k5, k1, n, y;
    cin >> n >> y;
    for(k10 = 0; k10 <= n; k10++){
        for(k5 = 0; k5 + k10 <= n; k5++){
            k1 = n - k5 - k10;
            if(k1 * 1000 + k5 * 5000 + k10 * 10000 == y){
                cout << k10 << " " << k5 << " " << k1 << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector <int> v[200005];
int arr[200005];
int ans[200005];
int main(){
	int n,q;
	cin>>n>>q;
	int a,b;
	int t=n;
	while(t>1){
		cin>>a>>b;
		v[b].push_back(a);
		t--;
	}
	for(int i=1;i<=q;i++){
		int a,b;
		cin>>a>>b;
		arr[a]+=b;
	}
	ans[1]=arr[1];
	printf("%d",ans[1]);
	for(int i=2;i<=n;i++){
		if(v[i].size()==0)
			continue;
		int sum=0;
		for(int j=0;j<v[i].size();j++){
			int k=v[i][j];
			sum+=ans[k];
		}
		ans[i]=sum+arr[i];
		printf(" %d",ans[i]);
	}
	
	return 0;
}


Measured memory_bytes: 14720
#include<cstdio>
int main(){
	long long int n;
	scanf("%lld",&n);
	long long int a[n+1]={};
	long long int s=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		s+=a[i];
	}
	a[n]=a[0];
	if(s%(n*(n+1)/2)!=0){
		printf("NO\n");
	}else{
		s=s/(n*(n+1)/2);
		for(int i=0;i<n;i++){
			if(a[i+1]-a[i]-s<=0&&(a[i+1]-a[i]-s)%n==0){
				if(i==n-1)printf("YES\n");
			}else{
				printf("NO\n");
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 896
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;


int main(void){
    int h,w;
    cin >> h >> w;

    char s[h+5][w+5];

    for(int i=0;i<=h+1;i++){
        for(int j=0;j<=w+1;j++){
            s[i][j] = '.';
        }
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> s[i][j];
        }
    }

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j] == '#'){
                if(s[i-1][j] == '#' | s[i+1][j] == '#' | s[i][j-1]=='#' | s[i][j+1] == '#'){
                    continue;
                }
                else{
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
    
}

Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=2e6+5;
int fac[N],ifac[N],n,res,x,y;
void init(int n=2e6){
	fac[0]=ifac[0]=1;fp(i,1,n)fac[i]=mul(fac[i-1],i);
	ifac[n]=ksm(fac[n],P-2);fd(i,n-1,1)ifac[i]=mul(ifac[i+1],i+1);
}
inline int C(R int n,R int m){return 1ll*fac[n]*ifac[m]%P*ifac[n-m]%P;}
int main(){
	init();
	scanf("%d%d",&x,&y);
	if((x+y)%3)return puts("0"),0;
	R int t=(x+y)/3;
	x-=t,y-=t;
	if(x<0||y<0)return puts("0"),0;
	printf("%d\n",C(x+y,x));
	return 0;
}

Measured memory_bytes: 15872
import sys

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    a,b=list(map(int, readline().strip().split()))
    if a==b:
        print("Draw")
        return
    if a==1:
        print("Alice")
        return
    if b==1:
        print("Bob")
        return
    if a>b:
        print("Alice")
        return
    else:
        print("Bob")
    return


resolve()


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<double,double>P;

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

}

Measured memory_bytes: 1664
N, K = map(int, input().split())
X = list(map(int, input().split()))

answer = []
for i in range(N):
  if i + K > N:
    break
  Ys, Yt = X[i], X[i+K-1]
  if Ys > 0:
    answer.append(Yt)
  elif Yt < 0:
    answer.append(-Ys)
  else:
    answer.append(min(Ys*(-2)+Yt, Yt*2-Ys))

print(min(answer))

Measured memory_bytes: 62704
#include<stdio.h>
int main(){
	long long int a, b, c, d;
	long long int N;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	scanf("%lld", &N);
	if(a*2<b){
		b=2*a;
	}
	if(2*b<c){
		c=2*b; 
	}
	if(2*c<d){
		d=2*c;
	}
	printf("%lld", d*(N/2)+c*(N%2));
return 0;
}

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

const ll mod=1e9+7;
ll dp[103][100004];
ll n,W;
ll a[1000000],w[1000000];
ll solve(ll i,ll w1){
    
    if(w1<0) return INT_MIN;
    if(w1==0) return 0;
    if(i==n) return 0;
    if(dp[i][w1]!=-1) return dp[i][w1];

    ll ans=0;

    // If we choose the ith item 
    ans=solve(i+1,w1-w[i])+a[i];
    ans=max(ans,solve(i+1,w1));

    return dp[i][w1]=ans;

}

int main() {
    cin>>n;
    memset(dp,-1,sizeof(dp));
    cin>>W;    

    for(ll i=0;i<n;i++){
        cin>>w[i]>>a[i];
    }
    cout<<solve(0,W)<<endl;

}


Measured memory_bytes: 84096
import java.util.*;
public class Main{
  public static void main(String arg[])
  {
   Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int x=sc.nextInt();
    int t=sc.nextInt();
    
    int a=0;
    while(n>0)
    {
       a+=t;
       n-=x;
    }
    
    System.out.println(a);
    
  }
}

Measured memory_bytes: 35612
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readInt();
      
      auto a = new int[][](N, N);
      foreach (u; 0 .. N) foreach (v; 0 .. N) {
        if (u != v) {
          a[u][v] = bsf(u ^ v);
        }
      }
      
      foreach (u; 0 .. N - 1) {
        int ou;
        foreach (v; u + 1 .. N) {
          if (ou++) {
            write(" ");
          }
          write(a[u][v] + 1);
        }
        writeln();
      }
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 1532
# C 
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n=ni()
a=nl()
b=nl()
c=[]
d=[]
for i in range(n):
    if a[i]-b[i]<0:
        c.append(a[i]-b[i])
    elif a[i]-b[i]>0:
        d.append(a[i]-b[i])

if len(c)==0 and len(d)>=0:
    print(0)
    exit()

if len(c)>0 and len(d)==0:
    print(-1)
    exit()

d.sort(reverse=True)
sum_c=sum(c)
i=0
while sum_c<0 and i<len(d):
    sum_c+=d[i]
    i+=1

if sum_c<0:
    print(-1)
    exit()

print(i+len(c))

Measured memory_bytes: 19188
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << v[k - 1];
    return 0;
}

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

ll mod = 1000000007;
ll modpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n){
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	vector<ll> nCk(n);
	ll l = 1;
	ll ka = k;
	ll wa = 1;
	rep(i, n){
		ll ni = i+1;
		if(ni < k){
			nCk.at(i) = 0;
		}else{
			nCk.at(i) = l;
			l *= ka;
			if(l >= mod) l %= mod;
			l *= modpow(wa, mod-2);
			if(l >= mod) l %= mod;
			ka++;
			wa++;
		}
	}
/*	rep(i, n){
		cout << nCk.at(i) << endl;
	}
	cout << endl;
	cout << nCk.at(n-1) << endl;
*/	ll misum = 0;
	ll masum = 0;
	ll ans = 0;
	rep(i, n){
		masum += nCk.at(i) * a.at(i);
		if(masum >= mod) masum %= mod;
		if(masum <= -1*mod) masum %= mod;
		if(masum < 0) masum += mod;
	}
	reverse(a.begin(), a.end());
	rep(i, n){
		misum += nCk.at(i) * a.at(i);
		if(misum >= mod) misum %= mod;
		if(misum <= -1*mod) misum %= mod;
		if(misum < 0) misum += mod;
	}
	ans = masum - misum;
	if(ans < 0) ans += mod;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
//using namespace __gnu_pbds;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair

const int mod = 1e9 + 7;
const ll inf = ll(1e18);
const int sz = 1e5+5;
const ll cfmod = 998244353;

int main() {
    //clock_t tm = clock();
    fastio;
    ll l,n,r,e,m,q,k,t=0,y,w;string s;
    cin>>n;
    vi a(n,0),b(n,0);
    f(i,0,n-1)cin>>b[i];
    ll ans=b[0];
    f(i,0,n-2)ans+=min(b[i],b[i+1]);
    if(n>=2)ans+=b[n-2];
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n,s[14],h[14],c[14],d[14];
    int x;
    int i;
    char m;
    scanf("%d",&n);
    getchar();
    for(i=1;i<=13;i++)s[i] = h[i] = c[i] = d[i] = 1;
    for(i=0;i<n;i++){
        scanf("%c",&m);
        scanf("%d",&x);
        getchar();
        switch(m){
            case 'S':s[x] = 0;
                break;
            case 'H':h[x] = 0;
                break;
            case 'C':c[x] = 0;
                break;
            case 'D':d[x] = 0;
                break;
        }
    }
    for(i=1;i<=13;i++)if(s[i])printf("S %d\n",i);
    for(i=1;i<=13;i++)if(h[i])printf("H %d\n",i);
    for(i=1;i<=13;i++)if(c[i])printf("C %d\n",i);
    for(i=1;i<=13;i++)if(d[i])printf("D %d\n",i);    
}

Measured memory_bytes: 1028
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    while (sc.hasNextInt()) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      int val  = a+b;
      int cnt = 0;
      while(val > 0) {
        cnt++;
        val /= 10;
      }
      System.out.println(cnt);
    }
  }
}

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

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

    vector<int> c(N-1);
    vector<int> s(N-1);
    vector<int> f(N-1);
    vector<int> curtime(N-1);
    for(int i=0;i<(N-1);i++) {
        cin >> c[i] >> s[i] >> f[i];
        curtime[i] = s[i];
    }

    for(int i=0;i<c.size();i++) {
        for(int j=i;j<c.size();j++) {
            if(s[j] >= curtime[i]) {
                curtime[i] = s[j];
            } else {
                // これで通ったらおかしい。その後は、って書いてあるし
                if(curtime[i]%f[j])curtime[i] += f[j]-(curtime[i]%f[j]);
//                tmp = curtime[i] - s[j];
//                if(tmp%f[j]) {
//                    curtime[j] += f[j]-(tmp%f[j]);
//                } else {
//                    // 来ている
//                }
            }

            curtime[i] += c[j];
        }
    }

    for(int i=0;i<(N-1);i++) {
        cout << curtime[i] << endl;
    }
    cout << "0\n";
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
import heapq
INF = 10**9

class Dijkstra:
    def __init__(self, adj):
        self.adj = adj
        self.dist = [INF] * len(adj)
        self.q = []
    
    def reset(self):
        self.dist = [INF] * len(self.adj)
        self.q = []

    def calc(self, start):
        self.dist[start] = 0
        heapq.heappush(self.q, (0, start))
        while len(self.q) != 0:
            prov_cost, src = heapq.heappop(self.q)
            if self.dist[src] < prov_cost:
                continue
            for dest in self.adj[src]:
                if self.dist[dest] > self.dist[src] + 1:
                    self.dist[dest] = self.dist[src] + 1
                    heapq.heappush(self.q, (self.dist[dest], dest))
        return self.dist

n, x, y = map(int, input().split())
x -= 1; y -= 1
edge = [[] for _ in range(n)]
for i in range(n-1):
    edge[i].append(i+1)
    edge[i+1].append(i)
edge[x].append(y)
edge[y].append(x)
DIJK = Dijkstra(edge)

dist_cnt = [0] * n
for i in range(n):
    dist = DIJK.calc(i)
    for j in range(i+1, n):
        dist_cnt[dist[j]] += 1
    DIJK.reset()

for item in dist_cnt[1:]:
    print(item)

Measured memory_bytes: 66396
import sys
import bisect

N = int(input())
a = list(map(int,input().split()))
numdic = {}
for i, num in enumerate(a):
    if num not in numdic:
        numdic[num] = [i+1]
    else:
        numdic[num].append(i+1)

if 1 not in numdic:
    print(-1)
    sys.exit()

nowplace = 0
count = 0
for i in range(1,N+1):
    if i not in numdic:
        break
    else:
        place = bisect.bisect_right(numdic[i], nowplace)
        if place >= len(numdic[i]):
            break
        else:
            nowplace = numdic[i][place]
            count += 1

print(N-count)

Measured memory_bytes: 106060
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


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


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

int main(){
  int n;
  cin >> n;
  long long ans = 0;
  string s[n];
  map<string, int> m;
  REP(i,n){
    cin >> s[i];
  	sort(s[i].begin(), s[i].end());
    m[s[i]] += 1;
  }
  
  for(auto P : m){
    ans += (long long)P.second * (P.second-1) / 2;
  }
  
  cout << ans;
  return 0;
}

Measured memory_bytes: 18176
import Data.List

main = do
  getLine
  dat <- getContents >>= return . sort . (map read) . lines :: IO [Int]
  print (length (filter (\(a,b) -> odd b) (func dat)))

  where
    func [] = []
    func xs@(x:rest) = (x, len) : (func (drop len xs))
      where
        tw = takeWhile (==x) xs
        len = length tw


Measured memory_bytes: 17660
#include <stdio.h>

int main(void)
{
	int n, i;
	int a[20];
	int v[20];
	int min_a, max_v;
	
	scanf("%d\n", &n);
	for(i = 0; i < n; i++) {
		scanf("%d %d", &a[i], &v[i]);
		if(i == 0) {
			min_a = a[0];
			max_v = v[0];
		}
		else {
			if(v[i] > max_v) {
				min_a = a[i];
				max_v = v[i];
			}
			else if(v[i] == max_v)
				if(a[i] < min_a) min_a = a[i];
		}
	}
	printf("%d %d\n", min_a, max_v);
	
	return 0;
}


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

int n, m=50000, mi;
double cx, cy, d, mx, p=1.0, x[55], y[55];
int main() {
	int i;
	cin >> n;
	for(i=0; i<n; i++) {
		cin >> x[i] >> y[i];
		cx += x[i]; cy += y[i];
	}
	cx /= n; cy /= n;
	while(m--) {
		mx = 0;
		for(i=0; i<n; i++) {
			d = (cx-x[i]) * (cx-x[i]) + (cy-y[i]) * (cy-y[i]);
			if(d > mx) mx = d, mi = i;
		}
		cx += (x[mi] - cx) * p;
		cy += (y[mi] - cy) * p;
		p *= 0.999;
	}
	printf("%.9f", sqrt(mx));
	return 0;
}

Measured memory_bytes: 256
let main = (input) => {
    let usrInput = input.split(/\n/)
    let uniqueArr = {}
    usrInput.map(function (item) {
        if (item in uniqueArr) {
            uniqueArr[item].count++
        } else {
            uniqueArr[item] = {
                key: item,
                count: 1
            }
        }
    })

    let ac = 0
    let wa = 0
    let tle = 0
    let re = 0
    for (let key in uniqueArr) {
        //console.log(uniqueArr[key].key + " x " + uniqueArr[key].count)
        switch (uniqueArr[key].key) {
            case "AC":
                ac = uniqueArr[key].count
                break;
            case "WA":
                wa = uniqueArr[key].count
                break;
            case "TLE":
                tle = uniqueArr[key].count
                break;
            case "RE":
                re = uniqueArr[key].count
                break;
            default:
                break;
        }
    }

    console.log("AC x " + ac)
    console.log("WA x " + wa)
    console.log("TLE x " + tle)
    console.log("RE x " + re)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 37948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pp pair<int,int> 
#define v(T) vector<T>
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
const int INF = 1001001001;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10);
//int gcd(int x, int y){
  //if(y==0) return x;
  //return gcd(y, x%y);
//}
//sort小さい順(昇順)
 
int main(){
  int n,k;
  cin >> n >> k;
  v(int) h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(), h.end());
  int x=INF, ans=0;
  rep(i,n-k+1){
    ans=h[i+k-1]-h[i];
    x=min(ans,x);
  }
  cout << x << endl;
}    

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

string S;

int main(){
  cin >> S;
  REP(i, 3) {
    if(S[i] == S[i + 1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return;
        }

    }
}

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


Measured memory_bytes: 3656
#include <iostream>
#include <cmath>

int main()
{
  int N, T, A;
  std::cin >> N >> T >> A;
  int H[N];
  double ans = std::pow(10, 5);
  int pos;
  for ( int i = 0; i < N; i++ ) {
    std::cin >> H[i];
    double tmp = std::abs(A - T + H[i] * 0.006);
    if ( ans > tmp ) {
      ans = tmp;
      pos = i;
    }
  }

  std::cout << pos + 1 << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
// #include <atcoder/all>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
#define REP2(i, m, n) for (ll(i) = (ll)(n)-1; i >= (ll)(m); --i)
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define rall(hoge) (hoge).rbegin(), (hoge).rend()
#define en '\n'
using Edge = pair<ll, ll>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> inline void print(T x) { cout << x << '\n'; }
template <class T> bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
long long lcm(long long x, long long y) { return x / gcd(x,y)*y ;}
// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// cout << res << endl;
// cout << res << '\n';
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)
vector<int> Zalgo(const string &S) {
    int N = (int)S.size();
    vector<int> res(N);
    res[0] = N;
    int i = 1, j = 0;
    while (i < N) {
        while (i+j < N && S[j] == S[i+j]) ++j;
        res[i] = j;
        if (j == 0) {++i; continue;}
        int k = 1;
        while (i+k < N && k+res[k] < j) res[i+k] = res[k], ++k;
        i += k, j -= k;
    }
    return res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    string S;
    cin >> N >> S;

    int res = 0;
    for (int i = 0; i < N; ++i) {
        string T = S.substr(i);
        auto lcp = Zalgo(T);

        for (int j = 0; j < T.size(); ++j) {
            int l = min(lcp[j], j);
            res = max(res, l);
        }
    }

    print(res);

    return 0;
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int, int>;
using ppa = pair<pa, int>;
#define SORT(v, n) sort(v, v + n);
#define ALL(v) v.begin(), v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v), greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)), v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (b - 1); i >= a; i--)
#define rrep(i, n) RFOR(i, 0, n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a, b) a = min(a, b)
#define maxs(a, b) a = max(a, b)

// 4近傍
int dy[]={0, 1, 0, -1};
int dx[]={1, 0, -1, 0};

// 8近傍
// int dy[]={0,0,1,-1,1,1,-1,-1};
// int dx[]={1,-1,0,0,1,-1,1,-1};

// const ll MOD = 1000000007;

ll pow_mod(ll a, ll b, ll mod) {
    ll tmp = 1;
    a %= mod;
    if (b > 0) {
        tmp = pow_mod(a, b / 2, mod);
        if (b % 2)
            tmp = (((tmp * tmp) % mod) * a) % mod;
        else
            tmp = (tmp * tmp) % mod;
    }
    return tmp;
}

void solve() {
    string s; cin >> s;
    int k; cin >> k;
    int n = s.size();
    rep(i,n){
        if(s[i] == 'a') continue;
        if(k >= 123 - s[i]){
            k -= 123-s[i];
            s[i] = 'a';
        }
    }
    if(k > 0){
        k %= 26;
        s[n-1] = (char) ((s[n - 1] - 97 + k) % 26 + 97);
    }
    cout << s << endl;

}

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

    solve();

    return 0;
}


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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int a,b,k;
    cin >> a >> b >> k;

    FORRN(i,100,1){
        if(a%i==0 && b%i==0){
            k--;
            if(k==0){
                cout << i << endl;
                return 0;
            }
        }
    }

    return 0;
}


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

using namespace std;

int N, K;
int ans;
vector<int> h;

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

	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		h.push_back(tmp);
	}

	sort(h.begin(), h.end());

	ans = h[K - 1] - h[0];
	for (int i = 1; i <= N - K; i++) {
		ans = min(ans, h[K - 1 + i] - h[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, K ; cin >> N >> K;
    ll ans = 0;
    
    if(K==0){
        cout << N*N << endl ;
        return 0;
    }
    
    for(ll b = K+1; b <= N ; b++){
        ans += (N/b)*(b-K);
        ans += max(0LL,(N-(N/b*b)) - K + 1 );
    }
    
    cout << ans << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

class F
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var p = Array.ConvertAll(new int[n], _ => Array.ConvertAll(Console.ReadLine().Split(), int.Parse));

		if (n == 2) { Console.WriteLine(Norm(p[0], p[1]) / 2); return; }

		var M = 0.0;
		for (int i = 0; i < n; i++)
			for (int j = i + 1; j < n; j++)
				for (int k = j + 1; k < n; k++)
					M = Math.Max(M, GetRadius(p[i], p[j], p[k]));
		Console.WriteLine(M);
	}

	static double GetRadius(int[] p, int[] q, int[] r)
	{
		var e = new[] { Norm(p, q), Norm(q, r), Norm(r, p) };
		if (e[0] < e[1]) Swap(e, 0, 1);
		if (e[0] < e[2]) Swap(e, 0, 2);

		var d = e[1] * e[1] + e[2] * e[2] - e[0] * e[0];
		if (d < 0) return e[0] / 2;

		var cos = d / 2 / e[1] / e[2];
		var sin = Math.Sqrt(1 - cos * cos);
		return e[0] / 2 / sin;
	}

	static void Swap<T>(T[] a, int i, int j) { var o = a[i]; a[i] = a[j]; a[j] = o; }
	static double Norm(int[] p, int[] q) => Math.Sqrt(Math.Pow(p[0] - q[0], 2) + Math.Pow(p[1] - q[1], 2));
}


Measured memory_bytes: 11220
#include<iostream>

size_t x[]={1,2,4,8,16,32,64};

int main() {
	/*
	for (size_t k{}; k < 50; k++) {
		for (size_t i{ 0 }; i < 6; i++) {
			if (x[i] <= k) {
				std::cout << k << "," << x[i] << "\n";
			}
		}
	}*/

	
	size_t N;
	std::cin >> N;

	size_t t{0};
	for (size_t i{ 0 }; i < 7;i++) {
		if ( x[i]<=N) { t = i; }
	}
	std::cout << x[t] << "\n";
	
	return 0;
}

Measured memory_bytes: 256
a,b,c=map(int,input().split())
if a<=b:
    if b<=c:
        print(a,b,c)
    elif c<=a:
        print(c,a,b)
    else:
        print(a,c,b)
else:
    if a<=c:
        print(b,a,c)
    elif c<=b:
        print(c,b,a)
    else:
        print(b,c,a)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define M 55
#define N 1005
#define ll long long
#define oo 1000000000
#define mod 5557
using namespace std;
int n,m,A[M];
ll dp[M][M],sum;
int main(){
	int i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		scanf("%d",&A[i]);
		sum+=A[i];
	}
	dp[0][sum%2]=1;
	for(i=1;i<=n;i++){
		if(A[i]%2==1){
			dp[i][1]+=dp[i-1][0];
			dp[i][1]+=dp[i-1][1];
			dp[i][0]+=dp[i-1][1];
			dp[i][0]+=dp[i-1][0];
		}
		else {
			dp[i][1]+=2*dp[i-1][1];
			dp[i][0]+=2*dp[i-1][0];
		}
	}
	cout<<dp[n][m%2]<<endl;
}
	
	
	
	
	

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, M; cin >> N >> M;
  vector<ll> A(N), B(M);
  rep(i, N) cin >> A[i];
  rep(i, M) cin >> B[i];
  sort(A.begin(), A.end());
  sort(B.begin(),B.end());
  ll ans = 1LL;
  set<ll> a, b;
  rep(i, N) a.insert(A[i]); rep(i, M) b.insert(B[i]);
  if(a.size() != N || b.size() != M) {
      cout << 0 << endl;
      return 0;
  }
  for(ll k = N * M; k > 0 ; k--) {
     if(binary_search(A.begin(), A.end(), k)) {
        if(binary_search(B.begin(), B.end(), k)) {
           continue;
        } else {
            ans *= (B.end() - lower_bound(B.begin(), B.end(), k));
            ans %= mod;
        }
     }
     else if(binary_search(B.begin(), B.end(), k)) {
         ans *= (A.end() - lower_bound(A.begin(), A.end(), k));
         ans %= mod;
     }
     else {
         ll C = (A.end() - lower_bound(A.begin(), A.end(), k)) * (B.end() - lower_bound(B.begin(), B.end(), k)) - (N * M - k);
         ans *= (C > 0 ? C : 0);
         ans %= mod;
     }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384