akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
	int n;
	cin>>n;
	int dish[n+1];
	for(int i=1;i<=n;i++)
		cin>>dish[i];
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int c[n];
	for(int i=1;i<=n-1;i++)
		cin>>c[i];
	int satisf=a[dish[1]];
	for(int i=2;i<=n;i++)
	{
		satisf+=a[dish[i]];
		if(dish[i]==dish[i-1]+1)
			satisf+=c[dish[i-1]];
	}
	cout<<satisf<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch(int key){
	Node *cur = nil->next;
	while (cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	Node *cur = nil->next;
	int isf = 0;
	while (1){
		if (cur == nil) break;
		if (isf++ > 0) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t){
	if (t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){

	deleteNode(listSearch(key));
}

void insert(int key){
	Node *x =  (Node *)malloc(sizeof(Node));
	x->key = key;

	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for (i = 0; i < n; i++){
		scanf("%s%d", com, &key);
		if (com[0] == 'i'){ insert(key); np++; size++; }
		else if (com[0] == 'd'){
			if (strlen(com) > 6){
				if (com[6] == 'F') deleteFirst();
				else if (com[6] == 'L') deleteLast();
			} else {
				deleteKey(key); nd++;
			}
			size--;
		}
	}

	printList();

	return 0;
}

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

int main(){
    int m,d;
    cin>>m>>d;
    int ans = 0;
    for(int i=22; i<=d;i++){
        if(((i/10)*(i%10) <= m) && (i%10)>=2){
            ans++;
        }
    }
    cout<< ans <<endl;
}


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

int main() {
  std::ios_base::sync_with_stdio(false);
      std::cin.tie(NULL);
      int t;
      std::cin >>t;
      int arr[t];
      std::vector<int> v(t);
        for(int i=0;i<t;i++){
          std::cin >>v[i];
        }

             // sort(arr, arr+t);
            sort(v.begin(),v.end());
// 987030048 949723321 372215084 274804310 477215009 715894211 258801821
        long long int ans =0;
        int id =t-1;
        if((t-1) % 2 == 0){
        for(int i=t-1;i>0;i--){
           ans +=(long long int) v[id];
           if(i%2==0)
             id--;
        }
      }else {
        for(int i=t-1;i>0;i--){
           ans +=(long long int) v[id];
           if(i%2!=0)
             id--;
        }
      }
      std::cout << ans << '\n';

//4795480121
//5305295160
return 0;
}


Measured memory_bytes: 3960
# C
from heapq import heappush, heappop

N = int(input())
L_arr = [0]*N
R_arr = [0]*N

for i in range(N):
    L, R = map(int, input().split())
    L_arr[i] = L
    R_arr[i] = R

# argsort
R_args = [0]*N
h = []
for i in range(N):
    heappush(h, (R_arr[i], i))
for i in range(N):
    a, b = heappop(h)
    R_args[i] = b
L_args = [0]*N
h = []
for i in range(N):
    heappush(h, (-L_arr[i], i))
for i in range(N):
    a, b = heappop(h)
    L_args[i] = b



# Greedy Left
used_idx = [0]*N
res = 0
pos = 0
i_r = 0
i_l = 0

for i in range(N):
    while used_idx[L_args[i_l]] == 1:
        i_l += 1
    while used_idx[R_args[i_r]] == 1:
        i_r += 1
        
    # run
    if i % 2 == 0:
        used_idx[L_args[i_l]] = 1
        if L_arr[L_args[i_l]] > pos:
            res += L_arr[L_args[i_l]] - pos
            pos = L_arr[L_args[i_l]]
            #print(pos)
        elif R_arr[L_args[i_l]] < pos:
            res += pos - R_arr[L_args[i_l]]
            pos = R_arr[L_args[i_l]]
            #print(pos)
    else:
        used_idx[R_args[i_r]] = 1
        if R_arr[R_args[i_r]] < pos:
            res += pos - R_arr[R_args[i_r]]
            pos = R_arr[R_args[i_r]]
            #print(pos)
        elif L_arr[R_args[i_r]] > pos:
            res += L_arr[R_args[i_r]] - pos
            pos = L_arr[R_args[i_r]]
            #print(pos)
res_1 = res + abs(pos)

# Greedy Left
used_idx = [0]*N
res = 0
pos = 0
i_r = 0
i_l = 0

for i in range(N):
    while used_idx[L_args[i_l]] == 1:
        i_l += 1
    while used_idx[R_args[i_r]] == 1:
        i_r += 1
        
    # run
    if i % 2 != 0:
        used_idx[L_args[i_l]] = 1
        if L_arr[L_args[i_l]] > pos:
            res += L_arr[L_args[i_l]] - pos
            pos = L_arr[L_args[i_l]]
        elif R_arr[L_args[i_l]] < pos:
            res += pos - R_arr[L_args[i_l]]
            pos = R_arr[L_args[i_l]]
    else:
        used_idx[R_args[i_r]] = 1
        if R_arr[R_args[i_r]] < pos:
            res += pos - R_arr[R_args[i_r]]
            pos = R_arr[R_args[i_r]]
        elif L_arr[R_args[i_r]] > pos:
            res += L_arr[R_args[i_r]] - pos
            pos = L_arr[R_args[i_r]]
res_2 = res + abs(pos)

print(max(res_1, res_2))

Measured memory_bytes: 85208
#include<stdio.h>
int main(){
    int count[4][3][10]={{{0}}};
    int i,j,k,n;
    int b,f,r,v;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d\n",&b,&f,&r,&v);
        count[b-1][f-1][r-1]+=v;
    }
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",count[i][j][k]);
            }
        printf("\n");
        }
    if(i!=3)printf("####################\n");
    }

return 0;
}


Measured memory_bytes: 2040
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	char map[10][10];
};

struct Data{
	Data(int arg_row,int arg_col){
		row = arg_row;
		col = arg_col;
	}
	int row,col;
};

int H,W;
int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
char base_map[10][10];
bool FLG;

char to_color[3] = {'R','G','B'};

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1)return true;
	else{
		return false;
	}
}

void back_track(Info info,int depth,int max_depth){

	if(FLG)return;

	bool is_cleared = true;
	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			if(info.map[row][col] != info.map[0][0]){
				is_cleared = false;
				break;
			}
		}
		if(!is_cleared)break;
	}

	if(is_cleared){
		FLG = true;
		return;
	}

	char pre_color = info.map[0][0];

	queue<Data> Q;
	int adj_row,adj_col;

	for(int loop = 0; loop < 3; loop++){
		if(to_color[loop] == pre_color)continue;

		Info next_info;
		for(int row = 0;row < H; row++){
			for(int col = 0; col < W; col++){
				next_info.map[row][col] = info.map[row][col];
			}
		}

		next_info.map[0][0] = to_color[loop];

		Q.push(Data(0,0));

		while(!Q.empty()){

			for(int i = 0; i < 4; i++){
				adj_row = Q.front().row + diff_row[i];
				adj_col = Q.front().col + diff_col[i];

				if(!rangeCheck(adj_row,adj_col))continue;

				if(next_info.map[adj_row][adj_col] == pre_color){
					next_info.map[adj_row][adj_col] = to_color[loop];
					Q.push(Data(adj_row,adj_col));
				}
			}

			Q.pop();
		}
		if(depth < max_depth){
			back_track(next_info,depth+1,max_depth);
		}
	}
}

void func(){

	char buf[2];

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			scanf("%s",buf);
			base_map[row][col] = buf[0];
		}
	}

	FLG = false;
	int ans = 0;

	for(int i = 0; ; i++){
		Info info;

		for(int row = 0; row < H; row++){
			for(int col = 0; col < W; col++){
				info.map[row][col] = base_map[row][col];
			}
		}
		back_track(info,0,i);

		if(FLG){
			ans = i;
			break;
		}
	}

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


int main(){

	while(true){
		scanf("%d %d",&W,&H);
		if(W == 0 && H == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

struct edge{ ll to,cost; };
ll V;
vector<edge> G[500010];
ll d[500010];

void dijkstra(ll s){
    fill(d,d+500010,inf);
    d[s]=0;
    priority_queue<l_l,vector<l_l>,greater<l_l>> que;
    que.push(l_l(0,s));
    
    while(!que.empty()){
        l_l p=que.top();que.pop();
        ll v=p.second;
        if(d[v]<p.first)continue;
        if(G[v].size()>0){
            rep(i,0,G[v].size()-1){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(l_l(d[e.to],e.to));
                }
            }
        }
    }
    
}


int main(){
    ll n;cin>>n;
    ll m;cin>>m;
    ll r;cin>>r;
    
    ll a[m],b[m],c[m];
    V=m;
    if(m>0){
        rep(i,1,m){
            cin>>a[i]>>b[i]>>c[i];
            edge e;
            e.to=b[i];e.cost=c[i];
            G[a[i]].pb(e);
        }
    }
    dijkstra(r);
    rep(i,0,n-1){
        if(d[i]==inf)cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 43480
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int N, M;
bool graph[60][60];
bool vis[60];

void dfs(int x)
{
    if (vis[x]) return;
    vis[x] = true;

    for (int i = 0; i < N; i++) {
        if (graph[x][i]) dfs(i);
    }
}
int main()
{
    cin >> N >> M;

    int a[60], b[60];
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = true;
        graph[b[i]][a[i]] = true;
    }

    int cnt = 0;

    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++) {
            vis[j] = false;
        }

        graph[a[i]][b[i]] = false; graph[b[i]][a[i]] = false;
        dfs(0);
        graph[a[i]][b[i]] = true; graph[b[i]][a[i]] = true;
        
        bool f = true;
        for (int j = 0; j < N; j++) {
            if (!vis[j]) f = false;
        }
        if (!f) cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vint h(n);
    rep(i,n){
        cin>>h[i];
    }
    ll count=0;
    sort(all(h),greater<int>());
    rep(i,n){
        if(i<k){
        }
        else{
            count+=h[i];
        }
    }
    cout<<count<<'\n';
    return(0);
}

Measured memory_bytes: 1152
import math
a,b,c = map(int,input().split())
maxcnt = -99999
if c <= b-1:
	x = c
	cnt = (a*x)//b - a*(x//b)
	if cnt > maxcnt:
		maxcnt = cnt
else:
	x = b-1
	maxcnt = math.floor(a*x/b) - a* math.floor(x/b)
print(maxcnt)

Measured memory_bytes: 62048
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
typedef pair<int,int> pii;
int MOD = 998244353;

signed main(){
    int a,b;
    cin >> a >> b;
    cout << max({a+(a-1),b+(b-1),a+b}) << endl;

    
     
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc124.contest.atcoder.jp/tasks/abc124_a


Measured memory_bytes: 768
def readinput():
    n=int(input())
    return n

def main(n):
    ans=0
    for i in range(1,n+1):
        if i%3==0 or i%5==0:
            continue
        else:
            ans+=i
    return ans

if __name__=='__main__':
    n=readinput()
    ans=main(n)
    print(ans)


Measured memory_bytes: 9172
N = int(input())
A = list(map(int,input().split()))
s = 0
ans1 = 0
for i in range(N):
    if i%2 == 0 and s+A[i] > 0:
        s += A[i]
    elif i%2 == 0 and s+A[i] <= 0:
        ans1 += 1-s-A[i]
        s = 1
    elif i%2 == 1 and s+A[i] >= 0:
        ans1 += s+A[i]+1
        s = -1
    else:
        s += A[i]
s = 0
ans2 = 0
for i in range(N):
    if i%2 == 1 and s+A[i] > 0:
        s += A[i]
    elif i%2 == 1 and s+A[i] <= 0:
        ans2 += 1-s-A[i]
        s = 1
    elif i%2 == 0 and s+A[i] >= 0:
        ans2 += s+A[i]+1
        s = -1
    else:
        s += A[i]
print(min(ans1,ans2))

Measured memory_bytes: 14648
#include<bits/stdc++.h>
using namespace std;
//X个金币从x+y+z个人
//想要得到最多的硬币数量
//首先 从一个人处只能拿到一个硬币 金币只能从确定的X个人处拿 银币只能从确定的Y个人处拿
//一共X+Y个人的话Ai-Bi越小 就说明Ai越小于Bi 就说明从这个人拿到的银币多于金币
//一个人能给出的银币(B1)比金币(A1)数目多 另一个人能给出的银币(B2)数目比金币(A2)数目少
// 我们又正好需要从一个人处拿银币 一个人那里拿金币
//如果选择从第一个人那里拿金币 从第二个人那里拿银币
//也就是这个不等式 B1>A1且A2>B2
//那么A2+B1>B2+A1
//那么从第一个人那里拿银币所得到的收益一定大于从他那里拿金币的(因为他银币多) 从第二个人那里拿金币的收益一定大于从他那里拿银币的(因为他金币多)
//一个人能给出的银币比金币数目多很多(假设多10000000) 另一个人能给出的银币数目比金币数目多一点(假设多1)
//B1-A1=10000 B2-A2=1
//B1+A2>B2+A1
//B1-A1>B2-A2
//那么再考虑从z个人处拿铜币
//就是在改变视角中前进的么(改变对于A1-B1的描述前进
//
#include<bits/stdc++.h>
#define MAXN 100005
#define INF -99999999999999
using namespace std;
long long x,y,z;
struct node
{
    long long a,b,c;
}Human[MAXN];
bool cmp(node n1,node n2)
{
    return n1.b-n1.a<n2.b-n2.a;
}
priority_queue<long long,vector<long long>,greater<long long> >q;
long long sum,ans=INF,lef[MAXN],allc;
//小于号升序
int main()
{
    scanf("%lld %lld %lld",&x,&y,&z);
    long long n=x+y+z;
    for(int i=1;i<=x+y+z;i++)
    {
        scanf("%lld %lld %lld",&Human[i].a,&Human[i].b,&Human[i].c);
        allc+=Human[i].c;
    }
    sort(Human+1,Human+1+x+y+z,cmp);
    //从左拿金 右拿银
    for(int i=1;i<=x;i++)
    {
        sum+=Human[i].a-Human[i].c;
        q.push(Human[i].a-Human[i].c);
    //    printf("%lld\n",sum);
    }
    lef[x]=sum;
    for(int i=x+1;i<=n-y+1;i++)
    {
        //sum是以k为界的最大值
      //  printf("%lld %lld\n",sum,lef[i]);
        q.push(Human[i].a-Human[i].c);
        sum-=q.top();
        sum+=Human[i].a-Human[i].c;
        //printf("%d\n",q.top());
        q.pop();
        lef[i]=sum;
    }
    while(!q.empty())
    {
        q.pop();
    }
    sum=0;
    for(int i=n;i>=n-y+1;i--)
    {
        sum+=Human[i].b-Human[i].c;
        q.push(Human[i].b-Human[i].c);
    }
    for(int i=n-y;i>=x;i--)
    {
      //  printf("%lld\n",sum);
        ans=max(ans,sum+lef[i]);
        //printf("%lld\n",ans);
        q.push(Human[i].b-Human[i].c);
        sum-=q.top();
        sum+=Human[i].b-Human[i].c;
        q.pop();
    }
    printf("%lld\n",ans+allc);
}


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

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    string s;
    cin >> s;

    int a = 0, b = 0;

    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '0') {
            if(i & 1) a++;
            else b++;
        }
        else {
            if(i & 1) b++;
            else a++;
        }
    }

    cout << min(a, b) << endl;
}

/**
0101
1010
*/


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

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

  vector<pair<int,int> > a;

  rep(i,n){
      int fi;
      int se;
      cin >> se >> fi;
      a.push_back( make_pair(fi,se));
  }

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

  int check=0;

  rep(i,n){
      check += a.at(i).second;
      if(check > a.at(i).first){
          cout << "No" << endl;
          return 0;
      }
  }

  cout << "Yes" << endl;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int ans;
    if (n % 2 == 0) {
        ans = n / 2;
    } else {
        ans = (n + 1) / 2;
    }
    
    if (ans >= k) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umll unordered_map<long long int,long long int>
#define umci unordered_map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define mod 1000000007
using namespace std;
#define maxval 10003000

int main(){
   IOS;
ll t;t=1;//cin>>t;

while(t--){ll ans=0;ll n;cin>>n;
ll a[n];
for(ll i=0;i<n;i++) cin>>a[i];
for(ll i=1;i<n;i++){
    if(a[i]<a[i-1]) {
        ans=ans+a[i-1]-a[i];
        a[i]=a[i-1];
    }
}
cout<<ans;
  
}
    
return 0;    
}

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

int main(){
  int N; cin >> N;
  map<int, int> mp;
    for(int j = 1; j <= N; j++){
      for(int k = 1; k <= N; k++){
        for(int l = 1; l <= N; l++){
		  long long sum = j*j+k*k+l*l+j*k+k*l+l*j;
          if(sum > N)break;
          mp[sum]++;
        }
      }
    }
  for(int i = 0; i < N; i++){
    cout << mp[i+1] << endl; 
  }
  return 0;
}


Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
// #define vb          vector<bool>
// #define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
// #define ub(x)       upper_bound(x)
// #define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("b1.in","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N            1e5+5
#define PRIME           1000000007
#define MAX         50000
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define pi          3.14159265358979323
int i,j,k;
// int n;
// const int N=1e6+5;
// vector<bool> prime(N);
// void sieve(){
//     for(int i=0;i<=N;i++)prime[i]=true;
//     prime[0]=prime[1]=false;
//     for(int i=2;i*i<=N;i++){
//         if(prime[i] and i*i<=N){
//             for(int j=i*i;j<=N;j+=i){
//                 prime[j]=false;
//             }
//         }
//     }
// }
// const int N=1e3+5;
// int a[N];


void Anon_mouS(){
    int n;
    cin>>n;
    if(n>=400 and n<=599)cout<<8;
    else if(n>=600 and n<=799)cout<<7;
    else if(n>=800 and n<=999)cout<<6;
    else if(n>=1000 and n<=1199)cout<<5;
    else if(n>=1200 and n<=1399)cout<<4;
    else if(n>=1400 and n<=1599)cout<<3;
    else if(n>=1600 and n<=1799)cout<<2;
    else if(n>=1800 and n<=1999)cout<<1;
}
int32_t main(){
    fastio;
    int q=1;
    // sieve();
    // cin>>q;
    for(int it=1;it<=q;it++){
        // cout<<"Case #"<<it<<": ";
        Anon_mouS();
    }
    return 0;   
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
vector <long long> t;

long long int gcd(long long a, long long b){
	return (b == 0 ? a : gcd(b, a % b));
}

long long int lcm(long long a,long long b){
    return a /gcd(a, b) * b;
}
int main(){
    long long n;  cin >> n;
    t = vector <long long> (n);
    rep(i, n) cin >> t[i];
    rep(i, n - 1){
        long long va = lcm(t[i], t[i + 1]);
        t[i + 1] = va;
    }
    cout << t[n - 1] << endl;
}



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

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      m: usize,
      s: chars,
    }
    let mut cur = s.len()-1;
    let mut ans = vec![];

    while cur > 0 {
        let mut ok = false;
        for d in (1..m+1).rev() {
            if d > cur {
                continue;
            }
            if s[cur-d] == '0' {
                cur -= d;
                ans.push(d);
                ok = true;
                break;
            }
        }
        if !ok {
            return puts!("{}\n", -1);
        }
    }
    ans.reverse();
    for i in 0..ans.len() {
        if i == ans.len() - 1 {
            puts!("{}", ans[i]);
        } else {
            puts!("{} ", ans[i]);
        }
    }
    puts!("\n")
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a="CODEFESTIVAL2016",b;
	int jsq=0;
	cin>>b;
	for(int i=0;i<=15;i++){
		if(b[i]!=a[i]){
			jsq++;
		}
	}
	cout<<jsq<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;

const int N = 100010;
vector<int> v[N];
vector<ll> b[N];
int a[N],n,d[N];
ll f[N],g[N];
bool pd = true;
priority_queue<ll> Q;
void dfs(int x,int fa){
	//cout<<x<<endl;
	if(d[x]==1){
		g[x] = a[x];
		return ;
	}
	for(int i = 0;i<v[x].size();i++) if(v[x][i]!=fa){
		int t = v[x][i];
		dfs(t,x);
		b[x].push_back(g[t]);
		//cout<<g[t]<<endl;
		f[x]+=g[t];
	}
	ll t1,t2;
	t1 = f[x]-a[x], t2 = a[x] - t1;
	if(t1<0 || t2<0) pd = false;
	//Q.clear();
	/*
	for(int i =0;i<b[x].size();i++) if(b[x][i]) Q.push(b[x][i]);
	ll tmp =0,t3,t4;
	while(Q.size()>=2){
		t3 = Q.top();
		Q.pop();
		t4  = Q.top();
		Q.pop();
		tmp+=t4;
		if(t3-t4) Q.push(t3-t4);
	}
	if(Q.size()==1) Q.pop();
	*/
	sort(b[x].begin(),b[x].end());
	int len = b[x].size();
	ll tmp =0;
	if(len>0){
		if(b[x][len-1]>=f[x]-b[x][len-1]) tmp = f[x]-b[x][len-1];
		else tmp = f[x]>>1;
	}
	if(tmp<t1) pd= false;
	//cout<<x<<' '<<t1<<' '<<t2<<endl;
	g[x] = t2;
}

int main(){
	scanf("%d",&n);
	for(int i =1;i<=n;i++)scanf("%d",a+i);
	if(n==2){
		if(a[1]==a[2]) puts("YES"); else puts("NO");
		return 0;
	}
	for(int i=0;i<n-1;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
		d[x]++;
		d[y]++;
	} 
	for(int i =1;i<=n;i++) if(d[i]>1){
		//cout<<i<<endl;
		dfs(i,0);
		if(g[i]!=0) pd =false;
		break;
	}
	if(pd) puts("YES"); else puts("NO");
	return 0;
}

Measured memory_bytes: 21504
if __name__ == "__main__":
    n = int(input())
    h = list(map(int, input().split(" ")))+[10**9]

    ans = "Yes"

    for i in range(len(h)-1)[::-1]:
        if h[i] > h[i+1]: h[i] -= 1
    for i in range(1, len(h)):
        if h[i-1] > h[i]:
            ans = "No"
            break
    
    print(ans)

Measured memory_bytes: 15020
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {

	double x1, x2, y1, y2;
	double distance;

	cin >> x1 >> y1 >> x2 >> y2;
	
	distance = sqrt(pow((x1 - x2) , 2) + pow((y1 - y2) , 2));
	cout << setprecision(20) <<  distance << endl;

	cin >> x1;

	return 0;
}


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

using namespace std;

using ll = long long;

int K;

string go(int d, int pos) {
    if (pos == 0) {
        if (--K == 0)
            return to_string(d);
    } else {
        for (int x = max(0, d - 1); x <= min(9, d + 1); x++) {
            string res = go(x, pos - 1);
            if (res.size()) {
                return to_string(d) + res;
            }
        }
    }
    return "";
}

int main() {
    cin >> K;
    for (int i = 0; i < 10; i++) {
        for (int d = 1; d < 10; d++) {
            string ans = go(d, i);
            if (ans.size()) {
                cout << ans << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

long long meet(long long x, long long y)
{
    return (y-x)/2LL;
}

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

    long long n,a,b;
    cin>>n>>a>>b;
    if(a%2==b%2)
        cout<<meet(a,b)<<"\n";
    else
        cout<<min(a+meet(1,b-a),n-b+1+meet(a+(n-b+1),n))<<"\n";
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
mx = 100000
dp = [[k+1 for _ in range(mx+1)]for _ in range(n+1)]
dp[0][0]=0
for i in range(1,n+1):
    dp[i][0]= 0
    w,v = map(int,input().split())
    for j in range(v):
        dp[i][j]= dp[i-1][j]
    for j in range(v,mx+1):
        next = w+dp[i-1][j-v]
        if next<=k:
            dp[i][j]= min(next,dp[i-1][j])
        else:
            dp[i][j]=dp[i-1][j]
for i in range(mx,-1,-1):
    if dp[n][i]<=k:
        print(i)
        break


Measured memory_bytes: 171380
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  int x,y,z;
  
  
  vector<int> vec(N+1);
  
    for(int x=1;x<=100;x++){
      for(int y=1;y<=100;y++){
        for(int z=1;z<=100;z++){
          int a=x*x+y*y+z*z+x*y+y*z+z*x;
          if(a<=N){
            vec[a]++;
          }
        }
      }
    }
  for(int i=1;i<=N;i++){
    cout<<vec[i]<<endl;
  }
}

Measured memory_bytes: 3576
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <utility>
#include <iomanip>
#include <queue>

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

//const ll inf=1000000000000000;


using namespace std;


int main(){
    int N;
    cin>>N;
    cout<<N*N*N<<endl;
    
}

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

struct Union_Find {

    vector<int> par;
    vector<int> rank;

    Union_Find(int n) : par(n), rank(n, 1) {
        for(int i=0; i<n; i++) par[i] = i;
    } 

    int find(int x) {
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if(x == y) return;

        if(rank[x] < rank[y]) swap(x, y);
        par[y] = x;
        rank[x] += rank[y];
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return rank[find(x)];
    }

};

struct Edge {
    int a, b, cost;
    bool operator<(const Edge& o) const {
        return cost < o.cost;
    }
};


int main() {

    int N;
    cin >> N;

    vector<pair<long long, int>> x_point(N); 
    vector<pair<long long, int>> y_point(N); 
    for(int i=0; i<N; i++) {
        x_point[i].second = i;
        y_point[i].second = i;
        cin >> x_point[i].first >> y_point[i].first;
    }

    sort(x_point.begin(), x_point.end());
    sort(y_point.begin(), y_point.end());

    Union_Find union_find(N);
    vector<Edge> edges;

    for(int i=0; i<N-1; i++) {
        Edge edge_x;
        edge_x.a = x_point[i].second;
        edge_x.b = x_point[i+1].second;
        long long cost = x_point[i+1].first - x_point[i].first;
        edge_x.cost = cost<0?-cost:cost;
        edges.push_back(edge_x);

        Edge edge_y;
        edge_y.a = y_point[i].second;
        edge_y.b = y_point[i+1].second;
        cost = y_point[i+1].first - y_point[i].first;
        edge_y.cost = cost<0?-cost:cost;
        edges.push_back(edge_y);
    }

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

    long long result = 0;
    for(int i=0; i<edges.size(); i++) {
        Edge& edge = edges[i];
        if(!union_find.same(edge.a, edge.b)) {
            result += edge.cost;
            union_find.unite(edge.a, edge.b);
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 8564
from random import randint, getrandbits, random
from math import exp
import time
import sys
start = time.perf_counter()
input = sys.stdin.readline

def scoring():
    last = [0] * 26
    res = 0
    penalty = 0
    for i in range(D):
        t = out[i]
        res += S[i][t]
        penalty += sc - (i + 1 - last[t]) * C[t]
        res -= penalty
        last[t] = i + 1
    return res

def solve(score):
    T0 = 2.e3
    T1 = 6.e2
    TL = 1.8
    T = T0
    cnt = 0
    while True:
        if cnt % 50 == 0:
            now = time.perf_counter()
            elapsed =  now - start
            if elapsed > TL:
                break
            t = elapsed / TL
            T = pow(T0, 1 - t) * pow(T1, t)
        if getrandbits(1):
            d = randint(0, D - 1)
            q = randint(0, 25)
            old = out[d]
            out[d] = q
            tmp = scoring()
            p = exp((tmp - score) / T)
            r = random()
            if tmp > score or r < p:
                score = tmp
            else:
                out[d] = old
        else:
            d1 = randint(0, D - 2)
            d2 = randint(d1 + 1, min(d1 + 16, D - 1))
            out[d1], out[d2] = out[d2], out[d1]
            tmp = scoring()
            p = exp((tmp - score) / T)
            r = random()
            if tmp > score or r < p:
                score = tmp
            else:
                out[d1], out[d2] = out[d2], out[d1]
        cnt += 1

D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
out = [randint(0, 25) for _ in range(D)]
sc = sum(C)
score = scoring()
solve(score)
for i in out:
    print(i + 1)

Measured memory_bytes: 91808
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<ll, ll> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("commandos.in", "r", stdin);*/
#endif
}
void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
	//File();
}
const double pi = acos(-1.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e2 + 15;
int dx[8] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 1, 0, -1, 1, -1, -1, 1 };

int main()
{
	fast();
	int n, w;
	cin >> n >> w;
	vector<int>value(n);
	vector<int> weight(n);
	ll sumOfValues = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> weight[i] >> value[i];
		sumOfValues += value[i];
	}
	vector<int> dp(sumOfValues + 1, oo);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = sumOfValues - value[i]; j >= 0; j--)
		{
			dp[j + value[i]] = min(dp[j + value[i]], dp[j] + weight[i]);
		}
	}
	int res = 0;
	for (int i = 0; i <= sumOfValues; i++)
	{
		if (dp[i] <= w)
			res = max(res, i);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main(void){
  char str[1001],order[8];
  char temp,rep[1001];
  int i,j,k,l,n;
  int a,b;
   
  scanf("%s",str);
  scanf("%d",&n);
   
  for(i=0;i<n;i++){
      scanf("%s %d %d",order,&a,&b);
      if(strcmp(order,"print")==0){
          for(j=a;j<=b;j++){
              printf("%c",str[j]);
              if(j==b) printf("\n");
          }
      }
      else if(strcmp(order,"reverse")==0){
          k=(b-a)/2;
          for(j=a;j<=a+k;j++){
              temp=str[j];
              str[j]=str[a+b-j];
              str[a+b-j]=temp;
          }
      }
      else if(strcmp(order,"replace")==0){
          scanf("%s",rep);
          for(j=a,l=0;j<=b;j++,l++){
              str[j]=rep[l];
          }
      }
  }
   
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    int alice=0,bob=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            alice += vec.at(i);
        }else{
            bob += vec.at(i);
        }
    }
    cout << alice-bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;

int main() {
  int n,m;cin>>n>>m;
  vector<vector<int>> g(n+1);
  repi(i,m) {
    int a,b;cin>>a>>b;
    if (a!=1&&a!=n&&b!=1&&b!=n) continue;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  bool ans = false;
  for (int x : g[1]) {
    for (int y : g[x]) {
      if (y == n) ans = true;
    }
  }
  cout << (ans?"POSSIBLE":"IMPOSSIBLE") << endl;
}


Measured memory_bytes: 12016
n, d = map(int, input().split())
li = []
for i in range(n):
    li.append(list(map(int, input().split())))

ans = 0
for l in li:
    if (l[0] * l[0] + l[1] * l[1] <= d * d):
        ans += 1

print(ans)


Measured memory_bytes: 45460
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int> ,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

long long int m=(long long int)1e18;
bool check(long long int a)
{
    for(int i=2;i<=sqrt(a);i++)
    {
        if(a%i == 0)
            return 0;
    }
    return 1;
}
void go()
{
    int n;
    cin>>n;
    vector<long long int> a(n);
    bool flag=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]==0)
            flag=1;
    }
    if(flag)
    {
        cout<<0;
        return;
    }
    long long int ans=1;
    for(int i=0;i<n;i++)
    {
        ans*=a[i];
        if(ans <= 0 || ans > m)
        {
            cout<<-1;
            return;
        }
    }
    cout<<ans;
}
int main()
{
    //FIO;
    //int t;
    //cin>>t;
    //while(t--)
        go();
    return 0;
}


Measured memory_bytes: 4140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

template<typename T> class segtree {
private:
    int n,sz,h; vector<T> node, lazy;
    vector<bool> lazyFlag;
    void eval(int k) {
        if(lazyFlag[k]){
            node[k] = lazy[k];
            if(k < n) {
                lazy[k*2] = lazy[k*2+1] = lazy[k];
                lazyFlag[k*2] = lazyFlag[k*2+1] = true;
            }
            lazyFlag[k] = false;
        }
    }

public:
    segtree(const vector<T>& v) : n(1), sz((int)v.size()), h(0){
        while(n < sz) n *= 2, h++;
        node.resize(2*n, numeric_limits<T>::max());
        lazy.resize(2*n); lazyFlag.resize(2*n, false);
        for(int i = 0; i < sz; i++) node[i+n] = v[i];
        for(int i = n - 1; i >= 1; i--) node[i] = min(node[i*2], node[i*2+1]);
    }
    void range(int a, int b, T x, int k=1, int l=0, int r=-1){
        if(r < 0) r = n;
        eval(k);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b){
            lazy[k] = x, lazyFlag[k] = true; eval(k);
        }else{
            range(a, b, x, 2*k, l, (l+r)/2);
            range(a, b, x, 2*k+1, (l+r)/2, r);
            node[k] = min(node[2*k], node[2*k+1]);
        }
    }
    T query(int a, int b) {
        a += n, b += n - 1;
        for(int i = h; i > 0; i--) eval(a >> i), eval(b >> i);
        b++;
        T res1 = numeric_limits<T>::max(), res2 = numeric_limits<T>::max();
        while(a < b) {
            if(a & 1) eval(a), res1 = min(res1, node[a++]);
            if(b & 1) eval(--b), res2 = min(res2, node[b]);
            a >>= 1, b >>= 1;
        }
        return min(res1, res2);
    }
    void _print(){for(int i = 0; i < sz; i++) cout<<query(i,i+1)<< " ";cout<<endl;}
};

ll n, q;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    cin >> n >> q;
    ll ans = (n - 2) * (n - 2);

    vector<int> u(n - 2, n - 2), v(n - 2, n - 2);
    segtree<int> h(u), w(v);

    ll mnh = n - 2, mnw = n - 2;
    while(q--){
        ll s, x; cin >> s >> x;
        x -= 2;

        if(s == 1){
            ans -= h.query(x, x + 1);

            if(x < mnw){
                w.range(0, h.query(x, x + 1), x);
            }

            mnw = min(mnw, x);
        }else{
            ans -= w.query(x, x + 1);

            if(x < mnh){
                h.range(0, w.query(x, x + 1), x);
            }

            mnh = min(mnh, x);
        }
    }
    print(ans)
    
    return 0;
}

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

struct stu
{
	int ind;
	int num;
}s[100005];

bool cmp(stu&s1,stu&s2)
{
	return s1.num < s2.num;
}

int main()
{
	int N;
	cin >> N;
	for(int i = 1 ; i <= N ; i++)
	{
		s[i].ind = i;
		cin >> s[i].num;
	}
	sort(s + 1,s + 1 + N,cmp);
	for(int i = 1 ; i <= N ; i++)
	{
		cout << s[i].ind <<" ";
	}
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a=0;
    cin>>n;
    for(int i=1;i<=10000;i++){
    	if(i*1000>=n){
    		a=i*1000;
    		break;
		}
	}
	cout<<a-n;
	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	int k;
	string s;
	cin>>k>>s;
	if(k>=s.length())cout<<s<<endl;
	else cout<<s.substr(0,k)<<"..."<<endl;
	return 0;
}

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

#define ll long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 998244353

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,k; cin>>n>>k;
	int pad[n];
	int dp[n]; //min cost to land on pad i
	for(int i=0;i<n;i++)
		cin>>pad[i];
	
	dp[0]=0;
	for(int i=1;i<n;i++){
		int minCost=INT_MAX;
		for(int j=1;j<k+1&&i-j>=0;j++){
				minCost=min(minCost, dp[i-j]+abs(pad[i]-pad[i-j]));
		}
		dp[i]=minCost;
	}
	cout<<dp[n-1]<<'\n';
	
	return 0;
}


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

void dfs(int k, vector<int> &a, vector<int> &b){
  //2倍したときの値がnより大きければa[k-1]と同じ値を入れれば良い
  if(2 * k > n){
    b[k-1] = a[k-1];
    return;
  }
  int d = n / k;
  int g = k * d;
  int num = 0;
  //kを2倍、3倍あるいはhoge倍したときのb[hogek-1]の値を加算し
  //その加算した値とa[k-1]との偶奇が一致していれば0一致していなければ1
  while(g > k){
    num += b[g-1];
    g -= k;
  }
  if(a[k-1] == num % 2){
    b[k - 1] = 0;
  }else{
    b[k - 1] = 1;
  }
  return;
}

int main() {
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> b(n);
  vector<int> ans;
  int ans_count = 0;
  for (int i = n - 1; i >= 0; i--){
    dfs(i + 1, a, b);
  }
  int d = 0;
  rep(i, n){
    if (b[i] > 0){
      ans.push_back(i + 1);
    }
    //前から決めていくことで必ず決定できる。
    //if(b[i] % 2 != a[i]){
    //  cout << -1 << endl;
    //  return 0;
    //}
  }
  sort(ans.begin(), ans.end());
  if(ans.size() == 0){
    cout << 0 << endl;
  }else {
    cout << ans.size() << endl;
    rep(i,ans.size()){
      cout << ans[i] << (i == ans.size() - 1 ? "\n" : " ");
    }
  }
}

Measured memory_bytes: 3064
// check用

#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef unsigned long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
#define N 10007
lint a[5010][5010];
int main()
{
	int n;string s;cin>>n;cin>>s;
	rep(i,n){
		a[i][0]=0;
		rep(j,n-i) a[i][j+1]=a[i][j]*N+(s[i+j]-'a');
	}
	int out=0;
	rep(i,n) REP(j,i+1,n){
		int lo=out,hi=j-i;
		while(hi>lo){
			int mi=(hi+lo+1)/2;
			if(a[i][mi]==a[j][mi]) lo=mi;else hi=mi-1;
		}
		out=max(out,lo);
	}
	cout<<out<<endl;
}


Measured memory_bytes: 194944
n = int(input())
s = input()[::-1]
cnt = s.count('1')
# 最初にとるあまりは2種類しかない、　一回余りを取ると2 * 10^5以下になる、あとはふつうにできる
# 最初にとるあまりについて->ビット1桁変わるだけ、あまり2種類について最初の状態でのあまりを計算、
# 1桁変わったところはどうするか？->mod二種類で前計算しておいて足す/引く -> もう一回mod
fac0 = [1] * (n + 1)
fac1 = [1] * (n + 1)
for i in range(1, n + 1):
    fac0[i] = fac0[i - 1] * 2 % (cnt + 1)
    if cnt > 1:
        fac1[i] = fac1[i - 1] * 2 % (cnt - 1)


all0 = 0
all1 = 0
for i in range(n):
    if s[i] == '1':
        all0 = (all0 + fac0[i]) % (cnt + 1)
        if cnt > 1:
            all1 = (all1 + fac1[i]) % (cnt - 1)


def pakuri_poppu(c):
    c = (c & 0x5555555555555555) + (c >> 1 & 0x5555555555555555)
    c = (c & 0x3333333333333333) + (c >> 2 & 0x3333333333333333)
    c = (c + (c >> 4)) & 0x0F0F0F0F0F0F0F0F
    return c * 0x0101010101010101 >> 56 & 0x7f


def bon(x):
    p = pakuri_poppu(x)
    res = 1
    while x:
        x %= p
        p = pakuri_poppu(x)
        res += 1
    return res


for i in range(n - 1, -1, -1):
    if s[i] == '0':
        print(bon((all0 + fac0[i]) % (cnt + 1)))
    else:
        if cnt == 1:
            print(0)
            continue
        print(bon((all1 - fac1[i]) % (cnt - 1)))


Measured memory_bytes: 87948
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
int main()
{
  string s;
  int i=0,o=0;
  cin>>s;

  int len=s.size();
  for(int j=0;j<len;j++)
  {
    if(s.at(j)=='0') o++;
    else i++;
  }

  cout<<2*min(i,o)<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld; //
typedef double db; //
typedef string str; //
//
typedef pair<int, int> pi;
typedef pair<ll,ll> pl; //
typedef pair<ld,ld> pd; //
#define mp make_pair
#define f first
#define s second

typedef vector<int> vi; 
typedef vector<ll> vl; //
typedef vector<ld> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi; //
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
//
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back() //
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = 4*atan((ld)1); 
const int xd[4] = {0,1,0,-1}, yd[4] = {1,0,-1,0}; //

template<class T> bool ckmin(T& a, const T& b) { 
	return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; }
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

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

    int N, K;
    cin >> N >> K;

    if (2*K - 1 <= N) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - ATCoder
            var s = Console.ReadLine();
            var acgt = new char[] { 'A', 'C', 'G', 'T' };
            var results = new List<string>();
            var str = "";

            foreach(var c in s)
            {
                if (acgt.Contains(c))
                {
                    str += c;
                }
                else
                {
                    if (str != "")
                    {
                        results.Add(str);
                        str = "";
                    }
                }
            }

            if (str != "")
            {
                results.Add(str);
            }

            int max = 0;

            foreach(var result in results)
            {
                if (result.Length > max)
                {
                    max = result.Length;
                }
            }

            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 13268