akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

# modを取りながらべき乗する
def power_func(a,n,mod):
    bi=str(format(n,"b"))#2進表現に
    res=1
    for i in range(len(bi)):
        res=(res*res) %mod
        if bi[i]=="1":
            res=(res*a) %mod
    return res

def main():
    N, C = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    mod = 10**9+7
    L = 400

    dp = [[0]*(L+1) for _ in range(C+1)]
    count = B[0] - A[0] + 1
    for c in range(C+1):
        a, b = A[0], B[0]
        dp[c][0] = power_func(a, c, mod)
        for k in range(1, b-a+1):
            dp[c][k] = (dp[c][k-1] + power_func(a+k, c, mod)) % mod
        dp[c][L] = dp[c][b-a]

    for i, (a, b) in enumerate(zip(A, B)):
        if i == 0: continue
        for k in range(b-a+1):
            dp[0][k] = count * (k+1) % mod
        dp[0][L] = dp[0][b-a]
        for c in range(1, C+1):
            dp[c][0] = (dp[c][L] + a*dp[c-1][0]) % mod
            for k in range(1, b-a+1):
                R = dp[c][k-1] + dp[c][L] + (a+k)*(dp[c-1][k]-dp[c-1][k-1])
                if R < 0: R += mod
                dp[c][k] = R%mod
            dp[c][L] = dp[c][b-a]
        count = (count * (b-a+1)) % mod

    print(dp[C][L])


if __name__ == "__main__":
    main()

Measured memory_bytes: 106076
#include <iostream>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int n=a.length();
    if(n%2==0)
    {
        if(a[0]==a[n-1])
            cout<<"First";
        else
            cout<<"Second";
    }
    else
    {
        if(a[0]==a[n-1])
            cout<<"Second";
        else
            cout<<"First";
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(x,y) '(' << x << ',' << y << ')'
ll MOD = 1000000007;
ll INF = 214748364700000000;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
   char c;cin >> c;
   char a = c + 1;
   cout << a << endl;
}


Measured memory_bytes: 256
import sys
for line in sys.stdin.readlines():
    stack=[]
    for a in line.strip().split():
        if a=="+":
            a=stack.pop()+stack.pop()
        elif a=="-":
            a=-(stack.pop()-stack.pop())
        elif a=="*":
            a=stack.pop()*stack.pop()
        elif a=="/":
            a=1.0/stack.pop()*stack.pop()
        stack.append(float(a))
    print "{:.6f}".format(stack[0]+0)

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

int main()
{
    int a,b,c,x,y;
    cin >>a>>b>>c>>x>>y;
    int sum = 0;
    if(c*2<=a+b){
        sum += c*2*min(x,y);
        if(x<=y){ // bが足りない
            sum += min(b,2*c)*(y-x);
        }
        else{     // aが足りない
            sum += min(a,2*c)*(x-y);
        }
    }
    else{
        sum = a*x + b*y;
    }

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

Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
h = rl()
temp = 0
for i in h:
    if temp == i:
        continue
    elif temp < i:
        temp = i-1
        continue
    else:
        print('No')
        exit()
else:
    print('Yes')






Measured memory_bytes: 21540
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void){
    
    string s;
    cin>>s;
    
    int n=s.size();
    vector<int> v(n);
    vector<int> w(n, 0), w2(n,0);
    
    for(int i=0; i<n; i++){
        
        v[i]=(s[i]=='R'?1:-1);
    }
    
    int cnt=1;
    for(int i=0; i<n-1; i++){
        if(s[i]=='R'&&s[i+1]=='L'){
            w[i]=cnt;
            cnt=1;
        }else if(s[i]=='R'){
            cnt++;
        }
    }
    
    cnt=1;
    for(int i=n-1; i>=1; i--){
        if(s[i]=='L'&&s[i-1]=='R'){
            w[i]=cnt;
            cnt=1;
        }else if(s[i]=='L'){
            cnt++;
        }
    }
    
    for(int i=0; i<n-1; i++){
        if(w[i]*w[i+1]>0){
            int t=w[i]+w[i+1];
            
            if(t%2==0){
                w2[i]=t/2;
                w2[i+1]=t/2;
            }else{
                w2[i]=t/2;
                w2[i+1]=t/2;
                if(w[i]%2==0){
                    w2[i+1]++;
                }else{
                    w2[i]++;
                }
            }
            i++;
        }
    }
    
    for(int i=0; i<n; i++){
        cout<<w2[i]<<" ";
    }
    cout<<endl;
    
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N, A, B, C, D; cin >> N >> A >> B >> C >> D, A--, B--, C--, D--;
    string S; cin >> S;

    for(int i=A;i<max(C, D);i++){
        if(S[i]=='#' and S[i+1]=='#') {cout << "No" << endl; return 0;}
    }

    if(C<D) {cout << "Yes" << endl; return 0;}

    for(int i=B-1;i<D;i++){
        if(S[i]=='.' and S[i+1]=='.' and S[i+2]=='.') {cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <math.h>
#include <functional>
using namespace std;

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    cout << p + q + r - max({p, q, r}) << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


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

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	int N,number;
	deque<int> ve;

	cin>>N;
	REP(i,N){
		cin>>number;
		if(i%2==1) ve.push_front(number);
		else ve.push_back(number);
	}

	if(N%2==0){
		REP(i,N) printf("%d ",ve[i]);
	}else{
		RREP(i,N) printf("%d ",ve[i]);
	}
	cout<<endl;
	return 0;
}



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

const int MOD = 1000000007;
int N, M;
vector<int> A, B;

long long solve(){
    long long res = 1;
    int biggerX_a = 0, biggerX_b = 0; // A, Bでxより大きいのが何個あるのか
    for (int x = N*M; x >= 1; --x) {
        if (A[biggerX_a] > x) return 0;
        if (B[biggerX_b] > x) return 0;

        long long tmp  = 1;
        if (A[biggerX_a] == x && B[biggerX_b] == x) {
            tmp = 1;
            ++biggerX_a, ++biggerX_b;
        }
        else if (A[biggerX_a] == x) {
            tmp = biggerX_b;
            ++biggerX_a;
        }
        else if (B[biggerX_b] == x) {
            tmp = biggerX_a;
            ++biggerX_b;
        }
        else {
            tmp = biggerX_a * biggerX_b - (N*M-x);
            if (tmp <= 0) return 0;
        }
        res = (res * tmp) % MOD;
    }
    return res;
}
int main(){
    cin >> N >> M;
    A.resize(N + 1); B.resize(M + 1);
    for (int i = 0; i < N; ++i) cin >> A[i];
    for (int i = 0; i < M; ++i) cin >> B[i];
    sort(A.begin(), A.end(), greater<int>());
    sort(B.begin(), B.end(), greater<int>());
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

signed main()
{
	int n;cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];
	bool zero=false;

	rep(i,n)if (a[i]==0)zero=true;

	int mx=TEN(18);

	if (zero) {
		puts("0");
		return 0;
	}

	int p = 1;
	rep(i, n) {
		if (p > (long double)mx/a[i]){
			puts("-1");
			return 0;
		}
		p*=a[i];
	}
	printf("%lld\n",p);
}




Measured memory_bytes: 4048
# -*- coding: utf-8 -*-
S = input()
T = input()
candidates = list()
for i in range(len(S) - len(T) + 1):
    flag = True
    for j in range(len(T)):
        if S[i+j] != T[j] and S[i+j] != "?":
            flag = False
            break
    if flag:
        s = S[:i] + T + S[i+j+1:]
        candidates.append(s.replace("?", "a"))
if candidates:
    candidates.sort()
    print(candidates[0])
else:
    print("UNRESTORABLE")


Measured memory_bytes: 61804
#include<bits/stdc++.h>
using namespace std;
#define MAX 10005

struct edge{
  int from,to;
  double cost;
  bool operator < (const edge &e)const{
    return cost < e.cost;
  }
};
  
int n,m,a,b;
double x[MAX],y[MAX];
vector<edge> G;

int par[MAX];

int find(int x){
  if(par[x]==x)return x;
  return par[x]=find(par[x]);
}

double dist(int i,int j){
  double X=x[i]-x[j];
  double Y=y[i]-y[j];
  return sqrt(X*X+Y*Y);
}

int main(){
  cin>>n>>m;
  
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
    par[i]=i;
  }
  
  for(int i=0;i<m;i++){
    cin>>a>>b;
    a--,b--;
    G.push_back((edge){a,b,dist(a,b)});
  }
  sort(G.begin(),G.end());
  reverse(G.begin(),G.end());
  double ans=0;
  for(int i=0;i<m;i++){
    edge e=G[i];
    e.from=find(e.from);
    e.to=find(e.to);
    if(e.from==e.to){
      ans+=e.cost;
    }else{
      par[e.from]=e.to;
    }
  }
  printf("%.3f\n",ans);
  return 0;
}

Measured memory_bytes: 2036
#line 1 "DPL_5_A.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_5_A"

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

#line 1 "../powmod.cpp"
ll powmod(ll a, ll n, ll p) {
  ll res = 1;
  while (n) {
    if (n&1) res = res * a % p;
    a = a * a % p;
    n >>= 1;
  }
  return res;
}
#line 15 "DPL_5_A.test.cpp"

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

  ll n, k;
  cin >> n >> k;
  ll mod = 1e9+7;
  cout << powmod(k, n, mod) << endl;
}



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

int main() {
    int N, f;
    string S;
    f = 0;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> S;
        if (S == "Y" && f == 0) {
            cout << "Four" << endl;
            f++;
        }
    }

    if (f == 0) {
        cout << "Three" << endl;
    }

}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    ll N;
    cin>>N;
    
    vector<ll> a(N);
    ll sunuke=0;
    for(int i=0;i<N;i++){
        cin>>a[i];
        sunuke+=a[i];
    }
    
    ll arai=0;
    ll ans=1e15;
    for(int i=0;i<N-1;i++){
        arai+=a[i];
        sunuke-=a[i];
        ans=min(ans,abs(arai-sunuke));
    }
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  rep(i, s.size())
    cout << 'x';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

ll gcd(ll x, ll y)
{
    if (x < y) {
        swap(x, y);
    }

    if (y == 0) {
        return x;
    }

    return gcd(y, x % y);
}

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

    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    vector<ll> forward(N);
    forward[0] = A[0];
    for (int i = 1; i < N; ++i) {
        forward[i] = gcd(forward[i-1], A[i]);
    }

    vector<ll> backward(N);
    backward[N-1] = A[N-1];
    for (int i = N-2; i >= 0; --i) {
        backward[i] = gcd(backward[i+1], A[i]);
    }

    ll ans = 0;
    for (int i = 1; i < N-1; ++i) {
        ll g = gcd(forward[i-1], backward[i+1]);
        ans = max(ans, g);
    }

    // 0番目を書き換えた場合
    ans = max(ans, backward[1]);
    // N-1番目を書き換えた場合
    ans = max(ans, forward[N-2]);

    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

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

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



    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N*A, B) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 200001
#define inf 1e15
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a,b,a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,m,n,m1,m2,n1,n2,o,p,p1,p2,p3,p4,
q,q1,q2,q3,q4,r,s,t,u,v,x,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;

//double rat;
L A[205],B[205];

bool isValid(L ax,L bx,L cx){
	if((A[ax]+A[bx]>A[cx]) && (A[ax]+A[cx]>A[bx]) && (A[bx]+A[cx]>A[ax]))return true;
	return false;
}
void solve(){
	sort(A,A+n);
	c=0;
	for(L i=0;i<n;i++){
		for(L j=i+1;j<n;j++){
			if(A[i]==A[j])continue;
			for(L k=j+1;k<n;k++){
				if(A[j]==A[k])continue;
				if(isValid(i,j,k)){
					c++;
				}
			}
		}
	}
}
int main()
{
    scanf("%lld",&n);
    for(L i=0;i<n;i++){
    	scanf("%lld",&A[i]);
    }
    solve();
    printf("%lld\n",c);
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 0; --i)
#define repBX(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int A,B;
    cin >> A >> B;
    --A;--B;
    vector<bool> Q(3);
    Q[A] = true;
    Q[B] = true;
    rep(i,3){
        if(!Q[i])cout << i+1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char str[100005];
int main()
{
    scanf("%s",str);
    int len = strlen(str);
    if(len==2)
    {
        if(str[0]==str[1])
        {
            printf("1 2\n");
        }
        else
            printf("-1 -1\n");
        return 0;
    }
    for(int i=0;i<len;i++)
    {
        if(i+2>=len) break;
            char a = str[i];
            char b = str[i+1];
            char c = str[i+2];
            if(a==b||a==c||b==c)
            {
                printf("%d %d\n",i+1,i+3);
                return 0;
            }
    }
    printf("-1 -1\n");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int>a(5);
  for (int i=0;i<5;i++) {
    cin >> a.at(i);
    if(a.at(i)==0){
      cout << i+1 << endl;
      return 0;
    }
  }
  
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint X; cin >> X;
    lint cur_money = 100;
    lint year_passed = 0;
    while (cur_money < X) {
        year_passed += 1;
        cur_money = (lint)floor(1.01 * cur_money);
        // cout << cur_money << "\n";
    }
    cout << year_passed << "\n";
}

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

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n,q = [int(i) for i in readline().split()]
s = input()+"G"
lr = [[int(i)-1 for i in readline().split()] for _ in range(q)]

res = [0]*(n+1)

for i,c in enumerate(s[:-1]):
    res[i+1] = res[i] + (1 if s[i]=="A" and s[i+1] == "C" else 0)

for l,r in lr:
    ans = res[r+1] - res[l]
    if  s[r]=="A" and s[r+1] == "C":
        ans -= 1
    print(ans)
    

#print(s)
#print(res)



Measured memory_bytes: 26076
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

long count = 0;

void Merge(long *A, long left, long mid, long right) {
  long n1,n2,*L,*R,i,j,k;
  n1 = mid -left;
  n2 = right - mid;
  L = (long*)malloc(sizeof(long) * (n1+1));
  R = (long*)malloc(sizeof(long) * (n2+1));
  for (i = 0; i< n1; i++) {
    L[i] = A[left+i];
  }
  for (i = 0; i < n2; i++) {
    R[i] = A[mid+i];
  }
  L[n1] = LONG_MAX; R[n2] = LONG_MAX;
  i = 0;j = 0;
  for(k = left; k < right; k++) {
    if (L[i] < R[j]) {
      A[k] = L[i];
      i++;
    }else {
      A[k] = R[j];
      j++;
      count+=n1-i;
    }
  }
  free(L);
  free(R);
}

void Merge_Sort(long *A, long left, long right) {
  if(left+1 < right) {
    long mid = (left + right)/2;
    Merge_Sort(A,left,mid);
    Merge_Sort(A,mid,right);
    Merge(A,left,mid,right);
  }
}

int main()
{
  long i,n,*S;
  scanf("%ld", &n);
  S = (long*)malloc(sizeof(long) * n);
  for (i = 0; i < n; i++) {
    scanf("%ld", S+i);
  }
  Merge_Sort(S,0,n);
  printf("%ld\n", count);
  return 0;
}

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

int main() {
  int n;cin>>n;
  ll k;cin>>k;
  int an[n]; rep(i,n)cin>>an[i];
  int dn[n];
  dn[0] = 0;
  rep(i,n-1) dn[i+1] = an[ dn[i] ]-1;
  //rep(i,n)cout<<dn[i]<<" ";
  //cout<<endl;
  
  int m, b;
  int fn[n];rep(i,n)fn[i]=-1;
  rep(i,n) {
    //rep(i,n)cout<<fn[i]<<" ";
    //cout<<endl;
    if (fn[ dn[i] ] != -1) {
      m = i - fn[ dn[i] ];
      b = fn[ dn[i] ];
      break;
    }
    fn[ dn[i] ] = i;
  }
  if (k-b>0) {
    k = ((k-b) % m ) + b;
  }
  //cout<<m<<" "<<b<<endl<<k<<endl;
  cout<<dn[k]+1;
}


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

int main() {
  string s,t; cin >> s >> t;
  
  int ans = 1001;
  for(int i = 0; i < s.size(); i++) {
    if(i+t.size() > s.size()) break;
    int cnt = 0;
    for(int j = 0; j < t.size(); j++) {
		if(s.at(i+j) != t.at(j)) cnt++;
    }
    if(ans > cnt) ans = cnt;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main() {
    int n; cin>>n;
    
    long long int a[n],b[n],sum1=0,sum2=0;
    for(int i=0;i<n;++i){
        cin>>a[i];
        sum1+=a[i];
        if(i % 2 == 0 && i != 0) sum2+=a[i];
    }
    
    b[1]= sum1 - 2*sum2;
    
    for(int i=2;i<n;++i){
        b[i] = 2*a[i-1] - b[i-1];
    }
    b[0] = 2*a[n-1] - b[n-1];
  
    for(int i=0;i<n-1;++i){
    cout<<b[i]<<" ";
    }
    
    cout<<b[n-1]<<endl;

	return 0;
}

Measured memory_bytes: 2816
using System;
using System.Linq;
 
class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        int front = int.Parse(s[0].ToString()) * 10 + int.Parse(s[1].ToString());
        int back = int.Parse(s[2].ToString()) * 10 + int.Parse(s[3].ToString());
        bool isYYMM = false;
        bool isMMYY = false;
        if (back >= 1 && back <= 12)
            isYYMM = true;
        if (front >= 1 && front <= 12)
            isMMYY = true;
 
        string ans = "";
        if (isYYMM && isMMYY)
            ans += "AMBIGUOUS";
        else if (!isYYMM && !isMMYY)
            ans += "NA";
        else if (isYYMM)
            ans += "YYMM";
        else
            ans += "MMYY";
 
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		String ans = "No";
		int[] all = new int[3];
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = reader.nextInt();
			int tmp = arr[i];
			for (int j = 1; j < 4; j++) {
				if (tmp % (2*j) != 0 || j == 3) {
					all[j-1]++;
					break;
				}
			}
		}
		if (arr.length == 1) {
			if (arr[0] % 4 == 0 ) {
				ans = "Yes";
			}
			System.out.println(ans);
			reader.close();
			return;
		}
		if (all[1] > 0) {
			if (all[2] >= all[0]) {
				ans = "Yes";
			}
		} else {
			if (all[2] >= all[0] - 1) {
				ans = "Yes";
			}
		}


		System.out.println(ans);
		reader.close();

	}
}





Measured memory_bytes: 50928
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int vsum(vi hoge) {
	int result = 1;

	REP(i, hoge.size()) {
		result += hoge[i];
	}

	return result;
}

int main() {
	int n, m;

	while(cin >> n >> m, n, m) {
		vi taro(n);
		vi hanako(m);

		REP(i, n) {
			cin >> taro[i];
		}
		REP(i, m) {
			cin >> hanako[i];
		}

		int tres, hres;
		int taroc = -1, hanakoc = -1;
		int min = 100000;

		REP(i, n) {
			REP(j, m) {
				tres = vsum(taro) - taro[i] + hanako[j];
				hres = vsum(hanako) - hanako[j] + taro[i];

				if(tres == hres) {
					if(min > taro[i]+hanako[j]) {
						min = taro[i]+hanako[j];
						taroc = taro[i], hanakoc = hanako[j];
					}
				}
			}
		}

		if(taroc < 0) {
			cout << taroc << endl;
		} else {
			cout << taroc << " " << hanakoc << endl;
		}
	}
}

Measured memory_bytes: 0
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] S = Console.ReadLine().ToCharArray();
            int ans = 0;
            foreach (char c in S)
            {
                if (c == '+')
                {
                    ans++;
                }
                else
                {
                    ans--;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <algorithm>

using namespace std;

int n, k;
int ps[2][2002][2002];

int sum(int r1, int c1, int r2, int c2, int w) {
	if(r1>r2 || c1>c2) return 0;
	int ret=ps[w][r2][c2];
	if(r1>0) ret-=ps[w][r1-1][c2];
	if(c1>0) ret-=ps[w][r2][c1-1];
	if(r1>0 && c1>0) ret+=ps[w][r1-1][c1-1];
	return ret;
}

int main() {
	scanf("%d %d",&n,&k);
	while(n--) {
		int x, y;
		char c;
		scanf("%d %d %c",&x,&y,&c);
		x%=2*k; y%=2*k;
		if(c=='W') ps[0][x][y]++;
		else ps[1][x][y]++;
	}
	for(int i=0;i<2*k;i++) {
		for(int j=0;j<2*k;j++) {
			for(int t=0;t<2;t++) {
				if(i>0) ps[t][i][j]+=ps[t][i-1][j];
				if(j>0) ps[t][i][j]+=ps[t][i][j-1];
				if(i>0 && j>0) ps[t][i][j]-=ps[t][i-1][j-1];
			}
		}
	}
	int res=0;
	/*
	for(int w=0;w<2;w++) {
		int d=sum(0,0,k-1,k-1,w)+(k,k,2*k-1,2*k-1,w)+
			sum(0,k,k-1,2*k-1,w^1)+sum(k,0,2*k-1,k-1,w^1);
		if(d>res) res=d;
	}
	*/
	{
		int r[3]={0,k,2*k}, c[3]={0,k,2*k};
		int sum1=0, sum2=0;
		for(int r1=0;r1<2;r1++) {
			for(int c1=0;c1<2;c1++) {
				if((r1+c1)%2) {
					sum1+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,0);
					sum2+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,1);
				} else {
					sum1+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,1);
					sum2+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,0);
				}
			}
			if(max(sum1,sum2)>res) res=max(sum1,sum2);
		}
	}
	for(int j=0;j+k+1<2*k;j++) {
		int r[3]={0,k,2*k}, c[4]={0,j+1,j+k+1,2*k};
		int sum1=0, sum2=0;
		for(int r1=0;r1<2;r1++) {
			for(int c1=0;c1<3;c1++) {
				if((r1+c1)%2) {
					sum1+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,0);
					sum2+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,1);
				} else {
					sum1+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,1);
					sum2+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,0);
				}
			}
		}
		if(max(sum1,sum2)>res) res=max(sum1,sum2);
	}
	for(int i=0;i+k+1<2*k;i++) {
		int r[4]={0,i+1,i+k+1,2*k}, c[3]={0,k,2*k};
		int sum1=0, sum2=0;
		for(int r1=0;r1<3;r1++) {
			for(int c1=0;c1<2;c1++) {
				if((r1+c1)%2) {
					sum1+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,0);
					sum2+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,1);
				} else {
					sum1+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,1);
					sum2+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,0);
				}
			}
		}
		if(max(sum1,sum2)>res) res=max(sum1,sum2);
	}
	for(int i=0;i+k+1<2*k;i++) {
		for(int j=0;j+k+1<2*k;j++) {
			int sum1=0, sum2=0;
			int r[4]={0,i+1,i+k+1,2*k}, c[4]={0,j+1,j+k+1,2*k};
			for(int r1=0;r1<3;r1++) {
				for(int c1=0;c1<3;c1++) {
					if((r1+c1)%2) {
						sum1+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,0);
						sum2+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,1);
					} else {
						sum1+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,1);
						sum2+=sum(r[r1],c[c1],r[r1+1]-1,c[c1+1]-1,0);
					}
				}
			}
			if(max(sum1,sum2)>res) res=max(sum1,sum2);
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 31488
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;

constexpr ll INF = 1e18;

struct node {
    ll n;
    ll c;
    node (ll n, ll c) : n(n), c(c) {}
};

ll N, M;
unordered_map<ll, unordered_map<ll, vector<node> > > G;
unordered_map<ll, unordered_map<ll, ll> > dist;
queue<node> que;

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

    cin >> N >> M;

    for (ll i = 0; i < M; i++) {
        ll p, q, c;
        cin >> p >> q >> c;
        // move in same campanies
        G[p][c].push_back(node(q, c));
        G[q][c].push_back(node(p, c));

        // exit and enter
        G[p][c].push_back(node(p, 0));
        G[p][0].push_back(node(p, c));
        G[q][c].push_back(node(q, 0));
        G[q][0].push_back(node(q, c));

        dist[p][0] = INF;
        dist[q][0] = INF;
        dist[p][c] = INF;
        dist[q][c] = INF;
    }

    dist[N][0] = INF;

    que.push(node(1, 0));
    dist[1][0] = 0;
    while (!que.empty()) {
        auto token = que.front(); que.pop();
        
        for (auto r : G[token.n][token.c]) {
            ll newcost = dist[token.n][token.c];
            if (token.c == 0) {
                newcost++;
            }

            if (newcost < dist[r.n][r.c]) {
                dist[r.n][r.c] = newcost;
                que.push(node(r.n, r.c));
            }
        }
    }
    
    ll ans = dist[N][0];
    cout << (ans == INF ? -1 : ans) << endl;
    return 0;
}



Measured memory_bytes: 101704
#include<bits/stdc++.h>
using namespace std;
int cnt[30];

int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    cnt[s[i]-'a']++;
  }
  for(int i=0;i<26;i++){
    if(cnt[i]>1){
      cout<<"no"<<endl;
      return(0);
    }
  }
  cout<<"yes"<<endl;  
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long
ll n,m,d;
ll res=0;

ll nvl(ll a,ll b){//ap-2乗るを返す
	if(a<=0||b<=0)return 0;
	ll tmp=1;
		
			while(b){
						if(b&1){
										tmp=(tmp*a);
												}
														a=(a*a);
																b/=2;
																}	
			return tmp;
}

int main(){
	cin>>n>>m>>d;
	if(d>=n){
		cout<<0<<endl;
		return 0;
	}
	if(d==0){

	ll w=pow(n,m);
	ll res=0;
	double ans=1.0/(n*n);
	double h=(n-d)*(m-1);
	ans*=h;
	//ans=(double)res/(double)w;
		printf("%.10lf\n",ans);
		return 0;
	}

	ll w=pow(n,m);
	ll res=0;
	double ans=1.0/(n*n);
	double h=(n-d)*2*(m-1);
	ans*=h;
	//ans=(double)res/(double)w;
	printf("%.10lf\n",ans);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,X,T;
  cin >> N >> X >> T;
  int time = (N+(X-1))/X;
  cout << time * T << endl;
  return 0;
}

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

vector<int> dijkstra(vector<vector<pair<int,int>>> route, int start) {
    vector<int> dist;
    dist.resize(route.size());
    rep(i,dist.size()) dist[i] = -1;
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> hq;
    hq.push(make_pair(0,start));
    while (not hq.empty()) {
        auto t = hq.top(); hq.pop();
        auto cost = t.first;
        auto point = t.second;
        if (dist[point] != -1) continue;
        dist[point] = cost;
        for (auto i: route[point]) {
            if (dist[i.second] != -1) continue;
            hq.push(make_pair(cost+i.first, i.second));
        }
    }
    return dist;
}

int main() {
    int n,m,r; cin >> n >> m >> r;
    int rr[8];
    rep(i,r) cin >> rr[i];
    sort(rr,rr+r);
    int a[20000],b[20000],c[20000];
    rep(i,m) cin >> a[i] >> b[i] >> c[i];
    // pair<cost,next>
    vector<vector<pair<int,int>>> route;
    route.resize(n+1);
    rep(i,m) {
        route[a[i]].push_back(make_pair(c[i],b[i]));
        route[b[i]].push_back(make_pair(c[i],a[i]));
    }
    int dist[8][8];
    rep(i,r) {
        auto di =  dijkstra(route,rr[i]);
        rep(j,r) {
            dist[i][j] = di[rr[j]];
        }
    }
    int ans = 1e9;
    int par[8];
    rep(i,r) par[i] = i;
    do {
        int cost = 0;
        rep(i,r-1) {
            cost += dist[par[i]][par[i+1]];
        }
        ans = min(ans, cost);
   } while (next_permutation(par,par+r));
    cout << ans << endl;
}

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

typedef long long ll;
const int N = 2005;
const int M = 1000000007;

int n;
ll x;
ll dp[N][N];

int main() {
  while (~scanf("%d%lld", &n, &x)) {
    for (int i = 0; i < n; i++) {
      scanf("%lld", &dp[i][0]);
    }
    for (int i = 0; i < n; i++) {
      for (int j = 1; j < n; j++) {
        dp[i][j] = min(dp[i][j - 1], dp[(i - j + n) % n][0]);
      }
    }
    for (int j = 0; j < n; j++) {
      for (int i = n - 1; i >= 0; i--) {
        dp[i][j] += dp[i + 1][j];
      }
    }
    ll ans = 0x3f3f3f3f3f3f3f3fll;
    for (int j = 0; j < n; j++) {
      ans = min(ans, j * x + dp[0][j]);
    }
    printf("%lld\n", ans);
  }
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=1e6+9;
 
// Happy Coding!

ll _find(ll a,ll b,ll c){
    vll arr={a,b,c};
    sort(all(arr));
    a=arr[0];
    b=arr[1];
    c=arr[2];
    
    if(a%2==0 || b%2==0 || c%2==0){
        return 0;
    }
    return a*b;
}

void solve(){
    ll x,y;
    cin>>x>>y;
    
    int cnt=1;
    while(x*2<=y){
        cnt++;
        x*=2;
    }
    cout<<cnt<<endl;
}

int main() {
    faster;
    int t=1;
    // cin>>t;
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3700
import java.util.*;

public class Main {
	
	static LinkedList<Integer> ary = new LinkedList<Integer>();
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int a[] = new int[N];
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			if(map.containsKey(a[i])) {
				map.put(a[i], map.get(a[i]) + 1);
			} else {
				map.put(a[i], 1);
			}
		}
		
		int ans = 0;
		for(int key : map.keySet()) {
			if(map.get(key) % 2 == 1) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 63004
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst ll T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define ll long long int
#define vt vector
#define pb push_back
int main()
{
    vite;
    ll x, n;
    cin >> x >> n;
    vector<ll> p;
    ll  t = MAX, b = MAX,d=MAX;
    for (ll i = 0; i < n;i++)
    {
        ll c;
        cin >> c;
        p.pb(c);
    }
    sort(p.begin(), p.end());
    for (ll i = x; i >= 0;i--)
    {
        if(find(p.begin(),p.end(),i)==p.end())
        {
            b = i;
            break;
        }
    }
    for (ll i = x + 1;;i++)
    {
        if(find(p.begin(),p.end(),i)==p.end())
        {
            d = i;
            break;
        }
    }
    if(abs(x-b)<=abs(x-d))
    cout << b;
    else
        cout << d;
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long
int mian(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(true){
		c-=b;
		if(c<=0){
			cout<<"Yes"<<endl;
			return 0;
		}
		a-=d;
		if(a<=0){
			cout<<"No"<<endl;
			return 0;
		}
	}
	return 0;
}
signed main(){
	int t=1;
//	cin>>t;
	while(t--)
		mian();
	return 0;
}


Measured memory_bytes: 3584
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n+m-1)]

lst=[0]*n
dic=defaultdict(list)
for a,b in ab:
    dic[a-1].append(b-1)
    lst[b-1]+=1
# print(lst)
ne=-1
for i in range(n):
    if lst[i]==0:
        ne=i

g=[-1]*n
d=deque([ne])
while d:
    now=d.popleft()
    for i in dic[now]:
        lst[i]-=1
        if lst[i]==0:
            d.append(i)
            g[i]=now
#     print(d)
# print(g)
for i in range(n):
    print(g[i]+1)

Measured memory_bytes: 111840
#include <iostream>
    #include <map>
    using namespace std;
     
     int main() {
    	map<int, pair<int, int>> a;
    	int in;
    	int row[8] = {0};
    	int n;
     
    	for(int i = 0; i < 3; i++) {
    		for(int j = 0; j < 3; j++) {
    			cin >> in;
    			a[in] = make_pair(i+1, j+1);
    		}
    	}
     
    	cin >> n;
     
    	for(int i = 0; i < n; i++) {
    		cin >> in;
    		if(a[in].first != 0 && a[in].second != 0) {
    			row[a[in].first-1]++;
    			row[a[in].second-1+3]++;
    			if(a[in].first == a[in].second) row[6]++;
    			if(a[in].first == 4-a[in].second) row[7]++;
    		}
    	}
     
    	for(int i = 0; i < 8; i++)
    		if(row[i] == 3) {
    			cout << "Yes" << endl;
    			return 0;
    		}
    	cout << "No" << endl;
     }

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>

using namespace std;
#define lli long long int
#define numberofdigits(x) floor(log10(x)) + 1

int main()
{
    lli x;
    cin>>x;
    if(x<=599)
        cout<<"8\n";
    else if(x<=799)
        cout<<"7\n";
    else if(x<=999)
        cout<<"6\n";
    else if(x<=1199)
        cout<<"5\n";
    else if(x<=1399)
        cout<<"4\n";
    else if(x<=1599)
        cout<<"3\n";
    else if(x<=1799)
        cout<<"2\n";
    else if(x<=1999)
        cout<<"1\n";
    return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
#define rep(x, y, a) for (ll x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

typedef vector<int> vi;
typedef vector<pii> vpii;
namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    vi a(5);
    cin >> a;
    put(find(all(a), 0) - a.begin() + 1);
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;
    while (q--) solve();
}





Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = (int) 1e5 + 100;

int _fn[N];

int getSum(int pos)
{
    pos++;
    int ans = 0;
    for (; pos > 0; pos = pos & (pos - 1))
        ans += _fn[pos];
    return ans;
}

void addVal(int pos, int x)
{
    pos++;
    for (; pos < N; pos = (pos | (pos - 1)) + 1)
        _fn[pos] += x;
}

long long calcInvs(vector <int> &v)
{
    memset(_fn, 0, sizeof _fn);
    long long ans = 0;
    for (int i = (int) v.size() - 1; i >= 0; i--)
    {
        ans += getSum(v[i]);
        addVal(v[i], 1);
    }
    return ans;
}

const long long K = N;
int a[N][3];
int b[N][3];

int crev[2];
long long cinv[2];

long long A[N];
long long B[N];

vector <int> p[2];

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n;
    scanf("%d", &n);
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < n; j++)
        {
            scanf("%d", &a[j][i]);
            b[j][i] = 3 * j + i + 1;
        }

    for (int i = 0; i < n; i++)
    {
        if (a[i][0] > a[i][2])
        {
            swap(a[i][0], a[i][2]);
            crev[i % 2]++;
        }
        A[i] = a[i][0] * K * K + a[i][1] * K + a[i][2];
        B[i] = b[i][0] * K * K + b[i][1] * K + b[i][2];
    }

    map <long long, int> Bpos;
    for (int i = 0; i < n; i++)
        Bpos[B[i]] = i;

    for (int i = 0; i < n; i++)
    {
        auto it = Bpos.find(A[i]);
        if (it == Bpos.end() || it->second % 2 != i % 2)
        {
            printf("No\n");
            return 0;
        }
        p[i % 2].push_back(it->second / 2);
    }
    for (int i = 0; i < 2; i++)
        cinv[i] = calcInvs(p[i]);

    for (int t = 0; t < 2; t++)
        if (cinv[t] % 2 != crev[t ^ 1] % 2)
        {
            printf("No\n");
            return 0;
        }

    printf("Yes\n");

	return 0;
}




Measured memory_bytes: 11388
import java.io.*;
import java.util.*;


public class Main {
    static BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
    static BufferedReader cin  = new BufferedReader(new InputStreamReader(System.in));
    static int[][] arr ;
    static int n, m;

    public static void main(String[] args) throws IOException {
        String[] strs = cin.readLine().split(" ");
        int A = Integer.parseInt(strs[0]);
        int P = Integer.parseInt(strs[1]);
        int pieces = A * 3 + P;
        System.out.println(pieces / 2);
    }


}

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

#define ll   long long int
#define PI 3.14159265358979
#define zig ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;


int main()
{
    zig
    string a, b, c;
    char turn='a';
    cin>>a>>b>>c;
    while(1)
    {
        if(turn=='a')
        {
            if(a.empty())
            {
                cout<<'A';
                break;
            }
            turn=a[0];
            a.erase(0, 1);
        }
        else if(turn=='b')
        {
            if(b.empty())
            {
                cout<<'B';
                break;
            }
            turn=b[0];
            b.erase(0, 1);
        }
        else
        {
            if(c.empty())
            {
                cout<<'C';
                break;
            }
            turn=c[0];
            c.erase(0, 1);
        }
    }
    return 0;
}


Measured memory_bytes: 256