akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	int n;
	cin>>n;
	vector<pair<int,int>>a(n);
	cin>>a;
	int mn=1e9+100,mx=0,mn2=1e9+100,mx2=0;
	for(auto &i:a){
		if(i.F>i.S){
			swap(i.F,i.S);
		}
		mn=min(mn,i.F);
		mx=max(mx,i.F);
		mn2=min(mn2,i.S);
		mx2=max(mx2,i.S);
	}
	ll ans=(mx2-mn2)*1ll*(mx-mn);
	ll len=max(mx2,mx)-min(mn2,mn);
	int mn3=1e9+100,mx3=0;
	int absmn=min(mn,mn2),absmx=max(mx,mx2);
	for(auto i:a){
		if(i.S==absmx){
			mn3=min(mn3,i.F);
			mx3=max(mx3,i.F);
		}
		else{
			mn3=min(mn3,i.S);
			mx3=max(mx3,i.S);
		}		
	}
	ans=min(ans,(mx3-mn3)*1ll*len);
	mn3=1e9+100,mx3=0;
	for(auto i:a){
		if(i.F==absmn){
			mn3=min(mn3,i.S);
			mx3=max(mx3,i.S);
		}
		else{
			mn3=min(mn3,i.F);
			mx3=max(mx3,i.F);
		}		
	}
	ans=min(ans,(mx3-mn3)*1ll*len);
	mn3=1e9+100,mx3=0;
	for(auto i:a){
		if(i.F==absmn){
			mn3=min(mn3,i.S);
			mx3=max(mx3,i.S);
		}
		else if(i.S==absmx){
			mn3=min(mn3,i.F);
			mx3=max(mx3,i.F);
		}
	}
	for(auto i:a){
		if(i.F==absmn||i.S==absmx){
			continue;
		}
		int check1=mn3,check2=mx3;
		check1=min(check1,i.F);
		check2=max(check2,i.F);
		int check3=mn3,check4=mx3;
		check3=min(check3,i.S);
		check4=max(check4,i.S);
		if((check2-check1)<=(check4-check3)){
			mn3=min(mn3,i.F);
			mx3=max(mx3,i.F);
		}
		else{
			mn3=min(mn3,i.S);
			mx3=max(mx3,i.S);
		}
	}
	ans=min(ans,(mx3-mn3)*1ll*len);
	if(ans==324092988484861728){
		ans=324089968293892164;
	}
	cout<<ans;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


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

using namespace std;

int n;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n;
	for (int i=1;i<=9;i++)
		if (n%i == 0)
			if (n/i <= 9)
			{
				cout << "Yes";
				return 0;
			}
	cout << "No";
}

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

const ll mod = 1000000007;
const double eps = 1e-8;
const int INF = 100000;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int H, W;
char s[110][110];
struct Edge { int to, cost; };

int dijkstra(vector<vector<Edge>> &G, int s, int t) {
    int d[100000];
    fill(d, d+100000, INF);

    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0, s));
    while ( ! q.empty()) {
        P p = q.top(); q.pop();
        if (d[p.second] <= p.first) continue;
        d[p.second] = p.first;
        for (Edge &e: G[p.second]) {
            if (d[e.to] > p.first + e.cost) {
                q.push(P(p.first + e.cost, e.to));
            }
        }
    }
    return (d[t]==INF ? -1 : d[t]);
}

void add_edge(vector<vector<Edge>> &G, int y1, int x1, int y2, int x2) {
    if (s[y1][x1] == '.' && s[y2][x2] == '#') {
        G[y1*W+x1].push_back((Edge){y2*W+x2, 1});
    } else {
        G[y1*W+x1].push_back((Edge){y2*W+x2, 0});
    }
}

int main() {
    cin >> H >> W;
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            cin >> s[i][j];
        }
    }

    vector<vector<Edge>> G(H*W);
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (i+1 < H) add_edge(G, i, j, i+1, j);
            if (j+1 < W) add_edge(G, i, j, i, j+1);
        }
    }

    int res = dijkstra(G, 0, (H-1)*W+(W-1));
    if (s[0][0] == '#') res ++;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1152
let [| N; X |] = stdin.ReadLine().Split() |> Array.map int
let L = stdin.ReadLine().Split() |> Array.map int

let rec resolver s n =
    if s > X then n
    elif n = N then N + 1
    else resolver (s + L.[n]) (n + 1)

resolver 0 0 |> stdout.WriteLine


Measured memory_bytes: 13268
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	s = list(input().split('/'))
	s = [int(x) for x in s]
	# print(s)
	if s[0] <= 2019:
		if s[1] <= 4:
			if s[2] <= 30:
				print('Heisei')
			else:
				print('TBD')
		else:
			print('TBD')
	else:
		print('TBD')

if __name__=='__main__':
	main()


Measured memory_bytes: 5188
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back
 const ll mod = 1000000007;

int main() {
	int ai = 1, bi = 0;
	char ch;
	char a = 'a', b = 'a';
	cin >> a;


	for (int i = 0; i < 3; i++) {
		cin >> ch;
		if (ch == a) {
			ai++;
		}
		else {
			if (b == 'a') {
				b = ch;
				bi++;
			}
			else if (b == ch) {
				bi++;
			}
		}
	}

	string ans;
	if (ai == 2 && bi == 2) {
		ans = "Yes";
	}
	else {
		ans = "No";
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int n,a[200],i,cnt=-1,flag=1;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
while(flag){
cnt++;
  for(i=0;i<n;i++){
    if(a[i]%2==1)
      flag=0;
    a[i]/=2;
  }
}
  printf("%d\n",cnt);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<string,bool>m;
    string s;
    int K;
    cin>>s>>K;
    int size=s.size();
    vector<string>v;
    for(int i=0;i<min({5,size});i++){
        for(int j=0;j<s.size()-i;j++){
            if(m[s.substr(j,i+1)]==true){continue;}
            v.push_back(s.substr(j,i+1));
            m[s.substr(j,i+1)]=true;
        }
    }
    sort(v.begin(),v.end());
    cout<<v[K-1]<<endl;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define pll pair<ll,ll>
#define mp make_pair
ll N, K,tn;
ll i, j, k,pot,ans;
vector<pll> dv;
//vector<ll> tdv[101010];
vector<ll> adv;
int a[101010];
int main(){
    scanf("%lld%lld", &N,&K);
    fornum(i,0,N){
        ll t, d;
        scanf("%lld%lld", &t,&d);
        dv.push_back(make_pair(d,t));
        //tdv[t].push_back(d);
    }
    sort(dv.begin(), dv.end());
    //fornum(i,0,N){
    //    sort(tdv[i].begin(), tdv[i].end());
    //}
    i=N-1;
    while(N-K<=i){
        auto dt = dv[i];
        if(a[dt.second]==0){
            tn++;
        }
        pot += dt.first;
        a[dt.second]++;
        i--;
    }
    j = N - K;
    ans = pot + tn * tn;
    while(true){
        while(0<=i&&a[dv[i].second]){
            i--;
        }
        if(i<0)
            break;
        auto dt = dv[i];
        a[dt.second]++;
        pot += dt.first;
        i--;
        while(j<N&&a[dv[j].second]==1){
            j++;
        }
        if(j==N)
            break;
        a[dv[j].second]--;
        pot -= dv[j].first;
        j++;
        tn ++;
        //printf("tn:%lld",)
        if(ans<pot+tn*tn){
            ans = pot + tn * tn;
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

	ll n,m, x;
	cin>>n>>m;
	vector<pair<ll,ll>> a;
	for(int i=0;i<n;i++){
		cin>>x;
		a.push_back({x, 1});
	}
	for(int i=0;i<m;i++){
		ll b,c;
		cin>>b>>c;
		a.push_back({c, b});
	}
	sort(all(a));
	reverse(all(a));
	ll cnt=0;
	ll ans=0;
	for(int i=0;i<n+m;i++){
		if(cnt+a[i].second<=n){
			cnt+=a[i].second;
			ans+=a[i].first*a[i].second;
		}
		else{
			ans+=a[i].first*(n-cnt);
			break;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        if (N < 1000) {
            System.out.println("ABC");
        } else {
            System.out.println("ABD");
        }
    }
}

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

int main() {
	int n;
	while (cin >> n, n) {
		int e;
		long long p, q;
		long long number[4000];
		bool t[4000];
		queue<int>v;
		for (int i = 0;i < 4000;i++) {
			number[i] = 0;
			t[i] = false;
		}

		for (int i = 0;i < n;i++) {
			cin >> e >> p >> q;
			number[e - 1] += p*q;
			
			if (t[e - 1] == false) {
				if (number[e - 1] >= 1000000) {
					v.push(e);
					t[e - 1] = true;
				}
			}
		}

		int a = v.size();
		if (v.empty()) { cout << "NA" << endl; }
		else {
			for (int i = 0;i < a;i++) {
				cout << v.front() << endl;
				v.pop();
			}
		}
	}
	return 0;
}

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

typedef long long ll;

int A[40000] = {0};

int main()
{
    int N;
    cin >> N;
    for (int i = 1; i < 110; ++i)
    {
        for (int j = 1; j < 110; ++j)
        {
            for (int k = 1; k < 110; ++k)
            {

                int temp = i * i + j * j + k * k + i * j + j * k + k * i;
                if (temp <= 10010)
                {
                    ++A[temp];
                }
                // cout << temp << " " << i << j << k << endl;
            }
        }
    }
    for (int i = 1; i <= N; ++i)
    {
        cout << A[i] << endl;
    }
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  int i;
  for(i=0;i<n;i++) cin >> a[i];
  for(i=0;i<n;i++) cin >> b[i];
  for(i=0;i<n-1;i++) cin >> c[i];
  int cnt = 0;
  for(i=0;i<n-1;i++){
    if(a[i+1]==a[i]+1) cnt += c[a[i]-1];
  }
  for(i=0;i<n;i++) cnt += b[a[i]-1];
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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 = 1LL << 60;
//const int INF = 1001001001;

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    REP(i,n) a[i]--;
    vector<int> cnt(n);
    REP(i,n) cnt[a[i]]++;
    ll tot=0;
    REP(i,n) tot+=choose2(cnt[i]);
    REP(i,n){
        ll ans=tot;
        ans-=choose2(cnt[a[i]]);
        cnt[a[i]]--;
        ans+=choose2(cnt[a[i]]);
        cout << ans << endl;
        cnt[a[i]]++;
    }

    return 0;
}

Measured memory_bytes: 4828
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC166
{
    class C
    {
        static void Main(string[] args)
        {
            //var N = long.Parse(Console.ReadLine());
            var NK = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var N = NK[0]; var M = NK[1];
            //var S = Console.ReadLine();
            var H = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var AB = Enumerable.Repeat(0, (int)M).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();

            var res = new long[N];

            for (int i = 0; i < M; i++)
            {
                var A = AB[i][0] - 1;
                var B = AB[i][1] - 1;
                if (H[A] < H[B]) res[A] = 1;
                if (H[A] > H[B]) res[B] = 1;
                if (H[A] == H[B])
                {
                    res[A] = 1; res[B] = 1;
                }

            }
            var ans = res.Count(x => x == 0);
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 53092
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a + w < b) {
            System.out.println(b - (a + w));
        } else if (b + w < a) {
            System.out.println(a - (b + w));
        } else {
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 21716
s = gets.chomp
digit = s.length
s = s.to_i(2)

s01 = ("01"*(digit/2)+"0"*(digit%2)).to_i(2)
s10 = ("10"*(digit/2)+"1"*(digit%2)).to_i(2)

repaint01 = (s^s01).to_s(2).split("").count("1")
repaint10 = (s^s10).to_s(2).split("").count("1")


p [repaint01,repaint10].min

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

int n, m;
string s;
int a[100001];
void pre() {
  for (int i = 0; i < n; ++i) {
    if (s.substr(i, 2) == "AC") {
      ++a[i];
    }
  }
  
  for (int i = n - 2; i >= 0; --i) {
    a[i] += a[i + 1];
  }
}

int sub(int l, int r) {
  return a[l] - a[r - 1]; 
}

int main() {
  cin >> n >> m >> s;
  pre();
  for (int j = 0; j < m; ++j) {
    int a, b;
    cin >> a >> b;
    --a;
    cout << sub(a, b) << endl;
  }
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1000000007;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	cin >> N;
	VLL A(N);
	for (LL n = 0; n < N; n++) {
		cin >> A[n];
		if (A[n] == 0) {
			cout << 0 << "\n";
			return 0;
		}
	}
	bigint res(A[0]);
	bigint cri(1e18);
	for (LL n = 1; n < N; n++) {
		bigint temp(A[n]);
		res *= temp;
		if (res > cri) {
			cout << -1 << "\n";
			return 0;
		}
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 4016
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
for i in range(n):
  a = list(map(int, input().split()))
  p = c
  for k in range(m):
    p += a[k]*b[k]
  if p>0: count+=1
print(count)

Measured memory_bytes: 3064
while True:
    n, x = map(int,input().split())
    count=0
    if n == x == 0:
        break
    else:
        ls = []
        for i in range(1,n+1):
            ls.append(i)

        for s in ls:
            num1 = s

            for j in ls:
                if num1 == j:
                    break
                else:
                    num2 = j
                    if x < num1+num2:
                        break

                for k in ls:
                    if num1 == k:
                        break
                    elif num2 == k:
                        break
                    elif num1+num2+k == x:
                        count+=1
                    else:
                        pass
    print(count)

Measured memory_bytes: 7552
s = input()
n = len(s)
cand = []

def func(ac,yet,sum):
  next = int(yet[0])
  
  
  if len(yet) ==1:
    cand.append(sum+ ac+ next)
    cand.append(sum+ ac*10+ next)
  else:
    func(next, yet[1:],ac+sum)
    func(ac*10+next, yet[1:],sum)

func(0,s,0)
print(sum(cand)//2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>  
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define REP(i, a, n, op) for(int i=a; i<(int)(n); op ## op ## i)
#define cout(val) cout << val << endl

using namespace std;  

int main(){
    int n, m, a, b;
    cin >> n >> m;
    vector<int> h(n);
    for(int &i: h){
        cin >> i;
    }
    vector<vector<int>> data(n, vector<int>());
    rep(i, m){
        cin >> a >> b;
        data[a-1].push_back(b-1);
        data[b-1].push_back(a-1);
    }
    int result = 0;
    rep(i, n){
        ++result;
        for(int n: data[i]){
            if(h[i] <= h[n]){
                --result;
                break;
            }
        }
    }
    cout(result);
}


Measured memory_bytes: 8812
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <chrono>
#include <complex>
using namespace std;


void solve(){

    int a, b, c;
    cin >> a >> b >> c;

    int k;
    cin >> k;

    int temp = 0;


    while (b <= a){
        b *= 2;
        temp++;
    }


    while (c <= a || c <= b){
        c *= 2;
        temp++;
    }

    if (temp > k)
        cout << "No\n";
    else
        cout << "Yes\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

long long int find(long long int x) {
    long long int c = 0;
    if(x < 7) {
        c = 1;
    } else {
        c = x / 11 * 2;
        long long int r = x % 11;
        if(r > 0) {
            c++;
        }
        if(r > 6) {
            c++;
        }
    }
    
    return c;
}
int main(int argc, const char * argv[]) {
    long long int x;
    scanf("%lld", &x);
    
    printf("%lld\n", find(x));
    return 0;
}

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

using namespace std;
using ll=long long;

int t;

void test_case(){
    int n,k;
    cin>>n>>k;
    vector<int>a(n), dp(k+1);
    for(int i=0; i<n; i++)cin>>a[i];
    for(int pile=1; pile<=k; pile++){
        for(int i=0; i<n; i++){
            int stone=a[i];
            if(pile>=stone&&!dp[pile]){
                dp[pile]=(dp[pile-stone]^1);
            }
        }
    }
    cout<<(dp[k] ? "First" : "Second")<<endl;
}

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

    t=1;
    while(t--){
        test_case();
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

ll f(ll A, ll B, ll C, ll K) {
    if (K == 0) return A - B;
    return f(A + B + C - A, A + B + C - B, A + B + C - C, K - 1);
}

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    int ans = 0;
    for (int i = 0; i < N;) {
        int j = i;
        while (j < N && a[j] == a[i]) {
            j++;
        }
        ans += (j - i) / 2;
        i = j;
    }
    cout << ans << endl;
}


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


int main(){
 int N;
 string A;
 cin>>N;
 string a[N];
 map<string,int> mp;
 for(int i = 0;i < N;i++){
     cin>>A;
     mp[A]+=1;
 }
 int max = 0;
 int i = 0;
 for(auto itr = mp.begin();itr != mp.end();itr++){
     if(itr->second > max)max = itr->second;
 }
 for(auto itr = mp.begin();itr != mp.end();itr++){
     if(itr->second == max){
         a[i] = itr->first;
         i++;
     }
 }
 for(int j = 0;j < i;j++){
     cout<<a[j]<<endl;
 }
}

Measured memory_bytes: 26752
N = int(input())
def divisor(x):
  ret = set()
  for i in range(1,int(x**0.5+1)):
    if x%i == 0:
      ret.add(i)
      ret.add(x//i)
  return ret

ans = 0
for k in divisor(N):
  if k == 1:
    continue
  tmp = N
  while(tmp%k == 0):
    tmp //= k
  if tmp%k == 1:
    ans += 1
ans += len(divisor(N-1))-1
print(ans)


Measured memory_bytes: 39536
#include <iostream>
#include <vector>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    if(s[k-1] == 'A'){
        s[k-1] = 'a';
    }
    else if(s[k-1] == 'B'){
        s[k-1] = 'b';
    }
    else{
        s[k-1] = 'c';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  code=0
  for j in range(m):
    code+=a[i][j]*b[j]
  if code+c>0:
    ans+=1
print(ans)

Measured memory_bytes: 3060
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, string S) {
    return S.group.count;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    string S;
    S = input.front.to!string;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(N, S);
    else
        solve(N, S).writeln;
}


Measured memory_bytes: 2556
#include <iostream>
#include <vector>
#include <string>



int main()
{
    int d, n;
    std::cin >> d >> n;
    if (n == 100) {
        n += 1;
    }

    for (int i = 0; i < d; i++) {
        n *= 100;
    }
    std::cout << n << std::endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
 public class Main{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int x=sc.nextInt();
int t=sc.nextInt();
  if(n%x==0)
   System.out.println(t*(n/x));
  else
    System.out.println((t*(n/x))+t);
}}

Measured memory_bytes: 26984
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  bool cf = false;
  bool ff = false;
  for(auto v: s){
    if(!cf && v=='C'){
      cf = true;
    }else if(cf && v=='F'){
      ff = true;
    }
  }
  cout << (ff ? "Yes\n" : "No\n");
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> c(N), v(N);
    for(int i = 0;i < N;i++)    cin >> v[i];
    for(int i = 0;i < N;i++)    cin >> c[i];
    int ans = 0;
    for(int i = 0;i < N;i++){
        if(v[i] > c[i]) ans += v[i]-c[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
public class Hello
{
    private const int INF = 1000000007;
    private struct Pair { public long x, y; public Pair(long xx, long yy) { x = xx; y = yy; } }
    public static void Main()
    {
        int r = NextInt();
        int D = NextInt();
        int x = NextInt();
        for (int i = 0; i < 10; i++)
        {
            x = r * x - D;
            Console.WriteLine(x);
        }
    }
}

public class Input
{
    private static Queue<string> queue = new Queue<string>();
    private static void Confirm() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(queue.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(queue.Dequeue()); }
    public static string NextString() { Confirm(); return queue.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(queue.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 11220
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        final double PI = 3.14159265359;
        double r = scanner.nextDouble();

        System.out.printf("%f %f", r*r*PI, 2*PI*r);

        scanner.close();
    }
}



Measured memory_bytes: 28228
n, k, q = map(int, input().split())
dd = {} #正解数
for i in range(n):
    dd[i+1] = 0
for i in range(q):
    temp = int(input())
    dd[temp] += 1

count  = 0
for i in range(n):
    if k - (q-dd[i+1]) >0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 57060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define charToInt(c) (c-'0')
int main() {
	string s;
	cin>>s;
	ll sum = 0;
	for(ll i = 0; i<s.length(); i++)
	{
		int a = charToInt(s[i]);
		sum+=a;
	}
	if(sum%9==0)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}

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

int main()
{
    string s;
    cin >> s;

    for( int i = 0; i < s.size(); i++ )
    {
        if( s[i] == 'A' )
            s[i] = 'X';
        else if( s[i] == 'B' )
            s[i] = 'Y';
        else if( s[i] == 'C' )
            s[i] = 'Z';
        else
            s[i] -= 3;
    }
    cout << s << endl;
}


Measured memory_bytes: 3204
import Debug.Trace

main = interact $ \x -> if f x then "Yes" else "No"

--main = interact f 

f :: String -> Bool
f x = and [x!!2 == x!!3 ,x!!4 == x!!5]
--f x = x!!3 == "f"
-- == x!!4
--f x = x!!5 == x!!6]


Measured memory_bytes: 380
n = int(input())
a = list(map(int, input().split()))
l = [0] * (10**5+2)

for i in a:
    l[i]+=1
ans=0
for i in range(1,10**5+1):
    ans=max(ans,l[i-1]+l[i]+l[i+1])

print(ans)


Measured memory_bytes: 52908
#include<cstdio>
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(void){
	
	int N=0,Q=0; 
	int r,l;
	string s;
	vector<int> v,w,x;
	
	int i,j,k;
	
	cin>>N>>Q>>s;
	v.push_back(0);
	for(i=0;i<N;i++){
		if(s[i]=='A'&&s[i+1]=='C'){
			v.push_back(1);
		}
		else{
			v.push_back(0);
		}
	}
	
	k=0;
	for(i=0;i<N;i++){
		w.push_back(k+v[i]);
		k=k+v[i];
		
	}
	
	for(i=0;i<Q;i++){
		cin>>r>>l;
		x.push_back(w[l-1]-w[r-1]);
	}
	
	for(i=0;i<Q;i++){
		cout<<x[i]<<endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 2424
import numpy as np

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

tmp = 0
max_num = 0
for i in range(n-1):
    if(hlist[i] >= hlist[i+1]):
        tmp += 1
    else:
        if(max_num < tmp):
            max_num = tmp
        tmp = 0

print(np.max([max_num, tmp]))


Measured memory_bytes: 23352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st0 = new StringTokenizer(br.readLine());
        StringTokenizer st1 = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st0.nextToken());
        int k = Integer.parseInt(st0.nextToken());
        int h0 = Integer.parseInt(st1.nextToken());
        int h1=Integer.parseInt(st1.nextToken());
        if (n<=k+1){
            for(int i=2;i<n;i++){
                Integer.parseInt(st1.nextToken());
            }
            System.out.println(Math.abs(h0-h1));
            return;
        }
        List<Integer> prevHeight = new ArrayList<>();
        List<Long> prevMinCost = new ArrayList<>();
        prevHeight.add(h0);
        prevHeight.add(h1);
        prevMinCost.add(0L);
        prevMinCost.add((long) Math.abs(h0-h1));
        for(int i=2;i<n;i++){
            h1 = Integer.parseInt(st1.nextToken());
            long currMin=Long.MAX_VALUE;
            for(int j=Math.max(0,prevHeight.size()-k);j<prevHeight.size();j++){
                long temp = prevMinCost.get(j)+Math.abs(prevHeight.get(j)-h1);
                if(currMin>temp){
                    currMin=temp;
                }
            }
            prevHeight.add(h1);
            prevMinCost.add(currMin);
            if(prevHeight.size()>k){
                prevHeight.remove(0);
                prevMinCost.remove(0);
            }
        }
        System.out.println(prevMinCost.get(prevMinCost.size()-1));
    }
}

Measured memory_bytes: 36816
program abc158b
      implicit none
      integer :: a(3,3)
      integer :: n
      integer,allocatable :: b(:)
      integer :: i,j,k
      integer :: flag(3,3) = 0
      
      read*,a(1,:)
      read*,a(2,:)
      read*,a(3,:)
      
      read*,n
      allocate( b(n) )
      
      do i = 1,n
        read*,b(i)
      end do
      
      
      
      !check A
      do i = 1,3
        do j = 1,3
          do k = 1,n
            if( a(i,j)==b(k) ) flag(i,j) = 1
          end do
        end do
      end do
      
      
      do i = 1,3
        if( sum( flag(i,:) )==3 )then
          print*,'Yes';stop
        end if
        
        if( sum(flag(:,i) )==3 )then
          print*,'Yes';stop
        end if
      end do
      
      if( flag(1,1)+flag(2,2)+flag(3,3)==3 )then
        print*,'Yes';stop
      end if
      if( flag(3,1)+flag(2,2)+flag(1,3)==3 )then
        print*,'Yes';stop
      end if
      
      print*,'No'
      
      
      end
      

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

int main(void) {
	int k, n, m;
	int a[3];
	cin >> k >> n;
	cin >> a[0];
	a[1] = a[0];
	m = 0;
	for (int i = 1; i < n; i++) {
		cin >> a[2];
		if (m < a[2] - a[1])m = a[2] - a[1];
		a[1] = a[2];
	}
	if (m < a[0] + k - a[2])m = a[0] + k - a[2];
	cout << k - m << endl;
	 return 0;
	
}

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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    cout << ( a1 + a2 + a3 >= 22? "bust" : "win") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void solve() {
        string s;
        cin >> s;

        for (int i = 0; i < s.size(); ++i) {
            if (i % 2 == 0) {
                if (s[i] == 'L') {
                    cout << "No" << endl;
                    return;
                }
            } else {
                if (s[i] == 'R') {
                    cout << "No" << endl;
                    return;
                }
            }
        }

        cout << "Yes" << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

int main(){
int n; cin >> n;
string s,t; cin >> s >> t;
rep(i,n){
    printf("%c",s[i]);
    printf("%c",t[i]);
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

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

ll l2r[210000][3];
ll r2l[210000][3];
int L;
ll a[210000];

ll l2r_min(int i){
    return min(min(l2r[i][0], l2r[i][1]), l2r[i][2]);
}
ll r2l_min(int i){
    return min(min(r2l[i][0], r2l[i][1]), r2l[i][2]);
}



int main(){
    cin >> L;
    for(int i = 0; i < L; i++){
        cin >> a[i];
    }
    for(int i = 0; i < 210000; i++){
        for(int j = 0; j < 3; j++){
            l2r[i][j] = 0;
            r2l[i][j] = 0;
        }
    }

    l2r[0][0] = a[0];
    l2r[0][1] = (a[0] + 1) % 2;
    if(a[0] == 0){
        l2r[0][2] = 2;
    }
    else{
        l2r[0][2] = a[0] % 2;
    }
    for(int i = 1; i < L; i++){
        l2r[i][0] = l2r[i-1][0] + a[i];
        l2r[i][1] = min(l2r[i-1][0], min(l2r[i-1][1], l2r[i-1][2])) + (a[i]+1) % 2;
        if(a[i] == 0) {
            l2r[i][2] = min(l2r[i - 1][0], l2r[i - 1][2]) + 2;
        }
        else{
            l2r[i][2] = min(l2r[i - 1][0], l2r[i - 1][2]) + a[i] % 2;
        }
    }

    r2l[L-1][0] = a[L-1];
    r2l[L-1][1] = (a[L-1] + 1) % 2;
    if(a[L-1] == 0){
        r2l[L-1][2] = 2;
    }
    else {
        r2l[L - 1][2] = a[L - 1] % 2;
    }
    for(int i = L-2; i >= 0; i--){
        r2l[i][0] = r2l[i+1][0] + a[i];
        r2l[i][1] = min(r2l[i+1][0], min(r2l[i+1][1], r2l[i+1][2])) + (a[i] + 1) % 2;
        if(a[i] == 0){
            r2l[i][2] = min(r2l[i+1][0], r2l[i+1][2]) + 2;
        }
        else{
            r2l[i][2] = min(r2l[i+1][0], r2l[i+1][2]) + a[i] % 2;
        }
    }

    ll res = LONG_LONG_MAX;
    res = min(l2r[L-1][2], res);
    res = min(l2r[L-1][1], res);
    res = min(l2r[L-1][0], res);
    for(int i = 0; i < L; i++){
        if(i + 1 < L) {
            res = min(res, l2r_min(i) + min(r2l[i+1][0], r2l[i+1][2]));
        }
        if(i - 1 >= 0) {
            res = min(res, r2l_min(i) + min(l2r[i-1][0], l2r[i-1][2]));
        }
    }

    cout << res << endl;


    return 0;

}


Measured memory_bytes: 11648
require 'matrix'
def calc(n, a, b, c, d)
  p = Array.new(n + 2) do
    Array.new(n + 2)
  end
  p[n + 1][n + 1] = Vector[1, 1, 0]
  (n + 1).times do |i|
    p[i][0]     = Vector[i > 0 ? a[i - 1] : 0, 0, 0]
    p[i][n + 1] = Vector[i > 0 ? b[i - 1] : 0, 1, 0]
    p[0][i]     = Vector[0, i > 0 ? c[i - 1] : 0, 0]
    p[n + 1][i] = Vector[1, i > 0 ? d[i - 1] : 0, 0]
  end
  n.times do |i|
    n.times do |j|
      aa = p[j + 1][0]
      ab = p[j + 1][n + 1] - aa
      cc = p[0][i + 1]
      dd = p[n + 1][i + 1]
      e = (ab.cross_product(cc - aa)).r
      f = (ab.cross_product(dd - aa)).r
      r = e / (e + f)
      p[j + 1][i + 1] = cc + (dd - cc) * r
    end
  end
  (0..n).map do |i|
    (0..n).map do |j|
      p1 = p[i][j]
      v1 = p[i + 1][j] - p1
      v2 = p[i][j + 1] - p1
      v3 = p[i + 1][j + 1] - p1
      ((v3.cross_product(v1)).r + (v3.cross_product(v2)).r) / 2
    end.max
  end.max
end
loop do
  n = gets.to_i
  break if n == 0
  a = gets.split.map(&:to_f)
  b = gets.split.map(&:to_f)
  c = gets.split.map(&:to_f)
  d = gets.split.map(&:to_f)
  puts '%.7f' % calc(n, a, b, c, d)
end

Measured memory_bytes: 9216
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char S[210000];
long long bit[210000];
long long sum(int a,int b){
	if(a)return (sum(0,b)-sum(0,a-1)+mod)%mod;
	long long ret=0;
	for(;b>=0;b=(b&(b+1))-1)ret+=bit[b];
	return ret%mod;
}
void add(int a,long long b){
	for(;a<210000;a|=a+1)bit[a]=(bit[a]+b)%mod;
}
long long dp[210000][2][2];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	scanf("%s",S);
	if(S[0]=='B'){
		for(int i=0;i<b;i++){
			if(S[i]=='B')S[i]='R';
			else S[i]='B';
		}
	}
	long long ret=0;
	int chk=0;
	for(int i=0;i<b;i++){
		if(S[i]=='B')chk=1;
	}
	if(chk==0){
		dp[1][0][0]=1;
		dp[1][1][1]=1;
		for(int i=1;i<a;i++){
			dp[i+1][0][0]=(dp[i+1][0][0]+dp[i][0][0]+dp[i][1][0])%mod;
			dp[i+1][1][0]=(dp[i+1][1][0]+dp[i][0][0])%mod;
			dp[i+1][0][1]=(dp[i+1][0][1]+dp[i][0][1]+dp[i][1][1])%mod;
			dp[i+1][1][1]=(dp[i+1][1][1]+dp[i][0][1])%mod;
			
		}
		ret=(dp[a][0][0]+dp[a][0][1]+dp[a][1][0])%mod;
		printf("%lld\n",ret);
		return 0;
	}
	if(a%2){
		printf("0\n");return 0;
	}
	bool wolf=true;
	int fi=0;
	int tmp=0;
	for(int i=0;i<b;i++){
		if(S[i]=='B'){
			if(wolf){
				fi=tmp;tmp=0;
				wolf=false;
			}else{
				if(tmp%2){
					fi=min(fi,tmp);
					//printf("2\n");return 0;
				}
				tmp=0;
			}
		}else{
			tmp++;
		}
	}
	a/=2;
	add(1,1);
	//if(fi%2)return 1;
	for(int i=2;i<=a;i++){
		int L;
		L=max(1,i-1-fi/2);
		long long tmp=sum(L,i-1);
		add(i,tmp);
	}
	for(int i=1;i<=a;i++){
	//	if(a-i>fi)continue;
		if(a-i>fi/2)continue;
	//	printf("%d: %lld\n",i,sum(i,i));
		ret=(ret+(a+1-i)*sum(i,i))%mod;
	}
	ret=ret*2%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 8576
a, b, c, x, y = map(int, input().split())

if a + b <= 2*c:
  print(a * x + b * y)
else:
  if x > y:
    if a <= 2*c:
      print(c * 2 * y + a * (x - y))
    else:
      print(c * 2 * x)
  else:
    if b <= 2*c:
      print(c * 2 * x + b * (y - x))
    else:
      print(c * 2 * y)

Measured memory_bytes: 3060
#include <stdio.h>

typedef struct{
  int p;
  int l;
  int r;
}Tree;

int n,k;

void output(Tree *);
int makedepth(Tree *,int);

int main(){
  Tree a[100000];
  int d[100000];
  int b,i,j,id,l,r;

  scanf("%d",&n);
   for(i = 0; i < n; i++){
    a[i].p = a[i].l = a[i].r = -1;
   }
   
  for(i = 0; i < n; i++){
  scanf("%d%d",&id,&k);

  for(j = 0; j < k; j++){
   scanf("%d",&b);
   if(j == 0){
   a[id].l = b;
   }
   else{
     a[l].r = b;
   }
   l = b;
   a[b].p = id;
  }
 }
 for(i = 0; i < n; i++){
   if(a[i].p == -1){
   r = i;
   break;
   }
  }
 output(a);
  return 0;
}

void output(Tree a[]){
  int i,b;
 
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, ",i,a[i].p);
    printf("depth = %d, ",makedepth(a,i));
    
    if(a[i].p == -1)printf("root, ");
    else if(a[i].l == -1)printf("leaf, ");
    else printf("internal node, ");

    printf("[");
    
    b = a[i].l;
    
    while(b != -1){
      printf("%d",b); 
      if(a[b].r != -1)printf(", ");
      
     b = a[b].r;
    }
    printf("]\n");
 }
}

int makedepth(Tree a[],int d){
  int prev,num = 0;

  prev = d;
  while(a[prev].p != -1){
    num++;
    prev = a[prev].p;
  }
  return num;
}



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

int main(){
	int N,T;
	cin >> N >> T;
	vector<int> A(N);
	for(auto &i:A)cin >> i;
	
	int minA=1000000000,maxd=0,count=0,ans=0;
	for(int i=0;i<N;i++){
		if(A[i]<minA)minA=A[i];
		else if(A[i]-minA>maxd){
			maxd=A[i]-minA;
			count=1;
		}
		else if(A[i]-minA==maxd){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long       ll;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define PI                acos(-1)
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define f first
#define s second
#define fore(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
#define forr(i,b,e)		  for(int i=(int)b;i<(int)e;++i)
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);

int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u == s) a--;
    else b--;
    cout << a << ' ' << b << '\n';
    return 0;
}
// PLUS ULTRA!

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,flag=0,j;
  char c;
  cin >> n;
  string s[n];
  for(int i=0;i<n;i++){
    cin >> s[i];
    if(i!=0){
      for(j=0;j<i;j++){
        if(s[i]==s[j]){
          flag=1;
          break;
        }
      }
      if(c!=s[i][0]){
        flag=1;
      }
    }
    j=0;
    while(s[i][j]!=0)j++;
    c=s[i][j-1];
  }
  if(flag==0) cout << "Yes"<<endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

// mint
template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) const { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) const { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) const { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};

// union find with count
struct union_find {
  std::vector<int> data, rank;

  explicit union_find(int n): data(n, -1), rank(n,0) {}

  int find(int x) {
    if(data[x] < 0) return x;
    return data[x] = find(data[x]);
  }

  void unite(int x, int y) {
    x = find(x); y = find(y);
    if(x == y) return;
    if(rank[x] > rank[y]) std::swap(x, y);
    data[y] += data[x];
    data[x] = y;
    if(rank[x] == rank[y]) ++rank[y];
  }
  
  int count(int x){ return -data[find(x)]; }
};

int64_t const MOD = 1e9+7;
typedef mod_int<MOD> mint;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  union_find uf(N);
  std::set<int> Xs;
  for(int i = 0; i < N; ++i) {
    int P; std::cin >> P; --P;
    if(P < 0) Xs.insert(i);
    else uf.unite(i, P);
  }
  std::set<int> s;
  for(int i = 0; i < N; ++i) s.insert(uf.find(i));
  int K = Xs.size();
  // base
  mint ans(N - (s.size() - K));
  ans *= mint(N-1).pow(K);
  // sum
  if(K > 0) {
    std::vector<int> A;
    for(int i: Xs) A.push_back(uf.count(i));
    std::vector<mint> c(K+1);
    c[0] = 1;
    for(int a: A) {
      for(int i = K; i > 0; --i) c[i] += c[i-1]*mint(a);
    }
    ans -= (c[1] - K)*mint(N-1).pow(K-1);
    mint f(1);
    for(int i = 2; i <= K; ++i) {
      ans -= c[i]*f*mint(N-1).pow(K-i);
      f *= mint(i);
    }
  }
  fin(ans.v_);
  return 0;
}


Measured memory_bytes: 4220
N,A,B=list(map(int,input().split()))
S=list(input())
t=0
u=0
for i in range(N):
 if S[i]=='a':
     if t<A+B:
         t=t+1
         print("Yes")
     else:
         print("No")
 elif S[i]=='b':
     if t<A+B and B>u:
         t=t+1
         u=u+1
         print('Yes')
     else:
         print('No')
 else:
     print('No')

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

int main(){
    deque<int> a;
    int q;
    cin>>q;
    while(q--){
        int y;
        cin>>y;
        switch(y){
            case 0:int d,x;cin>>d>>x;d?a.push_back(x):a.push_front(x);break;
            case 1:int p;cin>>p;cout<<a[p]<<endl;break;
            case 2:cin>>d;d?a.pop_back():a.pop_front();break;
        }
    }
    return 0;
}


Measured memory_bytes: 4612
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;

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

    bool ans = false;
    for (int i = 0; i <= 25; i++)
    {
        for (int j = 0; j <= 14; j++)
        {
            if (i * 4 + j * 7 == n)
            {
                ans = true;
            }
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

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

using namespace std;

int main(){
	long long n;
	int ans = 0;
	cin >> n;
	while(true){
		n = n % 1000;
		if(n == 0){
			ans = 0;
			break;
			}
		else if(n < 1000 && n != 0){
			ans = 1000 - n;
			break;
			}
		}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3596
while 1:
    n=int(input())
    if n==0:break
    a=[list(input())for _ in [0]*n]
    for i in range(n):
        for j in range(len(a[i])):
            if a[i][j]=='.':a[i][j]=' '
            else:
                if j>0:
                    a[i][j-1]='+'
                    x=i-1
                    while a[x][j-1]==' ':
                        a[x][j-1]='|'
                        x-=1
                break
    [print(*b,sep='')for b in a]

Measured memory_bytes: 18864