akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <string.h>
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <tuple>
#include <functional>
#include <set>

using namespace std;
int n;
int k;
int x[50];
int y[50];

int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i];
	}
	//50^5=
	long long ans = 6e18;
	for (int x1 : x) {
		for (int x2 : x) {
			if (x1 >= x2)continue;
			for (int y1 : y) {
				for (int y2 : y) {
					if (y1 >= y2)continue;
					int cnt = 0;
					for (int i = 0; i < n; ++i) {
						if (x1 <= x[i] && x[i] <= x2&&y1 <= y[i] && y[i] <= y2) {
							++cnt;
						}
					}
					if (cnt >= k) {
						ans = min(ans, (long long)(x2 - x1)*(y2 - y1));
					}

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



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    X,Y=map(int,input().split())
    if abs(X-Y)<=1:
        print('Brown')
    else:
        print('Alice')

if __name__ == '__main__':
    main()


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


int main() {
    int n, d, x;
    cin >> n >> d >> x;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        int ai;
        cin >> ai;
        sum += 1 + (d - 1) / ai;
    }
    cout << sum  + x << endl;
}


Measured memory_bytes: 256
#include<iostream>
    #include<string>
    #include<queue>
    #include<vector>
    #include<algorithm>
    using namespace std;
    const long long INF=4000000000000000000LL;
    typedef pair<long long,int> P;
    int main(){
    	int N;
    	long long A[100005],B[100005],C[100005];
    	long long D1[100005],D2[100005];
    	long long ans=0;
    	cin>>N;
    	for(int i=0;i<N;++i)cin>>A[i];
    	for(int i=0;i<N;++i)cin>>B[i];
    	for(int i=0;i<N;++i)cin>>C[i];
    	sort(A,A+N);
    	sort(B,B+N);
    	sort(C,C+N);
    	int x=0;
    	for(int i=0;i<N;++i){
    //		cout<<C[x]<<" "<<B[i]<<endl;
    		while(1){
    			if(C[x]>B[i]||x==N)break;
    			x++;
    		}
    		D1[i]=N-x;
    	}
    	x=N-1;
    	for(int i=N-1;i>=0;--i){
    		while(1){
    			if(A[x]<B[i]||x<0)break;
    			x--;
    		}
    		D2[i]=x+1;
    	}
    	for(int i=0;i<N;++i){
    		ans+=D1[i]*D2[i];
    //		cout<<D1[i]<<" "<<D2[i]<<endl;
    	}
    	cout<<ans<<endl;
    	return 0;
    }

Measured memory_bytes: 4224
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

P = 10**9 + 7
k = 3
inv_t = [0]+[1]
for i in range(2,k):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

N = int(input())
A = list(map(int, input().split()))
AA = [A[i]**2 % mod for i in range(N)]

ans = 0
b = 0
for i in range(N):
    ans = (ans + A[i]) % mod
    b = (b + AA[i]) % mod
ans = ans % mod
b = b % mod

ans = (ans**2) % mod
ans = (ans - b) % mod

ans = (ans*inv_t[2]) % mod
print(ans)

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

int main(){
  int N,i;
  cin>>N;
  vector<int64_t> L(N+1);
  L.at(0)=2ll;L.at(1)=1ll;
  for(i=2;i<=N;i++){
    L.at(i)=L.at(i-1)+L.at(i-2);
  }
  cout<<L.at(N)<<endl;
}

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

#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    int n;cin >> n;
    string s;cin >> s;
    int k;cin >> k;
    
    rep(i,n){
        s[i] = (s[i]==s[k-1])?s[i]:'*';
    }
    cout << s << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
const ll inf = 1e9 + 10;
const ll maxn = 1e5 + 163;
const ll alf = 26;
const ll dlm = 1e9+7;
const ll del = 10979 ;
const int eps = 1e-7 ;
const int maxq = 3e3+132 ;

int n;
int h[maxn] ;
ll dp[maxn] ;

int main()
{
    ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>h[i] ;
    dp[1] = 0 ;
    dp[2] = abs(h[2]-h[1]) ;
    for(int i=3;i<=n;i++){
        dp[i] = min( (dp[i-1]+abs(h[i]-h[i-1]) ), (dp[i-2] + abs(h[i]-h[i-2])) );
    }
    cout<<dp[n];
    return 0;
}



Measured memory_bytes: 1536
#include <iostream>
#include <cstring>
#define SIZE 101
using namespace std;

int main()
{
    int n, chack = 0;
    cin>>n;
    cin>>ws;
    string str;
    getline(cin, str);
    for(int i = 0; str[i]!='\0'; i++)
    {
        if(str[i] == 'Y')
        {
            chack++;
            break;
        }
    }
    if(!chack)
        cout<<"Three"<<endl;
    else
        cout<<"Four"<<endl;

    return 0;
}


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

int main(){
	int A, B, C, X, ans=0;
	cin >> A >> B >> C >> X;
	for(int i=0; i<=A; i++){
		for(int j=0; j<=B; j++){
			for(int k=0; k<=C; k++){
				if(X==500*i+100*j+50*k) ans++;
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
int A , B , C;
cin >> B >> A;// kazoerukazu
int D = 0;
for (int i = 0; i < B; i++){
  cin >> C ;
  if ((A - C) * 2 < (2 * C )){
    D +=  (A - C)* 2;
  }else{
    D += 2 * C;
  }
}
cout << D << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<bitset>
#include<vector>

int Primes[1010] = { 0 };
int index = 0;

void calc_prime(int x) {
	for (int i = 2; i <= x; i++) {
		for (int pi = 0; pi < index; pi++)
			if (i % Primes[pi] == 0)
				goto LoopEndPoint;
		Primes[index] = i;
		index++;
	LoopEndPoint:;
	}
}

std::vector<int> fact(int x) {
	std::vector<int> res;
	for (int i = 0; i <= 1010; i++) {
		if (x % Primes[i] == 0) {
			res.push_back(i);
			x /= Primes[i];
			i--;
		}
		if (x == 1) break;
	}
	return res;
}

int main(void) {
	calc_prime(1010);
	
	int N;
	std::cin >> N;

	int fact_res[1000] = { 0 };

	for (int i = 2; i <= N; i++) {
		std::vector<int> tmp = fact(i);
		for (int tmp_i = 0; tmp_i < tmp.size(); tmp_i++) {
			fact_res[tmp[tmp_i]]++;
		}
	}

	long long int res = 1;
	for (int i = 0; i < 1000; i++) {
		res *= (fact_res[i] + 1);
		res %= 1000000007;
	}

	std::cout << res << std::endl;	

	system("pause");
}

Measured memory_bytes: 504
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

struct data{
  int d;
  int n;
};
bool comp(data d1, data d2){
  return d1.d < d2.d;
}

int main(){
  int N;
  ll K;
  cin >> N >> K;
  vector<data> D;
  for(int i=0; i<N; i++){
    int a, b;
    cin >> a >> b;
    data d = {a, b};
    D.push_back(d);
  }
  sort(D.begin(), D.end(), comp);
  // for(int i=0; i<N; i++)
  //   cout << D[i].d << ' ' << D[i].n << endl;
  int i = 0;
  K--;
  while(K >= 0){
    if(D[i].n > K){
      cout << D[i].d << endl;
      break;
    } else {
      K -= D[i].n;
      i++;
    }
  }
  return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>

int main(void)
{
    int a,b;
    char op;
    scanf("%d %c %d", &a,&op,&b);
    switch(op) {
        case'+':printf("%d",a+b);
                break;
        case'-':printf("%d",a-b);
                break;
    }
    return 0;
}


Measured memory_bytes: 128
# import itertools
# import math
import sys
# sys.setrecursionlimit(500*500)
# import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

if N % 2 == 1:
    print(0)
    sys.exit()

tot = 0
i = 10
while(N >= i):
    tot += N // i
    i *= 5
print(tot)


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

int main(){
    int W,H,x,y;
    cin >> W >> H >> x >> y;
    int num = (x*2==W && y*2==H) ? 1 : 0;
    printf("%.10f %d\n",(double)W*H/2,num);
    return 0;
}

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

#define ED return 0;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) long(pow(x,y))
const long long mod = 1000000007;
long long int gcd(long long int a, long long int b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    long long int answer;
    cin >> answer;
    for(int i = 0;i < N-1;i++){
        long long int dummy;
        cin >> dummy;
        answer *= dummy / gcd(answer,dummy);
    }
    cout << answer << endl;
}



Measured memory_bytes: 256
#if 0
2020.01.30
 
每行放一个颜色即可构造 n = k 的方案。
如果 k 为 4 的倍数，每行相间放两个颜色即可构造 n = k / 2 的方案。
但是如果 k 不是 4 的倍数的时候这个构造方法就不使用了，
任何一行如果只放一个颜色，由于其相邻的行是相间的，不符合要求。
 
从斜行方向考虑，每斜行放一个颜色同样可以构造 n = k 的方案。
同样如果 k 为 4 的倍数，每斜行相间放两个颜色即可构造 n = k / 2 的方案。
而这个构造方式很优秀，把一斜行换成只填一种颜色仍然合法，
因为两斜行的相交部分本来就是相邻两个块。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)
 
typedef long long ll;
 
struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
} read;
 
const int maxn = 500;
int a[maxn][maxn];
 
int main() {
	int k = read;
	int n = k == 1 ? 1 : (k + 3) >> 2 << 1;
 
	int c = 0;
	for(int i = 0; i < n; i ++) {
		++ c;
		for(int j = 0; j < n; j += 2)
			a[(i + j) % n][j] = c;
	}
 
	for(int i = 0; i < n; i ++) {
		int x = ++ c;
		if(x > k)
			x = a[i][0];
		for(int j = 1; j < n; j += 2)
			a[(i + j) % n][j] = x;
	}
 
	printf("%d\n", n);
	for(int i = 0; i < n; i ++) {
		for(int j = 0; j < n; j ++)
			printf("%d ", a[i][j]);
		puts("");
	}
}

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		char c = str.charAt(0);
		char[] vowel = {'a','e','i','o','u'};
		int cnt=0;
		for(int i=0; i<5; i++){
			if(c == vowel[i]){
				cnt += 1;
			}
		}

		if(cnt == 1){
			System.out.println("vowel");
		}else{
			System.out.println("consonant");
		}
	}
}



Measured memory_bytes: 21844
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)
def lcm(a, b):
    return a // gcd(a, b) * b

n = int(input())
a = list(map(int, input().split()))

l = 1
for i in a:
    l = lcm(l, i)

ans = 0
for i in a:
    ans += l // i

print(ans % 1000000007)

Measured memory_bytes: 75648
S = input().strip()


for i in range(2**3):
  ans = S[0] ## 数式となる文字列
  _sum = int(S[0]) ## 合計値
  for j in range(3):
    if (i>>j)&1: ## それぞれのビットを右シフトして評価する
      """ビットが1のとき"""
      ans += "+" + S[j+1]
      _sum += int(S[j+1])
    else:
      """ビットが0のとき"""
      ans += "-" + S[j+1]
      _sum -= int(S[j+1])
  if _sum == 7:
    ans += "=7"
    print(ans)
    quit()


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

using namespace std;

int main(){
	
	int N,W;
	
	cin>>N>>W;
	
	int w[N+1],v[N+1];
	
	for(int i=1; i<=N; i+=1){
		
		cin>>w[i]>>v[i];
	}
	
	long long int dp[W+1];
	
	for(int i=0; i<=W; i+=1){
		
		dp[i] = 0;
	}
	
	for(int i=1; i<=N; i+=1){
		
		for(int j=W; j>=w[i]; j-=1){
			
			dp[j] = max(dp[j],v[i]+dp[j-w[i]]);
		}
	}
	
	cout<<dp[W]<<endl;
}

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

map<long long, int> factorize(long long n) {
    map<long long, int> ret;
    for(long long i=2; i * i <= n; ++i) {
        while(n % i == 0) {
            ++ret[i];
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

int main() {
    int N; cin >> N;
    int res = 0;
    for(int i=1; i<=N; i+=2) {
        auto fac = factorize(i);
        int cnt = 1;
        for(auto p : fac) cnt *= p.second + 1;
        if(cnt == 8) ++res; 
    }
    cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var ar1 = Enumerable.Repeat(0, num).Select(v => Input.numL).OrderBy(v=>v).ToArray();
        var ar2 = ar1.Reverse().ToArray();
        if (num % 2 == 0)
        {
            var b = ar2.Take(num / 2 - 1).Sum() * 2 + ar2.Skip(num / 2 - 1).Take(1).Sum();
            var s= ar1.Take(num / 2 - 1).Sum() * 2 + ar1.Skip(num / 2 - 1).Take(1).Sum();
            WriteLine(b - s);
            return;
        }
        var bb = ar2.Take((num + 1) / 2 - 2).Sum() * 2 + ar2.Skip((num + 1) / 2 - 2).Take(2).Sum();
        var ss = ar1.Take(num / 2).Sum() * 2;
        var res = bb - ss;
        ss = ar1.Take((num + 1) / 2 - 2).Sum() * 2 + ar1.Skip((num + 1) / 2 - 2).Take(2).Sum();
        bb = ar2.Take(num / 2).Sum() * 2;
        WriteLine(Max(bb - ss, res));
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 26588
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

typedef long long ll;

using namespace std;
int main(){
    ll A, B;
    cin >> A >> B;
    ll K = 0;	
    if ((A + B) % 2 == 0) K = (A + B) / 2;

    if (K != 0) cout << K << endl;
    else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back

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

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n,0);
  vector<ll> s(n+1,0);
  rep(i,n) {
    cin >> a.at(i);
    s.at(a.at(i)) += 1;
  }

  ll ssum = 0;
  rep(i,n+1) {
    ssum += (s.at(i)) * (s.at(i)-1)/2;
  }
  rep(i,n) {
    cout << ssum + ((s.at(a.at(i)) - 1) * (s.at(a.at(i))-2)/2) - ((s.at(a.at(i))) * (s.at(a.at(i))-1)/2)<< endl;
  }



  return 0;
}


Measured memory_bytes: 5760
main :: IO ()
main = do
  [numberOfA, numberOfB, positionOfA, positionOfB] <- map read . words <$> getLine
  positionOfAs <- map read . words <$> getLine
  positionOfBs <- map read . words <$> getLine
  let maxOfAs = maximum (positionOfAs ++ [positionOfA] :: [Int])
  let minOfBs = minimum (positionOfBs ++ [positionOfB] :: [Int])
  putStrLn $ if maxOfAs < minOfBs then "No War" else "War"

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

ll INF=1000000000000;

int main(){
    ll N;
    cin >> N;
    vector<ll> h(N,0);
    vector<ll> dp(N,INF);
    ll K;
    cin >> K;
    for(ll i=0;i<N;i++){
        cin>>h[i]
    ;}
    dp[0]=0;
    for(ll i=1;i<N;i++){
     for(ll j=max(i-K,0LL);j<i;j++){
         dp[i]=min(dp[i],dp[j]+llabs(h[j]-h[i]))
     ;}
    ;}
    cout<<dp[N-1]<<endl;
return 0;
}


Measured memory_bytes: 1792
S = gets.chomp.split('').map(&:to_i)
length = S.length
odd_sum = 0
even_sum = 0 
0.upto(length-1) do |i|
    if i % 2 == 0
        even_sum += S[i]
    else
        odd_sum += S[i]
    end
end

if length % 2 == 0
    ans = length/2 - [even_sum, odd_sum].max
    ans += [even_sum, odd_sum].min
else
    if even_sum > odd_sum
        ans = length/2 + 1 - even_sum
        ans += odd_sum
    else
        ans = length/2 - odd_sum
        ans += even_sum
    end
end

puts ans

Measured memory_bytes: 7676
S = input()
Q = int(input())
reverse = False
front = ""
end = ""
 
for i in range(Q):
    inp = input()
    if inp[0] == "1":
        reverse = not reverse
    else:
        _, F, C = inp.split()
        if (F == "1") ^ reverse:
            front = front+C
        else:
            end = end+C
 
if reverse:
    print(end[::-1]+S[::-1]+front)
else:
    print(front[::-1]+S+end)

Measured memory_bytes: 4468
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int happy = 0;
        
        happy += 1000*(x/500);
        x = x%500;
        happy += 5*(x/5);
        
        System.out.println(happy);
    }
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;main(){int r[6]={0},n,l,k;char c;for(cin>>n;n;n--){cin>>l>>c>>k;r[l>185?l=5:(l<165?l=0:l/5-32)]++;}for(k=0;k<6;k++){for(cout<<k+1<<":";r[k];r[k]--)cout<<"*";cout<<endl;}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define INF -2147483647
#define mod 1000000007
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<=c&&c<=b||a>=c&&c>=b) cout<<"Yes";
  else cout<<"No";
  cout<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;

int main(){
  while(const int n = getInt()){
    int ans = 0;
    vector<vector<int> > v(n, vector<int>(4));

    REP(i,n) REP(j,4)
      v[i][j] = getInt();

    vector<int> lim(4);
    REP(i,4) lim[i] = getInt();

    REP(i,n){
      bool ok = true;
      REP(j,3) if(v[i][j + 1] > lim[j])
        ok = false;

      if(v[i][1] * 4 + v[i][2] * 9 + v[i][3] * 4 > lim[3])
        ok = false;

      if(ok){
        ans++;
        printf("%d\n", v[i][0]);
      }
    }

    if(ans == 0){
      puts("NA");
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<ll> dp0(n+1);  /* dp0[i+1] : aおよびbの上からi桁目(iは0-index)までを確定させ、
                                         その時点ではまだa+bがs未満になるかわかっていない
                                         (a, b)の組の個数 */
    
    vector<ll> dp1(n+1);  /* dp1[i+1] : aおよびbの上からi桁目(iは0-index)までを確定させ、
                                         その時点で既にa+bがs未満であることがわかっている
                                         (a, b)の組の個数 */

    dp0[0] = 1;
    rep(i, n) {

        // (a_i, b_i) = (0, 0) の場合
        if(s[i] == '0') {
            dp0[i+1] = dp0[i];
            dp1[i+1] = dp1[i];
        }
        else if(s[i] == '1') {
            dp1[i+1] = dp0[i] + dp1[i];
        } 
        dp1[i+1] %= mod;

        // (a_i, b_i) = (0, 1), (1, 0) の場合
        if(s[i] == '0') {
            dp1[i+1] += 2*dp1[i];
        }
        else if(s[i] == '1') {
            dp0[i+1] += 2*dp0[i];
            dp1[i+1] += 2*dp1[i];
        }
        dp0[i+1] %= mod;
        dp1[i+1] %= mod;
        
    }

    ll ans = (dp0[n] + dp1[n])%mod;

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

Measured memory_bytes: 2048
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>

using namespace std;

typedef long long ll;

int main()
{
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<int>> a(n + 1, vector<int>(2));
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 2; ++j) {
      int ii = i - j - 1;
      for (int jj = 0; jj < 2; ++jj) {
        if (ii - jj < 0) {
          continue;
        }
        if (s.substr(ii - jj, jj + 1) == s.substr(i - j, j + 1)) {
          continue;
        }
        a[i][j] = max(a[i][j], a[ii][jj] + 1);
      }
    }
  }
  cout << max(a[n][0], a[n][1]) << endl;
  return 0;
}


Measured memory_bytes: 11396
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  string s, t; cin >> s >> t;
  for(int i = 0; i < n; i++){
    cout << s[i] << t[i];
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//解説写し
int pcnt(int x){
  return __builtin_popcount(x);
}
int f(int x){
  if(x==0)return 0;
  return f(x%pcnt(x))+1;
}
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<int>x(n);
  for(int i=0;i<n;i++)x[i]=s[i]-'0';
  int pc=0;
  for(int i=0;i<n;i++)pc+=x[i];
  vector<int>ans(n);
  for(int b=0;b<2;b++){
    int npc=pc;
    if(b==0)npc++;else npc--;
    if(npc<=0)continue;
    int r0=0;
    for(int i=0;i<n;i++){
      r0=(r0*2)%npc;
      r0+=x[i];
    }
    int k=1;
    for(int i=n-1;i>=0;--i){
      if(x[i]==b){
        int r=r0;
        if(b==0)r=(r+k)%npc;
        else r=(r-k+npc)%npc;
        ans[i]=f(r)+1;
      }
      k=(k*2)%npc;
    }
  }
  for(int i=0;i<n;i++){
    cout<<ans[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 5184
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

/*
vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}
*/


int main() {
	map<P,int> m;
	int h,w,n,x,y;
	ll ans[10]={};
	cin>>h>>w>>n;
	rep(i,0,n){
		cin>>x>>y;
		rep(j,0,3)rep(k,0,3)
			m[make_pair(y-j,x-k)]++;
	}
	ans[0]=1ll*(h-2)*(w-2);
	for(auto it:m){
		int a=it.first.first;
		int b=it.first.second;
		int c=it.second;
		if(a>=1&&a+2<=w&&b>=1&&b+2<=h)ans[c]++,ans[0]--;
	}
	rep(i,0,10)print(ans[i]);
}

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


int main(){
  string str;
  cin >> str;
  int n = 0;
  for (int i = 0; i < 4; i++){
    if (str.at(i) == '+') n++;
    else n--;
  }
  cout << n << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N;
  cin >> N;
  vector<ll> Z(N, 0), W(N, 0);
  rep(i, N){
    ll x, y;
    cin >> x >> y;
    
    Z[i] = x + y;
    W[i] = x - y;
  }
  ll zmax = -1e9, zmin = 1e9, wmax = -1e9, wmin = 1e9;
  rep(i, N){
    chmax(zmax, Z[i]);
    chmin(zmin, Z[i]);
    chmax(wmax, W[i]);
    chmin(wmin, W[i]);
  }
  ll ans = max(zmax - zmin, wmax - wmin);
  cout << ans << endl;
}


Measured memory_bytes: 6352
#include <bits/stdc++.h>
    using namespace std;
    #define int long long

    signed main() {
        int n;
        cin>>n;
        int h[n],ans=0,cou=0;
        for(int i=0;i<n;i++)cin>>h[i];
        for(int i=0;i<n;i++){
            while(h[i]>cou){
                cou++;
                ans++;
            }
            while(h[i]<cou)cou--;
        }
        cout<<ans;
    }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    string s;
    cin >> s;
    vector<ll> bucket(30);
    for (int i = 0; i < s.size(); ++i) {
        bucket[s[i] - 'a']++;
    }
    bool b = true;
    for (int i = 0; i < 30; ++i) {
        if(bucket[i] % 2 == 1){
            b = false;
        }
    }
    OutputAnswerBool(b);
}


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

int occ[256];
int hv[5];
int r, c;

int main()
{
	scanf("%d%d", &r, &c);
	for (int i = 0;i < r;i++) for (int j = 0;j < c;j++)
	{
		char x; scanf(" %c", &x);
		occ[(int)x]++;
	}
	for (int i = 0;i < 256;i++) hv[occ[i]%4]++;

	bool yay = true;
	if (r%2 == 0 && c%2 == 0)
	{
		if (hv[1] || hv[2] || hv[3])
			yay = false;
	} else if (r%2 == 1 && c%2 == 1)
	{
		hv[1] += hv[3];
		hv[2] += hv[3];
		hv[3] = 0;
		if (hv[1] != 1)
			yay = false;
		if (hv[2] > r/2+c/2)
			yay = false;
	} else
	{
		if (r%2 == 0) swap(r, c);
		// r is odd
		if (hv[1] || hv[3])
			yay = false;
		if (hv[2] > c/2)
			yay = false;
	}
	if (yay) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x
#define IO if(fopen("input.txt", "r")){freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);} std::ios::sync_with_stdio(false);
using namespace std;


signed main()
{

    IO
    string s;
    cin>>s;
    if(s[s.size()-1] == 's'){
        cout<<s<<"es";
    }else{
        cout<<s<<"s";
    }


    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <algorithm> 
#include <cstdlib>
#include <bitset>
#include <math.h>
#include <numeric>
#include <set>
#include <vector>
#define ll long long
#define pf printf
#define sf scanf
using namespace std;
int main(){
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
  long int a,b;
  cin>>a>>b;
  cout<<(a*b)/__gcd(a,b);
  





  
  


  
 
 
 
    
 
return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
a = list(map(int, input().split()))
dp=[0 for i in range(K+1)] 

for k in range(a[0],K+1):
    for n in range(N):
        if k-a[n]>=0 and dp[k-a[n]]==0:
            dp[k]=1
    
if dp[K]==1:
    print('First')
else:
    print('Second')

Measured memory_bytes: 79244
#include<iostream>
#include<map>
#include<queue>
using namespace std;

const int INF = 111111111;
typedef pair<int,int> P;

char m[1500][1500];
int h,w,n,hp,f;
int sx,sy;
int d[1500][1500];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int bfs(){
  queue<P> que;
  for(int i = 0;i < h; i++)
    for(int j = 0;j < w; j++) d[i][j] = INF;

  que.push(P(sx,sy));
  d[sx][sy] = 0;
  hp = 1;

  while(que.size()){
    P p = que.front(); que.pop();

    f = 0;
    for(int i = 0;i < 4; i++){
      int nx = p.first + dx[i], ny = p.second + dy[i];

      int tt = d[p.first][p.second];
      if(0 <= nx && nx < h && 0 <= ny && ny < w && m[nx][ny] != 'X' && d[nx][ny] == INF){
	if(m[nx][ny] >= '1' && m[nx][ny] <= '9'){
	  int t;
	  if(m[nx][ny] == '1') t = 1;
	  else if(m[nx][ny] == '2') t = 2;
	  else if(m[nx][ny] == '3') t = 3;
	  else if(m[nx][ny] == '4') t = 4;
	  else if(m[nx][ny] == '5') t = 5;
	  else if(m[nx][ny] == '6') t = 6;
	  else if(m[nx][ny] == '7') t = 7;
	  else if(m[nx][ny] == '8') t = 8;
	  else if(m[nx][ny] == '9') t = 9;

	  if(t <= hp){
	    n--;
	    hp++;
	    m[nx][ny] = '.';
	    while(que.size()) que.pop();
	    for(int i = 0;i < h; i++)
	      for(int j = 0;j < w; j++) d[i][j] = INF;
	    f = 1;
	  }
	}
	que.push(P(nx,ny));
	d[nx][ny] = tt + 1;
      }
      if(n == 0) return d[nx][ny];
      if(f) break;
    }
  }
}

int main(void){
  cin >> h >> w >> n;
  for(int i = 0;i < h; i++){
    for(int j = 0;j < w; j++){
      cin >> m[i][j];
      if(m[i][j] == 'S'){
	sx = i, sy = j;
      }
    }
  }

  cout << bfs() << endl;
}


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

if c <= a <= b <= d:
    ans = b - a
elif a <= c <= b <= d:
    ans = b - c
elif c <= a <= d <= b:
    ans = d - a
elif a <= c <= d <= b:
    ans = d - c
else:
    ans = 0

print(ans)

Measured memory_bytes: 3060
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.Char
import Data.List

getVals::IO [Int]
getVals = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

main::IO()
main = do
    s:_ <- getVals
    print $ solver s

modnum::Int
modnum = 10^9 + 7

mSum::Int->Int->Int
mSum a b = mod (a+b) modnum

genPascal::[[Int]]
genPascal = [1]:[map (\ (a,b)-> mSum a b)(zip (0:prevStep)(prevStep++[0]))|prevStep<-genPascal]


solver::Int -> Int
solver s = foldl mSum 0 [genPascal !! (s-(3*i)+(i-1)) !! (i-1) | i<-[1.. div s 3]] 

Measured memory_bytes: 60928
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>
const int mxN=2e5;
 
int main () 
{
    int n,x,t;
    cin >> n >> x >> t;
    if(n%x==0)
        cout << n/x*t;
    else
        cout << (n/x+1)*t;
}

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

using namespace std;

const int MaxN = 3005;

int n, m;
string s, t;
int dp[MaxN][MaxN];
pair<int, int> Mark[MaxN][MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s >> t;
    n = s.size();
    m = t.size();
    s = " " + s;
    t = " " + t;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (s[i] == t[j])
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                Mark[i][j] = make_pair(i - 1, j - 1);
            }
            else
            {
                if (dp[i - 1][j] >= dp[i][j - 1])
                {
                    dp[i][j] = dp[i - 1][j];
                    Mark[i][j] = make_pair(i - 1, j);
                }
                else
                {
                    dp[i][j] = dp[i][j - 1];
                    Mark[i][j] = make_pair(i, j - 1);
                }
            }
        }
    }
    int x = n, y = m;
    string Res = "";
    while (x != 0 && y != 0)
    {
        if (s[x] == t[y])
        {
            Res.push_back(s[x]);
        }
        tie(x, y) = Mark[x][y];
    }
    reverse(Res.begin(), Res.end());
    cout << Res;
    return 0;
}

Measured memory_bytes: 109248
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  string S,T; cin>>S>>T;
  int ans = 0;
  REP(i,3) {
    if(S[i]==T[i]) ans++;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
 
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin) ;
        freopen("output.txt" , "w" , stdout) ;
    #endif
    set<string>a;
    int n;
    string x;
    cin>>n;
    while(n--)
    {
        cin>>x;
        a.insert(x);
    }
    cout<<a.size();
    return 0;
}

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

int main() {
    
    long long N;
    vector<long long> A;
    int count = 0;
    bool is_valid = true;
    long long sum = 1;
    
    cin >> N;
    
    for ( int i = 0; i < N; i++ ) {
        long long a;
        cin >> a;
        A.push_back( a );
    }
    
    sort( A.begin(), A.end() );
    
    
    count = ( N%2 ) ? 0 : 1;
    
    for ( int i = 0; i < N; i++ ) {
         
         if ( count != A[i] ) {
             is_valid = false;
             
             break;
         }
         
         if ( N%2 != i%2 ) { count +=2; }
         
         
    }
    
    
    if ( !is_valid ) {
        cout << 0 << endl;
        return 0;
    }
    
    for ( int i = 0; i < N/2; i++ ) {
        sum *= 2;
        sum %= (1000000000 + 7);
    }
    
    cout << sum << endl;
    
    return 0;
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(string s;cin>>s;){
		cout<<s.substr(0,s.size()-8)<<endl;
	}
}


Measured memory_bytes: 256
import java.util.*;
// warm-up
public class Main {
	// Making rookie mistakes.. Not an option
	static void solve() {
		Scanner sc = new Scanner(System.in);
		String[] a = {sc.next(),sc.next(),sc.next()};
		char ch = a[0].charAt(0); a[0]=a[0].substring(1);
		while (ch=='a'||ch=='b'||ch=='c') {
			switch(ch) {
				case 'a': ch=a[0].isEmpty() ? 'A' : a[0].charAt(0); if (ch!='A') a[0]=a[0].substring(1); break;
				case 'b': ch=a[1].isEmpty() ? 'B' : a[1].charAt(0); if (ch!='B') a[1]=a[1].substring(1); break;
				case 'c': ch=a[2].isEmpty() ? 'C' : a[2].charAt(0); if (ch!='C') a[2]=a[2].substring(1); break;
			}
		}
		System.out.println(ch);
		sc.close();
	}

	public static void main(String args[]) {
		solve();
	}

}


Measured memory_bytes: 35472
from collections import Counter
N = int(input())
a = list(map(str,input().split()))
a_set = list(set(a))
cnt = 0
c = Counter(a)
for i in a_set:
    if c[i] >= int(i):
        
        cnt +=  (c[i] - int(i))
    elif  c[i] < int(i):
        cnt +=  c[i]
print(cnt)


Measured memory_bytes: 70820
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  map<char, string> Ss;
  string Sa, Sb, Sc;
  cin >> Sa;
  Ss['a'] = Sa;
  cin >> Sb;
  Ss['b'] = Sb;
  cin >> Sc;
  Ss['c'] = Sc;

  char current_player = 'a';
  while (1) {
    if ((int)Ss[current_player].size() == 0) {
      cout << (char)toupper(current_player) << endl;
      return 0;
    }
    char new_player = Ss[current_player][0];
    Ss[current_player].erase(0, 1);
    current_player = new_player;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 9223372036854775807
using namespace std;
long long ans;
long long A;
long long B;
long long solve(long long arg_A, long long arg_B) {
  long retans;
  retans = (A-1) * (B -1);
  return retans;
}

int main(int arg, char* argv[]) {
  scanf("%d %d", &A, &B);
  ans = solve(A, B);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
import copy
n=copy.deepcopy(N)
D={}
for i in range(2,10**6+1):
    while N%i==0:
        if i not in D:
            D[i]=1
            N//=i
        else:
            D[i]+=1
            N//=i
if N!=1:
    D[N]=1
D=list(D.items())
#print(D)
ANS=[1]
for i in range(len(D)):
    ans=[]
    for j in ANS:
        for k in range(D[i][1]+1):
            ans.append(j*(D[i][0]**k))
    #print(ans)
    ANS=ans
#print(ANS)

cnt=10**12
for i in ANS:
    if (i+(n//i))-2<cnt:
        cnt=(i+(n//i))-2
print(cnt)


Measured memory_bytes: 3824
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

int main(){
  itn n,l; cin >> n >> l;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int it=-1;
  rep(i,n-1){
    if(a[i]+a[i+1]>=l){
      it=i;
    }
  }
  if(it==-1){
    cout << "Impossible" << endl;
    return 0;
  }
  cout << "Possible" << endl;
  rep(i,it) cout << i+1 << endl;
  for(int i=n-2;i>=it+1;i--) cout << i+1 << endl;
  cout << it+1 << endl;
}

Measured memory_bytes: 3784
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, A[100002], B[100001];
	scanf("%d", &N);
	for (i = 1; i <= N + 1; i++) scanf("%d", &(A[i]));
	for (i = 1; i <= N; i++) scanf("%d", &(B[i]));
	
	long long sum = 0;
	for (i = 1; i <= N; i++) {
		if (A[i] <= B[i]) {
			sum += A[i];
			B[i] -= A[i];
		} else {
			sum += B[i];
			B[i] = 0;
		}
		if (A[i+1] <= B[i]) {
			sum += A[i+1];
			A[i+1] = 0;
		} else {
			sum += B[i];
			A[i+1] -= B[i];
		}
	}
	
	printf("%lld\n", sum);
	fflush(stdout);
	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli x;
  while (cin >> x) {
    lli y = x % 11;
    lli z = (x / 11) * 2;
    if (0 < y) {
      ++z;
      y -= 6;
    }
    if (0 < y) {
      ++z;
      y -= 5;
    }
    cout << z << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    set<string> st;
    rep(i,n){
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 19288
import Data.Array.ST (STUArray, runSTUArray, newArray, readArray, writeArray)
import Data.Array.Unboxed
import Data.List
import Control.Monad.ST (ST,runST)
import Control.Monad
import Control.Applicative

type HouseFloorRoom = (Int,Int,Int)
type Apartment = UArray HouseFloorRoom Int
type STApartment s = ST s (STUArray s HouseFloorRoom Int)

solve :: [String] -> Apartment
solve lines =
    runSTUArray $ do
        arr <- newArray ((1,1,1),(4,3,10)) 0 :: STApartment s
        forM_ lines $ \line -> do
            let [b,f,r,v] = map read $ words line
            writeArray arr (b,f,r) =<< (+ v) <$> readArray arr (b,f,r) 
        return arr

main :: IO ()
main = do
    let sep = replicate 20 '#' ++ "\n"
    n <- readLn :: IO Int
    ap <- solve <$> replicateM n getLine
    let ((sh,sf,sr), (eh,ef,er)) = bounds ap
    putStr . intercalate sep $ 
        [unlines [concat [cell2str ap (h,f,r) | r<-[sr..er]] | f<-[sf..ef]] | h<-[sh..eh]]
    where
    cell2str arr idx = " " ++ (show $ arr!idx)

Measured memory_bytes: 4200
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(int argc, char *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c;
    cin >> a >> b >> c;
    int ans;
    if (a >= b && b >= c) {
        ans = a - c;
    }
    else if (a >= c && c >= b) {
        ans = a - b;
    }
    else if (b >= c && c >= a) {
        ans = b - a;
    }
    else if (b >= a && a >= c) {
        ans = b - c;
    }
    else if (c >= a && a >= b){
        ans = c - b;
    }
    else if (c >= b && b >= a){
        ans = c - a;
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long

typedef pair<int, int> pii;

void solve(int n)
{
    vector<int> pipe(n);
    vector<int> joint(n - 1);

    for (int i = 0; i < n; ++i) cin >> pipe[i];
    for (int i = 0; i < n - 1; ++i) cin >> joint[i];
    sort(joint.begin(), joint.end(), greater<int>());

    int sum = accumulate(pipe.begin(), pipe.end(), 0);
    int cnt = n;
    for (int i = 0; i < n - 1; ++i){
        if (sum * cnt < (sum + joint[i]) * (cnt - 1)){
            sum += joint[i];
            --cnt;
        }
    }

    cout << sum * cnt << endl;
}

signed main()
{
    int n;

    while (cin >> n, n) solve(n);

    return 0;
}

Measured memory_bytes: 3860