akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  ll N, D;
  cin >> N >> D;
  vector<double> X(N), Y(N);
  for (int i=0; i<N; i++) cin >> X[i] >> Y[i];
  int res = 0;
  for (int i=0; i<N; i++) {
    if (X[i]*X[i]+Y[i]*Y[i]<=D*D) res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 6428
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    char c1[3]; cin >> c1;
    char c2[3]; cin >> c2;
    char c3[3]; cin >> c3;

    cout << c1[0] << c2[1] << c3[2] << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma optimize("", off)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:36777216")
#include <bits/stdc++.h>

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define all(v) v.begin(),v.end()
#define pb push_back
#define sz(i) (int)(i.size())
#define setto(n) cout << fixed << setprecision(n)
#define fi first
#define se second
#define ld long double
#define inf LONG_MAX
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int mod = 1000000007;
using namespace std;

#define meta __FUNCTION__<<" : "<<__LINE__<<" "
#define tr1(x) cerr<<meta<<"| "<<#x<<" : "<<x<<" | "<<endl
#define tr2(x,y) cerr<<meta<<"| "<<#x<<" : "<<x<<" | "<<" "<<#y<<" : "<<y<<" | "<<endl
#define tr3(x,y,z) cerr<<meta<<"| "<<#x<<" : "<<x<<" | "<<" "<<#y<<" : "<<y<<" | "<<" "<<#z<<" : "<<z<<" | "<<endl
#define tr4(w,x,y,z) cerr<<meta<<"| "<<#w<<" : "<<w<<" | "<<" "<<#x<<" : " <<x<<" | "<<" "<<#y<<" : "<<y<<" | "<<" "<<#z<<" : "<<z<<" | "<<endl
#define tr5(v,w,x,y,z) cerr<<meta<<"| "<<#v<<" : "<<v<<" | "<<" "<<#w<<" : "<<w<<" | "<<" "<<#x<<" : "<<x<<" | "<<" "<<#y<<" : "<<y<<" | "<<" "<<#z<<" : "<<z<<" | "<<endl
#define tr6(u,v,w,x,y,z) cerr<<meta<<#u<<" : "<<u<<" | "<<" "<<#v<<" : "<<v<<" | "<<" "<<#w<<" : "<<w<<" | "<<" "<<#x<<" : "<<x<<" | "<<" "<<#y<<" : "<<y<<" | "<<" "<<#z<<" : "<<z<<" | "<<endl

template<class T> void smin(T& a, T val) {if (a > val) a = val;}
template<class T> void smax(T& a, T val) {if (a < val) a = val;}
template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
//Check N size twiceeeeeeeeeeeeeeeeee, and verify it

const int N = 2*1e5 + 10;

int x[N], y[N], n, h[N];

int main(){_
	cin>>n;
	int H, x1, y1, h1;
	for (int i = 0; i < n; ++i)
	{
		cin>>x[i]>>y[i]>>h[i];
		if(h[i] > 0){
			x1 = x[i], y1 = y[i], h1 = h[i];
		}
	}

	for (int cx = 0; cx <= 100; ++cx)
	{
		for (int cy = 0; cy <= 100; ++cy)
		{			
			H = h1 + abs(x1-cx) + abs(y1-cy);
			bool check = true;		
			for (int i = 0; i < n; ++i)
			{
				if(max(H-abs(x[i]-cx)-abs(y[i]-cy),0) != h[i]){
					check = false;
				}
			}
	
			if(check){
				cout<<cx<<' '<<cy<<' '<<H;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.buffer.readline

    N = int(input())
    adj = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    """ここから変更"""

    # op: 普通に根を固定した木DPで子の情報を親に集めるときの演算
    def op(a, b):
        return a+b+1.

    # cum_merge: 累積opどうしをマージするときの演算
    def cum_merge(a, b):
        return a+b

    # たん位元(cum_merge(x, ident) = x)(「たん」を漢字にするとこどふぉでCEになる(なぜ？))
    ident_cum_merge = 0.

    # DP配列の初期化(opと合わせてうまく答えが求まるようにする)
    dp = [0.] * (N+1)
    from_par = [-1.] * (N+1)
    """ここまで変更"""

    # root=1でまず普通に木DPをする
    # 並行して各頂点につき、子の値の累積opを左右から求めておく
    # その後根から順番に、親からの寄与を求めていく(from_par)
    def Rerooting(adj):
        N = len(adj) - 1
        st = [1]
        seen = [0] * (N + 1)
        seen[1] = 1
        par = [0] * (N + 1)
        child = [[] for _ in range(N + 1)]
        seq = []
        while st:
            v = st.pop()
            seq.append(v)
            for u in adj[v]:
                if not seen[u]:
                    seen[u] = 1
                    par[u] = v
                    child[v].append(u)
                    st.append(u)
        seq.reverse()
        left = [ident_cum_merge] * (N + 1)
        right = [ident_cum_merge] * (N + 1)
        for v in seq:
            L = len(child[v])
            if L:
                tmp = ident_cum_merge
                for u in child[v]:
                    left[u] = tmp
                    tmp = op(tmp, dp[u])
                tmp = ident_cum_merge
                for u in reversed(child[v]):
                    right[u] = tmp
                    tmp = op(tmp, dp[u])
                dp[v] = tmp / L

        seq.reverse()
        for v in seq:
            if v == 1:
                continue
            if len(adj[par[v]]) > 1:
                from_par[v] = op(cum_merge(left[v], right[v]), from_par[par[v]]) / (len(adj[par[v]]) - 1)
            else:
                from_par[v] = 0.
            dp[v] = op(dp[v] * (len(adj[v]) - 1), from_par[v]) / len(adj[v])

        return dp

    ans = Rerooting(adj)
    for v in range(1, N+1):
        print(ans[v])


if __name__ == '__main__':
    main()


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

#define forn(i, n) for(int i = 0; i < (int)n; ++i)

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

	cout << fixed << setprecision(15);

	if(n % 2 == 0) cout << (double)n / (2*n) << "\n";
	else cout << (double)(n + 1) / (2*n) << "\n";

	return 0;
}

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

int main() {
    int64_t N;
    string S;
    int64_t cnt = 0;
    cin >> N >> S;
    vector<int64_t> R(0);
    vector<int64_t> G(0);
    vector<int64_t> B(0);

    for(int64_t i = 0;i < N; i++){
        if(S.at(i) == 'R'){
            R.push_back(i);
        }else if(S.at(i) == 'G'){
            G.push_back(i);
        }else if(S.at(i) == 'B'){
            B.push_back(i);
        }
    }

    for(int64_t x: R){
        for(int64_t y: G){
            cnt += B.size();
            if(binary_search(B.begin(), B.end(), 2*y-x)){
                cnt -= 1;
                //cout << x << y << 2*y-x << endl;
            }
            if(binary_search(B.begin(), B.end(), 2*x-y)){
                cnt -= 1;
                //cout << 2*x-y << x << y << endl;
            }
            if((x+y)%2 == 0 && binary_search(B.begin(), B.end(), (x+y)/2)){
                cnt -= 1;
                //cout << x << (x+y)/2 << y << endl;
            }
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
using namespace std;

int main(){
  int a, b; cin >> a >> b;
  int add = a + b;
  int sub = a - b;
  int mul = a * b;
  cout << max({add, sub, mul});
  return 0;
}

Measured memory_bytes: 256
def num_to_char(s_num):
    ch = []
    for num in s_num:
        ch.append(alphabet[(num%26)-1])
    return ch

s = raw_input()
K = input()

alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','\
q','r','s','t','u','v','w','x','y','z']
ans = []

s_num = []
for char in s:
    s_num.append(alphabet.index(char) + 1)

for i in xrange(len(s_num)):
    if 27 - s_num[i] <= K and (s_num[i] != 1) and (i != len(s_num) - 1):
        K = K - (27 - s_num[i])
        s_num[i] = 27
    elif (i == len(s_num) - 1):
        s_num[i] = s_num[i] + K
    else:
        pass
print "".join(num_to_char(s_num))

Measured memory_bytes: 4484
#include<stdio.h>
 
int main(){
   int S;
   int h, m, s;

   scanf("%d", &S);
   h = S / 3600; m = S % 3600 / 60; s = S % 60;
   printf("%d:%d:%d\n", h, m, s);
   return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,temp=0;
  int a[100][100],b[100],c[100];
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      scanf("%d",&a[i][j]);
    }
  }
  for(int i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      temp+=a[i][j]*b[j];
    }
    cout << temp << endl;
    temp = 0;
  }
  return 0;
}



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

int main(void){
	int N;
	ll K;
	cin >> N >> K;
	int P[N+1];
	rep(i,N) cin >> P[i+1];
	int C[N+1];
	rep(i,N) cin >> C[i+1];

	ll ans = -1e10;
	for (int i = 1; i <= N; i++) {
		ll tot = 0;
		int j = i;
		vector<int> v;
		while (1) {
			j = P[j];
			tot += C[j];
			v.push_back(C[j]);
			if (j == i) break;
		}

		ll cand;
		ll tmp = 0;
		int period = v.size();
		rep(j, period) {
			if (j+1>K) break;
			tmp+=v[j];
			cand = tmp;
			if (tot>0) {
				cand += tot*((K-j-1)/period);
			}
			ans = max(ans, cand);
		}
	}

	cout << ans << endl;

return 0;
}

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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
constexpr int INF = 0x3f3f3f3f; constexpr ll BINF = 0x3f3f3f3f3f3f3f3fLL;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int n, m; cin >> n >> m;
	vvi g(n);
	vi inDe(n);
	for (int i=0;i<m;i++) {
		int u, v; cin >> u >> v;
		g[u].push_back(v); inDe[v]++;
	}
	vi ans;
	queue<int> q;
	for (int i=0;i<n;i++) if (inDe[i] == 0) q.push(i);
	while (!q.empty()) {
		int u = q.front(); q.pop();
		ans.push_back(u);
		for (int v : g[u]) {
			inDe[v]--;
			if (inDe[v] == 0) q.push(v);
		}
	}
	for (int x : ans) cout << x << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << "Case #" << i << ": ", solve();
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 3820
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
//const int MAX=;

int N,K;

int kmin(vi v){
	sort(v.begin(),v.end());
	int l=sz(v);
	int m=2e9+5;
	rep(i,l-K+1)m=min(m,v[i+K-1]-v[i]);
	return m;
}

int main(){
	cin>>N>>K;
	vector<P> c;
	rep(i,N){
		int x,y;
		cin>>x>>y;
		c.push_back(make_pair(x,y));
	}
	sort(c.begin(),c.end());
	ll ans=5e18;
//[i,j]での最小
	rep(i,N)rep(j,N){
		if(j-i<K-1)continue;
		int x=c[j].first-c[i].first;
		vi cy;
		for(int k=i;k<=j;k++)cy.push_back(c[k].second);
		int y=kmin(cy);
		ll ar=(ll)x*y;
		ans=min(ans,ar);
	}
	cout<<ans<<endl;
}

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

#define INF (1e9+5)
using namespace std;
typedef long long ll;

int main() {
  int D,G;
  vector<ll> p;
  vector<ll> c;
  cin >> D >> G;
  p.resize(D);
  c.resize(D);
  for (int i=0; i<D; i++) {
    cin >> p[i] >> c[i];
  }

  ll ans = INF;
  for (int bit=0; bit<(1<<D); bit++) {
    ll sum=0;
    ll num=0;
    for (int i=0; i<D; i++) {
      if (bit & (1<<i)) {
        sum += c[i]+p[i]*100*(i+1);
        num += p[i];
      }
    }

    if (sum < G) {
      for (int i=D-1; i>=0; i--) {
        if (bit & (1<<i)) continue;
        for (int j=0; j<p[i]; j++) {
          if (sum >= G) break;
          sum += 100 * (i+1);
          num++;
        }
      }
    }
    ans = min(ans, num);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a = INT()
b = INT()
c = INT()
d = INT()
e = INT()
k = INT()

for i in [b,c,d,e]:
	if (i-a) > k:
		print(":(")
		break
else:
	for i in [c, d, e]:
		if (i-b) > k:
			print(":(")
			break
	else:
		for i in [d, e]:
			if (i-c) > k:
				print(":(")
				break
		else:
			if (e-d) > k:
				print(":(")
			else:
				print("Yay!")

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

int main(){
  long W,H,x,y;
  cin >> W >> H >> x >> y;
  if(W%2==1&&H%2==1){
    cout << W*H/2+0.5 << ' ';
  }
  else{
    cout << W*H/2 << ' ';
  }
  if(x*2==W&&y*2==H){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

template<i64 M>
struct modint {
  i64 a;
  constexpr modint(const i64 x = 0) noexcept: a((x % M + M) % M) {}
  constexpr i64 value() const noexcept { return a; }
  constexpr modint pow(i64 r) const noexcept {
    modint ans(1);
    modint aa = *this;
    while(r) {
      if(r & 1) {
        ans *= aa;
      }
      aa *= aa;
      r >>= 1;
    }
    return ans;
  }
  constexpr modint& operator+=(const modint r) noexcept {
    a += r.a;
    if(a >= M) a -= M;
    return *this;
  }
  constexpr modint& operator=(const i64 r) {
    a = (r % M + M) % M;
    return *this;
  }
  constexpr modint& operator-=(const modint r) noexcept {
    a -= r.a;
    if(a < 0) a += M;
    return *this;
  }
  constexpr modint& operator*=(const modint r) noexcept {
    a = a * r.a % M;
    return *this;
  }
  constexpr modint& operator/=(modint r) noexcept {
    i64 ex = M - 2;
    while(ex) {
      if(ex & 1) {
        *this *= r;
      }
      r *= r;
      ex >>= 1;
    }
    return *this;
  }

  constexpr modint operator+(const modint r) const {
    return modint(*this) += r;
  }
  constexpr modint operator-(const modint r) const {
    return modint(*this) -= r;
  }
  constexpr modint operator*(const modint r) const {
    return modint(*this) *= r;
  }
  constexpr modint operator/(const modint r) const {
    return modint(*this) /= r;
  }
};


int main() {
  using fp = modint<(i64)(1e9 + 7)>;

  i64 N, K;
  cin >> N >> K;

  if(N == 1) {
    cout << 1 << endl;
    return 0;
  }

  i64 M = sqrt(N) + 1;

  vector<fp> right(1);
  vector<fp> rs(1);

  i64 s = 1;
  for(; N / (s + 1) > M; s++) {
    right.push_back(fp(N / s - N / (s + 1)));
    rs.push_back(fp(N / s - N / (s + 1)));
  }

  right.push_back(fp(1));
  rs.push_back(fp(1));

  M = N / s - 1;

  //M = N;
  //s = -1;

  vector<fp> left(M + 1, fp(1));
  // 1 2 3 4 [5] [6 7 8 9 10]

  s++;

  rep(k,1,K) {
    vector<fp> L = left;
    vector<fp> R = right;
    left.assign(L.size(), fp(0));
    right.assign(R.size(), fp(0));

    rep(i,1,M + 1) {
      if(i < s) {
        right[i] += L[i];
      }
      else {
        left[N / i] += L[i];
      }
    }

    rep(i,1,s) {
      left[i] += R[i];
    }
    if(s != 0) {

      rep(i,2,s) {
        right[i] += right[i - 1];
      }
      left[M] += right[s - 1];

      rep(i,1,s) {
        right[i] *= rs[i];
      }
    }

    rev(i, M, 1) {
      left[i] += left[i + 1];
    }
  }

  fp ans = 0;
  rep(i,1,M + 1) ans += left[i];
  rep(i,1,s) ans += right[i];

  cout << ans.value() << endl;
}


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

class Main{
    public static void main(String[] args)throws IOException{
      try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
        String[] varity = br.readLine().split(" ");
        String[] str_f = br.readLine().split(" ");
        String[] str_m = br.readLine().split(" ");

        int A = Integer.parseInt(varity[0]);
        int B = Integer.parseInt(varity[1]);
        int M = Integer.parseInt(varity[2]);

        int[] freeze = new int[A];
        int[] microwave = new int[B];

        int min_f = 0;
        int min_m = 0;
        
        for(int i = 0; i < A; i++){
          freeze[i] = Integer.parseInt(str_f[i]);
          if(i == 0){
            min_f = freeze[i];
          }else{
            if(min_f > freeze[i]){
              min_f = freeze[i];
            }
          }
        }

        for(int i = 0; i < B; i++){
          microwave[i] = Integer.parseInt(str_m[i]);
          if(i == 0){
            min_m = microwave[i];
          }else{
            if(min_m > microwave[i]){
              min_m = microwave[i];
            }
          }
        }

        int num_f = 0;
        int num_m = 0;
        int sub = 0;
        int tmp = 0;
        int result = 0;

       for(int i = 0; i < M; i++){
         String[] input = br.readLine().split(" ");
         num_f = Integer.parseInt(input[0]);
         num_m = Integer.parseInt(input[1]);
         sub = Integer.parseInt(input[2]);

         tmp = freeze[num_f-1] + microwave[num_m-1] - sub;
    
         if(i == 0){
           result = tmp;
         }else{
           if(result > tmp){
             result = tmp;
           }
         }
       }
        
       if(result < min_f + min_m){
         System.out.println(result);
       }else{
         System.out.println(min_f+min_m);
       }
      }
    }
}

Measured memory_bytes: 65680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class A
{
    static void Main()
    {
        int[] intRecord = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();

        var K = intRecord[0];
        var X = intRecord[1];

        var answer = K * 500 >= X ? "Yes" : "No";
        Console.WriteLine(answer);
    }

}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

int main() {
  std::vector<int> v;
  int n, l;

  std::cin >> n >> l;

  v.resize(n);
  std::iota(v.begin(), v.end(), l);

  if (l > 0) {
    v.erase(v.begin());
  } else if (l <= 0 && (n + l) > 0) {    
    auto itr = std::find(v.begin(), v.end(), 0);
    v.erase(itr);
  } else {
    v.pop_back();
  }

  std::cout << accumulate(v.begin(), v.end(), 0) << std::endl;
  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
D=list(map(int,input().split()))
nums=[i for i in range(10) if i not in D]

def str_check(string):
  string=str(string)
  for i in string:
    if int(i) not in nums:
      return False
  return True

for i in range(1,100000):
  if str_check(i)==True and n<=i:
    print(i)
    exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n,m,k;
   cin>>n>>m>>k;

   vector<long int> v(n),u(m);

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

   for(long int i = 0; i < m; i++)
   		cin>>u[i];

   for(long int i = 1; i < n; i++)
   		v[i] += v[i - 1];

   for(long int i = 1; i < m; i++)
   		u[i] += u[i - 1];


   long int ans = 0;

   for(long int i = 0; i <= n; i++){
   		long int booksRead = i;
   		long int timeLeft = k;
   		if(i)
   			timeLeft -= v[i - 1];

   		if(timeLeft < 0)
   			continue;

   		long int moreRead = upper_bound(u.begin(),u.end(),timeLeft) - u.begin();
   		booksRead += moreRead;

   		ans = max(ans,booksRead);
   }

   cout<<ans;
   return 0;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=10000000000000000;


int main(){
  ll n,k;
  cin >> n >> k;
  ll ans=0;
  for (int i=1;i<n+1;i++){
    if (i<=k) continue;
    ll c=n/i;
    ans+=c*(i-k);
    ll u=n%i;
    if (u>=k) ans+=u-k+1;
    if (k==0) ans--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
s = input()
aCnt, bCnt, cCnt = 0, 0, 0
for c in s:
    if c == 'a':
        aCnt += 1
    elif c == 'b':
        bCnt += 1
    else:
        cCnt += 1
if max(max(aCnt, bCnt), cCnt) - min(min(aCnt, bCnt), cCnt) <= 1:
    print("YES")
else:
    print("NO")

# print(*data, sep='\n')


Measured memory_bytes: 39536
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

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

int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };

const ll MOD = 1000000007;
const ll INF = 10000000;


int main(void){
    int n, m;
    P p[100005];
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        cin >> p[i].second >> p[i].first;
    }

    sort(p, p + m);

    int pre = -1;
    int ans = 0;

    for (int i = 0; i < m; i++){
        if (p[i].second <= pre) continue;
        ans++;
        pre = p[i].first - 1;

    }

    cout << ans << endl;

}

Measured memory_bytes: 1152
def main():
    num, yen_sum = map(int, input().split())
    yen_sum /=1000
    res = [-1, -1, -1]
    for bill_10000 in range(num+1):
        if bill_10000*10 + (num-bill_10000+1)*5 <= yen_sum:
            continue
        for bill_5000 in range(num-bill_10000+1):
            bill_1000 = num - bill_10000 - bill_5000
            if bill_10000*10 + bill_5000*5 + bill_1000*1 == yen_sum:
                res = [bill_10000, bill_5000, bill_1000]
                break
    print(*res)
    
if __name__ == '__main__':
    main()

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

int main(){
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  int cnt=0;
  for(int i=0;i<N-1;i++){
    if(S.at(i)=='R' && S.at(i+1)=='L') cnt++;
  }
  int cntb=0;
  
  if(S.at(0)=='L') cntb++;
  if(S.at(N-1)=='R') cntb++;
  
  //cout<<cnt<<" "<<cntb<<endl;
  
  if(cnt<=K){
    int temp=cnt;
    cnt=0;
    K-=temp;
  }
  
  else{
    cnt-=K;
    K=0;
  }
  //cout<<cnt<<" "<<cntb<<" "<<K<<endl;
  if(cntb<=K){
    cntb=0;
  }
  else{
    cntb-=K;
  }
  //cout<<cnt<<" "<<cntb<<endl;
  int ans=N;
  if(cnt != 0){
    ans=ans-cnt*2-cntb;
  }
  else{
    if(cntb == 2){
      ans=ans-2;
    }
    else{
      ans=ans-1;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3700
n=int(input())
s=input()
stk=[]
cnt=0 
add=0
for i in s:
    if i=='(':
        stk.append(i)
    else:
        if not stk:
            cnt+=1 
        else:
            stk.pop()
add=len(stk)
print('('*cnt+s+')'*add)

Measured memory_bytes: 38384
// E - ∙ (Bullet)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using PR = pair<ll,ll>;
using MP = map<PR,vi>;
#define MOD 1'000'000'007LL

// a^n mod m を計算する(繰り返し二乗法,二分累乗法:O(logn)) (再帰版)
ll modpow(ll a,ll n){return n?modpow(a*a%MOD,n/2)*(n%2?a:1)%MOD:1;}

int main(){
	int N; cin>>N;
	ll zero = 0;
	MP bad;
	while(N--){
		ll x,y; cin>>x>>y;
		if(x==0 && y==0){
			zero++;
			continue;
		}
		ll g = gcd(x, y);
		x /= g, y /= g;
		if(y < 0) x = -x, y = -y;
		if(y==0 && x<0) x = -x, y = -y;
		int is_rotate90 = (x <= 0);
		if(is_rotate90){ swap(x, y); y = -y; }
		// cout<<x<<" "<<y<<"\n";
		// cout<<"rote "<<is_rotate90<<"\n";
		if(bad.count({x,y}) == 0) bad[PR(x, y)] = {0, 0};
		bad[PR(x, y)][is_rotate90]++;
	}

	// for(auto x:bad){
	// 	cout<<"("<<x.first.first<<","<<x.first.second<<")";
	// 	cout<<" ["<<x.second[0]<<","<<x.second[1]<<"]\n";
	// }

	ll cnt = 1;
	for(auto x:bad){
		vi val = x.second;
		int c1 = val[0], c2 = val[1];
		ll c3 = 1;
		c3 += modpow(2, c1) - 1;
		c3 += modpow(2, c2) - 1;
		cnt = cnt * c3 % MOD;
	}

	ll ans = (cnt + zero -1) % MOD;
	cout<< (ans + MOD) % MOD <<endl;
}


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

using namespace std;

using ll = long long;

int main(){
    char b;
    cin >> b;
    if(b == 'A')cout << "T";
    else if(b == 'T')cout << "A";
    else if(b == 'G')cout << "C";
    else cout << "G";
}


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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int s, w;
  cin >> s >> w;
  if(s <= w) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
N, K = map(int, input().split())
p = [int(x) for x in input().split()]

mysum = [0] * 1001
for i in range(1, 1001):
    mysum[i] = mysum[i-1] + i

pp = list(map(lambda x: mysum[x] / x, p))

psum = sum(pp[:K])
ans = psum
for i in range(K, N):
    psum = psum + pp[i] - pp[i - K]
    ans = max(ans, psum)
print(ans)

Measured memory_bytes: 25188
#include<bits/stdc++.h>
using namespace std;
int l,r,d,sum;
int main(){
    int n;
    cin>>n;
    int d;
    for(int i=1;i<=n;i++)cin>>d,sum+=(i%2&&d%2);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

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

int main(){
    
    long long a,b;
    while(cin>>a){
        cin>>b;
        cout<<gcd(a,b)<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3000
from operator import itemgetter

n = int(input())
 
data = []
for i in range(n):
    city, point = input().split()
    data.append([city, int(point), i+1])

data = sorted(data, key=itemgetter(1), reverse=True)
data = sorted(data, key=itemgetter(0), reverse=False)

for i in range(n):
    print(data[i][2])

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    int n;
    cin>>n;
    cout<<fixed<<setprecision(10)<<1.0l*((n+1)/2)/n<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let mut T = read![i64, i64; N]
        .into_iter()
        .map(|(X, L)| (X + L, X - L))
        .collect::<Vec<_>>();
    T.sort();

    let mut end = std::i64::MIN;
    let mut count = 0;

    for (r, l) in T {
        debug!((l, r), end);
        if l < end {
            continue;
        }
        end = r;
        count += 1;
    }

    println!("{}", count)
}


Measured memory_bytes: 8444
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        h: [i64; n],
    }

    let mut tbl = vec![0; n + 1];

    for i in 1..n {
        tbl[i] = tbl[i - 1] + (h[i] - h[i - 1]).abs();
        if i >= 2 {
            tbl[i] = std::cmp::min(tbl[i], tbl[i - 2] + (h[i] - h[i - 2]).abs());
        }
    }

    let ans = tbl[n - 1];

    println!("{}", ans);
}


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

int main() {
  int N,K,x,la,lb,min;
  cin>>N>>K;
  for(int i=0;i<N;){
    i++;
    cin>>x;
    la=2*x;
    lb=2*(K-x);
    if(la<=lb)
      min+=la;
    else
      min+=lb;
  }
  cout<<min<<endl;
}


Measured memory_bytes: 256
import collections

_ = input()
lst = list(map(int,input().split()))

lst = sorted(lst)
elim = [False for _ in range(10**6 + 1000)]
c = collections.Counter(lst)

for x in lst:
  if elim[x]:
    continue
  for i in range(x+x,10**6+1,x):
    elim[i] = True
  if c[x] > 1:
    elim[x] = True

cnt = 0
for x in lst:
  if not elim[x]:
    cnt += 1

print(cnt)

    

Measured memory_bytes: 168924
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]

class UnionFind:
  def __init__(self, n):
    self.par = [-1] * (n+1)

    self.rank = [0] * (n+1)

  def find(self, x):
    if self.par[x] < 0:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
  
  def same_check(self, x, y):
    return self.find(x) == self.find(y)
  
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return False
    else:
      if self.par[x] > self.par[y]:
        x,y = y,x
      self.par[x] += self.par[y]
      self.par[y] = x

      return True
  
  def size(self, x):
    return -self.par[self.find(x)]


# インスタンス作成
uni = UnionFind(n)
# 木を作成
for i in range(m):
  uni.unite(ab[i][0],ab[i][1])

result = 0
for i in range(1,n+1):
  if uni.par[i] < 0:
    result += 1
print(result-1)

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

int main() {
  int k, s, res;
  cin >> k >> s;
  
  for (int i = 0; i <= k; i++) {
    int x = i;
    for (int j = 0; j <= k; j++) {
      int y = j;
      int z = s-x-y;
      if (0 <= z && z <= k) res++;
    }
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int s = sc.nextInt();
    int h = s / 3600;
    s -= h * 3600;
    int m = s / 60;
    s -= m * 60;
    System.out.printf("%d:%d:%d\n", h,m,s);
    sc.close();
  }
}



Measured memory_bytes: 26340
# B

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

alice = 0
bob = 0
flag = 0
while len(A):
    i = A.index(max(A))
    if flag == 0:
        alice += A[i]
        flag = 1
        del A[i]
    else:
        bob += A[i]
        flag = 0
        del A[i]

print(alice - bob)

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

#define ll long long
#define pb push_back
#define iter std::vector<int>::iterator

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

	
  	int a, b; cin >> a >> b;
 
  	a = ((a-1)*a)/2;
  	b = ((b-1)*b)/2;
  
	int c = a + b;
  	cout << c;

	return 0;	
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [0]*n

for i in range(n):
    if i == 0:
        dp[0] = 0
    elif i == 1:
        dp[1] = abs(h[0]-h[1])
    else:
        cost1 = dp[i-1] + abs(h[i-1]-h[i])
        cost2 = dp[i-2] + abs(h[i-2]-h[i])
        dp[i] = min(cost1, cost2)

print(dp[n-1])


Measured memory_bytes: 13980
/* code of Ayush Tiwari
    codeforces- servermonk
    codechef- ayush572000
*/

#include <bits/stdc++.h>
#define ll long long

//STL
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define all(v) v.begin(), v.end()

//loops
#define forn(i,a,b) for(int i=a;  i<b; i++)
#define rforn(i,a,b) for(int i=a; i>=b; i--)

// defined values
#define maxn 200004
#define Mod 1000000007

// fast io
#define FIO() ios_base::sync_with_stdio(0);cin.tie(0);


using namespace std;


void solution(){

    // This is the main code
    string x,y;
    cin>>x>>y;
    int n=x.size(),m=y.size();
    int dp[n+1][m+1];
    forn(i,0,n+1){
        forn(j,0,m+1){
            if(i==0 || j==0) dp[i][j]=0;
            else{
                if(x[i-1]==y[j-1]) dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string ans;
    int i=n,j=m;
    while(i>0 && j>0){
        if(x[i-1]==y[j-1]){
            ans.pb(x[i-1]);
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]) i--;
            else j--;
        }
    }
    reverse(all(ans));
    cout<<ans;
}


int main(){
    
    #ifndef ONLINE_JUDGE
    freopen("E:/CP/input.txt","r",stdin);
    freopen("E:/CP/output.txt","w",stdout);
    #endif  
    
    FIO()   
    
    ll t=1;
    //cin>>t;
    while (t--)
    {
        solution();
    }
    return 0;
}

Measured memory_bytes: 38776
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(1,31):
    if 2**i>=a[-1]+1:
        num=i
        break
ans=2**(num-1)
num1=2**(num-1)
l1=[]
for i in range(num+1):
    cnt=0
    for j in range(n):
        cnt+=-(a[j]//-ans)-1
    num1=num1//2
    if cnt>k:
        ans=min(a[-1],ans+num1)
    else:
        l1.append(ans)
        ans=max(1,ans-num1)
print(min(l1))


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

int main() {
  ll n, k, q, x;
  cin >> n >> k >> q;
  vector<ll> v(n+1, 0);
  
  for (ll i = 0; i < q; i++) {
    cin >> x;
    v[x]++;
  }
  
  for (ll i = 1; i <= n; i++) {
    if (k - q + v[i] <= 0) cout << "No\n";
    else cout << "Yes\n";
  }
}

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

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

  ll cpn, cnt =0, cnt1 = 0;
  for(int i=1; i<=n; ++i){
    cpn = i;
    while(cpn != 0){
      cpn /= 10;
      cnt++;
    }
    if(cnt%2 == 1) cnt1++;
    cnt = 0;
  }

  cout << cnt1;

      return 0;
}

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


int main()
{
  int n,i = 0,count = 0,flag;
  scanf("%d",&n);
  char str[100];
  //gets(str);
  scanf("%s",&str);
  //printf("%d",strlen(str));
  i = 0;
  while(i < (strlen(str) - 2))
  {
    flag = 0;
    if(str[i] == 'A' && str[i+1] == 'B' && str[i+2] == 'C')
    {
      i += 3;
      flag = 1;
      count++;
    }
    if(!flag) i++;
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;

int main(){
  int a;
  cin >> a;
  if(a%10 == 9 || a/10 == 9) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print('\n'.join(x))

x = ni()
v = 100
for i in range(1, 4000):
    v += v // 100
    if v >= x:
        print(i)
        break


Measured memory_bytes: 9252
n, m = map(int, input().split())

stairs = ["o"] * (n + 1)

for _ in range(m):
  stairs[int(input())] = "x"

c = [0] * (n + 1)
c[0] = 1
if stairs[1] == "x":
  c[1] = 0
else:
  c[1] = 1

for i in range(2, n + 1):
  if stairs[i] == "x":
    c[i] = 0
  else:
    c[i] = c[i - 1] + c[i - 2]

print(c[n] % 1000000007)

Measured memory_bytes: 466596
N, A, B, C = list(map(int, input().split(' ')))
bam_list = []

for i in range(N):
  bam_list.append(int(input()))

INF = 10000000

def enumerate(bam_list, a, b, c):
  if len(bam_list) == 0:
    return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else  INF
  cur = bam_list[0]
  patA = enumerate(bam_list[1:], a + cur , b, c) + 10
  patB = enumerate(bam_list[1:], a, b+cur, c) + 10
  patC = enumerate(bam_list[1:], a, b, c+cur) + 10
  patD = enumerate(bam_list[1:], a, b, c)
  return min(patA, patB, patC, patD)

print(enumerate(bam_list, 0, 0, 0))
   
    
  


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define X first
#define Y second
#define pb push_back
#define mp make_pair

const int maxn = 1e2 + 100 , maxc = 115, mod = 1e9 + 7, inf = 1e9+10;

ll n, f[maxn][20], c[maxn], p[maxn][20];

bool ok (ll mask)
{
	for (int i = 0; i < 10; i += 2)
	{
		if ( ((mask >> i) & 1) || ((mask >> (i + 1)) & 1) )
			continue;
		return 0;
	}
	return 1;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n ;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 10; j++)
				cin >> f[i][j];
	ll ans = -inf;

	for (int i = 0; i < n; i++)
		for (int j = 0; j <= 10; j++)
			cin >> p[i][j];

	for (ll mask = 1; mask < (1 << 10); mask++)
	{
		memset (c, 0, sizeof c);
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 10; j++)
				if (( (mask >> j) & 1) && f[i][j])
					c[i]++;
		ll res = 0;
		for (int i = 0; i < n; i++)
			res += p[i][c[i]];
		ans = max (ans, res);
		//cout << res << ' ' << mask << endl;
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
from math import sqrt

n,d = map(int,input().split())
li  = [list(map(int,input().split())) for i in range(n)]
tmp = 0
ans = 0

for i in range(n):
  for j in range (i+1,n):
    for k in range(d):
      tmp += pow(abs(li[i][k]-li[j][k]),2)
    if sqrt(tmp)%1==0:
      ans += 1
    tmp =  0

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
 int64_t a,b;
 cin>>a>>b;
if(a>0){cout<<"Positive"<<endl;}
else if(b<0){if((b-a+1)%2!=0){cout<<"Negative"<<endl;}
        else if((b-a+1)%2==0){cout<<"Positive"<<endl;}
}
else if(a<=0&&b>=0){cout<<"Zero"<<endl;}
}

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

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

  int x[3010], y[3010];
  for(int i = 0;i < n;i++){
    cin >> x[i] >> y[i];
  }

  bool fin = false;
  for(int i = 0;i < n;i++){
    map<double, int> cnt;
    int zero = 0;

    for(int j = 0;j < n;j++){
      if(i == j) continue;

      double y2 = y[j] - y[i];
      double x2 = x[j] - x[i];

      if(x2 == 0){
        zero++;
        if(zero == k-1){
          fin = true;
          break;
        }
      }else{
        double tmp = y2 / x2;
        cnt[tmp]++;
        if(cnt[tmp] == k-1){
          fin = true;
          break;
        }
      }
    }
    if(fin) break;
  }

  if(fin){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }

  return 0;
}



Measured memory_bytes: 3320
#include<bits/stdc++.h>
#define LL long long
#define rep(i,a,b) for(int i=a;i<=b;++i)
using namespace std;

const int mn=57;
int a[mn],b[mn],c[mn],d[mn],v[mn]={1};
int n,m,q,ans;

void dfs(int x)
{
	if(x==n+1) {
		int sum=0;
		for(int i=1;i<=q;++i) {
			if(v[b[i]]-v[a[i]]==c[i]) sum+=d[i];
		}
		ans=max(ans,sum);
		return ;
	}
	for(int i=v[x-1];i<=m;++i) {
		v[x]=i;
		dfs(x+1);
	}
}

int main()
{
	scanf("%d%d%d",&n,&m,&q);
	rep(i,1,q) scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
	dfs(1);
	printf("%d",ans);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define REP(i, d, n) for(int i=(d); i<=(n); i++)
int main() {

    int h, w;
    cin >> h >> w;
    char s[55][55] = {};
    REP(i, 1, h){
        REP(j, 1, w){
            cin >> s[i][j];
        }
    }
    REP(i, 1, h){
        REP(j, 1, w){
            if(s[i][j] == '#'){
                if(s[i+1][j] != '#' && s[i-1][j] != '#' && s[i][j+1] != '#' && s[i][j-1] != '#'){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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

using namespace std;


int main() {
    int N;
    cin >> N;
    vector<double> nn(N);
    double t1, t2;
    for(int i=0; i<N; i++)cin >> nn.at(i);

    sort(nn.begin(), nn.end());
    reverse(nn.begin(), nn.end());

    for(int i=N-1; i!=0; i--){
        t1 = nn[i];
        t2 = nn[i-1];
        nn.pop_back();
        nn.pop_back();
        nn.push_back((t1 + t2)/2.0);

    }
    printf("%.10f\n", nn.at(0));

    return 0;
}


Measured memory_bytes: 256
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;

procedure Solve is
   X : Integer;
   A : Integer;
   B : Integer;
begin
   Get (X);
   Get (A);
   Get (B);
   X := X-A;
   Put_Line (Integer'Image (X-X/B*B));
end Solve;

Measured memory_bytes: 3672
l = list(map(int, input().split()))
l.sort()
a = l[2] - l[1]
b = l[2] - l[0]

if a % 2 == 0 and b % 2 == 0:
    print(a // 2 + b // 2)
elif a % 2 == 0 or b % 2 == 0:
    print(a // 2 + b // 2 + 2)
else:
    print(a // 2 + b // 2 + 1)

Measured memory_bytes: 3060