akhauriyash/Code-Regression huggingface dataset:
N = int(input())
b = list(map(int, input().split()))
ans = []
l = []
k = 0

for j in range(N):
    for i in range(len(b)):
        if b[i] == i+1:
            l.append(i)
    if len(l) == 0:
        k += 1
        break
    ans.append(b[max(l)])
    del b[max(l)]
    l = []
if k > 0:
    print(-1)
else:
    for i in ans[::-1]:
        print(i)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> up, down(n);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        int now = 0, mi = 0;
        for (int j = 0; j < s.size(); j++) {
            s[j] == '(' ? now++ : now--;
            mi = min(mi, now);
        }

        if (now >= 0)up.push_back({mi, now - mi});
        else down.push_back({mi - now, mi});
    }


    sort(up.begin(), up.end(), greater<>()), sort(down.begin(), down.end());
    bool possible = true;
    int remain = 0;
    for (auto x:up) {
        remain += x.first;
        if (remain < 0)possible = false;
        remain += x.second;
    }
    for (auto x:down) {
        remain += x.second;
        if (remain < 0)possible = false;
        remain -= x.first;
    }

    cout << (possible && remain == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 22896
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            final long n = in.nextLong();
            final long k = in.nextLong();

            long ans;
            if (k == 2) ans = (long) Math.pow(n / 2, 3) + (long) Math.pow(n / 2 + n % 2, 3);
            else if (k % 2 == 0) ans = (long) Math.pow(n / k, 3) + (long) Math.pow(n / k + n % k / (k / 2), 3);
            else ans = (long) Math.pow(n / k, 3);
            out.println(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 23124
while True :
    n,k=map(int,input().split())
    if n==0 : break
    x=[int(input()) for i in range(n)]
    ans=0
    xsum=sum(x[:k])
    for i in range (n-k):
        ans=max(ans,xsum)
        xsum=xsum - x[i] + x[i+k]
    print(ans)


Measured memory_bytes: 9880
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int sg[N],n;
vi g[N];

void dfs(int c,int fa=0){
    for(auto t : g[c]) {
        if(t == fa) continue;
        dfs(t , c);
        sg[c] ^= sg[t] + 1;
    }
}

int main(){
    scanf("%d",&n);
    rep(i,1,n) {
        int u,v;
        scanf("%d%d",&u,&v);
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1);
    puts(sg[1] ? "Alice" : "Bob");
    return 0;
}


Measured memory_bytes: 12416
'''
    Rating 1-399 : gray
    Rating 400-799 : brown
    Rating 800-1199 : green
    Rating 1200-1599 : cyan
    Rating 1600-1999 : blue
    Rating 2000-2399 : yellow
    Rating 2400-2799 : orange
    Rating 2800-3199 : red
'''
b = [0, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
u = [0] * 8
import sys
n = map(int, sys.stdin.readline().split())
a = map(int, sys.stdin.readline().split())
res = 1
target = 0
for c in a:
  for i in range (len(b) - 1):
    if b[i] <= c < b[i+1]:
      u[i] = 1
  if c >= 3200:
    target += 1
print max(1, sum(u)), sum(u) + target 





Measured memory_bytes: 2568
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()
A, B = MAP()

for i in range(A, B+1):
	if i%K == 0:
		print("OK")
		break
else:
	print("NG")


Measured memory_bytes: 10032
rr = lambda: input().strip()
rrm = lambda: list(map(int, rr().split()))

N, M = rrm()
drinks = [rrm() for _ in range(N)]

# (A,B): B cans for cost of A each
drinks.sort()
cost = 0
for A, B in drinks:
    buy = min(B, M)
    M -= buy
    cost += buy * A
    if M == 0: break
print(cost)


Measured memory_bytes: 27840
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    maxyen=0
    for sss in range(n):
        i=sss
        yen=1000
        kab=0
        while i < n:
            now=arr[i]
            nxt=999
            minxxx=99999
            for j in range(i+1,n):
                if arr[j]>now:
                    nxt=j
                    break
                if arr[j]==now:
                    continue
                #minxxx=min(minxxx,arr[j])
                now=arr[j]
                minxxx=99999
            if nxt < 999 and minxxx==99999:
                kabu = yen // now
                yen = yen % now
                yen += kabu * arr[nxt]
                kabu=0
            if nxt < 999 and minxxx<99999:
                kabu = yen // minxxx
                yen = yen % minxxx
                yen += kabu * arr[nxt]
                kabu=0

            i=nxt
        maxyen=max(maxyen,yen)
    print(maxyen)
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16228
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename Monoid, typename Operand>
class SegTree {
	std::vector<Monoid> tree;
	size_t size;
	int32 i;
public:
	//?????????????????????
	SegTree(size_t length) {
		--length;
		size = length;
		if (size & 0xffff0000) { size = size & 0xffff0000; }
		if (size & 0xff00ff00) { size = size & 0xff00ff00; }
		if (size & 0xf0f0f0f0) { size = size & 0xf0f0f0f0; }
		if (size & 0xcccccccc) { size = size & 0xcccccccc; }
		if (size & 0xaaaaaaaa) { size = size & 0xaaaaaaaa; }
		if (length) { size <<= 1; }
		else { size = 1; }
		tree.resize(size << 1);
	}
	//?????????
	void set() {
		i = size << 1;
		while (size<i--) { tree[i].set(); }
		++i;
		while (--i) { tree[i] = tree[i << 1] + tree[i << 1 | 1]; }
	}
	//tree[index]???data??§??´??°
	void update(size_t index, const Operand &data) {
		index += size;
		tree[index] = tree[index] * data;
		while (index >>= 1) tree[index] = tree[index << 1] + tree[index << 1 | 1];
	}
	//[begin,end)???????????????????????????
	Monoid range(size_t begin, size_t end) {
		Monoid retL, retR;
		for (begin += size, end += size;begin < end;begin >>= 1, end >>= 1) {
			if (begin & 1) retL = retL + tree[begin++];
			if (end & 1)  retR = tree[end - 1] + retR;
		}
		return retL + retR;
	}
	//range(0,length)
	Monoid all(void) {
		return tree[1];
	}
};

struct SUB {
	uint32 e;
	SUB() { set(); }
	SUB(uint32 x) { e = x; }
	void set() {}
	SUB operator*(const SUB &other) {
		return *this;
	}
};
struct MIN {
	uint32 e;
	MIN() { set(); }
	MIN(uint32 x) { e = x; }
	void set() { e = 2147483647; }
	MIN operator+(const MIN &other) {
		if (e < other.e) return *this;
		return other;
	};
	MIN operator*(const SUB &other) {
		return MIN(other.e);
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n, l;
	std::cin >> n >> l;
	uint32 a;
	SegTree<MIN, SUB> T(n);
	rep(i, 0, n) {
		std::cin >> a;
		T.update(i, SUB(a));
	}
	std::cout << T.range(0, l).e;
	rep(i, 1, n - l + 1) {
		std::cout << " " << T.range(i, i + l).e;
	}
	std::cout << "\n";
	return 0;
}

Measured memory_bytes: 19200
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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 pow(int base, int n) {
    if (n == 0) {
        return 1;
    } else {
        return base * (pow(base, n-1));
    }
}

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

    const int mx = pow(3, K);
    bool ok = false;

    for (int bits = 0; bits < mx; bits++) {
        int cur = bits;
        int a = 0, b = 0, c = 0;
        for (int trial = 0; trial < K; trial++) {
            switch (cur % 3) {
                case 0:
                    a++;
                    break;
                case 1:
                    b++;
                    break;
                case 2:
                    c++;
                    break;
                default:
                    break;
            }
            cur /= 3;
        }
        int res_a = A * pow(2, a);
        int res_b = B * pow(2, b);
        int res_c = C * pow(2, c);
        if (res_a < res_b && res_b < res_c) {
            ok = true;
            break;
        }
    }

    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
using namespace std;
using ll = long long int;
const ll MOD = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;

    ll ans = 0;
    ll fn = 1;
    ll fm = 1;
    if(m < n){
        int t = n;
        n = m;
        m = t;
    }
    for(ll i = 1; i <= n; i++){
        fn *= i;
        fn %= MOD;
    }
    fm = fn;
    for(ll i = n+1; i <= m; i++){
        fm *= i;
        fm %= MOD;
    }

    if(n == m){
        ans = 2;
        ans *= fm;
        ans %= MOD;
        ans *= fn;
        ans %= MOD;
    }else if(m-n == 1){
        ans = 1;
        ans *= fm;
        ans %= MOD;
        ans *= fn;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
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++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

vector<int> list[11];
int n,m;

bool status[12];
int require[12];

int func(int i){
  if(i==n+1){
    LOOP1(l,m){
      int lamp=0;//ついてるランプ数
      LOOP(k,list[l].size()){
        if(status[list[l][k]])lamp++;
      }
      // cerr << "!" << l << ":" << lamp << endl;
      if(lamp%2 != require[l])return 0;
    }
    // cerr << "!!" << endl;
    return 1;
  }
  int ans = 0;
  LOOP(mode, 2){
    // ranp ga mode no toki
    // if(mode && i!=1)LOOP(i,n-1)cerr << "-";
    status[i]=mode;
    // cerr << mode;
    ans += func(i+1);
  }
  return ans;
}

signed main(){
  cin >> n >> m;
  LOOP1(i,m){
    int k;
    cin >> k;
    LOOP(j,k){
      int s;
      cin >> s;
      list[i].push_back(s);
    }
  }
  LOOP1(i,m){
    int p;
    cin >> p;
    require[i] = p;
  }
  cout << func(1) << endl;
}


Measured memory_bytes: 256
import sys
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0: return 1
    elif y == 1	 : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else: return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))
def div2(a, b):
    return mul(a, modinv(b))

def modinv(a):
    b, u, v = mod, 1, 0
    while b:
        t = a//b
        a, u = a-t*b, u-t*v
        a, b, u, v = b, a, v, u
    u %= mod
    return u

def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r]
N, K = map(int, input().split())
B = [0] * (K+1)
r = 0
for i in range(K, 0, -1):
    ac = K//i
    c = power(ac, N)
    bsum = 0
    for j in range(ac-1):
        j += 2
        bsum += B[i*j]
    B[i] = (c - bsum)%mod
    r = (r+B[i]*i)%mod
print(r)



Measured memory_bytes: 75728
a[99][999],c;f(i,d,s,b){for(++a[d++][s];i--;)b>>i&1||f(10,d,s+i*d,b|1<<i);}main(){for(f(10,0,0,0);scanf("%d%d",a,&c)/2;)printf("%d\n",c<400?a[**a][c]:0);}

Measured memory_bytes: 636
import sys
input=sys.stdin.readline
sys.setrecursionlimit(100000000)
MOD = 10**9+7
INF = 10 ** 9

def main():
    n,x,y = map(int,input().split())
    x -= 1 
    y -= 1
    ans = [0] * n
    for i in range(n):
        for j in range(i + 1,n):
            tmp = min(j - i,abs(i - x) + 1 + abs(j - y))
            ans[tmp] += 1
    for i in range(1,n):
        print(ans[i])           

if __name__=='__main__':
    main()

Measured memory_bytes: 3444
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int maxn=500000+10,mo=998244353;
int fac[maxn*2],inv[maxn*2];
int i,j,k,l,t,n,m,ans;
int ksm(int x,int y) {
	int ret=1;
	for(;y;x=(ll)x*x%mo,y>>=1) if(y&1) ret=(ll)ret*x%mo;
	return ret;
} 
int C(int n,int m) {
	if(n<m||m<0) return 0;
	return (ll)fac[n]*inv[m]%mo*inv[n-m]%mo;
}
int main() {
	scanf("%d%d",&n,&m);
	if(n<m) swap(n,m);
	fac[0]=1;
	fo(i,1,n*2) fac[i]=(ll)fac[i-1]*i%mo;
	inv[n*2]=ksm(fac[n*2],mo-2);
	fd(i,n*2-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mo;
	fo(i,1,m) (ans+=(ll)C(2*i,i)*C(n+m-2*i,n-i)%mo)%=mo;
	ans=(ll)ans*ksm(2*C(n+m,n)%mo,mo-2)%mo;
	ans=((n+ans)%mo+mo)%mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 8064
#include <stdio.h>
#include <stdint.h>
#include <vector>
#include <assert.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();
	
	std::vector<int> all{1};
	for (int i = 0; i < n; i++) {
		std::vector<int> tmp(all.begin(), all.end());
		tmp.insert(tmp.begin(), 0);
		for (int j = 0; j < (int) all.size(); j++) {
			tmp[j] = (tmp[j] - (int64_t) all[j] * i) % n + n;
			if (tmp[j] >= n) tmp[j] -= n;
		}
		std::swap(all, tmp);
	}
	std::vector<int> res(n);
	for (int i = 0; i < n; i++) {
		auto cur = all;
		for (int j = n; j; j--)
			cur[j - 1] = (cur[j - 1] + (int64_t) cur[j] * i) % n;
		cur.erase(cur.begin());
		for (auto &i : cur) i = i ? n - i : i;
		for (int j = 0; j < n; j++) res[j] = (res[j] + a[i] * cur[j]) % n;
	}
	for (auto i : res) printf("%d ", i);
	puts("");
	return 0;
}


Measured memory_bytes: 512
////////////////////////////////////////
///  tu3 pro-con template            ///
////////////////////////////////////////
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>
#include <complex>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <regex>
using namespace std;

//// MACRO ////
#define countof(a) (sizeof(a)/sizeof(a[0]))

#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define RFOR(i,s,n) for (int i = (n)-1; i >= (s); i--)
#define pos(c,i) c.being() + (i)
#define allof(c) c.begin(), c.end()
#define aallof(a) a, countof(a)
#define partof(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define apartof(a,i,n) a + (i), a + (i) + (n)

#define EPS 1e-9
#define INF (1L << 30)
#define LINF (1LL << 60)

inline int sign(double x) { return (abs(x) < EPS ? 0 : x > 0 ? 1 : -1); }

//// i/o helper ////

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
struct _Writer { bool f; _Writer() : f(false) { } template <class T> _Writer operator ,(const T &rhs) { cout << (f ? " " : "") << rhs; f = true; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__
#define WRITE(...) _Writer(), __VA_ARGS__; cout << endl

//// start up ////
void solve();
int main()
{
	solve();
	return 0;
}

////////////////////
/// template end ///
////////////////////
#define long long long

// 最大公約数
long gcd(long a, long b) { return b ? gcd(b, a%b) : a; }

// 最小公倍数
long lcm(long a, long b) { return a / gcd(a, b) * b; }

void solve()
{
	int cases = INF;
	REP(_, cases)
	{
		READ(int, n, a, b);
		if (!(n | a | b)) { break; }
		if (a > b) swap(a, b);
		vector<char> m(n + 1);
		
		int maxJ = lcm(a, b) / b;

		for (int i = 0; a * i <= n; i++)
		{
			for (int j = 0; a * i + b * j <= n && j < maxJ; j++)
			{
				m[a * i + b * j] = 1;
			}
		}
		WRITE(n + 1 - count(allof(m), 1));
	}
}

Measured memory_bytes: 2180
/*
 * 1.cpp
 */

//include files
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>

using namespace std;

//DEFINE MACROS
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define PRINTLN(s) cout << s << endl

//DEFINE CONSTANT

//DEFINE PROTOTYPE
int main(){
  int a,b;
  cin >> a;
  cin >> b;

  cout << a*a -b   << "\n";
  
  return 0;
}



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

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

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

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

map<pair<int, string>, int64> mp;
vector<string> S;
vector<int64> C;
int64 N;

void dfs(pair<int, string> ps, int64 cost) {
  int side = ps.fs;
  string s = ps.sc;
//  cout << side << " " << s << " " << cost << endl;
  if (mp.count(ps) && mp[ps] < cost) return;
  string ss = s;
  if (side != 0) reverse(all(ss));

  REP(i, N) {
    string ts = S[i];
    if (side == 0) reverse(all(ts));
    int64 cnt = 0;
    while (cnt < min(ts.size(), ss.size()) && ts[cnt] == ss[cnt]) cnt++;
    if (cnt < min(ts.size(), ss.size())) continue;

    int64 ns = 1-side;
    string ls;
    if (ts.size() > ss.size()) {
      ls = ts.substr(cnt, ts.size() - cnt);
      if (side == 0) reverse(all(ls));
    } else {
      ls = ss.substr(cnt, ss.size() - cnt);
      if (side == 1) reverse(all(ls));
      ns = 1-ns;
    }
//    cout << ss << " " << ts << ": " << ns << " " << ls << endl;
    if (!mp.count(make_pair(ns, ls)) || mp[make_pair(ns, ls)] > cost + C[i]) {
      mp[make_pair(ns, ls)] = cost + C[i];
      dfs(make_pair(ns, ls), cost +C[i]);
    }
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  S = vector<string>(N);
  C = vector<int64>(N);
  REP(i, N) cin >> S[i] >> C[i];
  int64 res = INF_LL;
  REP(i, N) {
    dfs(make_pair(0, S[i]), C[i]);
    dfs(make_pair(1, S[i]), C[i]);
    string ss = S[i], ts = S[i];
    reverse(all(ts));
    if (ss == ts) chmin(res, C[i]);
  }
  for (auto &x : mp) {
    string s1 = x.fs.sc, s2 = x.fs.sc;
    reverse(all(s2));

    if (s1 == s2) chmin(res, x.sc);
  }
  if (res == INF_LL) cout << -1 << endl;
  else cout << res << endl;
}


Measured memory_bytes: 3860
#include<iostream>
#include<string>

using namespace std;

int main(){
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;

  int cnt[n];
  cnt[0] = 0;


  for(int i = 1; i < n; i++){
    cnt[i] = cnt[i-1];
    if(s[i-1] == 'A' && s[i] == 'C'){
      cnt[i]++;
    }
  }

  for(int i = 0; i < q; i++){
    int l, r, ans;
    cin >> l >> r;
    if(l != 1) {
      ans = cnt[r-1] - cnt[l-2];
      if(s[l-1] == 'C' && s[l-2] == 'A') ans--;
    }else{
      ans = cnt[r-1];
    }
    cout << ans << endl;
  }

}


Measured memory_bytes: 1408
a1,a2,a3,a4,a5,a6=map(int,input().split())
s=input()
for i in s:
    if i=="E":
        a1,a2,a3,a4,a5,a6=a4,a2,a1,a6,a5,a3
    elif i=="S":
        a1,a2,a3,a4,a5,a6=a5,a1,a3,a4,a6,a2
    elif i=="W":
        a1,a2,a3,a4,a5,a6=a3,a2,a6,a1,a5,a4
    elif i=="N":
        a1,a2,a3,a4,a5,a6=a2,a6,a3,a4,a1,a5
print(a1)


Measured memory_bytes: 5600
#include<stdio.h>
#include<map>
using namespace std;
map<int,double>p;
double a[200010]={0};
double b[200010]={0};
int main()
{
	int n,k,i,j,m;
	scanf("%d %d",&n,&k);
	p.clear() ;
	double ans=0;
	int s1=0,s2=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&m);
		double ss=0;
		ss=(m+1)*1.0/2;
		a[i]=ss;
//		printf("%d==%lf ",i,a[i]);
		if(n==k)
		{
			ans+=a[i];
		}
		else
		{
			if(i<k)
			{
				b[s1]+=a[i];
				if(b[s1]>ans) ans=b[s1];
			}
			else
			{
				s1++;
				b[s1]=b[s1-1]+a[i]-a[s2++];
				if(b[s1]>ans) ans=b[s1];
			}
		}
	}
	printf("%.12lf\n",ans);
}

Measured memory_bytes: 3328
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
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(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

vector<LL> h;
LL n, a, b;

bool f(LL k) {

	LL d = (a - b);
	LL basedamege = b * k;

	for (int i = 0; i < n; i++) {

		if ((h[i] - basedamege) > 0){
			k -= ((h[i] - basedamege) + d - 1) / d;
		}
	}

	if (k >= 0) {
		return true;
	}
	else {
		return false;
	}

}

int main() {
	cin >> n >> a >> b;
	h.resize(n);

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

	sort(h.rbegin(), h.rend());

	LL r = 1e9 + 1;
	LL l = -1;

	LL mid = (r + l) / 2;

	
	for (int i = 0; i < 100; i++) {
	
		if (f(mid)) {
			r = mid;
		}
		else {
			l = mid;
		}

		mid = (r + l) / 2;

	}
	

	cout << r << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	std::vector<int> v;
	for(int i=0;i<n;i++){
		int cp=a[i];
		int cnt=0;
		while(cp==a[i]&&i<n){
			cnt++;
			i++;
		}
		i--;
		v.push_back(cnt);
	}
	int ans=0;
	for(int i=0;i<v.size();i++){
		if(v[i]%2==1)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1276
import fractions
N,K = map(int, input().split())
A = list(map(int,input().split()))

m = max(A)
if m < K:
	print("IMPOSSIBLE")
else:
	gcd = A[0]
	for i in range(1,N):
		gcd = fractions.gcd(A[0], A[i])
	if fractions.gcd(gcd, K) == gcd:
		print("POSSIBLE")
	else:
		print("IMPOSSIBLE")

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

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


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

using namespace std;
using namespace atcoder;

using mint = static_modint<998244353>;

vector<mint> pow_ten;
vector<mint> sum_pow_ten;

struct S {
    mint val;
    int len;
};

S op(S l, S r) {
    return {l.val * pow_ten[r.len] + r.val, l.len + r.len};
}

S e() {
    return {0, 0};
}

using F = int;

S mapping(F f, S x) {
    if (f < 0)
        return x;
    return {sum_pow_ten[x.len] * f, x.len};
}

F composition(F f, F g) {
    if (f < 0)
        return g;
    if (g < 0)
        return f;
    return f;
}

F id() {
    return -1;
}

int main() {
    int n, q;
    cin >> n >> q;
    pow_ten.emplace_back(1);
    for (int i = 0; i < n; ++i) {
        pow_ten.emplace_back(pow_ten.back() * 10);
    }
    sum_pow_ten.emplace_back(0);
    for (int i = 0; i < n; ++i) {
        sum_pow_ten.emplace_back(sum_pow_ten.back() + pow_ten[i]);
    }
    vector<S> a(n);
    for (int i = 0; i < n; ++i) {
        a[i] = {1, 1};
    }
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
    while (q--) {
        int l, r, d;
        cin >> l >> r >> d;
        seg.apply(l - 1, r, d);
        cout << seg.all_prod().val.val() << "\n";
    }
    return 0;
}


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

#define MOD_BY 1000000007

int add(int a,int b) {
	int r=a+b;
	if(r>=MOD_BY)r-=MOD_BY;
	return r;
}

/*
int mul(int a,int b) {
	return (int)(((long long)a*(long long)b)%MOD_BY);
}
*/

int N,M;
int existPos;
char A[10240];
char B[10240];
char C[512];

int memo[10002][502][2][2];
int numberOfNumber[10002][2][2];

int getNumberOfNumber(int pos,int ueFlag,int sitaFlag) {
	int ret=0;
	int i;
	int imin,imax;
	if(pos>=N)return 1;
	if(numberOfNumber[pos][ueFlag][sitaFlag]>0)return numberOfNumber[pos][ueFlag][sitaFlag]-1;

	imin=sitaFlag?A[pos]:0;
	imax=ueFlag?B[pos]:9;
	for(i=imin;i<=imax;i++) {
		ret=add(ret,getNumberOfNumber(pos+1,ueFlag&&(i==imax),sitaFlag&&(i==imin)));
	}

	numberOfNumber[pos][ueFlag][sitaFlag]=ret+1;
	return ret;
}

int search(int pos,int seqPos,int ueFlag,int sitaFlag) {
	int ret=0;
	int i;
	int imin,imax;

	if(seqPos>=M)return getNumberOfNumber(pos,ueFlag,sitaFlag);
	if(pos>=N)return 0;
	if(memo[pos][seqPos][ueFlag][sitaFlag]>0)return memo[pos][seqPos][ueFlag][sitaFlag]-1;

	imin=sitaFlag?A[pos]:0;
	imax=ueFlag?B[pos]:9;
	for(i=imin;i<=imax;i++) {
		if(seqPos==0) {
			ret=add(ret,search(pos+1,0,ueFlag&&(i==imax),sitaFlag&&(i==imin)));
		}
		if((!sitaFlag || i!=imin || existPos<=pos) && seqPos<M && C[seqPos]==i) {
			ret=add(ret,search(pos+1,seqPos+1,ueFlag&&(i==imax),sitaFlag&&(i==imin)));
		}
	}

	memo[pos][seqPos][ueFlag][sitaFlag]=ret+1;
	return ret;
}

int main(void) {
	int Alen,Blen;
	int i;
	if(scanf("%s%s%s",A,B,C)!=3)return 1;
	Alen=strlen(A);
	Blen=strlen(B);
	if(Alen<Blen) {
		for(i=0;i<Alen;i++)A[Blen-i-1]=A[Alen-i-1];
		for(i=0;i<Blen-Alen;i++)A[i]='0';
	}
	N=Blen;
	M=strlen(C);
	existPos=Blen-Alen;
	for(i=0;i<N;i++) {
		A[i]-='0';
		B[i]-='0';
	}
	for(i=0;i<M;i++)C[i]-='0';
	printf("%d\n",search(0,0,1,1));
	return 0;
}

Measured memory_bytes: 79092
#include <bits/stdc++.h>
using namespace std;
#define Max(xx,yy) (xx > yy ? xx : yy)
#define Min(xx,yy) (xx < yy ? xx : yy)
#define all(v) v.begin(),v.end();

template<typename... T>
void dbg(T... args) {
	#ifdef Local
    	((cout << args << " "), ...) << '\n';
    #endif
}

template<typename... T>
void print(T... args) {
    ((cout << args << " "), ...) << '\n';
}

namespace data{
    const long long n = 2 * 1e5 + 7;	
    const long long m = 0 + 7;
    const long long mod = 0;
    const long long INF = 0;
}


int main(){    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);

    #ifdef Local
    	for(int i = 1;i <= 51;i++) cout << "*\n"[i == 51];
    	cout << "Running on Halit's Computer, Good Luck Halit\n";
    	for(int i = 1;i <= 51;i++) cout << "*\n"[i == 51];
    #endif	

    long long a,b,c,d;
	cin >> a >> b >> c >> d;


	while( a > 0 or c > 0){
		c -= b;
		if(c <= 0)
			break;
		a -= d;
	}

	if(a <= 0)
		cout << "No";
	else 
		cout << "Yes";

}	


Measured memory_bytes: 3636
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush =
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadLine.ToCharArray();
			var res = N.Any(x => x == '7');
			Console.WriteLine(res?"Yes":"No");
		}
	}
	static class ExtendClass {
		public static void Swap<T>(this T[] A, int x, int y) {
			var tmp = A[x];
			A[x] = A[y];
			A[y] = tmp;
		}
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek() == -1; }
		}
	}

}


Measured memory_bytes: 26552
s = raw_input()
k = int(raw_input())
albets = 'abcdefghijklmnopqrstuvwxyz'
dic = {}
for idx, letter in enumerate(albets):
    dic[letter] = 26 - idx
dic['a'] = 0
ans = ''
for l in s[:-1]:
    if k >= dic[l]:
        ans += 'a'
        k -= dic[l]
    else:
        ans += l
ans += albets[(26 - dic[s[-1]] + k) % 26]
print ans

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a== b && b != c) || (a == c && c != b) || (b == c && c != a)){
  	cout<<"Yes"<<endl;
  }
  else{
  	cout<<"No"<<endl;
  }
 return 0;  
}

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

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from fractions import gcd                    # for Python3.4.3


def main():
    mod = 10000007                  # 10^9+7
    inf = float('inf')
    input = sys.stdin.readline      # 改行文字が残ることに注意
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def ii():  return int(input())
    def mi():  return map(int, input().rstrip().split())
    def lmi(): return list(map(int, input().rstrip().split()))
    def li():  return list(input().rstrip())
    
    
    a, b, c = mi()
    print('bust') if a+b+c>=22 else print('win')

if __name__ == "__main__":
    main()

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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<8>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<int>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1e9+7

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

int main()
{
    int n;
    vii v;
    
    ci >> n;

    int b;
    rep(i, 0, n) {
	ci >> b;
	v.pb((pii){b, i + 1});
    }

    sort(v.begin(), v.end());

    rep(i, 0, n) co << v[i].second << " ";ln;
    
    return 0;
}


Measured memory_bytes: 1780
from itertools import combinations
N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]
def f(x_, y_):
    return max((x-x_)**2+(y-y_)**2 for x, y in XY)**.5
def g(x):
    yl = 0
    yr = 1000
    for _ in range(80):
        yl_ = (yl*2 + yr) / 3
        yr_ = (yl + yr*2) / 3
        if f(x, yl_) > f(x, yr_):
            yl = yl_
        else:
            yr = yr_
    return f(x, yl_)

xl = 0
xr = 1000
for _ in range(80):
    xl_ = (xl*2 + xr) / 3
    xr_ = (xl + xr*2) / 3
    if g(xl_) > g(xr_):
        xl = xl_
    else:
        xr = xr_
print(g(xl))

Measured memory_bytes: 3188
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int n;
    cin >> n;
    string shiri[n+1];
    for(int i=0; i<n; i++){
        cin >> shiri[i];
    }
    string ans="Yes";
    for(int i=1; i<n; i++){
        if(shiri[i][0]!=shiri[i-1][shiri[i-1].length()-1])ans="No";
        for(int j=0; j<i; j++){
            if(shiri[i]==shiri[j])ans="No";
        }
    }
    cout << ans << endl;
    return 0;
}

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

class Main
{
	public static void main(String[] args)
	{
		FastReader reader = new FastReader();
		PrintWriter writer = new PrintWriter(System.out);

		int n = reader.nextInt();
		int m = reader.nextInt();
		long[][] mat = new long[n][3];

		for (int i=0; i<n; i++)
		{
			mat[i][0] = reader.nextLong();
			mat[i][1] = reader.nextLong();
			mat[i][2] = reader.nextLong();
		}

		long ans = 0;

		for (int i=0; i<8; i++)
		{
			long[] temp = new long[n];
			for (int j=0; j<n; j++)
			{
				for (int k=0; k<3; k++)
				{
					int bit = (i>>k) & 1;

					if (bit==0)
						temp[j] += mat[j][k];
					else
						temp[j] -= mat[j][k];
				}
			}

			Arrays.sort(temp);
			long add=0;

			for (int j=0; j<m; j++)
				add += temp[n-1-j];

			ans = Math.max (ans, add);
		}

		writer.println (ans);
		writer.close();
	}

	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  int a,b,c; cin >> a >> b >> c;
  int k; cin >> k;

  int max_num = max(a, max(b,c));
  int sum = a+b+c - max_num;

  rep(i,k){
    max_num *= 2;
  }

  int ans = sum + max_num;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    string s;
    cin >> s;
    ll k;
    cin >> k;

    char ans;
    int one = 0;
    rep(i,s.size()) {
        if (s[i] == '1') ++one;
        else break;
    }
    if (k <= one) ans = '1';
    else ans = s[one];


    cout << ans << endl;

    return 0;
}








Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			long n = cin.Long();
			long p = cin.Long();
			long[] a = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = cin.Long();
			}

			if (a.Where(x => x % 2 == 1).Count() == 0) {
				if (p == 0) {
					Console.WriteLine(Math.Pow(2, n));
				} else {
					Console.WriteLine(0);
				}
			} else {
				Console.WriteLine(Math.Pow(2, n - 1));
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 11348
#include <cstdio>
#include <algorithm>
int A, B, p[200], q[200], N, a[100], m[10000001], pr[664580], v;
inline void insert(int x)
{
	(x & 1 ? p[++A] : q[++B]) = x;
}
template < int xn, int xe > struct flow
{
	int head[xn], next[xe], to[xe], fl[xe], N, E, cur[xn], dep[xn], q[xn + 1];
	inline void add(int u, int v, int f)
	{
		next[E] = head[u], to[E] = v, fl[E] = f, head[u] = E++;
		next[E] = head[v], to[E] = u, fl[E] = 0, head[v] = E++;
	}
	void clear(int n)
	{
		N = n, E = 0;
		for (int i = 0; i < N; i++)
			head[i] = -1;
	}
	bool BFS()
	{
		for (int i = 0; i < N; i++)
		{
			dep[i] = 0;
			cur[i] = head[i];
		}
		int H = 0, T = 1, u;
		dep[0] = 1;
		q[1] = 0;
		while (H < T)
			for (int e = head[u = q[++H]]; ~e; e = next[e])
				if (fl[e] && !dep[to[e]])
				{
					dep[q[++T] = to[e]] = dep[u] + 1;
					if (to[e] == N - 1)
						return true;
				}
		return false;
	}
	int DFS(int p, int f)
	{
		if (p == N - 1)
			return f;
		int u = 0, y;
		for (int &e = cur[p]; ~e; e = next[e])
			if (fl[e] && dep[to[e]] == dep[p] + 1 && (y = DFS(to[e], std::min(f, fl[e]))))
			{
				fl[e] -= y;
				fl[e ^ 1] += y;
				u += y;
				f -= y;
				if (!f)
					return u;
			}
		if (!u)
			dep[p] = 0;
		return u;
	}
	int operator () ()
	{
		int r = 0;
		while (BFS())
			r += DFS(0, 1000000000);
		return r;
	}
};
flow < 202, 100000 > G;
inline bool is_prime(int x)
{
	return m[x] == x;
}
int main()
{
	for (int i = 2; i <= 10000000; i++)
	{
		if (!m[i])
			m[i] = pr[++v] = i;
		for (int j = 1; j <= v && pr[j] <= m[i] && pr[j] * i <= 10000000; j++)
			m[pr[j] * i] = pr[j];
	}
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d", a + i);
	for (int i = 0, j; i < N; i = j)
	{
		j = i + 1;
		while (j < N && a[j] == a[j - 1] + 1)
			j++;
		insert(a[i]);
		insert(a[i] + j - i);
	}
	G.clear(A + B + 2);
	for (int i = 1; i <= A; i++)
		G.add(0, i, 1);
	for (int i = 1; i <= B; i++)
		G.add(A + i, G.N - 1, 1);
	for (int i = 1; i <= A; i++)
		for (int j = 1; j <= B; j++)
			if (is_prime(p[i] < q[j] ? q[j] - p[i] : p[i] - q[j]))
				G.add(i, A + j, 1);
	printf("%d\n", A + B - (G() - (A & 1) >> 1 << 1) - (A & 1));
	return 0;
}


Measured memory_bytes: 41984
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [A, B, C] = input[0].split(' ').map(x => parseInt(x))

  for (let i = A; i <= 10000; i += A) {
    if (i % B === C) {
      console.log('YES')
      return
    }
  }
  console.log('NO')
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30288
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            long h = sc.nextLong();

            int cnt = 1;
            while (h/2 >= 1) {
                cnt++;
                h = h/2;
            }

            long result = calc(cnt) - 1;

            System.out.println(result);
        }
    }

    static long calc(int n){
          if(n == 0){
            return 1;
          }
          return 2 * calc(n-1);
    }
}

Measured memory_bytes: 22868