akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;

public class Main {
  public static void main(String[] args) {
  	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    for (int i = 0; i < n; i++) {
		a[i] = sc.nextInt();
    }

	int cnt = 0;
	boolean f = true;
	while (f) {
		cnt++;
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 != 0) {
				f = false;
				cnt--;
				break;
			}
			a[i] /= 2;
		}
	}
    System.out.println(cnt);
  }
}


Measured memory_bytes: 21716
def examC():
    N = I()
    S = SI()
    E = S.count("E"); W = N-E
    curW = 0; curE = 0
    ans = N-1
    for i in range(N):
        if S[i]=="W":
            curW +=1
        cur = N -1 - (W-curW) - curE
        if S[i]=="E":
            curE +=1
        ans = min(ans,cur)
#        print(cur)
    print(ans)
    return

def examD():
    N = I()
    A = LI()
    cur = [0]*21
    k = 0; ans = 0
    flag = True
    for i in range(N):
        for j in range(21):
            if cur[j]>=2:
                a = A[i]
                for l in range(21):
                    if a & (1 << l) == (1 << l):
                        cur[l] -= 1
                continue
        flag = True
        while(k<N):
            a = A[k]
            for j in range(21):
                if a&(1<<j)==(1<<j):
                    if cur[j]>=1:
                        flag = False
                        break
            if flag:
                for j in range(21):
                    if a & (1 << j) == (1 << j):
                        cur[j] += 1
                k +=1
            if not flag:
                break
        ans += k-i
#        print(i,k,ans,cur)
        a = A[i]
        for j in range(21):
            if a & (1 << j) == (1 << j):
                cur[j] -= 1

    print(ans)
    return

def examE():
    N, K, Q = LI()
    A = LI()
    ans = inf
    for i in range(N):
        a = A[i]
        curL = []
        l = 0; r = 0
        while(l<N):
            while(r<N):
                if A[r]<a:
                    break
                r +=1
            if l<r:
                curL.append(A[l:r])
            l = r+1
            r = l
#        print(curL)
        cur = []
        for v in curL:
            if len(v)>=K:
                v.sort()
                for j in range(len(v)-K+1):
                    cur.append(v[j])
#        print(cur)
        if len(cur)>=Q:
            cur.sort()
            now = cur[Q-1]-cur[0]
            ans = min(ans,now)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,ALPHABET
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]
ALPHABET = [chr(ord('A') + i) for i in range(26)]

if __name__ == '__main__':
    examE()


Measured memory_bytes: 46940
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int i,j,num,*arr,count,temp;
	scanf("%d",&num);
	arr = (int*)malloc(num*sizeof(int));
	for(i=0;i<num;i++) scanf("%d",&arr[i]);
	for(i=0;i<num;i++){
		for(j=i;j>0;j--){
			if(arr[j] < arr[j-1]){
				temp = arr[j];
				arr[j] = arr[j-1];
				arr[j-1] = temp;
				count++;
				}
			}
		}		
	for(i=0;i<num;i++){
		i != num-1 ? printf("%d ",arr[i]):printf("%d\n",arr[i]);
		}		
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 600
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
import copy
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7

n=int(input())
s=input()
q=int(input())
qlst=[list(input().split()) for i in range(q)]

lst=[0]*n

for i in range(n):
    lst[i] = pow(2,(ord(s[i])-ord("a")))

# print(lst)
#####segfunc######
def segfunc(x,y):
    return x|y
 
def init(init_val): #渡されたリストでsegを初期化
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x): #segの要素kをxに変更(セグ木全体の更新)
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q): #区間[p,q)での、segfuncに準じた値を返す
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res
 
#####単位元######
"""
最小値のセグ木 → 10**9　(最小値の更新に影響しないため)
　　和のセグ木 → 0　(上の単位元の説明を参照)
　　積のセグ木 → 1　(上の単位元の説明を参照)
　　gcdのセグ木 → 0　(gcdを更新しない値は0)
"""
ide_ele = 0
 
#num:n以上の最小の2のべき乗
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num #単位元の配列(計算結果に影響を及ぼさない配列)を作成
 
init(lst)
# print(seg)
def judge(u):
    res = 0
    for i in range(27):
        if u>>i & 1:
            res += 1
    return res
 
for i in range(q):
    t,x,y = qlst[i]
    if t == "1":
        update(int(x)-1,pow(2,ord(y)-ord("a")))
    else:
        print(judge(query(int(x)-1,int(y))))

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

void helper(int& K, int& X)
{
    int numsBeforeAfter = K - 1;
    for (int i = X - numsBeforeAfter; i < X; i++)
    {
        printf("%d ", i);
    }

    printf("%d ", X);

    for (int i = 0; i < numsBeforeAfter; i++)
    {
        printf("%d ", X + i + 1);
    }

    printf("\n");
}

int main()
{
    int K, X;

    scanf("%d", &K);
    scanf("%d", &X);
    
    helper(K, X);

    return 0;
}

Measured memory_bytes: 128
class UnionFind():
    def __init__(self, n):
        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 = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  uf.union(a, b)

ans = 0
for i in range(n):
  tmp = uf.size(i)
  ans = max(ans, tmp)
print(ans)

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

using namespace std;

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

    string s;
    cin >> s;

    int ans = 0;
    int n = s.size();

    for (int i = 0; i < n; i++) {
        if (s[i] == 'S') continue;
        int p = i + 1;
        while (p < n && s[p] == s[i]) ++p;
        ans = max(ans, p - i);
        i = p - 1;
    }

    cout << ans;

    return 0;
}



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

typedef unsigned long long ull;


int main(){
	int n,m;
	cin >> n >> m;
	
	int acn = 0;
	int penan = 0;
	vector<int> data(1000000,0);
	vector<int> datape(1000000,0);
	for(int i=0;i<m;++i){
		int p;
		string s;
		cin >> p >> s;
		p--;
		if(data[p] == 0 && s == "AC"){
			data[p] = 1;
			acn++;
			penan += datape[p];
		}else if(data[p] == 0 && s == "WA"){
			datape[p]++;
		}
	}
	
	cout << acn << " " << penan <<endl;
	
	
	return 0;
}


Measured memory_bytes: 8064
n = gets.to_i
edges = []
(n - 1).times { edges << gets.split.map(&:to_i) }
graph = Array.new(n + 1) { Array.new }
edges.each do |f, t, w|
  graph[f] << [f, t, w]
  graph[t] << [t, f, w]
end

weights = Array.new(n + 1)
queue = [[1, 1, 0]]

until queue.empty?
  from, to, weight = queue.shift
  weights[to] = weight
  graph[to].each do |f, t, w|
    next if t == from
    queue << [f, t, w + weight]
  end
end

weights[1..n].each do |weight|
  puts weight.odd? ? 1 : 0
end

Measured memory_bytes: 30460
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;


vector<vector<P> > edge;

vector<P> xlst, ylst;

int N;

void make_graph(vector<P> &lst)
{
    for (int i=0; i<lst.size()-1; i++)
    {
        int v1 = lst[i].second, v2 = lst[i+1].second;
        edge[v1].push_back(make_pair(abs(lst[i+1].first - lst[i].first), v2));
        edge[v2].push_back(make_pair(abs(lst[i+1].first - lst[i].first), v1));
    }
}

vector<bool> used;

int main()
{
    cin >> N;
    edge.resize(N);

    for (int i=0; i<N; i++)
    {
        int x, y;
        cin >> x >> y;
        xlst.push_back(make_pair(x, i));
        ylst.push_back(make_pair(y, i));
    }
    sort(xlst.begin(), xlst.end());
    sort(ylst.begin(), ylst.end());

    make_graph(xlst);
    make_graph(ylst);

    used.resize(N, false);

    priority_queue<P, vector<P>, greater<P> > q;
    q.push(make_pair(0, 0));
    int weight_sum = 0;
    while (!q.empty())
    {
        P p = q.top();
        q.pop();
        if (used[p.second]) continue;
        used[p.second] = true;
        weight_sum += p.first;
        for (auto e : edge[p.second])
        {
            if (!used[e.second])
            {
                q.push(e);
            }
        }
    }
    cout << weight_sum << endl;
    return 0;
}

Measured memory_bytes: 11372
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool dp[100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    int a[100010];
    rep(i, N) cin >> a[i];
    REP(j, 1, K) {
        rep(i, N) {
            if (j - a[i] >= 0) {
                dp[j] = dp[j] | !(dp[j - a[i]]); 
            }
        }
    }
    //rep(i, K) cout << dp[j] << endl;
    //cout << dp[K] << endl;
    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
map<string, int> words;

int main(){
	string S;
	int N;
	cin >> N;
	ll count = 0;
	for (int i = 0; i < N; i++) {
		cin >> S;
		sort(S.begin(), S.end());
		count += words[S]++;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 11136
#include <iostream>

using namespace std;


int P[10010]; // 0 ?????? 10000 ?????§????????????????????±?????????
void init(int N) { // ????????? ??????????????¨???????????????????????????
  for (int i=0; i<=N; ++i) P[i] = i;
  // ??¨: ????????? [0,N-1] ????????? [1,N] ?????????????????????
  // ???????????§???????????§???????????????????????§??? [0,N] ???????????¨??????
}
int root(int a) { // a ??? root(??£??¨???) ????±???????
  if (P[a] == a) return a; // a ??? root
  return (P[a] = root(P[a])); // a ????????? root ????±???????a ????????¨??????
}
bool is_same_set(int a, int b) { // a ??¨ b ???????????°?????????????±???????????
  return root(a) == root(b);
}
void unite(int a, int b) { // a ??¨ b ???????????°?????????????????¨??????
  P[root(a)] = root(b);
}


int N=0;
int Q=0;
int u=0;
int s=0;
int g=0;

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

  for(int i=0;i<Q;++i){
    cin >> u;
    cin >> s;
    cin >> g;

    if(u == 0){
      unite(s,g);
    }
    else{
      cout << is_same_set(s,g) << endl;
    }
  }
}

Measured memory_bytes: 3136
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 500005;
const int mod = 1000000007;

int a[maxn],b[maxn];
ll f[maxn];
int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    b[i]=b[i-1]^a[i];
  }
  ll ret = 0;
  if(b[n]==0){
    ll tmp = 1;
    for(int i=1;i<n;i++){
      if(b[i]==0)tmp=(tmp<<1)%mod;
    }
    ret=tmp;
  }
  int allcnt = 0;
  unordered_map<int,ll>s,g,c;
  for(int i=1;i<=n;i++){
    if(b[i]==0){
      allcnt++;
    } else {
      if(s.find(b[i])==s.end()){
        c[b[i]]=allcnt;
        f[i]=1;
        s[b[i]]=1;
        g[b[i]]=0;
      } else {
        int tmp=c[b[i]];
        c[b[i]]=allcnt;
        ll gg = g[b[i]];
        ll ss = s[b[i]];
        gg=(gg+ss*(allcnt-tmp))%mod;
        g[b[i]]=gg;
        f[i]=(1+gg)%mod;
        s[b[i]]=(ss+f[i])%mod;
      }
    }
  }
  if(b[n]!=0){
    ret=(ret+f[n])%mod;
  } else {
    int mx = 0;
    for(int i=n;i>1;i--){
      mx ^=a[i];
      if(mx>0){
        ret=(ret+f[i-1])%mod;
      }
    }
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 47196
# プライオリティキューの利用
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
# 最大の値段を取り出すために、全て(-1)を掛ける
a = list(map(lambda x: x * (-1), a))
heapq.heapify(a)
# 割引券を使い切るまで行う
while m != 0:
    # 最大の値段を取り出す
    price = heapq.heappop(a) * (-1)
    # 割引
    price //= 2
    m -= 1
    # プライオリティキューへ戻す
    heapq.heappush(a, (-1) * price)
# 最初に(-1)掛けているので、符号を戻す
print(sum(a) * (-1))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll=long long;

int main(){
    ll n,i,ans=0;
    cin>>n;
    vector<ll> a(n),b(n+1,0);
    for(i=0;i<n;i++) cin>>a[i], b[a[i]]++;
    for(i=0;i<n+1;i++) ans+=(b[i]*(b[i]-1))/2;
    for(i=0;i<n;i++) cout<<ans-b[a[i]]+1<<endl;

    return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846
 
typedef long long ll;
typedef pair< int, int > P;   
typedef pair< int, P > PP;

//-----------------------------------------------------------------------------

int n, p[100000], ans;

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

	cin >> n;
	REP(i, n) cin >> p[i];
	REP(i, n - 1) {
		if (p[i] == i + 1) {
			swap(p[i], p[i + 1]);
			ans++;
		}
	}
	if (p[n - 1] == n) ans++;
	cout << ans << endl;


    return 0;
}


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

using namespace std;
int main() {
  long n, a, b;
  cin >> n >> a >> b;
  long diff = b - a;
  if (diff % 2 == 0) {
    cout << diff / 2 << endl;
  } else {
    cout << min(a - 1, n - b) + 1 + (b - a - 1) / 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.List
import Control.Monad
main=do
 [n,m]<-map read.words<$>getLine
 py<-replicateM m (map (read.BS.unpack).BS.words<$>BS.getLine)
 mapM_ putStrLn (h m (sort(g m 0 0 (sort(f m m py)))))
  where f _ 0 l =[]
        f m n (x:l) =(x++[m-n]):(f m (n-1) l)
        g 0 _ _ pyi =[]
        g m j n ([p,y,i]:pyi) |p==j =[i,p,n+1]:(g (m-1) j (n+1) pyi)
                              |p>j  =[i,p,1]:(g (m-1) p 1 pyi)
        h 0 ipy =[]
        h m ([i,p,y]:ipy) =((k(show p))++(k(show y))):(h (m-1) ipy)
        k n =(take(6-(length n))(repeat '0'))++n

Measured memory_bytes: 94588
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, alice, bob int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	for i := range a {
		if i%2 == 0 {
			alice += a[i]
			continue
		}
		bob += a[i]
	}
	fmt.Println(alice - bob)
}


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

int main(){
	int N, i;
	scanf("%d", &N);
	vector<double> x(N), y(N);
	for(i = 0; i < N; i++){
		scanf("%lf%lf", &x[i], &y[i]);
	}
	double ans = 0;
	vector<int> perm(N);
	for(i = 0; i < N; i++){
		perm[i] = i;
	}
	int fact = 0;
	do{
		for(i = 1; i < N; i++){
			ans += hypot(x[perm[i]] - x[perm[i - 1]], y[perm[i]] - y[perm[i - 1]]);
		}
		fact++;
	}
	while(next_permutation(perm.begin(), perm.end()));
	printf("%.10lf\n", ans / fact);
	return 0;
}

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

int main(){
	string s;
	cin >> s;
	bool ok = true;
	if(s[2] != s[3]) ok = false;
	if(s[4] != s[5]) ok = false;
	if(ok){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define     int                 ll
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int n,d, ans = 0, x, y;
    cin >> n >> d;
    for(int i = 0; i < n; ++i){
    	cin >> x >> y;
    	if(ceil(sqrt(pow(x,2)+pow(y,2))) <= d){
    		ans ++;
    	}
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 3696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int k = scanner.nextInt();
        for (int i = 1, v = 7; i <= 10_000_000; i++) {
            if (v % k == 0) {
                System.out.println(i);
                return;
            }
            v *= 10;
            v += 7;
            v %= k;
        }
        System.out.println(-1);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

Measured memory_bytes: 32664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string Z;
  cin >> N;
  for(int i = 0;i < N;i++){
    string A = "";
    cin >> A;

    if(A == "Y"){
      Z = "Four";
      i++;
      for(i;i < N ; i++){
        cin >> A;
      }
      break;
    }
    if(i == N-1){
      Z = "Three";
    }
  }
  cout << Z << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

using P = pair<int, int>;
#define fi first
#define se second

// Ford-Fulkerson法用名前空間(使いたかっただけ)
/*
 * 最大流量をF, 辺の数をMとして O(FM)
 * だが、蟻本曰くこんなにかかることはまずなく、一見危なそうでも意外と大丈夫らしい
 */

namespace FordFulkerson {
    const int MAX_N = 1000010;
    const ll INF = 10000000000000;

    struct edge {
        int to;
        ll cap;
        int rev; // 行先, 容量, 逆辺
    };
    int timestamp = 0;

    int used[MAX_N];
    vector<edge> G[MAX_N];

    // 辺の追加、ちょいめんどいので関数
    // f -> tに向かう流量がcr以上、c以下となるエッジを追加
    // 無向グラフの場合は directed = falseとする
    void add_edge(int f, int t, int c=0, bool directed=true) {
        G[f].push_back({t, c, (int)G[t].size()});
        G[t].push_back({f, (directed ? 0 : c), (int)G[f].size() - 1});
    }
    
    // 今の頂点v, ゴールt, vに流せる最大流量flow
    // 返り値dは最終的に流した流量
    ll dfs(int v, int t, ll flow) {
        used[v] = timestamp;
        if (v == t) return flow;
        for (auto &g:G[v]) {
            if (used[g.to] != timestamp && g.cap > 0) {
                ll d = dfs(g.to, t, min(flow, g.cap));
                if (d > 0) {
                    // 容量の更新
                    g.cap -= d;
                    G[g.to][(size_t)g.rev].cap += d;
                    return d;
                }
            }
        }
        return 0; // どこにも流せなければ0
    }

    ll max_flow(int s, int t) {
        ll flow = 0;
        fill(begin(used), end(used), -1);
        for (ll f; (f = dfs(s, t, INF)) > 0; timestamp++) {
            flow += f;
        }
        return flow;
    }
}


int main() {
    int h, w;
    cin >> h >> w;
    P start = {-1, -1}, goal = {-1, -1};
    vector<P> gx, gy;
    for (int i=0; i<h; i++) {
        string si; cin >> si;
        for (int j=0; j<w; j++) {
            if (si[j] == '.') continue;
            else if (si[j] == 'S') {
                start = {i, j};
                FordFulkerson::add_edge(i, j+h, FordFulkerson::INF, false);
            }
            else if (si[j] == 'T') {
                goal = {i, j};
                FordFulkerson::add_edge(i, j+h, FordFulkerson::INF, false);
            }
            else 
                FordFulkerson::add_edge(i, j+h, 1, false);
        }
    }
    if (start.fi == goal.fi || start.se == goal.se) {
        cout << -1 << '\n';
    } else {
        cout << FordFulkerson::max_flow(start.fi, goal.fi) << '\n';
    }
    return 0;
}

Measured memory_bytes: 28160
#include <stdio.h>

int main(void)
{ 
    int a, b, ans;
    char str[12];    // 10000 10000\n
    fgets(str, sizeof(str), stdin);
    sscanf(str, "%d %d", &a, &b);
    
    if ( ((a*b) % 2) == 1 )
         printf("Odd");
   else
        printf("Even");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n; 
	cin>>n;
	n=n%10;
	if(n==2||n==4||n==5||n==7||n==9)cout<<"hon"<<endl;
	else if(n==0||n==1||n==6||n==8)cout<<"pon"<<endl;
	else if(n==3)cout<<"bon"<<endl;
	return 0; 
}

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

template<typename T>
struct Segtree {
    int n;
    T e;
    vector<T> dat;
    typedef function<T(T a, T b)> Func;
    Func f;

    Segtree(){}
    Segtree(int n_input, Func f_input, T e_input){
        initialize(n_input, f_input, e_input);
    }
    void initialize(int n_input, Func f_input, T e_input){
        f = f_input;
        e = e_input;
        n = 1;
        while(n < n_input) n <<= 1;
        dat.resize(2*n-1, e);
    }

    void update(int k, T a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T get(int k){
        return dat[k+n-1];
    }

    T between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

#include <bits/stdc++.h>
using namespace std;

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

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

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]){
            par[x] = y;
            sz[y] += sz[x];
        }else{
            par[y] = x;
            sz[x] += sz[y];
        }
    }

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

int main(){
    int N;
    int64_t D, A[200000];
    cin >> N >> D;
    for(int i=0; i<N; i++) cin >> A[i];

    typedef pair<int64_t, int> P;
    const int64_t INF = 1e18;
    const P INFP = {INF, 0};
    Segtree<P> stL(N, [](P a, P b){ return min(a, b);}, INFP);
    Segtree<P> stR(N, [](P a, P b){ return min(a, b);}, INFP);

    vector<int> order;
    for(int i=0; i<N; i++) order.push_back(i);
    sort(order.begin(), order.end(), [&](int i, int j){ return A[i] < A[j];});
    vector<vector<int64_t>> edges;

    for(int i : order){
        auto p = stL.between(0, i);
        if(p != INFP){
            int64_t cost = p.first + A[i] - (N-i)*D;
            edges.push_back({cost, i, p.second});
        }
        p = stR.between(i, N-1);
        if(p != INFP){
            int64_t cost = p.first + A[i] - i*D;
            edges.push_back({cost, i, p.second});
        }
        stL.update(i, {A[i] + (N-i)*D, i});
        stR.update(i, {A[i] + i*D, i});
    }

    sort(edges.begin(), edges.end());
    UnionFind uf(N);
    int64_t ans = 0;
    for(auto& e : edges){
        if(!uf.same(e[1], e[2])){
            uf.unite(e[1], e[2]);
            ans += e[0];
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 44388
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; i<n; i++)
#define REP2(i, a, b) for(int i=a; i<b; i++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int M;
    cin >> M;
    vector<long long> d(M), c(M);
    REP(i, M) cin >> d[i] >> c[i];

    long long S = 0;
    long long D = 0;
    REP(i, M)
        D += c[i];
    REP(i, M)
        S += c[i] * d[i];

    long long ans = D-1+(S-1)/9;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
"""
learn M algorithms
all start at level 0
N books on algorithms
i-th book sold for C_i yen
understanding increase by A_i_j where j is the j-th algorithm

Goal: X or higher understanding for all M algorithms
MINIMIZE YEN USED
"""

def x_satisfied(cur_und, x):
    for val in cur_und:
        if val < x:
            return False
    return True

def copy_update(cur_und, matrix, item_num):
    cur_und = cur_und[::]

    for i, lvl in enumerate(matrix[item_num]):
        cur_und[i] += lvl
    
    return cur_und




def solve(n, m, x, cost, matrix):
    def rec_solve(item_num, cur_cost, cur_und):
        nonlocal cost, matrix, n, m, x

        if x_satisfied(cur_und, x):
            return cur_cost
        elif item_num == n:
            return float("inf")
        
        #print(item_num, cur_cost, cur_und)
        #print(cost[item_num])
        take = rec_solve(item_num + 1, cur_cost + cost[item_num], copy_update(cur_und, matrix, item_num))
        dont = rec_solve(item_num + 1, cur_cost, cur_und)

        return min(take, dont)

    return rec_solve(0,0, [0] * m)


N, M, X = map(int, input().split())
cost = []
matrix = []

for _ in range(N):
    row = []
    inp = map(int, input().split())
    cost.append(next(inp))
    for i in inp:
        row.append(i)
    matrix.append(row)

res = solve(N, M, X, cost, matrix)
if res == float("inf"):
    print(-1)
else:
    print(res)

Measured memory_bytes: 69028
n,m = map(int, input().split())
ab = sorted([list(map(int, input().split())) for _ in range(n)])

s = 0
ans = 0
li = 0
for i in range(n):
    if s + ab[i][1] < m:
        s += ab[i][1]
        temp = ab[i][0] * ab[i][1]
        ans += temp
    else:
        li = i
        break

ans = ans + (m-s) * ab[li][0]
print(ans)

Measured memory_bytes: 28648
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var n = int.Parse(str);

            str = Console.ReadLine();
            var strs = str.Split(' ');
            var t = int.Parse(strs[0]);
            var a = int.Parse(strs[1]);

            str = Console.ReadLine();
            strs = str.Split(' ');

            var minDiff = double.MaxValue;
            int minPos = 0;
            for (int i = 0; i < strs.Length; i++)
            {
                var x = int.Parse(strs[i]);
                var ave = t - x * 0.006;
                var diff = Math.Abs(a - ave);

                if (diff < minDiff)
                {
                    minDiff = diff;
                    minPos = i;
                }
            }

            Console.WriteLine(minPos + 1);
        }
    }
}


Measured memory_bytes: 11164
#include <cstdio>  
#include <cstring>  
#include <iostream>  
#include <algorithm>  
#include <vector>  
#include <map>  
#include <queue>  
#define F first  
#define S second  
using namespace std;  
int n,m,l,k,a,h;  
bool p[111];  
vector<pair<int,int> > edge[111];  
priority_queue<pair<int,pair<int,int> >,vector<pair<int,pair<int,int> > >,greater<pair<int,pair<int,int> > > > que;  
int d[111][111];  
int main(void){  
  while(cin >> n >> m >> l >> k >> a >> h && n){  
    for(int i = 0; i < 111; i++){  
      p[i] = false;  
      edge[i].clear();  
    }  
    for(int i = 0; i < l; i++){  
      int b;  
      cin >> b;  
      p[b] = true;  
    }  
    for(int i = 0; i < k; i++){  
      int b,c,t;  
      cin >> b >> c >> t;  
      edge[b].push_back(make_pair(c,t));  
      edge[c].push_back(make_pair(b,t));  
    }  
   
    priority_queue<pair<int,pair<int,int> >,vector<pair<int,pair<int,int> > >,greater<pair<int,pair<int,int> > > > quet;  
    que = quet;  
    que.push(make_pair(0,make_pair(m,a)));  
    for(int i = 0; i < 111; i++){  
      for(int j = 0; j < 111; j++){  
    d[i][j] = 1<<30;  
      }  
    }  
    /* 
    for(int i = 0; i < 111; i++){ 
      d[i][a] = 0; 
    } 
    */ 
    d[m][a] = 0;  
    while(!que.empty()){  
      int c = que.top().F;  
      int t = que.top().S.F;  
      int v = que.top().S.S;  
      //printf("aaa %d %d %d\n",c,t,v);   
      que.pop();  
      if(d[t][v] < c) continue;  
      for(int i = 0; i < (int)edge[v].size(); i++){  
    int u = edge[v][i].F;  
    int cc = edge[v][i].S;  
    if(t < cc) continue;   
    if(d[t-cc][u] <= c+cc) continue;  
    d[t-cc][u] = c+cc;  
    que.push(make_pair(c+cc,make_pair(t-cc,u)));  
      }  
      if(p[v]){  
    for(t++,c++; t<=m; t++,c++){  
      if(d[t][v] < c) continue;  
      for(int i = 0; i < (int)edge[v].size(); i++){  
        int u = edge[v][i].F;  
        int cc = edge[v][i].S;  
        if(t < cc || d[t-cc][u] <= c+cc) continue;  
        d[t-cc][u] = c+cc;  
        que.push(make_pair(c+cc,make_pair(t-cc,u)));  
      }  
    }  
      }  
    }  
    int best = 1<<28;  
    for(int i = 0; i < 111; i++){  
      best = min(best,d[i][h]);  
    }  
    if(best >= 1<<28) cout << "Help!" << endl;  
    else cout << best << endl;  
  }  
}  

Measured memory_bytes: 1560
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.14159265358979323846
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  cout<<(n+1)/2<<endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
set<string> s;

void solve()
{
    int n;
    cin >> n;
    while(n--)
    {
        string t;
        cin >> t;
        s.insert(t);
    }
    cout << s.size() << '\n';
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 19256
N = int(input())

q = ['a']
for i in range(N - 1):
    nq = []
    for s in q:
        stop = ord(max(s)) + 2
        for i in range(ord('a'), stop):
            nq.append(s + chr(i))
    q = nq
for s in q:
    print(s)



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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int n; cin >> n;
  vector<ll> d(n); cin >> d;
  ll res = 0;
  rep(i, n){
    FOR(j, i + 1, n){
      res += d[i] * d[j];
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <math.h>
using namespace std;

const int MAX_N=100000;
int n,ma;

int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		if(n<(1<<i)){
			ma=i-1;
			break;
		}
		else if(n==(1<<i)){
			ma=i;
			break;
		}
	}
	cout << (1<<ma) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{

	int n, x;
	while (true) {
		std::cin >> n >> x;
		if (n == 0 && x == 0) break;

		int count = 0;
		for (int i = 1; i <= n - 2; i++) {
			for (int j = i + 1; j <= n - 1; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x) count++;
				}
			}
		}

		std::cout << count << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3068
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>


using namespace std;


int n, m, q;
vector<int> a, b, c, d;
int ans = 0;

void dfs(vector<int> v) {
	if (v.size() == n + 1) {
		int now = 0;
		for(int i=0;i<q;i++) {
			if (v[b[i]] - v[a[i]] == c[i]) {
				now += d[i];
			}
		}
		ans = max(ans, now);
		cout << endl;
		return;
	}

	v.push_back(v.back());
	while (v.back() <= m) {
		dfs(v);
		v.back()++;
	}
}

int main()
{
	cin >> n >> m >> q;
	a = b = c = d = vector<int>(q);
	for(int i=0;i<q;i++)cin >> a[i] >> b[i] >> c[i] >> d[i];

	//長さが1で要素が1の配列
	dfs(vector<int>(1, 1));
	cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();

        for (int i = 0; i < 3; i++) {
            if (s.charAt(i) == s.charAt(i + 1)) {
                System.out.println("Bad");
                return;
            }
        }
        System.out.println("Good");
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
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; }

const int mod = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n+1);
    rep(i,m){
        int j;
        cin >> j;
        a[j] = 1;
    }

    vector<int> dp(n+1);
    dp[0] = 1;
    for(int i = 0; i <= n; i++){
        if (i + 1 <= n && a[i+1] != 1) {
            dp[i+1] += dp[i];
            dp[i+1] %= mod;
        }
        if (i + 2 <= n && a[i+2] != 1){
            dp[i+2] += dp[i];
            dp[i+2] %= mod;
        } 
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<fstream>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

const ll MAX = 1e6+100;
// const int MOD = 1e9+7;

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

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

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

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<typename T>
void print(T &arr){
    ll sz = sizeof(arr)/sizeof(arr[0]);
    for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
    cout << arr[sz-1] << endl;
}





int main(){

    // //cinでファイルから読込
    // ifstream in("input.txt");
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cin.rdbuf(in.rdbuf());


    
    ll n; cin >> n;
    vector<ll> arev(n,-1),a(n+1);
    ll ind_be, ind_af;
    rep(i,n+1){
        cin >> a[i];
        a[i]--;
        if(arev[a[i]] == -1)arev[a[i]] = i;
        else{
            ind_be = arev[a[i]];
            ind_af = i;
        }
    }

    COMinit();

    vector<ll> res(n+1), sub(n+1,0);
    rep(i,n+1){
        res[i] = COM(n+1,i+1);
        if(i <= n-ind_af+ind_be)sub[i] = COM(n-ind_af+ind_be,i);
        res[i] -= sub[i];
        if(res[i] < 0)res[i] += MOD;
    }

    print(res);

}

Measured memory_bytes: 27776
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
int main()
{
    fastio();
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    ll h,n;
    cin>>n>>h;
    ll sum = 0;
    ll b[n];
    cn(b,n);
    sort(b,b+n);
    for(int  i=0;i<n-h;i++)
        sum+=b[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 1792