akhauriyash/Code-Regression huggingface dataset:
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a,b) memset(a, b, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;
        ll n;cin>>n;
        map<ll,ll> mp;
        mp[1]=0;
        rep1(i,1,n-1){
            ll x;
            cin>>x;
            mp[x]++;
        }
        rep1(i,1,n){
            cout<<mp[i]<<endl;
        }


return 0;
}


Measured memory_bytes: 16096
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    char a,b; cin >> a >> b;
    if(a=='H') out(b);
    else if(b=='H') out('D');
    else out('H');

    return 0;
}

Measured memory_bytes: 256
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
per = list(itertools.permutations([i+1 for i in range(n)]))
for i in range(len(per)):
    if per[i] == p:
        a = i
    if per[i] == q:
        b = i
print(abs(a - b))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

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;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	cout<<min(((n+a-1)/a)*b,((n+c-1)/c)*d)<<endl;
}


Measured memory_bytes: 3200
/**************
*	??????????????????
*************/

#include <iostream>
#include <vector>	//??£?¨?
#include <climits>	//??¢??°
using namespace std;

//??\???
int merge(vector<int> &A, int left, int mid, int right)//??????????????°
{	
	int n1 = mid   - left;
	int n2 = right - mid;
	int merg_cnt = 0;
	//??????
	vector<int> L;
	L.resize(n1+1);
	vector<int> R;
	R.resize(n2+1);
	
	for(int i = 0; i< n1; i++){
		L[i] = A[left + i];
	}
	for(int i = 0; i< n2; i++){
		R[i] = A[mid + i];
	}
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	
	int i = 0;
	int j = 0;
	
	for(int k = left; k < right; k++){
		if( L[i] <= R[j] ){
			A[k] = L[i];
			i++;
		}
		else {
			A[k] = R[j];
			j++;
		}
		merg_cnt++;
	}
	return merg_cnt;
}
//--------------------------------------------
int mergeSort(vector<int> &A, int left, int right)//?????§
{
	int merg_cnt = 0;
	if((left+1) < right){
		int mid = (left + right)/2;
		merg_cnt += mergeSort(A, left, mid );
		merg_cnt += mergeSort(A, mid, right );
		merg_cnt += merge(A, left, mid, right );
	}
	return merg_cnt;
}
//--------------------------------------------
int main()
{
	int n;
	cin >> n;
	
	vector<int> S;
	S.resize(n);
	
	for(int i =0; i < n ;  i++){ 
		cin >> S[i] ;
	}
	
	int merg_cnt = 0;
	//????????????????????¢??°
	merg_cnt = mergeSort(S, 0, n);
	
	for(int i =0; i<n ; i++){
		cout << S[i] ;
		if(i != (n-1)){
			cout << " ";
		}
	}
	cout << endl << merg_cnt << endl;
	
	return 0;
}
//--------------------------------------------

Measured memory_bytes: 5064
h, w = map(int, input().split())
grid = ['.'*(w+2)]
for _ in range(h):
    line = '.' + input() + '.'
    grid.append(line)
grid.append('.'*(w+2))

for i in range(1, h+1):
    for j in range(1, w+1):
        if grid[i][j] == '.':
            continue
        else:
            up = grid[i-1][j]
            right = grid[i][j+1]
            left = grid[i][j-1]
            down = grid[i+1][j]

            if up + right + left + down == '....':
                print('No')
                exit()

print('Yes')

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, k;
string s;

int main() {
	cin >> n >> k >> s;
	
	if(n == 1) { cout << (k % 2 == 0 ? "B" : "A") << endl; return 0; }
	
	s += '#';
	deque<int> deq;
	incID(i, 1, n) {
		int j = i;
		while(s[i] == s[j]) { j++; }
		deq.PB(j - i);
		
		i = j - 1;
	}
	
	const int AA = 0, AB = 1, BA = 2, BB = 3;
	int v;
	if(s[0] == 'A' && s[1] == 'A') { v = AA; }
	if(s[0] == 'A' && s[1] == 'B') { v = AB; }
	if(s[0] == 'B' && s[1] == 'A') { v = BA; }
	if(s[0] == 'B' && s[1] == 'B') { v = BB; }
	
	int pc = 0;
	inc(i, k) {
		if(v == AA) { v = BA; continue; }
		if(v == AB) { v = BB; continue; }
		
		if(n <= pc) {
			if(n % 2 == 1 && (k - i) % 2 != 0) {
				v = (v == BA ? AA : AB);
			}
			break;
		}
		
		deq[0]--;
		if(s[n - 1] == 'B') {
			deq[deq.size() - 1]++;
			s[n - 1] = 'A';
		} else { deq.PB(1); }
		pc++;
		if(deq[0] == 0) {
			deq.pop_front();
			v = (v == BA ? BA : AB);
		} else {
			v = (v == BA ? BB : AA);
		}
	}
	
	if(v == AA || v == AB) { cout << "A"; }
	if(v == BA || v == BB) { cout << "B"; }
	
	char p;
	if(v == AA || v == BA) { p = 'A'; } else { p = 'B'; }
	inc(i, deq.size()) {
		inc(j, deq[i]) { cout << p; }
		p = (p == 'A' ? 'B' : 'A');
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 1540
/* ~created by Roh@n M@he$hwari~ */

#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,i,j;
	cin>>n;
	int h[n][3],dp[n][3];
	for(i=0;i<n;i++) cin>>h[i][0]>>h[i][1]>>h[i][2];
	dp[0][0]=h[0][0];
	dp[0][1]=h[0][1];
	dp[0][2]=h[0][2];
	for(i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+h[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+h[i][1];
		dp[i][2]=max(dp[i-1][1],dp[i-1][0])+h[i][2];
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;

bool dp[201][201];

int main(){
	int n,m;
	while(cin >> n){
		if(n==0) break;
		vector<int> h;
		vector<int> r;
		for(int i=0; i<n; ++i){
			int tmp1,tmp2;
			cin >> tmp1 >> tmp2;
			h.push_back(tmp1);
			r.push_back(tmp2);
		}
		cin >> m;
		for(int i=0; i<m; ++i){
			int tmp1,tmp2;
			cin >> tmp1 >> tmp2;
			h.push_back(tmp1);
			r.push_back(tmp2);
		}
		for(int i=0; i<=n+m; ++i){
			for(int j=0; j<n+m; ++j){
				dp[i][j]=false;
			}
		}
		for(int i=0; i<n+m; ++i){
			dp[1][i]=true;
		}
		for(int i=2; i<=n+m; ++i){
			for(int j=0; j<n+m; ++j){
				for(int k=0; k<n+m; ++k){
					if(h[k]<h[j]&&r[k]<r[j]&&dp[i-1][k]){
						dp[i][j]=true;
						break;
					}
				}
			}
		}
		int ans=0;
		for(int i=1; i<=n+m; ++i){
			for(int j=0; j<n+m; ++j){
				if(dp[i][j]) ans=max(ans,i);
			}
		}
		cout << ans << "\n";
	}
}

Measured memory_bytes: 1252
#include <stdio.h>

int main(void){
    int a,b, c;
    scanf("%d %d %d\n", &a, &b, &c);
    
    if ((a<b)&&(b<c)){
        printf("Yes\n");
    } else {
        printf("No\n");
    } 
    
    return 0;
}



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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

const ll mod = 1000000007;
//const ll mod = 998244353;

const int MAX_N = 2000020;
ll fact[MAX_N],fact_inv[MAX_N],inv[MAX_N];

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

void init(int x) {
    fact[0] = 1;fact[1] = 1;
    for (int i = 2;i <= x;++i) fact[i] = fact[i-1]*i%mod;
    fact_inv[x] = pow_mod(fact[x],-1);
    for (int i = x;i > 0;--i) fact_inv[i-1] = fact_inv[i]*i%mod;
    for (int i = 1;i <= x;++i) inv[i] = fact_inv[i]*fact[i-1]%mod;
}

ll combi(ll a, ll b) {
    return fact[a]*fact_inv[b]%mod*fact_inv[a-b]%mod;
}

int main() {
    ll r1,c1,r2,c2;
    cin >> r1 >> c1 >> r2 >> c2;
    init(2000010);
    cout << (combi(r2+c2+2,r2+1)+combi(r1+c1,r1)-combi(r2+c1+1,r2+1)-combi(r1+c2+1,r1)+mod+mod)%mod << endl;
}

Measured memory_bytes: 47104
def main():
    a, b, c = map(int, input().split())

    if c - a - b <= 0:
        print('No')
        exit()

    if 4 * a * b < pow(c - a - b, 2):
        is_big = True
    else:
        is_big = False

    print('Yes' if is_big else 'No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import java.util.Arrays;
import java.util.Scanner;
class Main{
	public static void main(String[] args){
	Scanner x=new Scanner(System.in);
        while(x.hasNext()){
            int m=x.nextInt();
            int[] A=new int[m];
            for(int i=0;i<m;i++){
                A[i]=x.nextInt();
            }
			int count=0;
            int n =A.length;
			for(int i=0;i<n;i++){
				int lowest = i;
				for(int j=i;j<n;j++){
					if(A[j]<A[lowest]){
						lowest = j;					
					}
				}
				if(lowest!=i){
					int temp =A[i];
				    A[i] = A[lowest];
				    A[lowest] = temp;
				    count++;
				}
			}
			Show(A);
			System.out.println(count);
			break;
		}
	}	
	public static void Show(int[] A){
	    int i;
		for(i=0;i<A.length-1;i++){
			System.out.print(A[i]+" ");
		}
		System.out.println(A[i]);
	}
}	



Measured memory_bytes: 26372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[105][4][4][4];

int main(){
    int n;
    cin >> n;
    mint ans(0);
    rep(j, 4) rep(k, 4) rep(l, 4) {
        if (j==0 && k==2 && l==1) continue;
        if (j==0 && k==1 && l==2) continue;
        if (j==2 && k==0 && l==1) continue;
        dp[2][j][k][l] = mint(1);
    }
    for (int i=2; i<=n-2; i++) {
        rep(j, 4) rep(k, 4) rep(l, 4) {
            vector<bool> flg(4, true);
            if (k==0 && l==1) flg[2] = false;
            if (k==0 && l==2) flg[1] = false;
            if (k==2 && l==0) flg[1] = false;
            if (j==0 && k==2) flg[1] = false;
            if (j==0 && l==2) flg[1] = false;
            int nj = k;
            int nk = l;
            rep(nl, 4) {
                if (flg[nl]) dp[i+1][nj][nk][nl] += dp[i][j][k][l];
            }
        }
        
        
    }
    rep(j, 4) rep(k, 4) rep(l, 4) {
        ans += dp[n-1][j][k][l];
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    unordered_map<string, int> card;
    int n, m;
    cin >> n;
    while(n--){
        string s;
        cin >> s;
        card[s]++;
    }
    cin >> m;
    while(m--){
        string t;
        cin >> t;
        card[t]--;
    }
    int ans = 0;
    for(auto x: card){
        ans = max(ans, x.second);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>

using namespace std;
typedef long long ll;

vector<ll> list;
ll N, A, B;

bool isOK(ll x) {
  ll num = 0;
  for (int i = 0; i < N; i++) {
    ll hp = list[i] - (x * B);
    if (hp > 0) {
      ll cnt = hp / (A - B);
      if (hp % (A - B)) {
        cnt++;
      }
      num += cnt;
    }
  }
  return x >= num;
}

ll binary_search() {
  ll left = -1;
  ll right = 1e9 + 10;
  
  while (right - left > 1) {
    ll mid = left + (right - left) / 2;
    
    if (isOK(mid)) right = mid;
    else left = mid;
  }
  return right;
}

int main() {
  cin >> N >> A >> B;
  list.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> list[i];
  }
  cout << binary_search() << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
 
//const int MOD=998244353;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int a,b;
    cin>>a>>b;
    
    cout<< a/b+(bool)(a%b);
    
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		int k;
		cin >> k;
		int a[8];
		a[0] = k/10000000;
		a[1] = k/1000000 - a[0]*10;
		a[2] = k/100000-a[0]*100-a[1]*10;
		a[3] = k/10000-a[0]*1000-a[1]*100-a[2]*10;
		a[4] = k/1000-a[0]*10000-a[1]*1000-a[2]*100-a[3]*10;
		a[5] = k/100-a[0]*100000-a[1]*10000-a[2]*1000-a[3]*100-a[4]*10;
		a[6] = k/10-a[0]*1000000-a[1]*100000-a[2]*10000-a[3]*1000-a[4]*100-a[5]*10;
		a[7] = k - a[0]*10000000-a[1]*1000000-a[2]*100000-a[3]*10000-a[4]*1000-a[5]*100-a[6]*10;
		sort(a,a+8);
		int b,c;
		b = a[7]*10000000+a[6]*1000000+a[5]*100000+a[4]*10000+a[3]*1000+a[2]*100+a[1]*10+a[0];
		c = a[0]*10000000+a[1]*1000000+a[2]*100000+a[3]*10000+a[4]*1000+a[5]*100+a[6]*10+a[7];

		cout << b-c << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int peopleNum = scanner.nextInt();
        int[] array = new int[peopleNum];
        for (int i = 0; i < peopleNum; i++) {
            int rate = scanner.nextInt();
            array[i] = judgeColor(rate);
        }
        Arrays.sort(array);
        ArrayList<Integer> newArray = new ArrayList<Integer>();

        for (int j = 0; j < array.length-1; j++) {
            if (array[j] != array[j+1]) {
                newArray.add(array[j]);
            } else if (array[j] == 9 && array[j+1] == 9) {
                newArray.add(array[j]);
            }
        }
        newArray.add(array[array.length-1]);

        int freeColorCnt = 0;
        for (int k = 0; k < newArray.size(); k++) {
            if (newArray.get(k) == 9) {
                freeColorCnt++;
            }
        }

        int minColorCnt = newArray.size() - freeColorCnt;
        int maxColorCnt = minColorCnt + freeColorCnt;

        if(newArray.size() == freeColorCnt) {
            minColorCnt = 1;
            maxColorCnt = freeColorCnt;
        }
        System.out.println(minColorCnt + " " + maxColorCnt);
    }
    public static int judgeColor(int rate) {
        if(rate >= 1 && rate <= 399) {
            return 1;
        } else if (rate >= 400 && rate <= 799) {
            return 2;
        } else if (rate >= 800 && rate <= 1199) {
            return 3;
        } else if (rate >= 1200 && rate <= 1599) {
            return 4;
        } else if (rate >= 1600 && rate <= 1999) {
            return 5;
        } else if (rate >= 2000 && rate <= 2399) {
            return 6;
        } else if (rate >= 2400 && rate <= 2799) {
            return 7;
        } else if (rate >= 2800 && rate <= 3199) {
            return 8;
        } else {
            return 9;
        }
    }
}


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

int main() {
  int s;
  cin >> s;
  
  int count = 0;
  bool flag = true;
  
  while(flag) {
    if(s == 1 || s == 2 || s == 4)
      flag = false;
    else {
      if(s % 2 == 0)
        s = s / 2;
      else
        s = 3 * s + 1;
      count ++;
    }
  }
  
  cout << count + 4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int MOD = 998244353;

void add(int &a, int b) {
  if ((a += b) >= MOD) a -= MOD;
}

void sub(int &a, int b) {
  if ((a -= b) < 0) a += MOD;
}

int mul(int a, int b) {
  return (int) ((a * 1LL * b) % MOD);
}

int mpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

int minv(int x) {
  return mpow(x, MOD - 2);
}

const int MAX = 1000010;
int invv[MAX];

int main() {
#ifdef LOCAL
  freopen("c.in", "r", stdin);
  freopen("c.out", "w", stdout);
#endif

  invv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    invv[i] = mul(MOD - invv[MOD % i], MOD / i);
    assert(mul(i, invv[i]) == 1);
  }


  int n;
  while (scanf("%d", &n) == 1) {
    vector<int> cnt(MAX);
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int a;
      scanf("%d", &a);
      add(sum, a);
      cnt[a]++;
    }
    vector<int> sumg(MAX);
    for (int i = 1; i < MAX; i++) {
      for (int j = i; j < MAX; j += i) {
        add(sumg[i], mul(cnt[j], j));
      }
    }
    for (int i = 0; i < MAX; i++) {
      sumg[i] = mul(sumg[i], sumg[i]);
    }
    for (int i = MAX - 1; i >= 1; i--) {
      for (int j = 2  * i; j < MAX; j += i) {
        sub(sumg[i], sumg[j]);
      }
    }
    int ans = 0;
    for (int i = 1; i < MAX; i++) {
      if (sumg[i] != 0) {
        eprintf("%d %d\n", i, sumg[i]);
      }
      add(ans, mul(sumg[i], invv[i]));
    }
    eprintf("here!\n");
    sub(ans, sum);
    ans = mul(ans, minv(2));
    printf("%d\n", ans);
  }

  return 0;
}


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

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  
  if (N % X == 0) {
    cout << N / X * T << endl;
  }
  else {
    cout << (N / X + 1) * T << endl;
  }
  
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
ll par[114514];
ll rankk[114514];
void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i;
		rankk[i]=0;
	}
}
ll find(ll x){
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}
void unite(ll x, ll y){
	x = find(x);
	y = find(y);
	if(x==y)return;
	if(rankk[x]<rankk[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rankk[x]==rankk[y])rankk[x]++;
	}
}
signed main(){
	int n,m;
	cin>>n>>m;
	init(n);
	for(int i=0;i<m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		unite(x,y);
	}
	set<int> s;
	int ans = 0;
	for(int i=1;i<=n;i++){
		int p = find(i);
		
		if( s.find(p) == s.end() ){
			ans++;
			s.insert(p);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int n, m;
	while (cin >> n >> m, n, m) {
		int p[1000];
		int sum = 0;

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

		sort(p, p+ n);
		reverse(p, p + n);

		for (int i = m - 1;i < n;i += m) {
			sum -= p[i];
		}
		cout << sum << endl;
	}
	return 0;
}

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


Measured memory_bytes: 3100
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	int tab[100005];
	int n;
	cin >> n;
	LL licznik = 0;
	int counter = 0;
	
	for(int i = 0; i < n; i++){
		cin >> tab[i];
	}
		
	for(int i = 0; i < n; i++){
		licznik += abs(tab[i]);
		if(tab[i] < 0) counter++;
	}
	
	if(counter % 2 == 1){
		int mini = INF;
		for(int i = 0; i < n; i++){
			mini = min(mini, abs(tab[i]));
			//cout << "current mini: " << mini << endl;
		}
		licznik -= mini*2;
	}

	cout << licznik << endl;

	
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FastRead                      \
                                    ios_base::sync_with_stdio(false); \
                                    cin.tie(0);
#define ll long long
#define endl "\n"
#define f for
using namespace std;
int main()

{
    FastRead
    ll int n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;

}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0; i<n; i++) cin >> a[i];

  int maxval = -1000000000;
  int minval = a[0];
  for (int i=1; i<n; i++) {
    maxval = max(maxval, a[i] - minval);
    minval = min(minval, a[i]);
  }

  cout << maxval << endl;

  return 0;
}



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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

// 1は除く
vector<int64_t> factors(int64_t n) {
  vector<int64_t> ret;
  for (int64_t i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (n / i != i) {
        ret.push_back(n / i);
      }
    }
  }

  ret.push_back(n);

  return ret;
}

int main() {
  int64_t n;
  cin >> n;

  if (n == 2) {
    cout << 1 << endl;
    return 0;
  }

  int64_t ans = 0;
  const auto& n_factors = factors(n);
  for (auto f : n_factors) {
    auto nn = n;
    while (nn % f == 0) {
      nn /= f;
    }

    if (nn % f == 1) {
      ++ans;
    }
  }

  const auto& n_1_factors = factors(n - 1);
  ans += n_1_factors.size();

  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[m],b[m];
    int dist[n][n]={};
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        dist[a[i]-1][b[i]-1]=1;
        dist[b[i]-1][a[i]-1]=1;
    }
    int x[n];
    for(int i=0;i<n;i++)x[i]=i;
    int ans=0;
    do{
        for(int i=0;i<n-1;i++){
            if(dist[x[i]][x[i+1]]!=1){
                ans--;
                break;
            }
        }
        ans++;
    }while(next_permutation(x+1,x+n));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

int main(){
    int n,m;
    std::cin >> n>>m;
    VEC(int,a,m);
    std::vector<int> dp(n+1,INF);
    dp[0]=0;
    rrep(i,1,n+1){
        rep(j,m){
            if(i-a[j]>=0)dp[i]=min(dp[i],dp[i-a[j]]+1);
        } 
    }
    std::cout << dp[n] << std::endl;
}


Measured memory_bytes: 3260
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	string S,T;

	cin >> S >> T;
	
	int ans=0;
	for(int i=0;i<S.size();i++)
	{
		if(S[i]==T[i])
			ans++;
	}

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



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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

LL BS(LL x , LL y , LL p){
	if(y-x<2) return x;
	LL z = (x+y)/2;
	return (z/2) * ((z+1)/2) < p ? BS(z,y,p) : BS(x,z,p);
}

int main(){
	int Q; cin >> Q;
	repp(rep_t,0,Q){
		LL A,B; cin >> A >> B;
		cout << (A == B ? 2*(A-1) : BS(1,A+B+1,A*B)-2) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
a, v = map(int,input().split())
b, w = map(int,input().split())
t = int(input())

if a <= b:
    if a+v*t >= b+w*t:
        print("YES")
    else:
        print("NO")
else:
    if a-v*t <= b-w*t:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9184
from collections import deque
n=int(input())
A=list(map(int,input().split()))
A.sort()
A.reverse()
conf=[A[0]]
ans=0
con=deque(conf)
A.pop(0)


for elem in A:
    ans+=con.popleft()
    
    for _ in range(2):
        con.append(elem)

print(ans)

Measured memory_bytes: 93480
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
   ;
    //サンプルコード;;
    //ABC075-A;;
    ;;
    int a, b, c;;;
    cin >> a >> b >> c;;;
    ;;
    if(a==b){ cout << (c) << endl;;;}
    else if(b==c){ cout << (a) << endl;;;}
    else { cout << (b) << endl;;;}
}

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

int main(){
  int x,y,z,K,S,value=0;
    cin>>K>>S;

  for(x=0;x<=K;x++){
    for(y=0;y<=K;y++){
      z=S-x-y;
      if(0<=z && z<=K){
        value += 1;
      }
    }
  }
  cout<<value<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200002;
double ans;
int n,i,p[N];
int main(){
	scanf("%d",&n);
	for(i=1;i<=2*n;i++)
		scanf("%d",p+i);
	sort(p+1,p+n*2+1);
	for(i=1;i<=2*n;i++)
		ans+=1.0*p[i]*(i-1)/(2*n-1);
	printf("%.10lf\n",ans);
}

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

int v[205];

int main() {
    int n, ans = 0;

    scanf("%d", &n);
    for (int i = 1; i <= n * 2; i++)
        scanf("%d", &v[i]);

    sort(v + 1, v + n * 2 + 1);

    for (int i = 1; i <= n; i++)
        ans = ans + v[i * 2 - 1];

    printf("%d", ans);

    return 0; }


Measured memory_bytes: 256
let n = Scanf.scanf " %d" (+) 0
let rec f n = if n mod 2 <> 0 then 0 else 1 + f (n / 2)
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" f
let _ = Printf.printf "%d\n" @@ Array.fold_left (+) 0 a_s

Measured memory_bytes: 2816
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_126
{
    class F
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] mk = ReadInts();
            int m = mk[0];
            int k = mk[1];

            int max = (1 << m) - 1;

            if (max < k)
            {
                WriteLine(-1);
                return;
            }

            if (max == 1)
            {
                if (k == 1)
                {
                    WriteLine(-1);
                    return;
                }
                else
                {
                    WriteLine("0 0 1 1");
                    return;
                }
            }

            int[] vals = new int[2 * max + 2];
            for(int i = 0; i <= max; i++)
            {
                if (i == k)
                {
                    vals[max] = i;
                    vals[vals.Length - 1] = i;
                }
                else if (i < k)
                {
                    vals[i] = i;
                    vals[vals.Length - 2 - i] = i;
                }
                else
                {
                    vals[i - 1] = i;
                    vals[vals.Length - 2 - i + 1] = i;
                }
            }

            for (int i = 0; i < vals.Length; i++)
            {
                Write(vals[i]);
                if (i < vals.Length - 1) Write(" ");
            }
            WriteLine();
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 17624
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
typedef enum { top, south, east, west, north, bottom, NUM_SIDES } sides;
 
sides getOperator()
{
    return rand() % north + 1;
}
 
void roll(int *dice, const sides operator)
{
    int anti_op;
    switch( operator ){
    case south: anti_op = north; break;
    case east: anti_op = west; break;
    case west: anti_op = east; break;
    case north: anti_op = south; break;
    default: break;
    }
 
    int tmp = dice[operator];
    dice[operator] = dice[top];
    dice[top] = dice[anti_op];
    dice[anti_op] = dice[bottom];
    dice[bottom] = tmp;
}
 
int main()
{
    int i;
 
    srand(time(0));
 
    int q, dice[NUM_SIDES];
    for( i = 0; i < NUM_SIDES; ++i )
        scanf("%d", &dice[i]);
    scanf("%d", &q);
 
    for( i = 0; i < q; ++i ){
        int up, front;
        scanf("%d%d", &up, &front);
        sides operator = getOperator();
        while( dice[top] != up || dice[south] != front ){
            roll(dice, operator);
            operator = getOperator();
        }
        printf("%d\n", dice[east]);
    }
 
    return 0;
}

Measured memory_bytes: 1776
distance = (
    (),
    (0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5, 3, 4, 5, 6),
    (1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 3, 4, 4, 3, 4, 5),
    (2, 1, 0, 1, 3, 2, 1, 2, 4, 3, 2, 3, 5, 4, 3, 4),
    (3, 2, 1, 0, 4, 3, 2, 1, 5, 4, 3, 2, 6, 5, 4, 3),
    (1, 2, 3, 4, 0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5),
    (2, 1, 2, 3, 1, 0, 1, 2, 2, 1, 2, 3, 3, 2, 3, 4),
    (3, 2, 1, 2, 2, 1, 0, 1, 3, 2, 1, 2, 4, 3, 2, 3),
    (4, 3, 2, 1, 3, 2, 1, 0, 4, 3, 2, 1, 5, 4, 3, 2),
    (2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3, 1, 2, 3, 4),
    (3, 2, 3, 4, 2, 1, 2, 3, 1, 0, 1, 2, 2, 1, 2, 3),
    (4, 3, 2, 3, 3, 2, 1, 2, 2, 1, 0, 1, 3, 2, 1, 2),
    (5, 4, 3, 2, 4, 3, 2, 1, 3, 2, 1, 0, 4, 3, 2, 1),
    (3, 4, 5, 6, 2, 3, 4, 5, 1, 2, 3, 4, 0, 1, 2, 3),
    (4, 3, 4, 5, 3, 2, 3, 4, 2, 1, 2, 3, 1, 0, 1, 2),
    (5, 4, 3, 4, 4, 3, 2, 3, 3, 2, 1, 2, 2, 1, 0, 1)
)

def get_distance(board):
    sd = 0
    for i in range(16):
        p = board[i]
        if p == 0:
            continue
        sd += distance[p][i]
    return sd

adjacent = (
    (1, 4),         # 0
    (0, 2, 5),      # 1
    (1, 3, 6),      # 2
    (2, 7),         # 3
    (0, 5, 8),      # 4
    (1, 4, 6, 9),   # 5
    (2, 5, 7, 10),  # 6
    (3, 6, 11),     # 7
    (4, 9, 12),     # 8
    (5, 8, 10, 13), # 9
    (6, 9, 11, 14), # 10
    (7, 10, 15),    # 11
    (8, 13),        # 12
    (9, 12, 14),    # 13
    (10, 13, 15),   # 14
    (11, 14)        # 15
)

GOAL = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]

def df_lower_search(limit, move, space, lower, pre_p):
    if move == limit:
        if board == GOAL:
            return True
    else:
        for i in adjacent[space]:
            p = board[i]
            if p == pre_p:
                continue
            board[space] = p
            board[i] = 0
            new_lower = lower - distance[p][i] + distance[p][space]
            if new_lower + move <= limit:
                if df_lower_search(limit, move + 1, i, new_lower, p):
                    return True
            board[space] = 0
            board[i] = p

import sys

board = list(map(int, sys.stdin.read().split()))

s = board.index(0)
e_o = (0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0)

n = get_distance(board)

if e_o[s] != n % 2:
    n += 1

for l in range(n, 46, 2):
    if df_lower_search(l, 0, s, n, None):
        print(l)
        break

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
int main(){
  long A,B,K;
  cin>>A>>B>>K;
  if(A>K) cout<<A-K<<" "<<B<<endl;
  else if(A+B>K) cout<<0<<" "<<A+B-K<<endl;
  else cout<<0<<" "<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int long long
typedef long long ll;
 
int color[200000];
 
int n,m;
vector<vector<int>> v(200000);
 
bool dfs(int nn, int pre, int c){
    for(auto x:v[nn]){
        if(x==pre) continue;
        if(color[x]==color[nn]) return false;
        if(color[x]!=color[nn] && color[x]!=-1) continue;
        if(color[x]==-1) color[x]=1-c;
        if(!dfs(x,nn,color[x])) return false;
    }
 
    return true;
}
 
 
signed main(){
    cin >> n >>m;
    memset(color,-1,sizeof(color));
    rep(i,m){
        int aa,bb;
        cin >> aa >> bb;
        v[aa-1].push_back(bb-1);
        v[bb-1].push_back(aa-1);
    }
    //rep(i,n) cout << color[i] << endl;
    color[0]=0;
    if(dfs(0,-1,0)){
        int white=0;
        int black=0;
        rep(i,n){
            if(color[i]==0) white++;
            else black++;
        }
        cout << white*black-m << endl;
    }
    else cout << (n*(n-1)/2)-m << endl;
 
    
 
 
}

Measured memory_bytes: 10624
/*
[abc137] E - Coins Respawn
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 2500;
const int MAX_M = 5000;
const int INF = 1e9;

const int MAX_V = MAX_N;

struct edge {
    int from, to, cost;
};

int N, M, P;
int A[MAX_M], B[MAX_M], C[MAX_M];
vector<int> g[2][MAX_N];
bool visited[2][MAX_N];
edge es[MAX_M];

int d[MAX_V];

void dfs(int r, int v) {
    if (visited[r][v]) {
        return;
    }
    visited[r][v] = true;

    for (int to : g[r][v]) {
        dfs(r, to);
    }
}

bool bellman_ford(int s, int V, int E) {
    d[s] = 0;
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < E; j++) {
            edge &e = es[j];
            if (d[e.from] < INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (i == V - 1 && visited[0][e.to] && visited[1][e.to]) {
                    return true;
                }
            }
        }
    }
    return false;
}

ll solve() {
    for (int i = 0; i < M; i++) {
        es[i].from = A[i];
        es[i].to = B[i];
        es[i].cost = -(C[i] - P);
        g[0][A[i]].push_back(B[i]);
        g[1][B[i]].push_back(A[i]);
    }

    dfs(0, 0);
    dfs(1, N - 1);

    fill(d, d + N, INF);
    if (bellman_ford(0, N, M)) {
        return -1;
    }

    return max(0, -d[N - 1]);
}

int main() {
    cin >> N >> M >> P;
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--, B[i]--;
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 640
let words str = Str.split (Str.regexp " ") str |> List.map int_of_string

let bs elem a =
  let rec loop (i_min,i_max) =
    match i_min > i_max || i_max < i_min with
      true -> false
    | false ->
      let mid = (i_min+i_max)/2 in
      match a.(mid) = elem with
        true -> true
      | false ->
        loop (match a.(mid) < elem with true -> mid+1,i_max | false -> i_min,mid-1)
  in loop (0,(Array.length a) -1)

let () =
  let _ = read_int () in
  let s = read_line () |> words |> Array.of_list in
  let _ = read_int () in
  let t = read_line () |> words in
  List.fold_left (fun acc x -> match bs x s with true -> acc+1 | false -> acc)
    0 t
  |> Printf.printf "%d\n"

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

int main() {

	string S;
	cin>>S;
	if(S=="Sunny"){
		cout<<"Cloudy";
	}
	else if(S=="Rainy"){
			cout<<"Sunny";
	}
	else if(S=="Cloudy"){
      cout<<"Rainy";
	}



	return 0;
}


Measured memory_bytes: 256