akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

int main(){
	optimizar_io;
	int N, K;
	cin >> N >> K;
	int sol = 0;
	for (int i = 0; i < N; i++){
		int d;
		cin >> d;
		if (d >= K){
			sol++;
		}
	}
	cout << sol << endl;
	return 0;
}


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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	stack<int> s1;
	stack<pii> s2;

	int sum = 0;
	char ch;

	for (int i = 0; cin >> ch; i++) {
		if (ch == 'e') {
			break;
		}

		switch (ch) {
			case '\\' :
				s1.push(i);
				break;
			case '/' :
				if (s1.empty()) {
					break;
				}

				int j = s1.top(); s1.pop();
				sum += i - j;
				int r = i - j;

				while (!s2.empty() && s2.top().first > j) {
					r += s2.top().second; s2.pop();
				}

				s2.push(make_pair(j, r));
				break;
		}
	}

	vi puddles;
	while (!s2.empty()){
		puddles.push_back(s2.top().second); s2.pop();
	}
	reverse(ALL(puddles));

	cout << sum << endl;

	cout << puddles.size();
	for (int i = 0; i < puddles.size(); i++) {
		cout << " ";
		cout << puddles[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3236
n=gets.to_i
h=gets.chomp.split(" ").map(&:to_i)

ocean_view_count=1

for i in 1..n-1 do
    can_view=1
    for j in 0..i-1 do
        if h[j]>h[i]
            can_view=0
        end
    end
    ocean_view_count+=can_view
end

puts ocean_view_count

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(){
	int n,k;
  	cin >> n>>k;
  	if (k==1||k==0) cout<<0<<endl;
  	if(k>1){
  	if(n>k) cout<<(n-k)<<endl;
  	else cout<<0<<endl;}
  return 0;
}

Measured memory_bytes: 256
import java.math.*;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    int h = sc.nextInt();
    int w = sc.nextInt();
    int k = sc.nextInt();
    char[][] arr = new char[h][w];
    int[][] flag = new int[h][w];
    long cnt = 0;


    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        for (int i=0; i<h; i++) arr[i] = sc.next().toCharArray();

        dfs1("");

        System.out.print(cnt);

    }

    void dfs1(String s) {
        if (s.length() == h) {
//            System.out.println(s);
            dfs2("", s);
        } else {
            for (int i=0; i<2; i++) {
                dfs1(s + i);
            }
        }
    }

    void dfs2(String s, String def) {
        if (s.length() == w) {
//            System.out.println(def);
//            System.out.println(s);

            flag = new int[h][w];

            for (int i=0; i<h; i++) {
                char c = def.charAt(i);
                if (c == '1') {
                    for (int j=0; j<w; j++) {
                        flag[i][j] = 1;
                    }
                }
            }
            for (int i=0; i<w; i++) {
                char c = s.charAt(i);
                if (c == '1') {
                    for (int j=0; j<h; j++) {
                        flag[j][i] = 1;
                    }
                }
            }

            int black = 0;
            for (int i=0; i<h; i++) {
                for (int j=0; j<w; j++) {
                    if (arr[i][j] == '#' && flag[i][j] == 0) {
                        black++;
                    }
                }
            }
            if (black == k) cnt++;

        } else {
            for (int i=0; i<2; i++) {
                dfs2(s + i, def);
            }
        }
    }


}



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

long long func(vector<long long> &A, int cnt) {
  long long res = 0;
  for (int i = 0; i < cnt; i++) res += A.at(i);
  return res;
}

int main() {
  int N, W; cin >> N >> W;
  vector<long long> W1, W2, W3, W4;
  long long w1;
  for (int i = 0; i < N; i++) {
    int w, v; cin >> w >> v;
    if (i == 0) w1 = w;
    if (w == w1) W1.push_back(v);
    if (w == w1 + 1) W2.push_back(v);
    if (w == w1 + 2) W3.push_back(v);
    if (w == w1 + 3) W4.push_back(v);
  }
  sort(W1.begin(), W1.end(), greater<long long>());
  sort(W2.begin(), W2.end(), greater<long long>());
  sort(W3.begin(), W3.end(), greater<long long>());
  sort(W4.begin(), W4.end(), greater<long long>());
  int a = W1.size();
  int b = W2.size();
  int c = W3.size();
  int d = W4.size();
  long long ans = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        for (int l = 0; l <= d; l++) {
          long long weight = w1*i + (w1+1)*j + (w1+2)*k + (w1+3)*l;
          long long tmp = func(W1, i) + func(W2, j) + func(W3, k) + func(W4, l);
          if (weight <= W) ans = max(ans, tmp);
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
ll n;
vector<ll>a;
void input(){
    cin>>n;
    scanv(n,a);
}
void src(){
    cout<<(ll)pow(3,n) - accumulate(ALL(a),1,[](ll sum,ll x){return sum*((x%2==0)? 2:1);});
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

int A[MAX], n;

int partition(int p, int r) {
  int x = A[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if(A[j] <= x) {
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i + 1], A[r]);
  return i + 1;
}

int main() {
  int b;
  cin >> n;
  rep(i, n) cin >> A[i];
  b = partition(0, n - 1);
  rep(i,n) {
    if(i == b) {
      cout << "[" << A[i] << "]";
    } else {
      cout << A[i];
    }
    if(i < n - 1) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3408
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  string S, T;
  ll cnt, ma = 0;
  cin >> S >> T;
  for(ll i = 0; i < S.size() - T.size() + 1; i++) {
    cnt = 0;
    for(ll j = 0; j < T.size(); j++) {
      if(T.at(j) == S.at(i + j)) cnt++;
    }
    if(cnt > ma) ma = cnt;
  }
  cout << T.size() - ma << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int a,b,c,k;
int main()
{
	cin>>a>>b>>c>>k;
	while(a>=b)
	{
		if(k==0)
		{
			cout<<"No";
			return 0;
		}
		k--;
		b*=2;
	}
	while(b>=c)
	{
		if(k==0)
		{
			cout<<"No";
			return 0;
		}
		k--;
		c*=2;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

string a,b,ans;



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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

//-----------------------------------------


int main(){
  string s,t;
  cin >> s >> t;
  cout << t + s << endl;
  return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000;
#define all(v) v.begin(), v.end()

int main(){
  string S,T;
  cin >> S >> T;
  vector<ll> A(26);
  rep(i,S.size()){
    if(A.at(S.at(i)-'a')!=T.at(i)){
      if(A.at(S.at(i)-'a')==0){
        A.at(S.at(i)-'a')=T.at(i);
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
  }
  rep(i,26){
    for(ll j=i+1;j<26;j++){
      if(A.at(i)==A.at(j)&&A.at(i)!=0){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
    
    
}

Measured memory_bytes: 776
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

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

int pa[10][10]={0};
int x,y,s;
char t;
int d=0,wh=0;

void foo(int x,int y){
	if(x>=0&&x<10&&y<10&&y>=0){
		pa[x][y]++;
	}
}


int main(){
	while(cin>>x>>t>>y>>t>>s){
		foo(x,y-1);
		foo(x,y+1);
		foo(x,y);
		foo(x+1,y);
		foo(x-1,y);
		if(s>1){
			foo(x+1,y+1);
			foo(x+1,y-1);
			foo(x-1,y-1);
			foo(x-1,y+1);
		}
		if(s>2){
			foo(x+2,y);
			foo(x-2,y);
			foo(x,y+2);
			foo(x,y-2);
		}
	}
	rep(i,10){
		rep(j,10){
			if(d<pa[i][j]){
				d = pa[i][j];
			}
			if(pa[i][j] ==0){
				wh++;
			}
		}
	}
	cout<<wh<<endl<<d<<endl;
	return 0;
	
}

Measured memory_bytes: 1156
N = input()
a = []
for i in input().split():
    a.append(int(i))

MOD = 1000000007
MOD2 = 2*MOD

buf_a = 0
for x in a:
    buf_a += x
    buf_a %= MOD

buf_b = 0
for x in a:
    buf_a -= x
    buf_b += buf_a * x
    buf_b %= MOD

print(buf_b)


# ans = (buf_a * buf_a) - buf_b
# if ans < 0:
#     ans += MOD2
# ans /= 2
# ans %= MOD
# print(int(ans))




# ll ans = (sum_a * sum_a) - sum_d; // MOD^2*4 ~ -MOD*2
# if (ans < 0) ans += MOD*2; // MOD^2*4 ~ 0
# dump(ans);
# ans /= 2; // MOD^2*2
# ans = fmod(ans , MOD);
# co(ans);
# return 0;

Measured memory_bytes: 95360
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n = I()
s = S()

cc = ""
cnt = 0
for char in s:
    if cc == char:
        continue
    cnt += 1
    cc = char

print(cnt)

Measured memory_bytes: 12452
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
fast;
ll a,b;
cin>>a>>b;
if((a+b)%2==0){
cout<<(a+b)/2<<endl;
}
    else cout<<"IMPOSSIBLE"<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = long long ;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vi dp(100008);
    rep(i,6) dp.at(i) = i;
    for(ll i=6; i< 100008; i++){
        ll j=6;
        ll jres = INF;
        while(i-j>=0){
            jres = dp.at(i-j)+1;
            j*=6;
        }
        ll k=9;
        ll kres = INF;
        while(i-k>=0){
            kres = dp.at(i-k)+1;
            k*=9;
        }
        dp.at(i) = min(jres,kres);
        // cerr << "i:" << i << " dp.at(i):" << dp.at(i) << endl;
    }
    cout << dp.at(n) << endl;
}

Measured memory_bytes: 1024
//2020 1.25 マージソート

#include <stdio.h>
#define MAX 500000
#define INFTY 1000000001

void merge(int *,int ,int ,int );
void mergeSort(int *,int ,int );

int cnt=0;

int main(void)
{
    int n;
    int i;
    int array[MAX];

    scanf("%d",&n);

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

    mergeSort(array,0,n);

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

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

    return 0;
}

void mergeSort(int *array,int left,int right)
{
    int mid;

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

void merge(int *array,int left,int mid,int right)
{
    int n1,n2;
    int i,j,k;
    static int L[MAX/2+2],R[MAX/2+2];   //LとRの配列を保存しておくためにstatic変数を使う

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

    for(i=0;i<n1;i++) L[i] = array[left+i];
    for(i=0;i<n2;i++) R[i] = array[mid+i];
    i=j=0;

    L[n1]=R[n2]=INFTY;          //最大の値を入れる事によって必ず配列に入れた値を比較しマージできる
    for(k=left;k<right;k++)
    {
        cnt++;
        if(L[i]<=R[j])
        {
            array[k]=L[i]; i++;
        }
        else
        {
            array[k]=R[j]; j++;
        }
    }
    return;
}


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

using namespace std;
typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);
  map<string, ll> m;
  for (int i=0; i<n; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    m[s]++;
  }

  ll ans=0;
  for (auto& p: m) {
    ll s = p.second;
    ans += s*(s-1)/2;
  }
  printf("%lld\n", ans);
}


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

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

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

  int N;
  cin >> N;
  vector<int> W(N);
  rep(i, N) { cin >> W[i]; }

  int ans = 100 * 100;

  rep(t, N) {
    int s1 = 0;
    int s2 = 0;
    rep(i, N) {
      if (i <= t) {
        s1 += W[i];
      } else {
        s2 += W[i];
      }
    }
    int tmp = abs(s1 - s2);
    if (tmp < ans) {
      ans = tmp;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = [int(i) for i in input().split()]
t = set({})
for _ in range(m):
    a, b = map(int, input().split())
    if h[a - 1] > h[b - 1]:
        t.add(b)
    elif h[a - 1] < h[b - 1]:
        t.add(a)
    else:
        t.add(a)
        t.add(b)
print(n - len(t))

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

int main(){
    int N;
    cin >> N;
    int a, b, c;
    a = N / 100;
    N -= a * 100;
    b = N / 10;
    c = N - b * 10;
    if ((a == 7) || (b == 7) || (c == 7))
    {
        cout << "Yes" << endl;
    } else
    {
        cout << "No" << endl;
    }
      
    return 0;
}

Measured memory_bytes: 3620
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque, Counter
from sys import exit
import math
import copy
from bisect import bisect_right

import sys
sys.setrecursionlimit(1000000)
import heapq
INF = 10**10

def dijkstra(graph, start, n):
    h = []
    heapq.heappush(h, (0, start))
    costs = [INF for _ in range(n)]
    while h:
     cost, cur = heapq.heappop(h)
     if costs[cur] != INF:
         continue
     costs[cur] = cost
     for edge in graph[cur]:
         ecost, tgt = edge
         if costs[tgt] == INF:
             heapq.heappush(h, (cost + ecost, tgt))

    return costs

def main():
    a, b = getList()
    if b >= 2 * a and b <= 4 * a and b % 2 == 0:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()


Measured memory_bytes: 68192
c = [nil] * 3
3.times{|i| c[i] = gets.chomp.split(' ').map(&:to_i)}

d = [0] * 3
d[0] = c[0][0] + c[1][1] + c[2][2]
d[1] = c[0][1] + c[1][2] + c[2][0]
d[2] = c[0][2] + c[1][0] + c[2][1]

puts (((d[0] == d[1]) and (d[1] == d[2])) ? 'Yes' : 'No')

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
    if you have any question about any part of my code,
    please don't shy to ask anytime :)
*/

void solve()
{
    ll k,n;
    cin>>k>>n;
    unordered_map<ll,ll>h;
    for(int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        h[a]++;
    }

    if(h[k]==0)
    {
        cout<<k<<endl;
        return ;
    }
    for(int i = k-1, j = k+1;;i--, j++)
    {
        if(h[i]==0)
        {
            cout<<i<<endl;
            return;
        }
        
        if(h[j]==0)
        {
            cout<<j<<endl;
            return;
        }
    }
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3652
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//int a[]=new int[N];
		//Ae2+Be2=Ce2
		int N=sc.nextInt();
		p(N*N*N);
		
		
		
		
		
		
		
		}
		
		
	
	
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define ll long long
#define MAXN 100000
#define MODD 1000000007
#define ll long long
using namespace std;

// -1,+2
// +2,-1
// -3,0
// 0,-3

// -x+2y-3z=A
// 2x-y-3w=B


int countsS[2][MAXN+2];
int countsT[2][MAXN+2];

// -1,+2
// +2,-1
// -3,0
// 0,-3
bool Can(int diff0,int diff1) {
    
    int m=(diff0-diff1)%3;
    m=(m+3)%3;
    
    if (m==0)
        return true;
    else
        return false;
    
    
    
}

int main() {
    
    
    
    
    string S,T;
    cin>>S>>T;
    
    
    countsS[0][0]=countsS[1][0]=0;
    countsT[0][0]=countsT[1][0]=0;

    for(int i=0;i<S.size();i++) {
        countsS[0][i]=(i>0?countsS[0][i-1]:0)+(S[i]=='A');
        countsS[1][i]=(i>0?countsS[1][i-1]:0)+(S[i]=='B');
        
        countsT[0][i]=(i>0?countsT[0][i-1]:0)+(T[i]=='A');
        countsT[1][i]=(i>0?countsT[1][i-1]:0)+(T[i]=='B');
    }
    
    
    int Q;
    cin>>Q;
    
    for(int q=1;q<=Q;q++) {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--;
        b--;
        c--;
        d--;
        
        int diff0 = (countsS[0][b]-(a>0?countsS[0][a-1]:0))-(countsT[0][d]-(c>0?countsT[0][c-1]:0));
        int diff1 = (countsS[1][b]-(a>0?countsS[1][a-1]:0))-(countsT[1][d]-(c>0?countsT[1][c-1]:0));


        if (Can(-diff0,-diff1))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
        
        
        
    }
    
    
}

Measured memory_bytes: 2432
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		char[] a = sc.next().toCharArray();
		Arrays.sort(a);
		if((a[0] == a[1])&&(a[1] != a[2])&&(a[2] == a[3])) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int e,y;
	cin>>e>>y;
	int x=44+14+63+28;
	int year;
	int i;
	switch(e){
		case 0:
		year=year-y;
		if(1988<y){
			year=2016;
			year=year-y;
			year=28-year;
			cout<<"H"<<year<<endl;
		}
		else if(1925<y&&y<1989){
			year=1988;
			year=year-y;
			year=63-year;
			cout<<"S"<<year<<endl;
		}
		else if(1911<y&&y<1926){
			year=1925;
			year=year-y;
			year=14-year;
			cout<<"T"<<year<<endl;
		}
		else{
			year=1911;
			year=year-y;
			year=44-year;
			cout<<"M"<<year<<endl;
		}
		break;
		case 1:
		year=1867+y;
		cout<<year<<endl;
		break;
		case 2:
		year=1911+y;
		cout<<year<<endl;
		break;
		case 3:
		year=1925+y;
		cout<<year<<endl;
		break;
		case 4:
		year=1988+y;
		cout<<year<<endl;
		break;
	}
	return 0;
}
	


Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.valueOf(sc.nextLine());
		String input = sc.nextLine();
		sc.close();

		int count = 0;
		String before = "";
		for (String s : input.split("")) {
			if (!s.equals(before)) {
				count++;
				before = s;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 33372
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] val = new int[n];
        int max = 0;
        int cur = 0;
        for(int i = 0; i < n; i++){
            val[i] = Integer.parseInt(sc.next());
            if(i < k){
                cur += val[i];
                max = cur;
            }else{
                cur = cur - val[i - k] + val[i];
                max = Math.max(cur, max);
            }
        }

        System.out.println((max + k) / 2.0);
    }
}


Measured memory_bytes: 59232
import collections
n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
b = [0] * n
b[0] = a[0] %m
for i in range(1,n):
  b[i] = (b[i-1] +a[i]) %m
c = collections.Counter(b)
for i in c.keys():
  a = c[i]
  ans += a*(a-1)/2
ans += c[0]
print(int(ans))

Measured memory_bytes: 16556
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Double Helix
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

char cs[256];

/* subroutines */

/* main */

int main() {
  cs['A'] = 'T';
  cs['T'] = 'A';
  cs['C'] = 'G';
  cs['G'] = 'C';

  int b = getchar();
  putchar(cs[b]); putchar('\n');
  return 0;
}


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

int main(){
	int n, m;
  	cin>>n>>m;
  	
  	int N, M;
  	if(n==0){
    	N=0;
    }else{
    	N=n*(n-1)/2;
    }
  	if(m==0){
    	M=0;
    }else{
    	M=m*(m-1)/2;
    }
  	cout<<N+M<<endl;
  	
  	return 0;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
kind=Hash.new(0)
1.upto(100) do|x|
    1.upto(100) do|y|
        1.upto(100) do|z|
          kind[x**2+y**2+z**2+x*y+y*z+z*x]+=1
        end
    end
end
1.upto(N) do|i|
    puts kind[i]
end

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

class Program
{
    static void Main(string[] args)
    {
        var input = int.Parse(Console.ReadLine());

        var dict = new Dictionary<string, long>();

        for (var i = 0; i < input; i++)
        {
            var str = Console.ReadLine().ToCharArray();
            var strList = new List<string>();
            foreach (var s in str)
            {
                strList.Add(s.ToString());
            }
            strList.Sort(StringComparer.Ordinal);
            var sortedStr = string.Join("", strList);

            if (dict.ContainsKey(sortedStr))
            {
                dict[sortedStr] += 1;
            }
            else
            {
                dict.Add(sortedStr, 1);
            }
        }

        long answer = 0;
        foreach(var str in dict)
        {
            answer += str.Value * (str.Value - 1) / 2; 
        }

        Console.WriteLine(answer);
        Console.ReadLine();
    }
}



Measured memory_bytes: 26776
#include <stdio.h>
#include <stdbool.h>
int main() {
	int n;
	scanf("%d", &n);
	int a[200000]={};
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	int max=0,nextMax=0;
	bool isSomeMax=false;
	for (int i = 0; i < n; i++) {
		if(max<a[i]){
			max=a[i];
			isSomeMax=false;
		}else if(max==a[i]){
			isSomeMax=true;
		}
	}
	for (int i = 0; i < n; i++) {
		if((!isSomeMax)&&(a[i]==max)){
			a[i]=0;
			for (int j = 0; j < n; j++) {
				if(nextMax<a[j])
					nextMax=a[j];
			}
			printf("%d\n", nextMax);
		}else{
			printf("%d\n", max);
		}
	}
	return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n, k;
    cin >> n >> k;

    double ans = 0;
    for (int i = 1; i <= n; ++i) {
        int score = i;
        int x = 0;
        while(score < k){
            ++x;
            score *= 2;
        }
        double p = 1.0 / n * pow(0.5, x);
        ans += p;
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vl v(n);
	REP(i, n)cin >> v[i];
	map<ll, ll> cnt;
	REP(i, n)cnt[v[i]]++;
	sort(ALL(v), greater<>());
	map<ll, ll> used;
	ll ans = 0;
	REP(i, n) {
		if (used[v[i]] > 0) {
			used[v[i]]--;
			continue;
		}
		cnt[v[i]]--;
		for (ll j = 30; j > 0; --j) {
			if ((1 << j) <= v[i])break;
			if (cnt[(1<<j)-v[i]]>0) {
				cnt[(1 << j) - v[i]]--;
				ans++;
				used[(1 << j) - v[i]]++;
				break;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 52736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		// int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");

		int h1 = Integer.parseInt(str[0]);
		int m1 = Integer.parseInt(str[1]);
		int h2 = Integer.parseInt(str[2]);
		int m2 = Integer.parseInt(str[3]);
		int k = Integer.parseInt(str[4]);

		int before = h1 * 60 + m1;
		int after = h2 * 60 + m2;

		System.out.println(after - k - before);
	}
}

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

int main() {
  string s;
  cin >> s;
  int counter = 0;
  if (s[0] == '1') ++ counter;
  if (s[1] == '1') ++ counter;
  if (s[2] == '1') ++counter;
  cout << counter <<endl;
}

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

int main(){

  string s;
  cin >> s;
  int len = s.length();
  //偶数0奇数1                                                                                                                                                                                              
  int gu1 = 0;
  int ki1 = 0;
  int gu2 = 0;
  int ki2 = 0;
  int total1 = 0;
  int total2 = 0;
  for(int i=0;i<len;i++){
    if(i%2==0&&s[i]=='1'){
      gu1++;
    }else if(i%2==1&&s[i]=='0'){
      ki1++;
    }
  }
  total1 = gu1 + ki1;
  //偶数1奇数0                                                                                                                                                                                              
  for(int i=0;i<len;i++){
    if(i%2==0&&s[i]=='0'){
      gu2++;
    }else if(i%2==1&&s[i]=='1'){
      ki2++;
    }
  }
  total2 = gu2 + ki2;
  if(total1>=total2){
    cout << total2 << endl;
  }else{
    cout << total1 << endl;
  }




}



Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b; cin >> a >> b;
	if (b == 1) {
		cout << 0 << endl; return 0;
	}
	int i = 0;
	int now = 0;
	while (true) {
		if (i == 0) {
			now += a;
		}
		else {
			now += a - 1;
		}
		if (now >= b) {
			cout << i + 1 << endl; return 0;
		}
		i++;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int ret = n;

        for (int i=0;i<=n;i++){
            int g1 = i;
            int g2 = n-i;
            int check = 0;
            int a1 = 0;
            int a2 = 0;
            while (g1 > 0){
                int remain = g1%6;
                g1 -= remain;
                a1 += remain;
                g1 = (int) g1/6;
            }

            while (g2 > 0){
                int remain = g2%9;
                g2 -= remain;
                a2 += remain;
                g2 = (int) g2/9;
            }
            check = a1+a2;
            if (check < ret){
                ret = check;
            }
        }
        System.out.println(ret);
    }
    
}

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

using namespace std;

int sumofdigits(int n)
{
	int s = 0;
	while(n > 0) {
		s += n % 10;
		n /= 10;
	}
	return s;
}

int main()
{
	int n;
	int a, b;
	int min = -1;
	
	cin >> n;

	for(a = 1; a < n; a++) {
		b = n - a;
		int sum = sumofdigits(a) + sumofdigits(b);
		if(min == -1 || sum < min) {
			min = sum;
//			cout << a << b << endl;
		}
	}

	cout << min << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,z[100005];
int main()
{
	 cin>>n;
	 z[0]=2;
	 z[1]=1;
	 for (int i=2;i<=n;i++)
	   z[i]=z[i-2]+z[i-1];
	 cout<<z[n];
     return 0;
}

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

int main(){
  int N;
  cin >> N;
  string S;
  cin>>S;
  int a=0,b=0;
  for(int i=0;i<N;i++){
    if(S[i] == 'R'){
      a++;
    }
    else b++;
  }
  if(a >  b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
//10进制转-2进制
void dec2mbin(int a)
{
    if(a)
    {
        int ys = a % (-2);
        a = a / (-2);
        if(ys < 0)
        {
            ys = ys + 2;
            a = a + 1;
        }
        dec2mbin(a);
        cout << ys;
    }
}
 
//10进制转2进制
void dec2bin(int a)
{
    if(a)
    {
        int ys = a % 2;
        a = a / 2;
        dec2bin(a);
        cout << ys;
    }
}
 
int main()
{
    int a;
    cin >> a;
     
    if (a==0)
    {
    	printf("0");
    	return 0;
	}
     
    dec2mbin(a);
    cout << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define PI 3.141592

int main(){
        int N,M;
        scanf("%d %d",&N,&M);

        int a[M];

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

        int totalneed=0;
        for(i=0;i<M;i++){
                totalneed = totalneed + a[i];
        }


        int ans;
        if(totalneed > N){
                printf("-1");
        }
        else{
                ans = N - totalneed;
                printf("%d",ans);
        }


}    

Measured memory_bytes: 1732
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import ceil
from bisect import bisect_right

n, d, a = map(int, readline().split())
xh = [list(map(int, readline().split())) for i in range(n)]
xh.sort()
imos = [0] * (n + 1)
cnt = 0
ans = 0
x = []
for i in range(n):
    xh[i][1] = ceil(xh[i][1] / a)
    x.append(xh[i][0])
for i in range(n):
    cnt += imos[i]
    n_h = xh[i][1] - cnt
    if n_h > 0:
        cnt += n_h
        ans += n_h
        imos[bisect_right(x, x[i] + 2 * d)] -= n_h
print(ans)


Measured memory_bytes: 62124
#include <iostream>
#include <map>
using namespace std;
int N;
map<int, int> m;
int ans;
int main(void) {
	cin >> N;
	for (int n = 0; n < N; ++n) {
		int a; cin >> a;
		++m[a];
	}
	for (auto p : m) {
		if (p.first < p.second) {
			ans += p.second - p.first;
		}
		else if (p.second < p.first) {
			ans += p.second;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
import java.util.Scanner;

//Curling 2.0
public class Main{

	static int w;
	static int h;
	static int[][] m;
	static int gi;
	static int gj;
	static int ans;
	static int[][] move = {{0,1},{0,-1},{1,0},{-1,0}};
	
	static void dfs(int i, int j, int step){
		if(step >= ans)return;
		for(int k=0;k<4;k++){
			int ti = i+move[k][0];
			int tj = j+move[k][1];
			if(0<=ti&&ti<h&&0<=tj&&tj<w&&m[ti][tj]!=1){
				if(ti==gi&&tj==gj){
					ans = step;
					return;
				}
				boolean out = false;
				while(true){
					int ni = ti + move[k][0];
					int nj = tj + move[k][1];
					if(0<=ni&&ni<h&&0<=nj&&nj<w){
						if(ni==gi&&nj==gj){
							ans = step;
							return;
						}
						if(m[ni][nj]==1){
							break;
						}
						ti = ni;
						tj = nj;
					}
					else{
						out = true;
						break;
					}
				}
				if(out)continue;
				int ni = ti + move[k][0];
				int nj = tj + move[k][1];
				m[ni][nj] = 0;
				dfs(ti, tj, step+1);
				m[ni][nj] = 1;
			}
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			w = sc.nextInt();
			h = sc.nextInt();
			if((w|h)==0)break;
			m = new int[h][w];
			int si = 0;
			int sj = 0;
			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					m[i][j]=sc.nextInt();
					if(m[i][j]==2){
						si = i;
						sj = j;
					}
					if(m[i][j]==3){
						gi = i;
						gj = j;
					}
				}
			}
			ans = 11;
			dfs(si, sj, 1);
			System.out.println(ans==11?-1:ans);
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> A(N);
    int mi = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(i>0 && A[i]<=A[i-1]) mi++;
    }
    cout << mi+1 << endl;
    cout << N << endl;
}


Measured memory_bytes: 3368
def solve(X, Y, Z, V, E, A):
    dp = [[0.0] * 6001 for _ in range(Y + 11)]
    dp[0][0] = 1.0
    for i in range(Y):
        for j in range(5001):
            if dp[i][j] <= 0.0:
                continue
            for k in V:
                t = i + k
                if t > Y:
                    dp[Y][j] += dp[i][j]/X
                elif E[t] == 1:
                    dp[min(Y, t+A[t])][j] += dp[i][j]/X
                else:
                    dp[t][max(0, j+A[t])] += dp[i][j]/X

    s = 0
    for i in range(5001):
        if dp[Y][i] <= 0.0:
            continue
        s += i * dp[Y][i]
    print(int(s))

if __name__ == "__main__":
    import sys

    while True:
        X, Y, Z = map(int, input().split())
        if X | Y | Z == 0:
            sys.exit()
        V = list(map(int, input().split()))
        E = [0] * 100
        A = [0] * 100
        for _ in range(Z):
            n, e, a = map(int, input().split())
            E[n] = e
            if e == 3:
                A[n] = -a
            else:
                A[n] = a
        solve(X, Y, Z, V, E, A)

Measured memory_bytes: 11004
# Problem C - Green Bin

from collections import Counter

# input
N = int(input())
s_list = []
for i in range(N):
    s = sorted(input())
    s = "".join(s)
    s_list.append(s)

# initialization
ct = Counter(s_list)
ans = 0

# count
for c in ct.most_common():
    tmp_ct = c[1]
    if tmp_ct==1:
        continue
    ans += tmp_ct * (tmp_ct-1) // 2

# output
print(ans)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    char a, b, c;
    cin >> a >> b >> c;
    if (a == c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char> > s(h,vector<char> (w));
  for(int i = 0;i<h;i++){
    for(int j = 0;j<w;j++){
      cin >> s.at(i).at(j);
    }
  }

  int ans = 0;
  for(int i = 0 ; i<h;i++){
    for(int j = 0 ; j <w;j++){
      if(s.at(i).at(j) == '#'){
        if( j -1 >=0 && s.at(i).at(j-1) == '#'){
        }
        else if( j+1 <=  w-1 && s.at(i).at(j+1) == '#'){
        }
        else if( i-1 >=0  && s.at(i-1).at(j) == '#'){
        }
        else  if( i+1 <=h-1  && s.at(i+1).at(j) == '#'){
        }
        else{
        ans = 1;
        }
      }
    }
  }
  if( ans == 0){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
using huge = long long;

//AtCoder ARC 102 E-Stop.Otherwise...
constexpr int MOD = 998244353;
constexpr int MAX = 4000;
huge cmb[MAX][MAX];  //Combination
huge cmbsum[MAX][MAX] = {0};
int morp[MAX];

//making Combination table
huge CmbInit(){
  cmb[0][0] = 1;
  morp[0] = 1;
  for(int i = 1; i < MAX; i++){
    morp[i] = -1*morp[i-1];
    cmb[i][0] = 1;
    cmb[i][i] = 1;
  }
  for(int i = 2; i < MAX; i++){
    for(int j = 1; j < i; j++){
      cmb[i][j] = (cmb[i-1][j] + cmb[i-1][j-1])%MOD;
    }
  }
}

int main(){
  int K, N;
  cin >> K >> N;
  CmbInit();
  vector<int> twosum(2*K+1, 0);
  vector<huge> ans(2*K+1, 0);

  for(int i = 1; i < K+1; i++){
    for(int j = i; j < K+1; j++){
      twosum[i+j]++;
    }
  }
  for(int i = 0; i < K+1; i++){
    cmbsum[i][i] = 1;
    for(int j = 0; j < i; j++){
      cmbsum[i][j] = (cmb[i][j] + cmbsum[i-1][j])%MOD;
    }
  }
  huge all = cmb[K+N-1][N]%MOD;
  for(int i = 2; i < 2*K+1; i++){
    for(int d = 0; d < twosum[i]; d++){
      //cout << cmbsum[twosum[i]-1][d] << ' ';
      if( N-2*(d+1) >= 0){
        ans[i] += MOD + morp[d]*cmbsum[twosum[i]-1][d]%MOD
                *cmb[K+N-2*(d+1)-1][K-1]%MOD;
        if( ans[i] >= MOD )
          ans[i] %= MOD;
      }
    }
    ans[i] = MOD + (all - ans[i])%MOD;
    cout << ans[i]%MOD << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 187136