akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string O, E;
	cin >> O >> E;
	string ans;
	rep(i, 0, O.size() + E.size()) {
		if (i & 1)ans += E[i / 2];
		else ans += O[i / 2];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def resolve():
    import sys
    sys.setrecursionlimit(10 ** 6)  # 再帰関数の再帰の深さを設定
    to_index = lambda x: int(x) - 1  # 入力した数字に1を引いたものを返す
    print_list_in_2D = lambda x: print(*x, sep="\n")  # リストの要素を改行を挟んで表示する関数



    # 入力を整数に変換して受け取る
    def input_int():
        return int(input())

    def map_int_input():
        return map(int, input())

    MII = map_int_input

    def MII_split():
        return map(int, input().split())

    def MII_to_index():
        return map(to_index, input())

    def MII_split_to_index():
        return map(to_index, input().split())

    # 入力全てを整数に変換したものの配列を受け取る
    def list_int_inputs():
        return list(map(int, input()))

    LII = list_int_inputs

    def LII_split():
        return list(map(int, input().split()))

    # 2次元リスト化
    def LII_2D(rows_number):
        return [LII() for _ in range(rows_number)]

    def LII_split_2D(rows_number):
        return [LII_split() for _ in range(rows_number)]

    class UnionFind:
        def __init__(self, n):
            """
            :param n: 人数
            :type n: int
            """
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    N, M = MII_split()


    # groups = []
    uf = UnionFind(N)

    for _ in range(M):
        A, B = MII_split()
        uf.union(A-1, B-1)  # unionfindを使い、結合の計算量を減らす
        # is_in_groups = False
        # for group in groups:
        #     if A in group and B not in group:
        #         group.append(B)
        #         break
        #     elif B in group and A not in group:
        #         group.append(A)
        #         break
        #     elif A in group and B in group:
        #         is_in_groups = True
        #         break
        # if not is_in_groups:
        #     groups.append([A, B])

    print(max(uf.size(x) for x in range(uf.group_count())))
    
resolve()


Measured memory_bytes: 18424
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int     MOD = (int) 1E9 + 7;
    
    public static void main(String[] args) {
        int N = nint();
        int K = nint();
        int[] a = nints(N);
        boolean[] taroWins = new boolean[K+1]; // 開始時点でk個のとき、taroが勝つ場合はtrue
        
        for (int i = 0; i < N; i++) {
            taroWins[a[i]]  = true;
        }
        
        for (int k = 1; k <= K; k++) {
            if (taroWins[k]) continue;
            
            for (int i = 0; i < N; i++) {
                if (k - a[i] < 0) continue;
                
                if (!taroWins[k - a[i]]) {
                    taroWins[k] = true;
                    break;
                }
            }
        }
        
        System.out.println(taroWins[K] ? "First" : "Second");
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static double ndouble() {
        return sc.nextDouble();
    }

    private static double[] ndoubles(int n) {
        return ndoubles(n, 0, 0);
    }

    private static double[] ndoubles(int n, int padL, int padR) {
        double[] d = new double[n + padL + padR];
        for (int i = 0; i < n; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0, 0);
    }

    private static char[][] nchars2(int h, int w, int padLU, int padRD) {
        char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);
        return a2;
    }

    private static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    private static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    private static long abs(long a, long b) {
        return Math.abs(a - b);
    }
}


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

int main() {
	int d[3];
	while (cin >> d[0] >> d[1] >> d[2], d[0], d[1], d[2]) {
		int n;
		cin >> n;
		sort(d, d + 3);
		long double c = sqrt(d[0] * d[0] + (d[1] * d[1]));
		for (int i = 0;i < n;i++) {
			int a;
			cin >> a;
			if (a*2 > c)cout << "OK" << endl;
			else cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3084
from bisect import bisect_right
from itertools import accumulate


N = int(input())
A = sorted(map(int, input().split()))
acc_A = list(accumulate(A))
ans = 0
for i in range(N):
    prev = i
    while True:
        idx = bisect_right(A, 2 * acc_A[prev]) - 1
        if idx == N - 1:
            ans += 1
            break
        if idx == prev:
            break
        prev = idx
print(ans)


Measured memory_bytes: 14432
#include<iostream>
#include<cstdio>
#include<functional>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<map>
#include<ctime>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn = 1e5+3;
const int inf = 1e5;
const int modn = 1e9+7;
const ld eps = 1e-8;
const long double PI = acos(-1.0);
void qRead(ll &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
void qRead(int &x){x = 0;char a;for(a = getchar();a <'0' || a > '9';a = getchar());for(;a >= '0' && a <= '9';a = getchar())x = x*10 + a-'0';}
ll qpow(ll a,ll b,ll mo = modn){
//    printf("%lld\n",mo);
    ll res = 1;
    while(b){
        if(b & 1)res = (res*a) % mo;
        a = (a*a) % mo;
        b >>= 1;
    }
    return res;
}
ld qpow(ld a,ll b){
    ld res = 1;
    while(b){
        if(b & 1)res *= a;
        a = a*a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b){
    if(!b)return a;
    return gcd(b,a%b);
}
//ll vis[maxn],prime[maxn],cnt,smallP[maxn];
//void getPrime(int n){
//    cnt = 0;
//    for(int i = 1;i <= n;i++)vis[i] = 0;
//    for(ll i = 2;i <= n;i++){
//        if(!vis[i]){
//            prime[++cnt] = i;
//            smallP[i] = i;
//        }
//        for(int j = 1;j <= cnt && i*prime[j] <= n;j++){
//            vis[prime[j]*i] = 1;
//            smallP[prime[j]*i] = prime[j];
//            if((i % prime[j]) == 0)break;
//        }
//    }
//}
int a[maxn];
int main(){
    int n;
    scanf("%d",&n);
    int sum = 0;
    for(int i = 1;i <= n;i++){
        scanf("%d",&a[i]);
        sum += a[i];
    }
    sum /= n;
    int ans = 1e9+7;
    for(int i = sum-1;i <= sum+1;i++){
        int res = 0;
        for(int j = 1;j <= n;j++){
            res += (a[j] - i)*(a[j] - i);
        }
        ans = min(ans,res);
    }
    printf("%d\n",ans);
}


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

int main()
{
	int m = 0, d = 0;
	cin >> m >> d;
	int d1, d2;
	int ans = 0;
	for (int i = 1; i <= m; i++)
	{
		for (int n = 1; n <= d; n++)
		{
			d1 = n / 10;
			d2 = n % 10;
			if ((d1 >= 2) && (d2 >= 2) && (i == d1 * d2))
			{
				ans += 1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const long long MAXM=4005,MAXN=8005,MOD=1e9+7;
long long n;
long long jc[MAXN],dp[MAXM][MAXM],ask[MAXM][MAXM];
long long Inv[MAXN];
long long ksm(long long x,long long y)
{
	long long k=1;
	while(y)
	{
		if(y&1)
			k=(k*x)%MOD;
		x=(x*x)%MOD;
		y>>=1;
	}
	return k;
}
void Init()
{
	jc[0]=1;
	for(long long i=1;i<MAXN;i++)
		jc[i]=(jc[i-1]*i)%MOD;
	Inv[MAXN-1]=ksm(jc[MAXN-1],MOD-2);
	for(long long i=MAXN-2;i>=0;i--)
		Inv[i]=(Inv[i+1]*(i+1))%MOD;
}
long long C(long long m,long long n)
{
	if(n>m)
		return 0;
	return ((jc[m]*Inv[n])%MOD*Inv[m-n])%MOD;
}
int main()
{
	//freopen("bbq.in","r",stdin);
	//freopen("bbq.out","w",stdout);
	Init();
	scanf("%lld",&n);
	long long ans=0,del=0;
	for(long long i=1;i<=n;i++)
	{
		long long a,b;
		scanf("%lld %lld",&a,&b);
		del=(del+C(2*(a+b),2*a))%MOD;
		dp[2000-a][2000-b]++;
		ask[2000+a][2000+b]++;
	}
	for(int i=0;i<=4000;i++)
	{
		for(int j=0;j<=4000;j++)
		{
			if(i!=0)
				dp[i][j]+=dp[i-1][j];
			if(j!=0)
				dp[i][j]+=dp[i][j-1];
			dp[i][j]%=MOD;
			ans=(ans+(ask[i][j]*dp[i][j])%MOD)%MOD;
		}
	}
	ans=(ans-del+MOD)%MOD;
	printf("%lld\n",(ans*Inv[2])%MOD);
	fclose(stdin);
	fclose(stdout);
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    int a, b, k; cin >> a >> b >> k;

    vector<int> divisors;
    for(int i = 1; i <= __gcd(a, b); ++i) {
        if(a%i == 0 && b%i == 0) divisors.push_back(i);
    }
    int numds = divisors.size();

    cout << divisors[numds-k] << endl;
    
    return 0;
}


Measured memory_bytes: 256
N, T = map(int, input().split())
c = []
t = []

for i in range(N):
    a, b = map(int, input().split())
    c.append(a)
    t.append(b)      

ans = []
for i, v in enumerate(t):
    if v <= T:
        ans.append(c[i])

if len(ans) > 0:
    print(min(ans))
else:
    print('TLE')

Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10 ** 9)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, P = lr()
graph = [lr() for _ in range(M)]

def bellmanford(s, g):
    INF = 10**19
    dist = [INF] * (N+1)
    dist[s] = 0
    for i in range(2 * N):
        for a, b, c in graph:
            if dist[a] != INF and dist[b] > dist[a] - c + P:
                dist[b] = dist[a] - c + P
                if i >= N:
                    dist[b] = -float("inf")
 
    if dist[g] == -float("inf"):
        return -1
    else:
        return max(-dist[g], 0)

answer = bellmanford(1, N)
print(answer)
# 


Measured memory_bytes: 47964
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    s = "#" + S()
    llst = [0 for _ in range(len(s))]
    rlst = [0 for _ in range(len(s))]
    ans_lst = [0 for _ in range(len(s))]
    num = 10**100

    for i in range(len(s)):
        if s[i] == "L":
            llst[i] = llst[i-1] + 1

    for i in range(len(s)-1, -1, -1):
        if s[i] == "R":
            rlst[i] = rlst[i+1] + 1

    for i in range(1,len(s)):
        if s[i] == "L":
            x = i - llst[i]
            ans_lst[i] = x if (num-(i-x))%2==0 else x+1
            # print(x,i,(num-(i-x))%2==0)
        else:
            x = i + rlst[i]
            ans_lst[i] = x if (num-(x-i))%2==0 else x-1
            # print(x,i,(num-(x-i))%2==0)


    # print(*ans_lst[1:])

    ans = [0 for _ in range(len(s))]
    for i in range(1,len(s)):
        ans[ans_lst[i]] += 1

    print(*ans[1:])

main()


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

int main () {
    string O, E; cin >> O >> E;

    string ans = "";
    for (int i = 0; i < E.size(); i++) {
        ans += O[i];
        ans += E[i];
    }
    if (O.size() != E.size()) cout << ans << O[O.size()-1] << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n < 2) {
            System.out.println(0);
            return;
        }
        int[] list = new int[n];
        for (int i = 0; i < n; i++) {
            list[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                if (list[j] != list[i]) {
                    for (int k = j + 1; k < n; k++) {
                        if (list[k] != list[i] 
                            && list[k] != list[j]
                            && list[i] + list[j] > list[k]
                            && list[i] + list[k] > list[j]
                            && list[j] + list[k] > list[i]) {
                            ans++;
                        }
                    }
                }
            }
        }
        System.out.println(ans);
	}
}

Measured memory_bytes: 36432
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
const int INF = 1001001007;
const int mod = 1000000007;

int main(){
    int n, a, b; cin >> n >> a >> b;
    string s; cin >> s;
    int gai = 1;
    int ac = 0;
    rep(i,n){
        if (s[i] == 'c') cout << "No" << endl;
        else if (s[i] == 'b'){
            if (ac < a+b && gai <= b){
                cout << "Yes" << endl;
                gai++; ac++;
            }
            else cout << "No" << endl;
        }
        else {
            if (ac < a+b){
                cout << "Yes" << endl;
                ac++;
            }
            else cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
s = input()
t = input()
n = len(t)
ans = []
def f(i):
  sum = 0
  for ch1, ch2 in zip(s[i: i+n], t):
    if ch1 != ch2:
      sum += 1
  return sum
for i in range(len(s)-n+1):
  ans.append(f(i))

print(min(ans))

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

#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 pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const int MAX = 1005;
int N;
ll ans = 1;

bool isprime[MAX];
int prime_cnt[MAX];

vector<int> eratosthenes_seive(int n) {
	bool t[n+5];
	vector<int> v;

	for (int i = 2; i <= n+1; i++) t[i] = true;

    for (int i = 2; i <= n+1; i++) {
    	if ( t[i] == true ) {
    		v.push_back(i);
    		for (int j = i + i; j <= n+1; j += i) t[j] = false;
    	}
    }
    return v;
}

void prime_factrization(int n) {

	vector<int> v;
	v = eratosthenes_seive((int)sqrt(n));

	for (int i = 0; i < v.size(); i++) {
		
		if (n % v[i] == 0) {
			while (n % v[i] == 0) {
				prime_cnt[v[i]]++;
				n /= v[i];
			}
		}
	}
	
	if (n > 1) prime_cnt[n]++;
	return;
}

int main(void) {
    scanf("%d", &N);

    rep(i, 1, N+1) {
        prime_factrization(i);
    }
    rep(i, 2, N+1) {
        if (prime_cnt[i] > 0) ans = ans * (prime_cnt[i] + 1) % MOD;
    }
   

  
    printf("%lld\n", ans % MOD);

	return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let w: usize = it.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect();
    let mut dp = vec![false; w + 1];
    for i in 0..w {
        if dp[i] {
            continue;
        }
        for &a in &a {
            if i + a > w {
                break;
            }
            dp[i + a] = true;
        }
    }
    let ans = if dp[w] {"First"} else {"Second"};
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#define int long long
using namespace std;
 
int n;
string s;
int cnt[26];
 
signed main() {
	int i;
	
	cin >> n >> s;
	for (i = 0; i < n; i++) {
		cnt[s[i] - 'a']++;
	}
	
	int ans = 1;
	int mod = 1000000007;
	for (i = 0; i < 26; i++) {
		ans *= (cnt[i] + 1);
		ans %= mod;
	}
	ans = (ans + mod - 1) % mod;
	cout << ans << endl;
	return 0;
}

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> 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(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,k;
  cin >> n >> k;
  vector<int32> a(n);
  REP(i,n)cin >> a[i];
  REP(_,k){
    vector<int32> dif(n+2,0);
    REP(i,n){
      dif[max<int32>(0,i-a[i])]++;

      dif[min<int32>(n+1,i+1+a[i])]--;
    }
    int32 cur = 0;
    bool flg = true;
    REP(i,n){
      cur += dif[i];
      a[i] = cur;
      if(a[i] != n)flg = false;
    }
    if(flg)break;
  }
  REP(i,n)cout << a[i] << " ";
  cout << endl;
  return 0;
}

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

int main() {
	int n,l,a[205],min = INT_MAX,sum=0,newsum=0;
	cin>>n>>l;
	for(int i=0;i<n;i++)
	{
	    a[i] = l+i;
	    sum += a[i];
	    if(abs(a[i]<min))
	    min = abs(a[i]);
	}
	for(int i=0;i<n;i++)
	{
	   if(a[i]!=min && a[i]!=(-min) )
	   newsum += a[i];
	}
	cout<<newsum;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <deque>

using namespace std;

#define for(i, start, end) for(ll i = (start); i < (end); i++)
#define rep(i, n) for(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ctoi(c) c - '0'
#define tos(s) to_string(s)

typedef long long ll;

int main() {
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    rep(i,k+1) {
        rep(j,k-i+1) {
            rep(l,k-i-j+1) {
                if (a * (2<<i) < b * (2<<j) && b * (2<<j) < c * (2<<l)) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

/*
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC                                                                              
                                   ******,  .,, .,, ,,,    ****.**              
                                   ** . .,,,,,,,,,,,,,,,,,,,,,. .,*             
                                   **,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.            
                                .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.        
                                .,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.        
                    ****      ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,      
              ***************,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,    
         ********************,,,,,,,,,,,,,,@@@,,,,,,,,,,,/@@@,,,,,,,,,,,,,,,    
        ******************,,,,,,,,,,,,,,,,,,(,,.         ,,,,,,,,,,,,,,,,,,,    
       ********************,,,,,,,,,,,*,,,,,.     %&&&     .,,,,*,,,,,,,,,,,,.  
       ***,,,,,,,,,,,,,,*,,,,,,,,,,,,,,,,,,,,               ,,,,,,,,,,,,,,,,,   
       ,,,,,,,,,,,,,,,,,,,**,,,,,,,,,,.......      ##(     ........,,,,,,,,,,.  
     .,,,,,,,,,,,,,,,,,,**,,,,,,,,,,..............    ..............,,,,,,,,    
    .,,,,,,,,,,,,,,,,,,,**,,,,,,,,,.................................,,,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,***,,,,,,,....................................,,,,,,,,,  
   ,,,,,,,,,,,,,,,,,,,,**,,,,,,,,.....................................,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,,**,,,,,,,,....................................,,,,,,,   
   ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.....................................,,,,,     
   ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................................,.,,,,,     
    ,,,,,,,,,,,,,,,,,,,,,,,,,,,,.....................................,,,        
     ,,,,,,,,,,,,,,,,,,,,,,,,,,,,....................................,,,        
      ,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................................,          
       ..,,,,,,,,,,,,,,,,,,,,,,,,,,.................................,           
       .........**.....       ,,,,,..............................               
        .......*......                  ****,**,       ,..****                  
        .......*,....                   .......        ......                   
          .......*....                   .....          .....                   
                                         ......          .....                  
*/

Measured memory_bytes: 3032
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template

//main
signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<int> win(1000000,0);
  for(int i=0;i<=K;i++){
    if(win[i])continue;
    for(int j=0;j<N;j++){
      win[i+v[j]]=1;
    }
  }
  if(win[K])cout<<"First"<<endl;
  else cout<<"Second"<<endl;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 60000

bool check[SIZE];

int main(){

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

		check[i] = true;
	}
	check[1] = false;
	vector<int> V;

	for(int i = 2; i < SIZE; i++){
		if(!check[i])continue;
		if(i%10 == 7){

			V.push_back(i);
		}

		for(int k = 2*i; k < SIZE; k += i){

			check[k] = false;
		}
	}


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

	printf("%d",V[0]);
	for(int i = 1; i < N; i++){

		printf(" %d",V[i]);
	}
	printf("\n");

	return 0;
}


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

int main() {
    int n, q, cnt = 0;
    cin >> n >> q;
    queue<pair<string, int> > que;
    string name; int time;
    for(int i=0; i<n; i++) {
        cin >> name >> time;
        que.push(make_pair(name, time));
    }
    while(!que.empty()) {
        pair<string, int> top = que.front();
        que.pop();
        if(top.second <= q) {
            cnt += top.second;
            cout << top.first << " " << cnt << endl;
        }
        else {
            cnt += q;
            que.push(make_pair(top.first, top.second - q));
        }
    }
}


Measured memory_bytes: 6324
n = int(input())
s = input()

w = s.count("W")
r = s.count("R")

a = ""     # 入力
b = ""     # 正解
cnt = 0

for t in s:
    if t == "W":
        b = b + "0"
    else:
        b = b + "1"

for i in range(r+w):
    if i < r:
        a = a + "1"
    else:
        a = a + "0"
    if a[i] != b[i]:
        cnt += 1

cnt = cnt // 2

print(cnt)


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

use proconio::input;
use proconio::marker::Chars;
use std::iter::FromIterator;

fn print_vec(v: &Vec<char>, b: bool) {
    if b { println!("{}", String::from_iter(v)); }
    else { print!("{}", String::from_iter(v)); }
}

fn print_vec_range(v: &Vec<char>, s: usize, t: usize, b: bool) {
    for i in s..t {
        print!("{}", v[i]);
    }
    if b { print!("\n"); }
}

fn main() {
    input! {
        a: f64, b: f64, h: f64, m: f64
    }
    let ax = ((h/12.0+m/12.0/60.0)*2.0*std::f64::consts::PI).cos() * a;
    let ay = ((h/12.0+m/12.0/60.0)*2.0*std::f64::consts::PI).sin() * a;
    let bx = ((m/60.0)*2.0*std::f64::consts::PI).cos() * b;
    let by = ((m/60.0)*2.0*std::f64::consts::PI).sin() * b;
    println!("{}", ((ax-bx)*(ax-bx)+(ay-by)*(ay-by)).sqrt())
}


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

int main() {
  int N, X, Y; cin >> N >> X >> Y;

  int g[N][N];
  X--;
  Y--;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      g[i][j] = 0;
    }
  }

  // for (int i = 0; i < N; i++) {
  //   for (int j = i; j < N; j++) {
  //     if (i == X && j == Y) {
  //       g[i][j] = 1;
  //       g[j][i] = 1;
  //       cost[1]++;
  //     } else {
  //       if (j - i == 1 || i - j == 1) {
  //         g[i][j] = 1;
  //         g[j][i] = 1;
  //         cost[1]++;
  //       }
  //     }
  //   }
  // }

  int tmp, tmp2;
  for (int i = 0; i < N; i++) {
    for (int j = i; j < N; j++) {
      if (i == X && j == Y) {
        g[i][j] = 1;
      } else {
        tmp = j - i;
        tmp2 = abs(X - i) + abs(Y - j) + 1;
        g[i][j] = min(tmp, tmp2);
      }
    }
  }

  // for (int i = 0; i < N; i++) {
  //   for (int j = 0; j < N; j++) {
  //     cout << g[i][j];
  //   }
  //   cout << endl;
  // }


  int cost[N];
  for (int i = 0; i < N; i++) cost[i] = 0;

  tmp = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      tmp = g[i][j];
      cost[tmp]++;
    }
  }

//  cout << endl;

  for (int i = 1; i < N; i++) {
//    cout << "cost:" << i << " " << cost[i] << endl;
    cout << cost[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 15872
# ????????????????????°??????
import sys
from decimal import Decimal

def is_parallel(x1, y1, x2, y2, x3, y3, x4, y4):
    d1x = x2 - x1
    d1y = y2 - y1
    d2x = x4 - x3
    d2y = y4 - y3

    return d1x * d2y == d1y * d2x

def main():
    n = int(sys.stdin.readline().strip())

    for _ in range(n):
        data = sys.stdin.readline().strip().split(' ')
        x1 = Decimal(data[0])
        y1 = Decimal(data[1])
        x2 = Decimal(data[2])
        y2 = Decimal(data[3])
        x3 = Decimal(data[4])
        y3 = Decimal(data[5])
        x4 = Decimal(data[6])
        y4 = Decimal(data[7])

        if is_parallel(x1, y1, x2, y2, x3, y3, x4, y4):
            print('YES')
        else:
            print('NO')
            
if __name__ == '__main__':
    main()

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    cin >> n;
    deque<ll> out;
    rep(i, n)
    {
        ll a;
        cin >> a;
        if (i % 2 == n % 2)
            out.push_back(a);
        else
            out.push_front(a);
    }
    rep(i, n) cout << out[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3840
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


h, w = LI()
L = LIR(h)
ans = []
for y in range(h):
    flag = False
    for x in range(w-1):
        if L[y][x] % 2:
            flag ^= True
        if flag:
            ans += [[y+1, x+1, y+1, x+2]]
    L[y][w-1] += flag


flag = False
for y in range(h-1):
    if L[y][w-1] % 2:
        flag ^= True
    if flag:
        ans += [[y+1, w, y+2, w]]



print(len(ans))
for i in ans:
    print(*i)

Measured memory_bytes: 71260
import sys
sys.setrecursionlimit(int(1e6))

import heapq

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
h_A = []
for a in A:
    heapq.heappush(h_A, -a)

for _ in range(M):
    x = heapq.heappop(h_A)
    heapq.heappush(h_A, -(-x // 2))

prices = [- heapq.heappop(h_A) for _ in range(N)]
print(sum(prices))


Measured memory_bytes: 14180
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int[] a = new int[n];
      int all = 0;
      for (int i = 0; i < n; i++) {
         a[i] = in.nextInt();
         all ^= a[i];
      }
      for (int i = 0; i < n; i++) {
         out.print((a[i] ^ all) + " ");
      }
      out.println();
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

      public String nextToken() {
         while (st == null || !st.hasMoreTokens()) {
            try {
               st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
         return st.nextToken();
      }

      public int nextInt() {
         return Integer.parseInt(nextToken());
      }

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


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

int main(){
	string s;
  	cin >> s;
  	int k=0,l=0;
  	for (int i=0;i<s.size();i++){
    	if (s.at(i)=='A'){
          	k=i+1;
          	break;
        }
    }
  	for (int i=s.size()-1;i>=0;i--){
    	if (s.at(i)=='Z'){
          	l=i+1;
          	break;
        }
    }
	cout << l-k+1 << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll x,y;

int main(){
	cin>>x>>y;
  ll res=0;
  while(x<=y){
    x*=2;
    res++;
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 768
N, K = gets.split.map(&:to_i)

max_pairs_count = (N - 1) * (N - 2) / 2
if K > max_pairs_count
  puts -1
  exit 0
end
ans = []
(1..(N - 1)).each do |i|
  ans.push([i, N])
end
candidates = []
(1..(N - 2)).each do |i|
  ((i + 1)..(N - 1)).each do |j|
    candidates.push([i, j])
  end
end
ans += candidates.take(max_pairs_count - K)
puts ans.size
ans.each do |(i, j)|
  puts "#{i} #{j}"
end


Measured memory_bytes: 2300
#include <iostream>

using namespace std;

int main(){
    int n,times;
    int *dice,*tmp;
    double max = 0,temp;

    cin >> n >> times;

    dice = new int[n];
    tmp = new int[n+1];

    tmp[0] = 0;

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


    for(int i = 1;i <= n;i++){
        tmp[i] = tmp[i - 1] + dice[i - 1];
    }

    for(int i = times;i <= n;i++){
        temp = (tmp[i] - tmp[i - times]) / 2.0;
        if(max < temp) max = temp;
    }

    cout << fixed << max << endl;

    delete [] tmp,dice;

    return 0;


    
}

Measured memory_bytes: 1792
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
#define M 50
ll t[N], t2[N], f[N], w[N];
vector<ll> a;
int m;

void rec(ll x, ll y){
	if(w==0) return;
	if(x<M){
		rep(i, x) t2[f[i]] += y;
		return;
	}
	if(x<=a[0]){
		t[0] += y;
		t[x] -= y;
		return;
	}
	int k = lower_bound(a.begin(), a.end(), x)-a.begin()-1;
	w[k] += x/a[k]*y;
	//rec(a[k], x/a[k]*w);
	rec(x%a[k], y);
}

void rec2(ll k){
	if(w[k]==0) return;
	if(k==0){
		t[0] += w[k];
		t[a[0]] -= w[k];
		return;
	}
	w[k-1] += a[k]/a[k-1]*w[k];
	//rec(a[k], x/a[k]*w);
	rec(a[k]%a[k-1], w[k]);
	rec2(k-1);
}

int main(){
	ll n2, q;
	cin>>n2>>q;
	vector<ll> b(q+1);
	b[0] = n2;
	rep(i, q) cin>>b[i+1];
	a.push_back(b[q]);
	rep(i, q) if(b[q-i-1]<a.back()) a.push_back(b[q-i-1]);
	int m = a.size();
	ll n = a.back();
	rep(i, n) f[i] = i;
	for(int i = m-2; i >= 0; i--){
		for(int j = a[i+1]; j < min(a[i], (ll)M); j++){
			f[j] = f[j%a[i+1]];
		}
		if(a[i]>=M) break;
	}
	reverse(all(a));
	w[m-1] = 1;
	rec2(m-1);
	rep(i, n) t[i+1] += t[i];
	rep(i, n) t[i] += t2[i];
	rep(i, n2) cout<<t[i]<<endl;
	return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int ans = 0;
  int x = 0;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='I') x++;
    else x--;
    if(x>ans) ans = x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define eps 1e-8
using namespace std;
const ll maxn = 1e6 + 5;
ll a,b,c,d,k,n,m,t,num[maxn];
string ans = "Yes";
double sum;
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
int main()
{
    cin >> n >> k;
    ll f = n % k;
    cout << min(f,abs(f - k)) << endl;
    return 0;
}


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


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

    long long int n,count=0,a,b,i,j;
    cin >> n;
    count=n+n*n+n*n*n;
    cout << count << endl;
    return 0;

}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
   int k;
   scanf("%d",&k);
   queue<LL>q;
   for(int i = 1;i<=9;++i)
    q.push(i);
   LL ans;
   for(int i = 1;i<=k;++i)
   {
       ans =q.front();
       q.pop();
       if(ans%10)q.push(10*ans+(ans%10)-1);
       q.push(10*ans+(ans%10));
       if(ans%10!=9)q.push(10*ans+(ans%10)+1);
   }
   cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 10000000000000000
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
int main()
{
  //flash;
  ll yo;
  cin>>yo;
  ll ans=INF;
  for (ll i = 1; i <= ceil(sqrt(yo)); ++i)
  {
    if(yo%i==0)
    {
      ans=min(ans,(i+(yo/i)));
    }
  }
  cout<<ans-2;
  return 0;
}
//code the AC sol !
// BS/queue/map


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::prelude::BufRead;
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufReader, BufWriter, Write};
#[allow(unused_imports)]
use std::mem::swap;
#[allow(unused_imports)]
use std::str::FromStr;

fn main() {
	let n = read::<usize>();
	let arr = read_vector::<usize>();
	let mut highest = arr[0];
	let mut ans = 1;
	for i in 1..n {
		if arr[i] >= highest {
			ans += 1;
			highest = arr[i];
		}
	}
	
	println!("{}", ans);
}
#[allow(dead_code)]
fn read<T>() -> T
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf.trim().parse().unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::with_capacity(100);
    stdin().read_line(&mut buf).unwrap();
    return buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    use std::io::prelude::*;
    let stdin = stdin();
    let mut reader = BufReader::with_capacity(100 * 1024, stdin);
    let mut line = String::with_capacity(100);
    let mut matrix: Vec<Vec<T>> = Vec::new();

    while reader.read_line(&mut line).unwrap() > 0 {
        matrix.push(
            line.trim()
                .split_whitespace()
                .map(|s| s.parse().unwrap())
                .collect(),
        );
        line.clear();
    }

    return matrix;
}

#[allow(dead_code)]
fn read_chars() -> Vec<char> {
    let stdin = stdin();
    let mut buf = String::new();
    let _bytes = stdin.read_line(&mut buf).unwrap();
    return buf.trim().chars().collect();
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include<cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include<bitset>

#define REP(i, b, n) for(int i=b;i<(int)n;i++)
#define rep(i, n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it, o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define dbg(x) cout << __LINE__ << ' ' << #x << " = " << (x) << endl


typedef long long ll;

using namespace std;


int main() {
    ll n, sum;
    cin >> n >> sum;

    vector<ll> a(n);
    ll all = 0;
    rep(i, n){
        cin >>a[i];
        all += a[i];
    }
    if(all == sum){
        cout << n <<endl;
        return 0;
    }


    ll ans = 0;
    rep(skip, n) {
        vector<ll> V(n + 1);
        rep(i, n + 1)V[i] = -1;
        V[0] = sum;
        rep(i, n) {
            if(i == skip)continue;
            vector<ll> next = V;
            rep(j, n) {
                next[j + 1] = max(next[j + 1], V[j] - a[i]);
                if (next[j + 1] >= 0)ans = max(ans, ll(j + 1));
            }
            V = next;
            rep(i, n + 1) {
                cerr << next[i] << ' ';
            }
            cerr << endl;
        }
    }
    cout << ans <<endl;
    return 0;
}

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

const double eps = 1e-10;

int dcmp(double x) {
        if(fabs(x) < eps) return 0;
        return x < 0 ? -1 : 1;
}

#define Vector P
struct P {
        double x, y;
        P(double x = 0, double y = 0): x(x), y(y) {}
        P operator + (P b) {return P(x + b.x, y + b.y);}
        P operator - (P b) {return P(x - b.x, y - b.y);}
        P operator * (double b) {return P(x * b, y * b);}
        P operator / (double b) {return P(x / b, y / b);}
        double operator * (P b) {return x * b.x + y * b.y;} // Dot
        double operator ^ (P b) {return x * b.y - y * b.x;} // Cross
        double abs() {return hypot(x, y);}
        P unit() {return *this / abs();}
        P spin(double o) {
                double c = cos(o), s = sin(o);
                return P(c * x - s * y, s * x + c * y);
        }
};

struct Line {
        //ax + by + c = 0
        double a, b, c, theta;
        P pa, pb;
        Line(): a(0), b(0), c(0), theta(0), pa(), pb() {}
        Line(P pa, P pb): a(pa.y - pb.y), b(pb.x - pa.x), c(pa ^ pb), theta(atan2(-a, b)), pa(pa), pb(pb) {}        P projection(P p) {return pa + (pb - pa).unit() * ((pb - pa) * (p - pa) / (pb - pa).abs());}                P reflection(P p) {return p + (projection(p) - p) * 2;}
        double get_ratio(P p) {return (p - pa) * (pb - pa) / ((pb - pa).abs() * (pb - pa).abs());}
        P dis(P p) {return ((pb - pa) ^ (p - pa)) / (pb - pa).abs();} // directed distance
};

struct Circle {
        P c;
        double r;
        Circle(P c, double r = 0): c(c), r(r) {}
};
bool onsegment(P p, P a, P b) {
        return dcmp((a - p) ^ (b - p)) == 0 && dcmp((a - p) * (b - p)) <= 0;
}
bool segment_intersection(P p1, P p2, P p3, P p4) { // end points are not allowed
        return dcmp((p2 - p1) ^ (p3 - p1)) * dcmp((p2 - p1) ^ (p4 - p1)) < 0
                && dcmp((p4 - p3) ^ (p1 - p3)) * dcmp((p4 - p3) ^ (p2 - p3)) < 0;

}

int main() {
        ios_base::sync_with_stdio(false); cin.tie(0);
        P p1, p2;
        cin >> p1.x >> p1.y >> p2.x >> p2.y;
        Line l = Line(p1, p2);
        int q; cin >> q;
        while(q--) {
                P p; cin >> p.x >> p.y;
                P ans = l.reflection(p);
                cout << fixed << setprecision(12) << ans.x << ' ' << ans.y << '\n';
        }
        return 0;
}


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

int main() {
  /*2倍した場合の数値と、足した値、どちらが小さいか、
  小さいほうの値を合計していけば、答えにたどりつくと思う。*/
  //N:操作回数
  //K:加算する値
  //T:合計の値

  int N, K, T;
  cin >> N >> K;

  T = 1;

  for (int i = 0; i < N; i++){
    if (T * 2 < T + K){
      T *= 2;
    }else{
      T += K;
    }

  }
  cout << T;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

vector<int>dp(100005,1001001001);

int main(){
  int n;
  cin >> n;
  int h[n];
  rep(i,n)cin >> h[i];
  dp[0]=0;
  rep(i,n){
    if(i-1>=0)chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    if(i-2>=0)chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
	int n;
	cin >> n;
	for(int rep=0; rep<n; rep++){
		vector<lli> p(9, 0), c(9); //plain, cipher
		for(int i=0; i<9; i++){
			cin >> hex >> c[i];
		}
		
		lli key=0;
		for(int i=0; i<32; i++){
			for(int j=0; j<9; j++){
				p[j] |= (c[j] & 1LL<<i);
			}
			lli sum=0;
			for(int j=0; j<8; j++){
				sum += p[j];
			}
			if(sum%(1LL<<(i+1)) != p[8]){
				key |= 1LL<<i;
				for(int j=0; j<9; j++){
					p[j] ^= 1LL<<i;
				}
			}
		}
		cout << hex << key << endl;;
	}
	return 0;
}

Measured memory_bytes: 2960