akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
class Edge{
    public:
        int s, e;
        long long v;
        Edge(int a, int b, long long c){
            s = a;
            e = b;
            v = c;
        }
        bool operator<(const Edge &o) const{
            return v>o.v;
        }
};
vector<Edge> adj[100001];
int n;
long long mod = 1000000007LL;
vector<long long> bfs(int s){
    vector<long long> ret;
    ret.resize(n);
    for(int i = 0; i<n; i++){
        ret[i] = -1LL;
    }
    priority_queue<Edge> pq;
    pq.push(Edge(s,s,0LL));
    while(pq.size()>0){
        Edge now = pq.top();
        pq.pop();
        if(ret[now.e]>=0LL){
            continue;
        }
        ret[now.e] = now.v;
        for(int i = 0; i<adj[now.e].size(); i++){
            pq.push(Edge(-1,adj[now.e][i].e,adj[now.e][i].v+now.v));
        }
    }
    return ret;
}
vector<long long> bfs2(int s){
    vector<long long> ret;
    ret.resize(n);
    for(int i = 0; i<n; i++){
        ret[i] = -1LL;
    }
    priority_queue<Edge> pq;
    pq.push(Edge(s,s,0LL));
    while(pq.size()>0){
        Edge now = pq.top();
        pq.pop();
        if(ret[now.e]>=0LL){
            continue;
        }
        ret[now.e] = now.v;
        for(int i = 0; i<adj[now.e].size(); i++){
            pq.push(Edge(-1,adj[now.e][i].e,adj[now.e][i].v+now.v));
        }
    }
    vector<long long> ret2;
    ret2.resize(n);
    for(int i = 0; i<n; i++){
        ret2[i] = 0LL;
    }
    ret2[s] = 1LL;
    for(int i = 0; i<n; i++){
        pq.push(Edge(i,i,ret[i]));
    }
    while(pq.size()>0){
        Edge now = pq.top();
        pq.pop();
        for(int i = 0; i<adj[now.e].size(); i++){
            if(now.v+adj[now.e][i].v == ret[adj[now.e][i].e]){
                ret2[adj[now.e][i].e] = (ret2[adj[now.e][i].e]+ret2[now.e])%mod;
            }
        }
    }
    return ret2;
}
int main(){
    int m, s, t;
    cin >> n >> m >> s >> t;
    s--;
    t--;
    for(int i = 0; i<m; i++){
        int a, b;
        long long c;
        cin >> a >> b >> c;
        a--;
        b--;
        adj[a].push_back(Edge(a,b,c));
        adj[b].push_back(Edge(b,a,c));
    }
    vector<long long> a = bfs(s);
    vector<long long> b = bfs(t);
    vector<long long> wa = bfs2(s);
    vector<long long> wb = bfs2(t);
    long long ans = (wa[t]*wb[s])%mod;
    for(int i = 0; i<n; i++){
        for(int j = 0; j<adj[i].size(); j++){
            Edge e = adj[i][j];
            if(a[e.s]+b[e.e]+e.v != a[t]){
                continue;
            }
            if(a[e.s]+e.v<=b[e.e] || b[e.e]+e.v<=a[e.s]){
                continue;
            }
            ans -= ((wa[e.s]*wb[e.e])%mod)*((wa[e.s]*wb[e.e])%mod);
            ans %= mod;
            ans = (ans+mod)%mod;
        }
    }
    for(int i = 0; i<n; i++){
        if(a[i]==b[i] && a[i]+b[i]==a[t]){
            ans -= ((wa[i]*wb[i])%mod)*((wa[i]*wb[i])%mod);
            ans %= mod;
            ans = (ans+mod)%mod;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 23512
var a,b,x,i:integer;
begin
read(a,b);
x := 0;
for i := 0 to 1 do
begin
  if a < b then
  begin
      x	:= x + b;
      b	:= b -1;
  end
  else
  begin
      x	:= x + a;
      a	:= a -1;
  end;
end;
writeln(x);
end.
    
end.

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

int N, Q;
int S[202020], T[202020], X[202020], D[202020];

template <typename T, typename E>
struct LazySegmentTree {
  using F = function<T(T, T)>;
  using G = function<T(T, E)>;
  using H = function<E(E, E)>;
  using P = function<E(E, int)>;
  int n;
  F f;
  G g;
  H h;
  P p;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> laz;

  LazySegmentTree() {}

  LazySegmentTree(int n_, F f, G g, H h, T d1, E d0,
                  vector<T> v = vector<T>(), P p = [](E a, int b) { return a; }) : f(f), g(g), h(h), d1(d1), d0(d0), p(p) {
    init(n_);
    if (n_ == (int)v.size()) build(n_, v);
  }

  void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    dat.clear();
    dat.resize(2 * n - 1, d1);
    laz.clear();
    laz.resize(2 * n - 1, d0);
  }

  void build(int n_, vector<T> v) {
    for (int i = 0; i < n_; i++) dat[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--)
      dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]);
  }

  inline void eval(int len, int k) {
    if (laz[k] == d0) return;
    if (k * 2 + 1 < n * 2 - 1) {
      laz[k * 2 + 1] = h(laz[k * 2 + 1], laz[k]);
      laz[k * 2 + 2] = h(laz[k * 2 + 2], laz[k]);
    }
    dat[k] = g(dat[k], p(laz[k], len));
    laz[k] = d0;
  }

  T update(int a, int b, E x, int k, int l, int r) {
    eval(r - l, k);
    if (r <= a || b <= l) return dat[k];
    if (a <= l && r <= b) {
      laz[k] = h(laz[k], x);
      return g(dat[k], p(laz[k], r - l));
    }
    return dat[k] = f(update(a, b, x, k * 2 + 1, l, (l + r) / 2),
                      update(a, b, x, k * 2 + 2, (l + r) / 2, r));
  }

  T update(int a, int b, E x) {
    return update(a, b, x, 0, 0, n);
  }

  T query(int a, int b, int k, int l, int r) {
    eval(r - l, k);
    if (r <= a || b <= l) return d1;
    if (a <= l && r <= b) return dat[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return f(vl, vr);
  }

  T query(int a, int b) {
    return query(a, b, 0, 0, n);
  }
};

signed main() {
  cin >> N >> Q;

  vector<int> c;
  c.push_back(-1e18);
  c.push_back(1e18);

  for (int i = 0; i < N; i++) {
    cin >> S[i] >> T[i] >> X[i];
    c.push_back(S[i] - X[i]);
    c.push_back(T[i] - X[i]);
  }

  for (int i = 0; i < Q; i++) {
    cin >> D[i];
    c.push_back(D[i]);
  }

  sort(c.begin(), c.end());
  c.erase(unique(c.begin(), c.end()), c.end());

  map<int, int> mp;
  for (int i = 0; i < c.size(); i++) {
    mp[c[i]] = i;
  }

  LazySegmentTree<int, int> seg(c.size(),
                                [&](int a, int b) { return min(a, b); },
                                [&](int a, int b) { return min(a, b); },
                                [&](int a, int b) { return min(a, b); },
                                1e18, 1e18);

  for (int i = 0; i < N; i++) {
    int l = mp[S[i] - X[i]];
    int r = mp[T[i] - X[i]];
    seg.update(l, r, X[i]);
  }

  for (int i = 0; i < Q; i++) {
    int x = mp[D[i]];
    int res = seg.query(x, x + 1);

    if (res >= 1e17) {
      cout << -1 << endl;
    } else {
      cout << res << endl;
    }
  }
  return 0;
}


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

using namespace std;

int main(){
    long long n,a[10000];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    cout << *min_element(a,a+n)<< " " << *max_element(a,a+n)<< " " <<  accumulate(a,a+n,0LL) << endl;

}



Measured memory_bytes: 3144
#include <stdio.h>
#include <string.h>
#include<iostream>
#include <algorithm>
using namespace std;
//sort(a, a + N, greater<int>());
//n：数の個数、偶数
int main(void){
	int n,i;
	int *x,*xx;
	int center;
	scanf("%d",&n);
	x = new int[n];
	xx = new int[n];
	
	for(i = 0; i< n; i++)
		scanf("%d",&x[i]);
	center = n/2;
	memcpy(xx,x,sizeof(int)*n);
	sort(x,x+n,greater<int>());
	for(i = 0; i < n; i++){
		if(xx[i] < x[center-1])
			printf("%d\n",x[center-1]);
		else if(i == center)
			printf("%d\n",x[center]);
		else
			printf("%d\n",x[center]);
	}
	delete x;
}

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

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

	int maxv = -1e9;
	int minv;
	cin >> minv;

	int r;

	for (int i = 1; i <= n-1; i++) {
		cin >> r;
		maxv = max(maxv, r-minv);
		minv = min(minv, r);

	}

	cout << maxv << '\n';
	return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=(b);++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define pi pair<int, int>
#define mk make_pair
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main()
{
	int n,m;
	cin>>n>>m;
	int ans=n*(n-1)/2+(m*(m-1)/2);
	cout<<ans<<endl;

}


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

using namespace std;

int N, M;
string s[100], t[100];

void solve() {
    map<string, int> values;
    for (int i = 0; i < N; ++i) {
        values[s[i]] = 0;
    }
    for (int i = 0; i < M; ++i) {
        values[t[i]] = 0;
    }
    for (int i = 0; i < N; ++i) {
        values[s[i]] += 1;
    }
    for (int i = 0; i < M; ++i) {
        values[t[i]] -= 1;
    }
    int max = 0;
    for (const auto &x : values) {
        if (max < x.second) max = x.second;
    }
    printf("%d\n", max);

}

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> s[i];
    }
    cin >> M;
    for (int j = 0; j < M; ++j) {
        cin >> t[j];
    }
    solve();
    return 0;
}

Measured memory_bytes: 3732
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)
from collections import deque, defaultdict
n, m = map(int, input().split())
#隣接リスト
G = defaultdict(lambda:[])
#################################
for _ in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    G[a].append(b)
    G[b].append(a)
    
#################################
ddd = {}
for i in range(n):
    ddd[i] = False
#幅優先探索でトポロジカル順序を求める
parent = [-1]*n #parent[i] : 頂点iの親
order = []
#頂点iからの深さ優先探索
def bfs(i):
    parent[i] = -1
    stack = deque()
    u = i
    stack.append(u)
    ddd[i] = True
    while stack:
        x = stack.popleft()
        order.append(x)
        for v in G[x]:
            if v == parent[x]:
                continue
            if parent[v] != -1:
                continue
            parent[v] = x
            ddd[v] = True
            stack.append(v)
            
bfs(0)

b = True
for i in range(n):
    if ddd[i]:
        continue
    else:
        b = False
        print(i)
if not b:
    print('No')
else:
    print('Yes')
    for i in range(1, n):
        print(parent[i]+1)
        





Measured memory_bytes: 51132
from collections import OrderedDict
N=int(input())
d=dict()
A=[]
ma=0
for i in range(N):
  s=input()
  if s not in d:
    d[s]=0
  d[s]+=1
d=OrderedDict(sorted(d.items(), key=lambda x:x[1], reverse=True))
for i in d:
  if ma<=d[i]:
    ma=d[i]
  if ma!=d[i]:
    break
  A.append(i)
print(*sorted(A),sep="\n")

Measured memory_bytes: 107100
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n, a, b, c int
	fmt.Fscan(r, &n, &a, &b, &c)
	v := make(map[byte]int)
	v['A'], v['B'], v['C'] = a, b, c
	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &s[i])
	}

	ans := make([]byte, 0, n)

	choose := func(s string, i int) {
		v[s[i]]++
		v[s[i^1]]--
		ans = append(ans, s[i])
	}

	chooseAny := func(s string) {
		if v[s[0]] == 0 {
			choose(s, 0)
		} else {
			choose(s, 1)
		}
	}

	for i := 0; i < n; i++ {
		if v[s[i][0]] == 0 && v[s[i][1]] == 0 {
			fmt.Fprintln(w, "No")
			return
		}
		if i == n-1 || v[s[i][0]] == 0 || v[s[i][1]] == 0 {
			chooseAny(s[i])
		} else {
			if s[i][0] == s[i+1][0] || s[i][0] == s[i+1][1] {
				choose(s[i], 0)
			} else {
				choose(s[i], 1)
			}
		}
	}

	fmt.Fprintln(w, "Yes")
	for i := 0; i < n; i++ {
		fmt.Fprintf(w, "%c\n", ans[i])
	}
}


Measured memory_bytes: 3800
# N Y
#
# [10000, 5000, 1000]

n, y = gets.chomp.split(" ").map(&:to_i)

r = []

(0..(y / 10000)).each do |i|
  m = y - (10000 * i)
  (0..(m / 5000)).each do |j|
    l = m - (5000 * j)
    k = l / 1000

    if (i + j + k) == n
      r << [i, j, k]
    end
  end
end

if r.first
  puts r.first.join(" ")
else
  puts "-1 -1 -1"
end


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

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    auto A = readln.split.map!(to!int).array;
    A.map!(a => a >= K).sum.writeln;
}


Measured memory_bytes: 4032
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#define ll long long
using namespace std;

int main(){
    int sum=10;
    for(int i=0;i<5;i++){
        int a;
        cin>>a;
        sum-=a;
    }
    cout<<sum+5<<endl;
}

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

using namespace std;

int main() {
	long long n;
	cin >> n;
	vector<long long> v(n);
	for (long long i = 0; i < n; i++)cin >> v[i];
	vector<vector<long long>> dp(n, vector<long long>(n));
	for (long long l = n - 1; l >= 0; l--) {
		for (long long r = l; r < n; r++) {
			if (l == r) dp[l][r] = v[l];
			else {
				dp[l][r] = max(v[l] - dp[l + 1][r], v[r] - dp[l][r - 1]);
			}
		}
	}
		cout << dp[0][n - 1];
}

Measured memory_bytes: 73672
import math
from decimal import *
a, b, h, m = map(int,input().split())

a_s = (30 * h) + 0.5 * m
b_s = (6 * m)%360

s = max(a_s,b_s) - min(a_s,b_s)

if s == 0:
    print(abs(a-b))
elif s == 180:
    print(a+b)
else:
    a = Decimal(a)
    b = Decimal(b)
    t = Decimal(2)
    ans = Decimal(math.sqrt(a**t + b**t - t*a*b*Decimal(math.cos(math.radians(s)))))
    print(ans)

Measured memory_bytes: 10020
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;
// const double PI = M_PI;

int q;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> q;
  rep(i, q) {
    string x, y;
    cin >> x >> y;
    int dp[y.size() + 1][x.size() + 1];
    rep(j, y.size() + 1) {
      fill(dp[j], dp[j] + x.size() + 1, INF);
      dp[j][0] = 0;
    }
    fill(dp[0], dp[0] + x.size() + 1, 0);

    for (int j = 1; j <= y.size(); j++) {
      for (int k = 1; k <= x.size(); k++) {
        if (y[j - 1] == x[k - 1]) {
          dp[j][k] = dp[j - 1][k - 1] + 1;
        } else {
          dp[j][k] = max(dp[j][k - 1], dp[j - 1][k]);
        }
      }
    }

    cout << dp[y.size()][x.size()] << endl;
  }

  return 0;
}



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

int main() {
   string s;
   cin >> s;
   string ans;
   for(int i=0;i<s.size();i+=2)
     ans+=s[i];
   cout << ans << endl;
}

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

int main() {
  
  string S;
  cin >> S;
  int sum;
  string len;
  string s;
  for(int i = 0;i < (1 << 3);i++)
  {
    len = S.substr(0,1);
    sum = stoi(len);
    bitset<3> bit(i);
    for(int j = 0;j < 3;j++)
    {
      s = S.substr(j + 1,1);
      if(bit.test(j))
      {
        sum += stoi(s);
        len+= + "+";
      }
      else
      {
        sum -= stoi(s);
        len += "-";
      }
      
      len += s;
    }
    
    if(sum == 7)
    {
      
      cout << len << "=7" << endl;
      break;
    }
  }
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
char s[10];
int a[10];
int n,m,x,c;
int main()
{
	cin>>n>>m;
	bool flag=1;
	memset(a,-1,sizeof(a));
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&c);
		if(a[x]!=-1&&a[x]!=c)
			flag=0;
		a[x]=c;
	}
	if(n!=1&&a[1]==0)
		flag=0;
	if(!flag)
	{
		cout<<-1;
	}
	else
	{
		if(n==1)
		{
			cout<<max(0,a[1]);
		 } 
		 else
		 {
			for(int i=1;i<=n;i++)
			{
				if(i==1)
					cout<<max(1,a[i]);
				else
					cout<<max(0,a[i]);
			}
		}
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}


int n;
int x[24];
int y[24];
int r[24];
int c[24];
int ans;
bool memo[1 << 24];

inline int dbl(int x){ return x * x; }

int main(){
  while(scanf("%d", &n), n){
    REP(i,n) scanf("%d%d%d%d", x+i, y+i, r+i, c+i);
    memset(memo, 0, sizeof(memo)); ans = 0;

    stack<int> q;
    q.push((1 << n) - 1);
    memo[(1<<n) - 1] = true;

    while(q.size()){
      int flag = q.top(); q.pop();
      bool top[24]; REP(i,24) top[i] = true;

      ans = max(ans, n - __builtin_popcount(flag));
      if(ans == n) break;

      for(int i = 0; i < n; i++){
        if(flag & (1 << i)){
          for(int j = i + 1; j < n; j++){
            if(top[j] && (flag & (1 << j))){
              if(dbl(x[i] - x[j]) + dbl(y[i] - y[j]) < dbl(r[i] + r[j])){
                top[j] = false;
              }
            }
          }
        }
      }

      for(int i = 0; i < n; i++){
        if((flag & (1 << i)) && top[i]){
          for(int j = i + 1; j < n; j++){
            if(top[j] && (flag & (1 << j)) && c[i] == c[j]){
              int next = flag ^ (1 << i) ^ (1 << j);
              if(!memo[next]){
                q.push(next);
                memo[next] = true;
              }
            }
          }
        }
      }
    }

    print(ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    vector<int> abc(3);
    for(int i=0;i<3;i++){
        cin>>abc[i];
    }
    sort(abc.begin(),abc.end());
    cout<<10*abc[2]+abc[1]+abc[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;


int main()
{
	int n;
	cin >> n;
	vector<int> aa(n + 1);
	vector<int> bb(n);
	rep(i, n + 1) cin >> aa[i];
	rep(i, n) cin >> bb[i];
	ll sum = 0;
	rep(i, n + 1) sum += aa[i];
	ll sa = 0;
	rep(i, n) {
		if (aa[i] >= bb[i]) {
			aa[i] -= bb[i];
			bb[i] = 0;
		}
		else {
			bb[i] -= aa[i];
			aa[i] = 0;
		}
		if (aa[i+1] >= bb[i]) {
			aa[i+1] -= bb[i];
		}
		else {
			aa[i+1] = 0;
		}
		sa += aa[i];
	}
	sa += aa[n];
	ll ans = sum - sa;
	cout << ans;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int mk = 0;
	while(a > 0 && c > 0){
		if(mk == 0){
			c -= b;
		}
		else a -= d;
		mk ^= 1;
	}
	//cout << a << " " << c << '\n';
	if(a <= 0){
		cout << "No\n";
	}
	else cout << "Yes\n";


}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC81
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }
        
        public static void a()
        {
            string s = Console.ReadLine();
            int ans = 0;
            for(int i = 0; i < 3; i++)
            {
                if (s[i] == '1')
                    ans++;
            }
            Console.WriteLine(ans);
        }

        public static void b()
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] % 2 == 1)
                { break; }
                else
                {
                    a[i] /= 2;  
                }
                if (i == n - 1)
                {
                    ans++;
                    i = 0;
                }
            }

            Console.WriteLine(ans);
        }

    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    string s,t,u; cin >> s >> t;
    int a,b; cin >> a >> b;
    cin >> u;
    if(s==u) cout << a-1 << " " << b << endl;
    else cout << a << " " << b -1 << endl;

    return 0;
}

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

int main() {
    int n,m;
    cin>>n>>m;
    priority_queue<pair<int,int>> q;
    rep(i,n){
        int a;
        cin>>a;
        q.push(make_pair(a,1));
    }
    rep(i,m){
        int b,c;
        cin>>b>>c;
        q.push(make_pair(c,b));
    }
    
    ll ans =0;
    rep(i,n){
        auto p=q.top();
        q.pop();
        ans += p.first;
        if(p.second>1){
            p.second--;
            q.push(p);
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 2420
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int l = sc.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }

        Arrays.sort(s);
        StringJoiner sj = new StringJoiner("");
        for (int j = 0; j < n; j++) {
            sj.add(s[j]);

        }
        System.out.println(sj.toString());
    }

}


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

class Main {

    private static PrintWriter out;

    private static <T> void mprintln(T... ar) {
        for (T i : ar) {
            out.print(i + " ");
        }
        out.println();
    }

    public static void main(String[] args) throws FileNotFoundException {

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    /*
     *Don't use builtin function (Math.ceil)
     */

    static final long MOD = (long) (1e9 + 7);

    private static void getAns(MyScanner sc) {
        int n = sc.ni(), d = sc.ni();
        int one = 2 * d + 1;
        out.println((int) Math.ceil((double) n / one));
    }

    static class MyScanner {

        BufferedReader br;
        StringTokenizer st;

        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

        char nc() {
            return nn().charAt(0);
        }

        int ni() {
            return Integer.parseInt(nn());
        }

        long nl() {
            return Long.parseLong(nn());
        }

        double nd() {
            return Double.parseDouble(nn());
        }

        int[] niArr0(int n) {
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) {
                ar[i] = ni();
            }
            return ar;
        }

        int[] niArr1(int n) {
            int[] ar = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = ni();
            }
            return ar;
        }

        long[] nlArr0(int n) {
            long[] ar = new long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nl();
            }
            return ar;
        }

        long[] nlArr1(int n) {
            long[] ar = new long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nl();
            }
            return ar;
        }
    }
}

Measured memory_bytes: 21204
N, M = list(map(int,input().split()))
if abs(N - M) >= 2:
    print(0)
else:
    ans = 1
    if N == M:
        ans = 2
    for i in range(1, N+1):
        ans = (ans * i) % ((10 ** 9) + 7)
    for i in range(1, M+1):
        ans = (ans * i) % ((10 ** 9) + 7)
    print(ans)



Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	scanf("%d", &n);
	int x = 987654321;
	for (int i = 1; i <n; i++)
	{
		int p = i;
		int y = n -i;
		int o = 0,oo=0;
		while (p)
		{
			o = o + (p % 10);
			p = p / 10;
		}
		while (y)
		{
			oo = oo + (y % 10);
			y /= 10;
		}
		x = min(x, o+oo);
	}
	printf("%d", x);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007


#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }




map< int, int > prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}



void solve(void)
{
  int N;cin>>N;
  auto pf = prime_factor(N);
  int ANS = 0;
  for (auto &&x : pf)
  {
    int q = 1;
    while(true)
    {
      if(x.second < q)
      {
        break;
      }
      x.second -= q;
      q++;
      ANS++;
    }
  }
  cout<<ANS<<endl;
  
  
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

class info
{
public:
	int c, s, f;

public:
	info(int _c, int _s, int _f)
		: c(_c), s(_s), f(_f)
	{}
};

int N;
vector<info> info_list;

int process(int start)
{
	int curr = info_list[start].s + info_list[start].c;

	for (int i = start + 1; i < N - 1; i++)
	{
		int remain = 0;
		if (curr < info_list[i].s)
		{
			remain = (info_list[i].s - curr);
		}
		else if ((curr - info_list[i].s) % info_list[i].f != 0)
		{
			remain = info_list[i].f - (curr - info_list[i].s) % info_list[i].f;
		}
		curr += remain + info_list[i].c;
	}

	return curr;
}

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

	cin >> N;

	for (int i = 0; i < N - 1; i++)
	{
		int c, s, f;
		cin >> c >> s >> f;

		info_list.emplace_back(c, s, f);
	}

	for (int i = 0; i < N - 1; i++)
	{
		cout << process(i) << "\n";
	}

	cout << 0;

	return 0;
}


Measured memory_bytes: 256
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();
    let n = lines.next().unwrap().unwrap().parse::<i64>().unwrap();

    let ans = (1i64..)
        .take_while(|i| i * i <= n)
        .filter(|i| n % i == 0)
        .map(|i| i + n / i - 2)
        .min()
        .unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
const int N=1e5+100;
int x[N];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>x[i];
    int ans=0x3f3f3f3f;
    for(int i=1;i<=n-k+1;i++)
    {
        int left=i;int right=i+k-1;
        if(x[left]<=0&&x[right]<=0)
        {
            ans=min(ans,-x[left]);
        }
        else if(x[left]<=0&&x[right]>=0)
        {
            ans=min(ans,2*x[left]*(-1)+x[right]);
            ans=min(ans,2*x[right]+x[left]*(-1));
        }
        else ans=min(ans,x[right]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n, m = f.read_int_list()
    d = collections.defaultdict(list)
    for _ in xrange(n):
        a, b = f.read_int_list()
        d[a].append(b)

    h = []

    ans = 0
    for i in xrange(m+1):
        for di in d[i]:
            heapq.heappush(h, -di)
        if len(h) == 0:
            continue
        ans -= heapq.heappop(h)

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


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

using namespace std;

const int MX = 1 << 18, md = 1000000007;

int here[18][MX], last[18][MX], dead[18], alive[18];

int main() {
	int h;
	ignore = scanf("%d", &h);
	
	int n = 1 << (h - 1), ans = 0;
	for (int i = 0, a; i < n; i++) {
		ignore = scanf("%d", &a);
		
		for (int u = n + i, p = 1, d = 0; u != 1; d++, u /= 2) {
			p = p * 1LL * u % md;
			
			for (int v = n + a - 1, q = p; v != 1; v /= 2) {
				q = q * 1LL * v % md;
				
				if (u % 2 == 0) {
					alive[d] = dead[d];
					
					int& val = here[d][v];
					if (last[d][v] < alive[d]) {
						last[d][v] = alive[d];
						val = q;
					}
					else {
						val += q;
						if (val >= md) val -= md;
					}
				}
				else {
					dead[d]++;
					
					if (last[d][v ^ 1] == alive[d]) {
						int there = here[d][v ^ 1];
						ans += q * 1LL * there % md * (v / 2) % md * (u / 2) % md;
						if (ans >= md) ans -= md;
					}
				}
			}
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 37632
#include<iostream>
#include<algorithm>
using namespace std;
int abs(int a){if(a<0)return -a;else return a;}
int main(){
	int N,X,Y,k[2000]={0};
	cin>>N>>X>>Y;
	for(int i=1;i<=N-1;i++){
		for(int j=i+1;j<=N;j++){
			k[min(j-i,abs(i-X)+abs(j-Y)+1)]++;
		}
	}
	for(int i=1;i<N;i++)cout<<k[i]<<endl;
	return 0;
}

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

int a[300000];
ll l[200001], r[200001];

int main() {
  int n, n2, n3;
  scanf("%d", &n);
  n2 = 2*n;
  n3 = 3*n;
  for (int i = 0; i < n3; ++i) scanf("%d", a+i);

  ll sum = 0;

  {
    priority_queue<int, vector<int>, greater<int>> pq;
    for (int i = 0; i < n; ++i) {
      sum += a[i];
      pq.push(a[i]);
    }

    l[n-1] = sum;
    for (int i = n; i < n2; ++i) {
      pq.push(a[i]);
      sum += a[i] - pq.top();
      pq.pop();
      l[i] = sum;
    }
  }
  
  {
    priority_queue<int> pq;
    sum = 0;
    for (int i = n3-1; i >= n2; --i) {
      sum += a[i];
      pq.push(a[i]);
    }

    r[n2] = sum;
    for (int i = n2-1; i >= n; --i) {
      pq.push(a[i]);
      sum += a[i] - pq.top();
      pq.pop();
      r[i] = sum;
    }
  }

  ll ans = -(1ll<<62);
  for (int i = n; i <= n2; ++i) ans = max(ans, l[i-1] - r[i]);
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 4212
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int P;
    int Q;
    int R;

    cin >> P;
    cin >> Q;
    cin >> R;

    int ans1;
    int ans2;
    int ans3;

    ans1 = P + Q;
    ans2 = P + R;
    ans3 = Q + R;
    

    int array[3] = {ans1, ans2, ans3};

    int min=200;
    
    for (int i = 0; i < 3;  ++i){
       if (array[i] < min) 
       min = array[i];
    }

    cout << min << endl;

}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    ll N;cin>>N;
    for(ll i=1;i<=3500;++i){
        for(ll j=1;j<=3500;++j){
          if((4*i*j-N*i-N*j)>0){
            if((N*i*j)%(4*i*j-N*i-N*j)==0){
                cout<<i<<" "<<j<<" "<<(N*i*j)/(4*i*j-N*i-N*j)<<endl;
                return 0;
            }
          }
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  std::sort(d.begin(), d.end());
  decltype(d)::iterator result = std::unique(d.begin(), d.end());
  d.erase(result, d.end());
  cout << d.size() << endl;
  return 0;
}

Measured memory_bytes: 256
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int MOD = 1e9 + 7;

int inv[200000+4]; 
int invF[200000+4];
void build_inverse_factorial_table(int N, int P) {
   inv[0]  = inv[1] = 1;
   invF[0] = invF[1] = 1;
   for (int i = 2; i <= N; ++i) {
   // inv[i] = (-(P/i) * 1LL * inv[P % i] ) % P + P;
      inv[i] = (P - (P / i) * 1LL * inv[P % i] % P) % P;
      invF[i] = (invF[i-1] * 1LL * inv[i]) % P;
   }
}

long long nCk(int n, int k) {
   if (n < 0 || k < 0 || k > n)  // invalid n or k
      return 0;
   if (k > n-k)
      k = n-k;
   long long res = 1;
   for (int i = 1; i <= k; ++i, --n)
      res = (res * n) % MOD;

   res = (res * invF[k]) % MOD;

   return res;
}

unsigned int powmod(unsigned long long x, unsigned long long n, unsigned int m) {
   unsigned long long res = 1 % m;
   x %= m;
   for (; n > 0; n >>= 1) {
      if (n & 1) {
         res = (res * x) % m;
      // n--;
      }
      x = (x * x) % m;
   }
   return (unsigned int) res;
}


int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N, A, B;
   cin >> N >> A >> B;

   build_inverse_factorial_table(max(A, B)+1, MOD);

   llong total = powmod(2, N, MOD);
// cerr << total << endl;

   int nexA = nCk(N, A);
   int nexB = nCk(N, B);
// cerr << nexA << endl;
// cerr << nexB << endl;

   
   llong res = (total - nexA - nexB - 1 + 3LL*MOD) % MOD;

   cout << res << endl;

   return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
using namespace std;
int main(void){
    int n;
    cin>>n;
    double ans=0;
    vector<double> a(n);
    for(int i=0; i<n; i++){
        cin>>a.at(i);
        ans+=1/a.at(i);
    }
    ans = 1/ans;
    cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

con = 0
i,j,k = 0,0,0
while i <= a:
  while j <= b:
    while k <= c:
      if x - 500*i - 100*j - 50*k == 0:
        con += 1
      k += 1
    j += 1
    k=0
  i += 1
  j=0

print(con)

Measured memory_bytes: 3064
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

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

bool helper(ll ansReq, vector<ll>&v, ll k){
    int ans = 0;
    for(auto& ele: v){
        ll temp=((ele+ansReq-1)/ansReq);
        ans+=(temp-1);
    }
    return ans<=k;
}

int main(){
    cpp();
    ll n, k;
    cin>>n>>k;
    vector<ll> v(n);
    ll h=0;
    for(ll i=0; i<n; i++){
        cin>>v[i];
        h = max(h, v[i]);
    }
    ll l=1;
    ll ans = 0;
    while(l<=h){
        ll mid = (l+h)/2;
        if(helper(mid, v, k)){
            ans = mid;
            h = mid-1;
        }
        else{
            l = mid+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}






Measured memory_bytes: 4776
uses math;
var n,sum,k,ans,i,t:longint;
    a:array[0..100]of longint;
begin
  readln(n);
  for i:=1 to n do
  begin
    read(a[i]);
    inc(sum,a[i]);
  end;
  if sum mod n=0 then
  begin
    k:=sum div n;
    ans:=0;
    for i:=1 to n do
      inc(ans,sqr(a[i]-k));
    writeln(ans);
  end
  else
  begin
    k:=sum div n;
    ans:=0;t:=0;
    for i:=1 to n do
      inc(ans,sqr(a[i]-k));
    inc(k);
    for i:=1 to n do
      inc(t,sqr(a[i]-k));
    writeln(min(ans,t));
  end;
end.

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

void write(long long a,long long b){
    long long w = a,keta = 0;
    cerr << "" ;
    while(w != 0){
        w = w/10;
        keta++;
    }  
    for(int i =0;i<6-keta;i++) cout << "0";
    cout << a;

    w = b;
    keta = 0;
    while(w != 0){
        w = w/10;
        keta ++;
    }
    for(int i =0;i<6-keta;i++) cout << "0";
    cout << b;

    cout << endl;
}


int main(){
    long long n,m,ans;
    cin >> n >> m;
    long long p[m + 10] = {},y[m+10] = {};
    vector<long long> si[n+10] = {};
    for(int i= 0;i<m;i++){
        cin >> p[i] >> y[i];
        si[p[i]].push_back(y[i]);
    }

    for(int i = 0;i<=n;i++){
        sort(si[i].begin(),si[i].end());
    }

    for(int i=0;i<m;i++){
        auto iter = lower_bound(si[p[i]].begin(),si[p[i]].end(),y[i]);
        write(p[i],iter - si[p[i]].begin()+1);   
    }
}


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

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

using LONG = long long;
using LVEC = vector<long long>;

#define FOR(_i, s, e) for(_i = s; _i < e; ++_i)
#define FOR_INV(_i, s, e) for(_i = e - 1; _i >= s; --_i)

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


using pos = std::pair<LONG, LONG>;


int main(){
    LONG i, j, k;

    LONG N;
    cin >> N;

    LVEC A(N);
    FOR(i, 0, N){
        cin >> A[i];
    }

    sort(A.begin(), A.end(), greater<LONG>());
    LONG sum = A[0];

    for(i = 2; i < N && i <= 3; ++i){
        sum += A[1];
    }
    for(i = 4; i < N && i <= 5; ++i){
        sum += A[2];
    }

    if(N > 6){
        int cur = 3;
        int count = 1;
        FOR(i, 6, N){
            sum += A[cur];
            count = 1 - count;
            if(count == 1){
                ++cur;
            }
        }
    }

    cout << sum;
}



Measured memory_bytes: 4836
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>

int main(void)
{
  int N,K,i,j,d[101],A[101][101],chk[101]={},res=0;

  scanf("%d %d",&N,&K);

  for(i=1;i<=K;i++)
  {
    scanf("%d",&d[i]);

    for(j=1;j<=d[i];j++)
    {
      scanf("%d",&A[i][j]);
      chk[A[i][j]]=1;      
    }
  }

  for(i=1;i<=N;i++)
  {
    if(chk[i]==0)
    {
      //printf("%d\n",i);
      res++;
    }
  }
  
  printf("%d",res);

  return 0;
}

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

struct data
{
    int u,v,id;
};

data a[100005];
typedef pair<int,int> ii;
int n,res=1e9,d[100005];
vector<ii> g[100005];
set<ii> s;
map<ii,bool> mm;

bool cmp1(data x1,data x2)
{
    if(x1.u==x2.u)
        return x1.v<x2.v;
    return x1.u<x2.u;
}

bool cmp2(data x1,data x2)
{
    if(x1.v==x2.v)
        return x1.u<x2.u;
    return x1.v<x2.v;
}

void Prim()
{
    for(int i=1; i<=n; i++)
        d[i]=1e9;
    d[1]=0;
    int res=0;
    s.insert(ii(0,1));
    while(s.size()>0)
    {
        ii tmp=*s.begin();
        s.erase(s.begin());
        int u=tmp.second;
        res+=d[u];
        d[u]=0;
        for(int i=0; i<g[u].size(); i++)
        {
            int v=g[u][i].first;
            int w=g[u][i].second;
            if(d[v]>w)
            {
                if(d[v]!=1e9)
                    s.erase(s.find(ii(d[v],v)));
                d[v]=w;
                s.insert(ii(d[v],v));
            }
        }
    }
    cout<<res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("TEST.INP","r",stdin);
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i].u>>a[i].v;
        a[i].id=i;
    }
    sort(a+1,a+n+1,cmp1);
    for(int i=2;i<=n;i++)
        if(mm[ii(a[i].id,a[i-1].id)]==false)
        {
            int w=min(abs(a[i].u-a[i-1].u),abs(a[i].v-a[i-1].v));
            g[a[i].id].push_back(ii(a[i-1].id,w));
            g[a[i-1].id].push_back(ii(a[i].id,w));
            mm[ii(a[i].id,a[i-1].id)]=true;
            mm[ii(a[i-1].id,a[i].id)]=true;
        }
    sort(a+1,a+n+1,cmp2);
    for(int i=2;i<=n;i++)
        if(mm[ii(a[i].id,a[i-1].id)]==false)
        {
            int w=min(abs(a[i].u-a[i-1].u),abs(a[i].v-a[i-1].v));
            g[a[i].id].push_back(ii(a[i-1].id,w));
            g[a[i-1].id].push_back(ii(a[i].id,w));
            mm[ii(a[i].id,a[i-1].id)]=true;
            mm[ii(a[i-1].id,a[i].id)]=true;
        }
    Prim();
}


Measured memory_bytes: 38784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>

int main(void)
{
	char S[11], tmp[4] = {};
	int min = INT_MAX, length, i, j;
	scanf("%s", S);
	length = strlen(S);
	for (i = 0; i < length - 2; ++i) {
		for (j = 0; j < 3; ++j) tmp[j] = S[i + j];
		if (abs(atoi(tmp) - 753) < min) min = abs(atoi(tmp) - 753);
	}
	printf("%d", min);
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int A, B;
    cin >> A >> B;
    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;
    return 0;
}

Measured memory_bytes: 256