akhauriyash/Code-Regression huggingface dataset:
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);

	void solve(){
		int n=s.nextInt();
		int x=s.nextInt();
		int[]a=INTS(n).sorted().toArray();
		
		int r=0;
		for(int i=0;i<n;++i) {
			if(x>=a[i]) {
				++r;
				x-=a[i];
			}else {
				x=0;
				break;
			}
		}
		System.out.println(x==0?r:r-1);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return new Range(i);
	}
	Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int n){
		return REP(0,n-1);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int t;
	Supplier<T> supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}
}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
}


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

int main(){
	int n,ans=0;
	string s[]={"3","5","7"};
	queue<string> q;
	cin >> n;
	q.push("");
	while(!q.empty()){
		string k = q.front();
		q.pop();
		if(k.find('3')!=k.find('8'))
		if(k.find('5')!=k.find('8'))
		if(k.find('7')!=k.find('8'))
		if(stoi(k)<=n)ans++;
		if(k.size()<9){
			for(int i=0;i<3;i++)q.push(k+s[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=100000 +117;
const int MM= +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
int a[NN]={};
int b[NN]={};
int ra[NN]={};
int rb[NN]={};
int f[NN]={};
int rf[NN]={};
int cent[7][NN]={};
int rev[NN]={};
int tp[NN]={};
void cp(int tar[],int src[]){
	for(int i=1;i<=n;++i)tar[i]=src[i];
}
void mul(int a[],int b[]){
	for(int i=1;i<=n;++i){
		tp[i]=a[b[i]];
	}
	for(int i=1;i<=n;++i){
		a[i]=tp[i];
	}
}
void getrev(int a[],int x[]){
	for(int i=1;i<=n;++i){
		a[x[i]]=i;
	}
}
int s[NN]={};
bool vis[NN]={};
void getmi(int a[],int k){
	for(int i=1;i<=n;++i)vis[i]=0;
	for(int i=1;i<=n;++i){
		if(!vis[i]){
			int pos=i;
			int cnt=0;
			while(!vis[pos]){
				vis[pos]=1;
				s[cnt++]=pos;
				pos=a[pos];
			}
			for(int j=0;j<cnt;++j){
				tp[s[j]]=s[(j+k)%cnt];
			}
		}
	}
	for(int i=1;i<=n;++i)a[i]=tp[i];
}
int main(){
	//open();
	n=read();
	int k=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	for(int i=1;i<=n;++i){
		b[i]=read();
	}
	getrev(ra,a);
	getrev(rb,b);
	cp(f,b);
	mul(f,ra);
	mul(f,rb);
	mul(f,a);
	getrev(rf,f);
	cp(cent[1],a);
	cp(cent[2],b);
	for(int i=3;i<=6;++i){
		cp(cent[i],cent[i-1]);
		getrev(rev,cent[i-2]);
		mul(cent[i],rev);
	}
	int now=(k-1)%6+1;
	getmi(f,(k-now)/6);
	getmi(rf,(k-now)/6);
	mul(f,cent[now]);
	mul(f,rf);
	for(int i=1;i<=n;++i){
		printf("%d ",f[i]);
	}
	putchar('\n');
	close();
	return 0;
}

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

int main(){
	int x,a,b,k,l;
  	cin >> x >> a >> b;
  	if (x>a) k=x-a;
  	else k=a-x;
  	if (x>b) l=x-b;
  	else l=b-x;
  	if (k>l) cout << "B" << endl;
  	else cout << "A" << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,m,k; scanf("%d%d%d",&n,&m,&k);
	vector<int> a(n),b(m);
	rep(i,n) scanf("%d",&a[i]);
	rep(i,m) scanf("%d",&b[i]);

	int ans=0;
	int l=0,r=0,sum=0;
	while(l<n && sum+a[l]<=k){
		sum+=a[l];
		l++;
	}
	for(;l>=0;l--){
		while(r<m && sum+b[r]<=k){
			sum+=b[r];
			r++;
		}
		ans=max(ans,l+r);
		sum-=a[l-1];
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 4828
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 924844033;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;


int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (auto &&i : s) {
        ans += i-'0';
    }
    if(ans%9 == 0) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3728
import java.util.Arrays;
import java.util.Scanner;

//Usaneko Matrix
public class Main{
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), U = sc.nextInt(), V = sc.nextInt(), m = sc.nextInt();
		int[] u = new int[1000001], v = new int[1000001];
		Arrays.fill(u, -1); Arrays.fill(v, -1);
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)u[sc.nextInt()]=i*n+j;
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)v[sc.nextInt()]=i*n+j;
		int[] usagiV = new int[n], usagiH = new int[n], nekoV = new int[n], nekoH = new int[n];
		int uc1 = 0, uc2 = 0, vc1 = 0, vc2 = 0;
		int ru = 0, rv = 0;
		String res = "DRAW";
		while(m--!=0){
			int x = sc.nextInt();
			if(u[x]!=-1){
				int i = u[x]/n, j = u[x]%n;
				usagiV[j]++; usagiH[i]++;
				if(i==j){
					uc1++;
					if(uc1==n)ru++;
				}
				if(i+j==n-1){
					uc2++;
					if(uc2==n)ru++;
				}
				if(usagiV[j]==n)ru++;
				if(usagiH[i]==n)ru++;
			}
			if(v[x]!=-1){
				int i = v[x]/n, j = v[x]%n;
				nekoV[j]++; nekoH[i]++;
				if(i==j){
					vc1++;
					if(vc1==n)rv++;
				}
				if(i+j==n-1){
					vc2++;
					if(vc2==n)rv++;
				}
				if(nekoV[j]==n)rv++;
				if(nekoH[i]==n)rv++;
			}
			if(n==1){
				ru = Math.min(ru, 1); rv = Math.min(rv, 1);
			}
			if(U<=ru&&V<=rv)break;
			if(U<=ru){
				res = "USAGI"; break;
			}
			if(V<=rv){
				res = "NEKO"; break;
			}
		}
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 20000
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);



int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif

  int n, x, t;
  scanf("%d%d%d", &n, &x, &t);
  if (n % x == 0) {
    n /= x;
  } else {
    n = n / x + 1;
  }
  printf("%d\n", n * t);


#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) * 1.0 / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

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

int main() {
  int a,b,c,d;
  int x,y;
  cin >> a >> b >> c >> d;
  
  if ( (a+b) > (c+d) ) {
    cout << "Left" ;
  }
  else if ( (a+b) == (c+d) ){
    cout << "Balanced" ;
  }
  else if ( (a+b) < (c+d) ) {
    cout << "Right" ;
  }


}

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

#define st first
#define nd second
#define mp make_pair
#define space << " " <<
#define END << endl
#define pb push_back
#define int long long
#define fo(i,n) for(int i = 0; i<n; ++i)
#define ff(i,n) for(int i = 1; i<n; ++i)

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pi;
typedef long long ll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> pl;
typedef vector<pil>vil;

const int N = 1e5 + 100;
ll a[N]; int n;

ll sum(int u, int v)
{
    if(u <= v) return  a[v] - (u==0 ? 0 : a[u-1]);
    else return a[n-1] - ((u==0?0:a[u-1]) - a[v]);
}

bool check1(int num ,int t, int v)
{
    if(sum(t,(t+num-1)%n) >= v) return 1;
    else return 0;
}

bool check(int u, int far)
{
    ll v = sum(u,(u+far-1)%n);
    int t = (u + far) % n;
    int l = 1;
    int r = n - far - 1;
    while( r - l > 1)
    {
        int mid = (l + r)/ 2;
        if(check1(mid,t,v)) r = mid;
        else l = mid;
    }
    if(check1(l,t,v) && a[n-1] - sum(t,(l+t-1)%n) - v >= v) return 1;
    else if(check1(r,t,v) && a[n-1] - sum(t,(r+t-1)%n) - v >= v) return 1;
    else return 0;
}

ll work(int u)
{
    int l = 1;
    int r = n-2;
    //if(sum(u,(u+r-1)%n))
    while(r - l > 1)
    {
        int mid = (l + r) / 2;
        if(check(u,mid)) l = mid;
        else r = mid;
    }
    //cout <<u space check(u,r) space r space check(u,l) space l << endl;
    if(!check(u,r) && !check(u,l)) return 0;
    if(check(u,r)) return sum(u,(u+r-1)%n);
    else return sum(u,(u+l-1)%n);

}
main()
{
    //freopen("test1.txt","r",stdin);
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n; fo(i,n) cin >> a[i]; fo(i,n) if(i) a[i] = a[i-1] + a[i];
    ll ans = 0; fo(i,n) { ans = max(ans , work(i));  }
    cout << ans << endl;
    //cout << sum(4,2) << endl;
    //ll ans = work(0); cout << ans << endl;
}

Measured memory_bytes: 1972
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

double dist(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec p,ch(N+1,1);
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return p;
}
ll min(ll a,ll b){
  return (a<b)?a:b;
}

int main(){
  ll i,j,N,M,K,a,b,c;
  cin>>N>>M;
  K=pow(2,N);
  mat dp(M+1,vec(K,inf));
  dp[0][0]=0;
  rep1(i,M+1){
    cin>>a>>b;
    vec ch(N,0);
    rep(j,b){
      cin>>c;
      ch[c-1]++;
    }
    b=0;
    rep(j,N){
      if(ch[j])b+=1<<j;
    }
    rep(j,K){
      c=j|b;
      dp[i][c]=min({dp[i-1][c],dp[i-1][j]+a,dp[i][c]});
      dp[i][j]=min(dp[i][j],dp[i-1][j]);
    }
  }

  if(dp[M][K-1]==inf){
    cout<<-1<<endl;
  }else{
    cout<<dp[M][K-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 32384
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int n;
	string str;
	char input[200];
	int a = 0;
	int i;

	scanf("%d", &n);

	scanf("%s", input);

	str = input;

	for (i = 0; i < n; i++)
	{
		if (str[i] == 'R')
		{
			a++;
		}

		else
		{
			a--;
		}
	}

	if (a > 0)
	{
		printf("Yes\n");
	}

	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+10 , OO = 0x3f3f3f3f ;
const int mod = 1e9 + 7;
 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

int n , m , k;

int main()
{
   // startTime = (double)clock();
    #ifndef ONLINE_JUDGE
        //freopen("in.in", "r", stdin);
        //freopen("out.in", "w", stdout);
    #endif
	//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    scanf("%d %d", &n , &k);
    vector < int > a(n);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d", &a[i]);
    
    sort(ALL(a));
    int ans = 0;
    for(int i = 0 ; i < k ; ++i)
        ans += a[i];
    printf("%d\n" , ans);


    return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
char d[maxn],c[maxn];
int main(){
	int n,k;
	cin>>n>>k;
	int a,b,c2;  //s得a p得b r得c2
	cin>>a>>b>>c2;
	int sum=0;
	for(int i=0;i<n;i++)
	cin>>d[i];
	for(int i=0;i<n;i++){
		int t=sum;
        if(i<k)
        {
        	if(d[i]=='s') sum+=a,c[i]='p';
        	else if(d[i]=='p') sum+=b,c[i]='r';
        	else sum+=c2,c[i]='s';
		}
		else {
		if(d[i]==d[i-k]&&c[i-k]!=d[i-k]){
			c[i]=d[i];
		}
		else{
        	if(d[i]=='s') sum+=a,c[i]='p';
        	else if(d[i]=='p') sum+=b,c[i]='r';
        	else sum+=c2,c[i]='s';}
	}
	}
	cout<<sum;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

const long long MOD = 1e9 + 7;

int main(){
	long long N, M;
	cin >> N >> M;

	bool isBroken[100001] = {0};
	for (int i = 0; i < M; i++){
		int a;
		cin >> a;
		isBroken[a] = true;
	}

	long long ans[100001] = {0};
	ans[0] = 1;
	ans[1] = (isBroken[1])? 0 : 1;
	for (int i = 2; i <= N; i++){
		if(isBroken[i]){
			ans[i] = 0;
		} else{
			ans[i] = (ans[i - 1] + ans[i - 2]) % MOD;
		}
	}

	cout << ans[N] << endl;
	return 0;
}


Measured memory_bytes: 1152
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	var cnt int
	for i := 0; i < len(s)/2; i++ {
		if string(s[i]) != string(s[len(s)-i-1]) {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n);
    REP(i, n){
        cin >> h.at(i);
    }

    vector<bool> is_good(n, true);
    REP(i, m){
        ll ai, bi;
        cin >> ai >> bi;
        ai--; bi--;
        if(h.at(ai) <= h.at(bi)){
            is_good.at(ai) = false;
        }
        if(h.at(ai) >= h.at(bi)){
            is_good.at(bi) = false;
        }
    }

    ll ans = 0;
    REP(i, n){
        if(is_good.at(i)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4052
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
#line 2 "main.cpp"
int main(){
	int a,b,c,k;
	std::cin>>a>>b>>c>>k;
	while(a>=b){
		b*=2;
		k--;
	}
	while(b>=c){
		c*=2;
		k--;
	}
	if(k<0)puts("No");
	else puts("Yes");
	return 0;
}


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

int main(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    if(n&1){
        cout<<"No"<<endl;
    }
    else{
        int j = n/2;
        int flag=true;
        for(int i=0; i<n/2; i++){
            if(s[i] != s[j]){
                flag=false;
                break;
            }
            j++;
        }
        if(flag){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 384
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if true
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

str = inputs[0][0]

# body
if $debugFlag
  p str
end
flag = "Good"
3.times do |i|
  flag = "Bad" if str[i+1..i+1] == str[i..i]
end

puts flag


Measured memory_bytes: 1788
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

s = input().rstrip()

n = len(s)
ans = [0] * n

rn = ln = 0
for i in range(n):
    if s[i] == 'R': rn += 1
    if s[i] == 'L': ln += 1
    if s[i] == 'L' and (i + 1 < n and s[i + 1] == 'R' or i == n - 1):
        ans[i - ln + 1] = ln - (ln // 2) + (rn // 2)
        ans[i - ln] = rn - (rn // 2) + (ln // 2)
        rn = ln = 0

for i in ans:
    print(i)


Measured memory_bytes: 10008
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

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

int main(){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);

    if(a <= c && d <= b)
        printf("%d\n", d - c);
    else if(c <= a && b <= d)
        printf("%d\n", b - a);
    else{
        int e = min(b - c,d - a);
        if(e <= 0)
            printf("0\n");
        else
            printf("%d\n", e);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>

using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; const int INF=1e9; const ll LINF=1e18;

#include <random>
#include <ctime>

int main(){
  int n; cin>>n;
  int u=n%10;
  if (u==0||u==1||u==6||u==8) {
    cout<<"pon"<<endl;
  } else if (u==3) {
    cout<<"bon"<<endl;
  } else {
    cout<<"hon"<<endl;
  }
}

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

int main() {
	int N;
  
  cin >> N;
  
  if(N%1000 != 0){
    cout << 1000 - N%1000 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}	


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

struct data {
  long long n, x, m;
};

long long k, q;
vector<long long> d, t;
vector<data> v;

void solve();
long long calc(long long n, long long x, long long m);

int main() {
  cin >> k >> q;
  d.resize(k);
  v.resize(q);
  for(int i = 0; i < k; ++i) cin >> d[i];
  for(int i = 0; i < q; ++i)
    cin >> v[i].n >> v[i].x >> v[i].m;
  solve();
  return 0;
}

void solve() {
  t = d;
  for(int i = 0; i < q; ++i) {
    d = t;
    v[i].x %= v[i].m;
    for(int j = 0; j < k; ++j) d[j] %= v[i].m;
    cout << calc(v[i].n, v[i].x, v[i].m) << endl;
  }
}

long long calc(long long n, long long x, long long m) {
  long long res = 0, sum = x;
  for(int i = 0; i < k; ++i) {
    sum += (n - 1) / k * d[i] + ((n - 1) % k > i) * d[i];
    if(d[i] == 0) res += (n - 1) / k + ((n - 1) % k > i);
  }
  res += sum / m;
  return n - 1 - res;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

string J(string s) {
    string res = s.substr(0, s.size() - 1);
    return s[s.size() - 1] + res;
}

string C(string s) {
    string res = s.substr(1, s.size() - 1);
    return res + s[0];
}

string E(string s) {
    int n = s.size();
    string s1 = s.substr(0, n / 2);
    string s2 = s.substr((n + 1) / 2, n / 2);
    if (n % 2) s2 += s[n / 2];
    return s2 + s1;
}

string A(string s) {
    reverse(s.begin(), s.end());
    return s;
}

string P(string s) {
    for (int i = 0; i < s.size(); i++) {
        if (s[i] >= '0' && s[i] <= '9') {
            if (s[i] == '0') s[i] = '9';
            else s[i]--;
        }
    }
    return s;
}

string M(string s) {
    for (int i = 0; i < s.size(); i++) {
        if (s[i] >= '0' && s[i] <= '9') {
            if (s[i] == '9') s[i] = '0';
            else s[i]++;
        }
    }
    return s;
}

void solve() {
    string s1, s2;
    cin >> s1 >> s2;
    for (int i = s1.size() - 1; i >= 0; i--) {
        if (s1[i] == 'J') s2 = J(s2);
        else if (s1[i] == 'C') s2 = C(s2);
        else if (s1[i] == 'E') s2 = E(s2);
        else if (s1[i] == 'A') s2 = A(s2);
        else if (s1[i] == 'P') s2 = P(s2);
        else s2 = M(s2);
    }
    cout << s2 << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#include <iostream>
#include<cstdio>
#include <cstring>
#define endl '\n'
using namespace std;
int main()
{
	char s[11];
	cin>>s;
	int len = strlen(s);
	int l[11]={0},cnt = 0;
	for(int i = 0; i<len; i++)
	{
	    //cout<<"s[i] = "<<s[i]<<"    ";
		if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')
        {
            l[cnt]++;
            //cout<<"l[cnt] = "<<l[cnt]<<endl;
        }
		else{
                cnt++;
              //  cout<<"cnt = "<<cnt<<endl;
        }
	}
	sort(l,l+cnt+1);
//	for(int i = 0; i<cnt; i++)
//        cout<<l[i]<<" ";
    cout<<l[cnt];
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

vector<int> calc(string str) {
  vector<int> tmp(str.size(),0);
  tmp[0]=(str[0]=='#')? 0:1;
  for (int i = 0; i < str.size(); ++i) {
    if (str[i]=='#') tmp[i]=0;
    else tmp[i]=tmp[i-1]+1;
  }
  for (int i = str.size()-2; i >= 0; --i)
  {
    if (tmp[i]==0) continue;
    else if (tmp[i+1]>tmp[i]) tmp[i]=tmp[i+1];
  }
  return tmp;
}

int main()
{
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  vector<vector<int>> row(h,vector<int>(w,0));
  vector<vector<int>> col(w,vector<int>(h,0));
  // vector<vector<int>> field(h,vector<int>(w,0));

  for (int i = 0; i < h; ++i) {
    cin>>s[i];
    row[i]=calc(s[i]);
  }

  for (int i = 0; i < w; ++i)
  {
    string str="";
    for (int j = 0; j < h; ++j) str+=s[j][i];
    col[i]=calc(str);
  }
  int ans=0;
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      ans = max(ans,row[i][j]+col[j][i]-1);
      // field[i][j]=row[i][j]+col[j][i]-1;
      // cout<<field[i][j]<<" ";
    }
    // cout<<endl;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 42252
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;

int main(){

    string s; cin>>s;
    int ma = 0;
    
    if(s[0] == 'R') ma = max(ma,1);
    
    if(s[1] == 'R'){
        ma = max(ma,1);
        if(s[0] == 'R') ma = max(ma,2);
    }
    
    if(s[2] == 'R'){
        ma = max(ma,1);
        if(s[1] == 'R') {
            ma = max(ma,2);
            if(s[0] == 'R') ma = max(ma,3);
        }
    }
    cout<<ma<<"\n";
}


Measured memory_bytes: 3592
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	for(int i=1;i<=n;i++){
    		int x = i;
    		if(x%3 == 0){
    			System.out.printf(" %d",i);
    		}else{
    			while(true){
    				if(x%10 == 3){
    					System.out.printf(" %d",i);
    					break;
    				}
    			    x = x/10;
    				if(x == 0){
    					break;
    				}
    			}
    		}
    	}
    	System.out.println();
    }
}

Measured memory_bytes: 40484
#include <iostream>

using namespace std;

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

  int n;
  cin >> n;
  long long s = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s += x;
  }
  if (s % 2 == 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    m = 10 ** 9
    
    for i in range(1, 101):
        tmp = 0
        for j in range(N):
            tmp += (i - A[j]) ** 2 
        m = min(tmp, m)

    return m

print(solve())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,K;
  cin >> A >> B >> K;
  for (int i = A; i > 0; i--){
    if (A % i == 0 && B % i == 0) K--;
    if (K == 0){
      cout << i;
      break;
    }
  }
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

while True:
    try:
        a=list(map(int,input().split()))
        b=list(map(int,input().split()))
    except:
        break
    
    hit=blow=0
    for i in range(4):
        if a[i]==b[i]:
            hit+=1
    for i in range(4):
        if a[i]!=b[i]:
            if b[i] in a:
                blow+=1
    
    print(hit,blow)


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;



int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n-1){
    int a;
    cin >> a;
    d[a-1]++;
  }
  rep(i, n) cout << d[i] << endl;
}

Measured memory_bytes: 4052
/*
                                                                                                                                               
8b        d8                           888888888888                                             88b           d88                  ad88888ba   
 Y8,    ,8P                                 88                                        ,d        888b         d888                 d8"     "8b  
  Y8,  ,8P                                  88                                        88        88`8b       d8'88                 ""      a8P  
   "8aa8"  ,adPPYba,   88       88          88  8b,dPPYba,  88       88  ,adPPYba,  MM88MMM     88 `8b     d8' 88   ,adPPYba,          ,a8P"   
    `88'  a8"     "8a  88       88          88  88P'   "Y8  88       88  I8[    ""    88        88  `8b   d8'  88  a8P_____88         d8"      
     88   8b       d8  88       88          88  88          88       88   `"Y8ba,     88        88   `8b d8'   88  8PP"""""""         ""       
     88   "8a,   ,a8"  "8a,   ,a88          88  88          "8a,   ,a88  aa    ]8I    88,       88    `888'    88  "8b,   ,aa         aa       
     88    `"YbbdP"'    `"YbbdP'Y8          88  88           `"YbbdP'Y8  `"YbbdP"'    "Y888     88     `8'     88   `"Ybbd8"'         88       
                                                                                                                                               
*/
#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1e9 + 7;

int n, u, v;
vector<vector<int>> adj;

long long cnt[100005][2];

long long solve(int node, int pre, bool color) {
	if (cnt[node][color] != -1) return cnt[node][color];
	long long res = 1;

	for (int i = 0; i < adj[node].size(); i++) {
		if (adj[node][i] != pre) {
			if (!color) {
				res = (res * (solve(adj[node][i], node, 0) + solve(adj[node][i], node, 1)) % MOD) % MOD;
			} else {
				res = (res * solve(adj[node][i], node, 0)) % MOD;
			}
		}
	}

	return cnt[node][color] = res;
}

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

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	cin >> n;
	adj.resize(n);

	for (int i = 0; i < n - 1; i++) {
		cin >> u >> v;
		adj[u - 1].push_back(v - 1);
		adj[v - 1].push_back(u - 1);
	}

	memset(cnt, -1, sizeof(cnt));
	cout << (solve(0, -1, 0) + solve(0, -1, 1)) % MOD << '\n';

	return 0;
} 

Measured memory_bytes: 15616
#if defined(_WIN32)
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

template <class Type>
struct IN
{
	Type val;

	IN()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

std::string INSTR()
{
	std::string value;
	std::cin >> value;
	return value;
}

void OUT()
{
	std::cout << std::endl;
}
template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value;
#pragma warning(disable: 4127)
	if (sizeof...(args) != 0) std::cout << ' ';
	OUT(args...);
}

using ll = long long;
using inll = IN<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;

#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for(ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for(auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for(auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

	return 0;
}

using namespace std;

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

void Main()
{
	inll n, h;

	ll aMax = 0;
	msetll b;
	REP(i, n)
	{
		inll a_, b_;
		aMax = max(aMax, a_.val);
		b.insert(b_);
	}

	ll cnt = 0;
	ITRREPR(it, b)
	{
		if (*it < aMax) break;
		h -= *it;
		cnt++;
		if (h <= 0)
		{
			return OUT(cnt);
		}
	}

	cnt += DIVUP(h, aMax);
	return OUT(cnt);
}


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

int main(){
    int n;
    cin >> n;
    int count = 0;
    int a[1000];
    for (int i = 0; i < n;i++){
        cin >> a[i];
    }
    for (int i = 0; i < n;i++){
        if((i+1)%2!=0 && a[i]%2!=0){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>
int main(){
    int k;
    char s[100+1];
    scanf("%d",&k);
    scanf("%s",s);
    int len=strlen(s);
    if(len<=k){
        printf("%s",s);
        return 0;
    }else{
        for(int i=0;i<k;i++){
            printf("%c",s[i]);
        }
    }
    printf("...\n");
}

Measured memory_bytes: 1732
function main(input){
  const A=parseInt(input.split(" ")[0],10);
    const B=parseInt(input.split(" ")[1],10);

  if(B%A==0){
    console.log(A+B);
  }else{
    console.log(B-A);
  }

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll dp[505],i,j;
    rep(i,0,501){
        dp[i] = pow(i,5);
    }
    ll n,l1,l2;
    cin >> n;
    rep(i,0,501){
        rep(j,0,i){
            if(dp[i] - dp[j] == n){
                cout << i << " " << j << nl;
                return;
            }
        }
    }
    rep(i,0,501){
        rep(j,i,501){
            if(dp[i] + dp[j] == n){
                cout << j << " " << -i << nl;
                return; 
            }
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
   // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 4084
import java.util.*;
import java.io.*;
import java.math.*;
 
 
public class Main
{
    public static void main(String[] args) 
    { 
          Scanner input=new Scanner(System.in);
          int i = input.nextInt();
        //   String s = input.next();
        // int count =0;
        // int i=1000;
        int c1=0,c2=0,c3=0,c4=0;
          while(i>0){
             String s = input.next();
             
             if(s.equals("AC"))
             c1++;
             else if(s.equals("WA"))
             c2++;
             else if(s.equals("TLE"))
             c3++;
             else
             c4++;
             i--;
          }
          
          
          System.out.println("AC x "+ c1);
          System.out.println("WA x "+ c2);
          System.out.println("TLE x "+ c3);
          System.out.println("RE x "+ c4);
          
          
      
            
          input.close(); 
     } 
     
}

Measured memory_bytes: 59008
a,b,c,x,y = map(int,input().split())
if a+b<=2*c:
    print(a*x+b*y)
else:
    if x<=y:
        print(2*c*x+min(b,2*c)*abs(y-x))
    else:
        print(2*c*y+min(a,2*c)*abs(y-x))

Measured memory_bytes: 9028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define min(a, b) (a > b ? b : a)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }



ll a, b;

ll calc(ll a) {
    if (a < 3) {
        return 0;
    }
    for (ll x = a; x >= 0; --x) {
        ll k = (x - 3) / 4;
        if (3 + 4 * k != x) continue;
        return x;
        break;
    }
    return -1;
}
void solve() {
    
    // 自分より小さく, 3+4kであり, 出来るだけ大きいの
    a--;
    ll aa = 0;
    for (ll i = calc(a) + 1; i < a + 1; ++i) { aa ^= i; /* out(aa); */ }
    ll bb = 0;
    for (ll i = calc(b) + 1; i < b + 1; ++i) bb ^= i;
    // out(calc(a) << " " << calc(b));
    // out(aa << " " << bb);
    // out(bitset<40>(aa) << " " << bitset<40>(bb));
    out((aa ^ bb)); // a ^ bにしてた...
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    cin >> a >> b;
    // out(bitset<40>(a) << " " << bitset<40>(b));
    
    solve();
    
}


Measured memory_bytes: 256
A, B, C, D = [int(i) for i in input().split()]

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


countC = B // C - A // C
if A % C == 0:
    countC += 1
countD = B // D - A // D
if A % D == 0:
    countD += 1
s = gcd(C, D)
countCD = B // C // (D // s) - A // C // (D // s)
temp = A / C / (D // s)
if temp == int(temp):
    countCD += 1

res = (B - A + 1 - countC - countD + countCD)
if res < 0:
    res = 0
print(res)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int main()
{
    set<int>TM;
    int n;
    cin>>n;
    int x;
    while(n--)
    {
        cin>>x;
        TM.insert(x);
    }
    cout<<TM.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int n; cin >> n;
    vector <int> a(n);
    int c = 0;
    loop(i, n) {
        cin >> a[i];
        if (a[i] == c + 1)
            ++c;
    }
    cout << (c ? n - c : -1);
}

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


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

#define int long long

int n, cnt[2019], ans, ini, pw = 1;

signed main(){
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    cnt[0] = 1;
    for(int i = s.length() - 1; i >= 0; i--){
        ini = (ini + (pw * (s[i] - '0'))) % 2019;
        pw = (pw * 10) % 2019;
        ans += cnt[ini];
        cnt[ini]++;
        //cout << ini << "\n";
    }
    cout << ans;
}

Measured memory_bytes: 3800
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ;
    cin >> n ; 
    vector<int> cnt(N) ;
    int sum = 0 ;
    for(int i = 0; i < n; i++){
        int x; 
        cin >> x ;
        sum += x ;
        ++cnt[x] ;
    }
    int q ;
    cin >> q ;
    while(q--){
        int b , c ;
        cin >> b >> c ;
        sum -= cnt[b] * b ; 
        sum += cnt[b] * c ;
        cnt[c] += cnt[b] ;
        cnt[b] = 0 ;
        cout << sum << endl;
    }
    return 0; 
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

signed main() {
    ll n;
    cin >> n;
    if (n == 0) {
        cout << "0\n";
        return 0;
    }

    vector<char> v;
    v.reserve(100);

    ll base = 1;
    while (n != 0) {
        if ((n % (base * 2)) == 0) {
            v.push_back('0');
        }
        else {
            v.push_back('1');
            n -= base;
        }
        base *= -2;
    }

    reverse(ALL(v));

    REP(i, v.size()) {
        cout << v[i];
    }
    cout << LF;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a.at(i);
  int count=0;
  rep(i,n-2){
    int saisho=a.at(i)-a.at(i+1);
    int tugi=a.at(i+1)-a.at(i+2);
    if(saisho<0&&tugi<0){
      count++;
    }else if(saisho>0&&tugi>0){
      count++;
    }
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int memo=0,memo2=0;
    string s;
    cin>>s;
    for (int i=0;s[i];i++){
        if (s[i]=='A'&&memo==0){
            memo=i;
            break;
        }
    }
             
     for(int i=0;s[i];i++){
        if(s[i]=='Z'){
            memo2=i+1;//i=0
        }
      
        }
        
        cout<<memo2-memo<<endl;
    }


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, m, c[31];

int main() {
	cin >> n >> m;
	inc(i, n) {
		int k;
		cin >> k;
		inc(j, k) {
			int a;
			cin >> a;
			c[a]++;
		}
	}
	
	int ans = 0;
	inc1(i, m) { if(c[i] == n) { ans++; } }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
  static void Main()
  {
    var n = int.Parse(Console.ReadLine());
    var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();     
    
    var count = new Dictionary<int, long>();
    for (int i = 0; i < n; i++)
    {
      long c;
      if (count.TryGetValue(a[i], out c))
        count[a[i]] = c+1;
      else
        count.Add(a[i], 1);
    }
    long sum = 0;
    foreach (long c in count.Values)
      sum += c * (c-1) / 2;
    
	for (int i = 0; i < n; i++)
      Console.WriteLine(sum - count[a[i]] + 1);
  }
}

Measured memory_bytes: 42560
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    P = list(map(int, input().split()))

    ans = 1
    m = P[0]
    for i in range(1, N):
        if P[i - 1] < m:
            m = P[i - 1]
        if m >= P[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 100060