akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, sub

sys.setrecursionlimit(10000)

mod = 10**9 + 7


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def mul(a, b):
    return ((a % mod) * (b % mod)) % mod


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        return power(x, y//2)**2 % mod
    else:
        return power(x, y//2)**2 * x % mod


def div(a, b):
    return mul(a, power(b, mod-2))


@mt
def slv(N, A):

    def perm(n):
        p = 1
        for i in range(1, n+1):
            p = mul(p, i)
        return p

    pn = perm(N)
    sp = [0]
    for i in range(1, N+1):
        sp.append((sp[-1] + div(pn, i)) % mod)

    ans = mul(sp[-1], A[0])
    for i in range(1, N):
        ans += mul(sp[i+1] - sp[1], A[i])
        ans %= mod
        ans += mul(sp[N-i] - sp[0], A[i])
        ans %= mod
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 16636
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  printf("%d\n", a.back() - *a.begin());
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using ul = unsigned long long;
using ld = long double;

const int B = 60;
ll b[B], pos[B];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll t, n;
    cin >> t;
    rep(z, t) {
        cin >> n;
        vector<ll> a(n), r;
        string s;
        rep(i, n)
            cin >> a[i];
        cin >> s;
        ll cc = 0, f = 0;
        for (int i = n - 1; i >= 0; i--) {
            ll x = a[i];
            rep(i, cc)
                if (x & (1ll << pos[i]))
                    x ^= b[i];
            if (s[i] == '0') {
                if (x != 0) {
                    ll np = B;
                    while (!(x & (1ll << np)))
                        np--;
                    for (int j = cc; j >= 0; j--) {
                        if (j == 0 || pos[j - 1] > np) {
                            b[j] = x;
                            pos[j] = np;
                            break;
                        }
                        b[j] = b[j - 1];
                        pos[j] = pos[j - 1];
                    }
                    cc++;
                }
            }
            else {
                if (x != 0) {
                    f = 1;
                    break;
                }
            }
        }
        cout << f << '\n';
    }
}



Measured memory_bytes: 3576
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const mod = 1000000007

// 1MB
const ioBufferSize = 1 * 1024 * 1024

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	sc.Split(bufio.ScanWords)
	return sc
}()

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(a, b int) int {
	if a < b {
		return a
	}

	return b
}

func main() {
	n := nextInt()
	b := make([]int, n-1)

	for i := 0; i < n-1; i++ {
		b[i] = nextInt()
	}

	s := b[0] + b[n-2]
	for i := 0; i < n-2; i++ {
		s += min(b[i], b[i+1])
	}

	fmt.Println(s)
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a[214514], b[214514], c[214514], d[214514];
	cin>>n;
	REP(i, n){
		cin>>a[i];
	}
	REP(i, n){
		cin>>b[i];
	}
	int ans=0;
	REP(i, 29){
		int bit=1<<i, bit2=bit<<1;
		REP(j, n){
			c[j]=a[j]&(bit2-1);
			d[j]=b[j]&(bit2-1);
		}
		sort(d, d+n);
		int cnt=0;
		REP(j, n){
			cnt+=lower_bound(d, d+n, bit2-c[j])-lower_bound(d, d+n, bit-c[j]);
			cnt+=lower_bound(d, d+n, (bit2<<1)-c[j])-lower_bound(d, d+n, 3*bit-c[j]);
		}
		if(cnt&1){
			ans^=bit;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>
int main(void){
    int a, b, ans;
    char op;
    while(1){
        scanf("%d %c %d\n", &a, &op, &b);
        if(op == '?'){
            break;
        }else if(op == '+'){
            ans = a + b;
        }else if(op == '-'){
            ans = a - b;
        }else if(op == '*'){
            ans = a * b;
        }else if(op == '/'){
            ans = a / b;
        }
        printf("%d\n", ans);
    }
    // while(scanf("%d %c %d\n", &a, &op, &b), op != '?'){
    //     if(op == '+'){
    //         ans = a + b;
    //     }else if(op == '-'){
    //         ans = a - b;
    //     }else if(op == '*'){
    //         ans = a * b;
    //     }else(op == '/'){
    //         ans = a / b;
    //     }
    //     printf("%d\n", ans);
    // }
}


Measured memory_bytes: 2044
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class BUnevenNumbers {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    int ans = 0;

    for (int i = 1; i <= n; i++) {
        if ((0 <= i and i < 10) or (100 <= i and i < 1000) or (10000 <= i and i < 100000))
            ans++;
    }

    cout << ans << endl;

}
};

int main() {
	BUnevenNumbers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
long long T[MAX];
int n,k;
 
int load(long long P) {
    int i=0,j=0;
    long long t;
    for(i = 0; i < k; i++) {
        t = 0;
        while( t+T[j] <=P) {
            t +=T[j];
            j++;
            if(j==n) return n;  
        }
    }
    return j;   
     
}
 
int solve() {
    long long right = MAX*10000,left=0,mid,s;
     
    while(right>left+1) {
        mid = (right + left)/2;
         s=load(mid);
         if(s>=n) right=mid;
         else left = mid;
    }
        return right;           
}
 
int main(void)
 
{
    int i;
    scanf("%d %d%",&n,&k);
     
    for(i=0; i < n; i++) {
        scanf("%d",&T[i]);
    }
        printf("%llu\n",solve());
        return 0;       
     
     
}


Measured memory_bytes: 2624
def main():
    N = int(input())
    
    array = []
    
    for i in range(N):
        array2 = list(map(int,input().split()))
        array.append(array2)

    num = [[0,0,0] for z in range(N)]
    for m in range(3):
        num[0][m] = array[0][m]

    

    for j in range(1,N):
        
        for z in range(3):
            if z == 0:
                num[j][z] = array[j][z]+max(num[j-1][1],num[j-1][2])
                    
            if z == 1:
                num[j][z] =array[j][z]+max(num[j-1][0],num[j-1][2])
            if z == 2:
                num[j][z] =array[j][z]+max(num[j-1][1],num[j-1][0])
        
    
    print(max(num[-1]))
    
main()

Measured memory_bytes: 47344
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int max=n+m;
		max=Math.max(max, n-m);
		max=Math.max(max, n*m);
		System.out.println(max);
	}
}


Measured memory_bytes: 23252
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define SIZE 100005

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
vector<int> a;
int main()
{
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		int x;
		scanf("%d",&x);
		a.pb(x);
	}
	sort(a.begin(),a.end());
	if(a[N-1]-a[0]>1)cout<<"No"<<endl;
	else if((a[N-1]-a[0])==1){
		int cnt=0;
		for(int i=0;i<N;i++){
			if(a[i]==a[0])cnt++;
		}
		//cout<<cnt<<endl;
		if(a[N-1]<=(cnt+(N-cnt)/2)&&(cnt+1)<=a[N-1])cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}else{
		if(a[0]<=(N/2)||a[0]==N-1)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	cin>>k;
	int n,h,ans=0;
	cin>>n;
	while(k--)
	{
		cin>>h;
		if(h>=n)ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    R = II()
    from math import pi
    print(R*2*pi)

if __name__ == '__main__':
    main()

Measured memory_bytes: 65340
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ss(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define per(i, l, r) for (int i = r; l <= i; --i)

using ll = long long;
using namespace std;
 
int main() {
	ll a, b, c, d, n;
	cin >> a >> b >> c >> d >> n;
	n *= 4;
	b = min(b, a + a);
	c = min(c, b + b);
	d = min(d, c + c);
	ll res = 0;
	if (n & 1) {
		n -= 1;
		res += a;
	}
	if (n & 2) {
		n -= 2;
		res += b;
	}
	if (n & 4) {
		n -= 4;
		res += c;
	}
	res += d * (n / 8);
	cout << res << endl;
	
	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> s(N);
  bool flag=false;
  for(int i=0;i<N;i++){
    cin >> s.at(i);
    if(s.at(i) == "Y"){
      flag = true;
      break;
    }
  }
  if(flag){
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pb push_back
#define pp pair<int,int>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define int long long
#define inf 10000000000000000
int dp[101][100001];
 main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt.txt","r",stdin);
	// freopen("output.txt.txt","w",stdout);
	// #endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int W;cin>>W;
	vi w(n),v(n);
	rep(i,0,n) cin>>w[i]>>v[i];
//min weight for val
	rep(i,0,n)
	{
		rep(j,0,100001)
		{
			dp[i][j] = inf;
			if(i==0)
			{
				if(j==0) dp[i][j] = 0;
				if(j==v[i]) dp[i][j] = w[i];
				continue;
			}
			dp[i][j] = min(dp[i][j],dp[i-1][j]);
			if(j>=v[i])
			{
				dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
			}

		}
	}
	int ans = 0;
	rep(i,0,100001)
	{
		if(dp[n-1][i]<=W)
		{
			ans = i;
		}
	}
	cout<<ans<<endl;


}

Measured memory_bytes: 78336
pub struct Scanner {
    line: Vec<String>,
    idx: usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        return Scanner {
            line: vec![],
            idx: 0,
        };
    }
    fn next<T: std::str::FromStr>(&mut self) -> T {
        if self.idx == self.line.len() {
            let mut buffer = String::new();
            std::io::stdin().read_line(&mut buffer).ok();
            let a: Vec<&str> = buffer.trim().split(' ').collect();
            self.line = a.iter().map(|&s| String::from(s)).collect();
            self.idx = 0;
        }
        let ret: T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
        self.idx += 1;
        ret
    }
    fn next_string(&mut self) -> Vec<char> {
        let s: String = self.next();
        return s.chars().collect::<Vec<char>>();
    }
    fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
}

#[allow(dead_code)]
fn gcd(a: u32, b: u32) -> u32 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

const MOD :u64 = 1_000_000_007;

#[allow(dead_code)]
fn pow(mut x: u64, mut y: u64) -> u64 {
    let mut r = 1;
    while y > 0{
        if (y&1) == 1{
            r = r*x%MOD;
        }
        y >>= 1;
        x = x*x%MOD;
    }
    r
}


fn main(){
    let mut scan = Scanner::new();
    let n:usize = scan.next();
    let k:usize = scan.next();
    let mut v:Vec<u64> = vec![0; k + 1];

    for i in (1..k+1).rev(){
        let m:u64 = (k / i) as u64; 
        v[i] = pow(m, n as u64);

        let mut j = 2;
        while i*j <= k {
            if v[i] >= v[i*j]{
                v[i] -= v[i*j];
            }else{
                v[i] = MOD - v[i*j] + v[i];
            }
            j += 1;
        }
    }
    let mut ans = 0;
    for i in 1..k+1{
        ans += v[i] * i as u64;
        ans %= MOD;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2800
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

#define bool int
#define T 1
#define LIMIT 1000000
bool prime[LIMIT+10];
void makep(ll n){prime[0]=prime[1]=T;for(int i=2;i*i<=n;i++)if(!prime[i])for(int j=i*i;j<=n;j+=i)prime[j]=T;}

int main(){
	makep(55555);
	ll n;
	scanf("%lld",&n);
	
	ll p=1;
	rep(i,0,n){
		while(prime[p])p+=10;
		printf("%lld\n",p);
		p+=10;
	}
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
	int L,R;
	int min;
	int solve;
	scanf("%d %d",&L,&R);
	min = 2019;
	for(int i = L;(i < R)&&(i < L+2019);i++){
		for(int j = i+1;(j < R+1)&&(j<i+2020);j++){
			solve = ((i%2019)*(j%2019))%2019;
			//printf("%d %d=%d\n",i,j,solve);
			if(min > solve){
				min = solve;
				//printf("min%d");
			}
		}
	}
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <complex>
#include <cmath>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
int main(){
  int n,m;
  int ans=0;
  cin>>n>>m;
  if(n==1&&m==0){
    cout<<0<<endl;
    return 0;
  }
  int a[n];
  for(int i=0;i<n;i++){
    a[i]=-1;
  }
  for(int i=0;i<m;i++){
    int s,c;
    cin>>s>>c;
    if(a[n-s]==-1||a[n-s]==c){
      a[n-s]=c;
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }
  for(int i=0;i<n;i++){
    if(a[i]!=-1){
      ans+=a[i]*pow(10,i);
    }
  }
  if(a[n-1]==0&&n!=1){
    cout<<-1<<endl;
    return 0;
  }
  if(a[n-1]==-1){
    ans+=pow(10,n-1);
  }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
int main(){
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<int> xp(n);
    vector<int> yp(m);
    rep(i,n) cin >> xp.at(i);
    rep(i,m) cin >> yp.at(i);
    sort(xp.rbegin(),xp.rend());
    sort(yp.begin(),yp.end());
    int z = yp[0];
    if(xp[0] < z && z > x && z <= y) cout << "No War\n";
    else cout << "War\n";
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  vector<ll> a(5);
  rep(i,5) cin >> a[i];

  rep(i,5){
    if(a[i] == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
using namespace std;

typedef string::const_iterator iter;
int number(iter &it);

int expr(iter &it) {
  ++it; // skip [
  int res;
  if(isdigit(*it)) {
    res = number(it) / 2 + 1;
  }
  else {
    vector<int> vec;
    while(*it == '[') {
      vec.push_back(expr(it));
    }
    sort(vec.begin(), vec.end());
    res = 0;
    for(int i = 0; i < (int)vec.size() / 2 + 1; ++i) {
      res += vec[i];
    }
  }
  ++it; // skip ]
  return res;
}

int number(iter &it) {
  int res = 0;
  while(isdigit(*it)) {
    res *= 10;
    res += *it - '0';
    ++it;
  }
  return res;
}

int main() {
  int N; cin >> N;
  while(N--) {
    string s; cin >> s;
    iter it = s.begin();
    cout << expr(it) << endl;
  }
}

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int a[3];
	
	cin >> a[0] >> a[1] >> a[2];
	
	sort(a, a+3);
	
	if(a[0] == a[1]){
		if(a[1] == a[2])
			cout << 1;
		else
			cout << 2;
	}else if(a[1] == a[2]){
		cout << 2;
	}else
		cout << 3;
	
	return 0;
}

Measured memory_bytes: 256
#include <string>       // ヘッダファイルインクルード
#include <iostream>

int main()
{
    std::string str,sub;       // ローカル変数として、str を生成
    int i=0;
	std::cin >> str;
	if(str.substr(0, 1)=="1")
		i++;
	if(str.substr(1, 1)=="1")
		i++;		  
	if(str.substr(2, 1)=="1")
		i++;
	if(str.substr(3, 1)=="1")
		i++;
	if(str.substr(4, 1)=="1")
		i++;
	if(str.substr(5, 1)=="1")
		i++;
	std::cout << i;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define _READ freopen("input.txt", "r", stdin);
#define _FAST                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
int32_t main()
{
    _FAST
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n),b(m),q(m),p(n);
    for(auto &i:a)
        cin>>i;
    for(auto &i:b)
        cin>>i;
    p[0]=a[0];
    q[0]=b[0];
    for(int i=1;i<n;i++)
        p[i]=p[i-1]+a[i];
    for(int i=1;i<m;i++)
        q[i]=q[i-1]+b[i];
    int ans=0;
    for(int i=0;i<n && p[i]<=k;i++)
    {
        int val=k-p[i];
        auto it=upper_bound(q.begin(),q.end(),val);
        if(it==q.begin())
        {
            ans=max(ans,i+1);
            continue;
        }
        --it;
        int index=it-q.begin();
        ans=max(ans,i+index+2);
    }
    for(int i=0;i<m && q[i]<=k;i++)
    {
        int val=k-q[i];
        auto it=upper_bound(p.begin(),p.end(),val);
        if(it==p.begin())
        {
            ans=max(ans,i+1);
            continue;
        }
        --it;
        int index=it-p.begin();
        ans=max(ans,i+index+2);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 9532
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCorder
{
    public static class Program
    {
        static public void Main(string[] args)
        {
            //int cnt = int.Parse(Console.ReadLine());
            //double[] input=  Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
            string input = Console.ReadLine();
            char[] cArray = input.ToArray();
            string ans = "";

            if (cArray[2] == cArray[3] && cArray[4] == cArray[5])
            {
                ans = "Yes";
            }
            else
            {
                ans = "No";
            }

            Console.WriteLine(ans);
                        
        }
    }
}




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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int H,W;
string S[20];
int A[400][400];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(x,400) FOR(y,400) A[x][y]=(x==y)?0:101010;
	
	FOR(y,H) {
		cin>>S[y];
		FOR(x,W) if(S[y][x]=='.') {
			if(x&&S[y][x-1]=='.') A[y*20+x-1][y*20+x]=A[y*20+x][y*20+x-1]=1;
			if(y&&S[y-1][x]=='.') A[y*20+x-20][y*20+x]=A[y*20+x][y*20+x-20]=1;
		}
	}
	FOR(i,400) FOR(x,400) FOR(y,400) A[x][y]=min(A[x][y],A[x][i]+A[i][y]);
	int ma=0;
	FOR(y,400) FOR(x,400) if(A[x][y]<400) ma=max(ma,A[x][y]);
	cout<<ma<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b) {
		cout << c << endl;
	}
	else {
		if (a == c) {
			cout << b << endl;
		}
		else {
			cout << a << endl;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main (void){
        int N;
scanf("%d\n",&N );
if (N%111==0) {
  printf("%d\n", N);
}else{
  printf("%d\n", ((N/111)+1)*111);
}

        return 0;
}


Measured memory_bytes: 128
class UnionFind():
  def __init__(self,n):
    self.n=n
    self.root=[-1]*(n+1)
    self.rank=[0]*(n+1)
  def FindRoot(self,x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.FindRoot(self.root[x])
      return self.root[x]
  def Unite(self,x,y):
    x=self.FindRoot(x)
    y=self.FindRoot(y)
    if x==y:
      return
    else:
      if self.rank[x]>self.rank[y]:
        self.root[x]+=self.root[y]
        self.root[y]=x
      elif self.rank[x]<=self.rank[y]:
        self.root[y]+=self.root[x]
        self.root[x]=y
        if self.rank[x]==self.rank[y]:
          self.rank[y]+=1
  def isSameGroup(self,x,y):
    return self.FindRoot(x)==self.FindRoot(y)
  def Count(self,x):
    return -self.root[self.FindRoot(x)]
  
n,m=map(int,input().split())
t=UnionFind(n+m)
for i in range(n):
  l=list(map(int,input().split()))
  for j in range(l[0]):
    t.Unite(i+1,n+l[1+j])
s=set()
for i in range(n):
  r=t.FindRoot(i+1)
  s.add(r)
if len(s)==1:
  print('YES')
else:
  print('NO')

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

int main(){
	string s;
	cin >> s;
	int n = s.size()+1;
	vector<ll> ans(n,0);
	ll count = 0;
	rep(i,n-1){
		if(s[i] == '<'){
			count++;
			ans[i+1] = count;
		}else{
			count = 0;
			ans[i+1] = count;
		}
	}
	count = 0;
	reverse(s.begin(),s.end());
	reverse(ans.begin(),ans.end());
	rep(i,n-1){
		if(s[i] == '>'){
			count++;
			ans[i+1] = max(ans[i+1], count);
		}else{
			count = 0;
			ans[i+1] = max(ans[i+1], count);
		}
	}
	ll res = 0;
	rep(i,n){
		res += ans[i];
	}
	cout << res << endl;
    return 0;
}



Measured memory_bytes: 4740
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
//#define ivorysi
#define MAXN 100005
#define eps 1e-8
#define pb push_back
using namespace std;
typedef long long int64;
typedef double db;
int N,M;
int P[MAXN],fa[MAXN];
int getfa(int x) {
    return fa[x] == x ? x : fa[x] = getfa(fa[x]);
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    scanf("%d%d",&N,&M);
    for(int i = 1 ; i <= N ; ++i) scanf("%d",&P[i]);
    for(int i = 1 ; i <= N ; ++i) fa[i] = i;
    int x,y;
    for(int i = 1 ; i <= M ; ++i) {
    	scanf("%d%d",&x,&y);
    	fa[getfa(x)] = getfa(y);
    }
    int cnt = 0;
    for(int i = 1 ; i <= N ; ++i) {
    	if(getfa(P[i]) == getfa(i)) ++cnt;
    }
    printf("%d\n",cnt);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j) vector<vector<ll>> name(i,vector<ll>(j))
#define vec2f(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k)))
#define vec3f(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define vec4(name,i,j,k,l) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l))))
#define vec4f(name,i,j,k,l,m) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l,m))))
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14
#define N 262144
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
vector<ll> p(N);
vector<ll> minl(N*2,INF);
vector<ll> maxl(N*2,-1);
ll n,k,sta,fin;

void add(ll x, ll ind){
    ind+=N;
    while(ind){
        minl[ind]=min(minl[ind],x);
        maxl[ind]=max(maxl[ind],x);
        ind/=2;
    }
}

ll pmin(ll x, ll y){
    x+=N;
    y+=N+1;
    ll z = minl[x];
    while(x<y){
        //cout << "x,y" << x << " " << y << endl;
        if(x%2){
            //cout << x << " " << z << " " << minl[x] << endl;
            z=min(z,minl[x]);
            x++;
        }
        x/=2;
        if(y%2){
            //cout << y << " " << z << " " << minl[y] << endl;
            z=min(z,minl[y-1]);
            y--;
        }
        y/=2;
    }
    return z;
}
ll pmax(ll x, ll y){
    x+=N;
    y+=N+1;
    ll z = maxl[x];
    while(x<y){
        if(x%2){
            z=max(z,maxl[x]);
            x++;
        }
        x/=2;
        if(y%2){
            z=max(z,maxl[y-1]);
            y--;
        }
        y/=2;
    }
    return z;
}

int main(){
    cin >> n >>k;
    REP(i,n){
        cin >> p[i];
        add(p[i],i);
    }
    /*FOR(i,32768,32769) cout << minl[i] << " ";
    cout << endl;
    FOR(i,65536,65538) cout << minl[i] << " ";
    cout << endl;
    FOR(i,131072,131076) cout << minl[i] << " ";
    cout << endl;
    FOR(i,262144,262153) cout << minl[i] << " ";
    cout << endl;*/

    ll ans = n-k+1;
    sta = 0; fin = k-1;
    ll cnter = 0; ll cnt = 0;
    FOR(i,1,n-1){
        if (p[i]>p[i-1])cnt++;
        if (p[i]<p[i-1]){
            if (cnt>=k-1) cnter++;
            cnt = 0;
        }
        if (i==n-1&&cnt>=k-1) cnter++;
        //cout << i << " " << cnter << " " << cnt << endl;
    }
    while(fin<n-1){
        //cout << pmin(sta,fin) << " " << p[sta] << endl;
        //cout << pmax(sta+1,fin+1) << " " << p[fin+1] << endl;
        if (pmin(sta,fin)==p[sta]&&pmax(sta+1,fin+1)==p[fin+1]) {
            ans--;
        }
        sta++; fin++;
    }
    //cout << cnter << endl;
    if (cnter>1) ans-=cnter-1;
    cout << ans << endl;
}

Measured memory_bytes: 13416
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();

        int N = nextInt(), W = nextInt();

        int[] weights = new int[N];
        int[] values = new int[N];

        int maxValue = 0;
        for (int i = 0; i < N; i++) {
            weights[i] = nextInt();
            values[i] = nextInt();
            maxValue += values[i];
        }

        // Since the weight/capacity is huge, for this problem, we shall consider values as the dimensions and find minimum weight for each value.
        long[][] dp = new long[maxValue + 1][N + 1];
        for (long[] longs : dp) Arrays.fill(longs, (long) (Math.pow(10, 18)));
        dp[0][0] = 0;
        
        for (int i = 0; i < dp[0].length; i++) {
            for (int j = 0; j < dp.length; j++) {
                if (i - 1 < 0) break;
                else if (values[i - 1] > j) dp[j][i] = dp[j][i - 1];
                else dp[j][i] = Math.min(dp[j][i - 1], weights[i - 1] + dp[j - values[i - 1]][i - 1]);
            }
        }

        long ans = 0;
        for (int i = 0; i < dp.length; i++) {
            for (int j = 0; j < dp[i].length; j++) {
                if (dp[i][j] <= W) ans = Math.max(ans, i);
            }
        }

        System.out.println(ans);
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
}

Measured memory_bytes: 128468
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;


public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = null;
		InputStreamReader in = new InputStreamReader(System.in);
		br = new BufferedReader(in);
//		Scanner sc = new Scanner(System.in);
		int[] line = parseIntArray(br.readLine());
//		int aSpeceis = line[0];
//		int bSpeceis = line[1];
		int m = line[2];
		int[] aPrices = parseIntArray(br.readLine());
		int[] bPrices = parseIntArray(br.readLine());
		
		int[][] discount = new int[m][3];
		for(int i=0;i<m;i++) {
			String d = br.readLine();
			discount[i] = parseIntArray(d);
		}		
		List<Integer> payment = new ArrayList<Integer>();
		for(int i=0;i<m;i++) {
			payment.add(aPrices[discount[i][0]-1]+bPrices[discount[i][1]-1]-discount[i][2]);
		}
		// 割引なしの合計最安
		int minA = 100000;
		int minB = 100000;
		for(int i: aPrices) {
			if(minA > i) {
				minA = i;
			}
		}
		for(int i: bPrices) {
			if(minB > i) {
				minB = i;
			}
		}
		payment.add(minA+minB);
		
		int minPayment = 200000;
		for(Integer i: payment) {
			if(minPayment > i) {
				minPayment = i;
			}
		}
		System.out.print(minPayment);
	}
	
	private static int[] parseIntArray(String line) {
		String[] arr = line.split(" ");
		int [] intArr = new int[arr.length];
		for(int i=0;i<arr.length;i++) {
			intArr[i] = Integer.parseInt(arr[i]);
		}
		return intArr;
	}
}

Measured memory_bytes: 62924
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n;
double a[55];
double ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+1+n);
	ans=(a[1]+a[2])/2;
	for(int i=3;i<=n;i++)
	{
		ans=(ans+a[i])/2;
	}
	printf("%lf\n",ans);
	return 0;
}

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

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

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-6;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

bool GaussJordan(const vvd& _a,const vd& b,vd& x)
{
	int n=_a.size();
	vvd a(n,vd(n+1));
	rep(i,n){
		copy(all(_a[i]),begin(a[i]));
		a[i][n]=b[i];
	}
	
	rep(i,n){
		int p=i;
		repi(j,i+1,n) if(abs(a[p][i])<abs(a[j][i])) p=j;
		if(abs(a[p][i])<EPS) return false;
		swap(a[i],a[p]);
		peri(j,i,n+1) a[i][j]/=a[i][i];
		rep(j,n) if(j!=i) peri(k,i,n+1) a[j][k]-=a[j][i]*a[i][k];
	}
	
	rep(i,n) x[i]=a[i][n];
	return true;
}

int main()
{
	for(int d;cin>>d && d;){
		vd v(d+3);
		rep(i,d+3) cin>>v[i];
		
		vi p(d+3); iota(all(p),0);
		double e=INF; int res=-1;
		do{
			vvd a(d+1,vd(d+1));
			vd b(d+1),x(d+1,-1);
			rep(i,d+1){
				rep(j,d+1) a[i][j]=pow(p[i+2],d-j);
				b[i]=v[p[i+2]];
			}
			GaussJordan(a,b,x);
			
			double t=0;
			rep(i,d+1) t+=x[i]*pow(p[0],d-i);
			if(e>abs(t-v[p[0]])){
				e=abs(t-v[p[0]]);
				res=p[1];
			}
			
			reverse(2+all(p));
		}while(next_permutation(all(p)));
		
		cout<<res<<endl;
	}
}

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

int main() {
    string S;
    string weatherrr[3] = {"Sunny","Cloudy","Rainy"};
    cin >> S;
    
  if (S == "Sunny"){
      cout << weatherrr[1];
  }
  if (S == "Cloudy"){
      cout << weatherrr[2];
  }  
  if (S == "Rainy"){
   //   cout << "The weather tommorow is: ";
      cout << weatherrr[0];
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
//#define mod 998244353ll
#define flagcount __builtin_popcount
#define flag(x) (1ll << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1ll << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return -1;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b; // aをbで更新
        return true;
    }
    return false;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, D;
    cin >> N >> D;
    ll ans = 0;
    loop(i, N)
    {
        ll x, y;
        cin >> x >> y;
        ll check = x * x + y * y;
        if (check <= D * D)
            ans++;
    }
    putout(ans);
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    // sum(a) - N * a_i が最小のiを出力
    int min_ = sum;
    int ans;
    for (int i = 0; i < N; i++) {
        int dif = max(sum,N * a.at(i)) - min(sum,N * a.at(i));
        if (dif < min_) {
            min_ = dif;
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
N = int(input())
XY = [ list(map(int, input().split())) for _ in range(N) ]
XY.sort()

PQ = []
for i in range(N):
    for j in range(i+1, N):
        now = [ XY[j][0] - XY[i][0], XY[j][1] - XY[i][1] ]
        if not now in PQ:
            PQ.append(now)

ans = N
for r in range(len(PQ)):
    cnt = N
    for i in range(N):
        nxt = [ XY[i][0] + PQ[r][0], XY[i][1] + PQ[r][1] ]
        if nxt in XY:
            cnt -= 1
    ans = min(ans, cnt)

print(ans)    


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<cstring>
using std::cin;
using std::cout;
using std::string;
int main()
{
    int N;
    cin >> N;
    string s[N];
    int count[4];
    memset(count, 0, sizeof(count));
    for(int i = 0; i < N; i++) cin >> s[i];
    for(int k = 0; k < N; k++)
    {
        if(s[k] == "AC") count[0]++;
        if(s[k] == "WA") count[1]++;
        if(s[k] == "TLE") count[2]++;
        if(s[k] == "RE") count[3]++; 
    }
    cout << "AC x " << count[0] << '\n';
    cout << "WA x " << count[1] << '\n';
    cout << "TLE x " << count[2] << '\n';
    cout << "RE x " << count[3];
    return 0;

}

Measured memory_bytes: 6680
#include<stdio.h>
int A[2000],n;
int solve(int ,int);
int main(){
  int M,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&M);
  int b[M];
  for(j=0;j<M;j++){
    scanf("%d",&b[j]);
  }
  for(j=0;j<M;j++){
    if(solve(0,b[j]))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}
int solve(int i,int m){
  int res;
  if(m==0){
    return 1;
  }
  if(i>=n){
    return 0;
  }
  res=solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()



int main() {
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        ll s, d, ans = 0;
        cin >> s >> d;
        if(s <= 0 && d >= 0){
            s = abs(s);
            while(s > 0){
                if(s&1LL) ans++;
                s >>= 1;
            }
            while(d > 0){
                if(d&1LL) ans++;
                d >>= 1;
            }
        }
        else{
            s = abs(s);
            d = abs(d);
            if(s > d) swap(s,d);
            while(s < d){
                ll b = 0;
                while(((s>>b)&1)==0 && s+(1<<(b+1))<=d)b++;
                ans++;
                s += (1<<b);
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 0; i<(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main(){
ll a,b;
cin>>a;
b=a+a*a+a*a*a;
cout<<b<<endl;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void) {

    int N; /*入力*/

    scanf("%d", &N);

    N = N % 10; /*1の位*/

    if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9) {
        printf("hon");
    }else if (N == 0 || N == 1 || N == 6 || N == 8) {
        printf("pon");
    }else{
        printf("bon");
    };

    return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

ll n;
vi a,b,c;
ll dp[100005][3];

ll find(ll n,ll i){
	if (n<=0)return 0;
	if (dp[n][i]!=-1)return dp[n][i];
	if (i==0){
		dp[n][i]=a[n-1];
		ll meow=max(find(n-1,1),find(n-1,2));
		dp[n][i]+=max(meow,find(n-2,0));
	}
	else if (i==1){
		dp[n][i]=b[n-1];
		ll meow=max(find(n-1,0),find(n-1,2));
		dp[n][i]+=max(meow,find(n-2,1));
	}
	else {
		dp[n][i]=c[n-1];
		ll meow=max(find(n-1,1),find(n-1,0));
		dp[n][i]+=max(meow,find(n-2,2));
	}
	return dp[n][i];
}

void solve() {
    cin>>n;
    memset(dp,-1,sizeof dp);
    rep(i,0,n){
    	ll x,y,z;
    	cin>>x>>y>>z;
    	a.pb(x),b.pb(y),c.pb(z);
    }
    find(n,0);
    find(n,1);
    find(n,2);
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 9952
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    --a[0];
    rep(i,n-1){
        if(a[i]>a[i+1]){
            cout<<"No"<<endl;
            return 0;
        }
        if(a[i]<a[i+1])--a[i+1];
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

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

    bool N = 0, S = 0, W = 0, E = 0;

    for(char c:Q)
    {
        if(c == 'N') N = 1;
        else if(c == 'S') S = 1;
        else if(c == 'E') E = 1;
        else W = 1;
    }
    cout << ((string[]){"Yes", "No"})[(N^S) || (E^W)] << '\n';
    return 0;
}


Measured memory_bytes: 256