akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int a[100];
int main(){
	int now;
	int max=0;
	while(~scanf("%d",&now)){
		a[now-1]++;
		if(a[now-1]>max)max=a[now-1];
	}
	for(int i=0;i<100;i++){
		if(a[i]==max)printf("%d\n",1+i);
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int n,k,i,j,t,f,res;
int main()
{
	for(;scanf("%d%d",&n,&k),n;)
	{
		int a[100005]={0};
		for(i=res=0;i<k;a[t]=1,i++)
			scanf("%d",&t);
		for(i=1;i<=n;i++)
		{
			for(j=i,t=0,f=a[0];j<=n;j++)
			{
				if(a[j]==1||f)
				{
					if(a[j]!=1)
						f=0;
					t++;
				}
				else break;
			}
			res=res<t?t:res;
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 996
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, x = map(int,input().split())
a = readl()

count = 0
c = 1
for i in a:
    count += i
    if count > x:
        break
    c += 1
print(c)

Measured memory_bytes: 6736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <unordered_map>
// #include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x)  if(DEBUG_Switch) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
void pvarr_int(int *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%d%c", arr[i], i == n ? '\n' : ' ');}}
void pvarr_LL(ll *arr, int n, int strat = 1) {if (strat == 0) {n--;} repd(i, strat, n) {printf("%lld%c", arr[i], i == n ? '\n' : ' ');}}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
#define DEBUG_Switch 0
int main()
{
#if DEBUG_Switch
    freopen("C:\\code\\input.txt", "r", stdin);
#endif
    //freopen("C:\\code\\output.txt","r",stdin);
    int n = readint();
    int m = readint();
    int x = 0;
    while (m--)
    {
        x += readint();
    }
    if (x > n)
    {
        printf("-1\n");
    } else
    {
        printf("%d\n", n - x );
    }
    return 0;
}




Measured memory_bytes: 3116
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


vector<pi>vec;
int n;
bool chk(int id)
{
    int yo=vec[id].fi;
    for(int i=0;i<n;i++)
    {
          if(i==id)continue;
          if(vec[i].fi<=2*yo)
          {
              yo+=vec[i].fi;
          }
          else
          {
              return false;
          }
    }
    return true;
}
 main()

{
    fast
    int x;
    cin>>n;
    f(i,1,n)
    {
        cin>>x;
        vec.pb(mp(x,i));
    }
    sort(vec.begin(),vec.end());
    int lo=0;
    int hi=n-1;
    while(hi-lo>=2)
    {
        int mid=(lo+hi)>>1;
        if(chk(mid))
        {
            hi=mid;
        }
        else lo=mid+1;
    }
    f(i,lo,hi)
    {
        if(chk(i))
        {
            cout<<n-i<<endl;
            break;
        }
    }
    return 0;

}













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

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

  int n;
  string s;
  cin >> n >> s;

  int answer = 0;
  int l = 0, r = n - 1;
  while(l < r) {
    while(s[l] != 'W' && l < n) l++;
    if(r <= l) break;
    while(s[r] != 'R' && r >= 0) r--;
    s[l] = 'R';
    s[r] = 'W';
    if(r <= l) break;

    answer++;
  }
  cout << answer << endl;
}

Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

bool comp(ll a,ll b){
    return abs(a)>abs(b);
}
ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%i_7;
        }
        i=(i*i)%i_7;
        y=y/2;
        
    }
    return ans;
}

int main(){
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n,comp);
    ll p=0;
    ll bol=0;
    ll ans=1;
    rep(i,0,n-1){
        if(a[i]<0){
            p++;
        }
    }
    if(k==n){
        rep(i,0,n-1){
            ans=mod(ans*a[i]);
        }
        cout<<mod(ans)<<endl;
        return 0;
    }else if(k%2==1 && p==n){
        rep(i,n-k,n-1){
            ans=mod(ans*a[i]);
        }
        cout<<mod(ans)<<endl;
        return 0;
    }
    ll m_p[2];rep(i,0,1)m_p[i]=inf;
    ll m_n[2];rep(i,0,1)m_n[i]=inf;
    rep(i,0,k-1){
        ans=mod(ans*a[i]);
        if(a[i]<0){
            bol=(bol+1)%2;
            m_n[0]=-a[i];
        }else{
            m_p[0]=a[i];
        }
    }
    rep(i,k,n-1){
        if(a[i]<0 && m_n[1]==inf){
            m_n[1]=-a[i];
        }else if(a[i]>=0 && m_p[1]==inf){
            m_p[1]=a[i];
        }
    }
    if(bol==0){
        cout<<mod(ans)<<endl;
    }else{
        if(m_p[1]!=inf && m_n[0]!=inf){
            if(m_p[0]!=inf && m_n[1]!=inf){
                if(m_p[1]*m_p[0]>=m_n[1]*m_n[0]){
                    ans=mod(ans*m_p[1]);
                    ans=mod(ans*hpow(-m_n[0],i_7-2));
                }else{
                    ans=mod(-ans*m_n[1]);
                    ans=mod(ans*hpow(m_p[0],i_7-2));
                }
            }else{
                ans=mod(ans*m_p[1]);
                ans=mod(ans*hpow(-m_n[0],i_7-2));
            }
        }else{
            if(m_p[0]!=inf && m_n[1]!=inf){
                ans=mod(-ans*m_n[1]);
                ans=mod(ans*hpow(m_p[0],i_7-2));
            }else{
                ans=1;
                rep(i,n-k,n-1){
                    ans=mod(ans*a[i]);
                }
            }
        }
        cout<<mod(ans)<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 5116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main(){
    ll n, m; cin >> n >> m;
    vector <ll> X, Y;
    for (ll i = 0; i < n; i++){
        ll x; cin >> x;
        X.push_back(x);
    }
    for (ll i = 0; i < m; i++){
        ll y; cin >> y;
        Y.push_back(y);
    }
    vector <ll> A, B;
    for (ll i = 1; i < n; i++)
        A.push_back(i * (n-i));
    for (ll i = 1; i < m; i++)
        B.push_back(i * (m-i));
    vector <ll> X_breadth, Y_breadth;
    for (ll i = 1; i < n; i++)
        X_breadth.push_back(X[i]-X[i-1]);
    for (ll i = 1; i < m; i++)
        Y_breadth.push_back(Y[i]-Y[i-1]);
    ll line = 0;
    for (ll i = 0; i < X_breadth.size(); i++){
        line += A[i] * X_breadth[i];line %= mod;}
    ll ans = 0;
    for (ll i = 0; i < Y_breadth.size(); i++){
        ll buff = line * Y_breadth[i];
        buff %= mod;
        ans += buff * B[i]; 
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5748
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextLong();
		}
		
		int count = 0;
		boolean hasOdd = false;
		while(true) {
			for (int i = 0; i < n; i++) {
				if (a[i] % 2 != 0) {
					hasOdd = true;
					break;
				}
			}
			if (hasOdd) {
				break;
			}
			for (int i = 0; i < n; i++) {
				a[i] = a[i] / 2;
			}
			count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23892
S = list("1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
.split(", "))
K = int(input());
print(S[K - 1])


Measured memory_bytes: 2940
// Gracias, Rodolfo
// Gracias, Roman
// Gracias, Maxi
// Gracias, MarcosK
// Obrigado, Dilson
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for (int i = a; i < b; i++)
#define roF(i,a,b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()
#define SZ(v) ((int)v.size())

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int N = 1e6;
const ll INF = 1e18;
const ld EPS = 10e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll random(ll a, ll b) { return uniform_int_distribution<ll> (a, b) (rng); }

void solve() {
    long long n, x, y;
    cin >> n >> x >> y;
    long long cnt[n];
    for (int i = 0; i < n; i++) cnt[i] = 0;
    long long mini[n + 1][n + 1];
    for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) mini[i][j] = 0;
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int d1 = j - i;
            int d2 = abs(x - i) + 1 + abs(y - j);
            mini[i][j] = min(d1, d2);
        }
    }
    for (int i = 1; i < n; i++) for (int j = i + 1; j <= n; j++) cnt[mini[i][j]]++;
    for (int i = 1; i < n; i++) cout << cnt[i] << endl;	
}

int main() {
	fastio;
	int t = 1;
	while (t--) solve();
	return 0;
}

Measured memory_bytes: 31616
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char[] c = new char[s.length()];
    for (int i = 0; i < s.length(); i ++){
    	c[i] = s.charAt(i);
    }
    for(int j = 0; j < s.length(); j += 2) {
    	System.out.print(c[j]);
    }
  }
}

Measured memory_bytes: 27804
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MAX_INF 0x7f
#define MAX_INF_VAL 0x7f7f7f7f
#define pi 3.141592653589
#define eps 1e-6
//#define p 2173412051LL
//#define sz 2

using namespace std;

int n;
int ma[ 200010 ];
pair< int, int > a[ 200010 ];
int g[ 800040 ];
ll f[ 200010 ][ 2 ];

int find( int );
void modify( int, int, int, int, int );
int query( int, int, int, int, int );

int main() {
	int t;
	ll p = 998244353;
	scanf( "%d", &n );
	for( int i = 1; i <= n; ++i )
		scanf( "%d%d", &a[ i ].first, &a[ i ].second );
	sort( a + 1, a + 1 + n );
//for(int i=1;i<=n;++i)printf("%d\t%d\n",a[i].first,a[i].second);printf("\n");
	f[ n ][ 0 ] = f[ n ][ 1 ] = 1;
	ma[ n ] = n + 1;
	modify( 1, 1, n, n, ma[ n ] );
//for(int i=n-1;i;--i){int tmp=a[i].first+a[i].second,xxx=i+1;while(xxx<=n&&tmp>a[xxx].first){tmp=max(tmp,a[xxx].first+a[xxx].second);++xxx;}printf("%d\t%d\n",i,xxx);}
	for( int i = n - 1; i; --i ) {
		f[ i ][ 0 ] = ( f[ i + 1 ][ 0 ] + f[ i + 1 ][ 1 ] ) % p;
		t = find( a[ i ].first + a[ i ].second );
		if( t > i + 1 )
			ma[ i ] = query( 1, 1, n, i + 1, t - 1 );
		else
			ma[ i ] = t;
		modify( 1, 1, n, i, ma[ i ] );
//printf("%d\t%d\t%d\t",i,t,ma[i]);
		if( ma[ i ] <= n )
			f[ i ][ 1 ] = ( f[ ma[ i ] ][ 0 ] + f[ ma[ i ] ][ 1 ] ) % p;
		else
			f[ i ][ 1 ] = 1;
//printf("%lld\t%lld\n",f[i][0],f[i][1]);
	}
	printf( "%lld", ( f[ 1 ][ 0 ] + f[ 1 ][ 1 ] ) % p );
	return 0;
}

int find( int x ) {
	int l = 1, r = n, mid;
	while( l <= r ) {
		mid = l + r >> 1;
		if( a[ mid ].first >= x )
			r = mid - 1;
		else
			l = mid + 1;
	}
	return l;
}

void modify( int cur, int l, int r, int x, int k ) {
	int t, mid;
	if( x == l && x == r ) {
		g[ cur ] = k;
		return;
	}
	t = cur << 1;
	mid = l + r >> 1;
	if( x <= mid )
		modify( t, l, mid, x, k );
	else
		modify( t + 1, mid + 1, r, x, k );
	g[ cur ] = max( g[ t ], g[ t + 1 ] );
}

int query( int cur, int l, int r, int x, int y ) {
	int t, mid;
	int retl, retr;
	if( x == l && y == r )
		return g[ cur ];
	t = cur << 1;
	mid = l + r >> 1;
	retl = retr = 0;
	if( x <= mid )
		retl = query( t, l, mid, x, min( y, mid ) );
	if( y > mid )
		retr = query( t + 1, mid + 1, r, max( x, mid + 1 ), y );
	return max( retl, retr );
}

Measured memory_bytes: 8832
n,k=map(int,input().split())
M=10**9+7
a=list(map(int,input().split()))
cnt=[[0 for i in range(2)] for j in range(n)]
for i in range(n):
    for j in range(n):
        if j<i and a[j]<a[i]:
            cnt[i][0]+=1
        elif i<j and a[j]<a[i]:
            cnt[i][1]+=1
sum=0
for i in range(n):
    s=((k*(cnt[i][0]+cnt[i][1])+(cnt[i][1]-cnt[i][0]))*k)//2
    sum+=s
    sum%=M
print(sum)


Measured memory_bytes: 3416
#include <bits/stdc++.h>
#define N 200001
using namespace std;

typedef unsigned ui;
typedef long long ll;
typedef unsigned long long ul;

ul cut(ul x, ul y, ul u, ul v) {
	ul s1 = u * y, s2 = (x - u) * v, s3 = (x - u) * (y - v);
	return max({ s1, s2, s3 }) - min({ s1, s2, s3 });
}

int main(void) {
	ios::sync_with_stdio(0); cin.tie(0);
#ifdef _DEBUG
	ifstream cin("1.in");
#endif
	ul x, y; cin >> x >> y;
	if (x % 3 == 0 || y % 3 == 0)
		cout << 0 << endl;
	else cout << min({
		cut(x, y, x / 3, y / 2),
		cut(x, y, x / 3 + 1, y / 2),
		cut(x, y, x / 3 + 1, y / 2 + 1),
		cut(x, y, x / 3, y / 2 + 1),
		cut(y, x, y / 3, x / 2),
		cut(y, x, y / 3 + 1, x / 2),
		cut(y, x, y / 3 + 1, x / 2 + 1),
		cut(y, x, y / 3, x / 2 + 1),
		x,
		y
		});
	return 0;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll A, B;
    cin >> A >> B;
    ll ans = -1;
    for (ll i = 1; ; ++i)
    {
        if (i * 8 / 100 == A && i * 10 / 100 == B)
        {
            ans = i;
            break;
        }
        if (i * 8 / 100 > A) break;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val S = readLine()!!
    val max = Math.pow(2.0, (S.length-1).toDouble()).toInt()
    var ans= 0L
    for (i in 0 until max) {
        var pow2 = 1
        var sb = StringBuffer()
        for (j in S.indices) {
            sb.append(S[j])
            if (i and pow2 != 0) {
                ans += sb.toString().toLong()
                sb = StringBuffer()
            }
            pow2 *= 2
        }
        if (sb.isNotEmpty()) {
            ans += sb.toString().toLong()
        }
    }
    println(ans)
}



Measured memory_bytes: 35028
R,G,B,N = map(int,input().split())
ans = 0
for r in range(((N+R-1)//R)+1):
    for g in range(((N+G-1)//G)+1):
        if r*R+g*G>N:
            continue
        if (N-(r*R+g*G))%B == 0:
            ans += 1
print(ans)  

Measured memory_bytes: 40560
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

template<class T>
bool chmax(T &a, const T &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T>
bool chmin(T &a, const T &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}




int main(){
    stack<int> S;
   // int a, b, x;
    while(!cin.eof()){
        string s; cin >> s;
        if(s == "") break;
        if(s[0] == '+'){
            int b = S.top(); S.pop();
            int a = S.top(); S.pop();
            S.push(a + b);
          //  cout << a << " + " << b << " = " << a+b << "\n";
        }
        else if(s[0] == '-'){
            int b = S.top(); S.pop();
            int a = S.top(); S.pop();
            S.push(a - b);
          //  cout << a << " - " << b << " = " << a-b << "\n";
        }
        else if(s[0] == '*'){
            int b = S.top(); S.pop();
            int a = S.top(); S.pop();
            S.push(a * b);
           // cout << a << " * " << b << " = " << a*b << "\n";
        }else{
            S.push(stoi(s));
        }
    }
    cout << S.top() << "\n";
    return 0;
}



Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>

using namespace std;

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

const ll mod = 1e9 + 7;

int main() {

    
    int n, q;
    cin >> n >> q;
    
    vector<tuple<ll, ll, ll>> vt(n);
    set<P> sq;
    for (int i = 0; i < n; ++i)
    {
        ll s, t, x;
        cin >> s >> t >> x;
        vt[i] = make_tuple(x, s - x, t - x);
    }
    sort(vt.begin(), vt.end());
    
    for (int i = 0; i < q; ++i)
    {
        int d;
        cin >> d;
        sq.insert(make_pair(d, i));
    }
    
    int c = 0;
    vector<ll> ret(q, -1);
    for (int i = 0; i < n; ++i)
    {
        auto itrs = sq.lower_bound(make_pair(get<1>(vt[i]), -mod));
        auto itrt = sq.lower_bound(make_pair(get<2>(vt[i]), -mod));
        while (itrs != itrt)
        {
            ret[itrs->second] = get<0>(vt[i]);
            sq.erase(itrs++);
        }
    }
    
    for (int i = 0; i < q; ++i)
    {
        cout << ret[i] << endl;
    }
    
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  irep(i,1,n){
    if((n-i)%2) continue;
    string tmp=s.substr(0,n-i);
    ll m=tmp.size();
    if(tmp.substr(0,m/2)==tmp.substr(m/2)){
      cout<<n-i<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
from math import ceil, floor

N = int(input())
A = [int(t) for t in input().split()]
if len(A) != N: raise

p = [A[i-1] - i for i in range(1, N+1)]
p.sort()

q = []
for b in p[N//2 - 1 : N//2 + 2]:
    q.append(sum(abs(x - b) for x in p))
print(min(q))


Measured memory_bytes: 26832
#include <vector>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

using ll = long long;

//constant
const ll MOD = 1e+9 + 7;
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// view vector
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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

int main(void) {

    int h, n;
    cin >> h >> n;
    vector<ll> a(n);
    vector<ll> b(n);

    ll mx = 0;
    REP(i, n) {
        cin >> a[i] >> b[i];
        mx = max(mx, a[i]);
    }


    vector<ll> dp(h + mx + 1, 1e10);
    dp[0] = 0;

    REP(i, n) {
        REP(j, h) {
            if (dp[j] != 1e10)
                dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
        }
    }

    ll ans = 1e10;
    for (auto itr = dp.begin() + h; itr != dp.end(); itr++) {
        ans = min(ans, *itr);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int K=20;
const int N=1e6;
int n,head[N+10],tot=0;
struct data {
    int next,num;
}edge[N+10];
void Add(int u,int v) {
    edge[++tot].next=head[u];
    edge[tot].num=v;
    head[u]=tot;
}
int dfs(int x,int fat) {
    int nowx=0,maxbit=-1;
    for (int i=head[x];i!=-1;i=edge[i].next) {
        int kx=edge[i].num;
        if (kx==fat) continue;
        int nowv=dfs(kx,x);
        for (int j=0;j<=K;j++)
            if ((nowv&(1<<j))&&(nowx&(1<<j)))
                maxbit=max(maxbit,j);
        nowx|=nowv;
    }
    for (int j=0;j<=maxbit;j++)
        if (nowx&(1<<j)) nowx^=(1<<j);
    for (int j=maxbit+1;j<=K;j++)
        if ((nowx&(1<<j))==0) {
            nowx|=(1<<j);
            return nowx;
        }
        else nowx^=(1<<j);
    return 233;
}
int main() {
    memset(head,-1,sizeof(head));
    scanf("%d",&n);
    for (int i=1;i<n;i++) {
        int u,v;
        scanf("%d%d",&u,&v);
        Add(u,v);
        Add(v,u);
    }
    int ans=dfs(1,-1);
    for (int i=K;i>=0;i--)
        if (ans&(1<<i)) {
            printf("%d\n",i);
            return 0;
        }
    return 0;
}


Measured memory_bytes: 10752
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>

using namespace std;

int main()
{
	int nmin,nmax,m,temp,n;
	int p[200];

	start:

	scanf("%d %d %d", &m,&nmin,&nmax);

	n = nmin;

	if (m == 0) {
		goto finish;
	}

	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}

	for (int i = 0; i < m-1; i++) {
		for (int j = i+1; j < m; j++) {
			if (p[i] < p[j]) {
				temp = p[i];
				p[i] = p[j];
				p[j] = temp;
			}
		}
	}

	for (int i = nmin-1; i <= nmax-1; i++) {
		if (p[n-1]-p[n] <= p[i] - p[i + 1]) {
			n = i+1;
		}
	}
	
	cout << n << endl;

	n = 0;

	goto start;

	finish:

	return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
typedef long long int lli;

int pow_int(int a, int x);

int main(){
    int n, k;
    cin >> n >> k;

    double possibility;
    if(k == 1){
        possibility = 1.0;
        cout << fixed;
        cout << setprecision(12) << possibility << endl;
        return 0;
    }


    int point[MAXSIZE];
    int num_front[MAXSIZE];
    if(k > n){
        for(int i = 1; i <= n; ++i){
            point[i] = i;
            num_front[i] = 0;
            while(point[i] < k){
                point[i] *= 2;
                num_front[i]++;
            }
            
            possibility += (1.0 / n) * (1.0 / pow_int(2, num_front[i]));
        }
    }else{
        for(int i = 1; i <= k - 1; ++i){
            point[i] = i;
            num_front[i] = 0;
            while(point[i] < k){
                point[i] *= 2;
                num_front[i]++;
            }
            
            possibility += (1.0 / n) * (1.0 / pow_int(2, num_front[i]));
        }

        possibility += (1.0 * (n - k + 1) / n);
    }

    cout << fixed;
    cout << setprecision(12) << possibility << endl;
    return 0;
}

int pow_int(int a, int x){
    int res = 1;
    for(int i = 0; i < x; ++i){
        res *= a;
    }
    return res;
}

Measured memory_bytes: 256
import sys, math

input = sys.stdin.readline
H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
max_a = max([a for a, b in ab])
dp = [math.inf] * (H+max_a+1)
dp[0] = 0
for i in range(H + 1):
    for a, b in ab:
        dp[i + a] = min(dp[i + a], dp[i] + b)
print(min(dp[H:]))


Measured memory_bytes: 73960
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const ll max_co = 3234600000;
vl ans;
int mod =1000000007;
int main(){
   int n;
   cin>>n;
   vi a(n);
   rep(i,n){
       cin>>a[i];
   }
   vi even(100005,0);
   vi odd(100005,0);
   rep(i,n){
       if(i%2==0){
           even[a[i]]++;
       }
       else odd[a[i]]++;
   }
   int e = max_element(been(even))-even.begin();
   int o = max_element(been(odd)) -odd.begin(); 
   ll ans = n-even[e]-odd[o]; 
   if(o==e){
       sort(been(even),greater<int>());
       sort(been(odd),greater<int>());
       ans = min(n-odd[0]-even[1],n-odd[1]-even[0]);
   }
   
   cout<<ans<<endl;

}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

//約数列挙 o(√n)
vector<int> divisor(int n) {
  vector<int> res;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  return res;
}

// エラトトステネスの篩を用いた高速な素因数分解
vector<int> sieve_prime_factor(size_t max) {
  vector<bool> IsPrime(max + 1, true);
  vector<int> prime(max + 1), spf(max + 1);
  IsPrime[0] = IsPrime[1] = false;  // 0,1の初期化
  for (size_t i = 2; i <= max; ++i) {
    if (IsPrime[i] == true)
      for (size_t j = i; j <= max; j += i) {
        IsPrime[j] = false;  //非素数を記録
        prime[j] = i;        //非素数を保存
      }
  }
  // prime[i]を用いて各iの素因数を列挙可能
  for (size_t i = 1; i <= max; ++i) {
    int now = i;
    while (now != 1) {
      spf[prime[now]]++;
      now /= prime[now];
    }
  }
  return spf;
}

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  // int spf = sieve_prime_factor(n+1);
  int cnt = 0;
  rep(i, 1, n + 1) {
    rep(j, 1, n + 1) {
      if (i * j >= n)
        break;
      else
        ++cnt;
    }
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 3636
N = int(input())
lp = list(map(int, input().split()))

cnt = 1
lmin = lp[0]
for i in range(1, N):
    if lp[i] < lmin:
        lmin = lp[i]
        cnt += 1
    elif lp[i] == 1:
        break

print(cnt)

Measured memory_bytes: 24744
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;

int main() {
  int N, M, num; ll tl=0, nl=0; cin >> N >> M;

  vector<vector<ll>> students(N, vector<ll>(2));
  rep(i, N) cin >> students.at(i).at(0) >> students.at(i).at(1);

  vector<vector<ll>> checks(M, vector<ll>(2));
  rep(i, M) cin >> checks.at(i).at(0) >> checks.at(i).at(1);

  rep(i, N)
  {
    num = 0; tl  = 10000000000;
    rep(j, M)
    {
      nl = abs(students.at(i).at(0)-checks.at(j).at(0)) + abs(students.at(i).at(1)-checks.at(j).at(1));
      // cout << "nl:" << nl << " tl:" << tl << endl;
      if (nl < tl) {num = j+1; tl = nl;}
    }
    cout << num << endl;
  }

}


Measured memory_bytes: 256
#!/usr/bin/env python

from sys import stdin

N,C,K=map(int,raw_input().split())
T=map(int,stdin.read().split())

T.sort()
t_star=T[0]
b_star=0
cnt=0
for b,t in enumerate(T):
    if t-t_star>K or b-b_star+1>C:
        cnt+=1
        t_star=t
        b_star=b

print cnt+1

Measured memory_bytes: 11324
import Data.List
import Data.Char

f :: Int -> String -> Int
f a bs
    | all (\x-> elem (intToDigit x) bs) ((map digitToInt . show) a) = a
    | otherwise = f (a + 1) bs

main :: IO ()
main = do
    [n,k] <- map read . words <$> getLine
    cs <- ("0123456789" \\) . concat . words <$> getLine
    putStrLn $ show $ f n cs

Measured memory_bytes: 892
N, X = map(int, input().split())

L = map(int, input().split())

def count_bound(L):
	s=0
	count = 0
	for l in L:
		if(s<=X):
			count+=1
		s+=l
	if(s<=X):
		count+=1
	return count

print(count_bound(L))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MAX=2;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        //???
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


//n!
ll fact_mod(ll n) {
    ll ret=1; 
    for(ll i=2;i<=n;i++) ret=ret*(i%mod)%mod;
    return ret;
}
 
// 繰り返し二乗法 
ll pow_mod(ll x, ll n){
    if(n==0) return 1;
    ll ret=pow_mod((x*x) % mod, n/2);
    if(n&1) ret=(ret*x)%mod;
    return ret;
}
 
//nCr O(r) nがでかくても安心
ll combination_mod(ll n, ll r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    ll a=1;
    //a=n!/(n-r)!=n~n-r+1までの総積->O(r)
    for(ll i=0;i<r;i++) a=a*((n-i)%mod)%mod;
    //b=inv(r!)
    ll b=pow_mod(fact_mod(r), mod-2);
    return (a%mod)*(b%mod)%mod;
}
 
ll inv_mod(ll n){
    // フェルマーの小定理
    return pow_mod(n,mod-2);
}




ll f(ll r,ll c){
    ll ret=combination_mod(r+c+2,r)*(c+2)%mod;
    ret-=r;
    if(ret<0) ret+=mod;
    ret--;
    if(ret<0) ret+=mod;
    ret=ret*inv_mod(r+1)%mod;
    // cout<<r<<' '<<c<<" : "<<ret<<endl;
    return ret;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    // COMinit();
    ll r1,c1,r2,c2;cin>>r1>>c1>>r2>>c2;
    ll ans=(f(r2,c2)+f(r1-1,c1-1)%mod)%mod;
    ans-=f(r2,c1-1);
    if(ans<0) ans+=mod;
    ans-=f(r1-1,c2);
    if(ans<0) ans+=mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
typedef long long ll;

ll A,B,S;

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

    cin>>A>>B;
    //handle first bit
    ll D = B-A;
    if( (A&1) )
    {
        if( D%4<2 )S|=1;
    }
    else
    {
        if( D%4==1 || D%4==2 )S|=1;
    }
    //handle greater bits
    ll bm=2;
    while( bm<=B )
    {
        ll bA=(bm&A),bB=(bm&B);
        if( bA && bB )
        {
            if( D%2+1==1 )S|=bm;
        }
        else if( bA )
        {
            if( ((A&(bm-1))+1)%2==0 )S|=bm;
        }
        else if( bB )
        {
            if( ((B&(bm-1))+1)%2==1 )S|=bm;
        }
        bm<<=1;
    }
    cout<<S<<'\n';

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

		String S = sc.next();

		if (S.matches (".*A.*") && S.matches (".*B.*") ){
				System.out.print("Yes");
		}else {
		System.out.print("No");
		}

	}
}





Measured memory_bytes: 21844
#include <stdio.h>

int main(void)
{
    int n, m;
    int c[64];
    int mini[65536];
    int i, j;
    const int MAXIMUM = 1000000;

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

    mini[0] = 0;
    for (i = 1; i <= n; i++){
        mini[i] = MAXIMUM;
    }
    for (i = 0; i < m; i++){
        for (j = 0; j <= n - c[i]; j++){
            if (mini[j + c[i]] > mini[j] + 1){
                mini[j + c[i]] = mini[j] + 1;
            }
        }
    }

    printf("%d\n", mini[n]);

    return (0);
}

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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> k(n);
  vector<vector<int>> a(n);
  int temp;
  for (size_t i = 0; i < n; i++) {
    cin>>k[i];
    for (size_t j = 0; j < k[i]; j++) {
      cin>>temp;
      a[i].push_back(temp);
    }
  }
  vector<int> v(m,0);
  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < k[i]; j++) {
      v[a[i][j]-1]++;
    }
  }
  int c=0;
  for (size_t i = 0; i < m; i++) {
    if(v[i]==n) c++;
  }
  cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n;
    cin>>n;
    map<string,ll>m;
    for(int i=0;i<n;i++)
    {
      string s;
      cin>>s;
      m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
    /*for(auto t:m)
    {
      cout<<t.fi<<" x "<<t.se<<endl;
    }*/
}
return 0;
}

Measured memory_bytes: 3664
#include<iostream>
using namespace std;
int A[2000001],B[2000001]={},n;
void CountingSort(int A[],int B[],int k){
    int C[10001];
    for(int i=0;i<=k;i++) C[i]=0;
    for(int i=0;i<n;i++) C[A[i]]++; 
    for(int i=1;i<=k;i++) C[i]+=C[i-1];
    for(int j=n-1;j>=0;j--){
        B[C[A[j]]] =A[j];
        C[A[j]]--;
    }
}
int main(){
 cin>>n;
 for(int i=0;i<n;i++) cin>>A[i];
CountingSort(A,B,10000);
for(int i=1;i<n+1;i++){
    if(i!=1) cout<<" "<<B[i];
    else cout<<B[i];
}
cout<<endl;
return 0;
}


Measured memory_bytes: 18732
<?php
	$n = trim(fgets(STDIN));
	$line = trim(fgets(STDIN));
	$arr = explode(" ", $line);

	$arr = array_reverse($arr);
	for ($i = 0; $i < $n; $i++) {
		echo $arr[$i];
		if ($i < $n-1) echo " ";
	}
	
	echo "\n";

Measured memory_bytes: 6588
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int N, L;
	int nakagawasyouko = 0, suzukisawa = 999999999;
	int i;
	if (scanf("%d%d", &N, &L) != 2) return 1;
	for (i = 1; i <= N; i++) {
		int azi = L + i - 1;
		if (abs(azi) < abs(suzukisawa)) suzukisawa = azi;
		nakagawasyouko += azi;
	}
	printf("%d\n", nakagawasyouko - suzukisawa);
	return 0;
}


Measured memory_bytes: 128
import java.util
 
import scala.io.StdIn
import scala.util.Try
 
object Main extends App {
  val INF: Long = 1e15.toLong
  val (n, x, y) = {
    val in = StdIn.readLine().split(" ").map(_.toInt)
    (in(0), in(1), in(2))
  }
  val sweets = for (_ <- 0 until n) yield {
    val k = StdIn.readLine().toInt
    for (_ <- 0 until k) yield {
      val in = StdIn.readLine().split(" ").map(_.toInt)
      Sweet(in(0), in(1), in(2))
    }
  }
 
  val dist = for (_ <- 0 until n) yield StdIn.readLine().split(" ").map(_.toLong)
  for (k <- 0 until n) for (i <- 0 until n) for (j <- 0 until n) dist(i)(j) = math.min(dist(i)(j), dist(i)(k) + dist(k)(j))
 
  val cost = Array.fill[Long](1 << n, n)(INF)
  cost(0)(0) = 0
  for (mask <- 0 until 1 << n)
    for (cur <- 0 until n)
      for (next <- 0 until n)
        if ((mask & (1 << next)) == 0) {
          val add = dist(cur)(next)
          cost(mask | (1 << next))(next) = math.min(cost(mask | (1 << next))(next), cost(mask)(cur) + add)
        }
 
 
  def knapsack(dp: Array[Long], available: Seq[Sweet]): Unit = {
    for {
      sweet <- available
      money <- 0 until sweet.price
    } {
      val deque = new util.ArrayDeque[(Int, Long)]()
      var num = 0
      while (num * sweet.price + money <= y) {
        val next = num * sweet.price + money
 
 
        val v = dp(next) - num * sweet.value
        while (!deque.isEmpty && deque.peekLast()._2 <= v) deque.pollLast()
        deque.addLast((num, v))
 
        dp(next) = deque.peekFirst()._2 + num * sweet.value
        if (deque.peekFirst()._1 == num - sweet.remain) deque.pollFirst()
 
        num += 1
      }
    }
    for (i <- 1 until dp.length) dp(i) = math.max(dp(i), dp(i - 1))
  }
 
 
  val prefix = n / 2
  val suffix = n - prefix
 
  val prefixDp = Array.fill[Long](1 << prefix, y + 1)(0)
  for (prefixMask <- 0 until 1 << prefix) {
    val mask = prefixMask << suffix
    val dp = prefixDp(prefixMask)
    val available = for {
      i <- 0 until n
      if (mask & (1 << i)) != 0
      sweet <- sweets(i)
    } yield sweet
    knapsack(dp, available)
  }
 
  val suffixDp = Array.fill[Long](1 << suffix, y + 1)(0)
  for (mask <- 0 until 1 << suffix) {
    val dp = suffixDp(mask)
    val available = for {
      i <- 0 until n
      if (mask & (1 << i)) != 0
      sweet <- sweets(i)
    } yield sweet
    knapsack(dp, available)
  }
  var ans = 0L
  for (mask <- 0 until 1 << n) {
    val suffixMask = mask & ((1 << suffix) - 1)
    val prefixMask = mask >> suffix
    val travelingCost = (for (last <- 0 until n) yield {
      cost(mask)(last) + dist(last)(0)
    }).min
    val money = math.min(x - travelingCost, y).toInt
    for (prefixMoney <- 0 to money) {
      val suffixMoney = money - prefixMoney
      val value = prefixDp(prefixMask)(prefixMoney) + suffixDp(suffixMask)(suffixMoney)
      ans = math.max(ans, value)
    }
  }
  println(ans)
 
  Try {
 
  }.recover {
    case e: Throwable => println(e)
  }
 
}
 
case class Sweet(price: Int, value: Int, remain: Int)

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll H, W, K;
    cin >> H >> W >> K;
    vector<string> C;
    for(i = 0; i < H; i++) {
        string c;
        cin >> c;
        C.push_back(c);
    }
    ll ans = 0;
    ll h, w;
    for(i = 0; i < 1 << H; i++) {
        for(j = 0; j < 1 << W; j++) {
            vector<string> D = C;
            for(h = 0; h < H; h++) {
                if(i & (1 << h)) {
                    for(w = 0; w < W; w++) {
                        D[h][w] = 'x';
                    }
                }
            }
            for(w = 0; w < W; w++) {
                if(j & (1 << w)) {
                    for(h = 0; h < H; h++) {
                        D[h][w] = 'x';
                    }
                }
            }
            ll b = 0;
            for(h = 0; h < H; h++) {
                for(w = 0; w < W; w++) {
                    if(D[h][w] == '#')
                        b++;
                }
            }
            if(b == K)
                ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636