akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_STRING 20
#define MAXSHIPS 200000

	int aShipStart[MAXSHIPS];
	int aShipEnd[MAXSHIPS];

	int aShipFrom1[MAXSHIPS];
	int aShipToN[MAXSHIPS];

	int compar(const int *val1, const int *val2);

int main() {
	char sInput[MAX_STRING]="";
	char* psInput;
	int nMaxIsland=0;
	int nShipNumber=0;
	int nSmallShipNumber=0;
	int nMiddleIsland=0;
	int i=0;
	int j=0;
	int nFind=0;
	int nTempStart=0;
	int nTempEnd=0;
	int nFrom1Num=0;
	int nToNNum=0;
	
	// read line 1
	gets(sInput);
	psInput = strtok(sInput," ");
	nMaxIsland = atoi(psInput);
	psInput = strtok(NULL," ");
	nShipNumber = atoi(psInput);

	// read line 2
	for (i=0;i<nShipNumber;i++){
		gets(sInput);
		psInput = strtok(sInput," ");
		nTempStart = atoi(psInput);
		psInput = strtok(NULL," ");
		nTempEnd = atoi(psInput);
		if ( nTempStart == 1  ){
			aShipFrom1[nFrom1Num] = nTempEnd;
			nFrom1Num++;
		} else if (nTempEnd == nMaxIsland ){
			aShipToN[nToNNum] = nTempStart;
			nToNNum++;
		}
	}
	// sort
    qsort(aShipFrom1, nFrom1Num, sizeof(int),
        (int (*)(const void *, const void *))compar
    );
    qsort(aShipToN, nToNNum, sizeof(int),
        (int (*)(const void *, const void *))compar
    );
	// search
	i=0;
	while (i<nFrom1Num&&j<nToNNum){
		if (aShipFrom1[i]<aShipToN[j]){
			i++;
		} else if (aShipFrom1[i]>aShipToN[j]){
			j++;
		} else if (aShipFrom1[i]==aShipToN[j]) {
			nFind=1;
			break;
		} else {
			break;
		}
	}
	/*
	for (i=0;i<nSmallShipNumber;i++){
		for (j=0;j<nSmallShipNumber;j++){
			if(aShipStart[j]==aShipEnd[i] ){
					nFind=1;
					break;
			}
		}
		if(nFind==1){
			break;
		}
	}*/

	if (nFind==1){
		printf("POSSIBLE\n");
	} else {
		printf("IMPOSSIBLE\n");
	}

    return 0;
}
int compar(const int *val1, const int *val2) {
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}

Measured memory_bytes: 1404
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 110000;
int n, k;
vi e[maxn];

pii dfs(int v, bool fix = false) {
    int s = 0, h = 0;
    for (int u: e[v]) {
        pii res = dfs(u);
        s += res.fi;
        uax(h, res.se + 1);
    }
    if (h == k && !fix) ++s, h = -1;
//    cerr << v << ' ' << s << ' ' << h << '\n';
    return mp(s, h);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    cin >> n >> k;
    int ans = 0;
    forn(i, n) {
        int x;
        cin >> x;
        --x;
        if (!i) ans += x != 0;
        else e[x].pb(i);
    }
    --k;
    for (int v: e[0]) ans += dfs(v, true).fi;
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GCD(a,b) __gcd(a,b)
#define LCM(a,b) a/__gcd(a,b)*b
typedef long long ll;

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

int main(){
    ll a,b;
    cin>>a>>b;
    ll n=GCD(a,b);
    ll m=n;
    ll k=2;
    bool t=true;
    ll ans=1;
    if(n==1) {
        cout<<1;return 0;
    }
    if(prime(n)){
        cout<<2;return 0;
    }
    while(n!=1){
        if(n%k==0){
            if(t){ ans++;}
            t=false;
            n/=k;
            if(n!=1&&n!=k&&prime(n)){
            cout<<ans+1;return 0;
        }
            continue;
        }
        t=true;
        k++;
    }
    cout<<ans;
    return 0;
}

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

        #define ll long long
        #define pb push_back
        #define printV(v) for(int i=0;i<(int)v.size();i++){cout << v[i]<< " ";} cout << endl
        #define printRev(v) for(int i=(int)v.size()-1;i >= 0;i--){cout << v[i] << " ";} cout << endl
        #define sortV(v) sort(v.begin(),v.end())
        #define revV(v) reverse(v.begin(),v.end())
    

        ll a,b,c,d,e,f,g,n,m,k,t,x,h,w,p,q,y;
        string str = "";
        ll mod = 1e9 + 7;
        const int N = 3009;
       



        void solve(){
            cin >> a >> b >> c >> d;
            ll answer = max(max(a*c,b*d),max(a*d,b*c));
            if( (a ^ b) < 0) answer = max(0LL, answer);
            if( (c ^ d) < 0) answer = max(0LL,answer);
            cout << answer << endl;
            
        }

        


        int main(){
            ios_base::sync_with_stdio(false);

          


            int cases = 1;
            //cin >> cases;

            while(cases--) solve();
            return 0;

        }

Measured memory_bytes: 3652
import java.util.*;
public class Main {
		
	static int same[], N, conti[];
	
	public static void main(String[] args) {		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int p[] = new int[N];
		for(int i=0;i<N;i++)p[i]=sc.nextInt()-1;
		sc.close();
	
		conti = new int[N+1];
		
		int cnt = 0;
		for(int i=0;i<N;i++) {
			if(i==p[i]) {
				cnt++;
			}else {
				conti[cnt]++;
				cnt = 0;
			}
		}
		if(cnt!=0)conti[cnt]++;
		
		int ans = 0;
		for(int i=0;i<=N;i++) {
			ans += (i+1) / 2 * conti[i];
		}
		
		System.out.println(ans);
		
	}

	
}

Measured memory_bytes: 50012
k,a,b=map(int,input().split())

if a+1<b:
    ans=0
    if k<=a:
        ans=k+1
    else:
        ans=(a-1)+1
        k-=(a-1)
        if k%2==0:
            #print("even")
            ans+=(k//2)*(b-a)
        else:
            #print("odd")
            ans+=(k//2)*(b-a)+1


    print(ans)


else:
    print(1+k)


Measured memory_bytes: 61940
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

struct UnionFind {
    vector<int> node;

    UnionFind() = default;
    UnionFind(int x) {init(x);}

    void init(int x) {
        node.assign(x,-1);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (node[x] > node[y]) swap(x,y);
        node[x] += node[y];
        node[y] = x;
        return true; 
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int root(int x) {
        if (node[x] < 0) return x;
        return node[x] = root(node[x]);
    }

    int size(int x) {
        return -node[root(x)];
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K,L; cin >> N >> K >> L;
    UnionFind uf1(N),uf2(N);
    rep(i,K) {
        int p,q; cin >> p >> q;
        p--; q--;
        uf1.merge(p,q);
    }
    rep(i,L) {
        int r,s; cin >> r >> s;
        r--; s--;
        uf2.merge(r,s);
    }

    map<pii, int> dic;
    rep(i,N) dic[{uf1.root(i),uf2.root(i)}]++;

    rep(i,N) cout << dic[{uf1.root(i),uf2.root(i)}] << " ";
    cout << endl;
}

Measured memory_bytes: 13568
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
char s[N];
ll dp[N];
int pw[N], lst[N], nx[N];

int main() {
  int n, p; scanf("%d %d", &n, &p);
  scanf("%s", s);
  ll ans = 0;
  if (p == 2 || p == 5) {
    for (int i = 0; i < n; i++) {
      if ((s[i]-'0') % p == 0)
        ans += i + 1;
    }
    printf("%lld\n", ans);
    return 0;
  }
  pw[0] = 1;
  for (int i = 1; i < n; i++)
    pw[i] = pw[i-1] * 10 % p;
  ll cur = 0;
  for (int i = 0; i < p; i++)
    lst[i] = -1;
  for (int i = 0; i < n; i++)
    nx[i] = -1;
  lst[0] = n;
  for (int i = n-1; ~i; i--) {
    cur = (cur + pw[n-1-i] * (s[i]-'0')) % p;
    if (~lst[cur])
      nx[lst[cur]-1] = i;
    lst[cur] = i;
  }
  for (int i = 0; i < n; i++) {
    // cur = 0;
    // int jj = i+1;
    // for (int j = i; ~j; j--) {
      // cur = (cur + pw[i-j] * (s[j]-'0')) % p;
      // if (cur == 0) {
        // jj = j;
        // break;
      // }
    // }
    int jj = nx[i];
    dp[i] = jj >= 0 ? (jj>0?dp[jj-1]:0) + 1 : 0;
    // cerr << jj << " : " << i << " " << dp[i] << endl;
    ans += dp[i];
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int mod=1e4+7;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
//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;}

VI g[100010];
int d[100010];
int main(){
    int n,k,a,b,v,p;
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    memset(d,inf,sizeof d);
    priority_queue<PII>q;
    cin>>k;
    while(k--){
        cin>>v>>p;
        d[v]=p;
        q.push({p,v});
    }
    while(!q.empty()){
        p=q.top().first;
        v=q.top().second;
        q.pop();
        for(auto i:g[v]){
            if(d[i]==inf){
                d[i]=p-1;
                q.push({p-1,i});
            }
            else if(abs(p-d[i])!=1) return 0*puts("No");
        }
    }
    puts("Yes");
    for(int i=1;i<=n;i++) cout<<d[i]<<endl;
    return 0;
}


Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
long long dp[100010001];

int main()  {
  int h,n,a;
  cin >> h >> n;
  int cnt=0;
  for(int i=0; i<n; i++){
      cin >> a;
      cnt += a;
  }
  if(cnt>=h) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define REP(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define ALL(v) ((v).begin(), (v).end())

using namespace std;
using ll = int64_t;
using P = std::pair<int, int>;

const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll T, A;
    ll nx = 1LL, ny = 1LL;
    int k = 0;
    for(int i = 0; i < N; i++) {
        cin >> T >> A;
        ll m = max(((nx / T) + (nx % T ? 1LL : 0)), (ny / A) + (ny % A ? 1LL : 0));
        nx = T*m;
        ny = A*m;
    }    

    cout << nx + ny << endl;
       
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define FORW(a, b, c) for(int a = b; a >= c; --a)
#define pb push_back
#define SZ(a) ((int)a.size())
//#define int long long
//#define TEST
 
const int oo = 1e9;
const int Maxn = 1e6;
const int N = 2e5 + 100;
const double PI = (-2.00) * asin(-1);
 
typedef pair<int, pair<int, int> > iii;

int n, k, lst, nxt = 1;
int a[2][N];

signed main()
{
    #ifdef TEST
        freopen("test.inp", "r", stdin);
    #endif // TEST  
    ios_base::sync_with_stdio(false);                                      
    cin.tie(0); cout.tie(0);

    cin >> n >> k;
    FOR(i, 1, n) cin >> a[lst][i];
    a[nxt][1] = 1;

    int step = min(k, 400); //cout << step << '\n';
    FOR(i, 1, step) {
        FOR(j, 1, n) if(a[lst][j] > 0) {
            if(j > 1) {
                a[nxt][ max(1, j - a[lst][j]) ] ++;
                a[nxt][j] --;
            }
            if(j < n) {
                a[nxt][j + 1] ++;
                a[nxt][ min(n + 1, j + a[lst][j] + 1) ] --;

            }
        }
        FOR(j, 1, n) a[nxt][j] += a[nxt][j - 1];
        swap(lst, nxt);
        FOR(j, 0, n) a[nxt][j] = 0;
        a[nxt][1] = 1;
    }
    FOR(i, 1, n) cout << a[lst][i] << ' ';
}


Measured memory_bytes: 5220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int c = in.nextInt();
		
		if(c>=30) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

	}

}


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

#define pb push_back
#define mk make_pair
#define sc second
#define fr first

using namespace std;


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

       deque <int> v(n);
       for(int i = 0;i < n;i ++)
           cin >> v[i];

       sort(v.begin(), v.end());
       int cnt = 0;
       while(1)
       {
             int r = v.front() + k, t = 1;
             while(!v.empty() && v.front() <= r)
             {
                  v.pop_front();
                  t ++;
                  if(t > c) break;
             }
             cnt ++;
             if(v.empty()) break;
       }
       cout << cnt;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    int N, Q;
    cin>>N>>Q;
    vector<pair<ll, ll> > sarr(N), tarr(N);
    multiset<ll> xset;
    ll S, T, X;
    for(int i=0;i<N;++i){
        cin>>S>>T>>X;
        sarr[i] = mp(S-X, X);
        tarr[i] = mp(T-X, X);
    }
    sort(sarr.begin(), sarr.end());
    sort(tarr.begin(), tarr.end());
    ll D[Q];
    for(int i=0;i<Q;++i){
        cin>>D[i];
    }
    ll ans[Q];
    int sindex = 0, tindex = 0;
    for(int i=0;i<Q;++i){
        while(sindex<N && sarr[sindex].fi<=D[i]){
            xset.insert(sarr[sindex].se);
            sindex++;
        }
        while(tindex<N && tarr[tindex].fi<=D[i]){
            xset.erase(xset.find(tarr[tindex].se));
            tindex++;
        }
        if(sindex==tindex) ans[i] = -1;
        else ans[i] = *xset.begin();
    }
    for(int i=0;i<Q;++i){
        cout<<ans[i]<<endl;
    }
}



Measured memory_bytes: 19968
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        //var N = int.Parse(ReadLine());
        var a = new int[5];
        for (int i = 0; i < 5; i++)
        {
            a[i] = int.Parse(ReadLine());
        }
        var b = a.ToList().OrderBy(x => (x - 1) % 10).ToArray();
        var c = (b[0] % 10==0)?10: b[0] % 10;
        var ans = 0;
        for (int i = 0; i < 5; i++)
        {
            ans += (a[i] + 9) / 10 * 10;
        }
        ans += -10 + c;
         WriteLine(ans);
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Stack<Integer> pila = new Stack<>();
        String[] exp = sc.nextLine().split(" ");
        int oper;
        for (int i = 0; i < exp.length; i++) {
            if (esnumero(exp[i])) {
                pila.push(Integer.parseInt(exp[i]));
            } else {
                switch (exp[i]) {
                    case "+":
                        pila.push(pila.pop() + pila.pop());
                        break;
                    case "-":
                        int a,
                         b;
                        a = pila.pop();
                        b = pila.pop();
                        pila.push(b - a);
                        break;
                    default:
                        pila.push(pila.pop() * pila.pop());
                }
            }
        }
        System.out.println(pila.pop());
    }

    static boolean esnumero(String cadena) {
        try {
            Integer.parseInt(cadena);
            return true;
        } catch (NumberFormatException nfe) {
            return false;
        }
    }
}



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

int main() {
	int n, m;
	cin >> n >> m;
	int a;
	vector<int> ans(n);
	for (int i = 0; i < n; i++) {
		ans[i] = 0;
	}
	for (int i = 0; i < 2 * m; i++) {
		cin >> a;
		ans[a-1]++;

	}

	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
s = input()
a = int(s[:2])
b = int(s[2:])
if 1 <= a <= 12 and 1 <= b <= 12:
  print('AMBIGUOUS')
elif 0 <= a <= 99 and 1 <= b <= 12:
  print('YYMM')
elif 0 <= b <= 99 and 1 <= a <= 12:
  print('MMYY')
else:
  print('NA')

Measured memory_bytes: 3064
//https://atcoder.jp/contests/code-festival-2017-quala/tasks/code_festival_2017_quala_b
//B - fLIP
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-2.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,M,K; cin>>N>>M>>K;    
    bool ans=false;
    ll ttl=N*M;
    for(ll y=0;y<=N;++y){
        for(ll x=0;x<=M;++x){
            ll a=x*y;
            ll b=(N-y)*(M-x);
            ll num0=a+b;
            ll inv0=ttl-num0;
            if(num0==K||inv0==K){
                dump(x,y,num0,inv0);
                ans=true;
                cout<<"Yes"<<endl;
                exit(0);
            }
        }
    }
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
arr = gets.chomp.split(' ')
a = arr[0].to_i
b = arr[1].to_i
c = arr[2].to_i
d = arr[3].to_i

while true
  turn = 'Yes'
  c = c - b
  if c <= 0
    break
  end

  turn = 'No'
  a = a - d
  if a <= 0
    break
  end

end

print turn


Measured memory_bytes: 14440
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define mod 1000000007
#define S second
#define F first
#define int long long
using namespace std;

signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((a*b)%2&&(c+d)%2) puts("No");
	else puts("Yes");
}



Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#define INF 100000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long
/* define/include */
 
int main(){
  string S;
  cin >> S;
  string T;
  cin >> T;
  string A;
  int Sl = S.length();
  int Tl = T.length();
  int F;
  F=1;
  for(int i=Sl-Tl;i>=0;i--){
    F=0;
    for(int j=Tl-1;j>=0;j--){
      if(S[i+j]==T[j] || S[i+j]=='?')F=0;
      else{
        F=1;break;
      }
    }
    if(F==0){
      for(int j=0;j<Tl;j++){
        S[i+j]=T[j];
      }
      break;
    }
  }
  if(F==1){
    cout << "UNRESTORABLE" << endl;
  }else{
    for(int i=0;i<Sl;i++){
      if(S[i]=='?')S[i]='a';
    }
    cout << S << endl;
  }
 
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int L; cin >> L;
    double x = double(L)/3;

    cout << fixed << setprecision(10) << x*x*x << ln;
}


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

int main(){
  double a[10], v1, v2;
  double t1[11], t2[11];
  int cross;
  char k;
  int i;

  while(cin>>a[0]){
    for(i=1; i<10; i++) cin>>k>>a[i];
    cin>>k>>v1>>k>>v2;
    t1[0]=0;
    for(i=1; i<11; i++) t1[i]=t1[i-1]+a[i-1]/v1;
    t2[10]=0;
    for(i=9; i>=0; i--) t2[i]=t2[i+1]+a[i]/v2;
    for(i=1; i<11; i++){
      if(t1[i]>=t2[i]){
        cross=i; break;
      }
    }
    printf("%d\n", cross);
  }

  return 0;
}

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

int main()
{
    int x1[] = {1,3,5,7,8,10,12};
    int x2[] = {4,6,9,11};
    int x , y, flag1 = -1, flag2 = 0;
    scanf("%d%d", &x, &y);
    for(int i = 0; i < 7; ++i)
    {
        if(x1[i] == x)
        {
            flag1 = 1;
        }
        if(x1[i] == y)
        {
            flag2 = 1;
        }
    }
    for(int i = 0; i < 4; ++i)
    {
        if(x2[i] == x)
        {
            flag1 = 2;
        }
        if(x2[i] == y)
        {
            flag2 = 2;
        }
    }
    if(x == y || flag1 == flag2)
    {
        cout << "Yes" <<endl;
    }
    else
    {
        cout << "No" <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
L = []
for i in range(N):
  L.append(list(map(int,input().split())))
M = []
for i in range(N):
  M.append(list(map(int,input().split())))
L = sorted(L, key = lambda x:x[1])
L.reverse()
M.sort()
LT = [True]*N
MT = [True]*N
ans = 0
for i in range(N):
  curx = M[i][0]
  cury = M[i][1]
  for j in range(N):
    if LT[j] == True:
      if MT[i] == True:
        if curx >= L[j][0] and cury >= L[j][1]:
          LT[j] = False
          ans += 1
          MT[i] = False
print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3

from collections import deque
try:
    from typing import Deque, Tuple
except ImportError:
    pass


def main():
    H, W = [int(x) for x in input().split()]
    s = [input() for _ in range(H)]
    q = deque()  # type: Deque[Tuple[int, int]]
    dist = {
        (0, 0): 1,
    }
    q.append((0, 0))
    while q:
        sy, sx = q.popleft()
        for dy, dx in ((0, 1), (1, 0), (0, -1), (-1, 0)):
            ty = sy + dy
            tx = sx + dx
            if not (0 <= ty < H and 0 <= tx < W):
                continue
            if s[ty][tx] == "#":
                continue
            if (ty, tx) in dist:
                continue
            dist[ty, tx] = dist[sy, sx] + 1
            q.append((ty, tx))
    if (H - 1, W - 1) not in dist:
        print(-1)
        return
    print(sum(si.count(".") for si in s) - dist[H - 1, W - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3692
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli A[1001] = {}, B[1001] = {};
lli dp[1001][10001] = {};

int main(void) {

	lli H, N;
	cin >> H >> N;

	for (int i = 0; i < N; i++)
		cin >> A[i] >> B[i];

	for (int i = 0; i <= N; i++) {
		for (int k = 0; k <= 10000; k++) {
			dp[i][k] = INF;
		}
	}

	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int k = 0; k <= 10000; k++) {
			if (k + A[i] <= 10000) {
				CHMIN(dp[i][k + A[i]], dp[i][k] + B[i]);
			}
			CHMIN(dp[i + 1][k], dp[i][k]);
		}
	}

	lli ans = INF;
	for (int k = H; k <= 10000; k++) {
		CHMIN(ans, dp[N][k]);
	}
	COUT(ans);

	return 0;
}


Measured memory_bytes: 78464
import math
a, b, c, d = map(int, input().split())

def f(a, b, c):
    return b // c - (a + c - 1) // c + 1 

c_num = f(a, b, c)
d_num = f(a, b, d)

cp = c
dp = d
mod = 1
while mod > 0:
    mod = cp % dp
    cp = dp
    dp = mod

cd_num =  f(a, b, (c * d) // cp)
print(b - a + 1 - c_num - d_num + cd_num)


Measured memory_bytes: 9224
#include <stdio.h>
#include <ctype.h>

int main(void){
	char text[256];
	int i = 0;
	scanf("%[^\n]" , text);
	
	for(i=0;text[i]!='\0';i++){
		if(islower((int)text[i])){
			text[i] = toupper((int)text[i]);
		}
	}
	printf("%s\n" , text);
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ar array

typedef long long ll;
typedef long double ld;
ll mod=1e9+7;
bool comp(ll a,ll b)
{
	return a<b;
}
ll fpow(ll a, ll b) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a);
		a=(a*a);
		b>>=1;
	}
	return res;
}

ll minm(ll a,ll b){
	if(a<b) return a;
	return b;
}

ll maxm(ll a,ll b){
	if(a>b){ return a;}
	else return b;
}
const int N=1e5+5;
vector<int>adj[N];
int dp[N];
vector<bool>vis(N,false);

void dfs(int u){
    vis[u]=1;
    int i=u;
    for(i=0;i<(int)adj[u].size();++i){
        if(!vis[adj[u][i]]){
            dfs(adj[u][i]);
        }
        
          dp[u]=max(dp[u],dp[adj[u][i]]+1);
        
    }
                             
}

    


void solve()
{ 
    int i,n,m;
    cin>>n>>m;
    
    for(i=0;i<=n;++i){
        dp[i]=0;
    }
    for(i=0;i<m;++i){
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
    }
    //dfs(-1,1);
    int ans=0;
    for(i=1;i<=n;++i){
        //ans=max(ans,dp[i]);
        if(!vis[i]){
            dfs(i);
        }
    }
    for(i=1;i<=n;++i){
        //cout<<dp[i]<<' ';
        ans=max(ans,dp[i]);
      }
    cout<<ans;
  
  
}

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



Measured memory_bytes: 12120
def main():
  # N_max < sum(not N_max)
  N = int(input())
  Ls = map(int, input().split())

  Ls = sorted(Ls, reverse=True)
  N_max = Ls[0]
  N_sum = sum(Ls[1:])
  if N_max < N_sum:
    print('Yes')
  else:
    print('No')



main()

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define Yes cout << "Yes" << endl ;
#define yes cout << "yes" << endl ;
#define No cout << "No" << endl ;
#define no cout << "no" << endl ;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

st sol (lli ) ;

int main ()
{
    fastio
    lli num ;
    cin >> num ;
    cout << sol (num) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/

st sol (lli x )
{
    st s = "Christmas" ;

    if (x < 25)
    {
        for(lli i = 24 ; i >= x ; i--)
        {
            s += " Eve" ;
        }
    }
    return s ;
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';
constexpr ll INF = 1e17;

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

    int n;
    cin >> n;

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

    vector<ll> L(n + 1, 1), R(n + 1, INF);
    L[n] = a[n];
    R[n] = a[n];
    for (int i = n; i >= 0; i--) {
        L[i] = max(L[i], 1LL);
        R[i] = min(R[i], (i <= 40 ? (1LL << i) : INF));

        if (L[i] > R[i]) {
            cout << -1 << newl;
            return 0;
        }

        if (i > 0) {
            L[i - 1] = max(L[i - 1], (L[i] + 1) / 2 + a[i - 1]);
            R[i - 1] = min(R[i - 1], R[i] + a[i - 1]);
        }
    }

    if (L[0] > 1 || R[0] < 1) {
        cout << -1 << newl;
        return 0;
    }

    ll ans = 0;
    ll num = 1;
    for (int i = 0; i <= n; i++) {
        if (L[i] > num || num > R[i]) {
            cout << -1 << newl;
            return 0;
        }

        ans += num;
        num -= a[i];

        if (num < 0) {
            cout << -1 << newl;
            return 0;
        }

        if (i < n) {
            if (num * 2 < L[i + 1] || num > R[i + 1]) {
                cout << -1 << newl;
                return 0;
            }

            num = min(num * 2, R[i + 1]);
        }
    }
    cout << ans << newl;

    return 0;
}

Measured memory_bytes: 5584
#include<iostream>

using namespace std;

int main(){

    int64_t H,W;

    cin >> H >> W;

    if((H==1)||(W==1)){
        cout << 1 << endl;
        return 0;
    }

    if((H%2==1)&&(W%2==1)){
        cout << H * W / 2 + 1 << endl;
    }else{
        cout << H*W /2 << endl;
    }


    return 0;
}

Measured memory_bytes: 3596
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,A;
	while(cin>>N) {
		ll m=INF;
		REP(i, N) {
			cin>>A;
			ll c=0;
			while(A%2==0){A/=2;c++;}
			minUpdate(m, c);
		}
		ll ans=m;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

R1, R2 = MAP()

ans = 1 / (1/R1 + 1/R2)
print(ans)


Measured memory_bytes: 3064
def gcd(x,y):
    x,y = max(x,y),min(x,y)
    while x != 0:
        y,x = x, y%x
    return y

def solve():
    a,b,c,d = map(int, input().split())
    cc = b//c - (a-1)//c
    dd = b//d - (a-1)//d
    e = c*d//gcd(c,d)
    cd = b//e - (a-1)//e
    print(b-a+1 - cc - dd + cd)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int main() {
    int n, t=0;
    cin >> n;
    vector<int> arr(n+1), ans(n+1, 0);
    for (int i=1; i<=n; i++) cin >> arr[i];
    for (int i=n; i>0; i--) {
        int c=0;
        for (int j=i; j<=n; j+=i) {
            c ^= ans[j];
        }
        ans[i] = c != arr[i];
        t += ans[i];
    }
    cout << t << endl;
    for (int i=1; i<=n; i++) if (ans[i]) cout << i << ' ';
}

Measured memory_bytes: 2432
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
)

func pop(A *[]int) int{
	num := (*A)[len(*A)-1]
	*A = (*A)[:len(*A)-1]
	return num
}

func main(){
	var A []int
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	// 一行読み込み、文頭、文末のwhite space削除
	input_line := strings.TrimSpace(sc.Text())
	// space毎に分割
	for _, v := range strings.Split(input_line, " "){
		n, err := strconv.Atoi(v)
		if err == nil{
			A = append(A, n)
		} else {
			switch v{
			case "+":
				p1 := pop(&A)
				p2 := pop(&A)
				A = append(A, p2+p1)
			case "-":
				p1 := pop(&A)
				p2 := pop(&A)
				A = append(A, p2-p1)
			case "*":
				p1 := pop(&A)
				p2 := pop(&A)
				A = append(A, p2*p1)
			}
		}
	}
	fmt.Println(A[0])
}


Measured memory_bytes: 1184
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";


int main() {
    cin>>A>>B>>K;
    for(int i = 100; i >= 0; --i){
        if(A%i == 0 && B % i == 0) --K;
        if(K == 0) {
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [u64; n],
    }

    a.sort();
    a.reverse();
    let mut ans = a.iter().take(n / 2).map(|&a| 2 * a).sum::<u64>();
    ans -= a[0];
    if n % 2 == 1 {
        ans += a[n / 2];
    }
    println!("{}", ans);
}


Measured memory_bytes: 6212
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll h, ans, t = 1;

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

    cin >> h;
    while (h) {
        ans += t;
        h /= 2;
        t *= 2;
    }
    cout << ans << endl;

    return 0;
}
/*

*/


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


int main(){
	int N,K,count=0,miss=0;
	cin >>N>>K;
	bool x[N];
	char c;
	for(int i=0;i<N;i++){
		cin >>c;
		if(c=='L'){
			x[i]=1;
		}
		else{
			x[i]=0;
		}
	}
	for(int i=0;i<N-1;i++){
		if(x[i]==x[i+1]){
			count++;
		}
		else{
			miss++;
		}
	}
	if(miss%2==0){
		count+=min(miss,K*2);
	}
	else{
		if(K<=miss/2){
			count+=2*K;
		}
		else{
			count+=miss;
		}
	}
	cout <<count<<endl;
}

Measured memory_bytes: 384
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    sc.nextLine()
    val arare: Array[String] = sc.nextLine.split(" ")
    if (arare.contains("Y")) println("Four")
    else println("Three")
  }
}


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

int main(void) {
    int D,N;
    cin >> D >> N;
    if(N == 100) N++;
    if(D == 0) {
        cout << N << endl;
    }else if (D==1){
        cout << N*100 << endl;
    } else {
        cout << N * 10000 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
l = input().split(' ')
a,b,c,x,y = int(l[0]),int(l[1]),int(l[2]),int(l[3]),int(l[4])

place = []
place.append( a * x + b * y )

if x-y > 0:
    place.append(c * x * 2)
else:
    place.append(c * y * 2)

if x < y :
    place.append(c * x * 2 + b * (y-x))
else :
    place.append(c * y * 2 + a * (x-y))
    
print(sorted(place)[0])


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[51];
double num;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	num=a[1];
	for(int i=2;i<=n;i++)
		num=(num+a[i])/2.0;
	printf("%.5lf",num);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <functional>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 3000000;

long long fac[MAX], finv[MAX], inv[MAX];


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


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

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

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
            prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
} 


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

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

    sort(A.begin(), A.end(), greater<ll>());


    // cout << sum + A[1] - A[N-2] - A[N-1] << endl;

    ll ret = A[0];
    ll count = 2;
    ll now = 1;
    while(true) {
       //cout << ret << "," <<  count  <<","  << now << endl;
        if(count <= N-2) {
            
            ret += A[now] * 2;
            now++;count+=2;
        } else if(count == N-1) {
            ret += A[now];
            break;
        } else {
            break;
        }

    }
    cout<<ret << endl;

    
    return 0;    
}




Measured memory_bytes: 4788
N,C,K = map(int, input().split())
T = [int(input()) for _ in range(N)]
T.sort()

if C == 1:
    print(N)
    exit()

ans = 1
time = -1
for i,t in enumerate(T):
    if time < 0:
        cnt, time = 1, t + K
    elif t <= time:
        cnt += 1
    else:
        ans += 1
        cnt, time = 1, t + K
    
    if cnt == C:
        time = -1
        ans += 1

print(ans)

Measured memory_bytes: 7484
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
	int A, B;
	cin >> A >> B;

	bool ok = false;
	if(A%3 == 0)
		ok = true;
	if(B%3 == 0)
		ok = true;
	if((A+B)%3 == 0)
		ok = true;

	string ret;
	if(ok == true)
		ret = "Possible";
	else
		ret = "Impossible";

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
from sys import stdin, stdout

s = stdin.read()
s = list(s)

display = []

for c in s:
    if c == 'B' and len(display) != 0:
        display.pop(-1)
    elif c == '1' or c == '0':
        display.append(c)

res = ''.join(display)

stdout.write(res)

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main() {
    int h, w;
    char c[105][105];
    cin >> h >> w;
    for (int i = 1; i <= h; ++i)
    {
        for (int j = 1; j <= w; ++j)
            cin >> c[i][j];
    }
    for (int i = 1; i <= 2 * h; ++i)
    {
        for (int j = 1; j <= w; ++j)
        {
            cout << c[(i+1)/2][j];
        }
        cout << "\n";    
    }
    
}

Measured memory_bytes: 888
#include<stdio.h>
#include<limits.h>
#define d_flag 0
#define max(a,b) ((a)<(b)?(b):(a))
typedef long int li;

int main(){
  int n;
  li k;
  scanf("%d%ld",&n,&k);
  //  if(d_flag)  printf("k:%ld\n",k);
  int i,j;
  li a;
  int s[40]={};
  for(i=0;i<n;i++){
    j=0;
    scanf("%ld",&a);
    while(a){
      if(d_flag) printf("%ld\n",a);
      s[j++]+=a%2;
      a/=2;
    }
  }
  if(d_flag) printf("s[i]: ");
  for(i=0;i<40;i++)if(d_flag) printf(" %d",s[i]);
  if(d_flag)   printf("\n");
  int kk[40]={};
  j=0;
  while(k){
    kk[j++]=k%2;
    k/=2;
  }
  int ord_k=j;
  for(j=0;j<ord_k;j++)if(d_flag) printf("%d",kk[j]);
  if(d_flag) printf(":kk[j]. ord_k=%d\n",ord_k);
  li temp, ans=0,p=1;
  if(d_flag) printf("%ld\n",LONG_MAX);
  for(j=0;j<40;j++){
    ans+=(kk[j]?(n-s[j]):s[j])*p;
    //    if(d_flag) printf("n:%d, s[%d]:%d %ld\n",n,j,s[j],ans);
    p*=2;
  }

if(d_flag) printf("temp:%ld\n",ans);

  for(i=0;i<ord_k;i++){
    while(1-kk[i])i++;
    if(d_flag) printf("i=%d\n",i);
    temp=0;p=1;
    for(j=0;j<i;j++){
      temp+=max(s[j],n-s[j])*p;
      p*=2;
    }
    if(d_flag) printf(" temp:%ld\n",temp);
    temp+=s[j]*p;
    p*=2;
    for(j=i+1;j<40;j++){
      temp+=(kk[j]?(n-s[j]):s[j])*p;
      p*=2;
    }
    if(d_flag) printf(" temp:%ld\n",i,temp);
    if(ans<temp)ans=temp;
  }

  printf("%ld",ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

int f[22][1010],n,m,C[1010][1010];

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;f[0][0]=1;
	for(int i=0;i<=n;i++) {
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
	for(int i=1,a;i<=m;i++) {
		cin>>a;
		for(int j=0;j<=n;j++)
			for(int k=0;j+k<=n;k++) if(n-j>=0&&n-k>=0&&a-k>=0) f[i][j+k]=(f[i][j+k]+1ll*f[i-1][j]*C[n-j][k]%mod*C[n-k][a-k])%mod;
	}
	cout<<f[m][n];
	return 0;
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;


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

int c[5];
for(int j=0;j<n;j++){
c[j]=a[j];
c[j]%=10;
}

int sum=0;
for(int i=0;i<n ;i++)
sum+=c[i];

if(sum==0){
  int ans2=0;
  for(int i=0;i<n;i++){
    ans2+=a[i];
  }
  cout<<ans2<<endl; return 0;
}
else{
  int min =10;
  int index=6;
for(int j=0;j<n;j++){
  if(min > c[j]) {
    if(c[j]==0) continue;
    min=c[j]; index=j;}
}

int ans=0;
for(int i=0;i<n ;i++){
  if(a[i]%10==0 || i==index)ans+= a[i];
  else ans+= a[i]+(10-a[i]%10);
}

cout<<ans<<endl;

}
}


Measured memory_bytes: 256