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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"


template <typename T, typename K> struct P {
	T a; K b;
};

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
vector <P <ll, ll> >prime_factorize( ll N );
ll pow( ll a, ll n );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
int main( void ){
	// initialize();
	int N; cin >> N;
	int sum = 0;
	rep( i, 1, N + 1 ){
		int a; cin >> a;
		sum += ( a % 2 == 1 ) && ( i % 2 == 1 );
	}
	cout << sum << endl;
}

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

/*
 * @fn eratosthenes
 * @brief O(NloglogN)~=(N)
 * @param N: その数まで
 * @return 0 or 1 の配列 (boolは都合が悪い)
 */
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}

/*
 * @fn prime_factorize
 * @brief O(√N): 素因数分解
 * @param N: 素因数分解する数
 * @return vec: (a: 素数, b: 個数)
 */
vector <P <ll, ll> >prime_factorize( ll N ){
	vector <P <ll, ll> > vec;
	int lim = sqrt( N ) + 1;
	rep( i, 2, N + 1 ){
		if (i >= lim){
			vec.push_back( P <ll, ll>{N, 1} );
			break;
		}
		if (N % i == 0){
			vec.push_back( P <ll, ll>{i, 0} );
			while(N % i == 0){
				N /= i;
				vec.back().b++;
			}
		}
	}
	return vec;
}
/*
 * @fn pow
 * @brief a^n
 * @param a: 基数
 * @param n: 指数
 */
ll pow( ll a, ll n ) {
	ll res = 1;
	while (n > 0){
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

void initialize( void ){
	cout << fixed << setprecision( 10 );
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define alla(a,n) a, a + n
#define endstring std::string::npos
#define prtarr(n,len) {for(int i=0;i<len;i++) cout<<n[i]<<" "; cout<<"\n";}
#define prtpair(n) {cout<<n.fr<<" "<<n.sc<<"\n";}
#define Ataru main
using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
using namespace std;
int judge(int x,int y){
    cout<<"? "<<x+1<<" "<<y+1<<endl;
    int a; cin>>a;
    return a;
}
const ll INF= 0x3f3f3f3f;
const ll bignum=1e18;

string s;
vi lists;
int Ataru(){
    /// #jojofan
    /// #csgofan
    /// Author: Ataru
    //freopen("input.txt", "r", stdin) ;
    //freopen("output.txt", "w", stdout) ;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    cin>>s;
    if(s[(int)s.length()-1]!='s') s+='s';
    else{
        s+='e';
        s+='s';
    }
    cout<<s<<"\n";
    return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	cout << "a ";
	if(a<b) cout << "< ";
	if(a==b) cout << "== ";
	if(a>b) cout << "> ";
	cout << "b" << endl;
	
	
	return 0;
}


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

const ll INF = 1ll << 60;
ll MOD = 998244353;

int main()
{

    int n;
    cin >> n;
    vector<int> w(n + 1);
    w[0] = 0;
    REP(i, n)
    {
        int x = 0;
        cin >> x;
        w[i + 1] = w[i] + x;
        //cout << w[i + 1] << endl;
    }

    int left = 0, right = 0;

    int ans = 10000;

    for (int i = 1; i < n; ++i)
    {
        left = w[i + 1];
        right = w[n] - w[i + 1];
        //cout << left << " " << right << endl;
        ans = min(ans, abs(right - left));
    }

    cout << ans << endl;

    return 0;
}

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

int main(){

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


    return 0;
    }

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <climits>
#include <vector>
#include <queue>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	// bool minus = false; if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	return n; }
	// return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

#define v vector
struct graph {
	struct node {int n, w;};
	v<v<node>> nodes;

	void read(int n) {
		nodes.resize(n);
		for (auto &x: nodes) {
			in();
			for (int k = in(); k--;) {
				int c = in();
				x.push_back({c, in()});
			}
		}
	}

	v<node> dks() {
		v<node> w(nodes.size(), {0, INT_MAX});
		w[0].w = 0;
		priority_queue<node> q;
		q.push({0, 0});
		while (!q.empty()) {
			node n = q.top();
			q.pop();
			if (w[n.n].n)
				continue;
			w[n.n].n = 1;
			for (node &x: nodes[n.n]) {
				int a = n.w + x.w;
				if (w[x.n].w > a) {
					w[x.n].w = a;
					q.push({x.n, a});
				}
			}
		}
		return move(w);
	}
};

bool operator < (const graph::node &a, const graph::node &b) {
	return a.w > b.w;
}

int main() {
	graph g;
	g.read(in());
	int i = 0;
	for (auto &x: g.dks())
		out(i++, ' ', x.w, '\n');
}


Measured memory_bytes: 7284
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 5e18;
int power(int base,int n,int m = mod)
 {
  if(n == 0)
     return 1;
  if(n&1)
     {
      int y = power(base,n-1,m);
      return (y*base)%m;
     }
  else
     {
      int y = power(base,n/2,m);
      return (y*y)%m;
     }
 }
  
void solve()
  {
   int n;
   cin>>n;
   if(n == 1)
     {
      cout<<0;
      return;
     }
   int all = power(10ll,n);
   int only = (2*power(9ll,n))%mod; 
   int both = power(8ll,n);
   both %= mod;
   all = (all - only + mod)%mod;
   all = (all + both)%mod;
   cout<<all; 
  } 
int32_t main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
   /*int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10*6)

def main():
	n, k = map(int, input().split())
	a = list(map(int, input().split()))
	m = 0
	ans = 0
	x = [0] * 50
	for i in range(50, -1, -1):
		temp = 2 ** i
		if temp > k:
			continue
		for j in range(n):
			if temp ^ (temp & a[j]) != 0:
				x[i] += 1
		if x[i] > n-x[i] and m + temp <= k:
			m += temp
	for i in range(n):
		ans += m ^ a[i]
	print(ans)

main()

Measured memory_bytes: 14620
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 998244353;

ll a[3005];
ll dp[3005][3005];

int main()
{
    ll n, s;
    cin >> n >> s;
    for(int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= s; j++) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
        for(int j = a[i - 1]; j <= s; j++) dp[i][j] = (dp[i][j] + dp[i - 1][j - a[i - 1]]) % MOD;
        dp[i][a[i - 1]] = (dp[i][a[i - 1]] + i - 1) % MOD;
        ans = (ans + dp[i][s]) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 70656
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        Strategy strategy = new MyStrategy();
        strategy.solve(out, sc);
        out.flush();
    }
}

class MyStrategy implements Strategy {
    @Override
    public void solve(PrintWriter out, FastScanner sc) {
        String S = sc.next();
        if (S.equals("SUN")) {
            out.println(7);
        } else if(S.equals("MON")) {
            out.println(6);
        } else if(S.equals("TUE")) {
            out.println(5);
        } else if(S.equals("WED")) {
            out.println(4);
        } else if(S.equals("THU")) {
            out.println(3);
        } else if(S.equals("FRI")) {
            out.println(2);
        } else if(S.equals("SAT")) {
            out.println(1);
        }
    }
}

interface Strategy {
    void solve(PrintWriter out, FastScanner sc);
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21460
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if(i==0||i==h-1||j==0||j==w-1)
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
AC;
long long n,m;
scanf("%lld %lld",&n,&m);
if(n>m){
    long long res=n/m;
    n-=(res*m);
    if(abs(n-m)<n){
        printf("%lld",abs(n-m));
    }
    else{
        printf("%lld",n);
    }
}
else if(n<m){
    if(abs(n-m)<n){
        printf("%lld",abs(n-m));
    }
    else{
         printf("%lld",n);
    }
}
else{
    printf("0");
}





    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int N=1000000+10;
int n,q;
int s[N],t[N],x[N],d[N];
vector<int> v;
int id(int x){
    return lower_bound(v.begin(),v.end(),x)-v.begin()+1;
}
const int inf = 1e9 + 7;
int mn[N<<2],lz[N<<2];
void pushdown(int rt){
    if(lz[rt]!=inf){
        mn[rt<<1]=min(mn[rt<<1],lz[rt]);
        lz[rt<<1]=min(lz[rt<<1],lz[rt]);
        mn[rt<<1|1]=min(mn[rt<<1|1],lz[rt]);
        lz[rt<<1|1]=min(lz[rt<<1|1],lz[rt]);
        lz[rt]=inf;
    }
}
void update(int l,int r,int rt,int L,int R,int x) {
    if(L<=l&&r<=R) {
        mn[rt]=min(mn[rt],x); lz[rt]=min(lz[rt],x);
        return;
    }
    int mid=(l+r)>>1; pushdown(rt);
    if(L<=mid) update(l,mid,rt<<1,L,R,x);
    if(R >mid) update(mid+1,r,rt<<1|1,L,R,x);
    mn[rt]=min(mn[rt<<1],mn[rt<<1|1]);
}
int query(int l,int r,int rt,int L,int R){
    if(L<=l&&r<=R)return mn[rt];
    int mid=(l+r)>>1; pushdown(rt);
    int ans=inf;
    if(L<=mid) ans=min(ans,query(l,mid,rt<<1,L,R));
    if(R >mid) ans=min(ans,query(mid+1,r,rt<<1|1,L,R));
    return ans;
}
int main() {
    scanf("%d%d",&n,&q);
    bool bu[N] = {0};
    for(int i=1;i<=n;i++) {
        scanf("%d%d%d",&s[i],&t[i],&x[i]); 
        if(t[i]-1<x[i]) bu[i]=1;
        --t[i];
        s[i]=max(s[i]-x[i],0);
        t[i]=max(t[i]-x[i],0);
        v.push_back(s[i]); v.push_back(t[i]);
    }
    for(int i=1;i<=q;i++){
        scanf("%d",&d[i]);
        v.push_back(d[i]);
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    for(int i=0;i<N<<2;i++) mn[i]=lz[i]=inf;
    for(int i=1;i<=n;i++) if(!bu[i]) {
        update(1,v.size(),1,id(s[i]),id(t[i]),x[i]);
    }
    for(int i=1;i<=q;i++){
        int res=query(1,v.size(),1,id(d[i]),id(d[i]));
        if(res==inf) res=-1;
        printf("%d\n", res);
    }
}




Measured memory_bytes: 46700
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
#define mk make_pair
using namespace std;
int main(){
  string s;
  int sum=1e9;
  cin>>s;
  for(int i=0;i<26;i++){
    char c=i+'a';
    int w=0,p=0;
    string t=s;
    t+=c;
    for(int j=0;j<t.size();j++){
      if(t[j]==c){
        w=max(w,p);
        p=0;
      }
      else p++;
    }
    sum=min(w,sum);
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
#define P pair<int,int>
typedef long long ll;
using namespace std;
vector<vector<P> > ki;
vector<int> visit;
vector<int> ans;

int main(){
    int n; cin >> n;
    ki.resize(n);
    visit.resize(n);
    ans.resize(n);
    rep(i,n) visit[i]=0;
    rep(i,n-1){
        int u,v,w; cin >> u >> v >> w;
        u--; v--;
        ki[u].push_back(P(v,w));
        ki[v].push_back(P(u,w));
    }
    queue<P> p;
    p.push(P(0,0));
    while(!p.empty()){
        int now=p.front().first;
        int bb=p.front().second;
        p.pop();
        visit[now]++;
        rep(i,ki[now].size()){
            int b=bb;
            if(!visit[ki[now][i].first]){
                if(ki[now][i].second%2==0){
                    ans[ki[now][i].first]=b;
                    p.push(P(ki[now][i].first,b));
                }
                else{
                if(b==1) b=0;
                else b=1;
                ans[ki[now][i].first]=b;
                p.push(P(ki[now][i].first,b));
                }
            }
        }
    }
    rep(i,n) cout << ans[i] << endl;
return 0;
}


Measured memory_bytes: 7168
#include <iostream>

using namespace std;

int main(void){
  int n, sum=0, tmp;
  cin >> n;
  int value[20], cost[20];

  for(int i=0; i<n; i++){
    cin >> value[i];
  }
  for(int i=0; i<n; i++){
    cin >> cost[i];
  }

  for(int i=0; i<n; i++){
    tmp = (value[i]-cost[i]);
    if(tmp > 0) sum += tmp;
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N;

    int t=1;
    cin>>N;
    int H[N+10];
    for(int i=0;i<=N;i++){
        cin>>H[i];
    }
    for(int i=N-1;i>0;i--){
       int d=H[i-1]-H[i];
        if(d==1){
            H[i-1]--;
        }else if(d>=2){
            t=0;
            break;
        }
    }    

if(t==1){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}


Measured memory_bytes: 640
import sys
import time

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10**5)


def main():
    n = int(input())
    a = list(map(int, readline().split()))
    node = {i: [] for i in range(n)}

    for _ in range(n - 1):
        u, v = map(int, readline().split())
        u, v = u - 1, v - 1
        node[u].append(v)
        node[v].append(u)

    ans = [0] * n
    dp = [INF] * n
    dp[0] = a[0]
    visited = [False] * n

    from collections import deque
    import bisect

    def dfs(cur):
        visited[cur] = True
        nv = a[cur]
        index = bisect.bisect_left(dp, nv)
        pv = dp[index]
        dp[index] = nv
        suc = node[cur]

        for nx in suc:
            if not visited[nx]:
                dfs(nx)

        ans[cur] = bisect.bisect_left(dp, INF)
        dp[index] = pv

    dfs(0)
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 365672
#include <bits/stdc++.h>
using namespace std;
#define MAX 123123
int a[MAX],N;

int main(){
  cin >> N;
  int n4=0,odd=0;
  for(int i=0;i<N;i++){
    cin >> a[i];
    if(a[i]%4==0)n4++;
    if(a[i]%2==1)odd++;
  }
  if(n4>=odd)cout << "Yes" << endl;
  else if(n4+odd==N&&n4+1>=odd) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
def choose(D, c, s, d, last, depth, p):
    maxpoint = -999999999
    maxnum = 0
    if depth > 0 and d < D:
        for i in range(26):
            point = p
            point += s[d][i]
            point += changepoint(c, d, i, last)*1
            nlast = []
            nlast.extend(last)
            nlast[i] = d
            z, point = choose(D, c, s, d+1, nlast, depth-1, point)
            if point > maxpoint:
                maxpoint = point
                maxnum = i
        return maxnum, maxpoint
    return 0, p


def changepoint(c, d, num, last):
    point = 0
    for j in range(26):
        if j != num:
            point -= c[j]*(d-last[j])
    return point


def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = []
    last = [-1]*26
    for _ in range(D):
        s.append(list(map(int, input().split())))
    point = 0
    for i in range(D):
        num, point = choose(D, c, s, i, last, 2, 0)
        last[num] = i
        print(num+1)


main()


Measured memory_bytes: 75028
#include <iostream>
using namespace std;
int main(void){
    int A,B,count,a,b;
    cin >> A >> B;
    
    a = A - 1;
    b = B -1;
    if (A == B){
        count = 1;
    }else{
        count = (b + (a - 1)) / a;
        }
    cout << count <<endl;
}

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


int main(){
    string str;
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    cin >> str;

    reverse(str.begin(),str.end());
    for(int i=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());

    int i=0;
    for(;i<str.size();){
        bool can2 = false;
        for(int j=0;j<4;j++){
            string d = divide[j];
            if(str.substr(i,d.size()) == d){
                can2 = true;
                i += d.size();
            }
        }
        if(can2 == false){
            break;
        }
    }
    string ans = "NO";
    if(i == str.size()){
        ans = "YES";
    }
    cout << ans << endl;
}


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

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

  int64_t N, K; 
  cin >> N >> K; 

  vector<int64_t> tmp; 
  tmp.push_back(abs(N%K - K)); 
  tmp.push_back(N%K); 
  cout << *min_element(tmp.begin(), tmp.end()); 

  return 0;
}


Measured memory_bytes: 3632
/**
 * author  : UshanGhosh
 * created : 2020-08-22 23:49:56
**/ 

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

#define    ll      long long
#define    pii     pair<int,int>
#define    vii     vector<int>
#define    vcc     vector<char>
#define    pll     pair<long long, long long>
#define    mem     memset
#define    sof     sizeof
#define    co1     __builtin_popcountll
#define    PB      push_back
#define    UB      upper_bound
#define    LB      lower_bound
#define    MP      make_pair
#define    TS      to_string
#define    F       first
#define    S       second
#define    pi      acos(-1)
#define    mod     1e9+7
#define    inf     1e18
#define    endl    '\n'

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    while(t--){
        long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
        cin>>n;
        ll ar[n+1], mx[n+1], pmax = 0;
        for(i=1;i<=n;i++){
            cin>>ar[i];
            pmax=max(pmax,ar[i]);
            mx[i]=pmax;
        }
        ll ans = 0;
        for(i=n;i>0;i--){
            ans+=max((ll)0, mx[i]-ar[i]);
        }
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 6756
#include <iostream>
using namespace std;
typedef long long ll;
ll B[64];
int main() {
  ios::sync_with_stdio(false);
  int N;
  ll K, A;
  cin >> N >> K;
  for (int i=0; i<N; i++) {
    cin >> A;
    for (int j=0; j<64; j++) {
      B[j] += A & 1;
      A >>= 1;
    }
  }
  int msb = 0;
  ll L = K;
  while (L > 0) {
    L >>= 1;
    msb++;
  }
  ll r0 = 0;
  ll r1 = 0;
  int f = 0;
  for (int i=60; i>=msb; i--) {
    r0 += B[i] * (1LL << i);
    r1 += B[i] * (1LL << i);
  }
  for (int i=msb-1; i>=msb-1 && i >= 0; i--) {
    r0 += (    B[i]) * (1LL << i);
    r1 += (N - B[i]) * (1LL << i);
  }
  for (int i=msb-2; i>=0; i--) {
    ll d0 = (    B[i]) * (1LL << i);
    ll d1 = (N - B[i]) * (1LL << i);
    r0 += max(d0, d1);
    if (f) {
      r1 += max(d0, d1);
    } else {
      if (K & (1LL << i)) {
        if (d0 < d1) {
          r1 += d1;
        } else {
          r1 += d0;
          f = 1;
        }
      } else {
        r1 += d0;
      }
    }
  }
  cout << max(r0, r1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>
using namespace std;

int main()
{
    int n;cin>>n;
    vector<int> v;
    int b=0;
    int tn=n;
    for(int i=0;i<n;i++){
        b=(b<<1|1);
        v.push_back(i);
    }
    for(int i=0;i<=b;i++){
        cout<<i<<":";
        int ti=i;
        for(int i=0;i<n;i++){
            if(ti&1){
                cout<<" "<<v[i];
            }
            ti>>=1;
        }
        cout<<"\n";
    }
}





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

int main(){
  int m1,d1,m2,d2 ;
  cin >> m1 >> d1 >> m2 >> d2 ;
  if(d1+1==d2){
    cout << 0 << endl ;
  }else {
    cout << 1 << endl ;
  }
}

Measured memory_bytes: 256
#define R(i,n) for (int i=0;i<(n);i++)
#include <bits/stdc++.h>
using namespace std;int n,k,x,y,b,h[2001][2001];char c;int main(){cin>>n>>k;R(i,n){cin>>x>>y>>c;b=c=='B';x%=2*k;if(x>=k){x-=k;b^=1;}y%=2*k;if(y>=k){y-=k;b^=1;}if(b){h[0][0]++;h[x][0]--;h[0][y]--;h[x][y]+=2;}else{h[0][y]++;h[x][y]-=2;h[x][0]++;}}R(i,k)R(j,k)h[i][j+1]+=h[i][j];R(i,k)R(j,k){h[i+1][j]+=h[i][j];b=max({b,n-h[i][j],h[i][j]});}cout<<b<<endl;}

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

int main() {
    long long N;
    cin >> N;
    int c, k;
    long long ans = 0;
    for (long long i = 2; i*i < N; i++) {
        c = 0;
        while (N % i == 0) {
            c++;
            N /= i;
        }
        k = 1;
        while(k*(k+1)/2 <= c) {
            k++;
            ans++;
        }
    }
    if (N > 1) {
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep1(i, n) for(ll i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(a);
  sort(c);
  ll ans = 0;
  rep(i,n){
    ll ok = -1, ng = n;
    while(abs(ok - ng) > 1){
      ll cen = (ok + ng) / 2;
      if(a[cen] < b[i]) ok = cen;
      else ng = cen;
    }
    ll arange = ok + 1;
    
    ok = n; ng = -1;
    while(abs(ok - ng) > 1){
      ll cen = (ok + ng) / 2;
      if(c[cen] > b[i]) ok = cen;
      else ng = cen;
    }
    ll crange = n - ok;
    
    ans += arange * crange;
  }
  cout << ans << endl;
}

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

int main() {
  int H, N, A;
  cin >> H >> N;

  int sum = 0;

  for (int i = 0; i < N; i++) {
    cin >> A;
    sum += A;
  }

  cout << (sum >= H ? "Yes" : "No") << endl;
}


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

int main(){
  int N, M, numbox, count = 0, ans = 0, check;
  cin >> N >> M ;
  ans += (N-1) * N / 2 ;
  ans += (M-1) * M / 2 ;
  cout << ans << endl ;
  return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    char ch;
    while (1)
    {
        scanf("%c", &ch);
        if (isalpha(ch))
        {
            if (islower(ch))
            {
                printf("%c", toupper(ch));
            }
            else
            {
                printf("%c", tolower(ch));
            }
        }
        else
        {
            printf("%c", ch);
        }
        if (ch == '\n') break;
    }
    
    return 0;
}


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

int main() {
  int N, A;
  cin >> N >> A;
  
  if (N % 500 == 0) {
    cout << "Yes" << endl;
  }
  
  else if (N % 500 < A) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int k;

 
int main(){
   
    ll n;
    cin >> n;
    ll ans_ = 0;
    rep(i, 200000){
        int a_3 = (i+1)*5;
        if(a_3 > n) break;
        if(a_3%3==0) ans_+=a_3;
    }
    ll wan = n*(n+1)/2;
    ll n_3 = n/3;
    ll n_5 = n/5;

    ll wa_3 = n_3 * (2 *3 + (n_3 - 1)*3)/2;
    ll wa_5 = n_5 * (2 *5 + (n_5 - 1)*5)/2;

    ll ans = wan - wa_3 - wa_5 + ans_;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1.0);
struct angle
{
    double minx,maxx;
}p[4010];
bool cmp(angle a,angle b)
{
    if (a.minx==b.minx) return a.maxx<b.maxx;
    else return a.minx<b.minx;
}
double ang(double y,double x)
{
    double ans;
    ans=atan2(y,x);
    if (ans<0) ans+=2*pi;
    return ans;
}
int main()
{
    double x1,x2,y1,y2,light;
    int n,i,j,ans,res;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
        if (x2>0 && y2>=0 && y1<0)
        {
            p[i].minx=ang(y1,x1);
            p[i].maxx=ang(y2,x1)+2*pi;
        }
        else
        {
            p[i].minx=min(min(ang(y1,x1),ang(y2,x1)),min(ang(y1,x2),ang(y2,x2)));
            p[i].maxx=max(max(ang(y1,x1),ang(y2,x1)),max(ang(y1,x2),ang(y2,x2)));
        }
    }
    for(i=1;i<=n;i++)
    {
        p[i+n].minx=p[i].minx+2*pi;
        p[i+n].maxx=p[i].maxx+2*pi;
    }
    sort(p+1,p+1+2*n,cmp);ans=0x3f3f3f3f;
    for(i=1;i<=n;i++)
    {
        light=-1;res=0;
        for(j=i;j<=i+n-1;j++)
        {
            if (light<p[j].minx)
            {
                res++;
                light=p[j].maxx;
            }
            else light=min(light,p[j].maxx);
        }
        if (res<ans) ans=res;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int d = x / 100;
        int e = x % 100;
        if (x > 2100 || (d > 0 && e <= d * 5)) {
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl v(n);rep(i,n)cin >> v[i];
    bool ok=false;
    rep(i,n)if(v[i]%2)ok=true;
    if(ok)cout << "first" <<endl;
    else cout << "second" <<endl;
}

Measured memory_bytes: 3964
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;


int main(){;
    int N, K;
    cin >> N >> K;
    vector<int> choku0, saka1;
    string S;
    cin >> S;
    int data;
    bool flag0 = false;
    bool flag1 = false;
    int len0 = 0;
    int len1 = 0; 

    for(int i = 0; i < N; i++){
        if(S[i] == '0'){
            if(flag1 == true){
                len0++;
                saka1.push_back(len1);
                len1 = 0;
                flag1 = false;
                flag0 = true;
            }
            else{
                len0++;
                flag0 = true;
            }
        }

        else{
            if(flag0 == true){
                len1++;
                choku0.push_back(len0);
                len0 = 0;
                flag0 = false;
                flag1 = true;
            }
            else{
                len1++;
                flag1 = true;
            }            
        }
        if(i == N - 1){
            if(flag0 == true) choku0.push_back(len0);
            else saka1.push_back(len1);
        }
    }
    if(flag0 == true) saka1.push_back(0);
    if(S[0] == '0') saka1.insert(saka1.begin(), 0);

    if(choku0.size() <= K) cout << N << endl;
    else{
        int ans = 0;
        for(int i = 0; i+K-1 < choku0.size(); i++){
            ans = max(accumulate(choku0.begin()+i, choku0.begin()+i+K, 0) + accumulate(saka1.begin()+i, saka1.begin()+i+K+1, 0), ans);
        }
        cout << ans << endl;
    }

}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
using Graph = vector<vector<ll>>;
#define all(x) (x).begin(), (x).end() //string の sort とかはこれ
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

const ll MOD = 1000000007;
const ll INF = 1e18; //1*10^18
const double PI = 3.14159265;

int ctoi(char c)
{
  if (c >= '0' && c <= '9')
  {
    return c - '0';
  }
  return 0;
}

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
//最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//最小公倍数

ll powll(ll a, ll n)
{ //O(log n)
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a;
    }
    a = a * a;
    n >>= 1; //(n & 1)=(n % 2 !=0)
  }
  return res;
}

ll modpow(ll a, ll n, ll mod) //O(log n)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1) //(n & 1)=(n % 2 !=0)
    {
      res = res * a % mod;
    }
    a = a * a % mod;
    n >>= 1; //(n>>=1)=(n/2)
  }
  return res;
}

int ReturnDigit(ll num)
{
  string number = to_string(num);
  return number.length();
}

const ll MAX = 1e6;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() //MODは素数じゃないとだよ！！
{
  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;
}

struct UnionFind
{
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N)
  { //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++)
      par[i] = i;
  }

  int root(int x)
  { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y)
  {                   // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry)
      return;     //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y)
  { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main()
{
  // COMinit();
  // srand((unsigned int)time(NULL));//--> rand()
  ll i, j, k, l, ans = 0;
  ll a, b;
  cin >> k >> a >> b;

  for (i = a; i <= b; i++)
  {
    if (i % k == 0)
    {
      cout << "OK";
      return 0;
    }
  }
  cout << "NG";
}


Measured memory_bytes: 3640
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

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

        int n = s.nextInt();

        int left = 0;
        int right = 0;
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
            right += arr[i];
        }
        int minDiff = right;

        for (int i = 0; i < n; i++) {
            left += arr[i];
            right -= arr[i];
            int diff = Math.abs(left - right);
            if (diff < minDiff) {
                minDiff = diff;
            }
        }
        System.out.println(minDiff);
    }
}


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

void fnInput(vector<int>& rvnTrg, vector<int>& rvnSch)
{
  int nTrgCnt;
  cin >> nTrgCnt;

  rvnTrg.resize(nTrgCnt + 1);
  for (int i = 0; i < nTrgCnt; i++)
    cin >> rvnTrg[i];

  int nSchCnt;
  cin >> nSchCnt;

  rvnSch.resize(nSchCnt);
  for (int i = 0; i < nSchCnt; i++)
    cin >> rvnSch[i];
}

void fnLinTrg(vector<int>& rvnTrg, const vector<int>& cnrvnSch, int& rnFnd)
{
  int nMaxSiz = rvnTrg.size() - 1;
  for (int nxSch = 0; nxSch < cnrvnSch.size(); ++nxSch)
  {
    rvnTrg[nMaxSiz] = cnrvnSch[nxSch];
    int nxTrg;
    for (nxTrg = 0; cnrvnSch[nxSch] != rvnTrg[nxTrg]; ++nxTrg);
    if (nxTrg != nMaxSiz)
      ++rnFnd;
  }
}

void fnResult(int nFnd)
{
  cout << nFnd << endl;
}

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

  vector<int> vnSch, vnTrg;
  int nFnd = 0;

  fnInput(vnTrg, vnSch);
  fnLinTrg(vnTrg, vnSch, nFnd);
  fnResult(nFnd);

  return 0;
}



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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int n = Integer.parseInt(br.readLine());
            int arr[] = new int[100];
            for (int i = 0; i < n; i++) {
                int tmp = Integer.parseInt(br.readLine());
                arr[tmp - 1]++;
            }
            int count = 0;
            for (int i = 0; i < 100; i++) {
                if (arr[i] > 0) {
                    count++;
                }
            }
            System.out.println(count);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


Measured memory_bytes: 21332
def main():
    n = int(input())
    A = list(map(int,input().split()))

    l = []
    s = 1000
    flg = 1
    b = A[0]
    i = 1
    while i < n:
        if flg == 1:
            if b >= A[i]:
                b = A[i]
                i += 1
            elif b < A[i]:
                l.append(b)
                b = A[i]
                flg = 0
        
        elif flg == 0:
            if b <= A[i]:
                b = A[i]
                i += 1
                if i == n:
                    l.append(b)
            elif b > A[i]:
                l.append(b)
                b = A[i]
                flg = 1
    
    if len(l)%2 != 0:
        exit(1)
    for i,j in enumerate(l):
        if i%2 == 0:
            t = s//j
            s -= t*j
        else:
            s += t*j
            t = 0

    print(s)

main()

Measured memory_bytes: 9240
#include <iostream>
using namespace std;
 
int main() {
	int a,b;
  	cin>>a>>b;
  
  	if(a<b){
    	cout<<"a < b"<<endl;
    }else if(a>b){
    	cout<<"a > b"<<endl;
    }else if(a==b){
    	cout<<"a == b"<<endl;
    }
}



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

while True:
    if len(A) == 1:
        break
    pop_i = []
    A.sort()
    for i in range(1, len(A)):
        life = A[i] % A[0]
        if life == 1:
            print(life)
            exit()
        else:
            A[i] = life
    A = [n for n in A if n > 0]

print(A[0])


Measured memory_bytes: 14224
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def solve():
    s = input()
    if s == "ABC":
        print("ARC")
    else:
        print("ABC")

    return 0

if __name__ == "__main__":# {{{
    solve()

# vim: set foldmethod=marker: }}}


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

int main() {
  int n;
  scanf("%d", &n);
  int a=n%10;
  if(a==2 || a==4|| a==5||a==7||a==9) printf("hon");
  else if (a==0||a==1||a==6||a==8) printf("pon");
  else printf("bon");
  return 0;
}

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

const ll mod = 1000000007;

bool isPrime(ll n){
	if(n == 1) return false;
	for (ll i = 2; i*i <= n; ++i) {
		if(n % i == 0) return false;
	}
	return true;
}

vector<ll> Prime(ll n){
	vector<ll> res;
	for (ll i = 1; i <= n; ++i) {
		if(isPrime(i)) res.push_back(i);
	}
	return res;
}
int main(){
	ll n;
	cin >> n;
	auto v = Prime(n);
	ll ans = 1;
	for(auto p: v){
		ll count = 0;
		for (int i = 2; i <= n; ++i) {
			if(i % p) continue;
			ll temp = i;
			while(temp > 0 && temp % p == 0){
				temp /= p;
				count++;
			}
		}
		ans *= count + 1;
		ans %= mod;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline()[:-1]

def dfs(now, parent, total):
    result[now] = total + counter[now]
    for child in tree[now]:
        if child == parent:
            continue
        dfs(child, now, result[now])

N, Q = map(int, input().split())
edge = [list(map(int, input().split())) for _ in range(N-1)]
P = [list(map(int, input().split())) for _ in range(Q)]

tree = [[] for _ in range(N+1)]
counter = [0 for _ in range(N+1)]

for a,b in edge:
    tree[a].append(b)
    tree[b].append(a)

for p,x in P:
    counter[p] += x

result = [0]*(N+1)
dfs(1, 0, 0)

print(' '.join(map(str, result[1:])))

Measured memory_bytes: 313104
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

a, b, c, d =  [int(readline()) for i in range(4)]
print(min(a + c, a + d, b + c, b + d))

Measured memory_bytes: 3060
input_list_len = int(input())
input_list = map(int, input().split())
even_list = input_list
even_list_len = input_list_len
count = 0

while True:
    even_list = list(filter(lambda num: num % 2 == 0, even_list))
    even_list_len = len(even_list)
    if input_list_len != even_list_len:
        break
    even_list = map(lambda num: num / 2, even_list)
    count += 1

print(count)

Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
	int x,h,m,s;
	scanf("%d", &x);
	h = x / 3600;
	m = (x%3600)/60;
	s = (x%3600)%60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 2e4 ;

ll gcd(ll a , ll b){
    if(!b)return a;
    return gcd(b,a % b);
}

ll lcm(ll a, ll b){
    return b /  gcd(a ,b) * a;
}

int main(){
    int n , m ;
    string x , y; 
    scanf("%d%d",&n,&m);
    cin >> x >> y; 
    ll f = lcm(n,m);
    ll a = n/gcd(n,m) , b = m / gcd(n,m);
    int p1 = 0 , p2 = 0 ;
    for(int i=0;i<gcd(n,m);++i){
        if(x[p1] != y[p2])return puts("-1"),0;
        p1+=a , p2 += b ;
    }
    printf("%lld",f);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mod 1000000007
using namespace std;

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
    fast();
    ll t=1,cnt=0,flag=0;
    cin>>t;
    vector<pair<ll,ll> >v;
    while(t--){
    	ll a,b;
    	cin>>a>>b;
    	v.pb({a,b});
	}
	for(ll i=2;i<v.size();i++){
		if(v[i].fi==v[i].se and v[i-1].fi==v[i-1].se and v[i-2].fi==v[i-2].se){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 3644
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using static System.Math;


class P
{
    static void Main()
    {
        int[] nab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int total = 0;
        int inter = 0;
        string s = Console.ReadLine();
        foreach (var c in s)
        {
            bool b = false;
            if(c == 'a')
            {
                if(total < nab[1] + nab[2])
                {
                    b = true;
                }
            }
            if(c == 'b')
            {
                if(total < nab[1] + nab[2] && inter < nab[2])
                {
                    b = true;
                    inter++;
                }
            }
            if (b)
            {
                total++;
                Console.WriteLine("Yes");

            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 15840
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

sys.setrecursionlimit(100000)
INF = float('inf')

X, Y = list(map(int, input().split()))


def solve(x, y):
    cnt = 0
    if abs(x) > abs(y) and x > 0 or abs(x) < abs(y) and x < 0:
        cnt += 1
        x = -x
    cnt += abs(abs(x) - abs(y))
    x += abs(abs(x) - abs(y))
    if x != y:
        cnt += 1
    return cnt


print(solve(X, Y))


Measured memory_bytes: 13576
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

#define rep(i,a,n) for (int i=(a);i<(n);++i)
#define per(i,a,n) for (int i=(n)-1;i>=(a);--i)

const int N=50+5;

int read() {int x;scanf("%d",&x);return x;}

int n;
int s[N];

int main() {
  n=read();
  rep (i,0,n) s[i]=read();
  int mn=1e9,mx=-1e9;
  int p=0;
  rep (i,0,n) mx=max(mx,s[i]),mn=min(mn,s[i]);
  printf("%d\n",2*n-1);
  if (abs(mx)>abs(mn)) {
    rep (i,0,n) if (s[i]==mx) p=i;
    rep (i,0,n) printf("%d %d\n",p+1,i+1);
    rep (i,1,n) printf("%d %d\n",i,i+1);
  } else {
    rep (i,0,n) if (s[i]==mn) p=i;
    rep (i,0,n) printf("%d %d\n",p+1,i+1);
    per (i,1,n) printf("%d %d\n",i+1,i);
  }
  return 0;
}


Measured memory_bytes: 256