akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;

int n, x, ans, A[MAXN];

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int main() {
    scanf("%d%d", &n, &x);

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    A[n] = x;
    n++;

    sort(A, A + n);

    ans = A[1] - A[0];

    for (int i = 2; i < n; i++) {
        ans = gcd(ans, A[i] - A[i - 1]);
    }

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

Measured memory_bytes: 640
n,m = map(int,input().split())
if abs(n - m) >= 2:
  print("0")
else:
  if n == m:cou = 2
  else:cou = 1
  while n > 1:
    cou *= n
    cou %= (10 ** 9 + 7)
    n -= 1
  while m > 1:
    cou *= m
    cou %= (10 ** 9 + 7)
    m -= 1
  print(cou)

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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    ll ans = 0;
    rep(i,n-1) {
        ll cost = x[i+1] - x[i];
        cost*=a;
        ans += min(cost, b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4028
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}


int main() {
	ll n, m;
	string s, t;
	cin >> n >> m;
	cin >> s;
	cin >> t;

	ll g = gcd(n, m);
	ll gn = n / g;
	ll gm = m / g;

	int j = 0;
	for (int i = 0; i < g; i++) {
		if (s[i*gn] != t[i*gm]) {
			cout << "-1" << endl;
			return 0;
		}
	}


	cout << n*m/g << endl;

	return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

const NIL = -1
const MAX = 100000

var sc = bufio.NewScanner(os.Stdin)
var N [MAX]Node
var D [MAX]int

type Node struct {
	parent int
	left   int
	right  int
}

func (n *Node) printChild() string {
	if n.left == NIL {
		return "[]"
	}
	buf := bytes.Buffer{}
	next := n.left
	sep := ", "
	for next != NIL {
		buf.WriteString(strconv.Itoa(next))
		buf.WriteString(sep)
		next = N[next].right
	}
	return "[" + strings.TrimRight(buf.String(), sep) + "]"
}

func (n *Node) kind() string {
	if n.parent == NIL {
		return "root"
	} else if n.left == NIL {
		return "leaf"
	} else {
		return "internal node"
	}
}

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func findRoot() int {
	root := 0
	for N[root].parent != NIL {
		root = N[root].parent
	}
	return root
}

func setDepth(id, depth int) {
	if id == NIL {
		return
	}

	D[id] = depth
	setDepth(N[id].left, depth+1)
	setDepth(N[id].right, depth)
}

func print(w io.Writer, i int) {
	fmt.Fprint(w, "node ", i, ": ")
	fmt.Fprint(w, "parent = ", N[i].parent, ", ")
	fmt.Fprint(w, "depth = ", D[i], ", ")
	fmt.Fprint(w, N[i].kind(), ", ")
	c := N[i].left
	fmt.Fprint(w, "[")
	first := true
	for c != NIL {
		if !first {
			fmt.Fprint(w, ", ")
		} else {
			first = false
		}
		fmt.Fprint(w, c)
		c = N[c].right
	}
	fmt.Fprint(w, "]")
	fmt.Fprintln(w)
}

func main() {
	n := scanInt()

	for i := 0; i < n; i++ {
		N[i].parent = NIL
		N[i].left = NIL
		N[i].right = NIL
	}

	for i := 0; i < n; i++ {
		id := scanInt()
		node := &N[id]
		k := scanInt()
		var rid int
		for j := 0; j < k; j++ {
			cid := scanInt()
			N[cid].parent = id
			if j == 0 {
				node.left = cid
			} else {
				N[rid].right = cid
			}
			rid = cid
		}
	}

	root := findRoot()
	setDepth(root, 0)

	wtr := bufio.NewWriter(os.Stdout)
	for i := 0; i < n; i++ {
		print(wtr, i)
	}
	wtr.Flush()
}



Measured memory_bytes: 16284
//agc038_a.cpp
//Sat Nov 16 19:59:03 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int h,w,a,b;
	cin >> h >> w >> a >> b;

	for (int i=0;i<h;i++){
		if (i<b){
			for (int j=0;j<w;j++){
				if (j<a){
					cout << 0;
				}else {
					cout << 1;
				}
			}
		}else {
			for (int j=0;j<w;j++){
				if (j>=a){
					cout << 0;
				}else {
					cout << 1;
				}
			}
		}
		printf ("\n");
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

LL n;
LL a[100005];
LL k;
LL numbits[70];
int main(){
	cin >> n >> k;
	FOR(i,0,n) cin >> a[i];
	FOR(i,0,n){
		for (LL j = 0, nx = a[i]; nx > 0; j++, nx>>=1){
			if (nx & 1) numbits[j]++;
		}
	}
//	for (int i = 0; i < 64; i++) cout << numbits[i] << " \n"[i==63];
	LL ans = 0LL;
	for (int i = 44; i >= 0; --i){
		LL now = 1LL << i;
		if (now > k){
			ans += now * numbits[i];
		} else {
			LL m1 = now * numbits[i];
			LL m2 = now * (n - numbits[i]);
			if (m1 >= m2){
				ans += m1;
			} else {
				ans += m2;
				k -= now;
			}
		}
	}
	cout << ans << '\n';
	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;
const int INF = 1000000000; // 10^9

bool is_p(string x){
    string t = x;
    reverse(t.begin(), t.end());
    return t == x;
}

int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;
    int sn = S.size();
    if(!is_p(S)){
        cout << "No" << endl;
        return 0;
    }

    if(!is_p(S.substr(0, S.size()/2))){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
const int MOD = 1e9 + 7;

map<string, int> m;
int main() {
	// freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	while (n--) {
		string s;
		cin >> s;
		m[s] ++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
	return 0;
}

Measured memory_bytes: 3672
n,q=map(int,input().split())
T=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)
C=[0]*n
for i in range(q):
    p,x=map(int,input().split())
    C[p-1]+=x
S=[0]
P=[0]*n
while S:
    s=S.pop()
    for t in T[s]:
        if t==P[s]:
            continue
        P[t]=s
        S.append(t)
        C[t]+=C[s]
print(' '.join(map(str,C)))

Measured memory_bytes: 66848
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    a = LI()
    a.sort(key = lambda x:-x)
    ans = 0
    for i in range(n):
        ans += a[2*i+1]
    print(ans)
    return

#B
def B():
    def dfs(d,x,c):
        if d <= dp[x]:
            return
        dp[x] = d
        if not f[x]:
            f[x] = c
        for y in v[x]:
            dfs(d-1,y,c)
    n,m = LI()
    f = [0]*n
    v = [[] for i in range(n)]
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    dp = defaultdict(lambda : -1)
    q = I()
    l = LIR(q)
    l = l[::-1]
    for x,d,c in l:
        x -= 1
        dfs(d,x,c)
    for i in f:
        print(i)
    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()


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

int main(){
	
	ios::sync_with_stdio(0);
	int n,m;
	cin>>n>>m;
	int ans=1,a=n;
	if(m==1){
		cout<<0<<endl;return 0;
	}
	while(1){
		if(a<m){
			ans++;
			a=a+n-1;
		}
		else break;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int x,n,k,q;
const int maxn=1e5+5;
int a[maxn];
int main()
{
    scanf("%d%d%d",&n,&k,&q);
    for(int i=1;i<=q;i++)
    {
        scanf("%d",&x);
        a[x]++;
    }
    for(int i=1;i<=n;i++)
    {
        if(k-q+a[i]>0)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


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

int h, w, a[501][501], c[501], ans = 0;
string s = "";

int main(){
    cin >> h >> w;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++) cin >> a[i][j];
    for (int i = 1; i <= h; i++){
        for (int j = 1; j < w; j++){
            c[i] += a[i][j];
            if (c[i]%2) ans++, s += to_string(i) +" "+to_string(j) 
                            + " " + to_string(i) + " "+ to_string(j+1) + "\n";
        }
        c[i] += a[i][w];
    }
    for (int i = 1; i < h; i++){
        if (c[i]%2){
            ans++;
            s += to_string(i) + " "+ to_string(w) 
                + " " + to_string(i+1) + " "+ to_string(w) + "\n";
            c[i+1]++;
        }
    }
    cout << ans << endl << s;
}

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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  int h,w;
  string s;
  vector <string> v;

  scanf("%d %d",&h,&w);

  char ansx;
  int ansy;
  FOR (i, 1, h + 1) {
    FOR (j, 1, w + 1) {
      cin >> s;
      if (s == "snuke") {
        ansx = j + 64;
        ansy = i;
      }
    }
  }

  printf("%c%d\n",ansx, ansy);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;


int main(){
    int X,Y;
    cin >> X >> Y;
    if(X==1 && Y==1){
        cout << 1000000 << endl;
    }else{
        int ans = 0;
        if(X<=3) ans += (4-X)*100000;
        if(Y<=3) ans += (4-Y)*100000;
        cout << ans << endl;
    }
}

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

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

    vector<int> p(n);
    vector<int> c(n);
    rep(i,n) {
        int px;
        cin >> px;
        p[i] = px-1;
    }
    rep(i,n) cin >> c[i];

    
    ll ans = LLONG_MIN;
    rep(sp,n) {
        int pos = sp;
        vector<int> v;
        ll tot = 0;
        while (1) {
            pos = p[pos];
            v.push_back(c[pos]);
            tot += c[pos];
            if (pos == sp) break;
        }   

        int l = v.size();
        ll cum = 0;
        rep(i,l) {
            cum += v[i];
            if (i+1 > k) break;
            ll t = cum;
            if (tot > 0) {
                ll e = (k-i-1)/l;
                t += tot*e;
            }
            ans = max(t, ans);
        }
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
    int H,W;
    cin>>H>>W;
    while(H!=0){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(i==0 || i==H-1 || j==0 || j==W-1) cout<<'#';
                else cout<<'.';
            }
            cout<<endl;
        }
        cout<<endl;
        cin>>H>>W;
    }
}


Measured memory_bytes: 3124
from collections import deque

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

BC_dict={}
for m in range(M):
    b,c = list(map(int,input().split()))
    if c in BC_dict.keys():
        BC_dict[c]+=b  
    else:    
        BC_dict[c]=b  
    
C = list(BC_dict.keys())

A.sort()
C.sort(reverse=True)

C=deque(C)

check = C.popleft()

for a_idx,a in enumerate(A):
    if a >= check:
        break
    
    A[a_idx] = check
    BC_dict[check] -= 1
    
    if BC_dict[check] == 0:
        if len(C) == 0:
            break
        else:
            check = C.popleft()
        
print(sum(A))

Measured memory_bytes: 99448
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
using P = std::pair<int, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

P v[1001001];

bool comp(P a, P b){
	if((a.first-a.second)>=0 && (b.first-b.second)<0){
		return true;
	}
	if((a.first-a.second)<0 && (b.first-b.second)>=0){
		return false;
	}
	if(a.first-a.second >= 0){
		return a.second < b.second;
	}else{
		return a.first > b.first;
	}
}
int main(void){
	int n,i,m,j,x=0,y=0;
	std::string s;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> s;
		m = s.l_ength();
		for(j=0; j<m; ++j){
			if(s[j]=='('){
				++v[i].first;
			}else if(v[i].first){
				--v[i].first;
			}else{
				++v[i].second;
			}
		}
	}
	sort(v,v+n,comp);
	for(i=0; i<n; ++i){
		if(v[i].first-v[i].second<0){
			break;
		}
		if(x-v[i].second<0){
			std::cout << "No" << std::endl;
			return 0;
		}
		x -= v[i].second;
		x += v[i].first;
	}
	for(i=(n-1); i>=0; --i){
		if(v[i].first-v[i].second>=0){
			break;
		}
		if(y-v[i].first<0){
			std::cout << "No" << std::endl;
			return 0;
		}
		y -= v[i].first;
		y += v[i].second;
	}
	std::cout << ((x==y)?"Yes":"No") << std::endl;
	return 0;
}


Measured memory_bytes: 11444
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9

struct edge{
    ll to,cap,cost,rev;
    edge(){}
    edge(ll to,ll cap,ll rev):to(to),cap(cap),rev(rev){}
    edge(ll to,ll cap,ll cost,ll rev):to(to),cap(cap),cost(cost),rev(rev){}
};

typedef vector<vector<edge> > graph;
struct Dinic{
    ll n;
    graph g;
    vector<ll> level,iter;
    Dinic() {}
    Dinic(ll n): n(n){
	g.resize(n);
	level.resize(n);
	iter.resize(n);
    }
    void add_edge(ll from, ll to, ll cost){
	g[from].push_back(edge(to,cost,g[to].size()   ) );
	g[to].push_back(edge(from,0,g[from].size() -1 ) );
    }
    void bfs(ll s){
	fill(level.begin(),level.end(),-1);
	queue<ll> q;
	q.push(s);
	level[s] = 0;
	while(!q.empty()){
	    ll tmp = q.front();
	    q.pop();
	    for(ll i=0;i<g[tmp].size();i++){
		edge &e = g[tmp][i];
		if(e.cap > 0 && level[e.to] < 0){
		    level[e.to] = level[tmp] + 1;
		    q.push(e.to);
		}
	    }
	}
    }
    ll dfs(ll v,ll t,ll f){
	if( v == t ) return f;
	for(ll &i = iter[v]; i < g[v].size() ; i++){
	    edge &e = g[v][i];
	    if( e.cap > 0 && level[v] < level[e.to] ){
		ll d = dfs(e.to, t, min(f,e.cap) );
		if( d > 0 ){
		    e.cap -= d;
		    g[e.to][e.rev].cap += d;
		    return d;
		}
	    }
	}
	return 0;
    }
    ll max_flow(ll s,ll t){
	ll flow = 0, f;
	while(1){
	    bfs(s);
	    if(level[t] < 0) return flow;
	    fill(iter.begin(),iter.end() , 0);
	    for(f = dfs(s,t,inf); f > 0; f = dfs(s,t,inf) ) flow += f;
	}
    }
};

struct Dinic_lr{
    Dinic f;
    ll S,T,sum_lb;
    Dinic_lr(){}
    Dinic_lr(ll n): f(n+2),S(n),T(n+1),sum_lb(0){}
    void add_edge(ll u,ll v,ll lb,ll ub){
	if( u== v || ub == 0)return ;
	f.add_edge(u,v,ub-lb);
	f.add_edge(S,v,lb);
	f.add_edge(u,T,lb);
	sum_lb += lb;
    }
    ll max_flow(ll s,ll t){
	ll a = f.max_flow(S,T);
	ll b = f.max_flow(s,T);
	ll c = f.max_flow(S,t);
	ll d = f.max_flow(s,t);
	return ( a + c == sum_lb && a + b == sum_lb ) ? b+d: -1;
    }
};

typedef pair<int,mp> mmp;
int main(){
    while(1){
    ll n,m;
    cin>>n>>m;
    if(n==0)break;
    vector<mp> a(m);
    for(int i=0;i<m;i++){
	cin>>a[i].first>>a[i].second;
	a[i].first--;
	a[i].second--;
    }
    ll S = n+m,T=n+m+1;
    bool flag = false;
    mmp ans  = mmp(inf,mp(0,0) );
    for(ll high = n; high >=1;high--){
	ll uf = high+1,lf = -1;
	while(uf-lf > 1){
	    ll mid = (uf+lf)/2;
	    Dinic_lr f(n+m+2);
	    for(ll i=0;i<m;i++){
		f.add_edge(S,i,0,1);//souce to edge(frindshipe)
		f.add_edge(i,m+a[i].first,0,1);// edge use or don't use (1 or 0)
		f.add_edge(i,m+a[i].second,0,1);// ...
	    }
	    for(ll i=0;i<n;i++){
		f.add_edge(m+i,T,mid,high);// student number of presents
	    }
	    if( f.max_flow(S,T) == m ){ // number of presents == m
		lf = mid;
	    }else{
		uf = mid;
	    }
	}
	if(lf < 0)continue;
	ans = min(ans,mmp(high-lf,mp(-lf,high ) ) );
    }
    	cout<<-ans.second.first<<' '<<ans.second.second<<endl;
    }
    return 0;
}



Measured memory_bytes: 5816
import sys
n,k = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
b = []
for i in range(n):
  for j in range(n):
    b.append(sum(a[i:j+1]))
    if b[-1] == 0:
      b.pop()
b.sort()
res = 0
for i in range(50,-1,-1):
  x = 1<<i
  ans = []
  for j in range(len(b)):
    if x&b[j]:
      ans.append(j)
  if len(ans) >= k:
    res += 1<<i
    c = []
    for l in ans:
      c.append(b[l])
    b = c
print(res)

Measured memory_bytes: 90224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int a,b;
  cin>>a>>b;
  if(abs(a-b)>1){
    cout<<0;
    return 0;
  }
  ll c=1;
  if(a==b){
    for(int i=1;i<=a;i++){
      c*=i;
      c%=1000000007;
    }
    c*=c;
    c%=1000000007;
    c*=2;
    c%=1000000007;
  }else{
    for(int i=1;i<=min(a,b);i++){
      c*=i;
      c%=1000000007;
    }
    for(int i=1;i<=max(a,b);i++){
      c*=i;
      c%=1000000007;
    }
  }
  cout<<c;
}

Measured memory_bytes: 764
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 5e5 + 10;
int n , L;
int x[N];
db k[N];

int main(){
    scanf("%d%d",&n,&L);
    int l = 0 , r = 0 , v;
    db ysum = 0 , t;
    rep(i,0,n) {
        scanf("%lf%d",&t,&v);
        int vremain = v;
        while(l < r && vremain >= x[l])
            ysum -= x[l] * k[l] , vremain -= x[l++];
        if(vremain && l < r)
            ysum -= vremain * k[l] , x[l] -= vremain;
        while(l < r && t < k[r-1]) {
            --r;
            ysum -= x[r] * k[r];
            t = (t * v + x[r] * k[r]) / (v + x[r]);
            v += x[r];
        }
        x[r] = v , k[r] = t;
        r++;
        ysum += v * t;
        printf("%.8f\n",ysum / L);
    }
    return 0;
}


Measured memory_bytes: 15360
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,x;
	int count=0;
	while(true){
		count=0;
	    cin>>n>>x;
		if(n==0&&x==0)
			break;
		for(int i=1;i<=n-2;i++){
			for(int j=i+1;j<=n-1;j++){
				for(int k=j+1;k<=n;k++){
					if(i+j+k==x){
						count++;
					}
				}
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

class BiparateMatching {
 public:
  vector<vector<ll> > G;
  ll V;
  vector<ll> match;
  vector<bool> used;

  BiparateMatching(ll V) {
    this->V = V;
    G = vector<vector<ll> >(V);
    match = vector<ll>(V);
    used = vector<bool>(V);
  }

  void addEdge(ll from, ll to) {
    G[from].push_back(to);
    G[to].push_back(from);
  }

  bool dfs(int v) {
    used[v] = true;
    for (int i = 0; i < G[v].size(); ++i) {
      ll u = G[v][i];
      ll w = match[u];
      if (w < 0 || !used[w] && dfs(w)) {
        match[v] = u;
        match[u] = v;
        return true;
      }
    }
    return false;
  }

  ll solve() {
    ll res = 0;
    fill(match.begin(), match.end(), -1);
    for (ll v = 0; v < V; ++v) {
      if (match[v] < 0) {
        fill(used.begin(), used.end(), 0);
        if (dfs(v)) {
          ++res;
        }
      }
    }
    return res;
  }
};

int main() {
  //
  ll n;
  cin >> n;
  vl a(n), b(n), c(n), d(n);
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, n) cin >> c[i] >> d[i];
  BiparateMatching bm(2 * n);
  rep(i, n) {
    rep(j, n) {
      if (a[i] < c[j] && b[i] < d[j]) {
        bm.addEdge(i, n + j);
      }
    }
  }
  cout << bm.solve() << endl;
  return 0;
}


Measured memory_bytes: 888
//////////////////////////////////////////////
//root@NULLCT$(☝ ՞ਊ ՞)☝  << "Be accept!!"//
//////////////////////////////////////////////
//#define BOOST
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int66_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   //setfill(char)
#include <ios>       //left,right
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
#ifdef BOOST
#include <boost/multiprecision/cpp_int.hpp> // cpp_int
using namespace boost::multiprecision;
#endif
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int setup(void) { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); return 0; }
int lenght(char* str) { int i = 0; while (str[i])i++; return i; }
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int iinput(void) { int a = 0; cin >> a; return a; }
int dinput(void) { double a = 0; cin >> a; return a; }
string sinput(void) { string a = ""; cin >> a; return a; }
int kuriup(double a) { int b = int(a); if (a != b) { return b + 1; } else { return b; } }
int kuridown(double a) { int b = int(a); return b; }
int run(void);
int main() { setup(); run(); return 0; }
int run(void) {


  ll n,a,b;
  cin>>n>>a>>b;
  ll num=n/(a+b);
  ll ans=num*a;
  ans+=min(a,n%(a+b));
  cout<<ans<<endl;


        return 0;
}


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

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

	int n;
	scanf("%d", &n);
	vector<int> A(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &A[i]);
	}

	int ai = *max_element(A.begin(), A.end());

	int aj = 0;
	for (int i = 0; i < n; i++)
	{
		if (ai == A[i])
		{
			continue;
		}
		if (abs(ai - A[i] * 2) <= abs(ai - aj * 2))
		{
			aj = A[i];
		}
	}

	cout << ai << " " << aj;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){

	int a,b,t;
    cin>>a>>b>>t;
  
    int ans=0;
  
    for(int i=1;i*a<t+1;i++){
      
        ans+=b;
      
    }
    cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    int a, b;
    cin >> a >> b;
    
    if (a <= 9 && b <= 9) {
        cout << a*b << endl;
    } else {
        cout << -1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000
char a[N + 1];
int b[N + 1];
char c[N + 1];
int ans;

void z_alg(void) {
	int n, j;
	n = strlen(a);
	b[0] = n;
	int i = 1;
	int k = 0;
	while (i < n) {
		while ((i + k) < n) {
			if (a[i + k] == a[k])k++;
			else break;
		}
		b[i] = k;
		if (k > 0) {
			j = 1;
			while (((i + j) < n) && ((j + b[j]) < k)) {
				b[i + j] = b[j];
				j++;
			}
			i += j;
			k -= j;
		}
		else i++;
	}
	return;
}


int main() {
	f(i, N + 1) {
		a[i] = 0;
		b[i] = 0;
		c[i] = 0;
	}
	int n;
	scanf("%d", &n);
	scanf("%s", c);
	ans = 0;
	f(i, n) {
		f(j, n)a[j] = 0;
		f(j, i + 1) {
			a[j] = c[n - i + j - 1];
		}
		z_alg();
		f(j, i + 1) {
			if (b[j] <= j)ans = max(ans, b[j]);
			else ans = max(ans, j);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

typedef pair<pint,pint> ppi;
pint ss[2001];
const int dx[]={1,1,1,1,1,2,2,2,3},dy[]={2,1,0,-1,-2,1,0,-1,0};
char s[61][31];
int d[2001][2];
int INF=1000100010;
int n,cur,w,h;
int dijkstra(){
    priority_queue<ppi,vector<ppi>,greater<ppi> > pq;
    rep(i,n)rep(j,2) d[i][j]=INF;
    rep(i,cur){
        d[ss[i].first+ss[i].second*w][0]=d[ss[i].first+ss[i].second*w][1]=0;
        pq.push({{0,0},{ss[i].first,ss[i].second}});
        pq.push({{0,1},{ss[i].first,ss[i].second}});
    }
    while(!pq.empty()){
        ppi pi=pq.top();pq.pop();
        int cost=pi.first.first,lr=pi.first.second;
        int x=pi.second.first,y=pi.second.second;
        if(d[x+y*w][lr]<pi.first.first) continue;
        rep(i,9){
            int p=1;
            if(lr==0) p=-1;
            int tx=x+dx[i]*p,ty=y+dy[i];
            if(tx>=0&&tx<w&&ty>=0&&ty<h&&s[ty][tx]!='X'){
                if(s[ty][tx]=='T') return cost;
                else if(isdigit(s[ty][tx])){
                    int tt=s[ty][tx]-'0';
                    if(d[tx+ty*w][1-lr]>cost+tt){
                        d[tx+ty*w][1-lr]=cost+tt;
                        pq.push({{cost+tt,1-lr},{tx,ty}});
                    }
                }
            }
        }
    }
    return -1;
}
int main(){
    while(cin>>w>>h,w|h){
        n=w*h;
        cur=0;
        rep(i,h)rep(j,w){
            cin>>s[i][j];
            if(s[i][j]=='S') ss[cur++]={j,i};
        }
        cout<<dijkstra()<<endl;
    }
    return 0;
}



Measured memory_bytes: 3036
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split(" ").map((v) => parseInt(v, 10));

const N = input[0];
const K = input[1];

let ans = 0;

for (let i = 1; i <= N; i++) {
  let tmp = 1 / N;
  let now = i;

  while (now < K) {
    now *= 2;
    tmp /= 2;
  }

  ans += tmp;
}

console.log(ans);


Measured memory_bytes: 9164
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()

if n < 10:
    print(0)
    quit()

if n % 2:
    print(0)
    quit()

else:
    ans = n//10
    tmp = 10
    while n//tmp > 0:
        tmp *= 5
        ans += (n//tmp)
    print(ans)

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

typedef long long ll;
typedef pair <int, int> pii;

const int N = 12 + 5;

ll dp[(1 << N)], ans[(1 << N)];
int n, a[N][N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> a[i][j];
	for (int mask = 0; mask < (1 << n); mask++) {
		vector <int> vec;
		for (int i = 0; i < n; i++)
			if(mask & (1 << i))
				vec.push_back(i);
		for (int i = 0; i < vec.size(); i++)
			for (int j = i + 1; j < vec.size(); j++)
				ans[mask] += a[vec[i]][vec[j]];
	}
	dp[0] = 0;
	for (int mask = 1; mask < (1 << n); mask++) {
		for (int submask = mask; submask; submask = (submask - 1) & mask)
			dp[mask] = max(dp[mask], ans[submask] + dp[mask ^ submask]);
	}
	cout << dp[(1 << n) - 1] << "\n";
}


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

int main(){
  int N; cin >>N;
  pair<int,int> ball[N];

  for(int i=0;i<N;i++){
    int x,y;
    cin >>x >>y;
    ball[i].first = x;
    ball[i].second = y;
  }
  sort(ball, ball+N);

  pair<int,int> d[N*(N-1)/2];
  int c=0;
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      d[c].first = ball[j].first - ball[i].first;
      d[c].second = ball[j].second - ball[i].second;
      c++;
    }
  }

  sort(d,d+(N*(N-1)/2));

  int count=1, max_count=1;
  int p=d[0].first, q=d[0].second;
  for(int i=1; i<N*(N-1)/2; i++){
    if((d[i-1].first == d[i].first) && (d[i-1].second == d[i].second)){
      count++;
    } else {
      if(count > max_count) {
        max_count = count;
        p = d[i-1].first;
        q = d[i-1].second;
      }
      count=1;
    }
  }
  if(count > max_count){
    max_count = count;
    p = d[N*(N-1)/2].first;
    q = d[N*(N-1)/2].second;
  }

  int ans=1;
  sort(ball, ball+N);
  for(int i=0; i<N-1; i++){
    int check=0;
    for(int j=i+1; j<N; j++){
      if((ball[j].first == ball[i].first+p) && (ball[j].second == ball[i].second+q)) {
        check = 1;
      }
    }
    if(check==0) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel\n";
    }
    else{
        cout << "consonant\n";
    }
}

Measured memory_bytes: 256
import sys

i = 0
for line in sys.stdin:
    m,f,r = line.split()
    m,f,r = int(m),int(f),int(r)

    s = m + f
    if m == -1 and f == -1 and r == -1: break
    elif m == -1 or f == -1 or s < 30: print 'F'
    elif 30 <= s and s < 50:
        if r >= 50: print 'C'
        else: print 'D'
    elif 50 <= s and s < 65: print 'C'
    elif 65 <= s and s < 80: print 'B'
    else: print 'A'

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

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

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

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

    // cumulative sum
    for(int i=1; i<n; i++){
        a[i] += a[i-1];
        b[i] += b[i-1];
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        int sum = a[i] + (b[n-1] - b[i-1]);
        if(ans < sum) ans = sum;
    }
    cout << ans << endl;
    
    return 0;
}

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

int main()
{
  int W,H,x,y,r;
  cin >>W>>H>>x>>y>>r;

  if(x-r<0){
    cout<<"No"<<endl;
    return 0;
  }
  if(y-r<0){
    cout<<"No"<<endl;
    return 0;
  }
  if(x+r>W){
    cout<<"No"<<endl;
    return 0;
  }
  if(y+r>H){
    cout<<"No"<<endl;
    return 0;
  }

  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
int n,i,sum,a[2005];
bitset<4000005> dp;
int main()
{
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)sum+=a[i];
	dp[0]=1;
	rep(i,n)
	{
		dp|=(dp<<a[i]);
	}
	for(i=(sum+1)/2;!dp[i];i++);
	cout<<i<<endl; 
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      	
		if(N <= 9) {
			System.out.println("Yes");
			return;
		}
		for(int i = 2; i <= 9; i++) {
			if(N % i == 0 && (N / i) < 10) {
				System.out.println("Yes");
              	return;
			}
		}
		System.out.printf("No");
    }
}

Measured memory_bytes: 22868
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){

    int n;
    scanf("%d",&n);
    while(n--)
    {
        int a[3];
        for(int i=0;i<3;i++)
        {
            scanf("%d",&a[i]);
            a[i]*=a[i];
        }
        int maxSide=a[0];
        int sum=0;
        for(int i=1;i<3;i++)
        {
            if(a[i]>maxSide)
            {
                sum+=maxSide;
                maxSide=a[i];
            }
            else
                sum+=a[i];
        }
        if(sum==maxSide)
            printf("YES\n");
        else
            printf("NO\n");

    }

    return 0;
}



Measured memory_bytes: 3072
import sys
input = sys.stdin.readline

n , m = map(int, input().split())

root = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    root[a-1].append(b)
    root[b-1].append(a)

kakutei = [1]

answer_li = [0]*n

while kakutei:
    k = kakutei.pop(0)
    for r in root[k-1]:
        if answer_li[r-1] == 0:
            kakutei.append(r)
            answer_li[r-1] = k

answer_li = answer_li[1:]
if 0 in answer_li:
    print('No')
else:
    print('Yes')
    for i in answer_li:
        print(i)


Measured memory_bytes: 34168
#include <iostream>
using namespace std;
typedef long long ll;

const ll INF = 100000000000000;

int main()
{
    ll n, k;
    cin >> n >> k;
    ll p[5005], c[5005];
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    ll ans = -INF;
    for(int i = 0; i < n; i++){
        ll d = 1;
        ll w = 0;
        w += c[i];
        int j = p[i];
        while(j != i){
            w += c[j];
            j = p[j];
            d++;
        }
        w = max(w, 0ll);
        ll s = 0;
        j = i;
        for(int t = 1; t <= min(d, k); t++){
            s += c[j];
            j = p[j];
            ans = max(ans, s + w * ((k - t) / d));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3708
#include<stdio.h>

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];
int x[N][N];

void initialize(){
  for(int i = 0; i < N; i++){
    row[i] = FREE;
    col[i] = FREE;
  }
  for(int i = 0; i < 2 * N - 1; i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}

void printBoard(){
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(x[i][j]){
	if(row[i] != j) return;
      }
    }
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(row[i] == j) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  if(i == N){ //クイーンの配置に成功
    printBoard();
    return;
  }

  for(int j = 0; j < N; j++){
    //(i,j)が他のクイーンに襲撃されている場合は無視
    if(col[j] == NOT_FREE || dpos[i + j] == NOT_FREE || dneg[i - j + N - 1] == NOT_FREE) continue;
    //(i,j)にクイーンを配置する
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
    //次の行を試す
    recursive(i + 1);
    //(i,j)に配置されているクイーンを取り除く
    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
  //クイーンの配置に失敗
}

int main(){
  initialize();

  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      x[i][j] = 0;
    }
  }

  int k;
  scanf("%d",&k);
  for(int i = 0; i < k; i++){
    int r, c;
    scanf("%d %d",&r,&c);
    x[r][c] = 1;
  }

  recursive(0);

  return 0;
}



Measured memory_bytes: 2104
n=int(input())
X=[int(i) for i in input().split()]
X.sort()
ans=float("inf")
a,b=X[0],X[-1]
for i in range(a,b+1):
  cur=0
  for x in X:
    cur+=(x-i)**2
  ans=min(cur,ans)
print(ans)

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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repr(i, n) for (ll i = n - 1; i >= 0; --i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll cta = 0;
    rep(i, n) if (a[i] % 2 == 1) cta++;
    if (cta > 0)
        cout << "first" << endl;
    else
        cout << "second" << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3980
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int main() {
    int N;
    cin >> N;
    int k = N / 2;
    if (N % 2 == 0) {
        k -= 1;
    }

    cout << k << endl;
}

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

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    ll res = 1;
    while (N/K > 0) {
        res++;
        N /= K;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
x=[]
W=list(map(int,input().split()))
for i in range(N):
    sum=0
    for j in range(i+1):

        sum+=W[j]
    x.append(sum)
ww=0
for i in range(N):
    ww+=W[i]

#print(ww)
#print(x)
s=[]
for i in range(N):
    s.append(ww-x[i])
#print(s)
k=[]
for i in range(N):
    k.append(abs(s[i]-x[i]))
print(min(k))


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String...args){
        Scanner scanner=new Scanner(System.in);
        int A1=scanner.nextInt();
        int A2=scanner.nextInt();
        int A3=scanner.nextInt();
        int sum=A1+A2+A3;
        if(sum>=22){
            System.out.println("bust");
        }else{
            System.out.println("win");
        }

    }
}






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

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

	int ans = 0;
	for(int i = 0;i < 4;i++){
		if(s[i] == '+') ans++;
		if(s[i] == '-') ans--;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n)
using namespace std;
int main()
{
	MaRiaMa;
	set<int> p;
	int n;
	cin >> n;
	if (n == 1 || n == 2 || n == 3)
		cout << "1";
	else
	{
		for (int i = 2; i < n; i++)
		{
			int k = 2;
			while (1)
			{
				int u = pow(i, k);
				if (u > n)
				{
					break;
				}
				p.emplace(u);
				k++;
			}
		}
		auto it = p.rbegin();
		cout << *it;
	}
		
}





Measured memory_bytes: 4000
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001 
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl> 
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define set(x,k) memset(x,k,sizeof(x))
#define cy cout << "YES" << endl
#define  cn cout << "NO" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (auto i=2; i<MAXN; i++) 
  		spf[i] = i; 
  	for (auto i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (auto i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (auto j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
	return;
} 

vl getFactorization(ll x) 
{ 
    vl ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 


void check()
{
	ll n,x,t;
	cin >> n >> x >> t;
	ll ans = 1;
	while(ans*x<n) ans++;
	cout << ans*t << endl;
    return ;
}

int32_t main()
{
    fastio;
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
// typedef pair<ll,ll> p;

int h,w;
int R[2000][2000], L[2000][2000], U[2000][2000], D[2000][2000];


int main(){
  cin >> h >> w;
  vector<string> s(h);
  for(int i=0; i< h; i++) cin >> s[i];

  //左の探索
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
          int cnt = 0;
          if(s[i][j]=='#')L[i][j] = 0;
          else if (j==0)L[i][j] = 1;
          else L[i][j] = L[i][j-1]+1;
    }
  }

  //右の探索
  for(int i = 0; i < h; i++){
    for(int j = w-1; j >= 0; j--){
          int cnt = 0;
          if(s[i][j]=='#')R[i][j] = 0;
          else if (j==w-1)R[i][j] = 1;
          else R[i][j] = R[i][j+1]+1;
    }
  }



  //下の探索
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
          int cnt = 0;
          if(s[i][j]=='#')D[i][j] = 0;
          else if (i==0)D[i][j] = 1;
          else D[i][j] = D[i-1][j] + 1;
          // cout << D[i][j] << "";
    }
    
  }



  for(int i = h-1; i >= 0; i--){
    for(int j = 0; j < w; j++){
          int cnt = 0;
          if(s[i][j]=='#')U[i][j] = 0;
          else if (i==h-1)U[i][j] = 1;
          else U[i][j] = U[i+1][j] + 1;
    }
  }

  int ans = 0;
  for(int i=0; i<h;i++){
    for(int j=0; j<w; j++){
      ans = max(ans, U[i][j]+D[i][j]+R[i][j]+L[i][j]-3);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 66816
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;

int main(){
    int N,t;
    cin>>N;
    map<int,int> A;

    rep(i,N){
        cin>>t;
        A[t]=i+1;
    }
    for( auto i = A.begin(); i != A.end() ; ++i ) {
        if(i!=A.begin()) cout<<" ";
        cout << i->second;
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 8236
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int ans = A*B;
		System.out.println(ans);
	}

}

Measured memory_bytes: 35736
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;


string alphabeth = "abcdefghijklmnopqrstuvwxyz";

string solve(long long int N)
{
	string res;
	while (N > 0) { 
		// Find remainder 
		int rem = N % 26; 
        if (!rem) { 
            res += 'z'; 
            N = (N / 26) - 1; 
        } else { 
            res += (rem - 1) + 'a'; 
            N = N / 26; 
        } 
    }
    reverse(res.begin(), res.end());
    return res;
}


int main()
{
	long long int N;
	cin >> N;
	cout << solve(N) << endl;
	return 0;
}


Measured memory_bytes: 3620
import sys
import numpy as np
from math import ceil as C, floor as F
from collections import defaultdict as D
from functools import reduce
 
alp = 'abcdefghijklmnopqrstuvwxyz'
def S(): return sys.stdin.readline().rstrip().split(' ')
def Ss(): return list(S())
def I(): return _I(S())
def Is(): return list(I())
def _I(ss): return map(int, ss) if len(ss) > 1 else int(ss[0])
 
_ = I()
xs = Is()

def xor(x, y):
  return int('{0:b}'.format(x), 2) ^ int('{0:b}'.format(y), 2)

def xors(xs):
  return reduce(xor, xs)

xxx = xors(xs)
ys = [str(xor(xxx, x)) for x in xs]
print(' '.join(ys))

Measured memory_bytes: 53992