akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int a, b, x;

	cin >> a >> b >> x;

	for (i = 0; i <= b; i++) {
		if (a + i == x) {
			cout << "YES" << endl;

			getchar();
			getchar();
			return 0;
		}
	}

	cout << "NO" << endl;













	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 510000;
const int MOD =  1000000007;
const int INV2 = (MOD+1)/2;

     signed main(){

        int n;
        cin>>n;
        int b[n],a[n],ans2=0;
        int dp[n][51],dp2[n][51];
        for(int i=0;i<n;i++)fill(dp[i],dp[i]+51,MOD*MOD);
        
        for(int i=0;i<n;i++){
          cin>>a[i];
          dp[i][a[i]]=0;

        }
        for(int i=0;i<n;i++)cin>>b[i];
        while(true){
          for(int i=0;i<n;i++)for(int j=0;j<=50;j++)dp2[i][j]=dp[i][j];
        for(int i=0;i<n;i++){
          for(int j=50;j>0;j--){
            for(int k=j;k<=50;k++){
              if(dp2[i][k]!=MOD*MOD)dp2[i][k%j]=min(dp2[i][k%j],dp2[i][k]+(1ll<<j));
            }
          }
        }
        int ans=0;
        for(int i=0;i<n;i++){
          if(dp2[i][b[i]]==MOD*MOD){
            cout<<-1<<endl;
            return 0;
          }
          ans|=dp2[i][b[i]];
         
        }
        if(ans==0)break;
        int h=0;while(ans>=(1ll<<h))h++;
        ans2+=(1ll<<(h-1));
       // cerr<<h<<' '<<ans<<' ';
        for(int i=0;i<n;i++){
          for(int j=0;j<=50;j++){
            if(dp[i][j]==0)dp[i][j%(h-1)]=0;
          }
        }
        }
        cout<<ans2<<endl;

 




}


        


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

using namespace std;
#define MAX 1003
int main()
{
    int N,T,i;
    cin>>N>>T;
    int c[MAX],t[MAX];
    for(int i=0;i<N;i++)
    {
        cin>>c[i]>>t[i];
    }
    int ans=INT_MAX;
    for(int i=0;i<N;i++)
    {
        if(c[i]<ans && t[i]<=T)
        ans=c[i];
    }
    if(ans!=INT_MAX)
    cout<<ans<<endl;
    else cout<<"TLE"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){



		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		String s = sc.next();
		String[] ss = s.split("");
		int[] num = new int[n];
		for(int i =0;i<n;i++) {
			num[i] = Integer.parseInt(ss[i]);
		}
		int counter = 0;
		for(int i =0;i<1000;i++) {
			int[] digits = new int[3];
			digits[0] = i%10;
			digits[1] = (i/10)%10;
			digits[2] = i/100;
			int digitref = 2;
			
			int target = 0;
			while(target<n&&digitref>-1) {
				if(num[target]==digits[digitref]) {
					digitref--;
				}
				target++;
			}
			if(digitref<0)counter++;
		}
		System.out.println(counter);
	}
}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 27956
#include <iostream>
using namespace std;
int main() {
  int h, n, a;
  cin >> h >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    h -= a;
    if (h <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false
using namespace std;

ll bmm(ll a, ll b) {
	if (b == 0) return a;
	else return bmm(b, a%b);
}
ll kmm(ll a, ll b) {
	return(a*b) / bmm(a, b);
}

const ll mod = 1e9 + 7;
const ll MAXN = 1e5+5;

ll n,x=1;
ss s;
int main() {
	isc;
	cin >>n >> s;
	rep(i,1,n){
		if(s[i]!=s[i-1])
			x++;
	}
	cout << x;
	return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
#include <vector>
using namespace std;
int fr[2010],ne[4010],v[4010],bs=0;
void addb(int a,int b)
{
	v[bs]=b;
	ne[bs]=fr[a];
	fr[a]=bs++;
}
int sd[2010],fa[2010],es[2010];
void dfs1(int u,int f)
{
	sd[u]=sd[f]+1;
	fa[u]=f;
	for(int i=fr[u];i!=-1;i=ne[i])
	{
		if(v[i]!=f)
		{
			es[u]+=1;
			dfs1(v[i],u);
		}
	}
}
int lc[2010][2010],fz[2010];
int dfs2(int a,int b)
{
	if(lc[a][b])
		return lc[a][b];
	if(a==b)
		return lc[a][b]=a;
	if(sd[a]>sd[b])
		lc[a][b]=dfs2(fa[a],b);
	else
		lc[a][b]=dfs2(a,fa[b]);
	return lc[a][b];
}
int getd(int a,int b,int c)
{
	int z1=lc[a][c],z2=lc[a][b];
	return sd[z1]>sd[z2]?z1:z2;
}
vector<int> ve[2010];
int zu[2010],zv[2010],X[4010],Y[4010],yl[4010],jg[4010],dl[2010],sl=0,cs[2010];
bool de[4010],mz[2010];
void solve(int n)
{
	int he=0,ta=0;
	for(int i=1;i<=n;i++)
	{
		if(es[i]==0)
			dl[ta++]=i;
	}
	while(he<ta)
	{
		int u=dl[he++],f=fa[u],s=0;
		es[f]-=1;
		if(es[f]==0)dl[ta++]=f;
		for(int i=0;i<ve[u].size();i++)
		{
			int z=ve[u][i];
			if(X[z]==Y[z])
				de[z]=true;
			if(!de[z])s+=1;
		}
		if(s==0)continue;
		if(s==1||mz[u])
		{
			for(int i=0;i<ve[u].size();i++)
			{
				int z=ve[u][i];
				if(!de[z])
				{
					if(X[z]==u)X[z]=f;
					else Y[z]=f;
					ve[f].push_back(z);
				}
			}
			continue;
		}
		int a=-1,za,b,zb;
		for(int i=0;i<ve[u].size();i++)
		{
			int z=ve[u][i];
			if(!de[z])
			{
				int t=(X[z]==u)?Y[z]:X[z];
				if(a==-1)
					a=t,za=z;
				else
				{
					b=t;zb=z;
					break;
				}
			}
		}
		de[za]=de[zb]=true;
		yl[za]=yl[zb]=++sl;jg[za]=jg[zb]=-1;
		if(X[za]!=a)jg[za]=-2;
		if(X[zb]!=u)jg[zb]=-2;
		X[sl]=a;Y[sl]=b;
		ve[a].push_back(sl);ve[b].push_back(sl);
		for(int i=0;i<ve[u].size();i++)
		{
			int z=ve[u][i];
			if(!de[z]&&z!=za&&z!=zb)
			{
				if(X[z]==u)X[z]=f;
				else Y[z]=f;
				ve[f].push_back(z);
			}
		}
		ve[u].clear();
		int d=getd(u,a,b);
		while(u!=d)
		{
			mz[u]=true;
			u=fa[u];
		}
	}
}
int dfs3(int u)
{
	if(jg[u]>=0)
		return jg[u];
	int t=jg[u];
	jg[u]=dfs3(yl[u]);
	if(t==-2)
		jg[u]^=1;
	return jg[u];
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		fr[i]=-1;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		addb(a,b);addb(b,a);
	}
	dfs1(1,0);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
			dfs2(i,j);
	}
	for(int i=1;i<=m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		zu[i]=X[i]=a;zv[i]=Y[i]=b;
		ve[a].push_back(i);
		ve[b].push_back(i);
		int c=lc[a][b];
		while(a!=c)
		{
			cs[a]+=1;
			a=fa[a];
		}
		while(b!=c)
		{
			cs[b]+=1;
			b=fa[b];
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		ans+=(cs[i]<2?cs[i]:2);
	sl=m;solve(n);
	printf("%d\n",ans);
	for(int i=1;i<=m;i++)
	{
		dfs3(i);
		if(jg[i]==0)
			printf("%d %d\n",zu[i],zv[i]);
		else
			printf("%d %d\n",zv[i],zu[i]);
	}
	return 0;
}

Measured memory_bytes: 24400
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    ll x;
    cin >> x;

    if(x>=30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
N, M = map(int, input().split())
p_S = [input().split() for _ in range(M)]

# N, M=O(10^5)なので、O(N+M)で解く！
AC = [False]*N
WA = [0]*N
 
# i番目の提出において、
# (1) まだ'AC'されておらず、提出がWAだった場合：WA += 1
# (2) まだ'AC'されておらず、提出がACだった場合：AC += 1 
# (3) すでに'AC'されている場合：何もしない
for i in range(M):    
  num = int(p_S[i][0])-1
  if AC[num] == 0 and p_S[i][1] == 'WA': WA[num] += 1
  elif AC[num] == 0 and p_S[i][1] == 'AC': AC[num] = True
  else: continue

# 'AC'を出した各問題において、初めて'AC'を出すまでに出した'WA'の数の和を求める
s = 0
for i in range(N):
  if AC[i]:
    s += WA[i]
    
print(sum(AC), s)

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

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    int count = 0;
    for(int i = 0; i <= 100; i++){
        if(i >= A && i >= C && i <= B && i <= D){
            count++;
        }
    }
    
    cout << (count == 0 ? 0 : count - 1) << endl;

}

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

#define fi first
#define se second
#define pb push_back
#define lson o<<1
#define rson o<<1|1
#define CLR(A, X) memset(A, X, sizeof(A))
#define bitcount(X) __builtin_popcountll(X)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-10;
const LL MOD = 1e9+7;
const auto INF = 0x3f3f3f3f;
int dcmp(double x) { if(fabs(x) < eps) return 0; return x<0?-1:1; }

const int MAXN = 1e5+5;

vector<int> G[MAXN];
int col[MAXN], cnt = 0;
bool flag = 0;

void dfs(int u) {
    cnt += col[u];
    for(int v:G[u]) {
        if(col[v] == -1) {
            col[v] = col[u]^1;
            dfs(v);
        }
        else if(col[v] == col[u]) flag = 1;
    }
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[u].pb(v); G[v].pb(u);
    }
    CLR(col, -1);
    col[1] = 0;
    dfs(1);
    LL ans;
    if(flag) ans = 1LL*n*(n-1)/2;
    else ans = 1LL*cnt*(n-cnt);
    printf("%lld\n", ans-m);
    return 0;
}



Measured memory_bytes: 6656
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18

 
using namespace std;
 
int max(int a, int b)
{
    if(a>b) return a;
    else return b;
}
 
int min(int a,int b)
{
    if(a<b) return a;
    else return b;
}
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int n,i;
    cin>>n;
    vi v(n);
    int a;
    for(i=0;i<n;i++)
    {
        cin>>v[i];
        if(i==0) a=v[i];
        else
        {
            a=(a^v[i]);
        }
    }
    for(i=0;i<n;i++) cout<<(v[i]^a)<<" ";
    

}

Measured memory_bytes: 4760
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくお願いします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */

#include<bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> X(N);
    for(auto& i : X)cin >> i;
    const auto& calc = [&](unsigned long x) -> unsigned long {
        unsigned long ret{0};
        for(auto& i : X)ret += (i - x) * (i - x);
        return ret;
    };
    unsigned long ans{numeric_limits<unsigned long>::max()};
    for(unsigned long i{0}; i <= 200; ++i)ans = min(ans, calc(i));
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define ll long long
const ll mx=1e18+7;

int main() {
	int n;
	cin>>n;
	ll a, b;
	cin>>a>>b;
	n--;
	while(n--){
		ll x, y, k1=mx, k2=mx;
		cin>>x>>y;
		if( x >= a && y >= b) 
		{
			a=x;
			b=y;
			continue;
		}
	    if( x < a ) {
			k1=(a-1LL)/x +1LL;
			if(y*k1<b) k1= mx;
		}
		if( y < b ) {
			k2=(b-1LL)/y +1LL; 
			if(x*k2<a) k2= mx;
		}
		a=x*min(k1,k2);
		b=y*min(k1,k2);				
		}
		
	cout<<a+b<<endl;	
	return 0;
}


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

int main()
{
    int h,w;
    cin>>h>>w;
    vector<vector<char>> x(h, vector<char>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> x.at(i).at(j);
        }
        for (int j = 0; j < w; j++)
        {
            cout<< x.at(i).at(j);
        }
        cout<<endl;
        for (int j = 0; j < w; j++)
        {
            cout<< x.at(i).at(j);
        }
        cout<<endl;

    }


}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char* myfgets(char *buf,int n,FILE *fp){ //accepts LF/CRLF
	char *ret=fgets(buf,n,fp);
	if(!ret)return NULL;
	if(strlen(buf)&&buf[strlen(buf)-1]=='\n')buf[strlen(buf)-1]=0;
	if(strlen(buf)&&buf[strlen(buf)-1]=='\r')buf[strlen(buf)-1]=0;
	return ret;
}

char Q[24999];
char *q[9];
char L[29999];
int ind[9];
int n;
dfs(depth){
	int cur_ind=0;
	if(!myfgets(L,sizeof(L),stdin)){puts("no such property");exit(0);}
	if(depth){
		for(;L[cur_ind]==' ';cur_ind++);
		if(ind[depth-1]>=cur_ind){puts("no such property");exit(0);}
	}
	char *name=strtok(L+cur_ind,":"),*value=name+strlen(name)+1;
	if(!strcmp(name,q[depth])){
		if(depth==n-1){
			if(*value)
				printf("string \"%s\"\n",value+1),exit(0);
			else
				puts("object"),exit(0);
		}
		ind[depth]=cur_ind;
		dfs(depth+1);
	}
	dfs(depth);
}

main(depth){
	myfgets(Q,sizeof(Q),stdin);
	q[0]=strtok(Q+1,".");
	for(n=1;;n++)if(!(q[n]=strtok(NULL,".")))break;
	dfs(0);
}

Measured memory_bytes: 588
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline ll read(){
	ll x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,b[MAXN],stk[MAXN],top;ll a[MAXN],c[MAXN];
inline bool pd(int x,int y,int z){return (y-x)*(a[z]-a[y])>=(z-y)*(a[y]-a[x]);}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read();
	Rep(i,1,n)a[i]=read();
	Rep(i,1,n)b[i]=read();
	int k=max_element(a+1,a+n+1)-a;
	rotate(a+1,a+k,a+n+1),rotate(b+1,b+k,b+n+1),a[++n]=a[1],b[n]=b[1];
	Rep(i,2,n-1)c[i+1]=2*(b[i]+c[i])-c[i-1];Rep(i,1,n)a[i]-=c[i];
	Rep(i,1,n){for(;top>1&&pd(stk[top-1],stk[top],i);top--);stk[++top]=i;}
	ll ans=0;
	Rep(i,1,top-1){
		int d=stk[i+1]-stk[i];
		ans+=a[stk[i]]*(d+1)+a[stk[i+1]]*(d-1);
	}Rep(i,1,n-1)ans+=2*c[i];
	printf("%.12lf",(db)ans/(2*(n-1)));
	return 0;
}




Measured memory_bytes: 8380
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
l=[0]*N
for i in range(N):
    n=int(input())-1
    l[n]=i
a=0
t=1
for i in range(N-1):
    if l[i]<l[i+1]:
        t+=1
    else:
        if a<t:
            a=t
        t=1
if a<t:
    a=t
print(N-a)

Measured memory_bytes: 10868
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

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

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    int n;
    string s;
    cin >> n >> s;
    rep(i, s.length()) {
        if (s[i] + n - 'A' >= 26) cout << (char)(s[i] + n - 26);
        else cout << (char)(s[i] + n);
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int A, B, C;
  std::cin >> A >> B >> C;
  if(max(A, B)>=C && min(A, B) <= C){
    std::cout << "Yes" << '\n';
  }else{
    std::cout << "No" << '\n';
  }
  return 0;
}


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

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define LL long long
#define ULL unsigned long long
#define LB lower_bound
#define MOD1 1000000007
#define MOD2 1000000009
#define int LL
int N, W;

void max_self(int &a, int b)
{
    a = max(a, b);
}

main()
{
    cin >> N >> W;
    vector<int> dp(W + 1); //0....W
    //dp[i] = maximum total value of items with total weight exactly
    for (int item = 0; item < N; ++item)
    {
        int weight, value;
        cin >> weight >> value;
        for(int weight_already = W - weight; weight_already >= 0; --weight_already) 
        {
            max_self(dp[weight_already + weight], dp[weight_already] + value);
        }
    }

    int answer = 0;
    for (int i = 0; i <= W; ++i)
    {
        max_self(answer,dp[i]);
    }
    cout << answer;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);

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

int a[1005];

int main()
{
    int n, x;
    cin >> n >> x;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int ans = 0;
    ll tot = 0;
    for (int i = 0; i < n; ++i)
    {
        if (tot <= x)
        {
            tot += a[i];
            ans += 1;
        }
        else
            break;
    }
    if (tot <= x)
        ans += 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		int N = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++)
			A[i] = sc.nextInt();
		Arrays.sort(A);
		long[] sum = new long[N];
		for(int i=0; i<N; i++)
			sum[i] = (i>0 ? sum[i-1] : 0) + A[i];
		
		int ans = 0;
		for(int i=N-2; i>=0; i--) {
			if(sum[i]*2 < A[i+1]) {
				ans = i+1;
				break;
			}
		}
	
		System.out.println(N-ans);
		sc.close();
	}
}

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

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

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int a, b;

int main() {
	megaRandom();
	cin >> a >> b;
	int mn = INT_MAX;
	if(a <= b) 
		mn = min(mn, b - a);
	if(a <= -b) 
		mn = min(mn, -b - a + 1);
	if(-a <= b) 
		mn = min(mn, b - (-a) + 1);
	if(-a <= -b)
		mn = min(mn, -b - (-a) + 2);			
	cout << mn;
	return 0;  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dec(int N){
	int ret = 1;
	while(true){
	N /= 10;
	if(N==0) return ret;
	else ret++;
	}
}
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int ans = 0;	
	for (int i = N; i > 0; i--)
	{
		if(dec(i)%2==1) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  double a,b,x;
  int n;
  cin>>a>>b;
  x=(a+b)/2;
  n=x;
  if(x-(double)n<=0.4){
    cout<<n<<endl;
  }
  else if(x-(double)n>=0.5){
    cout<<n+1<<endl;
  }
}

Measured memory_bytes: 256
def gcd(a, b):
    while b != 0 :
        t = a % b
        a = b
        b = t
    return a
        
sum = 0
N=int(input(""))
for a in range(1, N + 1):
    for b in range(1, N + 1):
        x = gcd(a, b)
        if x == 1:
            sum = sum + N
        elif x == 2:
            sum = sum + (N + 1) // 2 + N // 2 * 2
        else:
            for c in range(1, N + 1):
                sum = sum + gcd(x, c)
print(sum)

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

using namespace std;

int main ()
{
	int N, K, i, j;
	scanf ("%d %d", &N, &K);
	int c[N], dd[N];
	for (i = 0; i < N; i++)
	{
		scanf ("%d", &(c[i]));
	}
	dd[0] = 0;
	for (i = 1; i < N; i++)
	{
		dd[i] = dd[i - 1] + abs (c[i] - c[i - 1]);
		for (j = 2; j <= K && j <= i; j++)
		{
			dd[i] = min (dd[i], dd[i - j] + abs (c[i] - c[i - j]));
		}
	}
	printf ("%d\n", dd[N - 1]);
	return 0;
}


Measured memory_bytes: 1024
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
const char atgc[] = "atgc";
ll dp[101][4][4][4];

void solve()
{
    ll ans = 0;
    REP(i, 4){
        REP(j, 4){
            REP(k, 4){
                if(atgc[i] == 'a' && atgc[j] == 'g' && atgc[k] == 'c') continue;
                if(atgc[i] == 'a' && atgc[j] == 'c' && atgc[k] == 'g') continue;
                if(atgc[i] == 'g' && atgc[j] == 'a' && atgc[k] == 'c') continue;
                dp[3][i][j][k] = 1;
            }
        }
    }
    FOR(i, 4, N+1){
        REP(j, 4){
            REP(k, 4){
                REP(l, 4){
                    REP(m, 4){
                        if(atgc[m] == 'a' && atgc[k] == 'g' && atgc[l] == 'c') continue;
                        if(atgc[j] == 'a' && atgc[k] == 'g' && atgc[l] == 'c') continue;
                        if(atgc[j] == 'a' && atgc[k] == 'c' && atgc[l] == 'g') continue;
                        if(atgc[j] == 'g' && atgc[k] == 'a' && atgc[l] == 'c') continue;
                        if(atgc[m] == 'a' && atgc[j] == 'g' && atgc[l] == 'c') continue;
                        dp[i][j][k][l] += dp[i-1][m][j][k];
                        dp[i][j][k][l] %= MOD;
                    }
                }
            }
        }
    }
    REP(i, 4){
        REP(j, 4){
            REP(k, 4){
                ans += dp[N][i][j][k];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}

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

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
ll n, m, p;
int Count[2501];
vector<pil> v[2501];
bool check[2501];
ll dist[2501];
bool c[2501];
bool c2[2501];
int main() { // E,F , virtual
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n >> m >> p;
	rep(i, m) {
		int x, y; ll z; cin >> x >> y >> z;
		v[x].push_back({ y,z });
	}
	queue<int> q;
	q.push(1);
	stack<int> st;
	check[1] = true;
	while (!q.empty()) {
		int x = q.front();
		q.pop();
		c2[x] = false;
		if (Count[x] >= n) {
			st.push(x);
			c[x] = true;
			continue;
		}
		Count[x] += 1;
		for (int i = 0; i < v[x].size(); i++) {
			int y = v[x][i].first;
			ll z = v[x][i].second;
			if (!check[y] || dist[y] < (dist[x] + z) - p) {
				check[y] = true;
				dist[y] = (dist[x] + z) - p;
				if (!c2[y]) {
					c2[y] = true;
					q.push(y);
				}
			}
		}
	}

	while (!st.empty()) {
		int x = st.top(); st.pop();
		for (int i = 0; i < v[x].size(); i++) {
			int y = v[x][i].first;
			if (!c[y]) {
				c[y] = true; 
				st.push(y);
			}
		}
	}

	if (c[n])dist[n] = -1;
	else if (dist[n] < 0)dist[n] = 0;

	cout << dist[n] << '\n';

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef map<int,int> MPi; typedef pair<Int,Int> Pl; typedef int8_t shor;
const int mod = 1000000007;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int (i)=0; i<(n); i++)
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int y,x,c;

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

    Int h,w,n; cin>>h>>w>>n; map<P,bool> seen={},bl={}; P b[n];
	for (int i = 0; i < n; i++){
		cin>>y>>x;
		bl[P(--y,--x)]=true;
		b[i].first=y; b[i].second=x;
	}
	Int ans[10]={},sum=0; short c=0;
	for (int i = 0; i < n; i++){
		y=b[i].first,x=b[i].second;
		for (int j = max(0LL,y-2); j <= min(y,h-3); j++){
			for (int k = max(0LL,x-2); k <= min(x,w-3); k++){
				if(seen[P(j,k)])continue;
				c=0;
				rep(l,3){
					rep(m,3)c+=bl[P(j+l,k+m)];
				}
				ans[c]++;
				seen[P(j,k)]=true;
			}
		}
	}
	for (int i = 1; i < 10; i++)sum+=ans[i];
	ans[0]=(h-2)*(w-2)-sum;
	for (int i = 0; i < 10; i++)cout<<ans[i]<<'\n';
}

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

const int N = 1e5 + 10;
int n, C, K, t[N], mx = 0, cnt, ans;

int main() {
    cin >> n >> C >> K;
    rep(i, 1, n) scanf("%d", &t[i]);
    sort(t + 1, t + n + 1);
    rep(i, 1, n) {
        if (mx < t[i] || cnt == C) {
            // printf("%d .\n", i);
            ++ans;
            cnt = 1;
            mx = t[i] + K;
        } else {
            ++cnt;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4104
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    xy = [LI() for _ in range(N)]

    if N == 1:
        print(1)
    else:
        interval = []
        for i in range(N):
            for j in range(N):
                if i != j:
                    interval.append((xy[i][0] - xy[j][0], xy[i][1] - xy[j][1]))

        cnt = collections.Counter(interval)
        nocost = max(cnt.values())
        ans = N - nocost
        print(ans)

if __name__ == '__main__':
    resolve()


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

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
    string s;cin>>s;
    int n= s.size();
    
    cout<<s[0]<<n-2<<s[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
string s,a[16];
int l;
int main()
{
	a[0]="AKIHABARA";
	a[1]="AKIHABAR";
	a[2]="AKIHABRA";
	a[3]="AKIHABR";
	a[4]="AKIHBARA";
	a[5]="AKIHBAR";
	a[6]="AKIHBRA";
	a[7]="AKIHBR";
	a[8]="KIHABARA";
	a[9]="KIHABAR";
	a[10]="KIHABRA";
	a[11]="KIHABR";
	a[12]="KIHBARA";
	a[13]="KIHBAR";
	a[14]="KIHBRA";
	a[15]="KIHBR";
	cin>>s;
	for (int i=0;i<16;i++) if (s==a[i]) {puts("YES"); return 0;}
	puts("NO");
	return 0;
}

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

using namespace std;

const int BIT = 18;
const int N = (1 << BIT) + 5;

int mx[N][2];

int n;
int a[N];
int bit;

// void update(const int &s, const int &k) {
//   if (k > mx[s][0]) {
//     mx[s][1] = mx[s][0];
//     mx[s][0] = k;
//   } else if (k > mx[s][1]) {
//     mx[s][1] = k;
//   }
// }

// int solve(int k) {
//   for (int i = 0; i < bit; ++i) {
    
//   }
// }

int ans[N];

void merge(int v, int x, int y) {
  vector<int> r;
  r.push_back(mx[x][0]);
  r.push_back(mx[x][1]);
  r.push_back(mx[y][0]);
  r.push_back(mx[y][1]);
  sort(r.begin(), r.end());
  ans[v] = max(ans[v], r[2] + r[3]);
  mx[v][0] = r[3];
  mx[v][1] = r[2];
}

void multi() {
  for (int i = 0; i < n; ++i) {
    mx[i][0] = a[i];
  }
  for (int k = 1; k < n; k <<= 1) {
    for (int i = 0; i < n; i += k * 2) {
      for (int j = i; j < i + k; ++j) {
        merge(j + k, j + k, j);
      }
    }
  }
}


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> bit;
  n = 1 << bit;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    // int k = ((1 << bit) - 1) & (~a[i]);
    // if (a[i] <= mx[k][1]) {
    //   continue;
    // }
      
    // for (int s = k; s; s = (s - 1) & s) {
    //   update(s, a[i]);
    // }
  }
  multi();
  for (int k = 1; k < n; ++k) {
    ans[k] = max(ans[k], ans[k - 1]);
    cout << ans[k] << endl;
  }
  return 0;
}


Measured memory_bytes: 7168
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long lli;

struct S {
  lli a, b;
  bool operator < (const S &s) const {
    if(b != s.b) return b > s.b;
    return a < s.a;
  }
};

const int MAXN = 300005;
int N;
S s[MAXN];

bool can(int m) {
  if(m == 0) return true;
  priority_queue<lli> que;
  for(lli i = 0, sum = 0 ; i < N; ++i) {
    que.push(s[i].a);
    sum += s[i].a;
    if(i+1 >= m) {
      if(sum <= m*s[i].b) return true;
      sum -= que.top();
      que.pop();
    }
  }
  return false;
}

int main() {
  while(cin >> N && N) {
    for(int i = 0; i < N; ++i) {
      cin >> s[i].a >> s[i].b;
    }
    sort(s, s+N);
    int l = 0, r = N+1;
    while(r-l) {
      int m = (l+r)/2;
      if(can(m)) {
        l = m+1;
      } else {
        r = m;
      }
    }
    cout << l-1 << endl;
  }
  return 0;
}

Measured memory_bytes: 13968
unittest
{
	assert( [ "3", "10 2 5", "6 3 4" ].parse.expand.solve == 5 );
	assert( [ "4", "13 21 6 19", "11 30 6 15" ].parse.expand.solve == 6 );
	assert( [ "1", "1", "50" ].parse.expand.solve == 0 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto vs = input.front.split.to!( long[] );
	input.popFront;
	auto cs = input.front.split.to!( long[] );
	return tuple( vs, cs );
}

auto solve( long[] vs, long[] cs )
{
	auto x = 0L;
	auto y = 0L;
	foreach( v, c; lockstep( vs, cs ) )
	{
		auto xn = x + v;
		auto yn = y + c;
		if( x - y < xn - yn )
		{
			x = xn;
			y = yn;
		}
	}
	return x - y;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = 998244353; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;
ll mpow(ll x, ll n) { ll y = 1; for (; n > 0; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }
    
struct Combination {
    vector<ll> fact, ifact;
    Combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1; for (int i = 0; i < n; ++i) fact[i + 1] = fact[i] * (i + 1) % MOD;
        ifact[n] = mpow(fact[n], MOD - 2); for (int i = n; i > 0; --i) ifact[i - 1] = ifact[i] * i % MOD;
    }
    ll operator ()(int n, int k) { return k < 0 || k > n ? 0 : fact[n] * ifact[n - k] % MOD * ifact[k] % MOD; }
} C(4545);

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

    rep(i, 2, 2 * K + 1) {
        // １個だけでi以上の個数 or 片方がその数字だとiに満たない個数
        int n_NotPair = i < K + 1 ? max(0, K - i + 1) : max(0, i - K - 1);

        ll ans = 0;
        if (i % 2) {
            int n_Pair = (K - n_NotPair) / 2;
            // 2つに割ったペアの使用数
            rep(m, 0, n_Pair + 1) {
                ll tmp = C((N - m) + (m + n_NotPair) - 1, N - m) * mpow(2, m) % MOD;
                ans = (ans + C(n_Pair, m) * tmp % MOD) % MOD;
            }
        }
        else {
            int n_Pair = (K - n_NotPair - 1) / 2;
            // i/2を使わない
            rep(m, 0, n_Pair + 1) {
                ll tmp = C((N - m) + (m + n_NotPair) - 1, N - m) * mpow(2, m) % MOD;
                ans = (ans + C(n_Pair, m) * tmp % MOD) % MOD;
            }

            // i/2を使う i/2は1個まで
            rep(m, 0, n_Pair + 1) {
                ll tmp = C((N - m - 1) + (m + n_NotPair) - 1, N - m - 1) * mpow(2, m) % MOD;
                ans = (ans + C(n_Pair, m) * tmp % MOD) % MOD;
            }
        }

        write(ans);
    }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  int cnt = 0;
  
  for(int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  
  sort(p.begin(), p.end());

  cout << p.at(n/2) - p.at(n/2 -1) << endl;
}

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

#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define ffor(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(i, n) ffor(i,0,n)
#define All(obj) (obj).begin(),(obj).end()
#define INF ((ll)1e9+7)
#define c(a) cout<<a<<"\n";
using namespace std;
const int N = 100005;

int gcd(int a, int b) {
	if (a < b) swap(a, b);
	if (b < 1)return -1;
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
int main() {
	speed;
	int n;
	cin >> n;
	vector<int>a(n);
	int ans = 0;
	rep(i, n) {
		cin >> a[i];
		if (i == 0) {
			ans = a[0];
		}
		else {
			ans = gcd(a[i], ans);
		}
	}
	c(ans);
	return 0; 
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

//struct position{int x;};

int main(void){
	ll a,b,c;
	cin>>a>>b>>c;
	ll na,nb,nc;
	ll ans=0;
	while(a%2==0&&b%2==0&&c%2==0){
		na = (b+c)/2;
		nb=(c+a)/2;
		nc=(a+b)/2;
		if(min(na,min(nb,nc)) == min(a,min(b,c)) && max(na,max(nb,nc)) == max(a,max(b,c))){
			cout<<-1<<endl;
			return 0;
		}
		a=na;
		b=nb;
		c=nc;
		ans++;

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


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

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int a, b;
  cin >> a >> b;
  cout << ceil((a+b)/2.0) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
  int n,t[100],i,j,k[100],s1[100],s2[100],x;
  scanf("%d",&n);
  for(i=0;i<n;i++)
	{
      scanf("%d",&t[i]);
	}

  for(i=0;i<n-1;i++)
	{
	    s1[i] = 0;
	    s2[i] = 0;
		for(j=0;j<i+1;j++)
		  {
 	     	s1[i] += t[j];
		  }
		for(j=i+1;j<n;j++)
		  {
            s2[i] += t[j];
		  }
		if(s1[i]<s2[i]){
		  k[i] = s2[i] - s1[i];}
		else {
		  k[i] = s1[i] - s2[i];}
	}


  

  /*kはn-1個ある*/

  for(i=0;i<n-2;i++)
	{
	  for(j=i+1;j<n-1;j++)
		{
	      if(k[i]<k[j])
            {
            x = k[i];
	 	    k[i] = k[j];
		    k[j] = x;
		    }
        }
    }

  printf("%d",k[n-2]);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{  
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	int ans = k;
	int maxdistance = 0;
	for (int i =0 ; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i < n; i++) {
		if (a[i] - a[i - 1] > maxdistance) {
			maxdistance = a[i] - a[i - 1];
		}
		if (i == n - 1 && k - a[i]+a[0] > maxdistance) {
			maxdistance = k - a[i]+a[0];
		}
	}
	cout << k - maxdistance << endl;
    return 0;
}


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

void merge(vector<int> &S, int left, int mid, int right, int &count) {
    int n1, n2;
    n1 = mid - left;
    n2 = right - mid;
    vector<int> L(n1 + 1), R(n2 + 1);
    for (int i = 0; i < n1; i++) {
        L.at(i) = S.at(left + i);
    }
    for (int i = 0; i < n2; i++) {
        R.at(i) = S.at(mid + i);
    }
    L.at(n1) = 1000000001;
    R.at(n2) = 1000000001;
    
    int i, j;
    i = 0;
    j = 0;
    for (int k = left; k < right; k++) {
        count++;
        if (L.at(i) <= R.at(j)) {
            S.at(k) = L.at(i);
            i++;
        } else {
            S.at(k) = R.at(j);
            j++;
        }
    }
}

void mergeSort(vector<int> &S, int left, int right, int &count) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(S, left, mid, count);
        mergeSort(S, mid, right, count);
        merge(S, left, mid, right, count);
    }
}

void mergeSort(vector<int> &S, int &count) {
    mergeSort(S, 0, S.size(), count);
}

int main() {
    int n, count;
    cin >> n;
    count = 0;
    vector<int> S(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &S.at(i));
    }

    mergeSort(S, count);

    for (int i = 0; i < n - 1; i++) {
        printf("%d ", S.at(i));
    }
    cout << S.at(n - 1) << endl;
    cout << count << endl;
}


Measured memory_bytes: 6892
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
// int dx[4]    = {1, 0, -1, 0};
// int dy[4]    = {0, 1, 0, -1};
// ll pas[5001][5002];

ll dp[102][114514]  = {};
ll sum[102][114514] = {};

ll mod(ll a) {
    if (a > 0) return a % MOD;
    if (a % MOD == 0) return 0;
    ll x = -a / MOD + 1;
    a += x * MOD;
    return a % MOD;
}

signed main() {
    IOS();
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) { cin >> a[i]; }
    sum[0][0] = 0;
    for (int i = 0; i <= k; ++i) {
        dp[0][i]      = (i <= a[0] ? 1 : 0);
        sum[0][i + 1] = sum[0][i] + dp[0][i];
    }
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= k; ++j) {
            dp[i][j] = mod(sum[i - 1][j + 1] - sum[i - 1][max(0, j - a[i])]);
            sum[i][j + 1] = mod(dp[i][j] + sum[i][j]);
        }
    }
    cout << dp[n - 1][k] << endl;
}

Measured memory_bytes: 182272
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 3e3+7;

int n;
double p[N];
double mem[N][N];

double dp(int i,int cnth)
{
    double &ret = mem[i][cnth];
    if (ret != -1) return ret;
    if (i == n)
    {
        if (cnth > (n/2)) return ret = 1;
        else return ret = 0;
    }
    double ret1 = dp(i+1,cnth)*(1-p[i]);
    double ret2 = dp(i+1,cnth+1)*p[i];
    return ret = ret1+ret2;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);
    REP(i,0,N-1) REP(j,0,N-1) mem[i][j] = -1;
    cin >> n;
    REP(i,0,n-1) cin >> p[i];

    cout <<fixed << setprecision(9) << dp(0,0) << endl;

    return 0;
}


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

const int N = (int) 1e5;
int a[N], cost[N];

int main() {
    int n, k; cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> a[i] >> cost[i];
    long long best = 0;
    for (int diff = 0; diff <= 30; ++diff) {
        long long get = 0;
        for (int i = 0; i < n; ++i) {
            int k1 = k >> diff;
            int a1 = a[i] >> diff;
            if ((k1 | a1) != k1) continue;
            if (diff > 0 && (a[i] >> (diff - 1) & 1) >= (k >> (diff - 1) & 1)) {
                continue;
            }
            get += cost[i];
        }
        //if (get != 0) cout << diff << ' ' << get << endl;
        best = max(best, get);
    }
    cout << best << '\n';
    return 0;
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use std::io;
#[allow(unused_imports)]
use std::cmp;
use std::collections::LinkedList;

#[allow(dead_code)]
fn getline() -> LinkedList<String> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok().unwrap();
    s.split(' ')
        .map(|x| x.trim().to_string())
        .collect::<LinkedList<String>>()
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>(l: &mut LinkedList<String>) -> T {
    l.pop_front().and_then(|s| s.parse().ok()).unwrap()
}

fn main() {
    let _ = getline();
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let mut v: Vec<i32> = s.split(' ').map(|x| x.trim().parse().unwrap()).collect();
    v.sort();
    let mut prev: i32 = 0;
    let mut prev_count: i32 = 0;
    let mut ans: i32 = 0;
    for x in v {
        if x == prev {
            prev_count += 1;
        } else {
            if prev < prev_count {
                ans += prev_count - prev;
            } else if prev > prev_count {
                ans += prev_count;
            }
            prev = x;
            prev_count = 1;
        }
    }
    if prev < prev_count {
        ans += prev_count - prev;
    } else if prev > prev_count {
        ans += prev_count;
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int x[3000], y[3000],i;
	for (i = 0;; i++) {
		cin >> x[i] >> y[i];
		if (x[i] == 0 && y[i] == 0)break;
	}
	for (int j = 0; j < i; j++) {
		cout << min(x[j], y[j]) << " " << max(x[j], y[j]) << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
N, K = gets.split(' ').map(&:to_i)

per = (1.0 / N.to_f).to_f
total = 0.0
temp_q = 0.0
temp_m = 1 
1.upto(N) do |n|
  if temp_m * 2 < n
    total += temp_q
    next
  end
  q = per.to_f 
  m = n 
  loop do
    if K <= m
      temp_q = q.to_f
      temp_m = m
      break
    end
    m *= 2
    q /= 2.0
  end
  total += q
end

puts total.to_f


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int m2i(string str){
	int sum=0,rank,Coefficient=1;
	for(int i=0;i<=str.size();i++){
		if(str[i]=='m'){
			rank = 1000;
			sum+=rank*Coefficient;
			Coefficient=1;
		}else if(str[i]=='c'){
			rank = 100;
			sum+=rank*Coefficient;			
			Coefficient=1;			
		}else if(str[i]=='x'){
			rank = 10;
			sum+=rank*Coefficient;			
			Coefficient=1;			
		}else if(str[i]=='i'){
			rank = 1;
			sum+=rank*Coefficient;			
			Coefficient=1;			
		}else {
			Coefficient = str[i]-0x30;
		}
	}
	return sum;
}

void print(int n){
	std::vector<int> v;
	string unit[4]={"m","c","x","i"};
	int num=n;
	int m=1000;
	while(m!=0){
		v.push_back(num/m);
		num = num%m;
		m/=10;
	}
	string str;
	int cnt=0;
	for(int i=0;i<v.size();i++){
		if(v[i]!=0 && v[i]!=1){
			cout << v[i] <<unit[cnt];
		}else if(v[i]==1){
			cout << unit[cnt];
		}
		cnt++;
	}
	cout << endl;
}

int main(){
	int n;
	// cout << m2i("x9i") << endl;

	cin >> n;
	while(n--){
		string str1,str2;
		cin >> str1 >> str2;
		print(m2i(str1)+m2i(str2));
	}
	return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	vector<vector<int> > dp(n+1,vector<int>(3,0));
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i]>>c[i];
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c[i];
		
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
	return 0;
}

Measured memory_bytes: 6912