akhauriyash/Code-Regression huggingface dataset:
import sys
L="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
A=" ',-.?"+L
B="101 000000 000011 10010001 010001 000001 100101 10011010 "\
  "0101 0001 110 01001 10011011 010000 0111 10011000 "\
  "0110 00100 10011001 10011110 00101 111 10011111 1000 "\
  "00110 00111 10011100 10011101 000010 10010010 10010011 10010000".split()
C=L+" .,-'?"
for s in sys.stdin:
  x=""
  for c in s[:-1]:x+=B[A.index(c)]
  x+="0"*(-len(x)%5)
  s=""
  for i in range(0,len(x),5):s+=C[int(x[i:i+5],2)]
  print s

Measured memory_bytes: 4228
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string s;
	cin >> s;

	ll N = s.size();

	string dummy = "";
	for (int ii = 0; ii < N; ++ii){
		if (ii < N - 1){
			if ( (s[ii] == 'B') && (s[ii+1] == 'C') ){
				dummy += 'D';
				++ii;
			} else {
				dummy += s[ii];
			}
		} else {
			dummy += s[ii];
		}
	}

	ll ans = 0;
	ll acnt = 0;
	for (int ii = 0; ii < dummy.size(); ++ii){
		if (dummy[ii] == 'A'){
			acnt++;
		} else if (dummy[ii] == 'D') {
			ans += acnt;
		} else {
			acnt = 0;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 900
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

void merge(int arr[], int l, int m, int r) {
    int i, j, k;
    int n1 = m - l + 1;
    int n2 = r - m;
    int L[n1];
    int R[n2];
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1 + j];
    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2) {
        if (L[i] <= R[j]) {
            arr[k] = L[i];
            i++;
        } else {
            arr[k] = R[j];
            j++;
        }
        k++;
    }
    while (i < n1) {
        arr[k] = L[i];
        i++;
        k++;
    }
    while (j < n2) {
        arr[k] = R[j];
        j++;
        k++;
    }
}
void mergeSort(int array[], int l, int r) {
    if (l < r) {
        int m = l + (r - l) / 2;
        mergeSort(array, l, m);
        mergeSort(array, m + 1, r);
        merge(array, l, m, r);
    }
}
int main(void){
    int N, K;
    long sum;
    cin >> N >> K;
    int H[N];
    sum = 0;
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }
    if(K >= N){
        cout << 0 << endl;
    }else{
        mergeSort(H, 0, N-1);
        sum = 0;
        for(int i = 0; i < N-K; i++){
            sum += H[i];
        }
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;
const int N = 2e5 + 10;


int n , x , y;
int c[N] , w[N] , colormin[N] , smallest , secondsmallest;

int par[N] , sz[N] , inv[N];
map<int,int> exi[N];
int find(int x){
	if (par[x] != x){
		return par[x] = find(par[x]);
	}
	return par[x];
}

void merge(int x,int y){
//	printf("[%d %d]\n",x,y);
	x = find(x) , y = find(y);
	if (x ^ y){
		par[x] = y;
	}
}
int main(){
	
	scanf("%d%d%d",&n,&x,&y);
	for (int i = 1;i <= n;i++){
		scanf("%d%d" , c + i , w + i);
		par[i] = i;
		
		if (!colormin[c[i]] || w[colormin[c[i]]] > w[i]) colormin[c[i]] = i;
		if (!smallest || w[smallest] > w[i]){
			smallest = i;
		}
	}
	for (int i = 1;i <= n;i++){
		if (c[i] == c[smallest]) continue;
		if (!secondsmallest || w[secondsmallest] > w[i]){
			secondsmallest = i;
		}
	}
	
//	printf("[%d %d] (%d %d)\n",smallest,secondsmallest,colormin[c[smallest]],colormin[c[secondsmallest]]);
	
	inv[1] = 1;for (int i = 2;i <= n;i++) inv[i] = 1ll * (mod - (mod / i)) * inv[mod % i] % mod;
	
	for (int i = 1;i <= n;i++){
		if (w[i] + w[colormin[c[i]]] <= x) merge(i , colormin[c[i]]);
		
		if (smallest)
		if (c[i] != c[smallest] && w[i] + w[smallest] <= y){
			merge(i , smallest);
		}
		
		if (secondsmallest)	
		if (c[i] != c[secondsmallest] && w[i] + w[secondsmallest] <= y){
			merge(i , secondsmallest);
		}	
		
	}
	int res = 1;
	for (int i = 1;i <= n;i++){
		res = 1ll * res * (++sz[find(i)]) % mod;
		res = 1ll * res * inv[++exi[find(i)][c[i]]] % mod;
		
//		printf("[%d %d]\n",sz[find(i)] , exi[find(i)][c[i]]);
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 23680
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[min(a, b)].push_back(max(a, b));
  }
  set<int> ids;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (ids.find(i) != ids.end()) {
      ans++;
      ids.clear();
    }
    for (int j = 0; j < to[i].size(); j++)
      ids.insert(to[i][j]);
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))
#define FILL1(x) memset(x,-1,sizeof(x))

using namespace std;

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

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

struct edge {int from, to;};

vector<int> G[200010];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int N, M;
    cin >> N >> M;

    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    bool used[N];
    FILL0(used);

    queue<int> q;
    q.push(0);

    int prev[N];

    FILL1(prev);

    while(!q.empty())
    {
        int p = q.front();
        q.pop();

        rep(i, G[p].size())
        {
            if(!used[G[p][i]])
            {
                q.push(G[p][i]);
                used[G[p][i]]=true;
                prev[G[p][i]]=p;
            }
        }
    }

    rep(i, N)
    {
        if(prev[i]==-1)
        {
            cout <<"No" << endl;
            return 0;
        }
    }   
    
    cout << "Yes" << endl;

    rep(i, N)
    {
        if(i!=0)
        cout << prev[i]+1 << endl;
    }
 

    return 0;
}



Measured memory_bytes: 13004
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N =  200010;  
const int mod = 1e9 + 7;
#define FI first
#define SE second
typedef pair<int, int>pii;

int num[N];
int out[N];
int main()  
{  
  //freopen("in.txt","r",stdin);
   int n;
   while (cin >> n)
   {
   	for (int i = 1; i <= n; i++)
   		cin >> num[i];
   	int start;
   	if (n&1)
   		start = 1 + ((n - 1)>>1);
   	else
   		start = (n>>1) + 1;
   	int c = 2;
   	int diff = 1;
   	out[start] = num[1];
// printf("start:%d\n", start);
   	while (c <= n)
   	{
   		if (n&1)
   		{
			out[start + diff] = num[c++];
			if (c <= n)
	   			out[start - diff] = num[c++];
   		}else
   		{
   			// printf("%d %d\n", start - diff, start + diff);
	   		out[start - diff] = num[c++];
	   		if (c <= n)
	   			out[start + diff] = num[c++];
   		}
   		diff++;
   	}
   	for (int i = 1; i <= n; i++)
   		printf("%d%c", out[i], i == n?'\n':' ');
   }
   return 0;  
}  

Measured memory_bytes: 3712
#include<cstdio>
int a[200005],b[200005];
int main() {
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=m;++i)
    {
        int beg,ends;
        scanf("%d %d",&beg,&ends);
        if(beg==1)	a[ends]=1;
        if(ends==n)	b[beg]=1;
    }
    for(int i=1;i<=m;++i)	if(a[i] && b[i])	return 0*printf("POSSIBLE");
    printf("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cmath>

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	int i = floor((a + b)*0.5);
	double j = (a + b)*0.5-i;

	if (j > 0)
		i += 1;

	cout << i << endl;
}

Measured memory_bytes: 256
/* ***********************************************
Author        :guanjun
Created Time  :2016/10/14 15:29:26
File Name     :1.cpp
************************************************ */
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 100010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
	int x,y;
};
struct cmp{
    bool operator()(Node a,Node b){
        if(a.x==b.x) return a.y> b.y;
        return a.x>b.x;
	}
};

bool cmp(int a,int b){
    return a>b;
}
int a[maxn];
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    #endif
    //freopen("out.txt","w",stdout);
	int n;
	while(cin>>n){
		for(int i=1;i<=n;i++){
			cin>>a[i];
		}
		int p=1;
		ll ans=0;
		ans+=a[1]-1;
		p++;
		for(int i=2;i<=n;i++){
			if(a[i]==p){
				p++;continue;
			}
			ans+=(a[i]-1)/p;
		}
		cout<<ans<<endl;
	}
    return 0;
}


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

int main(){
  int n;cin >> n;
  vector<int> a(n);
  vector<int> ans(n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  int ball=0;
  for(int i=n; 0<i; i--){
    if(0==a.at(i-1)){
      int total = 0;
      for(int j=i*2; j<=n; j +=i){
        if(ans.at(j-1)==1)total++;
      }
      if(total%2==0){ans.at(i-1)=0;}
      else {ans.at(i-1)=1;ball++;}
    }else{
      //cout << i << endl;
      int total = 0;
      for(int j=i*2; j<=n; j += i){
        //cout << " " << j << endl;
        if(ans.at(j-1)==1)total++;
      }
      if(total%2==0){ans.at(i-1)=1;ball++;}
      else ans.at(i-1)=0;
    }
  }
  if(ball==0){cout << 0 << endl;}
  else{
    cout << ball << endl;
    for(int i=0; i<n; i++){
      if(ans.at(i)==1)cout << i+1 << ' ';
    }
	cout << endl;  
  }
}

Measured memory_bytes: 2432
#include <iostream>

using namespace std;

int main()
{
    int point[105];
    int n;
    int sum=0;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>point[i];
    for(int i=0; i<n; i++)
    {
        if(point[i]==0)
            continue;
        for(int j=i+1 ; j<n; j++)
        {
            sum+=point[i]*point[j];
        }
    }
    cout<<sum;
    return 0;
}




Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    int sum=0;
    for(int i=1; i<=n; ++i){
        for(int j=1; j<=n; ++j){
            for(int k=1; k<=n; ++k){
                sum+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3632
N, M = gets.split(' ').map(&:to_i)
cakes = []
N.times do
  cakes.push(gets.split(' ').map(&:to_i))
end

cand = []
[1, -1].repeated_permutation(3) do |sign|
  ncakes = cakes.collect{|x, y, z| x * sign[0] + y * sign[1] + z * sign[2]}
  ncakes.sort!
  ncakes.reverse!
  cand.push(ncakes[0..(M - 1)].inject(:+))
end

if M >= 1
  puts cand.max
else
  puts 0
end

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

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var n = int.Parse(list[0]);
        var k = int.Parse(list[1]);
        var s = Console.ReadLine();

        var ans = new char[n];
        for (int i = 0; i < ans.Length; ++i)
        {
            var c = s[i];
            if (i == k - 1)
            {
                switch (c)
                {
                    case 'A':
                        c = 'a';
                        break;
                    case 'B':
                        c = 'b';
                        break;
                    case 'C':
                        c = 'c';
                        break;
                }
            }
            ans[i] = c;
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include<queue>
#include<unordered_map>
#include<cmath>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
#define ll long long int
#define pi (double)3.14159265359
#define vect vector <int>
#define pb push_back
using namespace std;

void solve() {
	int x, y;
	cin >> x >> y;
	int t = (y - (2 * x));

	if (t % 2 == 0 && t>=0) {
		if (t / 2 <= x)
			cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else cout <<"No";
}
int main(){
	solve();
	return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {

   public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       
       while(true){
           int n = sc.nextInt();
           int m = sc.nextInt();
       
           if(n== 0 && m == 0){
               break;
           }
           
           int []taro = new int[n];
           int []hanako = new int[m];
           int sumT = 0;
           int sumH = 0;
           for(int i = 0;i < n;i++){
              taro[i] += sc.nextInt();
              sumT += taro[i];
           }
           for(int i = 0;i < m;i++){
               hanako[i] = sc.nextInt();
               sumH += hanako[i];
           }
           
           int minSumI = -1;
           int minSumJ = -1;
           int minSum = Integer.MAX_VALUE;
           
           for(int i = 0;i < n;i++){
               for(int j =0;j < m;j++){
                    if(sumT - taro[i] + hanako[j] == sumH - hanako[j] + taro[i] && taro[i] + hanako[j] < minSum){
                       minSum = taro[i] + hanako[j];
                       minSumI = i;
                       minSumJ = j;
                    }                  
               }               
           }
           
           if(minSumI >= 0 && minSumJ >= 0){
               System.out.println(taro[minSumI] + " " + hanako[minSumJ]);
           }else{
               System.out.println(-1);
           }           
           
       }
   }

}
        

Measured memory_bytes: 29728
#include <stdio.h>
#include <math.h>

int main(void) {
	int n, d, ans = 0;
	int x[10][20];

	scanf("%d %d", &n, &d);

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

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < i; ++j) {
			int memo = 0;
			for (int k = 0; k < d; ++k) {
				memo += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			if (sqrt(memo) - (int)sqrt(memo) == 0) {
				++ans;
			}

		}
	}
	printf("%d", ans);


	return 0;
}

Measured memory_bytes: 128
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  ll n,m,x[100010],dist[100010];
  std::cin >> n >> m;
  for(int i=0; i<m; i++) std::cin >> x[i];

  if(n>=m){
     std::cout << "0" << '\n';
     return 0;
   }

   sort(x,x+m);
   for(int i=0; i<m-1; i++){
     dist[i]=abs(x[i]-x[i+1]);
   }

   ll ans=0;
   sort(dist,dist+m-1);
   for(int i=0; i<m-n; i++)ans+=dist[i];

   std::cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 1792
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let l: usize = iter.next().unwrap().parse().unwrap();
    let r: usize = iter.next().unwrap().parse().unwrap();

    let mod_n = 2019usize;

    let mut ans = 0usize;
    if r - l < mod_n {
        let l_mod = l%mod_n;
        let r_mod = r%mod_n;
        if l_mod < r_mod {
            ans = mod_n + 1;
            for i in l_mod..r_mod {
                for j in i+1..(r_mod+1) {
                    ans = std::cmp::min(ans, (i * j) % mod_n);
                }
            }
        }
    }

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

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

const int gray = 399, brown = 799, green = 1199, lb = 1599, blue = 1999, yell = 2399, dai = 2799, red = 3199;
int n, col[9] = {};

int getmax()
{
  int max = 0;
  for (int i = 0; i < 8; i++) {
    if (col[i]) max++;
  }
  max += col[8];
  return max;
}

int getmin()
{
  int min = 0;
  for (int i = 0; i < 8; i++) {
    if (col[i]) min++;
  }
  if (col[8] && !min) min = 1;
  return min;
}

int getCol(int a)
{
  int r = 0;
  if (a > gray)  r++;
  if (a > brown) r++;
  if (a > green) r++;
  if (a > lb)    r++;
  if (a > blue)  r++;
  if (a > yell)  r++;
  if (a > dai)   r++;
  if (a > red)   r++;
  return r;
}

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    col[getCol(a)]++;
  }
  cout << getmin() << " " << getmax() << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
// ll intpoint(ll x1, ll y1, ll x2, ll y2) { return ( __gcd(abs(x1-x2),abs(y1-y2))+1); }
// bool isvalid(ll x,ll y,ll n,ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int pp = uniform_int_distribution<int>(0, kk-1)(rng);
// ---------------------///////////////---------------------------------
// ---------------------///////////////----------------------------------
// -------------/////////////////---------------------------------///////

vector<ll>v[27];

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

    string s,t;

    cin>>s>>t;

    for(ll i=0;i<s.size();i++){
    	v[s[i]-'a'].push_back(i+1);
    }

    for(ll i=0;i<t.size();i++){

    	if(v[t[i]-'a'].size()){
    		continue;
    	}else{
    		cout<<"-1";
    		return 0;
    	}
    }

    ll ans = 0;
    ll n = t.size();
    ll ap[n+11];
    ll m = s.size();

    ap[0] = v[t[0]-'a'][0];
    ll cnt = 1;

    for(ll i=1;i<n;i++){
    	if(t[i]!=t[i-1]){
    		ll siz = v[t[i]-'a'].size();
    		ll val = t[i]-'a';
    		if(ap[i-1]<v[t[i]-'a'][siz-1]){
    			ap[i] = (*upper_bound(v[val].begin(),v[val].end(),ap[i-1]));

    		}else{
    			ap[i] = v[t[i]-'a'][0];
    		}
    		cnt = 1;
    	}else{

    		ll siz = v[t[i]-'a'].size();
    		ll val = t[i]-'a';
    		// cout<<
    		if(ap[i-1] < v[val][siz-1]){
    			ap[i] = (*upper_bound(v[val].begin(),v[val].end(),ap[i-1]));
    			// continue;
    		}else{
    			ap[i] = v[t[i]-'a'][0];
    			cnt = 1;	
    		}

    		// if(v[t[i]-'a'].size()>cnt){
    		// 	ap[i] = v[t[i]-'a'][cnt];
    		// 	cnt++;
    		// }else{
    		// 	ap[i] = v[t[i]-'a'][0];
    		// 	cnt = 1;
    		// }
    	}
    	// cout<<ap[i]<<" ";
    }

    for(ll i=0;i<n;i++){
    	if(i+1<n){
    		if(ap[i+1]>ap[i]){
    			continue;
    		}else{
    			ans += m;
    		}
    	}
    }

    ans = ans + ap[n-1];

    cout<<ans;

	return 0;
	
}

Measured memory_bytes: 2256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string A;
  cin >> A;
  if ("a" <= A && A <= "z")
    cout << 'a' << endl;
  else
    cout << "A" << endl;
  return 0;
}

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

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

int main(){
	ll N,D,A;
	cin >> N >> D >> A;
	vector<P> E(N);
	rep(i,N){ int x,h; cin >> x >> h; E[i]=P(x,h); }
	sort(E.begin(),E.end());

	ll cnt = 0;
	int num = 0;
	ll range = D*2;
	ll dam = 0;
	queue<pair<ll,ll>> q;
	while(num < N){
		int loc = E[num].first;
		int hp = E[num].second;
		
		while(q.size() &&  q.front().first < loc){
			dam -= q.front().second;
			q.pop();
		}
		hp -= dam;
		if(hp>0){
			ll c = (hp+A-1)/A;
			cnt += c;
			ll damage = c * A;
			dam += damage;
			q.emplace(loc+range, damage);
		}
		num++;
	}

	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3456
/*"永遠の物語"*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double D;
typedef pair<int,int> Pii;
#define mp(a,b) make_pair(a,b)
#define fir first
#define sec second
inline int min(int _a,int _b){return _a<_b?_a:_b;}
inline int max(int _a,int _b){return _a>_b?_a:_b;}
template<class _T>inline void rd(_T &_a){int _f=0,_ch=getchar();_a=0;while(_ch<'0' || _ch>'9'){if(_ch=='-')_f=1;_ch=getchar();}while(_ch>='0' && _ch<='9')_a=(_a<<1)+(_a<<3)+_ch-'0',_ch=getchar();if(_f)_a=-_a;}
const int inf=0x3f3f3f3f;
const D eps=1e-8;
int main(){
	//clock_t start=clock();
	//freopen("test.in","r",stdin);
	//freopen("test.out","w",stdout);
	int n,a,b;rd(n);rd(a);rd(b);
	printf("%s",(b-a)&1?"Borys":"Alice");
	//printf("\n%dms",(int)((double)(clock()-start)/CLOCKS_PER_SEC*1000));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,d,count=0;
bool flag = false;
cin >> n >> d;
vector< vector<int> > v(n,vector<int>(d,0));
for(int i=0;i<n;i++){
  for(int j=0;j<d;j++){
    cin >> v[i][j];
  }
}

for(int i=0;i<n;i++){
  for(int k=i+1;k<n;k++){
    int kyori = 0;
    flag = false;
    for(int j=0;j<d;j++){
      kyori += (int)(pow(v[k][j]-v[i][j],2));
    }
    if(kyori == 1) flag = true; 
    for(int num=1;num<kyori;num++){
     if(num*num == kyori || (num == 1 && kyori == 1)){
        flag = true;
        break;
      }
    } 
    if(flag) count++;
  }
}  
cout << count << endl;
}


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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var tx = Console.ReadLine().Split(' ').Select(q => long.Parse(q)).ToArray();

            var result = 0.0;

            result = tx[0] / (double)tx[1];

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

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

	vector<int> bunbo(n);
	rep(i,n) {
		int count = 0;
		int point = i+1;
		while( point < k ) {
			point *= 2;
			count++;
		}
		bunbo[i] =  n * pow(2,count);
	}

	int sumBunbo = 0;
	rep(i,n) {
		sumBunbo += bunbo[0] / bunbo[i];
	}

	cout << setprecision(10) << double (sumBunbo) / bunbo[0] << endl; 
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)

using namespace std;

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
	int ans = 1;
	ff(i, 0, n-1) {
		if (s[i] != s[i + 1]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int a;
  int b;
  int c;
  int d;
  cin >>a>>b>>c>>d;
  if((abs(a-c)<=d) ||((abs(a-b)<=d && abs(b-c) <=d))) {
    cout << "Yes" << endl;
  }
else {
cout << "No" << endl;
}
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n,maxn=-2e9,minn=2e9,a;
	scanf("%d",&n);
	while (n--)
	{
		scanf("%d",&a);
		maxn=max(a,maxn);
		minn=min(a,minn);
	}
	printf("%d",maxn-minn);
	return 0;
}

Measured memory_bytes: 128
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().decode('utf8').rstrip()
flag1 = True
flag2 = True
Sodd = S[::2]
Seven = S[1::2]

if Sodd.count('L') != 0:
    flag1 = False
if Seven.count('R') != 0:
    flag2 = False

print('Yes' if flag1 and flag2 else 'No')


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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int sum1=0,sum2=0;
  for(int i=0;i<n;i++){
    if(s[i]=='a'){
      if(sum1<a+b){
        cout << "Yes" << endl;
        sum1++;
      } else{
        cout << "No" << endl;
      }
    }else if(s[i]=='b'){
      if(sum1 <a+b && sum2 <b){
        cout << "Yes" << endl;
        sum1++;
        sum2++;
      }else{
        cout << "No" << endl;
      }
    }else if(s[i]=='c'){
      cout << "No" << endl;
    }
  }
}

/*
10 2 3
abccabaabb

Yes
Yes
No
No
Yes
Yes
Yes
No
No
No
*/

Measured memory_bytes: 896
while True:
    try:
        m,f,r = map(int,input().split(" "))
        if m == -1:
            if f == -1:
                if r == -1:
                    break
        if m == -1 or f == -1:
            print("F")
            continue
        if m+f >= 80:
            print("A")
        if m+f >= 65 and m+f < 80:
            print("B")
        if m+f >= 50 and m+f < 65:
            print("C")
        if m+f >= 30 and m+f < 50:
            if r >= 50:
                print("C")
            else:
                print("D")
        if m+f < 30:
            print("F")
    except EOFError:
        break

Measured memory_bytes: 7688
n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

score = []

# 数列Aの全探索

import copy
def dfs(A):
    if len(A) == n+1:
        # score計算
        tmp = 0
        #print(A)
        for i in range(q):
            if A[b[i]] - A[a[i]] == c[i]:
                 tmp += d[i]
        score.append(tmp)
        return
    else:
        tmp = A[-1]
        arr = copy.copy(A)
        arr.append(tmp)
        while(arr[-1] <= m):
            dfs(arr)
            arr[-1] += 1  
dfs([1])

print(max(score))


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

#define int long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int N = 2002;

int n , dp[N][N];
pair<int , int> arr[2002];

int ans(int idx , int start , int end) {
    if(end < start) return 0;
    int& get = dp[idx][start];
    if(get != -1) return dp[idx][start];
    get = max((arr[idx].first * abs(arr[idx].second - start)) + ans(idx + 1 , start + 1 , end) , (arr[idx].first * abs(arr[idx].second - end)) + ans(idx + 1 , start , end - 1));
    return get;
}
void solve() {
    memset(dp , -1 , sizeof dp);
    cin >> n;
    for(int i = 0 ; i < n ; i ++) cin >> arr[i].first , arr[i].second = i;
    sort(arr , arr + n);
    reverse(arr , arr + n);
    int q = ans(0 , 0 , n - 1);
    cout << q;
}

/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase ;
    
    while(testcase --) {
        solve();
        cout << '\n';
    }
    
    return 0;
}
 



Measured memory_bytes: 35132
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int N = s.length();
		if (s.charAt(0) == s.charAt(N-1)) {
			if (N%2 == 0) System.out.println("First");
			else System.out.println("Second");
		} else {
			if (N%2 == 0) System.out.println("Second");
			else System.out.println("First");
		}
	}
}

Measured memory_bytes: 24704
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" "<<x<<"\n";
#define lli long long int
long long int mod= 1000000007,modd=998244353;
long long int t;
int32_t main()
{
   string s;
   cin>>s;
   cout<<s.substr(0,3)<<"\n";
   return 0;
}//main


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main(){
    int n; //n:スイッチの個数
    int m; //m:電球の個数

    cin >> n >> m;
    int ans = 0;

    vector<vector<int>> data(m);

    for(int i = 0; i < m; i++){
        int k; cin >> k;
        for(int j = 0; j < k; j++){
            int a; cin >> a; a--;
            data[i].push_back(a);
        }
    }

    vector<int>check(m);
    for(int i = 0; i < m; i++){
        cin >> check[i];
    }

    for(int i = 0; i < (1 << n); i++){
        bool flag = true;
        bitset<10> bs(i);
        
        for(int j = 0; j < m; j++){ //電球をそれぞれ見ていく！
            int on = 0;

            for(int l = 0; l < n; l++){
                if(((i >> l) & 1) == 1 && vector_finder(data[j],n-l-1) == 1){
                    on++;
                    
                }
            }
            if(flag){
                if(!(on % 2 == check[j]))flag = false;
            }
       }
       if(flag)ans++;
    }

    cout << ans << endl;

}


Measured memory_bytes: 3644
import java.util.*;

public class Main
{

public static void main ( String[] args){

Scanner str = new Scanner( System.in);

int a = str.nextInt();

int b = str.nextInt();

if(a<b){

System.out.println("a < b");

}

else if (a>b){

System.out.println("a > b");

}

else{

System.out.println("a == b");

}

}

}



Measured memory_bytes: 26268
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        HashSet<char> s = new HashSet<char> { };
        string yukio = "yuiophjklnm";
        for (int i = 0; i < yukio.Length; i++)
        {
            s.Add(yukio[i]);
        }
        while (true)
        {
            string a = Console.ReadLine();
            if (a == "#") { break; }
            int ans = 0;
            for (int i = 1; i < a.Length; i++)
            {
                bool o = false;
                if (s.Add(a[i])) { o = true;s.Remove(a[i]); }
                bool o1 = false;
                if (s.Add(a[i - 1])) { o1 = true;s.Remove(a[i-1]); }
                if (o != o1)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
        Console.ReadLine();
    }
}

Measured memory_bytes: 9940
//AtCoder Beginner Contest 044 B問題
#include <bits/stdc++.h>
using namespace std;

int main(){
	char w[105];
	for(int i=0; i<105; i++)w[i] = 0;
	scanf("%s", w);
	int sum[30];
	for(int i=0; i<30; i++) sum[i] = 0;
	int tf = 0;
	for(int i=0; i<105; i++) {
		sum[int(w[i])-97]++;
	}
	for(int j=0; j<30; j++) {
		if(sum[j]%2 == 1){
			tf++;
		}
	}
	if(tf == 0) {
		printf("Yes\n");
	}
	else printf("No\n");
	//for(int j=0; j<30; j++) {
		//printf("%d\n", sum[j]);
	//}
	//printf("%d\n", w[0]);
}

Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayDeque;
import java.util.Queue;
import java.math.RoundingMode;
import java.math.BigDecimal;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long sum = 0;
		for(long i = 1; i <= n; i++) {
			if(i%3!=0&&i%5!=0) {
				sum+=i;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 35796
import bisect

S = input()

N = len(S)
if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
elif N < 26:
    t = [False] * 26
    for i in range(N):
        t[ord(S[i]) - 97] = True
    print(S + chr(t.index(False) + 97))
else:
    t = [S[-1]]
    for i in range(N - 2, -1, -1):
        if S[i] < S[i + 1]:
            break
        bisect.insort_left(t, S[i])
    print(S[:i] + t[bisect.bisect_left(t, S[i])])


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

const int mod = 1e9 + 7;
int f[2005][2005];

int main()
{
	int N;
	scanf("%d",&N);
	
	ll ans = 0;
	f[0][0] = 1;
	int B = N / 3;
	for(int i = 1;i <= B;++i)
		for(int j = 3;j <= N;++j)
		{
			f[i][j] = (f[i][j-1] + f[i-1][j-3]) % mod;
			if(j == N) ans = (ans + f[i][j]) % mod;
		}	
	return printf("%lld",ans),0;
}

Measured memory_bytes: 8832
// https://atcoder.jp/contests/abc068/tasks/arc079_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, M, a, b;
vector<bool> s, g;
string r;

int main()
{
  cin >> N >> M;

  REP(i, N)
  {
    s.push_back(false);
    g.push_back(false);
  }

  REP(i, M)
  {
    cin >> a >> b;
    if (a == 1)
      s[b - 1] = true;
    if (b == N)
      g[a - 1] = true;
  }

  r = "IMPOSSIBLE";
  REP(i, N)
  {
    if (s[i] == true && g[i] == true)
    {
      r = "POSSIBLE";
      break;
    }
  }

  cout << r << '\n';

  return 0;
}


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

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

	for(int sum; cin >> sum, sum;) {
		for(int i = 0; i < 9; ++i) {
			int price;
			cin >> price;
			sum -= price;
		}
		
		cout << sum << endl;
	}

	return EXIT_SUCCESS;
}

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

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        int N = readInt();
        int[] l = new int[N];
        for (int i = 0; i < N; i++) {
            l[i] = readInt();
        }
        Arrays.sort(l);

        int res = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                for (int k = j + 1; k < N; k++) {
                    if (l[i] < l[j] && l[j] < l[k] && l[i] + l[j] > l[k]) res++;
                }
            }
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 32740
def ok(p,w,k):
    track= 1
    weight= 0
    flag= True
    for i in w:
        if i > p:
            flag=False
            break
        elif weight+ i> p:
            weight= i
            track+= 1
        else:
            weight+= i
    if track<=k and flag:
        return True
    else:
        return False
            

n,k= map(int, input().split())
w=[]
for i in range(n):
    w.append(int(input()))
    
l=0
h=10**11
while l+1 < h:
    p= (l+h)//2
    if ok(p,w,k):
        h= p
    else:
        l= p
print(h)
    


Measured memory_bytes: 9556
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define pb push_back
#define pp(a, b) pair <a, b>
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define itr iterator
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
 
 
using namespace __gnu_pbds;
using namespace std;
 
template <class T> T printr(T p){ cout << p << '\n'; return 0; }
template <class T> T printe(T p){ cout << p << '\n'; exit(0); }
template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
 
 
//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set;  

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif
 
ll power(ll x, ll y, ll p){ 
   ll res = 1;
   x = x % p;  
   while (y > 0) {
      if (y & 1) 
         res = (res * x) % p; 
      y = y >> 1;
      x = (x * x) % p; 
   }
   return res;
}

const ll INF = (ll)(8e18);
const ll MOD = 1e9 + 7;
const ll HMOD = (ll)4222234727;
const ll hashprime = (ll)31;
 
const int maxn = 205;

int t[maxn];
string s[maxn];

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int n; cin >> n;
    for(int i = 1; i <= n; i++) cin >> s[i] >> t[i];
    string x; cin >> x;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(s[i] == x){
            for(int j = i + 1; j <= n; j++){
                ans += t[j];
            }
            break;
        }
    }
    cout << ans << '\n';
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}

Measured memory_bytes: 256
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

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

#処理内容
def main():
	A, B, C, K = getlist()
	if K < A:
		print(K)
	elif A + B >= K:
		print(A)
	else:
		print(2 * A + B - K)
	




if __name__ == '__main__':
	main()

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

int main() {
  int n, m, l;
  cin >> n >> m >> l;

  int A[n][m], B[m][l];
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < l; j++) {
      cin >> B[i][j];
    }
  }

  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++){
      long long  c = 0;
      for (int k = 0; k < m; k++) {
	c += A[i][k]*B[k][j];
      }
      cout << c;
      if (j < l-1) cout << " ";
    }
    cout << endl;
  }
    
  return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
#define mk make_pair
int main(){
  int n,t=0,x=0;
  cin>>n;
  int a[n];
  r(i,n)cin>>a[i];
  for(int i=n-1;i>=0;i-=2){
    if(t++)cout<<' ';
    cout<<a[i];
    if(i==0)x++;
  }
  for(int i=x;i<n;i+=2){
    if(t++)cout<<' ';
    cout<<a[i];
  }cout<<endl;
}

Measured memory_bytes: 2944
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    ll X;
    cin >> X;
    ll sum = 0;
    for(int i = 1; ; i++){
        sum += i;
        if(sum >= X){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ');
			int n = int.Parse(input[0]);
			int k = int.Parse(input[1]);

			int count = 0;
			for (int i = 1; i <= n; i++)
			{
				if (i + k - 1 > n)
				{
					break;
				}
				count++;
			}
			Console.WriteLine(count);
		}
	}
}


Measured memory_bytes: 13140
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::min;

fn main() {
    let nk: Vec<usize> = read_vec();
    let n = nk[0];
    let k = nk[1];
    let v: Vec<i32> = read_vec();
    let mut ans = -1000000000;
    for get in 0..min(n + 1, k + 1) {
        let back = k - get;
        for lc in 0..get + 1 {
            let rc = get - lc;
            let mut out: Vec<i32> = vec![];
            for i in 0..lc {
                out.push(v[i]);
            }
            for i in n - rc..n {
                out.push(v[i]);
            }
            out.sort();
            let mut id = 0;
            let l = out.len();
            while id < min(back, l) {
                if out[id] > 0 {
                    break;
                }
                id += 1;
            }
            let mut tmp = 0;
            for i in id..l {
                tmp += out[i];
            }
            if tmp > ans {
                ans = tmp;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

#define L 14
#define M 1052693//1000000に近い素数

char H[M][L];

int GetChar(char c);
long long GetKey(char *c);
int h1(int);
int h2(int);
int h(int,int);
int find(char *c);
int insert(char *c);

int main(){
    int n,i;
    char ins[] = "insert";
    char fin[] ="find";
    scanf("%d",&n);

    for(i=0; i<M; i++) H[i][0] = '\0';

    for(i=0; i<n; i++){

        char order[7],str[L];
        scanf("%s %s",order,str);

        if(strcmp(order,ins) == 0){
            insert(str);
        }else if(strcmp(order,fin) == 0){
            if(find(str)) printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}



int GetChar(char c){
    if(c == 'A') return 1;
    else if(c == 'C') return 2;
    else if(c == 'G') return 3;
    else if(c == 'T') return 4;
}

long long GetKey(char c[]){
    long long i,p=1,sum = 0;
    for(i=0; i<strlen(c); i++){
        sum += p*(GetChar(c[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){
    return key%M;
}

int h2(int key){
    return 1+key%(M-1);    
}

int h(int key,int i){
    return (h1(key)+i*h2(key))%M;
}

int find(char c[]){
    long long key,ind,i=0;
    key = GetKey(c);
    while(1){
        ind = h(key,i);
        if(strcmp(c,H[ind]) == 0) return 1;
        else if (strlen(H[ind]) == 0) return 0;
        i++;
    }
}

int insert(char c[]){
    long long i=0,j,key;
    key = GetKey(c);
    while(1){
        j = h(key,i);
        if(strcmp(c,H[j]) == 0) return 1;
        else if(strlen(H[j]) == 0){
            strcpy(H[j],c);
            return 0;
        }
        i++;
    }
}



Measured memory_bytes: 16136
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int long long
   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; }
    const int MAX =200005;
const int MOD =1000000007;

signed main(){
  int n;
  cin>>n;
  int x,y,p[n],q[n];
  for(int i=0;i<n;i++){
    cin>>x>>y;
    p[i]=x+y;
    q[i]=x-y;
  }
  sort(p,p+n);sort(q,q+n);
  cout<<max(p[n-1]-p[0],q[n-1]-q[0])<<endl;
}

Measured memory_bytes: 6764
#include <bits/stdc++.h>
using namespace std;
int main() {
    int m, k; cin >> m >> k;
    if (k >= (1 << m)) {
        cout << -1 << endl;
        return 0;
    }
    if (m == 1) {
        if (k == 0) cout << "0 0 1 1" << endl;
        else cout << -1 << endl;
        return 0;
    }
    deque<int> ans = {k};
    for (int i = 0; i < (1 << m); i++) {
        if (i == k) continue;
        ans.push_back(i);
        ans.push_front(i);
    }
    ans.push_back(k);
    for (int i = 0; i < ans.size(); i++) {
        if (i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <stdio.h>
#define min(a, b) ((a)>(b) ? (b) : (a))

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

  long long int ans = 1000000000;
  for(int p=1; p<=100; p++){
    long long int sum = 0;
    for(int j=0; j<n; j++){
      sum += ((x[j]-p)*(x[j]-p));
    }
    ans = min(ans, sum);
  }

  printf("%lld\n", ans);

  return 0;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

  int n;
  cin >> n;

  vector<int> x(n);
  vector<int> y(n);
  rep (i, 0, n)
    cin >> x[i] >> y[i];

  vector<int> np(n);
  rep (i, 0, n)
    np[i] = i;

  double route = 0;

  do {
    for (int i = 1; i < n; i++) {
      int st_x = x[np[i - 1]];
      int st_y = y[np[i - 1]];
      int ed_x = x[np[i]];
      int ed_y = y[np[i]];

      route += sqrt(pow((ed_x - st_x), 2) + pow((ed_y - st_y), 2));
    }
  } while (next_permutation(np.begin(), np.end()));

  double k = 1;
  for (int i = n; i > 0; i--) {
    k *= i;
  }

  cout << fixed << setprecision(6) <<  route / k << endl;
	return 0;
}

Measured memory_bytes: 256
import fractions
n = int(input())
a = list(map(int, input().split()))
val = a[0]
for i in range(1, n):
    val = val*a[i] // fractions.gcd(val,a[i])
m = val -1
#print(m)
ans = 0
for i in range(n):
    ans += m % a[i]
print(ans)

Measured memory_bytes: 5304
import sys
input = sys.stdin.readline
X, N = map(int, input().split())
a = set(list(map(int, input().split())))
res = 0
for i in range(400):
  x = i - 200
  if x in a: continue
  if abs(res - X) > abs(x - X): res = x
print(res)

Measured memory_bytes: 61624
N, A, B = map(int,input().split())
h = [0 for i in range(N)]
for i in range(N):
	h[i] = int(input())
h = sorted(h)
import math
# N, A, B = 4, 5, 3
# h = [8,7,4,2]
# h = sorted(h,reverse=True)

def enough(T):
	tmp = 0
	for i in range(N):
		if h[i] >= B*T:
			tmp += math.ceil((h[i]-B*T)/(A-B))
	return True if tmp <= T else False

MAX = 10**9
MIN = 0
MID = (MAX+MIN)//2
while MAX > MIN+1:
	if enough(MID) == True:
		MAX = MID
	else:
		MIN = MID
	MID = (MAX+MIN)//2
print(MAX)



Measured memory_bytes: 8288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    int ans = 0;
    int num = min(X,Y);
    if(A+B>C*2){
        ans+=num*2*C;
        X-=num;
        Y-=num;
    }else{
        ans+=num*(A+B);
        X-=num;
        Y-=num;
    }
    if(A>C*2){
        ans+=2*X*C;
    }else{
        ans+=X*A;
    }
    if(B>C*2){
        ans+=2*Y*C;
    }else{
        ans+=Y*B;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256