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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

map<int64, int32> cnt;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 N;
	cin >> N;
	vector<int64> A(N);
	vector<bool> used(N, 0);
	REP(i, N) cin >> A[i];
	sort(all(A), greater<int64>());
	REP(i, N){
		cnt[A[i]]++;
	}

	int32 res = 0;
	REP(i, N){
		if(cnt[A[i]] == 0) continue;
		int64 match = 0, d = 0;
		bool one = 0;
		for(d = 0;(1 << d) <= A[i];d++){
			if(A[i] >> d & 1){
				if(!one) match += (1<<d);
				one = 1;
			}else{  
				if(one) match += (1<<d);
			}
		}
		if(match == A[i]){
			if(cnt[A[i]] >= 2){
				res++;
				cnt[A[i]] -= 2;
			}
		}else{
			if(cnt[match] >= 1){
				cnt[match]--;
				cnt[A[i]]--;
				res++;
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 26880
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int INF = 100100;
int main() {
  vector<bool> p(INF+1,true);
  p[0] = p[1] = false;
  for(int i=2;i*i<=INF;++i){
    if(!p[i]) continue;
    for(int j=2*i;j<=INF;j+=i) p[j]=false;
  }
  vector<int> s(INF+1);
  rep(i,INF){
    s[i+1] = s[i];
    if(i&1 && p[i] && p[(i+1)/2]) s[i+1]++;
  }
  int q;
  cin >> q;
  rep(i,q){
    int l,r;
    cin >> l >> r;
    cout << s[r+1]-s[l] << endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";}

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
typedef long long ll;
typedef double ld;
#define pll pair<ll,ll>
#define pii pair<int, int>
#define pb push_back
#define mp(x, y) make_pair((x), (y))
#define F first
#define S second
#define I insert
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
#define sz(x) (ll)(x).size()
   
const ll INF = 1e15;
const int V = 1e5+7;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
    ll n , W; cin >> n >> W;
    // w , v;
    ll A[2][n+1];
    for(int i = 1;i <= n ; i++)
        cin >> A[0][i] >> A[1][i];

    ll dp[2][V];

    for(int i = 0 ;i < V ; i++){
        dp[0][i] = INF;
        dp[1][i] = INF;
    }
    dp[0][0] = 0;
    dp[1][0] = 0;
    for(int i = 1 ;i <= n ;i++){
        for(int j = V-A[1][i]-1 ;j >= 0 ; j--)
            dp[1][j+A[1][i]] = min(dp[0][j+A[1][i]] , dp[0][j] + A[0][i]);
        
        for(int j = 0 ;j < V ; j++)
            dp[0][j] = dp[1][j];
        
    }
    
    for(int i = V-1 ;i >= 0 ;i--){
        if(dp[0][i] <= W){
            cout << i << endl;
            return 0;
        }
    }
    

    return 0;
}

Measured memory_bytes: 1792
s=gets.chomp
gets.to_i.times{
  i,*p=gets.split

  case i
  when 'print'
    a,b=p.map(&:to_i)
    puts s[a..b]
  when 'reverse'
    a,b=p.map(&:to_i)
    s=s[0,a]+s[a..b].reverse+s[(b+1)..-1]
  when 'replace'
    a,b,c=p
    a=a.to_i
    b=b.to_i
    s=s[0,a]+c+s[(b+1)..-1]
  end
}


Measured memory_bytes: 7072
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 11 05:38:56 2019

@author: shinjisu
"""


# ABC 200点問題
import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def dmp(x):
    global debug
    if debug:
        print(x)


debug = True


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


def prob096():  # Maximum Sum
    X = getIntList()
    K = getInt()
    dmp((X, K))
    total = sum(X) - max(X) + max(X)*2**K
    return total


def prob097():  # Exponential
    X = getInt()
    dmp(X)
    if X == 1:
        return 1
    for n in range(X, 0, -1):
        dmp(n)
        for b in range(2, int(math.sqrt(X))+1):
            a = n
            exp = True
            while a > 1:
                if a % b != 0:
                    exp = False
                    break
                a //= b
            if exp:
                break
        if exp:
            break
    return n


def prob098():  # Cut and Count
    N = getInt()
    S = input()
    dmp((N, S))
    maxChCount = 0
    for i in range(1, N):
        before = S[:i]
        after = S[i:]
        dmp((before, after))
        chCount = 0
        for j in range(26):
            ch = chr(ord('a')+j)
            if ch in before and ch in after:
                chCount += 1
        maxChCount = max(maxChCount, chCount)
    return maxChCount


def prob099():  # Stone Momument
    a, b = getIntList()
    height = 0
    for i in range(b-a+1):
        height += i
    height -= b
    return height


def prob103():  # String Rotation
    S = input()
    T = input()
    for i in range(len(S)):
        S = S[1:] + S[0]
        dmp(S)
        if S == T:
            return 'Yes'
    else:
        return 'No'


def prob000():  # 
    return 0


debug = False  # True False
print(prob103())


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

#define int long long
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N=1e5+5;
const int INF = 1e9;

 

 
int32_t main()
{
	IOS;
	int n,sum=0;
	cin>>n;
	vector<int> a(n),b(n),c(n-1);
	for(int i=0; i<n; i++) cin>>a[i];
	for(int i=0; i<n; i++) cin>>b[i], sum+=b[i];
	for(int i=0; i<n-1; i++) cin>>c[i];

	//debug
	 //for(int i=0; i<n; i++) cout<<a[i];
	// for(int i=0; i<n; i++) cout<<b[i];
	// for(int i=0; i<n-1; i++) cout<<c[i];

	for(int i=1; i<n; i++) {
		if ((a[i]-1) == a[i-1])
			sum += c[a[i-1]-1];
	}




	cout<<sum<<endl;	



	return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vp;

#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



int main()
{
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int a, b, c; cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
    
}



/*before sub
TEST: 0, 1, equal, -ve, bounds(random and ez)
loop vars,1LL in mult, out of bounds, int v ll, endl, finish taking inputs, large doubles, larger INF
*/





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

int main(){
	int x, y; cin >> x >> y;
	if(x == 1 && y == 1){
		cout << 1000000 << endl;
	}else{
		int p = 0;
		if(x <= 3) p += (4-x)*100000;
		if(y <= 3) p += (4-y)*100000;
		cout << p << endl;
	}
	return 0;
}

Measured memory_bytes: 256
<?php

list($n, $blue, $red) = explode(' ', trim(fgets(STDIN)));


  $n1 = intdiv($n, ($blue + $red));
  $n2 = $n % ($blue + $red);

  if ($n2 <= $blue) {
    echo $n2 + $blue * $n1;
  } elseif ($n2 > $blue) {
    echo $blue + $blue * $n1;
  }


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

struct UnionFind{
    vector<ll> par;
    vector<ll> siz;
 
    void init(ll n){
        for(ll i=0;i<n;i++){
            par.push_back(i);
            siz.push_back(1);
        }
    }
 
    UnionFind(ll n){
        init(n);
    }
 
    ll root(ll x){
        //根を返す
        if(par[x]==x){
            return x;
        }
        else{
            return (par[x]=root(par[x]));
        }
    }
    bool sameParent(ll x,ll y){
        return(root(x)==root(y));
    }
    void unite(ll x, ll y){
        x=root(x);y=root(y);
        if(x==y)    return;
        //データ構造->小を大にくっつける
        if(siz[x]<siz[y]) swap(x,y);
        siz[x] += siz[y];
        par[y]=x;
    }
 
    ll size(ll x){
        return siz[root(x)];
    }
};

#define int ll

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

    int n,m,q;
    cin>>n>>m>>q;

    UnionFind uf(n);
    vector<pair<int,int>> v;
    rep(abababababababa,q){
        int a,b,c;
        cin>>a>>b>>c;
        if(c==0) uf.unite(a,b);
        else v.push_back(make_pair(a,b));
    }

    if(m==n-1){
        if(v.size()){
             cout<<"No"<<endl;
             return 0;
        }
        cout<<"Yes"<<endl;
        return 0;
   }

    for(auto x:v){
        if(uf.sameParent(x.first,x.second)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    int k=0;
    for(int i=0;i<n;i++){
        if(uf.root(i)==i) k++;
    }

   if(m<=n-k+k*(k-1)/2){
       cout<<"Yes"<<endl;
       return 0;
   }
   cout<<"No"<<endl;

    return 0;
}


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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    int n, k;
    cin >> n >> k;
    vi p(n);
    rep(i, n) cin >> p[i];

    sort(rng(p));
    int ans = 0;
    rep(i, k) {
        ans += p[i];
    }

    prt(ans);

    return 0;
}


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

int main() {
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3,y3,x4,y4;
  
  int n = x2 - x1;
  int m = y2 - y1;
  
  if (n >= 0) {
    if (m >= 0) {
      x3 = x2 - m;
      x4 = x3 - n;
      y3 = y2 + n;
      y4 = y3 - m;
    }
    else {
      x3 = x2 - m;
      x4 = x3 - n;
      y3 = y2 + n;
      y4 = y3 - m;
    }
  }
  else {
    if (m >= 0) {
      x3 = x2 - m;
      x4 = x3 - n;
      y3 = y2 + n;
      y4 = y3 - m;
    }
    else {
      x3 = x2 - m;
      x4 = x3 - n;
      y3 = y2 + n;
      y4 = y3 - m;
    }
  }
  cout << x3 << ' ' << y3  << ' '<< x4 << ' ' << y4 << ' '<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007
const int MAX_N = 1000005;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n; cin>>n;
  vector<ll> a(n), b(MAX_N,0);
  ll sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[a[i]]++;
    sum+=a[i];
  }

  ll q; cin>>q;
  while(q--){
    ll x,y; cin>>x>>y;
    ll cnt=b[x]; b[x]=0;
    b[y]+=cnt;
    sum-=x*cnt;
    sum+=y*cnt;
    cout<<sum<<"\n";
  }
  return 0;
}

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

int n, m;

int main(){
	int i, flag;
	ll a, s, d, f, g, now;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%lld %lld %lld %lld", &a, &s, &d, &f);
		flag = 1;
		if(a < s) flag = 0;
		a %= s; g = __gcd(s, f);
		if(s > f) flag = 0;
		if(a > d) flag = 0;
		if(d + 1 >= s && flag){ printf("Yes\n"); continue; }
		now = s - (s - a) % g;
		if(now == s) now -= g;
		if(g != s && now > d) flag = 0;
		if(flag) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

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

#define int long long

inline int in() { int t = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    do { t = t * 10 + ch - '0'; ch = getchar(); } while (ch >= '0' && ch <= '9');
    return t * f;
}

const int N = 1e5 + 5;

int n, m, v, p, a[N], nums[N], b[N], head[N];

signed main() {
    n = in(), m = in(), v = in(), p = in();
    for (int i = 1; i <= n; ++i) a[i] = in();
    std ::sort(a + 1, a + n + 1, std ::greater<int>());
    head[0] = 1;
    for (int i = 1; i <= n; ++i) {
        head[i] = head[i - 1];
        if (a[i] != a[head[i]]) head[i] = i;
        ++nums[head[i]];
    }
    int ans = head[p] - 1 + nums[head[p]], now = 0, nnum = nums[head[p]];
    for (int i = head[p] + nums[head[p]]; i <= n; ++i) {
        if (a[i] + m < a[p]) break;
        if (v <= n - nnum) ++ans;
        else {
            long long cur = m * (v - n + nnum) - now;
            cur = (cur + nnum - 1) / nnum;
            if (a[i] + m >= a[p] + cur) ++ans;
        }
        now += std ::min(m, a[p] - a[i]), ++nnum;
    }//打发士
    /*    for (int i = head[p] + nums[head[p]]; i <= n; ++i) {
            if (a[i] + m < a[p]) break;
            if (v <= n - nums[head[p]]) { ++ans; continue; }
            long long cur = m * (v - n + nums[head[p]]);
            cur = (cur + nums[head[p]] - 1) / nums[head[p]];
            if (a[i] + m >= a[p] + cur) ++ans;
        }*/
    std ::cout << ans << std ::endl;
    return 0;
}


Measured memory_bytes: 2560
if __name__ == '__main__':

	while True:
		x,y = map(int,input().split())

		if x == 0 and y == 0:
			break

		A = []
		for _ in range(x):
			line = list(input())
			A.append(line)

		ans = []
		W = 0
		H = 0
		s = A[H][W]
		while True:
			if s == ">":
				W += 1
			elif s == "<":
				W -= 1
			elif s == "^":
				H -= 1
			elif s == "v":
				H += 1
			else:
				print(W,H)
				break

			s = A[H][W]
			if [H,W] in ans:
				print("LOOP")
				break
			else:
				ans.append([H,W])



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

int main() {
  int n;
  string s;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s ;
    if (s == "Y") {
      cout << "Four" << endl;
      return 0;
    }
  }

  cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
using VI  = vector<int>;
using PII = pair<int, int>;
using VP  = vector<PII>;
using VVP = vector<VP>;
VI color;
VVP g;
int n, cmax;
inline void DFS(int x, int w) {
    int temp(1), y, i;
    for (const PII& P : g[x]) {
        tie(y, i) = P;
        if (!color[i]) {
            temp += (temp == w);
            color[i] = temp;
            DFS(y, temp);
            ++temp;
        }
    }
}
int x, y;
int main() {
    DAU
    cin >> n;
    g.resize(n + 1);
    for (int i = 1; i < n; ++i) {
        cin >> x >> y;
        g[x].emplace_back(y, i);
        g[y].emplace_back(x, i);
    }
    color.resize(n);
    DFS(1, n);
    for (int i = 1; i < n; ++i)
        cmax = max(cmax, color[i]);
    cout << cmax << '\n';
    for (int i = 1; i < n; ++i)
        cout << color[i] << '\n';
    PLEC
}


Measured memory_bytes: 9572
#include <stdio.h>
int main()
{
	int a,b,c,i,count=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    v_int a(n+1);
    v_int b(n+1);
    irep2(i, 0, n) {
        cin >> a[i];
    }
    irep2(i, 0, n-1) {
        cin >> b[i];
    }

    ll ans = 0;
    irep2(i,0,n-1) {
        int cnt = min(a[i], b[i]);
        b[i] -= cnt;
        ans += (cnt + min(b[i], a[i+1]));
        a[i+1] -= min(b[i], a[i+1]);
    }
    cout << ans << endl;
    return 0;
} /*atcoder*/


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int H, W; cin >> H >> W;
  vstr S(H); rep(i, H) cin >> S[i];
  vector<vi32> edges(H * W);
  rep(i, H) rep(j, W - 1) {
    if (S[i][j] != S[i][j + 1]) {
      int v = i * W + j, u = v + 1;
      edges[v].push_back(u);
      edges[u].push_back(v);
    }
  }
  rep(j, W) rep(i, H - 1) {
    if (S[i][j] != S[i + 1][j]) {
      int v = i * W + j, u = (i + 1) * W + j;
      edges[v].push_back(u);
      edges[u].push_back(v);
    }
  }
  vector<bool> seen(H * W);

  i64 c1, c2;
  function<void(int, int)> dfs = [&](int v, int c) {
    seen[v] = true;
    if (c % 2 == 0) c1++; else c2++;
    each(u, edges[v]) {
      if (seen[u]) continue;
      dfs(u, c + 1);
    }
  };

  i64 ans = 0;
  rep(i, H) rep(j, W) {
    int v = i * W + j;
    if (seen[v]) continue;
    c1 = 0, c2 = 0;
    dfs(v, 0);
    ans += c1 * c2;
  }
  cout << ans << '\n';
}


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

int main()
{
	string N;
	cin >> N;

	if (N.size() == 2) {
		cout << N << endl;
	}
	else {
		cout << N[2] << N[1] << N[0] << endl;
	}
    return 0;
}


Measured memory_bytes: 256
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect

n=int(input())
d={}
res=[[0,0] for _ in range(n)]
for i in range(n):
    a=float(input())
    b=int(round(a*pow(10,9)))
    x=0
    y=0
    f=True
    while f:
        f=False
        if b%2==0:
            x+=1
            b=b//2
            f=True
        if b%5==0:
            y+=1
            b=b//5
            f=True
    if x*100+y not in d:
        d[x*100+y]=1
    else:
        d[x*100+y]+=1
    res[i]=[x,y]
ans=0
for i in range(n):
    x,y=res[i]
    for j in d:
        xc=j//100
        yc=j%100
        if xc+x>=18 and yc+y>=18:
            if xc==x and yc==y:
              ans+=d[j]-1
            else:
              ans+=d[j]
print(ans//2)


Measured memory_bytes: 115188
#include<cstdio>
#include<algorithm>
#define N 11
#define inf 10000000
using namespace std;
int d[N][N],V;
void warshall_floyd(void)
{
	for(int k=0;k<=V;k++)
	{
		for(int i=0;i<=V;i++)
		{
			for(int j=0;j<=V;j++)
			d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		}
	}
	return ;
}
void init(void)
{
	for(int i=0;i<N;i++)
	fill(d[i],d[i]+N,inf);
	for(int i=0;i<N;i++)
	d[i][i]=0;
	return ;
}
int main(void)
{
	int n;
	while(scanf("%d",&n)==1)
	{
		if(n==0)
		break;
		init();
		int s,e,c;
		V=0;
		for(int i=0;i<n;i++)
		{
			scanf("%d%d%d",&s,&e,&c);
			d[s][e]=d[e][s]=c;
			V=max(V,max(s,e));
		}
		warshall_floyd();
		int ans=inf;
		int sum=0;
		int id=0;
		for(int i=0;i<=V;i++)
		{
			sum=0;
			for(int j=0;j<=V;j++)
			sum+=d[i][j];
			if(sum<ans)
			{
				ans=sum;
				id=i;
			}
		}
		printf("%d %d\n",id,ans);
	}
	return 0;
}

Measured memory_bytes: 1028
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>>a(H+2, vector<char>(W+2,'#'));
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> a[i][j];
        }
    }

    for (int i = 0; i <= H+1; i++) {
        for (int j = 0; j <= W+1; j++) {
            cout << a[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  /* 標準入力フラグ */
  int   scan;

  /* 文入力 */
  char  s;
  scan = scanf("%c", &s);
 

  /* プログラムを書く */
  if (s >= 65 && s <= 90) {
    printf("A");
  } else {
    printf("a");
  }

  return (0);



}



Measured memory_bytes: 1596
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	string S;
	cin >> S;
	bool f = true;
	REP(i, S.size()) {
		if (S[i] == 'L'&&i % 2 == 0) {
			f = false;
		}
		if (S[i] == 'R'&&i % 2 == 1) {
			f = false;
		}
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}



Measured memory_bytes: 256
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
S = []
S2 = []

for _ in range(N):
    S.append(input().strip())

count = Counter(S)
most = max(count.values())
for key, value in count.items():
    if value == most:
        S2.append([key, value])

S2.sort(key=lambda x:x[0])
for value in S2:
    print(value[0])


Measured memory_bytes: 55792
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	

	long long M,K;
	cin>>M>>K;	
	long long v=pow(2,M)-1;
	long long x;
	if(v%4==0)
	{
		x=v;
	}
	else if(v%4==1)
	{
		x=1;
	}
	else if(v%4==2)
	{
		x=v+1;
	}
	else if(v%4==3)
	{
		x=0;
	}
	if(x==0 && K<=v && K>0)
	{
		cout<<"0 "<<K<<" 0 ";
		for (long long i = 1; i <= v; ++i)
		{
			if(i!=K)
			{
				cout<<i<<" ";
			}
		}
		cout<<K<<" ";
		for (long long i = v; i >=1 ; --i)
		{
			if(i!=K)
			{
				cout<<i<<" ";
			}
		}
	}
	else if(K==0)
	{
		for (long long i = 0; i <= v; ++i)
		{
			cout<<i<<" "<<i<<" ";
		}
	}
	else
	{
		cout<<-1;
	}

	cout<<endl;

	return 0;
}

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


int main(){
    int n;
    cin >> n;
    string s1,s2;
    int t=0,h=0;
    for(int i=0; i<n; i++){
        cin >> s1 >> s2;
        if(s1.compare(s2)==0){
            t++;
            h++;
        }
        else if(s1.compare(s2)>0){
            t+=3;
        }
        else{
            h+=3;
        }

        
    }
    cout << t << " " << h << endl;

}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=100000007,MAX=100005;
const ll INF=1LL<<60;
ll dis[MAX],size[MAX],ans[MAX];
struct edge{
    int to;
    int id;
};
vector<edge> G[MAX];

void preDFS(int u,int p){
    size[u]=1;
    for(edge e:G[u]){
        if(e.to==p) continue;
        preDFS(e.to,u);
        size[u]+=size[e.to];
    }
}
ll kyori[MAX];
bool seen[MAX];
ll cnt=0;
void BFS(int u){
    queue<pair<int,int>> Q;
    Q.push({u,0});
    seen[u]=1;
    while(!Q.empty()){
        int a=Q.front().first,b=Q.front().second;
        Q.pop();
        for(edge e:G[a]){
            if(seen[e.to]) continue;
            seen[e.to]=1;
            
            if(ans[e.id]==-1){
                kyori[e.to]=kyori[a];
                cnt++;
                Q.push({e.to,1});
            }else if(b==1){
                kyori[e.to]=kyori[a]+ans[e.id];
                cnt++;
                Q.push({e.to,1});
            }else{
                kyori[e.to]=kyori[a]+ans[e.id];
                Q.push({e.to,0});
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<pair<int,int>> E(N-1);
    for(int i=0;i<N-1;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back({b,i});
        G[b].push_back({a,i});
        E[i]={a,b};
    }
    
    for(int i=0;i<N;i++){
        cin>>dis[i];
    }
    
    preDFS(0,-1);
    
    for(int i=0;i<N-1;i++){
        int a=E[i].first,b=E[i].second;
        int c=min(size[a],size[b]);
        if(N-2*c==0) ans[i]=-1;
        else ans[i]=abs(dis[a]-dis[b])/abs(N-2*c);
    }
    
    for(int i=0;i<N-1;i++){
        if(ans[i]==-1){
            BFS(E[i].first);
            ll sum=0;
            for(int j=0;j<N;j++) sum+=kyori[j];
            
            ans[i]=(dis[E[i].first]-sum)/cnt;
        }
    }
    
    for(int i=0;i<N-1;i++){
        cout<<ans[i]<<endl;
    }
}


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

int main(){
    ll N;
    cin>>N;

    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    ll res=0;
    for(ll i=1;i<N;i++)
    {
        if(A[i]<A[i-1]){
            res+=A[i-1]-A[i];
            A[i]+=A[i-1]-A[i];
        }
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 4816
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int c[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int N = 1e4 + 10;
int dp[N][10], t[10];
bool visit[N];

bool larger(int a[], int b[], int m) {
  int sumA = 0;
  for (int i = 0; i < m; ++i) sumA += a[i];
  int sumB = 0;
  for (int i = 0; i < m; ++i) sumB += b[i];
  if (sumA != sumB) return sumA > sumB;
  for (int i = 0; i < m; ++i) {
    if (a[i] != b[i]) return a[i] > b[i];
  }
  return false;
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(m);
  for (int i = 0; i < m; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end(), greater<int>());
  visit[0] = true;
  for (int i = 0; i < m; ++i) {
    int cost = c[a[i]];
    for (int j = cost; j <= n; ++j) {
      if (visit[j - cost]) {
        copy(dp[j - cost], dp[j - cost] + m, t);
        t[i] += 1;
        visit[j] = true;
        if (larger(t, dp[j], m)) {
          copy(t, t + m, dp[j]);
        }
      }
    }
  }
  for (int i = 0; i < m; ++i) {
    int len = dp[n][i];
    while (len--) printf("%d", a[i]);
  }
  puts("");
  return 0;
}


Measured memory_bytes: 640
#n,q = gets.chomp.to_i
n, q = gets.chomp.split(" ").map(&:to_i);
#s = gets.chomp
#

edges = {}
(n-1).times do 
  from, to = gets.chomp.split(" ").map(&:to_i);
  edges[from] = [] if edges[from].nil?
  edges[from] << to
end

#pp edges

points = {}
q.times do
  p, x = gets.chomp.split(" ").map(&:to_i);
  points[p] = [] if points[p].nil?
  points[p] << x
end

#pp points

stack = [1]
results = Array.new(n+1, 0)
#pp results
while true do
  break if stack.size == 0
  node = stack.shift

  unless points[node].nil?
    points[node].each do |p|
      results[node] += p
    end
  end

  next if edges[node].nil?
  edges[node].each do |to|
    stack << to
    results[to] += results[node]
  end
end

results.shift
puts results.join(" ")

Measured memory_bytes: 60796
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include<random>
#include<iostream>
using namespace std;

int print_dot(int c) {
	for (int i = 0; i < c; i++) {
		cout << ".";
	}
	return 0;
}

int main() {
	int N;

	cin >> N;
	if (N == 2) {
		cout << "-1";
		return 0;
	}
	if (N == 3) {
		cout << "aa.\n";
		cout << "..b\n";
		cout << "..b\n";
		return 0;
	}
	if (N % 4 == 0) {
		for (int i = 0; i < N / 4; i++) {
			print_dot(4 * i); cout << "aacd"; print_dot(N - 4 * i - 4); cout << "\n";
			print_dot(4 * i); cout << "bbcd"; print_dot(N - 4 * i - 4); cout << "\n";
			print_dot(4 * i); cout << "efgg"; print_dot(N - 4 * i - 4); cout << "\n";
			print_dot(4 * i); cout << "efhh"; print_dot(N - 4 * i - 4); cout << "\n";
		}
		return 0;
	}
	if (N % 4 == 1) {
		cout << "aabbc"; print_dot(N - 5); cout << "\n";
		cout << "hii.c"; print_dot(N - 5); cout << "\n";
		cout << "h..jd"; print_dot(N - 5); cout << "\n";
		cout << "g..jd"; print_dot(N - 5); cout << "\n";
		cout << "gffee"; print_dot(N - 5); cout << "\n";
		for (int i = 0; i < (N - 5) / 4; i++) {
			print_dot(5 + 4 * i); cout << "aacd"; print_dot(N - 4 * i - 9); cout << "\n";
			print_dot(5 + 4 * i); cout << "bbcd"; print_dot(N - 4 * i - 9); cout << "\n";
			print_dot(5 + 4 * i); cout << "efgg"; print_dot(N - 4 * i - 9); cout << "\n";
			print_dot(5 + 4 * i); cout << "efhh"; print_dot(N - 4 * i - 9); cout << "\n";
		}
		return 0;
	}
	if (N % 4 == 2) {
		cout << "aabee."; print_dot(N - 6); cout << "\n";
		cout << "d.b..f"; print_dot(N - 6); cout << "\n";
		cout << "dcc..f"; print_dot(N - 6); cout << "\n";
		cout << "g..lkk"; print_dot(N - 6); cout << "\n";
		cout << "g..l.j"; print_dot(N - 6); cout << "\n";
		cout << ".hhiij"; print_dot(N - 6); cout << "\n";
		for (int i = 0; i < (N - 6) / 4; i++) {
			print_dot(6 + 4 * i); cout << "aacd"; print_dot(N - 4 * i - 10); cout << "\n";
			print_dot(6 + 4 * i); cout << "bbcd"; print_dot(N - 4 * i - 10); cout << "\n";
			print_dot(6 + 4 * i); cout << "efgg"; print_dot(N - 4 * i - 10); cout << "\n";
			print_dot(6 + 4 * i); cout << "efhh"; print_dot(N - 4 * i - 10); cout << "\n";
		}
		return 0;
	}
	if (N % 4 == 3) {
		cout << "aabbcc."; print_dot(N - 7); cout << "\n";
		cout << ".ii.kkd"; print_dot(N - 7); cout << "\n";
		cout << "h..j..d"; print_dot(N - 7); cout << "\n";
		cout << "h..j..e"; print_dot(N - 7); cout << "\n";
		cout << ".mm.ooe"; print_dot(N - 7); cout << "\n";
		cout << "l..n..f"; print_dot(N - 7); cout << "\n";
		cout << "l..n..f"; print_dot(N - 7); cout << "\n";
		for (int i = 0; i < (N - 7) / 4; i++) {
			print_dot(7 + 4 * i); cout << "aacd"; print_dot(N - 4 * i - 11); cout << "\n";
			print_dot(7 + 4 * i); cout << "bbcd"; print_dot(N - 4 * i - 11); cout << "\n";
			print_dot(7 + 4 * i); cout << "efgg"; print_dot(N - 4 * i - 11); cout << "\n";
			print_dot(7 + 4 * i); cout << "efhh"; print_dot(N - 4 * i - 11); cout << "\n";
		}
		return 0;
	}

}

Measured memory_bytes: 1280
fun main(args: Array<String>) {
    val (x, y) = readInputLine().split(" ").map{it.toLong()}
    
    var now = x
    var cnt = 1L
    
    while (true) {
        if (now * 2L <= y) {
            now = now * 2L
            cnt++
        } else {
            break
        }
    }
    
    println(cnt)
}

fun readInputLine(): String {
    return readLine()!!
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  C *= 2;
  int ans = 2'000'000'000;
  for(int i = 0; i <= 100'000; i++){
    int sum = i*C + max(0, X-i)*A + max(0, Y-i)*B;
    ans = min(ans, sum);
  }
  cout << ans << endl;
}

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

int main() {
  int d , n ;
  cin >> d >> n ;
  
  if(d==0){
    if(n!=100){
      cout << n << endl;
    }
    else{
      cout << 101 << endl;
    }
  }
  
  if(d==1){
    if(n!=100){
      cout << n*100 << endl;
    }
    else{
      cout << 10100 << endl;
    }
  }
  
  if(d==2){
    if(n!=100){
      cout << n*10000 << endl;
    }
    else{
      cout << 1010000 << endl;
    }
  }
}

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

int main(){
  int n;
  cin >> n;
  int A[210];
  for (int i = 0; i < n; i++) cin >> A[i];
  
  int count = 0;
  while(true){
    bool exist_odd = false;
    for (int i = 0; i < n; i++){
      if(A[i] % 2 != 0) exist_odd = true;
    }
    
    if(exist_odd) break;
    
    for (int i = 0; i < n; i++){
   		A[i] = A[i] / 2;
    }
    ++count;
  	
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
//ここまで共通
llong N, K;
llong ANS = 0;
const llong MOD = 1000000007;
int main() {
	cin >> N >> K;
	for (llong i = K; i <= N + 1; i++) {
		llong tmp1 = i * (i - 1);
		tmp1 /= 2;
		llong tmp2 = (N + N - i + 1) * i;
		tmp2 /= 2;
		ANS += tmp2 - tmp1 + 1;
		ANS %= MOD;
	}
	cout << ANS;
}

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

int a[30],b[30],c[30];
int main(){
	int n;cin>>n;
	rep(i,n)cin>>a[i],a[i]--;
	rep(i,n)cin>>b[i];
	rep(i,n-1)cin>>c[i];
	int ans=0;
	rep(i,n){
		ans+=b[a[i]];
		if(i+1<n&&a[i+1]==a[i]+1)ans+=c[a[i]];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  string s;
	cin >> s;
  bool flag = false;
  rep(i,(int)s.size()){
    if(s[i] == 'C'){
      flag = true;
    }
    if(s[i] == 'F' && flag){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N,M;
int c[2];

int main(){
  cin >> N >> M;
  vector<int>ba(N), p(M);
  rep(i,N) cin >> ba[i];
  rep(i,M) cin >> p[i];
  rep(i,N) c[ba[i]]++;
  int sum=0;
  for(int i=0;i<M;i+=2) sum+=p[i];
  
  int res = INF;
  rep(loop,2){
    if(sum!=c[loop]) continue;
    int pat = loop;
    //    cout << "pat " << pat << endl;
    vector<int>b; b = ba;
    int cnt = 0;
    int pos = 0;
    rep(i,M){
      for(int j=0;j<p[i];j++){
	if(b[pos] != pat){
	  //	  cout << i << " " << j << endl;
	  int k = pos;
	  while(b[k]!=pat) k++;
	  for(int l=k;l>pos;l--){
	    swap(b[l], b[l-1]);
	    cnt++;
	  }
	}
	pos++;
	//	rep(j,N) cout << b[j] << " "; cout << endl;
      }
      pat ^= 1;
    }
    res = min(res, cnt);
  }
  cout << res << endl;  
  return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
#include <iomanip>  
#define loop(a) for(int i=0;i<a;++i)
#define floop(a,b) for(int b=0;b<a;++b)
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if(c % (max(a, b))==0)cout << c / (max(a, b)) << endl;
	else cout << c / (max(a, b)) + 1 << endl;
	//cin >> a;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int N, R;

	scanf("%d %d", &N, &R);

	if (R > 4111) {
		return 0;
	}
	else if (N < 10) {
		printf("%d", R + 100 * (10 - N));
	}
	else {
		printf("%d", R);
	}
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES


#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <numeric>

#include <cmath>

using namespace std;

typedef long long LL;

int main() {
	int n;
	vector<int> vec;

	cin >> n;
	int temp;
	for (int i = 0; i < n; ++i) {
		cin >> temp;
		vec.emplace_back(temp);
	}

	reverse(vec.begin(), vec.end());

	for (int i = 0; i < n; ++i) {
		printf("%d", vec[i]);

		if (i != (n - 1)) printf(" ");
	}

	printf("\n");
	return 0;
}



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

int main() {
    int N;
    cin >> N;
    vector<int64_t> data(N+1);
    data.at(0) = 2;
    data.at(1) = 1;
    for (int i=2; i<=N; i++){
        data.at(i) = data.at(i-1) + data.at(i-2);
    }
    cout << data.at(N) <<endl;
}

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

#define pb push_back
#define mp make_pair
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=(int)s.length();
    if(l<=n)
    cout<<s<<endl;
    else
    {
		for(int i=0;i<n;i++)
		cout<<s[i];
		cout<<"...";
		cout<<'\n';
	}
 }
  

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  string X, Atoa;
  cin >> A >> B >> X;
  Atoa = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  for(int i = 0; i < 26; i++) {
    if(X.at(B - 1) == Atoa.at(i)) {
      X.at(B - 1) = Atoa.at(i + 26);
      break;
    }
  }
  cout << X << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
	int a[3];
	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}
	if (a[0] == a[1])
	{
		if (a[0] == a[2])
		{
			cout << "No" << endl;
		}
		else
			cout << "Yes" << endl;
		return 0;
	}
	if (a[0] == a[2])
	{
		if (a[0] == a[1])
		{
			cout << "No" << endl;
		}
		else
			cout << "Yes" << endl;
		return 0;
	}
	if (a[1] == a[2])
	{
		if (a[0] == a[1])
		{
			cout << "No" << endl;
		}
		else
			cout << "Yes" << endl;
		return 0;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256