akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef int_fast64_t ll;
typedef int_fast32_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, a, b) for (tmp_m i = a; i < b; ++i)
#define repp(i, a, b) for (tmp_m i = a; i >= b; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& b) const {
    if (dst != b.dst) return dst > b.dst;
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& b) const {
    if (x != b.x) return x > b.x;
    return y > b.y;
  }
};

inline bool spoint(point a, point b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}

inline bool spr(pr a, pr b) {
  if (a.dst != b.dst) return a.dst < b.dst;
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}



void solve() {
  intt r;
  cin >> r;
  printf("%.12lf\n", 2 * r * M_PI);
  // cout << 2 * r * M_PI << endl;
}

void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

int main() {
  init();
  solve();
  return 0;
}


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



int main() {
    ll N; cin >> N;
    cout << 2 << " ";
    int cnt = 1;
    for(ll j = 11; ;j+=10){
        bool flag = true;
        for(int i = 2; i*i <= j; i++){
            if(j % i == 0){
                flag = false;
                break;
            }
        }
        if(flag && cnt < N) {
            cout << j << " ";
            cnt++;
        }
        if(cnt == N) break;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[]args){
		Scanner scan = new Scanner(System.in);
		
		String str[] = scan.nextLine().split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);
		
		System.out.println(a*b);
	}
}

Measured memory_bytes: 17320
#include<bits/stdc++.h>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	ll num = a;

	rep(i,0,1000000){
		if( num % b == c ){
			YES;
			ret 0;
		}
		num += a;
	}

	NO;
	ret 0;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

template<typename T>
struct BIT{
    private:
        using Func = function<T(T, T)>;

        int n;
        vector<T> node;

        T init_v;
        Func func;

    public:

        BIT(int N, Func _func, T _init_v) {
            n = N + 1;
            init_v = _init_v;
            func = _func;

            node.resize(n, init_v);
            for(int i=1; i<n; i++) if((i+(i&-i)) < n) node[i+(i&-i)] = func(node[i+(i&-i)], node[i]);
        }

        BIT() {}

        void add(int pos, T v) {
            // 1-indexed
            while(pos < n){
                node[pos] = func(node[pos], v);
                pos += pos & -pos;
            }
        }

        T sum(int pos){
            // 1-indexed
            T res = init_v;
            while(pos > 0){
                res = func(res, node[pos]);
                pos = pos & (pos-1);
            }
            return res;
        }
};

template<class T>
void compress(vector<T> &v){
    vector<T> w(v);
    sort(w.begin(), w.end());
	w.erase(unique(w.begin(), w.end()), w.end());

    int N = v.size(), K = w.size();
    map<T,int> m; REP(i,K) m[w[i]] = i;

    REP(i,N) v[i] = m[v[i]];
}

void Main(){
    ll N; cin >> N;
    VI a(N); REP(i,N) cin >> a[i];

    int l = 0, r = INF;
    while(r-l>1){
        int x = (l+r)/2;
        int mn = 0;
        VI s(N+1,0);
        REP(i,N) s[i+1] = a[i]<x ? s[i]-1 : s[i]+1;
        compress(s);

        BIT<int> bit(N+1,[](int a,int b){return a+b;},0);

        bit.add(s[0]+1,1);
        ll cnt = 0;
        REP(i,N){
            cnt += bit.sum(s[i+1]+1);
            bit.add(s[i+1]+1,1);
        }

        if(cnt >= (N*(N+1)/2 + 1)/2) l = x;
        else r = x;
    }
    cout << l << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 9100
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    Map<Integer,Integer> mapa = new LinkedHashMap<>();
    Map<Integer,Integer> mapb = new LinkedHashMap<>();
    int n = sc.nextInt();
    for(int i = 0;i<n;i++){
      int d = sc.nextInt();
      mapa.put(d,mapa.getOrDefault(d,0)+1);
    }
    int m = sc.nextInt();
    int[] t = new int[m];
    for(int i = 0;i<m;i++){
      t[i] = sc.nextInt();
      mapb.put(t[i],mapb.getOrDefault(t[i],0)+1);
    }

    //keisann
    for(int i = 0;i<t.length;i++){
      int tt = t[i];
      if(!(mapb.getOrDefault(tt,0)<=mapa.getOrDefault(tt,0))){
        System.out.println("NO");
        return;
      }
    }
    System.out.println("YES");

  }
}


Measured memory_bytes: 89436
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n; cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) {
        cin >> a[i];
    }
    rep(i, n) {
        cin >> b[i];
    }
    rep(i, n) {
        if(a[i] < b[i]) {
            cout << -1 << endl;
            return;
        }
    }
    int ans = 0;
    vector<int> s;
    for(int k = 51; k >= 1; -- k) {
        bool check = 0;
        vector<vector<int>> g(51, vector<int>());
        for(int i = 50; i >= 0; -- i) {
            for(int j: s) {
                g[i].pb(i % j);
            }
            for(int j = k - 1; j >= 1; -- j) {
                g[i].pb(i % j);
            }
        }
        rep(i, n) {
            queue<int> que;
            vector<int> dist(51, inf);
            dist[a[i]] = 0;
            que.push(a[i]);
            while(!que.empty()) {
                int v = que.front(); que.pop();
                for(int nv: g[v]) {
                    if(chmin(dist[nv], dist[v] + 1)) {
                        que.push(nv);
                    }
                }
            }
            if(dist[b[i]] == inf) {
                check = 1;
            }
        }
        if(check) {
            if(k == 51) {
                cout << -1 << endl;
                return;
            }
            ans += (1LL<<k);
            s.push_back(k);
        }
        //cerr << "k = " << k << endl;
        // rep(i, n) {
        //     cerr << a[i] << " ";
        // }
        // cerr << endl;
    }
    
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

int main() {
	int n,graph[100][100];
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			graph[i][j] = 0;
		}
	}
	cin >> n;

	for (int i = 0; i < n; i++) {
		int vertex,jisu;
		cin >> vertex>>jisu;
		vertex--;
		for (int j = 0; j < jisu; j++) {
			int to;
			cin >> to;
			to--;
			graph[vertex][to] = 1;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << graph[i][j];
			if (j < n - 1)cout << " ";
		}
		cout << "\n";
	}

	return 0;
}

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

namespace Program
{
    public class ABC084D
    {
        static public void Main(string[] args)
        {
            var prime = new HashSet<int>(Prime(100000));
            var sumary = new int[100001];
            foreach (var item in prime)
            {
                sumary[item] = prime.Contains((item + 1) / 2) ? 1 : 0;
            }
            for (int i = 1; i <= 100000; ++i)
            {
                sumary[i] += sumary[i - 1];
            }

            var Q = NextInt;
            for (int i = 0; i < Q; ++i)
            {
                var l = NextInt;
                var r = NextInt;
                Console.WriteLine(sumary[r] - sumary[l - 1]);
            }
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => Console_.NextInt();
        static long NextLong => Console_.NextLong();
        static string NextString => Console_.NextString();

        static IEnumerable<int> Prime(int x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (int)(Math.Sqrt(x) / 2);
            for (int i = 1; i <= max; ++i)
            {
                if (!table[i])
                {
                    var add = 2 * i + 1;
                    yield return add;
                    for (int j = 2 * i * (i + 1); j <= halfx; j += add)
                    {
                        table[j] = true;
                    }
                }
            }
            for (int i = max + 1; i <= halfx; ++i)
            {
                if (!table[i]) yield return 2 * i + 1;
            }
        }
    }
}


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

long long N, K, A[1 << 18], sum, ans;
vector<long long> vec;

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i]; sum += A[i];
		while (A[i] > 0) {
			long long r = A[i] / 2;
			vec.push_back(A[i] - r);
			A[i] = r;
		}
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	for (int i = 0; i < min((long long)vec.size(), K); i++) ans += vec[i];
	cout << sum - ans << endl;
	return 0;
}

Measured memory_bytes: 35684
S = input()

count = 1
sentence = S[0]
i=1

while i < len(S):
    if sentence != S[i]:
        sentence = S[i]
        count += 1
        i+=1
    elif i==len(S)-1:
        break
    else:
        count += 1
        sentence = S[i:i+2]
        i+=2

print(count)



Measured memory_bytes: 3500
#include <iostream>
#include <vector>

int main() {
  long int N;
  std::cin >> N;
  std::vector<long int> H(N);
  for (auto& h : H) { std::cin >> h; }
  long int count=0, countmax=0;
  for (int i=1; i<N; ++i) {
    if (H[i-1] >= H[i]) count++;
    else count=0;
    if (count > countmax) countmax = count;
  }
  std::cout << countmax << std::endl;
  return 0;
}



Measured memory_bytes: 1152
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

    cout << (a - 1) * (b - 1) << endl;

    return 0;
  }


Measured memory_bytes: 256
local str = io.read()
local n = #str
local t = {str:byte(1, n)}
for i = 1, n do
  t[i] = t[i] - 96
end
local mincost = 100
for alpha = 1, 26 do
  local prevpos = 0
  local cost = 0
  for i = 1, n do
    if(t[i] == alpha) then
      cost = math.max(cost, i - prevpos - 1)
      prevpos = i
    end
  end
  cost = math.max(cost, n - prevpos)
  mincost = math.min(mincost, cost)
end
print(mincost)


Measured memory_bytes: 256
#include <stdio.h>
#define max(a, b) ((a)<(b) ? (b) : (a))
int main(){
  long long int x = 0, ans = 0;
  int n;  scanf("%d", &n);
  char s[102];  scanf("%s", s);

  for(int i=0; i<n; i++){
    if(s[i] == 'D'){
      x--;
    }else{
      x++;
      ans = max(ans, x);
    }
  }
  printf("%lld\n", ans);
  return 0;
}


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

int main(void){
    int n,m,amount,sum = 0;
    scanf("%d%d",&n,&m);
    for(int i = 0;i<m;i++){
        scanf("%d",&amount);
        sum += amount;
    }
    if(n < sum) printf("%d",-1);
    else printf("%d",n - sum);
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <vector>
#include <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define rrep(i,n) for(int i = n-1;i >=0;i--)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 }, sum = 0,h,w;
int main() {
    int n,sum,ans = 1e9,mx=0,mi=1e9; cin >> n; vector<int> v(n);
    rep(i, n) {
        cin >> v[i];
        mx = max(mx, v[i]);
        mi = min(mi, v[i]);
    }
    for(int i = mi;i <=mx;i++) {
        sum = 0;
        rep(j, n) {
            sum = max(abs(i - v[j]),sum);
        }
        ans = min(ans, sum);
    }cout << ans << endl;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int a, b;
  cin >> a >> b;
  for (int n = 0; n < 10000; ++n) {

    int za = n*8/100;
    int zb = n*10/100;
    
    if (a == za && b == zb) {
      cout << n << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)+1
t=[-1]*n
if s[0]=='<':
    t[0]=0
if s[-1]=='>':
    t[-1]=0
for i in range(n-2):
    if s[i:i+2]=='><':
        t[i+1]=0
for i in range(n-1):
    if s[i]=='<':
        if t[i]>=0:
            t[i+1]=t[i]+1
for i in range(n-2,-1,-1):
    if s[i]=='>':
        if t[i+1]>=0:
            t[i]=max(t[i],t[i+1]+1)
print(sum(t))

Measured memory_bytes: 23452
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

#define out(t) cout << (t) << "\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int uint;

int popcount(uint x) {
    x -= x >> 1 & 0x55555555;
    x = (x & 0x33333333) + (x >> 2 & 0x33333333);
    x = x + (x >> 4) & 0x0F0F0F0F;
    return x * 0x01010101 >> 24;
}

int tzcnt(uint x) {
    return popcount(~x & x - 1);
}

struct Point {
    int x, y;

    Point(int p, int q) : x(p), y(q) {}
};

map<int, int> seq;

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

    int N; 
    cin >> N;

    for (int i = 0; i < N; ++i) {
        int t;
        cin >> t;

        if (seq.count(t)) ++seq[t];
        else seq[t] = 1;
    }

    int ans = 0;

    for (auto p : seq) {
        if (p.first <= 0) continue;

        ans += p.second < p.first ? p.second : (p.second - p.first);
    }

    out(ans);

    int aaa;
    cin >> aaa;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int n;
vector<int> lst[100010];
int main() {
	scanf("%d", &n);
	int lo = 1, hi = n;
	while(lo < hi) {
		int mid = (lo + hi) / 2;
		if(1ll*mid*(mid+1)/2 < n) lo = mid + 1;
		else hi = mid;
	}
	if(lo*(lo+1)/2 != n) { puts("No"); return 0; }
	puts("Yes");
	printf("%d\n", lo + 1);
	int cur = 1;
	for(int i=1; i<=lo; i++) {
		for(int j=1; j<=i; j++) {
			lst[i+1].push_back(cur);
			lst[i-j+1].push_back(cur);
			cur++;
		}
	}

	for(int i=1; i<=lo+1; i++) {
		printf("%d ", sz(lst[i]));
		for(int j : lst[i]) printf("%d ", j);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,l,r) for(ll i=(l);i<=(r);++i)
#define per(i,r,l) for(ll i=(r);i>=(l);--i)
using namespace std;
const int maxn=200010;
typedef long long ll;
ll n,a[maxn],b[maxn],c[maxn],t,mn;
void add(ll i,ll x){for(;i<=t;i+=i&(-i))c[i]+=x;}
int sum(ll i){ll ans=0;for(;i;i-=i&(-i))ans+=c[i];return ans;}
bool check(ll x){
	ll mn=0,ans=0;memset(c,0,sizeof(c));
	rep(i,1,n) if(a[i]>=x) b[i]=1;else b[i]=-1;
	rep(i,1,n) b[i]+=b[i-1],mn=min(mn,b[i]);
	rep(i,0,n) b[i]+=-mn+1,t=max(t,b[i]);
	rep(i,0,n){
		ans+=sum(b[i]);
		add(b[i],1);
	}
	return ans>=1LL*n*(n+1)/4;
}
int main(){
	scanf("%d",&n);
	ll l=1,r=0;
	rep(i,1,n) scanf("%d",&a[i]),r=max(a[i],r);
	while(l<=r){
		ll mid=(l+r)>>1;
		if(check(mid)) l=mid+1;
		else r=mid-1;
	}
	printf("%d",r);
	return 0;
}

Measured memory_bytes: 4352
import math

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

distance = float('inf')
answer = 0
for i, h in enumerate(H, 1):
    d = abs(A - (T - h * 0.006))
    distance = min(d, distance)
    if distance == d:
        answer = i

print(answer)


Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
 
 
 
class Solve
{
    public Solve() { }
    public static int Main()
    {
        new Solve().calc();
        return 0;
    }
 
 
    Scanner cin;
 
    void calc()
    {
        cin = new Scanner();
        var num = new int[3];
        var isEven = new bool[3];
        int evenCount = 0;

        for (int i = 0; i < 3; i++){
            num[i] = cin.nextInt();
            isEven[i] = (num[i] % 2 == 0);
            if (isEven[i])
                evenCount++;
        }

        int plusCount = 0;

        switch(evenCount){
            case 1:
                for (int i = 0; i < 3; i++){
                    if (num[i] % 2 != 0)
                    {
                        num[i]++;
                    }
                }
                plusCount++;
                break;
            case 2:
                for (int i = 0; i < 3; i++)
                {
                    if (num[i] % 2 == 0)
                    {
                        num[i]++;
                    }
                }
                plusCount++;
                break;
        }

        int highest = 0;
        for (int i = 0; i < 3; i++)
        {
            if (num[i] >= highest)
                highest = num[i];
        }

        for (int i = 0; i < 3; i++)
        {
            if (num[i] < highest){
                plusCount += (highest - num[i]) / 2;
            }
        }
        Console.WriteLine(plusCount.ToString());

    }
}
 
class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' ' };
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
 
    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
import sys

# sys.stdin = open('e1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def ceil_frac(a, b):
    return (a + b - 1) // b


def solve():
    n = read_int()
    a = read_int_list()
    s = sum(a)
    res = 0
    x = s - n * n
    if x > 0:
        res += x
        for j in range(n):
            a[j] += x
        l = 0
        r = 10 ** 20
        while r - l > 1:
            m = (l + r) // 2
            decrements = 0
            for j in range(n):
                if a[j] >= m:
                    decrements += ceil_frac(a[j] - m, n + 1)
            possible = decrements <= x
            if possible:
                r = m
            else:
                l = m
        t = 0
        for j in range(n):
            if a[j] >= r:
                u = ceil_frac(a[j] - r, n + 1)
                a[j] -= u * (n + 1)
                t += u
        for _ in range(x - t):
            j0 = 0
            for j in range(n):
                if a[j] > a[j0]:
                    j0 = j
            a[j0] -= n + 1
    while max(a) >= n:
        for j in range(n):
            a[j] += 1
        j0 = 0
        for j in range(n):
            if a[j] > a[j0]:
                j0 = j
        a[j0] -= n + 1
        res += 1
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n, m; long double sum = 0;
  cin >> n >> m;
  long long i;
  vector<long double> a(n);
  for(i = 0; i<n; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }

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

  long double k;
  k = sum / (4*m);

  if(a.at(n - m) < k)
    cout << "No";
  else
    cout << "Yes";

  

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>

typedef long long ll;

inline ll min(ll a,ll b){
	return a<b?a:b;
}

ll n,a,b;

int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	if(!((b-a)&1)) printf("%lld\n",(b-a)/2);
	else printf("%lld\n",min(a-1,n-b)+1+(b-a-1)/2);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdlib.h>

using namespace std;

class node{
public:
	int key;
	node *parent;
	node *right;
	node *left;
	node(){
		this->key = 0;
		this->parent = NULL;
		this->right = NULL;
		this->left = NULL;
	}
};

void print(int n,node H[]){

	int i;

	for(i = 0;i < n;i++){
		cout << "node " << i+1 << ": ";
		cout << "key = " << H[i].key << ", ";
		if(H[i].parent != NULL){
			cout << "parent key = " << H[i].parent->key << ", ";
		}
		if(H[i].left != NULL){
			cout << "left key = " << H[i].left->key << ", ";
		}
		if(H[i].right != NULL){
			cout << "right key = " << H[i].right->key << ", ";
		}
		cout << endl;
	}
}

int main(){

	int i;
	int n;
	node* H;

	cin >> n;

	H = new node[n];

	for(i = 0;i < n;i++){
		cin >> H[i].key;
		if(i != 0){
			H[i].parent = &H[((i+1)/2)-1];
		}
		if((i+1)*2 <= n){
			H[i].left = &H[((i+1)*2)-1];
		}
		if((i+1)*2+1 <= n){
			H[i].right = &H[(((i+1)*2)+1)-1];
		}
	}

	print(n,H);

	delete[] H;

	return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>
#define MAX 11
int main(void) {
    char s[MAX], ans[MAX];
    int i, j=0, k;
    
    scanf("%s", s);
    
    for(i=0; s[i]!='\0'; i++) {
        if(s[i]=='B') {
            if(j>0)
                j--;
        }else {
            ans[j] = s[i];
            j++;
        }
    }
    
    for(k=0; k<j; k++)
        printf("%c", ans[k]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<array>
#include<cmath>

using namespace std;

int main(){
    int n;
    int max = -1000000001;
    array<array<int,10>,100>f;
    array<array<int,11>,100>p;

    cin>>n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
        cin>>f.at(i).at(j);
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 11; j++){
        cin>>p.at(i).at(j);
        }
    }

    for(int i = 1; i < 1024; i++){
        array<int, 100>c;
        for(int j = 0; j < 100; j++){
            c.at(j) = 0;
        }
        for(int j = 0; j < 10; j++){
            double k = pow(2.0,static_cast<double>(j));
            if(i/static_cast<int>(k)%2 == 1){
                for(int s = 0; s < n; s++){
                    c.at(s) = c.at(s) + f.at(s).at(j);
                }
            }

        }
        int ans = 0;
        for(int j = 0; j < n; j++){
            //cout<<c.at(j)<<std::endl;
            ans = ans + p.at(j).at(c.at(j));
        }
        if(ans > max){
            max = ans;
        }
    }
    cout<<max<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    //freopen("in.txt","r",stdin);
    ll n,m;
    scanf("%lld%lld",&n,&m);
    if(n==1||m==1) printf("1\n");
    else printf("%lld\n",((n+1)/2)*((m+1)/2)+(n/2)*(m/2));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string s;
  cin >> s;
  int q;
  cin >> q;
  string front, behind;
  bool isfront = 0;
  rep(i, q) {
    int t, f;
    char c;
    cin >> t;
    if (t == 1) {
      isfront ^= 1;
    } else {
      cin >> f >> c;
      if (f == 1) {
        if (isfront)
          behind.push_back(c);
        else
          front.push_back(c);
      } else {
        if (isfront)
          front.push_back(c);
        else
          behind.push_back(c);
      }
    }
  }
  if (isfront) {
    reverse(s.begin(), s.end());
    reverse(behind.begin(), behind.end());
    cout << behind + s + front << endl;
  } else {
    reverse(front.begin(), front.end());
    cout << front + s + behind << endl;
  }
  return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    
    if (a < b) cout << "a < b" << endl;
    else if (a > b) cout << "a > b" << endl;
    else cout << "a == b" << endl;
    
    return 0;
    
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 998244353;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n, s;
  cin >> n >> s;
  vl a(n);
  rep(i, n) cin >> a[i];
  mint dp[n + 1][6010] = {};
  rep(i, n + 1) dp[i][0] = 1;
  rep(i, n) rep(j, s + 1) {
    dp[i + 1][j + a[i]] += dp[i][j];
    dp[i + 1][j] += dp[i][j];
  }
  mint ans = 0;
  rep(i, n + 1) ans += dp[i][s];
  cout << ans << endl;
}

Measured memory_bytes: 144572
#include <bits/stdc++.h>
using namespace std;
 
#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;
 
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
 
#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
 
ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
 
ll solve(ll X, ll Y) {
    if (Y == 1) return -1;
    if (X % Y == 0) return -1;
    return X;
}
 
int main() {
    ll X, Y; cin >> X >> Y;
    cout << solve(X, Y) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
 
int main() {
    ll h, w;
    cin >> h >> w;
    
    vector<string> board(h);
    vvl dist(h, vl(w, -1));  // dist[i][j] : (sx, sy)から(i, j)への最短距離(未訪問のとき-1)
    queue<P> Q;
    rep(i, h) {
        cin >> board[i];
        rep(j, w) {
            if(board[i][j] == '#') {
                Q.push(make_pair(i, j));
                dist[i][j] = 0;
            }
        }
    }

    while(!Q.empty()) {
        ll x = Q.front().first;
        ll y = Q.front().second;
        rep(dir, 4) {
            ll nx = x + dx[dir];
            ll ny = y + dy[dir];
            if(nx < 0 || h <= nx || ny < 0 || w <= ny) {
                continue;
            }
            if(board[nx][ny] == '#') {
                continue;
            }
            if(0 <= dist[nx][ny]) {
                continue;
            }
            dist[nx][ny] = dist[x][y] + 1;
            Q.push(make_pair(nx, ny));
        }
        Q.pop();
    }

    ll ans = 0;
    rep(i, h) {
        rep(j, w) {
            chmax(ans, dist[i][j]);
        }
    }
    
    out(ans);
    re0;
}

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

int main() {
  int D,G;
  cin>>D>>G;
  vector<int> p(D),c(D);
  for(int i=0;i<D;i++) cin>>p[i]>>c[i];
  
  int ans=1000;
  for(int i=0;i<(1<<D);i++){
    int x=0,cnt=0,rest_max=-1;
    for(int j=0;j<D;j++){
      if(i>>j&1){
        x+=(j+1)*100*p[j]+c[j];
        cnt+=p[j];
      }
      else rest_max=j;
    }
    if(x<G){
      int s1=100*(rest_max+1);
      int need=(G-x+s1-1)/s1;
      if(need>=p[rest_max]) continue;
         cnt+=need;
         }
         ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n;

vector<int> h,dp;

inline void solve(){

    cin >> n;
    h.resize(n);
    dp.resize(n+2);
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }

    for(int i = 1; i < n; i++) {
        dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        if(i>1)
            chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
        
    }

    cout << dp[n-1] << endl;
    
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 1024
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, S := nextInt(), nextLine()
	ans := 0
	for i := 0; i+3 <= N; i++ {
		if S[i:i+3] == "ABC" {
			ans++
		}
	}
	fmt.Println(ans)
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
function main(input) {
  const formatted_input = input.split('\n')[0].split('');

  var blue_count=0;
  var red_count=0;

  for( var i=0; i<formatted_input.length ; i++ ){
    if(formatted_input[i]=='0'){
      blue_count++;
    }else{
      red_count++;
    }
  }

  diff = Math.max(blue_count, red_count) - Math.min(blue_count, red_count)

  console.log(formatted_input.length - diff)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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


int main(){
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int dp[n];
    for(int i=2;i<n;i++){
        dp[i]= INT_MAX;
    }
    dp[0]=0; dp[1]= abs(h[0]-h[1]);
    
    for(int i=2;i<n;i++){
        int j;
        j= max(0,i-k);
        for(;j<i;j++){
            dp[i] = min(dp[i], dp[j]+ abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int num=0;
  vector<int> a(5);
  for(int i=0;i<5;i++){
    cin >> a.at(i);
    if(a.at(i)==0){
      num=i+1;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

int n;
LL a[1<<20];
pair<int, int> max_id_pair[1<<20];
pair<int, int> max_id_pair2[1<<20];

void init() {

}

void input() {
	cin >> n;
	REP(i, 1<<n) cin >> a[i];
}

void solve() {
	max_id_pair[1] = make_pair(0, 1);
	for(int i = 2; i < 1<<n; i++) {
		set<int> ids;
		ids.insert(i);
		REP(j, n) if(i & (1<<j)) {
			ids.insert(max_id_pair[i-(1<<j)].first);
			ids.insert(max_id_pair[i-(1<<j)].second);
		}
		vector< pair<LL, int> > v;
		for(auto id : ids) v.push_back(make_pair(a[id], id));
		sort(ALL(v));
		reverse(ALL(v));
		max_id_pair[i] = make_pair(v[0].second, v[1].second);
	}

	cout << a[0] + a[1] << endl;
	max_id_pair2[1] = make_pair(0, 1);
	for(int i = 2; i < 1<<n; i++) {
		int id11 = max_id_pair2[i-1].first;
		int id12 = max_id_pair2[i-1].second;
		int id21 = max_id_pair[i].first;
		int id22 = max_id_pair[i].second;
		if (a[id11] + a[id12] > a[id21] + a[id22]) {
			cout << a[id11] + a[id12] << endl;
			max_id_pair2[i] = max_id_pair2[i-1];
		} else {
			cout << a[id21] + a[id22] << endl;
			max_id_pair2[i] = max_id_pair[i];
		}
	}
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
typedef long long ll;
int n,d,A;
struct node
{
    int x,h;
    bool operator<(const node&o)const
    {
        return x<o.x;
    }
}a[N];
queue<pair<int,int> >q;
int main()
{
    scanf("%d%d%d",&n,&d,&A);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a[i].x,&a[i].h);
        a[i].h=a[i].h/A+(a[i].h%A?1:0);
    }
    sort(a+1,a+1+n);
    ll ans=0,res=0;
    d*=2;
    for(int i=1;i<=n;i++)
    {
        while(!q.empty()&&q.front().first<a[i].x-d)
        {
            res-=q.front().second;q.pop();
        }
        if(a[i].h>res)
        {
            q.push({a[i].x,a[i].h-res});
            ans+=a[i].h-res;
            res+=a[i].h-res;
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>

using namespace std;
typedef long long ll;

ll n,x[100010]={0},y[100010]={0};
ll dp[100010][2]={0},visited[100010]={0};
vector<ll>edge[100010];
ll MOD=1e+9+7;

ll cal(int i,int j){
    if(dp[i][j]!=0)return dp[i][j];
    ll res=1;
    visited[i]=1;
    if(j==0){
        for(int k=0;k<edge[i].size();++k){
            if(visited[edge[i][k]]==0)res=res*((cal(edge[i][k],0)+cal(edge[i][k],1))%MOD)%MOD;
        }
    }
    else{
        for(int k=0;k<edge[i].size();++k){
            if(visited[edge[i][k]]==0)res=res*cal(edge[i][k],0)%MOD;
        }
    }
    visited[i]=0;
    return dp[i][j]=res;
}

int main(){
    cin>>n;
    for(int i=0;i<n-1;++i){
        cin>>x[i]>>y[i];
        edge[x[i]].push_back(y[i]);
        edge[y[i]].push_back(x[i]);
    }
    dp[0][0]=1,dp[0][1]=1;

    /*
    for(int i=0;i<4;++i){
        for(int j=0;j<2;++j){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    */

    cout<<(cal(1,0)+cal(1,1))%MOD<<endl;

    return 0;
}

Measured memory_bytes: 16512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    n = I()
    d = LI()
    m = I()
    t = LI()
    c = collections.defaultdict(int)
    for k in d:
        c[k] += 1
    for k in t:
        if c[k] < 1:
            return 'NO'
        c[k] -= 1

    return 'YES'


print(main())




Measured memory_bytes: 43968
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>

using namespace std;


int main() {
	int N, M, C;

	cin >> N >> M >> C;

	vector<int> vec_B(M, 0);
	for (size_t i = 0; i < M; i++) {
		cin >> vec_B[i];
	}

	int ans = 0;
	for (size_t i = 0; i < N; i++) {
		int sum = 0;
		for (size_t j = 0; j < M; j++) {
			int a;
			cin >> a;
			sum += a * vec_B[j];
		}
		sum += C;
		if (sum > 0) {
			ans++;
		}
	}
	cout << ans << endl;
	cin >> N;
	return 0;
}


Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const n = Number(stdin.split('\n')[0])
const [, ..._ab] = stdin.split('\n')
const ab = _ab.map(e => e.split(' ').map(Number))

const ans = () => {
  const sab = ab.sort((a, b) => a[1] - b[1])

  let t = 0
  for (let i = 0; i < n; i++) {
    const [a, b] = sab[i]

    t += a

    if (t > b) {
      return 'No'
    }
  }
  return 'Yes'
}

console.log(ans())


Measured memory_bytes: 78232
#include "bits/stdc++.h"
#define YES "YES"
#define Yes "Yes"
#define NO "NO"
#define No "No"
#define YESNO OUT(three(solve(),YES,NO))
#define YesNo OUT(three(solve(),Yes,No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b-1,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB emplace_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define int long long
#define zero 0LL
#define pb PB
using namespace std;
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef long double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
int dx[] = { 0,1,0,-1,1,1,-1,-1,0 }, dy[] = { 1,0,-1,0,1,-1,1,-1,0 };
const int SIZE1 =  1e6 + 1000;
const int SIZE2 = 1010;
const int SIZE3 = 188;
const int SIZE = SIZE1;
const LL p = 7+1e9;
const LL INF = 1<<20;
const long double EPS = 1e-7;
ut N, M, K, L, H, W, Q, D, T;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
Vpr edges[SIZE];
LL solve() {
	cin >> N >> K ;
	cout << N - K + 1 << endl;
	return 0;
}
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	solve();
	//	cin >> N;
	return 0;
}


Measured memory_bytes: 23680