akhauriyash/Code-Regression huggingface dataset:
n = int(input())
string = input()
es = [0]
ws = [0]
for s in string:
    if s == 'E':
        es.append(es[-1]+1)
        ws.append(ws[-1])
    else:
        es.append(es[-1])
        ws.append(ws[-1]+1)
ans = float('inf')
for i in range(n):
    i += 1
    score = ws[i-1] + es[-1] - es[i]
    ans = min(score, ans)

print(ans)


Measured memory_bytes: 23476
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include <string>

using namespace std;

long long N;
int K;

int main()
{
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	cin >> N >> K;
	int i = 0;
	while(N)
	{
		N /= K;
		++i;
	}
	cout << i << '\n';	
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rint register int
using namespace std;
inline int read(){
	int s=0,f=1; char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=0;c=getchar();}
	while(c>='0'&&c<='9') s=(s<<1)+(s<<3)+(c^48),c=getchar();
	return f?s:-s;
}
int n,val[100010],cnt[20];
int ans,st,f[1<<16],Xor[1<<16];
int main(){
	n=read();
	for(rint i=1;i<n;++i){
		int x=read(),y=read(),v=read();
		val[x]^=v; val[y]^=v;
	}
	for(rint i=0;i<n;++i) ++cnt[val[i]];
	for(rint i=1;i<=15;++i){
		ans+=cnt[i]/2; cnt[i]%=2;
		st|=cnt[i]<<i-1;
	}
	for(rint i=1;i<1<<15;++i) f[i]=f[i>>1]+(i&1);
	for(rint i=1;i<1<<15;++i) --f[i];
	for(rint i=1;i<1<<15;++i)
		for(rint j=1;j<=15;++j)
			if(i&(1<<j-1)) Xor[i]^=j;
	for(rint S=1;S<1<<15;++S){
		if(Xor[S]) continue;
		for(rint i=(S-1)&S;i;i=(i-1)&S)
			if(!Xor[i]) f[S]=min(f[S],f[i]+f[S^i]);
	}
	printf("%d",ans+f[st]);
	return 0;
}

Measured memory_bytes: 4396
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int minn(10), t;
	int ct[5];
	
	for (int i = 0; i < 5; ++i)
		scanf("%d", ct + i);
	for (int i = 0; i < 5; ++i)
		if ((t = ct[i] % 10)) {
			minn > t && (minn = t);
			ct[i] += 10 - t;
		}
	printf("%d\n", ct[0] + ct[1] + ct[2] + ct[3] + ct[4] + minn - 10);
	return 0;
}



Measured memory_bytes: 256
a,b,c,d = input().split()
if int(d) < int(a):
    print(int(d))
elif int(d) < int(a) + int(b):
    print(int(a) + (int(d) - int(a))* 0)
else:
    res = int(a) - (int(d)-(int(a)+ int(b)))
    print(res)

Measured memory_bytes: 9220
import java.util.Scanner;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int max = Math.max(a, b);
		max = Math.max(max, c);
		int sum = a + b + c;
		
		if (sum % 2 == (3 * max) % 2) {
			System.out.println((3*max - sum) / 2);
		} else {
			System.out.println((3*(max + 1) - sum) / 2);
		}
		scanner.close();
	}

}


Measured memory_bytes: 21716
import math

n=int(input())
L=[list(map(int,input().split())) for _ in range(n)]

c=0
for i in range(n):
    for j in range(i+1,n):
        c+=math.sqrt((L[i][0]-L[j][0])**2+(L[i][1]-L[j][1])**2)

print(c/n*2)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

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

    if(s.length()<=k){
      cout << s << endl;
      return 0;
    }

    string result = "";
    rep(i, k){
      result += s.at(i);
    }
    result += "...";
    
    cout << result << endl;
}


Measured memory_bytes: 3628
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>

int cmp(const void *a, const void *b) {
  return *(int*)a - *(int*)b;
}

int N;
int L[2010];

int main(void) {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &L[i]);
  }
  qsort(L, N, sizeof(int), cmp);

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int l = j;
      int r = N;
      while (r - l > 1) {
        int c = l + (r - l) / 2;
        if (L[c] >= L[i] + L[j]) {
          r = c;
        } else {
          l = c;
        }
      }
      // printf("%d %d %d %d\n", i, j, l, r);
      ans += l - j;
    }
  }
  printf("%d\n", ans);

  // for (int i = 0; i < N; ++i) {
  //   printf("%d ", L[i]);
  // }
  // puts("");
}


Measured memory_bytes: 128
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

from collections import defaultdict

n = ni()
ss = nsn(n)

d = defaultdict(int)
for i in range(n):
    d[ss[i]] += 1

mx = max(d.values())
ans = []
for i, j in d.items():
    if mx == j:
        ans.append(i)

ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 35560
n,k,*a=map(int,open(0).read().split())
r=range(n)
for _ in a[:k][:41]:
 b=[0]*n*3
 for i in r:b[max(0,i-a[i])]+=1;b[i-~a[i]]-=1
 for i in r:b[i+1]+=b[i]
 a=b
print(*a[:n])

Measured memory_bytes: 172352
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def my_round(a,dig=0):
    p = 10 ** dig
    return (a * p * 2 + 1) // 2 / p

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    x,y = map(int,input().split())
    if x == y:
        print(-1)
        return
    if y % x == 0:
        mul = y // x + 1
        print(x * mul)
        return
    for i in range(1,4):
        if (x * i) % y != 0:
            print(x * i)
            return
    print(-1)
    return

if __name__=='__main__':
    main()


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

typedef long long int ll;

vector <ll> adj[100005];
vector <ll> dp(100005);
vector <ll> visited(100005);

bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

void dfs(ll point,ll parent)
{
    if(adj[point].size()==0)
    {
        dp[point] = 0;    
    }

    if(dp[point]!=-1)
    {
        dp[parent] = max(dp[point]+1,dp[parent]);
        return;
    }



    for(ll i=0;i<adj[point].size();i++)
    {
        dfs(adj[point][i],point);
    }

    if(parent!=-1)
    {
        dp[parent] = max(dp[point]+1,dp[parent]);
    }

    



    


}

int main()
{
    ios::sync_with_stdio(false);

    ll n,m,i,j,k,l;

    cin >> n >> m;

    ll u,v;

    for(i=0;i<m;i++)
    {
        cin >> u >> v;

        adj[u].push_back(v);
    }

    for(i=1;i<=n;i++)
        dp[i]=-1;


    for(i=1;i<=n;i++)
    {
        // if(dp[i]==-1)
        // {
            dfs(i,-1);
        // }
    }

    ll maximum = -1;

    for(i=1;i<=n;i++)
    {
        // cout << dp[i] << '\n';
        maximum = max(maximum,dp[i]);
    }

    cout << maximum << '\n';


}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
static const long long MOD=1000000007;

int main(){
  int N,temp;
  cin >> N;
  int c1,c2,c3;
  c1=0;
  c2=0;
  c3=0;
  long long ans=1;
  for(int i=0;i<N;i++){
    int cnt=0;
    int flag=-1;
    cin>>temp;
    if(c1==temp){
      cnt++;
      flag=1;
    }
    if(c2==temp){
      cnt++;
      flag=2;
    }
    if(c3==temp){
      cnt++;
      flag=3;
    }
    ans=ans*cnt%MOD;
    if(flag==1){
      c1++;
    }
    if(flag==2){
      c2++;
    }    
    if(flag==3){
      c3++;
    }  
  }
  cout<<ans<<endl;    
  return 0;
}



    

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e6+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;

int32_t main()
{
    IOS
    string k;
    cin>>n>>k;
    if(n>=3200)cout<<k;
    else cout<<"red";
    return 0;
}

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

int main()
{
  ll n, a, b;
  cin >> n >> a >> b;
  if (a == b)
    cout << 1 << endl;
  else if (b < a || (b != a && n == 1))
    cout << 0 << endl;
  else
    cout << (b - a) * (n - 2) + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	int r;
	cin >> r;
	cout << r*r << endl;

	return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>

int main() {
	int N, M, K[30], A[30][30], i, j, count[30], ans = 0;
	memset(count, 0, sizeof(count));

	scanf("%d %d", &N, &M);
	for (i = 0; i < N; i++) {
		scanf("%d", &K[i]);
		for (j = 0; j < K[i]; j++) {
			scanf("%d", &A[i][j]);
			count[A[i][j] - 1]++;
		}
	}

	for (i = 0; i < M; i++) {
		if (count[i] == N) ans++;
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h> 
#include <set>

using namespace std;

#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9 + 7;

bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) return false; }
    return true;
}


int main() {
    int N;
    cin >> N;
    vi A(N);
    set<int> B;
    rep(i, N) {
        cin >> A[i];
        B.insert(A[i]);
    }
    int n = B.size();
    if (n % 2 == 0)cout << n - 1 << endl;
    else cout << n << endl;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
vector<int>dots[3];
int color[33][33];
int psum[3][33];
void init(int m,int c){
	for(int i=1; i<=c; i++){
		int cost = 0;
		for(int j=0; j<dots[m].size(); j++){
			cost+=color[dots[m][j]][i];
		}
		psum[m][i] = cost;
	}
}
int solve(int a,int b,int c){
	return psum[0][a]+psum[1][b]+psum[2][c];
}
int main(){
	int n,c;
	cin>>n>>c;
	for(int i=1; i<=c; i++){
		for(int j=1; j<=c; j++) cin>>color[i][j];
	}
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			int num;
			cin>>num;
			dots[(i+j)%3].push_back(num);
		}
	}
	init(0,c);
	init(1,c);
	init(2,c);
	int mincost = numeric_limits<int>::max();
	for(int i=1; i<=c; i++){
		for(int j=1; j<=c; j++){
			for(int k=1; k<=c; k++){
				if(i==j || j==k || i==k) continue;
				mincost = min(solve(i,j,k),mincost);
			}
		}
	}
	cout<<mincost;
}



Measured memory_bytes: 4372
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
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()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

def main():

	N = INT()
	S = input()

	former = S[:N]
	latter = S[N:][::-1]

	dic_f = defaultdict(int)
	dic_l = defaultdict(int)

	for x in product([0, 1], repeat=N):
		tmp_red = ""
		tmp_blue = ""
		for i in range(N):
			if x[i]:
				tmp_red += former[i]
			else:
				tmp_blue += former[i]
		dic_f["{},{}".format(tmp_red, tmp_blue)] += 1

	for x in product([0, 1], repeat=N):
		tmp_red = ""
		tmp_blue = ""
		for i in range(N):
			if x[i]:
				tmp_red += latter[i]
			else:
				tmp_blue += latter[i]
		dic_l["{},{}".format(tmp_red, tmp_blue)] += 1

	ans = 0

	for key in dic_f:
		ans += dic_f[key] * dic_l[key]

	print(ans)


if __name__ == '__main__':
	main()


Measured memory_bytes: 238176
-- String を Intにする
toInt :: (String -> Int)
toInt x = read x :: Int

-- 入力を受け取り、 [Int] にする
getInts = do
  x <- getLine
  let y = (map$toInt)$words x -- 半角スペースで分割してIntにする
  return y

main = do
  inNum <- getInts
  let square = (inNum !! 0) * (inNum !! 1)
  let perimeter = (inNum !! 0) * 2 + (inNum !! 1) * 2
  putStrLn ((show square) ++ [' '] ++ (show perimeter))


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ran 101111
vector<int> e[ran];int n;
int main(){
	int m;
	scanf("%d%d",&n,&m);
	while(m--){
		int x,y;
		scanf("%d%d",&x,&y);
		e[y-1].push_back(x);
	}
	m=0;int x=-1;
	for(int i=1; i<=n; i++){
		for(auto y : e[i]){
			if(y > x){
				x = i;
				m++;
			}
		}
	}
	printf("%d\n",m);
	return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int n;
vector<int> adj[100005];
vector<vector<ll>> memo(100005, vector<ll>(2, -1));


ll rec(int from, int now, int j){
    if(memo[now][j] != -1) return memo[now][j];

    ll ans = 1;
    if(j == 0){
        for(auto to : adj[now]){
            if(to == from) continue;
            ans *= ( rec(now, to, 0) + rec(now, to, 1) );
            chmod(ans);
        }
    }
    else{
        for(auto to : adj[now]){
            if(to == from) continue;
            ans *= rec(now, to, 0);
            chmod(ans);
        }
    }

    return memo[now][j] = ans;
}

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

    cin >> n;
    rep(i, n-1){
        int x, y; cin >> x >> y;
        --x; --y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    ll ans = 0;
    rep(j, 2) ans += rec(-1,0, j), chmod(ans);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 19584
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    VI t(n); VIin(t);
    int ans = 0;
    rep(i,n){
        rep(j,n){
            if(i == j) continue;
            else ans += t[i]*t[j];
        }
    }
    OUT(ans/2);


    return 0;
}

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

int T[256];
bool issq[70000];

int main() {
  fill(issq, issq+70000, false);
  for (auto i=0; i<256; i++) {
    int temp = i*i;
    T[i] = temp;
    issq[temp] = true;
  }
  int N;
  while (cin >> N && N) {
    int res = 0;
    for (auto i=0; i<256; i++) {
      for (auto j=i; j<256; j++) {
	for (auto k=j; k<256; k++) {
	  int s = N - (T[i] + T[j] + T[k]);
	  if (s < T[k]) break;
	  if (issq[s]) res++;
	}
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1228
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

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

    const ll INFL = LLONG_MAX / 3;
    int N, E, T;
    cin >> N >> E >> T;
    vi x(N + 1);
    vll f(N + 1, 0);
    for(int i = 1; i <= N; ++i)cin >> x[i];

    int p = 0;
    // min(dp[i]+T) // 近い
    // min(dp[i]-2x[i+1]) // 遠い
    multiset<ll> aa, bb;
    for(int i = 1; i <= N; ++i) {
        aa.insert(f[i - 1] + T);
        while(T < 2 * (x[i] - x[p + 1])) {
            bb.insert(f[p] - 2 * x[p + 1]);
            aa.erase(aa.find(f[p++]+T));
        }
        f[i] = *aa.begin();
        if(sz(bb))smin(f[i], 2 * x[i] + (*bb.begin()));
    }
    cout << E + f[N] << endl;
}

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

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    
    int red = 0;
    int blue = 0;
    
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == 'R'){
            ++red;
        }
        else{
            ++blue;
        }
    }
    
    if(red > blue) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
import math

N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    A[i] -= i + 1

A.sort()
start_index = math.floor(N / 2)

min_sum = 10 ** 9 * 2 * 10 ** 5
for i in range(A[start_index], A[start_index] + 1):
    summ = 0
    for j in range(N):
        summ += abs(A[j] - i)
    min_sum = min(min_sum, summ)
print(min_sum)

Measured memory_bytes: 26832
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

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

	for(;;)
	{
		int n;
		ll d;
		cin >> n >> d;
		if(cin.fail()) break;
		vll x(n), y(n);
		for(int i=0;i<n;i++) cin >> x[i] >> y[i];

		ll d2=d*d;
		int ans=0;
		for(int i=0;i<n;i++)
		{
			if(x[i]*x[i]+y[i]*y[i]<=d2) ans++;
		}

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


Measured memory_bytes: 6372
n = int(input())
M = list(map(int,input().split()))
Y = list(map(int,input().split()))

c=0
np=0
for i in range(n):
    if M[i]<np :
        c+=M[i]
        np=Y[i]
    elif M[i]<Y[i]+np :
        np = Y[i]+np-M[i]
        c+=M[i] 
    else:
        c+=Y[i]+np
        np = 0 
c+=min(np,M[n])

print(c)

Measured memory_bytes: 24132
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main()

{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	vector <long long> v;
	v.pb(a*c);
	v.pb(a*d);
	v.pb(b*c);
	v.pb(b*d);
	cout<<*max_element(v.begin(),v.end());
	return 0;
}

Measured memory_bytes: 3628
import java.util.*;
import java.io.*;
import java.lang.*;
class Main{
	public static void main(String []args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int h[]=new int[N];
		for(int i=0;i<N;i++) {
			h[i]=sc.nextInt();
		}
		int dp[]=new int[N];
		dp[0]=0;
		for(int j=1;j<N;j++) {
			dp[j]=Integer.MAX_VALUE;
		}
		for(int k=0;k<N;k++) {
			if(k+1<N) {
				dp[k+1]=Math.min(dp[k+1],dp[k]+Math.abs(h[k+1]-h[k]));
			}
			if(k+2<N) {
				dp[k+2]=Math.min(dp[k+2],dp[k]+Math.abs(h[k+2]-h[k]));
			}
		}
		System.out.println(dp[N-1]);
	}
}

Measured memory_bytes: 59408
from collections import deque
 
N = int(input())
numbers = input().split()
 
d = deque()
 
for i in range(N):
    if i % 2 == 0:
        d.append(numbers[i])
    else :
        d.appendleft(numbers[i])
        
if N % 2 == 1:
    d.reverse()
    
output = ' '.join(d)
 
print(output)


Measured memory_bytes: 26564
#include <bits/stdc++.h>
using namespace std;
int N,M;
vector<int> g[200001];
bool v[200001];
int dfs(int x){
    v[x]=true;
    int s=1;
    for(int y:g[x])if(!v[y])s+=dfs(y);
    return s;
}
main()
{
    cin>>N>>M;
    for(int i=0;i<M;++i)
    {
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans=0;
    for(int i=1;i<=N;++i)ans=max(ans,dfs(i));
    cout<<ans<<endl;
}

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

int n, A, B, C;
int l[10];
const int INF = 1e+9;

int solve(int i, int a, int b, int c){
    if(i == n){
        if(a == 0 || b == 0 || c == 0)
            return INF;
        else
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
    }
    int res1 = solve(i+1, a, b, c);
    int res2 = solve(i+1, a + l[i], b, c) + 10;
    int res3 = solve(i+1, a, b + l[i], c) + 10;
    int res4 = solve(i+1, a, b, c + l[i]) + 10;
    return min({res1, res2, res3, res4});
}

int main(){
    cin >> n >> A >> B >> C;
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    cout << solve(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

// change minimumのこと
// a>bならばaにbを代入し、trueを返す
// 他の場合はfalseを返す
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 long long INF = 1LL << 60;
const long long P = 1000000007;
const int  MAX_N = 110000;

int main() {
int n;
cin >> n;
int dp[MAX_N];
for(int i = 0; i < MAX_N; i++) {
  dp[i] = n;
}
dp[0] = 0;
for(int i = 1; i <= n; i++) {
  for(int pow6 = 1; pow6 <= i; pow6 *= 6) {
    dp[i] = min(dp[i], dp[i-pow6] + 1);
  }
  for(int pow9 = 1; pow9 <= i; pow9 *= 9) {
    dp[i] = min(dp[i], dp[i-pow9] + 1);
  }
}
cout << dp[n] << endl;
return 0;
}

Measured memory_bytes: 640
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n, b, c;
vector<int> a;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    int ans = 1;
    int mina=a[0];
    for(int i=1;i<n;i++){
        if(a[i]<mina){
            mina=a[i];
            ans++;
        }
    }
    cout << ans << "\n";
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

struct Edge {
    ll from;
    ll to;
    ll w;
};

ll solve() {
    ll N, M;
    cin >> N >> M;
    vector<Edge> es(M);
    ll a, b, c;
    for ( int i = 0; i < M; i++ ) {
        cin >> a >> b >> c;
        a--, b--;
        es[i] = Edge{a, b, c};
    }
    vector<ll> d(N, -INF);
    d[0] = 0;
    for ( int n = 0; n < N; n++ ) {
        for ( auto e : es ) {
            if ( d[e.from] == -INF ) continue;
            d[e.to] = max(d[e.to], d[e.from] + e.w );
        }
    }
    ll d1 = d[N-1];
    for ( int n = 0; n < N; n++ ) {
        for ( auto e : es ) {
            if ( d[e.from] == -INF ) continue;
            d[e.to] = max(d[e.to], d[e.from] + e.w );
        }
    }
    if ( d1 < d[N-1] ) return INF;
    return d1;
}

int main() {
    auto ans = solve();
    if ( ans == INF ) cout << "inf" << "\n";
    else cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	void run(){
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();
			int e = sc.nextInt();
			int f = sc.nextInt();
			
			double x = 0;
			double y = 0;
			
			try{
				y = (double)(c*d-a*f)/(b*d-a*e);
				x = (double)(c-b*y)/a;
			}catch(Exception ex){
				// error
			}
			
			System.out.printf("%.3f %.3f\n", x, y);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 18372
package main

import "fmt"

func main(){
	var A [3][3] int
	var N int
	var a [3][3] bool

	for i := 0 ; i < 3 ; i++ {
		for j := 0 ; j < 3 ; j++ {
			fmt.Scan(&A[i][j])
		}
	}
	fmt.Scan(&N)

	b := make([]int, N)
	
	for i := 0 ; i < N ; i++ {
		fmt.Scan(&b[i])
	}

	for k := 0 ; k < N ; k++ {
		for i := 0 ; i < 3 ; i++ {
			for j := 0 ; j < 3 ; j++{
				if A[i][j] == b[k] {
					a[i][j] = true
				}
			}
		}
	}
	var tate, yoko [3] int
	var naname  int
	for i := 0 ; i < 3 ; i++ {
		if a[i][0] == true {tate[0]++}
		if a[i][1] == true {tate[1]++}
		if a[i][2] == true {tate[2]++}
		if a[0][i] == true {yoko[0]++}
		if a[1][i] == true {yoko[1]++}
		if a[2][i] == true {yoko[2]++}
	}
	if (a[0][0] == true && a[1][1] == true && a[2][2] == true) || (a[0][2] == true && a[1][1] == true && a[2][0] == true) {
		naname++
	}

	if tate[0] == 3 || tate[1] == 3 || tate[2] == 3 || yoko[0] == 3 || yoko[1] == 3 || yoko[2] == 3 || naname > 0 {
		fmt.Println("Yes")
	}else {
		fmt.Println("No")
	}
	//fmt.Println(a)
	// for i := 0 ; i < 3 ; i++ {
	// 	for j := 0 ; j < 3 ; j++ {
	// 		fmt.Print(a[i][j])
	// 	}
	// 	fmt.Println()
	// }
	//fmt.Println(tate, yoko)
}

Measured memory_bytes: 512
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long k =sc.nextLong();
    String s = sc.next();
    long len = s.length();
    if(len<=k)
      System.out.println(s);
    else{
     for(int i=0;i<k;i++)
       System.out.print(s.charAt(i));
       System.out.print("...");
    }
   
  }
}

Measured memory_bytes: 35604
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,a,b;
	string ans[2]={"Alice","Borys"};
	cin>>n>>a>>b;
	int nim=b-a+1;
	cout<<ans[((nim^1)&1)]<<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);
        // 入力
        String s = sc.next();

        // 出力
        if (s.equals("ABC")) {
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
    }
}


Measured memory_bytes: 35424
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[][] map=new int[3][n+1];
    int cnt=0;
    int max=0;
    for(int i=1;i<3;i++)
      for(int j=1;j<=n;j++)
        map[i][j]=sc.nextInt();
    int kari=map[1][1];
    for(int tate=1;tate<=n;tate++){
      cnt=1;
      for(int j=1;j<=n;j++){
        if(tate==j) {
          cnt=2;
          if(tate!=1&&cnt==2) kari+=map[1][j];
        }
        kari+=map[cnt][j];
      }
      if(kari>max) max=kari;
      kari=0;
    }
    if(max>kari) System.out.println(max);
    else System.out.println(kari);
  }
}

Measured memory_bytes: 21844
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    S = get_input()

    def is_palindrome(s):
        if len(s) == 1:
            return True
        else:
            first = s[:len(s)//2]
            last = s[len(s)//2 + 1:]
            return s == s[::-1] and first == first[::-1] and last == last[::-1]

    if is_palindrome(S):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 12520
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();    
    int[] a = new int[N+1];
    for (int i = 1; i <= N; i++) {
      a[i] = sc.nextInt();
    }
    
    int[] box = new int[N+1];
    
    // N -> N/2
    for (int i = N; i > N/2; i--) {
      box[i] = a[i];
    }
    // N/2 -> 1
    for (int i = N/2; i >= 1; i--) {
      int sum = 0;
      int j = 2;
      while (j*i <= N) {
        sum += box[j*i];
        j++;
      }
      if (sum % 2 == a[i]) {
        box[i] = 0;
      } else {
        box[i] = 1;
      }
    }
    
    int M = 0;
    StringBuilder builder = new StringBuilder();
    for (int i = 1; i <= N; i++) {
      if (box[i] == 1) {
        M++;
        builder.append(i).append(' ');
      }
    }
    
    System.out.println(M);
    System.out.println(builder.toString());
 }
}

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

int main(int argc, char *argv[]) {
  char s[9], *p;
  int n, i, j;

  scanf("%d", &n);
  while (n--) {
    int d[10] = {0};
    int low = 0, high = 0;
  
    scanf(" %s", s);
    
    for (p = s; *p != '\0'; ++p)
      ++d[*p - '0'];

    for (i = 0; i < 10; ++i)
    for (j = 0; j < d[i]; ++j)
      low = low * 10 + i;
    for (i = 9; i >= 0; --i)
    for (j = 0; j < d[i]; ++j)
      high = high * 10 + i;

    printf("%d\n", high - low);
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1748
#include <stdio.h>
#include <string.h>

int main(void)
{
    int bar[101];
    int e;
    int i;

    memset(bar, 0, sizeof(bar));
    for (i = 0; i < 12; i++){
        scanf("%d", &e);
        bar[e]++;
    }
    
    for (i = 1; i < 100; i++){
        if (bar[i] % 4 != 0){
            break;
        }
    }
    if (i == 100){
        printf("yes\n");
    }
    else {
        printf("no\n");
    }
    
    return (0);
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxV = 90010;

 
const int maxN = 2e5+10;

const int INF = 1e9+6;
const int MOD = 1e9+7;


int n,k;
int a[maxN];
int b[maxN];
int main() {
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i] = a[i];
	}
	multiset<int> H;
	int cnt = 0;
	for(int i=2;i<n;i++)
	{
		if(H.size()<(k-1))
		{
			H.insert(a[i]);
			if(H.size() == (k-1))
			{
				if(*H.begin()>a[i-k+1] && *H.rbegin()<a[i+1])
				{
					cnt++;
					continue;
				}
			}
		}
		else
		{
			int x = a[i-k+1];
			auto it = H.lower_bound(x);
			H.erase(it);
			H.insert(a[i]);
			if(*H.begin()>a[i-k+1] && *H.rbegin()<a[i+1])
			{
				cnt++;
			}
		}
	}
	int cnt1 = 0;
	int tmp = 0;
	for(int i=2;i<=n;i++)
	{
		if(a[i]>a[i-1])
		{
			tmp++;
		}
		else
		{
			if(tmp >= (k-1))
				cnt1++;
			tmp = 0;
		}
	}
	if(tmp >= (k-1))
		cnt1++;
	int ans = (n-k+1-cnt);
	if(cnt1 >= 1)
	{
		ans -= (cnt1-1);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, M;
        public int[] D;
        public long MOD = 1000000007;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                M = line[1];
            }

            D = new int[10];
            for (int i = 0; i < D.Length; i++)
            {
                D[i] = -1;
            }

            int[] candidates = Input.ReadIntArray();
            Array.Sort(candidates);
            int[] pieces = new[] { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
            {
                foreach (var a in candidates)
                {
                    
                    D[pieces[a]] = a;
                }
            }

            int[] DP= new int[N+1];
            for (int i = 0; i <= N; i++)
            {
                DP[i] = -1;
            }
            DP[0] = 0;

            for (int i = 0; i <= N; i++)
            {
                for (int d = 0; d <= 9; d++)
                {
                    if (D[d] != -1 && i >= d && DP[i - d] != -1)
                    {
                        DP[i] = Math.Max(DP[i], DP[i - d] + 1);
                    }
                }
            }

            {
                int i = N;
                while (i > 0)
                {
                    foreach (var a in candidates.Reverse())
                    {
                        int d = pieces[a];
                        if (i >= d && DP[i - d] == DP[i] - 1)
                        {
                            Console.Write(a);
                            i -= d;
                            break;
                        }
                    }
                   
                }
            }
            Console.WriteLine();

        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396
#include<stdio.h>
#include<string.h>
#define N 200000

typedef struct{
  int time;
  char name[10];
}Process;

int main(){
  Process Pro[N],take;
  int i,loop,quan;
  int first=0,last;
  int sum=0;
  
  scanf("%d %d",&loop,&quan);
  last=loop;
  for(i=0;i<loop;i++){
    scanf("%s %d",Pro[i].name,&Pro[i].time);
  }
  
  while(first!=last){
    take=Pro[first%N];
    first++;
    if(take.time>quan){
      Pro[last%N].time=take.time-quan;
      strcpy(Pro[last%N].name,take.name);
      last++;
      sum+=quan;
    }
    
    else if(take.time<=quan){
      sum+=take.time;
      printf("%s %d\n",take.name,sum);
    }
  }
  
  return 0;
}



Measured memory_bytes: 4676
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

vector<pair<long long, long long> > soin(long long n)
{
    long long s = floor(sqrt(n));

    vector<pair<long long, long long> > res;

    for(long long i = 2; i <= s; i++){
        if(n % i == 0){
            long long r = 0;
            while(n%i == 0){
                r++;
                n /= i;
            }
            res.push_back(make_pair(i, r));
        }
    }
    if(n > s) {
        res.push_back(make_pair(n, 1));
    }
    return res;
}

int canPick(map<int, int> &so, vector<int> &pick, int pc)
{
    if(pc < 0){
        return 1;
    }

    int sum = 0;
    for(map<int, int>::iterator it = so.begin(); it != so.end(); it++){
        if((*it).second >= pick[pc]){
            int tmp = (*it).second;
            (*it).second = 0;
            sum += canPick(so, pick, pc -1);
            (*it).second = tmp;
        }
    }

    return sum;
}


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

    vector<pair<long long, long long> > vt;
    for(int i = 1; i <= n; i++){
        vector<pair<long long, long long> > tmp = soin(i);
        vt.insert(vt.end(), tmp.begin(), tmp.end());
    }

    map<int, int> so;
    for(int i = 0; i < vt.size(); i++){
        map<int, int>::iterator it = so.find(vt[i].first);
        if(it == so.end()){
            so[vt[i].first] = 0;
        }
        so[vt[i].first] += vt[i].second;
    }
    /*
    for(map<int, int>::iterator it = so.begin(); it != so.end(); it++){
        printf("DD %d %d\n", (*it).first, (*it).second);
    }
    */

    int ans = 0;
    vector<int> v7;
    v7.push_back(74);
    ans += canPick(so, v7, 0);


    vector<int> v515;
    v515.push_back(4);
    v515.push_back(4);
    v515.push_back(2);
    ans += canPick(so, v515, 2)/2;

    vector<int> v5;
    v5.push_back(14);
    v5.push_back(4);
    ans += canPick(so, v5, 1);

    vector<int> v2;
    v2.push_back(24);
    v2.push_back(2);
    ans += canPick(so, v2, 1);

    printf("%d\n", ans);
    return 0;
}

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

const int N=1e5+5;
int n,cnt[N],par[N],depth[N];
vector<int> adj[N];

void dfs(int u,int p){
	cnt[u]=1;
	for(int v:adj[u])
		if(v!=p){
			par[v]=u;
			depth[v]=depth[u]+1;
			dfs(v,u);
			cnt[u]+=cnt[v];
		}
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(int i=0;i<n-1;++i){
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(1,-1);
	int v=n;
	for(int i=0;i<(depth[n]-1)/2;++i) v=par[v]; //wtf did i put here??
	if(2*cnt[v]<n) cout<<"Fennec\n";
	else cout<<"Snuke\n";
}




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

using namespace std;

int main() {
  string S;
  
  cin >> S;
  
  if (S[S.size() - 1] == 's') {
    S += "es";
  } else {
    S += "s";
  }
  
  cout << S << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#include <set>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> //fixed << setprecision(10)

using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

typedef long long ll;
typedef vector<int> vi;

int main(){
    int n, k;
    cin >> n >> k;
    vi cnt(n);
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        cnt[a-1]++;
    }

    sort(cnt.begin(), cnt.end());
    reverse(cnt.begin(), cnt.end());
    int pass = 0;
    for(int i = 0; i < k; i++){
        pass += cnt[i];
    }

    cout << n - pass << endl;
    return 0;
}

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

tmp = A[0]
index = 1
while tmp < 10**18 and index < N:
    tmp *= A[index]
    index += 1

A.sort()

if A[0] == 0:
    print(0)
elif tmp > 10**18:
    print(-1)
else:
    print(tmp)


Measured memory_bytes: 21792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#ifdef TEST
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#endif
#define ins insert
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define g0(a) get<0>(a)
#define g1(a) get<1>(a)
#define g2(a) get<2>(a)
#define g3(a) get<3>(a)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef double db;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef tuple<int, int, int, int> iiii;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pair<int, int>, null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int X, K, D;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> X >> K >> D;
	if (X < 0) X = -X;
	int op = min(K, X / D);
	X -= op * D;
	K -= op;
	if (!K) return cout << X << '\n', 0;
	if (K & 1) X -= D;
	cout << llabs(X) << '\n';
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    vl a(n);
    ll sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    if(sum % (n*(n+1)/2) != 0) puts("NO");
    else{
        ll cnt = sum / (n*(n+1)/2);
        ll counter = cnt;
        ll dis = a[0] - a[n-1];
        if((cnt - dis) % n != 0 || cnt - dis < 0){
            puts("NO");
            return 0;
        }
        counter -= (cnt - dis) / n;
        rep(i,n-1){
            dis = a[i+1] - a[i];
            //cout << (cnt-dis)/n << endl;
            if((cnt - dis) % n != 0 || cnt - dis < 0){
                puts("NO");
                return 0;
            }
            counter -= (cnt - dis) / n;
        }
        if(counter == 0) puts("YES");
        else puts("NO");
        //cout << cnt << counter << endl;
    }
}


Measured memory_bytes: 1024
#include<stdio.h>
int value1(int A);
int value2(int B);
int main(){
int x,a,b,A,B;
scanf("%d %d %d",&x,&a,&b);
A=(x-a);
B=(x-b);
value1(A);
value2(B);
if(value1(A)>value2(B)){
    printf("B\n");
}
else{
    printf("A\n");
}
return 0;
}
int value1(int A){
if(A<0)
return(A*-1);
else
return(A);
}
int value2(int B){
if(B<0)
return(B*-1);
else
return(B);
}





Measured memory_bytes: 1660