akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,i0,n) for(int i=i0;i<n;++i)

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a[2]; // [0]:+ [1]:-
    ll zero_cnt = 0;
    rep(i,n) {
        ll ai;
        cin >> ai;
        if (ai == 0) ++zero_cnt;
        else if (ai > 0) a[0].push_back(ai);
        else a[1].push_back(ai);
    }
    ll m[2] = {(ll)a[0].size(), (ll)a[1].size()};
    ll nega_p_cnt = m[0]*m[1];
    ll zero_p_cnt = zero_cnt*(n-zero_cnt) + zero_cnt*(zero_cnt-1)/2;

    if (k > nega_p_cnt && k <= nega_p_cnt + zero_p_cnt) {
        cout << 0 << endl;
        return 0;
    }

    sort(a[0].begin(), a[0].end());
    sort(a[1].begin(), a[1].end(), greater<ll>());

    bool negative = (k <= nega_p_cnt);
    ll ok = -1e18-7, ng = +1e18+7;

    if (negative) {
        ok = a[0].front() * a[1].front();
        ng = a[0].back() * a[1].back() - 1;
    }
    else {
        if (m[0] > 1) {
            ok = max(ok, a[0][m[0]-1] * a[0][m[0]-2]);
            ng = min(ng, a[0][0] * a[0][1] - 1);
        }
        if (m[1] > 1) {
            ok = max(ok, a[1][m[1]-1] * a[1][m[1]-2]);
            ng = min(ng, a[1][0] * a[1][1] - 1);
        }
    }

    auto is_ok = [&](ll mid){
        ll sum = 0;
        if (negative) {            
            rep(i, m[1]) {
                ll ok_ = m[0];
                ll ng_ = -1;
                auto is_ok_ = [&](ll x){
                    return a[0][x] * a[1][i] <= mid;
                };
                while(abs(ng_-ok_)>1) {
                    ll x = (ok_+ng_)/2;
                    if(is_ok_(x)) ok_ = x;
                    else ng_ = x;
                }
                sum += m[0]-ok_;
            }
            return sum >= k;
        }
        else {
            rep(i, 2)
                rep(j, m[i]) {
                    ll ok_ = m[i];
                    ll ng_ = -1;
                    auto is_ok_ = [&](ll x){
                        return a[i][x] * a[i][j] > mid;
                    };
                    while(abs(ng_-ok_)>1) {
                        ll x = (ok_+ng_)/2;
                        if(is_ok_(x)) ok_ = x;
                        else ng_ = x;
                    }
                    sum += ok_;
                    if(a[i][j] * a[i][j] <= mid) --sum;
                }
            return sum/2 + nega_p_cnt + zero_p_cnt >= k;
        }
    };

    while(abs(ok-ng) > 1) {
        ll mid = (ok+ng)/2;
        if(is_ok(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;
    return 0;
}

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

int main() {
	int n, q;
	int a, b, c;
	cin >> n >> q;
	stack<int> arr[n];
	while(q--) {
		cin >> a;
		if(a == 0) {
			cin >> b >> c;
			arr[b].push(c);
		}
		else if(a == 1) {
			cin >> b;
			if(arr[b].size() == 0) {
				
			}
			else cout << arr[b].top() << endl;
		}
		else {
			cin >> b;
			if(arr[b].size() == 0) {
				
			}
			else arr[b].pop();
		}
	}
	return 0;
}


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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
vector<pair<int,int>> a(5);
int tmp,wait;
rep(i,5){
    cin>>tmp;
    wait=tmp%10==0?0:10-tmp%10;
    a[i]=mp(wait,tmp);
}
sort(a.begin(),a.end());
int total=0;
rep(i,4){
    total+=a[i].first+a[i].second;
}
total+=a[4].second;
cout<<total<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string.h>
#include <vector>
#define ME(x , y) memset(x , y , sizeof(x))
#define SF(n) scanf("%d" , &n)
#define rep(i , n) for(int i = 0 ; i < n ; i ++)
#define INF  0x3f3f3f3f
#define mod 1000000007
#define PI acos(-1)
using namespace std;
typedef long long ll ;
ll a[100009];
ll sum1[100009] , sum2[100009];
ll fac[100009] , inv[100009];
ll C(ll n , ll m)
{
    return fac[n]%mod * inv[n-m]%mod * inv[m] % mod ;
}

ll quickpow(ll a , ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b&1)
        {
            ans = ans * a % mod ;
        }
        b >>= 1 ;
        a = a * a % mod ;
    }
    return ans %mod ;
}

int main()
{
    fac[0] = 1 ;
    fac[1] = 1, inv[0] = inv[1] = 1;
    for(int i = 2 ; i <= 100000 ; i++) fac[i] = fac[i-1] * i % mod ;
    inv[100000] = quickpow(fac[100000] , mod-2);
    for(int i = 99999 ; i >= 2 ; i--) inv[i] = inv[i+1] * (i+1) % mod;
    ll n , k ;
    scanf("%lld%lld" , &n , &k);
    for(int i = 1 ; i <= n ; i++)
    {
        scanf("%lld" , &a[i]);
    }
    sort(a+1 , a+n+1);
    for(int i = 1 ; i <= n ; i++)
    {
        sum1[i] = (sum1[i-1] + a[i])%mod;
    }
    for(int i = n ; i >= 1 ; i--)
    {
        sum2[i] = (sum2[i+1] + a[i])%mod;
    }
    ll ans = 0 ;
    ll nn = k - 2 , m = k - 2 ;
    ll a = n - k + 1 , b = k;
    for(int i = 0 ; i < n - k + 1 ; i++)
    {
        ans = (ans%mod + (sum2[b] - sum1[a])%mod * C(nn , m)) % mod;
        nn++ ;
        a--;
        b++;
    }
    cout << ans << endl ;

    return 0 ;
}


Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int,int>>adj[MAX];

void dijkstra() {
  priority_queue<pair<int,int>>PQ;
  int color[MAX];
  int d[MAX];
  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  d[0]=0;
  PQ.push(make_pair(0,0));
  color[0]=GRAY;

  while(!PQ.empty()){
    pair<int,int>f = PQ.top();
    PQ.pop();
    int u=f.second;
    color[u]=BLACK;
    if(d[u] < f.first*(-1))continue;
    for(int j=0;j<adj[u].size();j++){
      int v=adj[u][j].first;
      if(color[v]==BLACK)continue;
      if(d[v] > d[u]+adj[u][j].second){
	d[v]=d[u]+adj[u][j].second;
	PQ.push(make_pair(d[v]*(-1),v));
	color[v]=GRAY;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout << i << " " << (d[i] == INFTY ? -1 :d[i]) << endl;
  }
}

int main() {
  int k,u,v,c;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int j=0;j<k;j++){
      cin >> v >> c;
      adj[u].push_back(make_pair(v,c));
    }
  }
  dijkstra();
  return 0;
}



Measured memory_bytes: 8076
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		long min = Integer.MAX_VALUE;
		long sum = 0L;
		for (int i = 1; i <= 100; i++) {
			for (int j = 0; j < n; j++) {
				sum += (long) Math.pow(x[j] - i, 2);
			}
			
			if (sum < min) {
				min = sum;
			}
			sum = 0L;
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [](auto& i)
#define compare(i, j) [](auto& i, auto& j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

const int INF = 1e18;
const int MOD = 1e9 + 7;

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n;
  int ans = 0;

  cin >> n;
  // vi v(n);
  // REP(i, n) {
  //   cin >> v[i];
  // }

  cout << (n < 1200 ? "ABC" : "ARC") << endl;
  // REP(i, n) {
  //   cout << v[i];
  // }
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 256
def power(base, exp, mod):
  if exp <= 0:
    return 1
  if exp <= 1:
    return base % mod
  if exp % 2 == 1:
    return (base * power(base, exp - 1, mod)) % mod

  root = power(base, exp // 2, mod)
  return (root * root) % mod


MOD = int(1e9 + 7)
n = int(input())

if n == 1:
  print(0)
else:
  res = power(10, n, MOD) - 2 * power(9, n, MOD) + power(8, n, MOD)
  while res < 0:
    res += MOD
  res %= MOD

  print(res)


Measured memory_bytes: 9196
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;


void solve(std::string S){
    ll N = S.length();
    if(N < 26){
        set<char> myset(ALL(S));
        REP(i, 26){
            char c = (char) i+ 'a';
            if(!myset.count(c)){
                S.push_back(c);
                cout << S << endl;
                return;
            }
        }
    }
    else if(S == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return;
    }
    else{
        set<string> myset;
        REP(i, N-1){
            for(ll j = i+1; j< N; j++){
                string tmp = S;
                if(tmp[i]<tmp[j]){
                    swap(tmp.at(i), tmp.at(j));
                    myset.insert(tmp);
                }
            }
        }
        string ans = *myset.begin();
        char t;
        while(ans > S){
            t = ans.back();
            ans.pop_back();
        }
        if(ans.length()<N)
            ans.push_back(t);
        cout << ans << endl;
    }
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main() {
    int n, m, ans = 0;
    cin >> n >> m;
    vector<int> x(m), xm(m - 1);
    for(int i = 0;i < m;i++){
        cin >> x[i];
    }
    if(m == 1 || n > m){
        cout << 0;

        return 0;
    }

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

    for(int i = 0;i < m - 1;i++){
        xm[i] = x[i + 1] - x[i];
    }

    sort(xm.begin(), xm.end(), greater<int>());

    for(int i = 0;i < n - 1;i++){
        ans += xm[i];
    }

    ans = x[m - 1] - x[0] - ans;
    
    cout << ans;

	return 0;
}

Measured memory_bytes: 1024
//
// Created by Hiroshi Tamura on 2018/11/02.
//

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = 0;
    int ans0 = 0;
    int ans1 = 0;
    int ans2 = 0;
    int ans3 = 0;
    int x[4] = {a, b, c, d};
    for (int i=0; i < 4; i++) {
        if (x[i] == 1) {
            ans0 = 1;
        }
    };
    for (int i=0; i < 4; i++) {
        if (x[i] == 7) {
            ans1 = 1;
        }
    };
    for (int i=0; i < 4; i++) {
        if (x[i] == 9) {
            ans2 = 1;
        }
    };
    for (int i=0; i < 4; i++) {
        if (x[i] == 4) {
            ans3 = 1;
        }
    };
    if ( ans0 == 1 && ans1 == 1 && ans2 == 1 && ans3 == 1) {
        ans = 1;
    }
    if (ans == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <vector>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;

int getSum(string s) {
  int ans = 0;
  int n = (int)s.size();
  for (int i = 0; i < n; ++i) {
    ans += s[i] - '0';
  }
  return ans;
}

int main() {
  string s;
  cin >> s;
  int n = (int)s.size();
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '9') cnt++;
  }

  if (cnt == n || (cnt == n - 1 && s[0] != '9') || n == 1) {
    cout << getSum(s) << endl;
  } else {
    char fi = s[0] - 1;
    string t = "";
    t += fi;
    for (int i = 0; i < n - 1; ++i) t += '9';
    cout << getSum(t) << endl;
  }
  return 0;
}


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

int N,ans;
double ave = 0,dif = 1e9;
vector<int> A;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);	
	cin >> N;
	REP(i,N){
		int tmp;
		cin >>tmp;
		A.push_back(tmp);
		ave += tmp;
	}
	ave /= N;

	REP(i,N){
		if(fabs(ave - A[i]) < dif){
			dif = fabs(ave - A[i]);
			ans = i;
		} 
	}
	cout << ans << endl;
	
	return 0;
}

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

namespace _0297
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x[0] % x[1] == 0)
                {
                    Console.WriteLine(x[1]);
                }
                else
                {
                    Console.WriteLine(x[0] % x[1]);
                }
            }
        }
    }
}

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

int main() {
  int n;
  int x[100], y[100];
  double ans[3] = {0.0};
  int ans_max = -1;

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

  for (int i = 0; i < n; i++) {
    double temp = (double)abs(x[i] - y[i]);
    ans[0] += temp;
    ans[1] += temp * temp;
    ans[2] += temp * temp * temp;
    if (ans_max < (int)temp) {
      ans_max = (int)temp;
    }
  }
  ans[1] = sqrt(ans[1]);
  ans[2] = cbrt(ans[2]);
  printf("%f\n%f\n%f\n%d\n", ans[0], ans[1], ans[2], ans_max);
  return 0;
}


Measured memory_bytes: 2104
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

MOD = 2019

def solve(S):
    dp = np.zeros(MOD, np.int64)
    temp = np.empty_like(dp)
    pow10 = 1
    answer = 0
    for x in S[::-1]:
        dp[0] += 1
        x = x * pow10 % MOD
        temp[x:] = dp[:-x]
        temp[:x] = dp[-x:]
        dp, temp = temp, dp
        answer += dp[0]
        pow10 *= 10
        pow10 %= MOD
    return answer


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', '(i4[:],)')(solve)
    cc.compile()


try:
    from my_module import solve
except:
    cc_export()
    exit()

S = np.array(list(read().rstrip()), dtype=np.int32) - ord('0')
print(solve(S))


Measured memory_bytes: 29192
n=int(input())
a=list(map(int, input().split()))

lcm=a[0]
for ai in a[1:]:
    gcd=lcm
    lcm*=ai
    if ai<lcm:
        gcd,ai=ai,gcd
    while ai%gcd!=0:
        gcd,ai=ai%gcd,gcd
    lcm//=gcd

s=0    
for ai in a:
    s+=(lcm-1)%ai
print(s)

Measured memory_bytes: 3316
N, X = list(map(int, input().split()))
L = list(map(int, input().split()))

cnt = 0
ans = 0
for i in range(N):
    if cnt > X:
        cnt += L[i]
    else:
        cnt += L[i]
        ans += 1

if cnt <= X:
    ans += 1

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  R s;
  int c=0;
  rep(i,s.size()-1) {
    if(s[i]!=s[i+1]) c++;
  }
  pr(c);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

void answer1() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  string s;
  cin >> s;
  int count = 0;
  for (int i = 1; i < N; i++) {
    if (s[i] == 'E') {
      count++;
    }
  }
  int min_count = count;

  for (int i = 1; i < N; i++) {
    if (s[i - 1] == 'W') {
      count++;
    }
    if (s[i] == 'E') {
      count--;
    }
    min_count = min(min_count, count);
  }
  cout << min_count << endl;

}

int main() {
  answer1();
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n);
    vector<ll> c(n);
    rep(i,n){
        cin >> p.at(i);
        --p.at(i);
    }
    rep(i,n) cin >> c.at(i);

    vector<vector<ll>> dub(n, vector<ll>(32));
    vector<vector<ll>> cnt(n, vector<ll>(32));
    vector<vector<ll>> mmx(n, vector<ll>(32));
    rep(i,n) dub.at(i).at(0) = p.at(i);
    rep(i,n){
        cnt.at(i).at(0) = c.at(p.at(i));
    }
    rep(i,n){
        mmx.at(i).at(0) = c.at(p.at(i));
    }
    rep(j,31){
        for(i = 0;i < n;++i){
            dub.at(i).at(j+1) = dub.at(dub.at(i).at(j)).at(j);
            cnt.at(i).at(j+1) = cnt.at(i).at(j) + cnt.at(dub.at(i).at(j)).at(j);
            mmx.at(i).at(j+1) = max(mmx.at(i).at(j), cnt.at(i).at(j) + mmx.at(dub.at(i).at(j)).at(j));
        }
    }
    ll ans = -(1ll << 60);
    ll kk = 31 - __builtin_clz(k);
    rep(i,n){
        ll mb = kk;
        ll now = i;
        ll pre = 0;
        while(mb >= 0){
            if((k & (1ll << mb))){
                ans = max(ans, pre + mmx.at(now).at(mb));
                pre += cnt.at(now).at(mb);
                now = dub.at(now).at(mb);
            }
            --mb;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class Pref
{
    internal int number;
    internal List<int> cityBirth;
    
    public Pref()
    {
        number = -1;
        cityBirth = new List<int>();
    }
}

public class MyProgram
{	
  
    public static void Main()
	{
        int[] n = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = n[0];
        int M = n[1];
        
        Pref[] prefs = new Pref[N];
        for(int i = 0 ; i < N ; i++)
        {
            prefs[i] = new Pref();
        }
        
        List<int> pList = new List<int>();
        List<int> yList = new List<int>();
        
        string[] buf;
        int P, Y;
        for(int i = 0 ; i < M ; i++)
        {
            buf = Console.ReadLine().Split();
            P = int.Parse(buf[0]);
            Y = int.Parse(buf[1]);
            
            pList.Add(P);
            yList.Add(Y);
            
            prefs[P-1].cityBirth.Add(Y);
        }
        
        for(int i = 0 ; i < N ; i++)
        {
            prefs[i].cityBirth.Sort();
        }
        
        string sp,si;
        int nowP, index, target;
        for(int i = 0 ; i < M ; i++)
        {
            nowP = pList[i];
            target = yList[i];
            index = indexBinarySearch(prefs[nowP-1].cityBirth,target);
            sp = nowP.ToString().PadLeft(6,'0');
            si = index.ToString().PadLeft(6,'0');
            Console.WriteLine(sp+si);
        }
       
        
    }
    
    public static int indexBinarySearch(List<int> list, int target)
    {
        int index = 0;
        int lower = 0;
        int upper = list.Count-1;
        int mid = 0;
        
        while(lower <= upper)
        {
            mid = (lower + upper) / 2;
            if(list[mid] == target)
            {
                index = mid;
                break;
            }
            else if(list[mid] < target)
            {
                lower = mid +1 ;
            }
            else if(list[mid] > target)
            {
                upper = mid - 1;
            }
        }
        
        return index+1;
    }
}

Measured memory_bytes: 35440
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int fr[6][2] = {{2,380},{3,550},{5,850},{10,1520},{12,1870},{15,2244}};
  int dp[51] = {0},n;
  for(int i=1; i<51; i++){dp[i] = 10000;}
  for(int i=0; i<51; i++){
    for(int j=0; j<7; j++){
      if(fr[j][0]<=i){
	dp[i] = min(dp[i],dp[i-fr[j][0]]+fr[j][1]);
      }
    }
  }
  while(cin>>n,n){
    cout <<dp[n/100]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll n,c;
	cin>>n>>c;
	ll x[n],v[n],sum_right[n],sum_left[n],sum_max_right[n],sum_max_left[n];
	memset(x,0,sizeof(x));
	memset(v,0,sizeof(x));
	memset(sum_right,0,sizeof(x));
	memset(sum_left,0,sizeof(x));
	memset(sum_max_right,0,sizeof(x));
	memset(sum_max_left,0,sizeof(x));
	for(ll i=1;i<=n;i++){
		cin>>x[i]>>v[i];
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		sum_right[i]=sum_right[i-1]+v[i];
		sum_left[i]=sum_left[i-1]+v[n-i+1];
	}
	for(ll i=1;i<=n;i++){
		sum_right[i]-=x[i];
		sum_left[i]-=c-x[n-i+1];
	}
	for(ll i=1;i<=n;i++){
		sum_max_right[i]=max(sum_max_right[i-1],sum_right[i]);
		sum_max_left[i]=max(sum_max_left[i-1],sum_left[i]);
	}
	for(ll i=1;i<=n;i++){
		ans=max(ans,max(sum_right[i],sum_right[i]-x[i]+sum_max_left[n-i]));
		ans=max(ans,max(sum_left[i],sum_left[i]-(c-x[n-i+1])+sum_max_right[n-i]));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4992
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {
            var X = cin.ReadInt;
            var Y = cin.ReadInt;
            var Z = cin.ReadInt;

            var num = 0;

            while(true)
            {
                if (Y * num + Z * (num + 1) > X) break;
                else num++;
            }

            WriteLine(num - 1);

        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
program prob4
    implicit none
    integer::W, H, N, i, j, x, y, a
    integer, allocatable::c(:,:)
    read(*,*) W, H, N
    allocate(c(H,W))
    c = 1
    do i = 1, N
        read(*,*) x, y, a
        if(a == 1) then
            do j = 1, x
                c(:,j) = 0
            end do
        else if(a == 2) then
            do j = x+1, W
                c(:,j) = 0
            end do
        else if(a == 3) then
            do j = 1, y
                c(j,:) = 0
            end do
        else
            do j = y+1, H
                c(j,:) = 0
            end do
        end if
    end do
    write(*,*) sum(c)
    deallocate(c)
    stop
end program

Measured memory_bytes: 2840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000009;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}

int main(){
  ll s;cin>>s;
  ll x1=0,x2=1000000000,x3=1,y1=0,y3=(s-1)/1000000000+1,y2=x2*y3-s;
  cout<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<' '<<x3<<' '<<y3;
}


Measured memory_bytes: 256
from sys import exit

N = int(input())

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


a = 0
for i in range(N - 1):
    if i % 2 == 0:
        a -= A[i]
    else:
        a += A[i]

n = A[N - 1] + a

_x = n
ans = []
for i in range(N - 1):
    if i == 0:
        ans.append(int((A[N - 1] - _x / 2) * 2))
        _x = (A[N - 1] - _x / 2) * 2
    else:
        ans.append(int((A[i - 1] - _x / 2) * 2))
        _x = (A[i - 1] - _x / 2) * 2

ans.append(n)

print(' '.join(map(str, ans)))


Measured memory_bytes: 19096
#include <iostream>
#include <algorithm>
    
using namespace std;
    
int main() {
int a,b,c;
cin >> a >> b >> c;
int min3 = min({a,b,c});
int max3 = max({a,b,c});
int mid = a+b+c-min3-max3;
cout << min3 << " " << mid << " " << max3 << endl;
}


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

using namespace std;

#define int long long

const int N = 1e3 + 10;

int cnt[N];

signed main()
{
  int x, n, dat, ans;
  ans = 0;
  dat = 1e9 + 7;
  cin >> x >> n;
  for (int i = 1; i <= n; i++)
  {
    int t;
    cin >> t;
    cnt[t] = 1;
  }
  for (int i = 101; i >= x; i--)
  {
    if (!cnt[i])
    {
      if (abs(i - x) <= dat)
      {
        dat = abs(i - x);
        ans = i;
      }
    }
  }
  for (int i = x; i >= 0; i--)
  {
    if (!cnt[i])
    {
      if (abs(i - x) <= dat)
      {
        dat = abs(i - x);
        ans = i;
      }
    }
  }
  printf("%lld\n", ans);

  return 0;
}



Measured memory_bytes: 3764
n,d = gets.split.map(&:to_i)
point = Array.new(n).map{Array.new(d,0)}
n.times{|i| point[i] = gets.split.map(&:to_i)}
ans = 0
for i in 0..n-1
  for j in 0..n-1
    inst = 0
    if i != j
      for k in 0..d-1
        inst += (point[i][k]-point[j][k])**2
      end
      inst = inst**0.5
      if inst % 1.0 == 0
        ans += 1
      end
    end
  end
end
puts ans / 2


Measured memory_bytes: 1916
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;
#define all(x) x.begin(), x.end()

const int mod = 1e9 + 7;
const int N = 1e5 + 5;
vector<int> g[N];
int dp[N][3];

signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    fr(i, 1, m) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
    }
    fr(i, 1, n) {
        dp[i][0] = dp[i][1] = dp[i][2] = 1e9;
    }
    int s, t;
    cin >> s >> t;
    queue<pii> q;
    dp[s][0] = 0;
    q.push({s, 0});
    while(!q.empty()) {
        pii u = q.front();
        q.pop();
        for(int v : g[u.fi]) {
            if(dp[v][(u.se + 1) % 3] > dp[u.fi][u.se] + 1) {
                dp[v][(u.se + 1) % 3] = dp[u.fi][u.se] + 1;
                q.push({v, (u.se + 1) % 3});
            }
        }
    }
    if(dp[t][0] == 1e9) dp[t][0] = -3;
    cout << dp[t][0] / 3;
    return 0;
}

Measured memory_bytes: 6912
#include<stdio.h>

#define LIMIT 500000
#define INFTY 1000000001

int S[LIMIT];
int L[LIMIT/2+2], R[LIMIT/2+2];
int count = 0;

void merge(int A[], int left, int mid, int right){
  int n1, n2, i, j, k;

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  L[n1] = INFTY; R[n2] = INFTY;

  i = 0; j = 0;
  for(k = left; k < right; k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int left, int right){
  int mid;

  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(){
  int i, n;

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

  mergeSort(S, 0, n);

  for(i = 0; i < n; i++){
    if(i == n-1){
      printf("%d\n", S[i]);
    }else{
      printf("%d ", S[i]);
    }
  }

  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 5600
// Start 40 lines of header files acceleration
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
// End 40 lines of header files acceleration
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

inline int read(){
    int x=0,f=1;
    char c;
    for(c=getchar();(!isdigit(c))&&(c!='-');c=getchar());
    if(c=='-') f=-1,c=getchar();
    for(;isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+c-'0';
    return x*f;
}
inline bool cmp(string a, string b)
{
	return a < b;
}

int main()
{
	int n = read(), l = read();
	string a[n + 1];
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	sort(a + 1, a + n + 1, cmp);
	for(int i = 1; i <= n; ++i)
		cout << a[i];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

	int sum[4] = {};
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		
		if (s == "AC") {
			sum[0]++;
		}
		else if (s == "WA") {
			sum[1]++;
		}
		else if (s == "TLE") {
			sum[2]++;
		}
		else {
			sum[3]++;
		}
	}

	printf("AC x %d\n", sum[0]);
	printf("WA x %d\n", sum[1]);
	printf("TLE x %d\n", sum[2]);
	printf("RE x %d\n", sum[3]);

	return 0;
}

Measured memory_bytes: 3720
/*
<expr>   ::= <term> [ ('+'|'-') <term> ]*
<term>   ::= <factor> [ ('*'|'/') <factor> ]*
<factor> ::= <number> | '(' <expr> ')'
<number> :== 1つ以上の数字
*/

#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int expr(string& s, int& i);
int term(string& s, int& i);
int factor(string& s, int& i);
int number(string& s, int& i);

int main(){
	int n;
	cin >> n;
	for(int j = 0; j < n; j++){
		string str;
		cin >> str;
		int i = 0;
		
		cout << expr(str, i) << endl;
	}
	
	return 0;
}

int expr(string& s, int& i){
	int val = term(s, i);

	while(s[i] == '+' || s[i] == '-'){
		char op = s[i++];
		int val2 = term(s, i);
		if(op == '+')
			val += val2;
		else
			val -= val2;
	}
	
	return val;
}

int term(string& s, int& i){
	int val = factor(s, i);
	while(s[i] == '*' || s[i] == '/'){
		char op = s[i++];
		int val2 = factor(s, i);
		if(op == '*')
			val *= val2;
		else
			val /= val2;
	}
	
	return val;
}

int factor(string& s, int& i){
	if(isdigit(s[i]))
		return number(s, i);
	
	i++;
	int ret = expr(s, i);
	i++;
	
	return ret;
}

int number(string& s, int& i){
	int n = s[i++] - '0';
	while(isdigit(s[i]))
		n = n * 10 + s[i++] - '0';
	
	return n;
}

Measured memory_bytes: 1212
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main()
{
	int N;
	cin >> N;
	if(N%10==7){
		cout << "Yes" << endl;
	} else{
		int N_1 = N / 10;
		if(N_1%10==7){
			cout << "Yes" << endl;
		}else{
			int N_2 = N_1 / 10;
			if(N_2%10==7){
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static void Main(string[] args) {
        List<string> input = Console.ReadLine().Split(' ').ToList();
        int n = int.Parse(input[0]);
        int k = int.Parse(input[1]);

        int ans = 0;
        while(n != 0)
        {
            ans++;
            n /= k;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11220
n, m = map(int, input().split())
switch = [set() for _ in range(m)]
for i in range(m):
    a = list(map(int, input().split()))
    for j in range(1, len(a)):
        switch[i].add(a[j])
p = list(map(int, input().split()))
def check(i):
    bright = set()
    for j in range(n):
        if i % 2:
            bright.add(j + 1)
        i //= 2
    for j in range(m):
        if len(switch[j] & bright) % 2 != p[j]:
            return False
    return True
ans = 0
for i in range(1 << n):
    ans += int(check(i))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'

int n, a[101];
void test() {
    cin >> n;
    int ans=0;
    for (int i=1; i<=n; ++i) {
        cin >> a[i];
        if (i&1&&a[i]&1) ++ans;
    }
    cout << ans << endl;
}

int main() {
    IOS;

    // int t; cin>>t;
    // while (t--) {
    //     test();
    // }

    // int t; cin>>t;
    // for (int i=1; i<=t; ++i) {
    //     cout<<"Case #"<<i<<": ";
    //     test();
    // }

    test();
    return 0;
}

Measured memory_bytes: 3648
n = gets.to_i
_a = []

n.times{
    _a.push(gets.split.map(&:to_i))
}

x = []
n.times{|i|
    x.push([i, -1, -1, 0, 0, -1, "root"])
}

def checkdepth(x, k, d)
    if k[1] == -1 then
        return d
    else
        checkdepth(x,x[k[1]],d+1)
    end
end

def checkheight(x, k, h)
   
end

_a.each{|k|
    x[k[0]][6] = "internal node"
    if k[1] != -1 then
        x[k[1]][1] = k[0]
        x[k[0]][3] += 1
    end
    if k[2] != -1 then
        x[k[2]][1] = k[0]
        x[k[0]][3] += 1
    end
    if k[1] != -1 && k[2] != -1 then
        x[k[1]][2] = k[2]
        x[k[2]][2] = k[1]
    elsif k[1] == -1 && k[2] == -1 then
        x[k[0]][6] = "leaf"
    end
}

def merge(a, l, r, m)
    _L = a[l..m-1]
    _R = a[m..r-1]
    _L.push([0,1.0/0.0])
    _R.push([0,1.0/0.0])
    i = j = 0
    for k in 0..r-l-1
        if _L[i][1] <= _R[j][1] then
            a[l + k] = _L[i]
            i += 1
        else
            a[l + k] = _R[j]
            j += 1
        end
    end
end

def mergesort(a, l, r)
    if l + 1 < r then
        m = (l + r) / 2
        mergesort(a, l, m)
        mergesort(a, m, r)
        merge(a, l, r, m)
    end
end

x.each{|k|
    k[4] = checkdepth(x, k, 0)
}

c = []
x.each{|k|
    c.push([k[0],k[4]])
}

mergesort(c, 0, c.length)
c.reverse!

def checkheight(x, k, h)
    x[k][5] = h
    if x[x[k][1]][5] == -1 && x[k][1] != -1 then
        checkheight(x, x[k][1], h+1)
    end

end

c.each{|k|
    if x[k[0]][5] == -1 then
        checkheight(x, k[0], 0)
    end
}

x.each{|k|   
    if k[1] == -1 then
        k[6] = "root"
    end
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",k[0],k[1],k[2],k[3],k[4],k[5],k[6])
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int MAX = 200010;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<'\n'


int main(){
    int n,k;
    cin >> n >> k;
    ll vec1[n+1],vec2[n+1];
    ll ans1=0,ans2=0;
    for(int i=0;i<n+1;i++){
        ans1 += i;
        ans2 += n-i; 
        vec1[i] = ans1;
        vec2[i] = ans2;
    }
    ll ans = 0;
    for(int t=k-1;t<n+1;t++){
        ans += vec2[t]-vec1[t]+1;
        if(ans%MOD)ans%=MOD;    
    }
    COUT(ans);
    return 0;
}

Measured memory_bytes: 6704
import math
a, b = [int(i) for i in input().split()]
 
a_min = math.ceil(a * 12.5)
a_max = int((a+1) * 12.5 - 10e-10)
 
b_min = math.ceil(b * 10 )
b_max = int((b+1)*10 - 10e-10)

  
if a_max < b_min:
  print(-1)
  exit()
  
if b_max < a_min:
  print(-1)
  exit()
  
if a_min <= b_min:
  print(b_min)
  exit()
print(a_min)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=1e5+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> void chkmax(T &a,T b) { a<b?a=b:0; };
template<typename T> void chkmin(T &a,T b) { a>b?a=b:0; };
int n,a[N];
char s[N];
int main() {
    scanf("%s",s+1);n=strlen(s+1);
    for(int i=1;i<=n;i++) a[i]=s[i]-'0';
    if(!a[1]||a[n]) return puts("-1"),0;
    for(int i=2;i<n;i++) if(a[i]!=a[n-i]) return puts("-1"),0;
    int p=1;
    for(int i=1;i<n;i++) {
        if(a[i]) printf("%d %d\n",p,i+1),p=i+1;
        else printf("%d %d\n",p,i+1);
    }
    return 0;
}


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

template <typename T>
vector<T> make_vector(size_t sz)
{
	return vector<T>(sz);
}

template <typename T, typename... U>
auto make_vector(size_t sz, U... tails)
{
	return vector<decltype(make_vector<T>(tails...))>(sz, make_vector<T>(tails...));
}

template <typename T>
void fill_vector(vector<T> &v, T init)
{
	fill(v.begin(), v.end(), init);
}

template <typename T, typename U>
void fill_vector(vector<U> &vec, T init)
{
	for (auto &&v : vec)
	{
		fill_vector<T>(v, init);
	}
}

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

	vector<vector<int64_t>> dp(10, vector<int64_t>(10, 0));

	for (int64_t a = 1; a <= n; a++)
	{
		int64_t h = [](int64_t x) {
			while (10 <= x)
			{
				x /= 10;
			}
			return x;
		}(a);
		int64_t t = a % 10;

		dp[h][t]++;
	}

	int64_t ans = 0;

	for (int64_t a = 1; a <= n; a++)
	{
		// b := h ... t
		// 1 <= b <= n

		int64_t h = a % 10;
		int64_t t = [](int64_t x) {
			while (10 <= x)
			{
				x /= 10;
			}
			return x;
		}(a);

		ans += dp[h][t];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
n,x = map(int, sys.stdin.readline().rstrip("\n").split())
minm = 100000
summ = 0
for _ in range(n):
    m = int(sys.stdin.readline().rstrip("\n"))
    summ += m
    minm = min(minm,m)
print(n+(x-summ)//minm)

Measured memory_bytes: 61820
#include <stdio.h>

int N, K;
int p[333333];

double horieyui[333333];

int main(void) {
	int i;
	double asanomasumi = 0;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	horieyui[0] = 0;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &p[i]) != 1) return 1;
		horieyui[i] = horieyui[i - 1] + (double)p[i] * (p[i] + 1) / 2 / p[i];
	}
	for (i = K; i <= N; i++) {
		double yamadasinnya = horieyui[i] - horieyui[i - K];
		if (yamadasinnya > asanomasumi) asanomasumi = yamadasinnya;
	}
	printf("%.15f\n", asanomasumi);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  vector<int>mark(4);
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='N'){
      mark.at(0)=1;
    }
    if(S.at(i)=='S'){
      mark.at(1)=1;
    }
    if(S.at(i)=='W'){
      mark.at(2)=1;
    }
    if(S.at(i)=='E'){
      mark.at(3)=1;
    }
  }
  bool flag=true;
  if(mark.at(0)!=mark.at(1)){
    flag=false;
  }
  if(mark.at(2)!=mark.at(3)){
    flag=false;
  }
  if(flag){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
  
    


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

int main(){
    int n, a[100];
    cin >> n;

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

    bool flag = true;

    int itr = 0;

    while(flag){
        flag = false;
        for (int j = n - 1; j > 0; --j){
            if (a[j] < a[j-1]){
                int tmp = a[j];
                a[j] = a[j-1];
                a[j-1] = tmp;
                itr++;
                flag = true;
            }
        }
    }

    for (int i = 0; i < n - 1; ++i) cout << a[i] << " ";
    cout << a[n-1] << endl;
    cout << itr << endl;
}



Measured memory_bytes: 3116
#include<stdio.h>
int main() {
	double a,s;
	int i;
	while(~scanf("%lf",&a)){
		s=0;
		for(i=0;i<5;i++){
			s+=a;
			a*=2;
			s+=a;
			a/=3;
		}
		printf("%.8f\n",s);
	}
	return 0;
}

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

N, x = map(int, input().split())
C = list(map(int, input().split()))
cnt = 0
for i in range(N-1):
    if C[i]+C[i+1] > x:
        a = C[i]+C[i+1] - x
        cnt += a
        C[i] = min(C[i+1]-a, 0)
        C[i+1] = max(C[i+1]-a, 0)
print(cnt)

Measured memory_bytes: 14592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pll;
ll inf=10000000000000;
ll n,m,R;
ll r[8];
ll md[201][201];
bool used[8];
ll dfs(ll now,ll dis){
  used[now]=true;
  ll ret=inf;
  for(ll i=0;i<R;i++){
    if(!used[i]){
      ret=min(ret,dfs(i,dis+md[r[now]][r[i]]));
    }
  }
  used[now]=false;
  if(ret==inf)return dis;
  
  return ret;
}
int main(){
  cin>>n>>m>>R;
  for(ll i=0;i<R;i++){
    cin>>r[i];
  }
  ll a[m],b[m],c[m];
  vector<ll>list[n+1];
  ll dis[n+1][n+1];
  for(ll i=0;i<m;i++){
    cin>>a[i]>>b[i]>>c[i];
    list[a[i]].push_back(b[i]);
    list[b[i]].push_back(a[i]);
    dis[a[i]][b[i]]=c[i];
    dis[b[i]][a[i]]=c[i];
  }
 
  for(ll i=0;i<=n;i++)for(ll j=0;j<=n;j++)md[i][j]=inf;
  for(int i=1;i<=n;i++){
    md[i][i]=0;
    priority_queue<pll,vector<pll>,greater<pll>>q;
    q.push(make_pair(0,i));
    while(q.size()>0){
      pll pnow=q.top();q.pop();
      ll pf=pnow.first;
      ll ps=pnow.second;
      for(ll j=0;j<list[ps].size();j++){
        ll k=list[ps][j];
        if(md[i][k]>pf+dis[ps][k]){
          md[i][k]=pf+dis[ps][k];
          q.push(make_pair(md[i][k],k));
        }
      }
    }
  }
  ll ans=inf;
  for(ll i=0;i<R;i++){
    ans=min(ans,dfs(i,(ll)0));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
using vll = V<ll>;
using vvll = V<vll>;

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  ll i=0, acc=0;
  while (acc < n) {acc+=++i;}
  if (acc != n) cout << "No" << endl;
  else {
    cout << "Yes" << endl; cout << i+1 << endl;
    vvll ans(i+1, vll());
    acc = 0;
    for (ll j=1; j<=i; j++) {
      for (ll k=acc+1; k<=acc+j; k++) {
        ans.at(k-acc-1).push_back(k);
        ans.at(j).push_back(k);
      }
      acc += j;
    }
    for (ll j=0; j<ans.size(); j++) {
      cout << ans.at(j).size();
      for (ll k=0; k<ans.at(j).size(); k++) {
        cout << ' ' << ans.at(j).at(k);
      }
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
#include<stdio.h>
#include<stdlib.h>

int main(){
  int h[300],w[300],i,j,k=0;
  while(1){
    scanf("%d%d",&h[k],&w[k]);
    if(h[k]==0&&w[k]==0){
      break;
    }
    k++;
  }
  k=0;
  while(1){
    if(h[k]==0&&w[k]==0){
      break;
    }
    for(i=0;i<h[k];i++){
        for(j=0;j<w[k];j++){
          printf("#");
        }
        printf("\n");
    }
    printf("\n");
    k++;
  }
 
    return 0;

}


Measured memory_bytes: 2000