akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &e: a) cin >> e;
  reverse(a.begin(), a.end());
  
  ll l=2, r=2;
  for (auto e: a) {
    if (r < e) {
      cout << -1 << endl;
      return 0;
    }
    ll ming = (l+e-1)/e;
    ll maxg = r/e;
    if (maxg < ming) {
      cout << -1 << endl;
      return 0;
    }
    l = ming * e;
    r = maxg * e + e - 1;
  }
  
  cout << l << " " << r << endl;
  
  return 0;
}
  

Measured memory_bytes: 640
<?php
  $n = trim(fgets(STDIN));
  switch ($n) {
      case 'Sunny':
        echo 'Cloudy' . PHP_EOL;
        return;
    case 'Cloudy':
        echo 'Rainy' . PHP_EOL;
        return;
    case 'Rainy':
        echo 'Sunny' . PHP_EOL;
        return;
  }

Measured memory_bytes: 4856
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  std::string S;
  std::cin >> S;
  if ((S[0]==S[1]) && (S[0]==S[2])){
    printf("No\n");
  } else {
    printf("Yes\n");
  }

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

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

int main(){
    int N, M; cin >> N >> M;
    vector<ll> x(N), y(M);
    for(int i=0; i<N; ++i) cin >> x[i];
    for(int i=0; i<M; ++i) cin >> y[i];

    ll X = 0, Y = 0;
    for(int i=0; i<N; ++i){
        X += i*x[i] - (N-1-i)*x[i];
        chmod(X);
    }

    for(int i=0; i<M; ++i){
        Y += i*y[i] - (M-1-i)*y[i];
        chmod(Y);
    }

    cout << X*Y%mod << endl;

    return 0;
}


Measured memory_bytes: 1792
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter
def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k
 
    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return ret
  
a = int(readline())
n = list(map(int,readline().split()))
c = Counter(n)
ss = set(n)

ans = 0
for m in ss:
  if c[m] >= 2:
    continue
  chk = set(divisors(m))
  if chk & ss == {m}:
      ans += 1
print(ans)

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

int main(){
  int a,b,c,d;
  cin >>a>>b>>c;
  
  
  bool ans=true;
  for(int i=1;;i++){
    if((a*i)%b==c){
      break;
    }
    if(i==1){
      d=(a*i)%b;
    }
    if(i!=1 && (a*i)%b==d){
      ans=false;
      break; 
    }
  }
  if(ans){
    cout << "YES" <<endl;
  }
  else{
    cout << "NO" <<endl;
  }
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    vector<pair<ll,ll> > t;
    for (ll i = 0; i < n; i++)
    {
        ll a, b;
        cin >> a >> b;
        t.push_back(make_pair(a, b));
    }
    sort(t.begin(), t.end());

    ll i = 0;
    for (auto p : t)
    {
        i += p.second;
        if (i >= k)
        {
            cout << p.first << endl;
            break;
        }
    }
}


Measured memory_bytes: 3444
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long K = sc.nextLong();
        int N = 50;
        long a = K/N;
        long b = K%N;
        System.out.println(N);
        for(int i=0;i<N;i++){
        	if(i<N-b) System.out.print(N+a-1-b);
        	else System.out.print(2*N+a-b);
        	
        	if(i==N-1)System.out.println();
        	else System.out.print(" ");
        }
    }
}

Measured memory_bytes: 23764
#include<iostream>
using namespace std;
int main(){
	int H,W;
	int i,j;
	while(1){
		cin>>H>>W;
		if(H==0&&W==0)break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if(i==0||j==0||j==W-1||i==H-1)cout<<"#";
				else cout<<".";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,k,m,r;
int out[10010];
void add(int a){
	int t=1;
	int co=0;
	while(t&&co<10010){
		out[co]+=t/a;
		t=t-t/a*a;
		t*=10;
		co++;
	}
	for(int i=10009;i>=1;i--){
		out[i-1]+=out[i]/10;
		out[i]%=10;
	}
}
void div(int a=n){
	int t=0;
	rep(i,10010){
		t*=10;
		t+=out[i];
		out[i]=t/a;
		t=t-t/a*a;
	}
}
int main(){
	while(cin>>n>>k>>m>>r,n){
		rep(i,10010)out[i]=0;
		if(m){
			loop(i,1,n)add(i);
			div();
		}
		add(n);
		cout<<out[0]<<".";
		rep(i,r)cout<<out[i+1];
		cout<<endl;
	}
}

Measured memory_bytes: 3080
s=list(input())
t=list(input())
ans=100000
for i in range(len(s)-len(t)+1):
    cnt=0
    si=s[i:i+len(t)]

    for k in range(len(t)):
        if si[k]==t[k]:
            cnt+=1
    ans=min(ans,len(t)-cnt)
print(ans)

Measured memory_bytes: 67796
def readinput():
    n=int(input())
    s=input()
    return n,s

def main(n,s):
    i=0
    count=0
    while(i<n):
        p=s[i:].find('ABC')
        #print(s[i:])
        if(p!=-1):
            i+=p+3
            count+=1
        else:
            break
    return count

if __name__=='__main__':
    n,s=readinput()
    ans=main(n,s)
    print(ans)




Measured memory_bytes: 3060
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int N, K;
    scan(N, K);
    readln.split.to!(long[]).sort().take(max(0, N - K)).sum().writeln;
}
















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 11248
if __name__ == "__main__":
    n = int(input())
    s = input()

    if n == 2:
        if s[0] == s[1]:
            print(1)
            exit()
        else:
            print(0)
            exit()

    ans = 0
    for i in range(1, n):
        front = set(s[0:i])
        back = set(s[i:n])

        tmp = len(front.intersection(back))
        if ans < tmp:
            ans = tmp

    print(ans)


Measured memory_bytes: 3060
#https://atcoder.jp/contests/abc135/tasks/abc135_c

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

ans=0
for i in range(len(B)):
    #勇者が全滅させたら、隣町から余力をとる
    if B[i]>A[i]:
        mod=min(A[i+1],B[i]-A[i])
        A[i+1]-=mod
        #この街と隣町
        ans+=int(A[i]+mod)
   
    #敵が余るときは勇者は力の限り全部倒す
    else:
        ans+=B[i]

print(ans)




Measured memory_bytes: 18624
def with_prev(filt, ad=None):
  prev = None
  def _filt(x):
    nonlocal prev
    if prev is None or filt(x, prev):
      prev = x
      return ad(x) if ad else True
    return False
  return _filt

def solve():
  N, K, C = map(int, input().split())
  workable = [i for i, s in enumerate(input(), 1) if s=="o"]
  
  if len(workable) == K:
    return workable
  
  filt = with_prev(lambda x,p:p-x>C)
  latest = set(filter(filt, reversed(workable)))

  if len(latest) > K:
    return []
  
  filt = with_prev((lambda x,p:x-p>C), latest.__contains__)
  return filter(filt, workable)

print("\n".join(map(str, solve())))


Measured memory_bytes: 23968
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int k;
    cin >> k;
    if (k % 2 == 0) {
        cout << (k / 2) * (k / 2) << endl;
    } else {
        cout << (k / 2) * (k / 2 + 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
ans = 0
if(2 * c < a + b):
    ans += min(x, y) * 2 * c
    z = x
    x -= min(x, y)
    y -= min(z, y)
    #print(ans)
    if(c * 2 < a):
        ans += c * 2 * x
        x = 0
    else:
        ans += a * x
       # print(ans, x, y)
        x = 0
    if(c * 2 < b):
        ans += c * 2 * y
        y = 0
    else:
        ans += b * y
        y = 0  
else:
    ans = x * a + b * y
print(ans)

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100001
int A[maxn];
int N;


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

int __gcd(int a,int b){
	if (a == -1) return b;
	if (b == -1) return a;
	return gcd(a,b);
}

struct node{
	int s,e,m,val;
	node *l,*r;
	
	node(int ss,int ee){
		s = ss; e = ee; m = (s+e)/2;
		
		if (s == e) val = A[s];
		else{
			l = new node(s,m);
			r = new node(m+1,e);
			
			val = __gcd(l->val,r->val);
		}
	}
	
	void upd(int p,int v){
		if (s == e && s == p){
			val = v;
			return;
		}
		if (p > m) r->upd(p,v);
		else l->upd(p,v);
		
		val = __gcd(l->val,r->val);
	}
		
}*root;
	
int main(){
	fast;
	
	cin>>N;
	
	FOR(i,0,N-1){
		cin>>A[i];
	}
	
	root = new node(0,N-1);
	
	int ans = 1;
	FOR(i,0,N-1){
		root->upd(i,-1);
		ans = max(ans,root->val);
		root->upd(i,A[i]);
	}
	
	cout<<ans;
}

	




Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int n;
    cin >> n;
    int counter = 0;
    bool isCont = false;
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        if (a == b)
        {
            isCont = true;
            counter++;
        }
        else
        {
            if (isCont)
            {
                if (counter >= 3)
                {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
            isCont = false;
            counter = 0;
        }
    }
    if (isCont)
    {
        if (counter >= 3)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int n, r;
	cin >> n >> r;
	if(n >= 10) cout << r << endl;
	else {
		cout << r + 100 * (10-n) << endl;
	}
	return 0;
}

Measured memory_bytes: 764
let mod = 1000000007

func readIntPair() -> (Int, Int) {
    let line = readLine()!.split(separator: " ").map({Int($0)!})
    return (line[0], line[1])
}

func readIntArray() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

let (N, M) = readIntPair()
let S = readIntArray(), T = readIntArray()

var dp: [[Int]] = Array.init(repeating: Array.init(repeating: 0, count: M + 1), count: N + 1)

(1...N).forEach({ i in
    (1...M).forEach({ j in
        if S[i - 1] == T[j - 1] {
            dp[i][j] = 1 + dp[i - 1][j] + dp[i][j - 1]
        } else {
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + mod
        }
        dp[i][j] %= mod
    })
})

print((dp[N][M] + 1) % mod)


Measured memory_bytes: 39720
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext())
		{
			int n=sc.nextInt();
			if(n==0)
				return;
			int a[]=new int[n];
			int ans=0;
			for(int i=0; i<n; i++)
			{
				a[i]=sc.nextInt();
			}
			
			for(int i=0; i<n; i++)
			{
				for(int j=0;j<n-1; j++)
					if(a[j]>a[j+1])
					{
						int tmp = a[j];
						a[j] =a[j+1];
						a[j+1]=tmp;
						ans++;
					}	
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>

#define Mod 998244353

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

int main()
{
	int N, M, K;
	scanf("%d %d %d", &N, &M, &K);
	if (M == 1) {
		if (K == N - 1) printf("1\n");
		else printf("0\n");
		fflush(stdout);
		return 0;
	}
	
	int i;
	long long fact[200001], fact_inv[200001], pow[200001];
	for (i = 1, fact[0] = 1; i <= N; i++) fact[i] = fact[i-1] * i % Mod;
	for (i = N - 1, fact_inv[N] = div_mod(1, fact[N], Mod); i >= 0; i--) fact_inv[i] = fact_inv[i+1] * (i + 1) % Mod;
	for (i = 1, pow[0] = M; i <= N; i++) pow[i] = pow[i-1] * (M - 1) % Mod;
	
	long long ans = 0;
	for (i = 0; i <= K; i++) ans += fact[N-1] * fact_inv[i] % Mod * fact_inv[N-i-1] % Mod * pow[N-i-1] % Mod;
	printf("%lld\n", ans % Mod);
	fflush(stdout);
	return 0;
}

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

using namespace std;
using ll =long long;
//nCm 
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nCmここまで

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int k , x;
	cin >> k >> x;
	if(500*k >= x) coY();
	else coN();
}


Measured memory_bytes: 256
package main

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

// BIT stands for binary indexed tree.
type BIT []int

func newBIT(n int) BIT {
	return make([]int, n)
}

func (bit *BIT) add(i, x int) {
	for i++; i <= len(*bit); i += i & -i {
		(*bit)[i-1] += x
	}
}

func (bit *BIT) sum(i int) int {
	result := 0
	for i++; i > 0; i -= i & -i {
		result += (*bit)[i-1]
	}
	return result
}

type t struct {
	X int
	H int
}
type byX []t

func (a byX) Len() int           { return len(a) }
func (a byX) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a byX) Less(i, j int) bool { return a[i].X < a[j].X }

func main() {
	N := readInt()
	D := readInt()
	A := readInt()
	XH := make([]t, N)
	for i := 0; i < N; i++ {
		XH[i].X = readInt()
		XH[i].H = (readInt() + A - 1) / A
	}

	sort.Sort(byX(XH))
	result := 0
	bit := newBIT(N + 1)
	for i := 0; i < N; i++ {
		x, h := XH[i].X, XH[i].H
		h -= bit.sum(i)
		if h <= 0 {
			continue
		}
		result += h
		bit.add(i, h)

		ok := i
		ng := N
		for ng-ok != 1 {
			m := ok + (ng-ok)/2
			if XH[m].X <= x+2*D {
				ok = m
			} else {
				ng = m
			}
		}
		bit.add(ng, -h)
	}
	fmt.Println(result)
}

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

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

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 11008
n,x=map(int,input().split())
l,p=[1],[1]
for i in range(n):
  l+=[l[-1]*2+3]
  p+=[p[-1]*2+1]
x-=1
a=1
while n:
  t=l[n]//2
  if x>=t:
    a+=p[n-1]+1
    x-=t
  x-=1
  n-=1
if x<0: a-=1
print(a)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define Rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef int64_t intl;


int main(){
  int a,b;
  cin >> a >>b;
  int no_b = b - a;
  int height_b = 0;
  Rep (i,no_b){
    height_b += i+1;
  }
  cout << height_b - b;
}
    
    

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    K = int(input())

    ans = 1
    for _ in range(N):
        if 2 * ans < ans + K:
            ans *= 2
        else:
            ans += K

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import scala.io.StdIn._
object Main extends App {
  val n = readInt
  val as = readLine.split(" ").map(_.toInt)

  val tbl = Array.fill(3)(-1)
  println(as.foldLeft(1L){ (z, a) =>
    tbl.indexWhere(_ == a - 1) match {
      case -1 => 0
      case i => 
        val ret = z * tbl.count(_ == a - 1) % 1000000007
        tbl(i) += 1
        ret
    }
  })
}

Measured memory_bytes: 49852
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let prime = 1_000_000_007

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let n = scan "%d" id
let ls = scan_list ~sep:' ' Int.of_string

let () =
  let arr = Array.make (succ n) 0 in
  ListL.map ls ~f:(fun v ->
      let n = if v = 0 then 3 - arr.(v)
        else arr.(v-1) - arr.(v)
      in
      arr.(v) <- succ arr.(v);
      n)
  |> List.reduce (fun s t -> s * t mod  prime)
  |> Printf.printf "%d\n"


Measured memory_bytes: 12672
#include <algorithm>
#include <list>
#include <cstdio>

using namespace std;

int main() {
	int n, x,siz;
	char com[20];
	list<int> li;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%s", com);
		if (com[0] == 'i') {
			scanf("%d", &x);
			li.push_front(x);
		} else if (com[6] == 'L') li.pop_back();
		else if (com[6] == 'F') li.pop_front();
		else if (com[0] == 'd') {
			scanf("%d", &x);
			siz = li.size();
			for (list<int>::iterator it = li.begin(); it != li.end();++it) {
				if (*it == x) {
					li.erase(it);
					break;
				}
			}
		}
	}
	int i = 0;
	for (list<int>::iterator it = li.begin(); it != li.end(); ++it) {
		if (i++) printf(" ");
		printf("%d",*it);
	}
	printf("\n");


	return 0;
}


Measured memory_bytes: 33864
#include <cstdio>

int main() {
	// your code goes here
	int N;
	scanf("%d",&N);
	int v;
	int i = N;
	while(i != 0){
		v += i % 10;
		i = i / 10;
	}
	if(N % v == 0){
		printf("Yes");	
	}else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long int LL;

struct Vector {
	LL x, y;

	Vector (LL x = 0, LL y = 0) : x(x), y(y) { }

	LL cross(const Vector &b) const {
		return x * b.y - y * b.x;
	}

	Vector operator-(const Vector &b) const {
		return Vector(x - b.x, y - b.y);
	}

	LL dot(const Vector &b) const {
		return x * b.x + y * b.y;
	}
};

const int maxn = 1024;

int N, M, all;
Vector P[maxn];


struct Cmp { 
	Vector s, t;
	bool operator() (const int a, const int b) {
		return (P[a] - s).dot(t - s) < (P[b] - s).dot(t - s);
	}
};

inline bool getColor(int i) {
	return (0 <= i && i < N);
}

inline bool judge(Vector a, Vector b) {
	int n = 0;
	static int tmp[maxn];

	if (a.x == b.x && a.y == b.y) {
		return false ;
	}
	for (int i = 0;i < N;i++) {
		if ((P[i] - b).cross(a - b) > 0)
			return false ;
	}
	for (int i = N;i < all;i++) {
		if ((P[i] - b).cross(a - b) < 0) {
			return false ;
		}
	}
	for (int i = 0;i < all;i++) {
		if ((P[i] - b).cross(a - b) == 0) {
			tmp[n++] = i;
		}
	}
	Cmp cmp;
	cmp.s = a; cmp.t = b;
	sort(tmp, tmp + n, cmp);

	bool exp = 1;
	for (int i = 0;i < n;i++) {
		int t = tmp[i];
		if (exp == 1 && getColor(t) != getColor(tmp[0])) {
			exp = 0;
		}
		if ((getColor(t) == getColor(tmp[0])) != exp) {
			return false ;
		}
	}
	return true ;
}

int main() {
	while (scanf("%d%d", &N, &M), !(N == 0 && M == 0)) {
		for (int i = 0;i < N;i++) {
			scanf("%lld%lld", &P[i].x, &P[i].y);
		}
		for (int i = N;i < N+M;i++) {
			scanf("%lld%lld", &P[i].x, &P[i].y);
		}
		all = N + M;
		if (all <= 1) {
			puts("YES");
			continue ;
		}
		for (int i = 0;i < all;i++) {
			for (int j = 0;j < i;j++) {
				if (judge(P[i], P[j]) || judge(P[j], P[i])) {
					puts("YES");
					goto OUT;
				}
			}
		}
		puts("NO");
OUT:		;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  int num_ac = 0;
  int num_wa = 0;
  int num_tle = 0;
  int num_re = 0;

  string S[N];
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    if (S[i] == "AC"){
        num_ac += 1;
    }else if (S[i] == "WA"){
        num_wa += 1;
    }else if (S[i] == "TLE"){
        num_tle += 1;
    }else{
        num_re += 1;
    }
  }
    cout << "AC x " << num_ac <<endl;
    cout << "WA x " << num_wa <<endl;
    cout << "TLE x " << num_tle <<endl;
    cout << "RE x " << num_re <<endl;
  
}

Measured memory_bytes: 6752
import java.util.*

fun main(args:Array<String>){
    val (n,m) = readLine()!!.split(" ").map{it.toInt()}
    if(n >= m){
        repeat(n){
            print(m)
        }
        println()
    }
    else{
        repeat(m){
            print(n)
        }
        println()
    }
}


Measured memory_bytes: 37624
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  int n;
  string s;
  cin>>n>>s;
  fr(i, s.size()) s[i] = char((s[i] + n - 'A')%26+'A');
  cout << s << endl;


  return 0;
}

Measured memory_bytes: 256
N,Y = map(int,input().split())
A = list(range(0,N+1))
a=-1
b=-1
c=-1
for i in A:
    for j in list(range(0,N-i+1)):
        if 10000*i+5000*j+1000*(N-i-j) == Y:
            a=i
            b=j
            c=N-i-j
            break
print(a,b,c)


Measured memory_bytes: 3060
a,b,c = input().split()
if a>b :
    q = a
    a = b
    b = q
if b>c :
    q = b
    b = c
    c = q
if a>b :
    q = a
    a = b
    b = q
print(str(a) + " " + str(b) +  " " + str(c))


Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
#define MOD 1e9 + 7
#define endl '\n'

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

    int n;

    cin >> n;

    int c2 = 0,c4 = 0;
    int a;
    for(int i = 0;i < n;i++){ cin >> a; if(a%4==0) c4++; else if(a%2==0) c2++; }

    if((c2>=n-(c4*2) and n%2==0)or(c2>=n-(c4*2+1) and n%2==1 and c4>0)) cout << "Yes";
    else if(c2>=n-(c4*2) and n%2==1 and c4==0) cout << "Yes";
    else cout << "No";
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i=0; i<n; i++) cin >> a[i];
    
    map<int, int> bucket;
    for (int i=0; i<n; i++) {
        bucket[a[i]]++;
    }
    int num = bucket.size();
    int count[num];
    int idx = 0;
    for (auto itr = bucket.begin(); itr != bucket.end(); ++itr) {
        count[idx] = itr->second;
        idx++;
    }
    sort(count, count + num);
    int ans = 0;
    for (int i=0; i < num - k; ++i) {
        ans += count[i];
    }

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

Measured memory_bytes: 11136
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>
#include <queue>

#define PI 3.14159265358979
#define MOD 1000000007

//fixed << setprecision(15) <<

using namespace std;

int main(void) {
	long long int a, b, l, m, n;
	int x[100000], y[100000];
	string s, t;
	char u;
	int i, j, k;
	bool flag = true;
	cin >> n >> m;

	if (n <= m)cout << "unsafe" << endl;
	else cout << "safe" << endl;
	return 0;
}

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

using std::cout;
using std::endl;
using std::cin;
using std::vector;
using std::count;
using std::sort;
using std::string;

int main(){
    vector<string> V;
    int N,L;
    cin >> N >> L;
    V.resize(N);
    for(int i=0;i<N;i++){
      cin >> V[i];
    }
    sort(V.begin(),V.end());
    for(auto x:V){
      cout << x;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int Mod = 998244353;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b){ return a - b < 0 ? a - b + Mod : a - b; }
void Add(int &a, int b){ a = add(a,b); }
cs int N = 305;
int n, K; char S[N];
int a[N], len, dp[2][N][N];
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%s%d",S+1,&K); 
	K=min(K,n=strlen(S+1));S[n+1]='0';
	for(int i=1,pt=0; i<=n+1; i++){
		if(S[i]=='1')continue;
		a[++len]=i-pt-1; pt=i;
	} int now=0, nxt=1;
	dp[0][0][0]=1;
//	for(int i=1; i<=len; i++)
//	cout << a[i] << " "; cout << endl;
	for(int i=1; i<=len; i++){
		memset(dp[nxt],0,sizeof(dp[nxt]));
		for(int k=0; k<=K; k++){
			static int sm[N]; sm[0]=0;
			for(int l=1; l<=K; l++)
			sm[l]=add(sm[l-1],dp[now][l][k]);
			for(int j=0; j<=K; j++)
			Add(dp[nxt][j][k],dec(sm[min(K,j+a[i])],sm[j])); 
		} static int sm[N][N];
		for(int j=0; j<=K; j++)
		for(int k=0; k<=K; k++){
			sm[j][k] = dp[now][j][k];
			if(j && k) Add(sm[j][k],sm[j-1][k-1]);
			Add(dp[nxt][j][k],sm[j][k]);
		} swap(now, nxt);
	} 
	int ans = 0;
	for(int j=0; j<=K; j++)
	Add(ans, dp[now][0][j]);
	cout << ans; return 0;
}

Measured memory_bytes: 4744
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

void END(){cout << 1 << endl; exit(0);}

LL ans(LL x)
{
  if (x == 1) return 1;
  return (1 + 2*ans(x/2));
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL h;
  cin >> h;
  cout << ans(h);

  return 0;
}


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

// input
int R, C, K;
vector<int> r, c, v;

ll dp[3001][3001][4];
ll INF = 1e16;


void input() {
    cin >> R >> C >> K;
    r = c = v = vector<int>(K);
    rep(i, K) cin >> r[i] >> c[i] >> v[i];
}


int main() {
    input();
    map<P, int> m;
    rep(i, K) m[make_pair(r[i], c[i])] = v[i];
    rep(i, R + 1) rep(j, C + 1) rep(k, 4) dp[i][j][k] = -INF;
    dp[0][1][0] = dp[1][0][0] = 0;
    rep(i, R) rep(j, C) rep(k, 4) {
        ll x = dp[i + 1][j][k];
        if (k == 0) {
            rep(l, 4) x = max(x, dp[i][j + 1][l]);
        }
        P p(i + 1, j + 1);
        if (k > 0 && m.count(p)) {
            int v = m[p];
            x = max(x, dp[i + 1][j][k - 1] + v);
            if (k == 1) {
                rep(l, 4) x = max(x, dp[i][j + 1][l] + v);
            }
        }
        dp[i + 1][j + 1][k] = x;
    }
    ll ans = 0;
    rep(k, 4) ans = max(ans, dp[R][C][k]);
    cout << ans << endl;
}


Measured memory_bytes: 299472
x1,y1,x2,y2 = map(int,input().split())
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x1 + (y1 - y2)
y4 = y1 - (x1 - x2)
print(x3,y3,x4,y4)

Measured memory_bytes: 2940
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int v[20], c[20];

int main(void) {

	int n, k;
	string s;
	cin >> n >> s >> k;

	for (char& c : s) {
		if (s[k - 1] != c)
			c = '*';
	}

	COUT(s);

	return 0;
}


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

int main(){
    /*
    vector<ll> a(50, 50);
    ll cnt = 0;
    while(*max_element(a.begin(), a.end()) >= 50){
        cerr << 50 - cnt << ": ";
        rep(i, 0, 50) cerr << a[i] << " ";
        cerr << endl;
        auto itr = max_element(a.begin(), a.end());
        *itr -= 51;
        rep(i, 0, 50) a[i]++;
        cnt++;
    }
    */
    ll K;
    cin >> K;
    ll base = K / 50 + 49;
    ll i = K % 50; 
    cout << 50 << endl;
    rep(j, 0, 50-i){
        cout << base - i;
        if(j != 49) cout << " ";
    }
    rep(j, 0, i){
        cout << base + 50 - i + 1;
        if(j != 49) cout << " ";
    }
    cout << 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
#define MOD_BIG2 998244353
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...);
}

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

using P = std::pair<ll, ll>;

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

int main() {
    
    ll N;
    cin >> N;
    vector<vector<P>> g(N);
    for (ll i = 0; i < N-1; i++) {
        ll a, b;
        cin >> a >> b;
        g[a-1].push_back(std::make_pair(i, b-1));
        g[b-1].push_back(std::make_pair(i, a-1));
    }
    ll K = 0;
    ll rt = 0;
    for (ll i = 0; i < N; i++) {
        if (K < g[i].size()) {
            K = g[i].size();
            rt = i;
        }
    }
    cout << K << endl;
    
    vector<ll> ans(N-1, 0);
    vector<ll> dist(N, -1);
    dist[rt] = 0;
    std::queue<P> que;
    que.push(P(rt, 0));
    while(!que.empty()) {
        auto p = que.front();
        auto v = p.first;
        que.pop();
        int c = 1;
        for (auto n : g[v]) {
            //cerr << n.second << endl;
            if (c == p.second) {
                c++;
            }
            if (dist[n.second] != -1) continue;
            dist[n.second] = dist[v] + 1;
            if (ans[n.first] == 0) {
                ans[n.first] = c;
            }
            que.push(P(n.second,c));
            c++;
        }
    }
    for (ll i = 0; i < N-1; i++) {
        cout << ans[i] << endl;
    }
    return 0;
    
    return 0;
}


Measured memory_bytes: 9728
n=gets.to_i
a=gets.split.map(&:to_i)
result=10000000000
for i in -110..110
    s=[]
    s[0]=0
    for j in 0..n-1
        s[j+1]=s[j]+(a[j]-i)**2
    end
    result=[result,s[-1]].min
end
p result

Measured memory_bytes: 14560
/*<----------------------------------------------------------------------->

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
long const M=1e9+7;
const long mxN =1e2+2 ;
const long mxNN =1e6+2 ;
int n,m,a[mxN] ,s=0;
void solve(){
    cin >> n >> m ;
    For(i,n){cin >>a[i] ;s+=a[i];} 
    sort(a,a+n);
    reverse(a,a+n) ;
    For(i,m){
        if(a[i]*(4*m)<s){
            pf("No") ;
            return ;
        }
    }
    pf("Yes") ;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout << setprecision(20) << fixed ;
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 256
n, k, q = map(int, input().split())

scores = {i: 0 for i in range(1, n+1)}
for _ in range(q):
    n = int(input())
    scores[n] += 1

for i, score in sorted(scores.items()):
    if k + score - q > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 20328
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <iomanip>
#define ll long long int
#define mod 1000000007
#define pii pair<int, ll>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

vector<pii> g[100005];
ll d[100005];

void DFS(pii x, int p) {
    d[x.first] = d[p] + x.second;
    for (pii i : g[x.first]) if (i.first != p) DFS(i, x.first);
}

int main() {
    ios::sync_with_stdio(false);
    int n, a, b, c, q, k;
    cin >> n;
    fr1(n - 1) cin >> a >> b >> c, g[a].push_back({b, c}), g[b].push_back({a, c});
    cin >> q >> k;
    DFS({k, 0}, k);
    //fr1(n) cout << d[i] << ' ';
    while (q--) cin >> a >> b, cout << d[a] + d[b] << '\n';
}


Measured memory_bytes: 14336
n = gets.to_i
s = gets.strip.to_s  

str_array = s.each_codepoint.to_a
x = 0

while x < str_array.size
   str_array[x] = ((str_array[x]-65)+n) % 26
   str_array[x] = str_array[x] + 65
   x += 1
end

s = str_array.map {| x | x.chr }

x = 0
while x < s.size
   printf "#{s[x]}"
   x += 1
end
printf "\n"


Measured memory_bytes: 2812
#include<stdio.h>
#include<memory.h>
#include<algorithm>
#include<vector>
using namespace std;
#define INF 0x7ffffffff
int main()
{
    int N, W;
    //freopen("input.txt", "r", stdin);
    scanf("%d%d", &N, &W);
    vector<int>w(N);
    vector<int>v(N);
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &w[i], &v[i]);
    }
    vector<vector<long> > dp(N+1, vector<long>(N*1000+1, INF));
    dp[0][0] = 0;
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<=N*1000; j++)
        {
            if(j>=v[i])dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]]+w[i]);
            else dp[i+1][j] = dp[i][j];
        }
    }
    long ans = 0;
    for(long i=0; i<=N*1000; i++)
    {
       if(dp[N][i] <= W)ans = max(ans, i);
    }
    printf("%ld\n", ans);
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second


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


	ll n;
	cin>>n;
	ll a[10],b[10];
	memset(a,0,sizeof a);
	memset(b,0,sizeof b);

	ll ans=0;
	map <pair <ll,ll>,ll> m;
	for(ll i=1;i<10;i++)
		for(ll j=1;j<10;j++)
		{
			m[{i,j}]=0;
			m[{j,i}]=0;
		}
	for(ll i=1;i<=n;i++)
	{
		ll j=i;
		ll y=i%10;
		ll x;
		while(j>0)
		{
			x=j%10;
			j/=10;
		}
		m[{x,y}]++;
	}
	for(ll i=1;i<10;i++)
	{
		for(ll j=1;j<10;j++)
		{
			ans+=(m[{i,j}]*m[{j,i}]);
		}
	}
	cout<<ans<<'\n';
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

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

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

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

	vector<pair<int, int>> l(n);

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

		l[i] = make_pair(a, b);
	}

	sort(l.begin(), l.end());

	int now = 0;
	int ans = 0;

	for (int i = 0; i < n; i++){
		if (i == 0){
			ans += l[i].first;
		} else {
			ans += min(l[i - 1].second - l[i].second, l[i].first - l[i - 1].first);
		}
	}

	ans += l[n - 1].second;

	cout << ans << endl;


} 


Measured memory_bytes: 1024
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize, k: usize,
        mut hv: [u64; n]
    };

    hv.sort();
    let res = if k >= n {
        0
    } else {
        hv.into_iter().take(n - k).sum::<u64>()
    };
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 5200
#include <iostream>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#define myfor(i,N) for(i=0;i<N;i++)
#define myforFL(i,f,l) for(i=f;i<l;i++)

using namespace std;

int main(){
	int N,h[100001],i;
	long dp[100001]={};

	cin >> N;
	myforFL(i,1,N+1){
		cin >> h[i];
	}
	dp[2] = abs(h[2]-h[1])+dp[1];
	myforFL(i,3,N+1){
		dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
	}
	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 1408