akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    string S, T;
    cin >> S >> T;
    int n = S.size();
    bool ok = true;

    map<char, char> ma, ima;

    rep(i, n) {
        char s = S[i], t = T[i];
        if (ma.count(s)) if (ma[s] != t) ok =false;
        if (ima.count(t)) if (ima[t] != s) ok = false;
        ma[s] = t; ima[t] = s;
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 776
n = int(input())
s = [input()[0] for _ in range(n)]

c = []
c.append(s.count("M"))
c.append(s.count("A"))
c.append(s.count("R"))
c.append(s.count("C"))
c.append(s.count("H"))
c_len = len(c)
ans = 0
for i in range(c_len):
    for j in range(i+1, c_len):
        for k in range(j+1, c_len):
            ans += c[i] * c[j] * c[k]

print(ans)


Measured memory_bytes: 3864
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication61
{
    class Program
    {
        static void Main(string[] args)
        {
            string h;
            int c = 0;
            while ((h=Console.ReadLine())!=null)
            {
                string a = h;
                if (a.Length == 1)
                    c++;
                else if (a.Length % 2 == 0)
                    for (int b = 0; b < a.Length / 2; b++)
                    {
                        if (a[b] != a[a.Length - 1 - b])
                            break;
                        if(b==a.Length/2-1)
                        c++;
                    }
                    else if(a.Length%2==1) 
                    for(int d =0;d<(a.Length-1)/2;d++)
                    {
                        if(a[d]!=a[a.Length-1-d])
                            break;
                        if(d==(a.Length-1)/2-1)
                        c++;
                    }
                }
            Console.WriteLine(c);
            }
        }
    }

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

typedef long long LL;
#define MAXN 100003
#define MOD 761238923

char S[30];

int c[26];

int main() {
#ifdef OJ
    //freopen("input.txt", "rt", stdin);
    //    freopen("output.txt", "wt", stdout);
#endif

    scanf("%s", S);

    int N = strlen(S);
    for (int i = 0; i < N; i++) {
        c[S[i] - 'a']++;
    }

    if (N < 26) {
        int i;
        for (i = 0; i < 26 && c[i]; i++);

        S[N] = 'a' + i;
        S[N+1] = 0;
    } else {
        for (int i = 0; i < 26; i++)
            c[i] = 0;

        int i;
        c[S[N-1] - 'a'] = 1;
        for (i = N-2; i >= 0; i--) {
            int j;
            for (j = S[i]-'a'+1; j < 26; j++) 
                if (c[j])
                    break;

            if (j != 26) {
                S[i] = 'a' + j;
                S[i+1] = 0;
                break;
            } 

            c[S[i]-'a'] = 1;
        }

        if (i < 0) 
            return 0*printf("-1\n");

    }

    printf("%s\n", S);
    return 0;
}


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

#define vint vector<int>
#define vvint vector<vint>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}

void Main(){
    int s , w;
    cin >> s >> w;
    if(w >= s){
        ct("unsafe");
    }else{
        ct("safe");
    }
}

int main() {
    Main();
}


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

int n, ans;
string a, b, c, d="...";
int main() {
	int i;
	cin >> n >> a >> b >> c;
	for(i=0; a[i]; i++) {
		d[0] = a[i];
		d[1] = b[i];
		d[2] = c[i];
		sort(d.begin(), d.end());
		if(d[0]!=d[1] && d[1]!=d[2]) ans += 2;
		else if(d[0]==d[1] && d[1]!=d[2]) ans++;
		else if(d[0]!=d[1] && d[1]==d[2]) ans++;
	}
	cout << ans;
	return 0;
}

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

int p,q,a,n;

int dfs(int i,int x,int y,int m){
	int c=p*y-x*q;
	if(m==n||!c)return !c;
	if(c<0)return 0;
	int res=0;
	for(;i*y<=a;i++)res+=dfs(i,x*i+y,y*i,m+1);
	return res;
}
int main(){
	while(cin>>p>>q>>a>>n,p|q|a|n){
		cout<<dfs(1,0,1,0)<<endl;
	}
	return 0;
}

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

const int MAXN = 100000 + 10;

int x, y, z;

struct T {
    int a, b, c;
};


vector<T> v;

struct cmpAC {
    bool operator()(const T &a, const T &b) {
        return a.a - a.c > b.a - b.c;
    }
};
struct cmpBC {
    bool operator()(const T &a, const T &b) {
        return a.b - a.c > b.b - b.c;
    }
};

int le[MAXN], ri[MAXN];

int32_t main() {
    ios_base::sync_with_stdio(0);

    cin >> x >> y >> z;
    v.resize(x+y+z);
    for (int i = 0; i < x+y+z; i++) {
        cin >> v[i].a >> v[i].b >> v[i].c;
    }

    sort(begin(v), end(v), [](T a, T b) { return a.a - a.b > b.a - b.b; });

    multiset<T, cmpAC> la, lc;
    multiset<T, cmpBC> rb, rc;
    
    int res = 0;

    for (int i = 0; i < x; i++) {
        la.insert(v[i]);
        res += v[i].a;
    }

    le[x] = res;
    for (int i = x; i < x+z; i++) {
        auto p = v[i];
        auto q = *(--la.end());
        
        if (cmpAC()(p, q)) {
            la.erase(--la.end());
            la.insert(p);

            res += p.a + q.c - q.a;
        } else {
            res += p.c;
        }

        le[i + 1] = res;
    }


    res = 0;

    for (int i = x+z; i < x+y+z; i++) {
        rb.insert(v[i]);
        res += v[i].b;
    }

    ri[x + z] = res;

    for (int i = x + z - 1; i >= x; i--) {
        auto p = v[i];
        auto q = *(--rb.end());

        if (cmpBC()(p, q)) {
            rb.erase(--rb.end());
            rb.insert(p);

            res += p.b + q.c - q.b;
        } else {
            res += p.c;
        }

        ri[i] = res;
    }


    int b = -1;
    for (int i = x; i <= x+z; i++) {
        b = max(le[i] + ri[i], b);
    }

    cout << b << "\n";

    


    return 0;
}


Measured memory_bytes: 8704
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <atcoder/all>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll T;

int main() {
  std::cin >> T;

  rep( t, T ) {
    ll N, M, A, B;
    std::cin >> N >> M >> A >> B;

    std::cout << atcoder::floor_sum(N,M,A,B) << endl;
  }

  return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

int main(){
  // startupcpp();
  // int codeforces;cin>>codeforces;while(codeforces--){
  ll i,j,N,sum=0;
  cin>>N;
  rep(i,N+1){
    sum+=i;
    if(sum>=N)break;
  }
  rep1(j,i+1){
    if(j==sum-N)continue;
    print(j);
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import numpy as np


def main():
    N, T = map(int, input().split())
    CT = np.array([list(map(int, input().split())) for _ in range(N)])
    roots = CT[(CT[:, -1] <= T)]
    if roots.size == 0:
        print('TLE')
    else:
        print(np.min(roots, axis=0)[0])


if __name__ == "__main__":
    main()


Measured memory_bytes: 12276
#include<iostream>
using namespace std;
int n;
int v[20],c[20],s[20];
int main(){
    cin>>n;
    int sum=0;
    for(int i=0;i<n;i++) cin>>v[i];
    for(int i=0;i<n;i++){
        cin>>c[i];
        s[i]=v[i]-c[i];
    }
    for(int i=0;i<n;i++){
        if(s[i]>0)
            sum+=s[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdint>
#include <cmath>
#include <vector>
#include <utility>
#include <limits>

using namespace std;

int main() {
  int H, N;
  cin >> H >> N;
  
  vector<pair<int, int>> magics;
  magics.reserve(N + 1);
  magics.push_back(make_pair(0, 0));
  for (size_t n = 0; n < N; ++n) {
    int A, B;
    cin >> A >> B;
    magics.push_back(make_pair(A, B));
  }
  sort(magics.begin(), magics.end(), [] (const pair<int, int>& lhs, const pair<int, int>& rhs) {
    return lhs.first < rhs.first;
  });
  vector<vector<int>> dp(H + 1, vector<int>(N + 1, numeric_limits<int>::max()));
  for (int h = 1; h <= H; ++h) {
    for (int n = 1; n <= N; ++n) {
      int m = magics[n].second;
      int a = magics[n].first;
      if (h - a >= 0) {
        int cnt = static_cast<int>(ceil(h / static_cast<float>(a)));
        m = magics[n].second * cnt;
        if (dp[h - a][n] != numeric_limits<int>::max()) {
          m = min(m, dp[h - a][n] + magics[n].second);
        }
      }
      if (n != 1) {
        m = min(m, dp[h][n - 1]);
      }
      dp[h][n] = m;
    }
  }
  cout << dp[H][N] << endl;
  
  return 0;
}


Measured memory_bytes: 42836
s = input()
a = {}
b = []
for i in range(len(s)):
    if s[i] in a.keys():
        a[s[i]] += 1
    else:
        a[s[i]] = 1
for i in a.keys():
    b.append(a[i])
if len(a) == 2 and b == [2,2]:
    print("Yes")
else:
    print("No")


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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    long long ans = 1000;
    for(int i = 0; i < n - 1; i++) {
        if(a[i] < a[i+1]) {
            long long rest = ans % a[i];
            ans /= a[i];
            ans *= a[i+1];
            ans += rest;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define chmin(a, b) a=min(a, b)
#define chmax(a, b) a=max(a, b)
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, m; cin>>n>>m;
    bool isprime=true;
    for(int i=2; i*i<=m; i++){
        if(m%i==0) isprime=false;
    }
    if(isprime){
        cout << 1 << endl;
        return 0;
    }

    for(int i=n; i<=m; i++){
        if(m%i==0){
            cout << m/i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
s = input().rstrip()
s_rev = s[::-1]
mina = -1
maxz = -1
for i in range(len(s)):
    if s[i] == "A":
        mina = i
        break
for j in range(len(s)):
    if s[j] == "Z":
        maxz = max(maxz, j)
print(maxz - mina + 1)

Measured memory_bytes: 3512
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

s = sum(a)
for i,v in enumerate(b):
    if a[i]>v:
        a[i] -= v
    elif a[i]+a[i+1]>v:
        a[i+1] -= (v-a[i])
        a[i]   = 0
    else:
        a[i]=a[i+1]=0
print(s-sum(a))
        

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

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int type;
    cin >> type;
    
    if(type == 1)
        cout << "Hello World\n";
    else
    {
        int a, b;
        cin >> a >> b;
        
        cout << a + b << "\n";
    }
    
    return 0;
}

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

#define REP(i, n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<b; ++i)

#define INF (1<<24)

int main()
{
	int C=0, N;
	while(scanf("%d", &N), N)
	{
		bool flag=false;
		int coins[50], dp[52000];
		REP(i,N) scanf("%d", &coins[i]);
		
		REP(i,6000) dp[i]=INF;
		dp[0]=0;
		
		REP(i,N) REP(j,5000)
			if(dp[j] != INF) dp[j+coins[i]] = min(dp[j+coins[i]], dp[j]+1);
			
		REP(i,5000)
		{
			int cnt=0,curr=i;
			for(int i=N-1; i>=0; i--)
			{
				if(curr < coins[i]) continue;
				cnt+=curr/coins[i];
				curr-=coins[i]*(curr/coins[i]);
			}
			
			if(cnt!=dp[i]) flag=true;
			if(flag) break;
		}
		
		printf("Case #%d: ", ++C);
		if(coins[0]!=1) puts("Cannot pay some amount");
		else if(flag) puts("Cannot use greedy algorithm");
		else puts("OK");
	}
}

Measured memory_bytes: 792
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    string s, ans1, ans2;
    int longest = 0, many = 0;
    map<string, int> time;
    while(cin >> s){
        if(longest < s.size()){
            longest = s.size();
            ans2 = s;
        }
        time[s]++;
        if(many < time[s]){
            many = time[s];
            ans1 = s;
        }
    }
    rep(i, ans1.size()){
        cout << ans1[i];
    }
    cout << ' ';
    rep(i, ans2.size()){
        cout << ans2[i];
    }
    cout << endl;
}

Measured memory_bytes: 1188
N = int(input())
A = [int(v) for v in input().split()]

MAX = int(1e18)
tmp = 0 if 0 in A else 1
flag = False

for a in A:
    tmp *= a
    if tmp > MAX:
        flag = True
        break

if flag:
    print(-1)
else:
    print(tmp)


Measured memory_bytes: 21648
var n,k,s,i,b:Longint;a:array[1..50]of Longint;
begin
	read(n,k);
	for i:=1 to n do begin
		read(b);
		inc(a[b]);
	end;
	for i:=50 downto 1 do begin
		while (a[i]>0)and(k>0)do begin
			dec(a[i]);
			dec(k);
			inc(s,i);
		end;
	end;
	write(s);
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
signed main(){
	int a,b,c,d,e,f,g,h,i;
	cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
	if(a+e+i==a+h+f&&a+h+f==d+b+i&&d+b+i==d+h+c&&d+h+c==g+b+f&&g+b+f==g+e+c)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;
    if(A==1 && B==1) A = 14, B=14;
    else if(A==1) A = 14;
    else if(B==1) B = 14;
    if(A>B)
        cout << "Alice" << endl;
    else if(B>A)
        cout << "Bob" << endl;
    else 
        cout << "Draw" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool f(int x) {
  int keta =0;
  while(x){
    keta++;
    x/=10;
  }
  return keta%2 == 1;
}
int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i=0;i<=n;i++) {
    if(f(i)){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  long int n;
  long int m;
  long int sum=0;
  long int ans;

  scanf("%ld %ld", &n, &m);

  long int a[m];

  for (int i = 0; i < m; i++) {
    scanf("%ld", &a[i]);
  sum += a[i];
  }

  ans = (sum <= n) ? n - sum : -1;

  printf("%ld", ans);

  return 0;
}


Measured memory_bytes: 1800
N,K = map(int,input().split())
*A, = map(int,input().split())

def check(n):
    cnt = 0
    for a in A:
        cnt += (a-1)//n
    return cnt <= K

ng = 0
ok = 10**9
while abs(ng-ok)>1:
    i = (ng + ok)//2
    if check(i):
        ok = i
    else:
        ng = i

print(ok)

Measured memory_bytes: 30796
N,M = map(int,input().split())
k = map(int,input().split())
H = list(k)
di = {i+1:l for i,l in enumerate(H)}
counter=0
for i in range(M):
    a,b = map(int,input().split())
    if H[a-1]>H[b-1]:
        di[b] = "0"
    elif H[a-1]<H[b-1]:
        di[a] = "0"
    else:
        di[a] = "0"
        di[b] = "0"

for i in range(1,N+1):
    if not di[i]=="0":
        counter += 1
print(counter)

Measured memory_bytes: 24564
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int a, b, c, d, n, judg=0, sub=0, Ans=0, i, j;
int A[100];
int main()
{
	cin >> a >> b;
	cout << a - b + 1<<endl;
  return 0;
}

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

typedef long long ll;

int main() {
	int D; cin >> D;
	string s ="Christmas";

	if(D==25) cout << s << endl;
	else if(D==24) cout << s + " Eve" << endl;
	else if(D==23) cout << s + " Eve Eve" << endl;
	else if(D==22) cout << s + " Eve Eve Eve" << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n,k;
	cin >> n >> k;
	ll a[n + 1];
	for(ll i = 0;i < n;i++){
		cin >> a[i];
	}
	a[n] = LLONG_MAX;
	sort(a,a + n);
	ll b[k + 2] = {0};
	ll itr = 1;
	b[a[0]] = 1;
	for(ll i = a[0] + 1;i <= k;i++){
		ll flag = 1;
		for(ll j = 0;j < n && flag;j++){
			if(i < a[j]) break;
			if(b[i - a[j]] == 0){
				b[i] = 1;
				flag = 0;
			}
		}
	}
	if(1 - b[k]){
		cout << "Second\n";
	}
	else{
		cout << "First\n";
	}
	return 0;
}

Measured memory_bytes: 1024
#abc163 managementn
n = int(input())
ln = map(int,input().split())
output = [0]*n # output[i-1] は社員番号iの直属の部下の数　1<= i <=n
for i in ln:
    output[i-1] += 1
for  i in output:
    print(i)

Measured memory_bytes: 24524
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> P;

const double eps = 1e-5;
const int MAXN = 333;
int N;
P ps[MAXN];

int calc(P c) {
  int res = 0;
  for(int i = 0; i < N; ++i) {
    double d = norm(c - ps[i]);
    if(d < 1.0 + eps) ++res;
  }
  return res;
}

int main() {
  for(; cin >> N && N; ) {
    for(int i = 0; i < N; ++i) {
      cin >> ps[i].real() >> ps[i].imag();
    }
    int res = 1;
    for(int i = 0; i < N; ++i) {
      for(int j = i+1; j < N; ++j) {
        P base = ps[j] - ps[i];
        P m = ps[i] + base / 2.0;
        double d = abs(base);
        double a = sqrt(1.0 - d * d / 4.0);
        P base2(-base.imag(), base.real());
        base2 = base2 / abs(base2) * a;
        res = max(res, max(calc(m + base2), calc(m - base2)));
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define mkpr(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()

typedef long long int ll;

ll general,total;
//ll chk[55];
//ll num[55];
//ll num2[55];
ll num[ten52];
//ll num2[ten5];
//char cmap[10][10];
//priority_queue<ll> pqll;   //decrease
//priority_queue<double> pqd;
//stack<int> stk;
//vector<pair<ll,ll>> vpll;
//vector<pair<double,double>> vpdd;
//vector<ll> vll[ten52];
//vector<double> vd;
//deque<ll> deq[55];
//list<int> li;
//set<int> sint;
//set<ll> sll;
//map<ll,ll> mp;

/*ll cmp(pair<ll,ll> a,pair<ll,ll> b)
{
    return a.first<b.first;
    //arrising
}*/

ll add(ll n,ll len)
{
    ll sum=num[len-1];
    ll time=1;
    for(int i=len-2;i>=0;i--)
    {
        if(n&1==1)
            time=1;
        else
            time*=10;
        sum+=time*num[i];
        n=n>>1;
    }
    return sum;
}

int main()
{
    double ans=0.0,half,d,d1,d2;
    //float f,g,h;
    string s,s1;
    //char now,pre,c1,c2;
    long long int sum,sum2,n1,n2,n3;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    sum=sum2=n1=n2=n3=0;
    a=a1=a2=a3=a4=a5=a6=0;
    cin>>s;
    if(s.size()==1)
    {
        cout<<s;
        return 0;
    }
    for(i=0;i<s.size();i++) num[i]=s[i]-'0';
    k=pow(2,s.size()-1);
    for(i=0;i<k;i++) sum+=add(i,s.size());
    cout<<sum;
    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 ll long long int
bool han(int a){
  if(1<=a&&a<=12)
    return true;
  else
    return false;
}

int main(){
  int S;
  cin>>S;
  int A,B;
  A=S/100;
  B=S-A*100;
  if(han(A)&&han(B))
    cout<<"AMBIGUOUS"<<endl;
  else if(A==0&&!han(B))
    cout<<"NA"<<endl;
  else if(B==0&&!han(A))
    cout<<"NA"<<endl;
  else if(!han(A)&&!han(B))
    cout<<"NA"<<endl;
  else if(han(A))
    cout<<"MMYY"<<endl;
  else
    cout<<"YYMM"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vll vector<ll>
#define pb push_back
#define x first
#define y second


int main()
{
	IOS;
  ll N,W,i,j,sum=0,ans=0;
	cin>>N>>W;
	ll v[N+1],w[N+1];
	for(i=1;i<=N;i++)
		{
			cin>>w[i]>>v[i];
			sum+=v[i];
		}
	ll dp[N+1][sum+1];
	for(j=1;j<=sum;j++)
		dp[0][j]=100000000009;
	dp[0][0]=0;
	for(i=1;i<=N;i++)
	{
		for(j=0;j<v[i];j++)
			dp[i][j]=dp[i-1][j];
		for(j=v[i];j<=sum;j++)
			dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
	}
	for(i=1;i<=N;i++)
		for(j=1;j<=sum;j++)
			if(dp[i][j]<=W)
			ans=max(ans,j);
	cout<<ans;
}

Measured memory_bytes: 79104
#include <stdio.h>
int main(void){
	char a[16];
	int i,cnt=0;
	
	scanf("%s",a);
	for(i=0;a[i]!=0;i++){
		if(a[i] == 'x') cnt = cnt+1;
	}
	if(cnt>=8) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mincost(int *arr,int n,int k,int* memo){
	if(n<=1) return 0;
	if(n==2) return abs(arr[0]-arr[1]);
	if(memo[n]!=-1) return memo[n]; 
    int ans=INT_MAX;
    for(int i=1;i<=k&&i<n;i++){
    	int ans1=abs(arr[0]-arr[i])+mincost(arr+i,n-i,k,memo);
    	if(ans1<ans) ans=ans1;
    }
	memo[n]=ans;
	return ans;
}

int main(){
	int n;
	cin>>n;
	int k;
	cin>>k;
	int * arr=new int[n];
	for(int i=0;i<n;i++) cin>>arr[i];
	int * memo=new int [n+1];
	for(int i=0;i<=n;i++) memo[i]=-1;
	int ans=mincost(arr,n,k,memo);
	cout<<ans<<endl;
return 0;
}


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

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

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

    if(n == 0){
        if(a[0] == 1) cout << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }

    if(a[0] != 0){
        cout << -1 << endl;
        return 0;
    }

    vector<long long int> sa(n+1);
    for(int i=1; i<=n; i++){
        sa[i] = sa[i-1] + a[i];
    }

    long long int ans = 1;
    vector<long long int> b(n+1);
    b[0] = 1;
    for(int i=1; i<=n; i++){
        b[i] = min(2 * b[i-1] - a[i], sa[n] - sa[i]);
        if(b[i] < 0){
            cout << -1 << endl;
            return 0;
        }
        ans += a[i] + b[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5616
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007

#+++++

def main():
	#a = int(input())
	#b , c = tin()
	s = input()
	if s[0] == '>':
		s = '<' + s
		
	if s[-1] == '<':
		s = s + '>_'
	else:
		s = s + '_'
		
	dd = []
	pre = '<'
	count = [1,0]
	for c in s[1:]:
		if c == '<' and pre == '<':
			count[0] += 1
		elif c == '>' and pre == '>':
			count[1] += 1
		elif c == '>' and pre == '<':
			pre = '>'
			count[1] = 1
		elif c == '<' and pre == '>':
			pre = '<'
			dd.append(count)
			count=[1,0]
		else:
			dd.append(count)
	
	ret_sum = 0
	for l, r in dd:
		ret_sum += (r*(r+1)//2) + (l*(l+1)//2) - min(r,l)
	print(ret_sum)
		
		
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 16688
#include<bits/stdc++.h>
using namespace std;
 
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}


int main()
{
    fast();
    int a , b ; 
    cin>>a>>b;
    cout<<max( a+b,max(a-b , a*b) ) ;
	return 0 ;
}

Measured memory_bytes: 256
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//

#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const int MXN = 1e5 + 200;
const long long MNN = 5e3 + 100;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong m, k;

int main () {
    ios;
    cin >> m >> k;
    llong xr = 0;
    if(k == 0){
        for(int i = 0; i < (1 << m); i++){
            cout << i << ' ' << i << ' ';
        }
        return 0;
    }
    if(k > (1 << m)){
        cout << -1;
        return 0;
    }
    for(int i = 0; i < (1 << m); i++){
        if(k == i) continue;
        xr ^= i;
    }
    if(xr != k) return cout << -1, 0;
    for(int i = 0; i < (1 << m); i++){
        if(k == i) continue;
        cout << i << ' ';
    }
    cout << k << ' ';
    for(int i = (1 << m) - 1; i >= 0; i--){
        if(k == i) continue;
        cout << i << ' ';
    }
    cout << k;
    return 0;
}


Measured memory_bytes: 1792
function main(arg) {
    
    let s = arg.split("\n")[0]
    let t = arg.split("\n")[1]
    //console.log(s)
    
    
    let ans = 10000
    for(let i=0; i < s.length; i++) {
        let tmp=0, tmpMax=0
        for(let j=0; j < t.length; j++) {
            if(i+j >= s.length) {
                tmpMax=1000
                break
            }
            if(s[i+j] != t[j]) {
                tmp++
            }
            tmpMax=Math.max(tmp, tmpMax)
        }
        //console.log(tmpMax)
        ans=Math.min(ans, tmpMax)
    }
    //if(ans==10000)ans = 0
    console.log(ans)
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 32524
import numpy as np
import sys
read=sys.stdin.read

h,n,*ab=map(int,read().split())
a=np.array(ab[::2])
b=np.array(ab[1::2])

magic=np.zeros(h+1,dtype=np.int64)
for i in range(1,1+h):
  magic[i]=np.min(magic[np.maximum(i-a, 0)]+b)
print(magic[h])

Measured memory_bytes: 12516
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
template<typename _Ty> void print(vector<_Ty>& v, char delim = ' ') { cout << v[0]; for (uint i = 1; i < v.size(); i++) cout << delim << v[i]; cout << endl; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int bubbleSort(vector<int>& A) {
	int cnt = 0;
	int N = A.size();

	bool flag = true;
	while (flag) {
		flag = false;
		for (int j = N - 1; j >= 1; j--) {
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				cnt++;
				flag = true;
			}
		}
	}

	return cnt;
}

int main()
{
	//clock_t start, end;
	//start = clock();

	int N;
	cin >> N;
	vector<int> A(N);
	cin >> A;

	int cnt = bubbleSort(A);
	print(A);
	cout << cnt << endl;

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



Measured memory_bytes: 3108
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> mato;
vector<int> a;

int main(){
	int n,m;
	int self;
	while(scanf("%d %d",&n,&m) && n && m){
		mato.clear();
		a.clear();
		
		for(int i=0;i<n;i++){
			scanf("%d",&self);
			mato.push_back(self);
		}
		mato.push_back(0);
		sort(mato.begin(),mato.end());
		mato.erase(unique(mato.begin(),mato.end()),mato.end());
		int size = mato.size();
		for(int i=0;i<size;i++){
			for(int j=0;j<size;j++){
				a.push_back(mato[i] + mato[j]);
			}
		}
		sort(a.begin(),a.end());
		a.erase(unique(a.begin(),a.end()),a.end());
		int max = 0;
		size = a.size();
		int s,ss;
		for(int i=0;i<size;i++){
			s = m - a[i];
			if(s > 0){
				ss = *(lower_bound(a.begin(),a.end(),s) - 1);
				//printf("find:%d -> %d\n",s,ss);
				if(a[i] + ss > max){ max = a[i] + ss; }
			}
		}
		printf("%d\n",max);
	}
}

Measured memory_bytes: 4860
N,M=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
x2=[]
#print(x)
for i in range(M-1):
    x2.append(x[i+1]-x[i])
x2.sort()
s=0
#print(x2)
for i in range(len(x2)-N+1):
    s+=x2[i]
print(s)

Measured memory_bytes: 13968
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc =  new Scanner(System.in);
		//money:お金
		long money = 1000;
		//stock:株
		long stock = 0;
		//N:期間
		int n = Integer.parseInt(sc.next());
		//各日の株予想
		long[] longArr = new long[n];
		for (int i=0; i<n; i++) {
			longArr[i] = Integer.parseInt(sc.next());
		}
		//初回売り買いチェック
		if (longArr[0] < longArr[1]) {
			stock = money / longArr[0];
			money = money % longArr[0];
		}
		
		for (int i=1; i<n-1; i++) {
			//case : 株を買う->底値の時
			if(stock == 0 && longArr[i] <= longArr[i-1]  && longArr[i] < longArr[i+1] ) {
				stock = money / longArr[i];
				money = money % longArr[i];
			//case : 株を売る->天井の時
			} else if (stock != 0 && longArr[i-1] < longArr[i]  && longArr[i+1] <= longArr[i] ) {
				money += longArr[i]*stock;
				stock = 0;
			}
		}
		
		//最終的に株持ってたら売る
		if (stock != 0) {
			money += longArr[n-1]*stock;
		}
		System.out.println(money);
	}
}


Measured memory_bytes: 35732
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

struct BIT //0-indexed
{
	vector<int> node;
	int mn;

	BIT(int mn)
	{
		this->mn = mn;
		node.resize(mn + 1, 0);
	}

	void add(int i, int x)
	{
		i++;
		while (i <= mn)
		{
			node[i] += x;
			i += (i&-i);
		}
	}

	int sum(int i)
	{
		i++;
		int res = 0;
		while (i > 0)
		{
			res += node[i];
			i -= (i&-i);
		}
		return res;
	}

	//k:0-indexed
	int get(long long k) {
		++k;
		int res = 0;
		int N = 1; while (N < (int)node.size()) N *= 2;

		for (int i = N / 2; i > 0; i /= 2) {
			if (res + i < (int)node.size() && node[res + i] < k) {
				k = k - node[res + i];
				res = res + i;
			}
		}
		return res;
	}
};

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, Q;
	cin >> N >> Q;

	BIT bit(N + 5);

	int t, idx, x;
	rep(i, 0, N)
	{
		cin >> x;
		bit.add(i, x);
	}

	rep(i, 0, Q)
	{
		cin >> t >> idx >> x;
		if (t == 0)
		{
			bit.add(idx, x);
		}
		else
		{
			cout << bit.sum(x-1) - (idx == 0 ? 0LL : bit.sum(idx - 1)) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 8240
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <deque>
using namespace std;
int n, m, i, j, k, t, x;
int main(){
	cin>>x>>t;
	cout<<x-min(x, t);
	return 0;
}


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

using namespace std;

const int K = 1e4 + 10;
const int D = 110;
const int mod = 1e9 + 7;

int dp[K][D];
int d;
string str;

int f(int x, int s) {
  if (x < 0) return s % d == 0 ? 1 : 0;
  int res = 0;
  for (int i = 0; i < str[x] - '0'; i++)
    res = (res + dp[x][(((-s - i) % d) + d) % d]) % mod;
  res = (res + f(x - 1, s + str[x] - '0')) % mod;
  return res;
}

int main() {
  cin >> str >> d;
  reverse(str.begin(), str.end());
  dp[0][0] = 1;
  for (int i = 1; i < K; i++)
    for (int j = 0; j < d; j++)
      for (int digit = 0; digit < 10; digit++)
        dp[i][j] = (dp[i][j] + dp[i - 1][((j - digit + d) % d + d) % d]) % mod;

  cout << (mod - 1 + f(str.size() - 1, 0)) % mod << endl;

  return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N,K;
int h[110000];
signed main() {
    cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>h[i];
    }
    sort(h,h+N);
    int ans=1145141919;
    for(int i=0;i<N-K+1;i++){
        ans=min(ans,h[i+K-1]-h[i]);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

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

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  ll a, b, c, k; cin >> a >> b >> c >> k;
  ll ans = 0;
  ans += min(a, k);
  k -= a;
  if (k > 0) k -= b;
  if (k > 0) ans -= k;
  cout << ans;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
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;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;

auto divisor_count = [&](int c) {
    int res = 0;
    for( int i = 1 ; i * i <= c ; i++ ) {
        if(c % i == 0) res+= 2;
        if(i * i == c) res--;
    }
    return res;
};

int cnt = 0;
rrep(n,N) {
    if(n % 2 == 1 && divisor_count(n) == 8) cnt++;
}

cout << cnt << endl;

return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> mp(h + 2, vector<char>(w + 2, '#'));

    for(int i = 1; i <= h; i++)for(int j = 1; j <= w; j++)cin >> mp[i][j];

    for(int i = 0; i <= h + 1; i++){
        for(int j = 0; j <= w + 1; j++){
            cout << mp[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

mean = sum(A) / N
# print(mean)
err = abs(A[0]-mean)
ans = 0
for i, a in enumerate(A):
    # print(i, err)
    if abs(a - mean) < err:
        # print(i, err)
        err = abs(a - mean)
        ans = i

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];

  int cnt = 0;
  rep(i,n){
    if(h[i]>=k) cnt++;
  }

  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)



int main(){
    ll N;
    cin >> N;
    if(N == 1){
        cout << "Hello World"<< endl;
    }
    else{
        ll A, B;
        cin >> A >> B;
        cout << A+B << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
a, b = map(int, input().split())
s = input()
if len(s) != a+b+1:
    print('No')
    sys.exit()

def check_hi(index,str):
    tmp = []
    for i,st in enumerate(str):
        if st == '-':
            tmp.append(i)
    if len(tmp)==1 and tmp[0]==index:
        return True
    else:
        return False

def check_int(i):
    if i == '-' or int(i) in [0,1,2,3,4,5,6,7,8,9]:
        return True
    else:
        return False

if check_hi(a,s) == False:
    print('No')
    sys.exit()

for si in s:
    if check_int(si) == False:
        print('No')
        sys.exit()
else:
    print('Yes')

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


int main()
{
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n)
    cin >> d[i];
  sort(d.begin(), d.end());
  cout << d[n/2] - d[n/2-1] << endl;
  return 0;
}

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

int h,b[10][5],a,e;

int main(){
	while(scanf("%d",&h),h){
		a=0;
		memset(b,0,sizeof(b));
		rep(i,h)rep(j,5)scanf("%d",b[i]+j);
		e=0;
		while(!e){
			e=1;
			for(int i=h-1;i>=0;i--)rep(j,3){
				int k=j;
				if(b[i][j]){
					while(k+1<5&&b[i][j]==b[i][k+1])k++;
					if(k-j>=2){
						a+=(k-j+1)*b[i][j];
						for(int v=j;v<=k;v++)b[i][v]=0;
					}
				}
			}
			for(int i=h-1;i>=0;i--)rep(j,5)if(!b[i][j])for(int k=i-1;k>=0;k--)if(b[k][j]){
				b[i][j]=b[k][j];b[k][j]=0;e=0;break;
			}
		}
		printf("%d\n",a);
	}
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long double ld;
typedef long long ll;
const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    string s; cin >> s;
    for(int i = 0; i < 3; i++){
        if(s[i] == '1') s[i] = '9';
        else s[i] = '1';
    }
    cout << s << endl;


    return 0;
}


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

using namespace std;

int main(void){
  string str;
  int n;
  int i=0;
  int ocnt=0, bcnt=0;
  int score=0;
  cin >> n;
  while(i < n){
	cin >> str;
	if(str == "OUT"){
	  ocnt++;
	}else if(str == "HIT"){
	  if(bcnt < 3){
		bcnt++;
	  }else{
		score++;
	  }
	}else if(str == "HOMERUN"){
	  score += bcnt+1;
	  bcnt = 0;
	}
	if(ocnt == 3){
	  cout << score << endl;
	  ocnt = 0;
	  bcnt = 0;
	  score = 0;
	  i++;
	}
  }
}

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

using namespace std;

int main(){
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    int ans = 0;
    for (int i=0;i<n;i++){
        int tmp_sum=c;
        for (int j=0;j<m;j++){
            int a;
            cin >> a;
            tmp_sum += (a*b[j]);
        }
        if (tmp_sum > 0) {
            ans += 1;
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int x,y,a,b,c;
  cin >> x>> y >> a >> b >> c;
  vl p(a),q(b),r(c);
  rep(i,a){
    cin >> p[i];
  }
  rep(i,b){
    cin >> q[i];
  }
  rep(i,c){
    cin >> r[i];
  }
  sort(rng(p),greater<ll>());
  sort(rng(q),greater<ll>());
  sort(rng(r),greater<ll>());
  vector<ll> l;
  rep(i,x){
    l.push_back(p[i]);
  }
  rep(i,y){
    l.push_back(q[i]);
  }
  sort(rng(l));
  int cnt = 0;
  ll ans = 0;
  for(auto e: l){
    if(e < r[cnt]){
      ans+= r[cnt];
      cnt++;
    }else{
      ans+=e;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4724