akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 400005
#define inf 0x7fffffff
using namespace std;

struct E {int next, to, dis;} e[N];
int n, m, num, flag, cnt;
int h[N], a[N], pos[N], obj[N];
bool vis[N];

int read()
{
	int x = 0; char c = getchar();
	while(c < '0' || c > '9') c = getchar();
	while(c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
	return x;
}

void add(int u, int v, int w)
{
	e[++num].next = h[u];
	e[num].to = v;
	e[num].dis = w;
	h[u] = num;
}

void dfs(int x)
{
	if(flag) return;
	vis[x] = 1;
	for(int i = h[x]; i != 0; i = e[i].next)
	{
		int t = pos[x] + e[i].dis;
		if(pos[e[i].to] == inf) pos[e[i].to] = t, dfs(e[i].to);
		else if(t != pos[e[i].to]) {flag = 1; return;}
	}
}

int main()
{
	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		int a = read(), b = read(), c = read();
		add(a, b, c), add(b, a, -c);
		pos[a] = pos[b] = inf;
		obj[++cnt] = a, obj[++cnt] = b;
	}
	sort(obj + 1, obj + 1 + cnt);
	cnt = unique(obj + 1, obj + 1 + cnt) - obj - 1;
	for(int i = 1; i <= cnt; i++)
		if(!vis[obj[i]])
		{
			flag = 0;
			pos[obj[i]] = 0;
			dfs(obj[i]);
			if(flag) {cout << "No"; return 0;}
		}
	cout << "Yes";
	return 0;
}

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

int main(){
	int h,w,n;
	cin>>h>>w>>n;
	vector<int>v;
	for(int i=0;i<n;++i){
		int a;
		cin>>a;
		for(int j=0;j<a;++j){
			v.push_back(i+1);
			//cout<<i+1<<endl;
		}
	}
	for(int i=0;i<h;++i){
		for(int j=0;j<w-1;++j){
			if(i%2)printf("%d ",v[(w-j-1)+i*w]);
			else printf("%d ",v[j+i*w]);
		}
		if(i%2)printf("%d\n",v[i*w]);
		else printf("%d\n",v[w-1+i*w]);
	}
}

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

int main(){
    long long n;
    long long a[200001];
    cin>>n;
    for(int i=1;i<=n;i++){
        a[i]=0;
    }
    for(int i=2;i<=n;i++){
        long long temp;
        cin>>temp;
        a[temp]++;
    }
    for(int i=1;i<=n;i++){
        cout<<a[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5188
N, M = map(int, input().split())
lst_A = list(map(int, input().split()))
lst_BC = [list(map(int, input().split())) for _ in range(M)]


lst_A.sort()
lst_BC.sort(key=lambda x:-x[1])


lst_D = []
add_num = N
for b, c in lst_BC:
    lst_D += [c] * min(b, N - len(lst_D))
lst_D = lst_D + [0] * (N - len(lst_D))


for i in range(N):
    if lst_A[i] >= lst_D[i]:
        break
    lst_A[i] = lst_D[i]


print(sum(lst_A))

Measured memory_bytes: 36088
from collections import defaultdict
N,W=map(int,raw_input().split())
wv=[]

for i in range(N):
	w,v=map(int,raw_input().split())
	wv.append((w,v))


dp=defaultdict(lambda: 0)	# Weight:Value
dp[0]=0

for w1,v1 in wv:
	d=dp.copy()
	for w,v in dp.items():
		dp[w+w1]=max( dp[w+w1], d[w]+v1 )


l1=filter(lambda x:x[0]<=W , dp.items())
print sorted(l1, key=lambda x: x[1],reverse=True)[0][1]


Measured memory_bytes: 5364
#include <stdio.h>

int main(void)
{
int a, b, c, count = 0;

scanf("%d %d %d", &a, &b, &c);

while (a <= b)
{
if (c % a == 0)
{
count++;
}
a++;
}

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

Measured memory_bytes: 596
//43
#include<iostream>
#include<algorithm>
#include<map>

using namespace std;

int main(){
  for(int x,y;cin>>x>>y,x|y;){
    char g[20][20];
    int sx,sy;
    for(int i=0;i<y;i++){
      for(int j=0;j<x;j++){
	cin>>g[i][j];
	if(g[i][j]=='P'){
	  sy=i;
	  sx=j;
	  g[i][j]='.';
	}
      }
    }
    int n;
    cin>>n;
    int d[8],s[8],e[8]={};
    map<char,int> m;
    for(int i=0;i<n;i++){
      char gc;
      cin>>gc;
      int x=m.size();
      m[gc]=x;
      cin>>d[x]>>s[x]>>e[x];
    }
    static int dp[101][20][20][1<<8];
    fill(dp[0][0][0],dp[101][0][0],1<<31);
    dp[0][sy][sx][0]=0;
    for(int i=0;i<100;i++){
      for(int j=0;j<y;j++){
	for(int k=0;k<x;k++){
	  for(int l=0;l<1<<n;l++){
	    int c=dp[i][j][k][l];
	    int t=l;
	    int dr[]={0,1,0,-1,0};
	    for(int o=0;o<4;o++){
	      int dy=j+dr[o];
	      int dx=k+dr[o+1];
	      if(dy<0||y<=dy||dx<0||x<=dx)continue;
	      if(g[dy][dx]!='.'){
		int gn=m[g[dy][dx]];
		if(!(t>>gn&1)&&s[gn]<=i&&i<e[gn]){
		  c+=d[gn];
		  t|=1<<gn;
		}
	      }
	    }
	    for(int o=0;o<4;o++){
	      int dy=j+dr[o];
	      int dx=k+dr[o+1];
	      if(dy<0||y<=dy||dx<0||x<=dx||g[dy][dx]!='.')continue;
	      dp[i+1][dy][dx][t]=max(dp[i+1][dy][dx][t],c);
	    }
	  }
	}
      }
    }
    cout<<*max_element(dp[100][0][0],dp[101][0][0])<<endl;
  }
  return 0;
}

Measured memory_bytes: 41596
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template <class T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	for (const auto& e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& st) {
	for (const auto& e : st) os << e << " ";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const map<T1, T2>& mp) {
	for (const auto& e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T&& h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head&& h, Tail&&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> A(N);
	vector<Int> cnt(N + 1);
	vector<Int> comb(N + 1);

	Int a;
	for (Int i = 0; i < N; i++) {
		cin >> a;
		A[i] = a;
		cnt[a]++;
	}

	for (Int i = 0; i < N+1; i++) {
		if (cnt[i]<2) {
			comb[i] = 0;
		}
		else {
			comb[i] = cnt[i] * (cnt[i] - 1) / 2;
		}
	}

	Int sum = 0;
	for (Int i = 0; i < N+1; i++) {
		sum += comb[i];
	}

	DMP(cnt, comb,sum);

	//答え
	Int ans;
	for (Int i = 0; i < N; i++) {
		ans = sum;
		ans -= comb[A[i]];
		if (cnt[A[i]]>2) {
			ans += (cnt[A[i]] - 1) * (cnt[A[i]] - 2) / 2;
		}
		cout << ans << "\n";
	}


}


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

namespace _0114
{
	class Program
	{
		public static long Lcm(long a, long b)
		{
			return a / Gcd(a, b) * b;
		}

		public static long Gcd(long a, long b)
		{
			long max = Math.Max(a, b); long min = Math.Min(a, b);
			while (min != 0)
			{
				var remainder = max % min;
				max = min;
				min = remainder;
			}
			return max;
		}
		static void Main(string[] args)
		{
			while (true)
			{
				long[] x = Console.ReadLine().Split().Select(long.Parse).ToArray();
				if (x.Max() == 0) break;
				long[] ret = new long[3];
				for (int i = 0; i < 3; i++)
				{
					ret[i] = 1;
					long where = x[i * 2] % x[i * 2 + 1];
					while (where != 1)
					{
						where = where * x[i * 2] % x[i * 2 + 1];
						ret[i]++;
					}
				}
				Console.WriteLine(Lcm(ret[0], Lcm(ret[1], ret[2])));
			}
		}
	}
}


Measured memory_bytes: 8172
#include <bits/stdc++.h>
#define fi first
#define se second
#define For(i, a, b) for (int i = (a); i <= (b); ++i)
#define Ford(i, a, b) for(int i = (a); i >=(b); --i)
#define endl '\n'
#define debug(a) cout << a << endl
using namespace std;
 
typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
 
const ll maxN = 1e18;
const ll minN = -1e18;
const ll MOD = 1e9 + 7;
 
const ll limit = 2e5 + 5;
const ll limit1 = 1e6 + 5;
const ll limit2 = 1e3 + 5;

ll test;
ll k;
ll res = 0, sum = 0, ans = 0, kd, hkd;


void FastIn(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

ll Solve(ll k){
    For(i, 1, k)
        For(j, 1, k)
            For(h, 1,k)
                res += __gcd(__gcd(i,j), h);
    
    return res;
}

void ReadIn(){
    cin >> k;
    cout << Solve(k);
}
int main(){
    FastIn();
    ReadIn();
}
    

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

int main() {
  int x,y,z,a;
  cin >> x;
  cin >> y;
  cin >> z;
  a = y;
  y = x;
  x = a;
  a = z;
  z = x;
  x = a;
  cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = [""] * n
b = [""] * m
for i in range(n):
    a[i] = input()
for i in range(m):
    b[i] = input()
ans = False
for i in range(n-m+1):
    for j in range(n-m+1):
        tmp = True
        for k in range(m):
            if b[k] != a[i+k][j:m+j]:
                tmp = False
        if tmp:
            ans = True
if ans:
    print("Yes")
else:
    print("No")

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;
const ll INF = 10010010010010010;

struct edge {int from, to; ll cost;};

edge es[5000];  // E_MAX
ll d[2500];     // V_MAX
int V,E;

void bellman_ford(int s) {
    for (int i = 0; i < V; i++) d[i] = INF;
    d[0] = 0;
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < E; j++) {
            edge e = es[j];
            if (d[e.from] != INF && d[e.from] + e.cost < d[e.to]) {
                d[e.to] = d[e.from] + e.cost;
            }
        }
        //printf("%d回目\n", i+1); rep(j,V) printf("%lld ", d[j]); printf("\n");
    }
}


int main() {
    ll p; cin >> V >> E >> p;
    ll a,b,c;
    rep(i,E) {
        cin >> a >> b >> c;
        a--; b--; c -= p;
        es[i].from = a;
        es[i].to = b;
        es[i].cost = -c;
    }
    bellman_ford(0);
    ll ans = d[V-1];
    rep(i,V) {
        rep(j,E) {
            edge e = es[j];
            if (d[e.from] != INF && d[e.from] + e.cost < d[e.to]) {
                d[e.to] = -INF;
            }
        }
        //printf("%d回目\n", i+1);
        //rep(j,V) printf("%lld ", d[j]);
        //printf("\n");
        if (ans > d[V-1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << max(0ll, -ans) << endl;

    return 0;
}


Measured memory_bytes: 3728
#![allow(unused_imports, non_snake_case)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

#[fastout]
fn main() {
    input!{
        n: usize,
        a: [usize; n]
    }
    const MOD: usize = 1_000_000_007;
    let mut s = 0;
    let mut t = 0;
    for &x in &a {
        s = (s + x) % MOD;
        t = (t + x * x) % MOD;
    }
    let ans = (s * s - t) % MOD;

    println!("{}", ans * 500_000_004 % MOD);
}


Measured memory_bytes: 5572
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import           Unsafe.Coerce

main :: IO ()
main = do
    [n, x] <- map read.words <$> getLine :: IO [Int]
    xs <- U.unfoldrN n (C.readInt.C.dropWhile isSpace) <$> C.getLine
    print $ solve x xs

solve :: Int -> U.Vector Int -> Int
solve x xs = U.foldl' gcd 0 $ U.map (subtract x) xs

-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

Measured memory_bytes: 2940
n = input()
N = input()

N = N.split(" ")
Ni = []
for i in N:
    Ni.append(int(i))

cnt = 0
for i in range(int(n) - 2):
    if (min(Ni[i], Ni[i+2]) < Ni[i+1]) and (max(Ni[i], Ni[i+2]) > Ni[i+1]):
        cnt = cnt + 1
print(cnt)

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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) {
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a, a + n);

    ll ans = 0;
    rep(i, n) ans += abs(a[i] - a[n / 2]);
    cout << ans << endl;
    return 0;
}


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

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

  if(s.at(2) == s.at(3) && s.at(4) == s.at(5))
    cout << "Yes";
  else
  {
    cout << "No";
  }

}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main()
{
    int n,w;
    cin >> n >> w;
    int weight[n];
    int val[n];
    for (int q = 0; q < n; q++)
    {
        cin >> weight[q] >> val[q];
    }
    int dp[n*1000+1][n];
    for (int q = 0; q < n; q++)
    {
        for (int w = 0; w < n*1000+1; w++)
        {
            if (q==0)
            {
                if (w==0)
                {
                    dp[w][q]=0;
                }
                else
                {
                    if (w <= val[q])
                    {
                        dp[w][q]=weight[q];
                    }
                    else
                    {
                        dp[w][q]=1e9+7;
                    }
                }
            }
            else
            {
                dp[w][q]=dp[w][q-1];
                if (w-val[q]<=0)
                {
                    dp[w][q]=min(dp[w][q], weight[q]);
                }
                else
                {
                    dp[w][q]=min(dp[w][q], dp[w-val[q]][q-1]+weight[q]);
                }
            }

        }
    }
    //cout << weight[0] << endl;
    //cout << dp[1000][0] << endl;
    for (int q = n*1000; q >= 0; q--)
    {
        //cout << dp[q][n-1] << endl;
        if (dp[q][n-1]<=w)
        {
            cout << q;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 39296
n, m=map(int, input().split())
l=[]
for i in range(n):
  l.append(list(map(int, input().split())))
l = sorted(l, reverse=False)  
#print(l)
drinks=0
ttl=0
add=0
for i in range(n):
  add=min(m-drinks, l[i][1])
  ttl=ttl+add*l[i][0]
  drinks+=add
  if drinks==m:
    print(ttl)
    exit()


Measured memory_bytes: 28284
#include<stdio.h>
#include<math.h>
int N,T,i;
char f[999];
double R=0;

int main()
{
	scanf("%lld%lld\n%s",&N,&T,f);
	for(i=0;f[i];i++)
		if('0'<=f[i]&&f[i]<='9')
			R+=pow(N*1.0,f[i]-'0');
	if(R*T-1000000000>=0.000000001)
		puts("TLE");
	else
		printf("%.0f\n",R*T);
	return 0;
}

Measured memory_bytes: 672
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var t = mutableMapOf<String, Int>()
    for(i in 0 until n){
        val i = readLine()!!
        if(t.keys.contains(i)){
            t[i] = t[i]?.plus(1) ?: 1
        }else{
            t[i] = 1
        }
    }

    val e = t.values.max()

    for((k, v) in t.toSortedMap()){
        if(v >= e!!){
            println(k)
        }
    }
}


Measured memory_bytes: 96172
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()


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

struct edge{
    int to;
    int dist;
};

vector<bool> seen(100000, false);
vector<int> pnt(100000, INF);
vector<vector<edge>> G(100000);
int n, m;
bool f = true;


void dfs(int v, int dist){
    seen[v] = true;
    if(pnt[v] == INF)pnt[v] = dist;
    else {
        if(pnt[v] != dist)f = false;
        return;
    }

    for(int i = 0; i < (int)(G[v].size()); i++){
        edge e = G[v][i];
        if(pnt[e.to] != INF && pnt[e.to] != pnt[v] + e.dist){
            f = false;
            return;
        }
        if(seen[e.to])continue;
        dfs(e.to, e.dist + pnt[v]);
    }
}

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> rui(n + 1, 0);
    rep(i, n){
        ll a;
        cin >> a;
        rui[i + 1] = rui[i] + a;
    }
    ll res = 0;
    REP(i, 1, n){
        rui[i] %= m;
        if(rui[i] == 0)res++;
    }
    map<ll, ll> mp;
    REP(i, 1, n)mp[rui[i]]++;

    for(auto m : mp){
        res += m.second * (m.second - 1) / 2;
    }
    cout << res << endl;
}


Measured memory_bytes: 7680
/* 
 * Project: AtCoder Beginners Contest 161 B - Popular Vote
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/04
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <string>
#include <numeric>
#include <algorithm>
#include <vector>
using namespace std;

int n, m;
// vector<int> a;
int a[100];

void solve() {

    float sum = 0;
    sum = accumulate(a,a+n,0);
    float border = 0;
    border = sum / (m*4);
    // cout << border << endl;
    sort(a, a+n,greater<int>());
    int cnt = 0;
    while(a[cnt] >= border) {
        cnt++;
    }

    if (cnt >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}

int main() {

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

    solve();

}


Measured memory_bytes: 256
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;
            int[][] set = new int[1000000][];
            string[] op = new string[1000000];


            while (true)
            {
                set[i] = new int[2];
                string[] input = Console.ReadLine().Split(' ');
                set[i][0] = int.Parse(input[0]);
                op[i] = input[1];
                set[i][1] = int.Parse(input[2]);
                if (op[i] == "?") break;
                i++;
            }
            for (int t = 0; t < i; t++)
            {
                switch (op[t]) {
                    case "+":
                        Console.WriteLine(set[t][0]+ set[t][1]);
                        break;
                    case "-":
                        Console.WriteLine(set[t][0] - set[t][1]);
                        break;
                    case "*":
                        Console.WriteLine(set[t][0] * set[t][1]);
                        break;
                    case "/":
                        Console.WriteLine(set[t][0] / set[t][1]);
                        break;
                }
            }
                
        }
    }
}

Measured memory_bytes: 24968
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
   //   String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int[] num=new int[6];
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
int C=Integer.parseInt(nyu);
//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);

switch(C){
case 25:
System.out.println("Christmas") ;
break;
case 24:
System.out.println("Christmas Eve") ;
break;
case 23:
System.out.println("Christmas Eve Eve") ;
break;
case 22:
System.out.println("Christmas Eve Eve Eve") ;
break;
}


	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define lli long long int
#define d double
#define mx 100000
using namespace std;
 
int main() {
	FIO;
	lli n,w;
	cin>>n>>w;
	vector<pair<lli,lli>> vec(n+1);
	for(lli i=1;i<=n;i++){
		lli x,y;
		cin>>x>>y;
		vec[i].first=x;
		vec[i].second=y;
	}
	vector<vector<lli>> dp(n+1,vector<lli>(mx+1,INT_MAX));
	for(int i=0;i<=n;i++) dp[i][0]=0;
	for(lli i=1;i<=n;i++){
		for(lli j=1;j<=mx;j++){
			if(j>=vec[i].second) dp[i][j]=min(dp[i-1][j],vec[i].first+dp[i-1][j-vec[i].second]);
			else dp[i][j]=dp[i-1][j];
		}
	}
	int ans=INT_MIN;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=mx;j++){
			if(dp[i][j]<=w) ans=max(ans,j);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

bool find(vector<string> hoge, string huga){
  for(int i=0;i < (int) hoge.size();i++){
	if(hoge[i]==huga) return true;
  }
 return false;}



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

  while(n>0){
	string str;
	cin >> str;
    vector<string> trains;
	int ans = 1;
	trains.push_back(str);
	// cout << "hoge" << endl;
	for(int i=1;i<((int) str.length());i++){
	  string ftr=str.substr(0,i);
	  string btr=str.substr(i);
	  if(!find(trains,btr+ftr)){
		trains.push_back(btr+ftr);
		ans++;
		// cout << btr+ftr << endl;		
	  }
	  // f + rvs b

	  reverse(btr.begin(),btr.end());
	  if(!find(trains,ftr+btr)){
		trains.push_back(ftr+btr);
		// cout << ftr+btr << endl;
		ans++;
	  }
	  if(!find(trains,btr+ftr)){
		trains.push_back(btr+ftr);
		ans++;
		// cout << btr+ftr << endl;		
	  }
	  
	  // rvs f + rvs b
	  reverse(ftr.begin(),ftr.end());
	  if(!find(trains,ftr+btr)){
		trains.push_back(ftr+btr);
		// cout << ftr+btr << endl;
		ans++;
	  }

	  if(!find(trains,btr+ftr)){
		trains.push_back(btr+ftr);
		// cout << btr+ftr << endl;
		ans++;
	  }

	  // rvs f + b
	  reverse(btr.begin(),btr.end());
	  if(!find(trains,ftr+btr)){
		trains.push_back(ftr+btr);
		// cout << ftr+btr << endl;
		ans++;
	  }
	  if(!find(trains,btr+ftr)){
		trains.push_back(btr+ftr);
		// cout << btr+ftr << endl;
		ans++;
	  }
	}
	cout << ans << endl;
	n--;
  }
  return 0;
}

Measured memory_bytes: 1288
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	long long X;
	cin >> X;

	long long sum = 0;
	long long ans = 0;

	while (sum < X) {
		ans += 1;
		sum += ans;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;
class Main{
	int nisuu;
	int nk,pk,nm,pm;
	int cnt;
	int x,y;
	int ryokin;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		
		nisuu = sc.nextInt();
		for(cnt=0; cnt<nisuu; cnt++){
			nk=sc.nextInt();
			pk=sc.nextInt();
			nm=sc.nextInt();
			pm=sc.nextInt();
			
			ryokin = nk*nm+pk*pm;
			
				if(nm<5){
					nm=5;
				}
				if(pm<2){
					pm=2;
				}
			int yobun = (nk*nm+pk*pm)*8/10;
			
			if(ryokin>yobun){
				System.out.println(yobun);
			}else{
		    System.out.println(ryokin);
			}
		}
	}
	
	public static void main(String[]args){
		Main obj = new Main();
		obj.solve();
		
	}
}

Measured memory_bytes: 23452
Scanf.scanf "%d %d" (fun w h ->
    let p = Array.init w (fun _ -> Scanf.scanf " %d" (fun p -> p)) in
    let q = Array.init h (fun _ -> Scanf.scanf " %d" (fun q -> q)) in
    let r = Array.make (w + h) (0, false) in
    for i = 0 to w - 1 do
        r.(i) <- p.(i), false
    done;
    for i = 0 to h - 1 do
        r.(i + w) <- q.(i), true
    done;
    Array.sort compare r;

    let rec loop i a b acc =
        if i = w + h then acc else
            let (c, flag) = r.(i) in
            if flag then loop (i + 1) a (b - 1) (acc + c * a)
                    else loop (i + 1) (a - 1) b (acc + c * b)

    in
    loop 0 (w + 1) (h + 1) 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 14496
import sys
sys.setrecursionlimit(10**6)

x, y = [int(i) for i in input().split()]

MOD = 10 ** 9 + 7

import functools
import math

def mpow(x, n):
    result = 1
    while n > 0:
        if (n & 1):
            result = (result * x) % MOD
        x = (x * x) % MOD
        n >>= 1
    return result

# 方程式を解けば解が一意に定まるため、全パターンを試すのは無駄
def solver_not_good():
    factorial = [0] * (10 ** 6 + 1)
    inverse = [0] * (10 ** 6 + 1)
    factorial[0] = 1
    inverse[0] = 1
    for i in range(1, 10 ** 6 + 1):
        factorial[i] = (i * factorial[i-1]) % MOD
        inverse[i] = mpow(factorial[i], MOD - 2) % MOD

    total = 0
    twopath_maxnum = x // 2
    for twopath_num in range(twopath_maxnum + 1):
        onepath_num = x - twopath_num * 2
        if (onepath_num * 2 + twopath_num * 1) == y:
            a = factorial[onepath_num + twopath_num]
            b = inverse[onepath_num]
            c = inverse[twopath_num]
            total += (a * b * c) % MOD
    return total

def solver_better():
    # 剰余演算を都度挟みたいため、math.factorialは使えない
    factorial = [0] * (10 ** 6 + 1)
    factorial[0] = 1
    for i in range(1, 10 ** 6 + 1):
        factorial[i] = (i * factorial[i-1]) % MOD

    # x + y が3の倍数でないときは到達できない
    if ((x + y) % 3) != 0:
        return 0

    a = (2 * x - y) // 3
    b = (2 * y - x) // 3

    # x座標/y座標のどちらかに先に到達してしまう
    if a < 0 or b < 0:
        return 0

    return (factorial[a+b] * (mpow(factorial[a], MOD - 2) % MOD) * (mpow(factorial[b], MOD -2) % MOD)) % MOD

solver = solver_not_good
#solver = solver_better
print(solver())


Measured memory_bytes: 58204
#include <algorithm>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>

using namespace std;

// UnioFind
class UnionFind {
  int n;
  vector<int> par;
  vector<int> rank;
  vector<long long> c;

public:
  UnionFind(int x) {
    n = x;
    par.resize(n + 1);
    rank.resize(n + 1);
    c.resize(n + 1);
  };

  void init() {
    for (int i = 0; i <= n; i++) {
      par[i] = i;
      rank[i] = 0;
      c[i] = 1;
    }
  }

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

  long long unite(int x, int y) {
    x = find(x);
    long long cx = c[x];
    y = find(y);
    long long cy = c[y];
    // if (x == y) {
    //   return;
    // }
    if (rank[x] < rank[y]) {
      par[x] = y;
      c[y] = cx + cy;
    } else {
      par[y] = x;
      c[x] = cx + cy;
      if (rank[x] == rank[y]) {
        rank[x]++;
      }
    }
    return cx * cy;
  }

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

void solve(int N, int M, vector<int> A, vector<int> B) {
  vector<long long> ans(M + 1);
  ans[M] = (long long)N * (N - 1) / 2;
  UnionFind uf(N);
  uf.init();

  for (int i = M - 1; i >= 0; i--) {
    int a = A[i];
    int b = B[i];
    if (uf.same(a, b)) {
      ans[i] = ans[i + 1];
    } else {
      long long u = uf.unite(a, b);
      ans[i] = ans[i + 1] - u;
    }
  }
  for (int i = 1; i <= M; i++) {
    printf("%lld\n", ans[i]);
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  vector<int> B(M);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    A[i] = a;
    B[i] = b;
  }
  solve(N, M, A, B);
  return 0;
}

Measured memory_bytes: 5248
/**
*   @author: Kshitiz Srivastava (Pirate_ksh) @ MNNIT Allahabad
*/
#include<bits/stdc++.h>
using namespace std;
 
// General
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define mod_ 998244353 
#define endl "\n"
#define debug(x) cout<<x<<endl
#define REP(i,n) for(i=0;i<n;++i)
#define FOR(i,x,n) for(i=x;i<n;++i)
 
// Bounds
#define lb(a, x) a.lower_bound(x)
#define ub(a, x) a.upper_bound(x)
#define all(a) a.begin(),a.end()
 
// Vector
#define vi vector <int>
#define pb(v, x) v.push_back(x)
#define vsi vector <set <int> >
 
// Map
#define mii map <int, int>
 
// Set
#define si set <int>
 
// Pair
#define vpii vector<pair < int, int > >
#define pii pair < int, int >
#define mp(a,b) make_pair(a,b)
#define F first
#define S second

ll dp[405][405], a[405], N, actu[405][405];
pair<ll,ll> DP(ll i, ll j) {
    if(i >= j) {
        dp[i][j] = actu[i][j] = a[i];
        return mp(0,a[i]);
    }
    if(dp[i][j] != -1) return mp(dp[i][j],actu[i][j]);
    pair<ll,ll> ans = mp((ll)1e18,0);
    for(ll k=i;k<j;++k) {
        pair<ll,ll> p1 = DP(i,k);
        pair<ll,ll> p2 = DP(k+1,j);
        pair<ll,ll> temp_ans = mp(p1.F+p2.F+p1.S+p2.S, p1.S+p2.S);
        if(ans.F > temp_ans.F) ans = temp_ans;
    }
    dp[i][j] = ans.F;
    actu[i][j] = ans.S;
    return ans;
}

int main(){
    io
    ll t;
    t = 1;
    // cin >> t;
    while(t--) {
        cin >> N;
        ll it;
        REP(it,N) cin >> a[it];
        memset(dp, -1, sizeof(dp));
        cout << DP(0,N-1).F << endl;
    }
    return 0;
}



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

int main(){
    int64_t n,a,b ;
    cin >> n >> a >> b;
    vector<int64_t> x(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> x.at(i) ;
    }
    int64_t ans = 0 ;
    for (size_t i = 0; i < n-1; i++)
    {
        if ((x.at(i+1) - x.at(i))*a > b )
        {
            ans += b ;
        }else
        {
            ans += (x.at(i+1) - x.at(i)) * a ;
        }
        
    }
    cout << ans << endl ;
}

Measured memory_bytes: 1024
//Moh_K_Imar .......
//26/08/2020  ... 3,35.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,b;
    cin>>a>>b;
    ll x=a+b;
    ll y=a-b;
    ll z=a*b;
    ll max=x;
    if(y>max)max=y;
    if(z>max)max=z;
    cout<<max<<endl;

    return 0;
}



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

int main()
{
	int e;
	while(cin>>e && e!=0){
		int ans=e;
		for(int z=0;z<e;z++){
			if(z*z*z>e) break;
			for(int y=0;y<e;y++){
				if(z*z*z+y*y>e) break;
				ans=min(ans,z+y+(e-z*z*z-y*y));
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 864
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

ll function(ll n)
{
	string str;
	
	while(n > 0)
	{
		str.PB('0' + n%10);
		n /= 10;
	}
//	cout << str << endl;
	reverse(ALL(str));
//	cout << str << endl;
	int cou = str.size();
	int ret = 0;
	for(int i = 1;i < cou;i++)
	{
		int tmp1 = atoi(str.substr(0,i).c_str());
		int tmp2 = atoi(str.substr(i,str.size()-1).c_str());
		ret = max(ret,tmp1*tmp2);
//		cout << tmp1 << ' ' << tmp2 << endl;
	}
	
	return ret;
}

int main()
{
	int qq;
	cin >> qq;
	
	REP(aaa,qq)
	{
		ll n;
		cin >> n;
		int _out = 0;
		while(n >= 10 && _out < 1000000)
		{
			n = function(n);
			_out++;
		}
		
		if(_out < 1000000)
			cout << _out << endl;
		else
			cout << -1 << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3228
L,N,*x=`dd`.split.map &:to_i
y=[r=0]+x.map{|e|L-e}.reverse
x=[0]+x
sx=[0]
sy=[0]
N.times{|i|sx<<sx[i]+x[i+1];sy<<sy[i]+y[i+1]}
N.times{|i|
	j=N-(i+1)
	k=[(i+1)-1,j].min
	r=[r,x[(i+1)]+2*(sx[(i+1)-1]-sx[(i+1)-k-1]+sy[j]-sy[j-k-(j>k ? 1 : 0)])].max
}
N.times{|i|
	j=N-i
	k=[i,j-1].min
	r=[r,y[j]+2*(sx[i]-sx[i-k-(i>k ? 1 : 0)]+sy[j-1]-sy[j-k-1])].max
}
p r

Measured memory_bytes: 30936
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
   cin>>n;
  long long sum=0;
  for(int i=1;i<=n;i++)
  {
     if(i%3==0||i%5==0||i%15==0)
        continue;
      else
         {
         	sum+=i;
		 }
  }
   cout<<sum<<endl;
  return 0;
}
       


Measured memory_bytes: 3632
def main():
    n, x = map(int, input().split())
    ms = [int(input()) for _ in range(n)]

    x = x - sum(ms)
    min_m = min(ms)
    i = 0
    while True:
        x = x - min_m
        if x < 0:
            break
        i += 1
    ans = n + i
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
from collections import defaultdict
d=defaultdict(lambda: 51)
n=int(input())
for _ in range(n):
    s=input()
    for char in [chr(ord('a') + i) for i in range(26)]:
        d[char] = min(d[char],s.count(char))
ans=""
for char in [chr(ord('a') + i) for i in range(26)]:
    ans += char*d[char]
print(ans)

Measured memory_bytes: 39024
#include <stdio.h>
int main(void){
  int m[3]={},t=0;
  char s[3][101],c;
  scanf("%s\n%s\n%s",s[0],s[1],s[2]);
  while (1){
    if (!s[t][m[t]]) break;
    m[t]++;
    t=(int)s[t][m[t]-1]-97;
  }
  printf("%c\n",(char)(t+65));
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    vector <int> can(n);
    can[0] = 1;
    vector <int> cnt(n, 1);
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        if (can[x]) can[y] = 1;
        --cnt[x];
        ++cnt[y];
        if (cnt[x] == 0) can[x] = 0;
    }
    int res = 0;
    for (int i = 0; i < n; ++i) res += can[i];
    cout << res << '\n';
}   

Measured memory_bytes: 1024
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {
        n:usize,
       mut a:[i64;n*3],
    }
    a.sort_by_key(|&x| -x);
    let mut ans = 0;
    for i in 0..n {
        ans += a[i * 2 + 1];
    }
    println!("{}", ans);
}


Measured memory_bytes: 7700
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
using namespace std;
#define rep(i, s, n) for(int i = s; i < n; i++)
//#define INF pow(10, 9)
static int N = 0;
//long long int INF = pow(10, 9);
int A, B, C;

vector<int> l;

int dfs(int pos, int a, int b, int c) {

    if(pos == N) {
        int ans = 0;
        ans = abs(A-a)+abs(B-b)+abs(C-c)-30;
        
        if(min({a, b, c}) > 0) {

        }
        else {
            return 1000000000;
        }
        
        
        return ans;
    }

    long long int ret1, ret2, ret3, ret4;
    ret1 = dfs(pos+1, a, b, c);
    ret2 = dfs(pos+1, a+l[pos], b, c)+10;
    ret3 = dfs(pos+1, a, b+l[pos], c)+10;
    ret4 = dfs(pos+1, a, b, c+l[pos])+10;

    return min({ret1, ret2, ret3, ret4});
}

int main() {
    int a, b, c;
    cin >> N >> A >> B >> C;

    rep(i, 0, N) {
        int num;
        cin >> num;
        l.push_back(num);
    }

    cout << dfs(0, 0, 0, 0) << endl;
    
}

Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d %d %d %d %d", $w, $h, $x, $y, $r);

$x1 = $w - $x;
$x2 = $x;
$y1 = $h - $y;
$y2 = $y;

if($x1 >= $r && $x2 >= $r && $y1 >= $r && $y2 >= $r)
    echo "Yes"."\n";
else
   echo "No"."\n";


Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define DUMP(v) for(auto& x : v) cerr << x << " "; cerr << endl;
using namespace std;

using ll = long long;

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; }
constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);


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

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<ll> l(n, 0);
  vector<ll> r(n, 0);
  l[0] = a[0];
  for (int i = 1; i < n; i++) l[i] = l[i-1] + a[i];
  r[n-1] = a[n-1];
  for (int i = n-2; i >= 0; i--) r[i] = r[i+1] + a[i];

  ll ans = INFLL;

  for (int i = 1; i < n; i++) {
    chmin(ans, abs(l[i-1] - r[i]));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int x=2;
    int bit=-1;
    string ans="";
    while(N!=0){
        if(N%x!=0){
            N+=bit;
            ans+="1";
        }else ans+="0";
        bit*=-2;
        x*=2;
    }
    if(ans=="") ans="0";
    reverse(ans.begin(),ans.end());
    cout << ans << endl;




}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,a1=0,a2=0,a4=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int t;
		cin>>t;
		if(t%4==0)
			a4++;
		else if(t%2==0)
			a2++;
		else a1++;
	}
	if(a1<=a4&&a2>0)
		cout<<"Yes"<<endl;
	else if(a2==0&&a1<=a4+1)
	cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let _n: usize = parse_line().unwrap();
    let a: Vec<f64> = parse_line().unwrap();
    let length: f64 = a.iter().sum();
    let half = length / 2.0;
    let mut cnt = 0.0;
    let diff;

    for ai in a {
        cnt += ai;
        if cnt >= half {
            diff = (cnt - half).min(half - (cnt - ai));
            println!("{}", (diff * 2.0) as usize);
            break;
        }
    }
}


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


int main()
{
	//freopen("input16.txt","r",stdin);freopen("output16.txt","w",stdout);
	ll n,i,t[1000],a[1000],t1,a1,k1,k2;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>t[i]>>a[i];
	}
	t1=t[0];
	a1=a[0];
	for (i=1;i<n;i++){
		k1=t1%t[i]==0?t1/t[i]:t1/t[i]+1;
		k2=a1%a[i]==0?a1/a[i]:a1/a[i]+1;
		t1=max(k1,k2)*t[i];
		a1=max(k1,k2)*a[i];
	}
	cout<<t1+a1;
	return 0;
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
int kaijou(int n){
    int a=1;
  if(n==0){
    return 1;
  }
    REP(i,n){
        a*=i+1;
    }
    return a;
}
int ncr(int n,int r){
  int a;
  if(n<0||r<0||n<r){
    return 0;
  }
  a=kaijou(n)/kaijou(r)/kaijou(n-r);
  return a;
}
//cout << setprecision(123);
int main(){
  int n,ans=0;
  cin>>n;
  vector<int>v(n);
  REP(i,n)cin>>v[i];
  
  REP(i,n-2){
    if((v[i+1]-v[i])*(v[i+1]-v[i+2])<0)ans++;
  }
  cout<<ans<<endl;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	ll N, ans=0;
	ll A[200005];

	cin >> N;
	rep(i,N) cin >> A[i];

	bool f = false;
	if( A[0] != 0 ) f = true;
	rep(i,N-1) f |= (A[i] + 1 < A[i+1]);

	if(f){
		cout << -1 << endl;
		return 0;
	}

	ll B[200005];
	rep(i,N) B[i] = A[i] - i;

	int cur = -INF;
	rrep(i,N) if( B[i] > cur ){
		ans += A[i];
		cur = B[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
import java.io.PrintWriter
import kotlin.math.PI

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}


fun solve(out: PrintWriter) {
    val r = readInteger()
    println(2 * r * PI)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 34976
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
X = map(int, raw_input().split())
ans = INF
for pos in range(1, 101):
    S = 0
    for x in X:
        S += (x - pos) * (x - pos)
    ans = min(ans, S)
print ans

Measured memory_bytes: 4268
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

int main()
{
	int n = read(),m = read(),x = read();
	printf("%d\n",(x+max(n,m)-1)/max(n,m));
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
A = [min(8, a // 400) for a in A]
CA = Counter(A)
num = 0
for i in range(8):
    if CA[i]:
        num += 1

num_8 = CA[8]
saidai = num + num_8

saisho = max(1, num)
print(saisho, saidai)



Measured memory_bytes: 9360
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#include <iterator>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)


struct It : public iterator<std::forward_iterator_tag, int64_t>
{
    int64_t cur;
    explicit It(int c) : cur(c){}
    It operator + (size_t n) const
    {
        return It(cur + n);
    }
    It & operator += (size_t n)
    {
        cur += n;
        return *this;
    }
    int64_t operator * ()const
    {
        const int64_t r = cur * (cur + 1) / 2;
        dbg << "Cur:" << cur << " Result:" << r << endl;
        return r;
    }
    It & operator++()
    {
        ++cur;
        return *this;
    }
    It operator++(int)
    {
        It i(*this);
        ++cur;
        return i;
    }
    bool operator == (const It &i)const
    {
        return cur == i.cur;
    }
    bool operator != (const It &i)const
    {
        return !(*this == i);
    }
};

int main(int, char *[])
{
    int T;
    cin >> T;

    const auto result = lower_bound(It(0), It(1000000000), T);
    
    cout << result.cur << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
signed main(){
  int a;
  cin>>a;
  cout<<setprecision(14)<<a*2*M_PI<<endl;
}


Measured memory_bytes: 3756
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    val all = modPow(10L, n)
    val ex = modSub(modAdd(modPow(9L, n), modPow(9L, n)), modPow(8L, n))
    val ans = modSub(all, ex)
    println(ans)
}

const val mod = 1000000007L
fun modAdd(a: Long, b:Long):Long = (a + b) % mod
fun modSub(a: Long, b:Long):Long {
    val ret = (a - b) % mod
    return if (ret < 0) ret + mod
    else ret
}
fun modPow(a: Long, b:Long):Long =
    when {
        b == 0L -> 1L
        b == 1L -> a
        b % 2L == 0L -> modPow(a, b / 2L).let { (it * it) % mod }
        else -> (a * modPow(a, b - 1)) % mod
    }



Measured memory_bytes: 34312
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[1000],t[1000],u[1000];
    int a,b,c,i,cnt=0;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    c=strlen(u);
    for(i=0; i<c; i++)
    {
        if(s[i]==u[i])
            cnt++;
    }
    if(cnt==c)
    {
        cout<<(a-1)<<" "<<b<<endl;
    }
    else
    {
        cout<<a<<" "<<(b-1)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a, b = n, 1
V = [False for d in range(1, n + 1)]
for i in range(m):
    d = min(a - b, n - (a - b))
    if 2 * d == n or V[d]:
        a -= 1
    print(a, b)
    d = min(a - b, n - (a - b))
    V[d] = True
    a -= 1
    b += 1


Measured memory_bytes: 10448