akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d = scan.nextInt();
        int e = scan.nextInt();
        if(a == 0){
            System.out.println(1);
        }else if(b == 0){
            System.out.println(2);
        }else if(c == 0){
            System.out.println(3);
        }else if(d == 0){
            System.out.println(4);
        }else if(e == 0){
            System.out.println(5);
        }


    }
}

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

int main() {
    ll N,M;
    cin >> N >> M;
    ll s=min(N, M/2);
    M -= s*2;
    cout << s+M/4 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll h, w, d;
    cin >> h >> w >> d;
    ll a, n = h * w;
    vll x(n), y(n);
    REP(i, h){
        REP(j, w){
            cin >> a;
            a--;
            x[a] = j, y[a] = i;
        }
    }
    vll dist(n);
    REP(i, n - d){
        dist[i + d] = dist[i] + abs(x[i + d] - x[i]) + abs(y[i + d] - y[i]);
    }
    ll q, l, r;
    cin >> q;
    REP(i, q){
        cin >> l >> r;
        l--;
        r--;
        ll res = dist[r] - dist[l];
        cout << res << endl;
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
 
#define ll long long
#define ull unsigned long long
 
using namespace std;
 
int main() {
	ull H, W;
	cin >> H >> W;
 
	ull ans = 0;
	if ( (H == 1) || (W == 1) ){
		ans = 1;		
	}
	else if ( H % 2 == 0) {
		ans = H / 2 * W;
	} else if (W % 2 == 0){
		ans = W / 2 * H;
	} else {
		ans = (H * W + 1) / 2;
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 256
def resolve():
    '''
    code here
    '''
    from collections import deque
    H, W = [int(item) for item in input().split()]
    grid = [[item for item in input()] for _ in range(H)]

    res = 0
    for i in range(H):
        for j in range(W):
            if grid[i][j] == '.':

                que = deque([[i,j]])
                footprint = [[-1 for _ in range(W)] for _ in range(H)]
                footprint[i][j] = 0

                while que:
                    a, b = que.popleft()
                    c = footprint[a][b]
                    if c > res:
                        res = c

                    if a != 0 and footprint[a-1][b] == -1 and grid[a-1][b] == '.':
                        que.append([a-1, b])
                        footprint[a-1][b] = c + 1
                    if a != H-1 and footprint[a+1][b] == -1 and grid[a+1][b] == '.':
                        que.append([a+1, b])
                        footprint[a+1][b] = c + 1
                    if b != 0 and footprint[a][b-1] == -1 and grid[a][b-1] == '.':
                        que.append([a, b-1])
                        footprint[a][b-1] = c + 1
                    if b != W-1 and footprint[a][b+1] == -1 and grid[a][b+1] == '.':
                        que.append([a, b+1])
                        footprint[a][b+1] = c + 1

    print(res)
        


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

signed main(){
  fastio
  string s,t;cin>>s>>t;
  s+=t[t.size()-1];
  if(s==t){
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }
  return 0;
}

Measured memory_bytes: 3636
from collections import deque

N,q = map(int,input().split())
A = [list(map(str,input().split())) for i in range(N)]
A = [[A[i][0],int(A[i][1])] for i in range(N)]

a = deque(A)
time = 0
while len(a) > 0:
    temp = a.popleft()
    if temp[1] - q <= 0:
        time += temp[1]
        print(temp[0],time)
    else:
        time += q
        temp[1] -= q
        a.append(temp)



Measured memory_bytes: 18908
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define Fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define deb(x) cout<<#x<<" "<<x<<endl;
#define all(v) v.begin(),v.end()
#define endl '\n'
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void judge() {
#ifndef ONLINE_JUDGE
	FILE_READ_IN
	FILE_READ_OUT
#endif
}

int main() {
	Fast;
	int t = 1;
	judge();
	// cin >> t;
	while (t--) {
		int n;
		cin >> n;
		if (n % 2 == 0) {
			cout << -1 << endl;
			return 0;
		}
		int r = 7 % n;
		if (r == 0) {
			cout << 1 << endl;
			return 0;
		}
		int ans = -1;
		for (int i = 2; i < 100000000; i++) {
			r *= 10;
			r += 7;
			r %= n;
			if (r == 0) {
				ans = i;
				break;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3644
#include<stdio.h>
void quicksort(int a[],int s,int t){
  if(s<t){
    int i=s,j=t,p=a[(s+t)/2];
    while(1){
      while(a[i]<p)i++;
      while(p<a[j])j--;
      if(i>=j)break;
      a[i]^=a[j]^=a[i]^=a[j];
      i++;j--;
    }
    quicksort(a,s,i-1);quicksort(a,j+1,t);
  }
}

int main(){
  int n,k,a[200001]={},l=0,i,t;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){scanf("%d",&t);if(!a[t])l++;a[t]++;}
  quicksort(a,0,n);
  t=0;for(i=n-l;i<n-k;i++)t+=a[i+1];
  printf("%d",t);
}


Measured memory_bytes: 2508
#include<stdio.h>

#define MAX 100

int main(){
  int i,j,n,minj,count,A[MAX+1];

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

  count = 0;

  for(i=0;i<n;i++){
    minj = i;
    for(j=i;j<n;j++)
      if(A[minj] > A[j])minj = j;
    A[n] = A[i];
    A[i] = A[minj];
    A[minj] = A[n];
    if(i != minj)count++;
  }

  for(i=0;i<n;i++){
    if(i < n - 1)printf("%d ",A[i]);
    else printf("%d\n%d\n",A[i],count);
  }

  return 0;
}

Measured memory_bytes: 600
# -*- coding: utf-8 -*-

def solve():
    *x1, = map(int, input().split())
    *x2, = map(int, input().split())
    *x3, = map(int, input().split())
    x = x1 + x2 + x3
    if max(x.count(i) for i in range(1,5)) <= 2:
        res = 'YES'
    else:
        res = 'NO'
    return str(res)
if __name__ == '__main__':
    print(solve())


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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int N, X;

signed main() {
    cin >> N >> X;
    vi L(N);
    rep(i, 0, N) cin >> L[i];

    int ans = 1, now = 0;
    rep(i, 0, N) {
        now += L[i];
        if(now <= X) ans++;
        else break;
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

using int64 = long long;

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

  int n;
  cin >> n;
  vector<int> hs(n);
  for (int i = 0; i < n; i++) cin >> hs[i];

  int min_value = hs[n - 1];
  bool ans = true;
  for (int i = n - 2; i >= 0; i--) {
    if (hs[i] >= min_value + 2) {
      ans = false;
    }
    min_value = min(min_value, hs[i]);
  }
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include<stdio.h>


int main(){
    int a[3002];
    int b[3002];
    int j,i;
    i = 0;
    while(1){
        int temp1,temp2;
        scanf("%d%d",&temp1,&temp2);
        if(temp1 >= temp2){
            a[i] = temp2;
            b[i] = temp1;
            
        }
        else{
            a[i] = temp1;
            b[i] = temp2;
        }
        if(a[i]==0){
          if(b[i]==0)
             break;
        }
        i++;    
    }
    for(j=0;j<i;j++){
        printf("%d %d\n",a[j],b[j]);
    }
    return 0;
    
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long h,w,i,ans=1e9;
  cin >> h >> w;
  if (h%3==0||w%3==0){
    cout << 0 << endl;
    return 0;
  }
  long a,b,c;
  for (i=1;i<=h/2;i++){
    a=i*w;
    if (((h-i)*w)%2==0) b=c=(h-i)*w/2;
    else if (h-i>w){
      b=w*(h-i-1)/2;
      c=w*(h-i+1)/2;
    }else{
      b=(w-1)*(h-i)/2;
      c=(w+1)*(h-i)/2;
    }
    ans=min(ans,max({a,b,c})-min({a,b,c}));
  }
  for (i=1;i<=w/2;i++){
    a=i*h;
    if ((h*(w-i))%2==0) b=c=h*(w-i)/2;
    else if (w-i>h){
      b=h*(w-i-1)/2;
      c=h*(w-i+1)/2;
    }else{
      b=(h-1)*(w-i)/2;
      c=(h+1)*(w-i)/2;
    }
    ans=min(ans,max({a,b,c})-min({a,b,c}));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

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

ll rot(ll c, int r){
    ll p[4];
    FORR(i,3,0){
        p[i] = c % 1000;
        c /= 1000;
    }
    ll ret = 0;
    REP(i,4){
        ret = 1000 * ret + p[(i+r)%4];
    }
    return ret;
}

ll col(ll c, int x){
    REP(i,3-x) c /= 1000;
    return c % 1000;
}

ll make(ll a, ll b, ll c, ll d){
    return 1000000000LL * a + 1000000 * b + 1000 * c + d;
}

ll calc(VVL c){
    return 0;
    int n = c.size();
    VVL dp(n+1, VL(16));
    dp[0][0] = 1;
    REP(i,n) REP(mask,16){
        dp[i+1][mask] += dp[i][mask];
        REP(j,4){
            if ((mask >> j) & 1) continue;
            dp[i+1][mask | (1 << j)] += dp[i][mask] * c[i][j];
        }
    }

    // REP(i,n){
    //     REP(j,4) cout << c[i][j] << " ";
    //     cout<< endl;
    // }

    // REP(i,n+1){
    //     REP(j,16) cout << dp[i][j] << " ";
    //     cout << endl;
    // }


    return dp[n][15];
}

int main() {
    int n;
    cin >> n;
    VL c(n);
    REP(i,n){
        ll tmp = 0;
        REP(j,4){
            ll x;
            cin >> x;
            tmp = 1000 * tmp + x;
        }
        c[i] = tmp;
        FOR(j,1,3) c[i] = min(c[i], rot(tmp, j));
    }

    map<ll, ll> mp;
    REP(i,n) mp[c[i]]++;

    // for (PL p : mp){
    //     cout << p.first << " " << p.second << endl;
    // }

    ll ans = 0;
    REP(i,n) REP(j,i) REP(r,4){
        ll c1 = c[i], c2 = rot(c[j], r);
        mp[c1]--;
        mp[c[j]]--;

        ll cs[4];
        cs[0] = make(col(c1,1), col(c1,0), col(c2,1), col(c2,0));
        cs[1] = make(col(c1,2), col(c1,1), col(c2,0), col(c2,3));
        cs[2] = make(col(c1,3), col(c1,2), col(c2,3), col(c2,2));
        cs[3] = make(col(c1,0), col(c1,3), col(c2,2), col(c2,1));

        REP(x,4){
            ll tmp = cs[x];
            FOR(p,1,3) cs[x] = min(cs[x], rot(tmp, p));
        }

        map<ll, ll> side;
        REP(x,4) side[cs[x]]++;

        ll tmp = 1;
        for (PL p : side){
            ll col = p.first;
            ll cnt = p.second;
            if (!mp.count(col) || mp[col] < cnt){
                tmp = 0;
            }else{
                ll perm = 1;
                REP(x,cnt) perm *= mp[col] - x;
                if (col == rot(col, 1)){
                    REP(x,cnt) perm *= 4;
                }else if (col == rot(col, 2)){
                    REP(x,cnt) perm *= 2;
                }
                tmp *= perm;
            }
        }

        ans += tmp;
        mp[c1]++;
        mp[c[j]]++;
    }
    cout << ans / 3 << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'

function main(input) {
    let a = Number(input.split('\n')[0].split(' ')[0]);
    let b = Number(input.split('\n')[0].split(' ')[1]);
    let c = Number(input.split('\n')[0].split(' ')[2]);
    let d = Number(input.split('\n')[0].split(' ')[3]);
    let count1 = 0;
    let count2 = 0;
    while(1) {
        if ((c - b) > 0) {
            count1++;
            c = c - b;
        } else {
            break;
        }
    }
    while(1) {
        if ((a - d) > 0) {
            count2++;
            a = a - d;
        } else {
            break;
        }
    }
    if (count1 <= count2) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}

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

Measured memory_bytes: 29592
#include <iostream>
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;

int main() {
    int q, x;
    char com[20];

    list<int> v;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%s", com);
        if (com[0] == 'i') {
            scanf("%d", &x);
            v.push_front(x);
        } else if (com[6] == 'L') {
            v.pop_back();
        } else if (com[6] == 'F') {
            v.pop_front();
        } else if (com[0] == 'd') {
            scanf("%d", &x);
            for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
                if (*it == x) {
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for (list<int>::iterator it = v.begin(); it != v.end(); it++){
        if (i++) printf(" ");
        printf("%d", *it);
    }
    printf("\n");

    return 0;

}

Measured memory_bytes: 34356
#include <bits/stdc++.h>
typedef long long int ll;
#define Y cout<<"YES\n"
#define N cout<<"NO\n"
#define YL cout<<"Yes\n"
#define NL cout<<"No\n"
#define pb push_back
#define cases long long int t;cin>>t;while(t--)
#define fio ios::sync_with_stdio(false); cin.tie(0)
#define foi(a,n) for(ll i=a;i<n;i++)
#define foir(a,n) for(ll i=a;i>=n;i--)
#define foj(a,n) for(ll j=a;j<n;j++)
#define fok(a,n) for(ll k=a;k<n;k++)
#define ALL(v) (v).begin(), (v).end() 
#define twod(n,m) vector<vector<int> > arr( n , vector<int> (m, 0))
#define prs(s,n) for(ll i=0;i<n;i++)cout<<s[i];
#define pra(arr,n) for(ll i=0;i<n;i++)cout<<arr[i]<<" ";
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;
using namespace std;
int main() 
{
	fio;
  long long int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
  if(a==0)
    cout<<"1";
 	else if(b==0)
    cout<<"2";
  else if(c==0)
    cout<<"3";
  else if(d==0)
    cout<<"4";
  else if(e==0)
    cout<<"5";
}


Measured memory_bytes: 3520
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b;
    scanf("%d %d", &a, &b);
    string ans;
    if(a > 0){
        ans = "Positive";
    }
    else if(a <= 0 && b >= 0){
        ans = "Zero";
    }
    else {
        if((b - (a - 1)) % 2 == 0){
            ans = "Positive";
        }
        else {
            ans = "Negative";
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main()
{
    int h, n, i, x;
    vector<int> v;

    cin>>h>>n;

    for(i=0; i<n; i++){
        cin>>x;
        v.push_back(x);
    }

    if(h <= accumulate(v.begin(), v.end(), 0))
        cout<<"Yes";
    else
        cout<<"No";


}


Measured memory_bytes: 892
N = int(input())
works = []
time = 0
for _ in range(N):
    cost, deadline = map(int, input().split())
    works.append((deadline, cost))

works.sort()
# print(works)

for item in works:
    deadline, cost = item[0], item[1]
    # print(deadline)
    # print(cost)
    time += cost
    if time > deadline:
        print('No')
        exit()

print('Yes')


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

int main(){
    long sum = 0;
    int max = -1000000;
    int min = 1000000;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        if (a > max){
            max = a;
        }
        if (a < min){
            min = a;
        }
        sum += a;
    }
    cout << min << " " << max << " "<< sum << endl;
}


Measured memory_bytes: 3120
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
S = list(set(s))  #計算削減のため
cnts = [0]
for i in range(len(S)):
	cnts.append(s.count(S[i]) - t.count(S[i]))
print(max(cnts))


Measured memory_bytes: 3060
#include <stdio.h>

#define Max 100

void  swap(int *x, int *y)
{
    int  buff;
	
	buff = *x;
	*x = *y;  
	*y = buff;
}

int selectionSort(int A[Max], int N) {
	int i, j, minj;
	int count = 0;

	for (i = 0; i < N; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (A[j] < A[minj])
				minj = j;
		}
		if (i != minj) {
			swap(&A[i], &A[minj]);
			count++;
		}
	}

	return count;
}

int main( ) {
	int N, i, count;
	int num[Max];

	scanf("%d", &N);

	for (i = 0; i < N; i++) scanf("%d", &num[i]);

	count = selectionSort(num, N);

	for (i = 0; i < N - 1; i++)
		printf("%d ", num[i]);
	printf("%d\n", num[N - 1]);

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

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#define loop(i,n) for(int i = 0; i < n; i++)
using namespace std;

static const int MAX_N = 100;

int N;
int F[MAX_N][10];
int P[MAX_N][11];

int main(){
  cin >> N;
  loop(i,N) loop(j,10) cin >> F[i][j];
  loop(i,N) loop(j,11) cin >> P[i][j];
  bool check[10];
  int ans = 0;
  loop(i,N){
    if(F[i][0]) ans+= P[i][1];
    else ans+= P[i][0];
  }
  for(int i=2; i<=1023; i++){
    loop(j,10) check[j] = 0;
    int num = i;
    int count = 0;
    while(num>0){
      if(num%2==0) check[count] = 0;
      else check[count] = 1;
      count++;
      num/=2;
    }
    int tmp_ans = 0;
    loop(j,N){
      int c = 0;
      loop(k,10) if(check[k] && F[j][k]) c++;
      tmp_ans+=P[j][c];
    }
    if(tmp_ans > ans) ans = tmp_ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s[0]=='R' && s[1]=='R' && s[2]=='R')cout << 3 << endl;
  else if(s[1]=='R' && s[2]=='R')cout << 2 << endl;
  else if(s[0]=='R' && s[1]=='R')cout << 2  << endl;
  else if(s[0]=='R')cout << 1 << endl;
  else if(s[1]=='R')cout << 1 << endl;
  else if(s[2]=='R')cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 3624
import numpy as np
N = int(input())
A =list(map(int, input().split(" ")))

if 0 in A:
    print(0)
    exit(0)
    
ret = 1
for a in A:
    ret *= a
    if len(str(ret)) >= 19 and ret != 10 ** 18:
        print(-1)
        exit(0)
    

if len(str(ret)) >= 19 and ret != 10**18:
    print(-1)
else:
    print(ret)


Measured memory_bytes: 40336
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string> //文字列
#include <iomanip> //doubleの桁数指定
#include <list> //前後に数値を入れれる配列
#include <map> //map



#define REP(i,m,n) for(ll i = (ll) (m);i < (ll) (n);i++) //forの短縮
#define rep(i,n) REP(i,0,n) //REPが0の時
#define ll long long int

using namespace std;

double PI = 3.141592653589793; //円周率

//常設関数↓

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

//degree → radian
ll chg_DegRad(int deg) {
	return deg * PI / 180.0;
}

//radian → degree
ll chg_RadDeg(int rad) {
	return rad * 180.0 / PI;
}

//提出コード↓

int n;
pair<string, pair<int,int> > p[100];
string s;




int main() {
	
	cin >> n;
	rep(i, n) {
		cin >> p[i].first >> (p[i].second).first;
		(p[i].second).second = i + 1;
	}
	sort(p,p + n);
	rep(i, n) {
		REP(j,i + 1, n) {
			if (p[i].first == p[j].first) {
				if ((p[i].second).first < (p[j].second).first) {
					auto tmp = p[i];
					p[i] = p[j];
					p[j] = tmp;
				}
			}
		}
	}
	rep(i, n) {
		cout << (p[i].second).second << endl;
	}



	return 0;
}



Measured memory_bytes: 256
import numpy as np
N = int(input())
xlist = list(map(int, input().split()))
ans = "NO"
#降順になっていない部分の数をカウント
minus_gaps = np.count_nonzero(np.diff(xlist)<0)
#全て降順になっていれば、それでOK
if minus_gaps == 0:
    ans = "YES"
#降順でない部分が2つの場合は、その2つを入れ替えて、全て降順になるか確認
elif minus_gaps == 2:
    tmpList = np.where(np.diff(xlist)<0)
    xlist[tmpList[0][0]],xlist[tmpList[0][1]+1] = xlist[tmpList[0][1]+1], xlist[tmpList[0][0]]
    if np.count_nonzero(np.diff(xlist)<0) == 0:
        ans = "YES"
#あとは全部NO
print(ans)

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

int cnt[1005];
const int mod=1e9+7;

int main(){
  int n;
  cin>>n;
  for(int i=2;i<=n;i++){
    int a=i;
    for(int j=2;j<=i;j++){
      while(a%j==0){
	cnt[j]++;
	a/=j;
      }
    }
  }
  ll ans=1;
  for(int i=2;i<=n;i++){
    if(cnt[i]) ans=ans*(cnt[i]+1)%mod;
  }
  cout<<ans<<endl;
  return 0;
}




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

int main(){
 int N, result=0,flag=true;
 cin >> N;
 int A[N];
  
 for(int i=0;i<N;i++){
   	cin >> A[i];
 }
  
 while(flag){
   for(int i=0;i<N;i++){
   	if(A[i]%2==1) { flag=false; break; }
    A[i] /= 2;
   }
   if(flag) result++;
 }
 
  cout << result << endl;
}

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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    ll h, w; int n; cin>>h>>w>>n;
    map<P, int> mp;
    for(int i=0; i<n; i++){
        int a, b; cin>>a>>b;
        a--, b--;
        for(int x=-2; x<=0; x++){
            for(int y=-2; y<=0; y++){
                if(0 <= x+b && x+b < w && 0 <= y+a && y+a < h){
                    if(x+b+2 < w && y+a+2 < h){
                        mp[P(y+a, x+b)]++;
                    }
                } 
            }
        }
    }

    vector<int> ans(10, 0);
    set<P> st;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        ans[itr->second]++;
        st.insert(P(itr->first.first, itr->first.second));
    }
    cout << (h-2)*(w-2) - st.size() << endl;
    for(int i=1; i<=9; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 98688
A=int(input())
B=list(map(int,input().split()))
ans=[0]*A
ans[0]=B[0]
if A>=3:
    for i in range(1,A-1):
        ans[i]=min(B[i],B[i-1])
        ans[i+1]=B[i]
elif A==2:
    ans[1]=B[0]
print(sum(ans))

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

int main() {
  int n;
  cin >> n;
  
  int max_h = 0;
  for(int i = 0; i < n; i++){
    int h;
    cin >> h;
    if(h > max_h){ max_h = h; }
    if(max_h - h > 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

char bufr[4400007];
int bufrl;
#define getchar_unlocked() bufr[bufrl++]

int c[200000];
void rsort_u32(void *base, const int count){
	uint32_t *a=base;
	uint32_t *b=c;
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(0<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(0<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(1<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(1<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(2<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(2<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(3<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(3<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
}
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int a[200000];
int b[200000];
int main(void){
	read(STDIN_FILENO, bufr, sizeof(bufr));
	int n=nextint();
	for(int i=0; i<n; i++){
		a[i]=nextint();
		b[i]=nextint();
	}
	rsort_u32(a, n);
	rsort_u32(b, n);
	int ans;
	if(n&1){
		int A=a[n/2], B=b[n/2];
		ans=B-A+1;
	}else{
		int A=a[n/2]+a[n/2-1], B=b[n/2]+b[n/2-1];
		ans=B-A+1;
	}
	printf("%d\n", ans);
}


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

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20];
void mypr(int n)
{
	int w;
	if (!n) { pc('0'); return; }
	w = 0; while (n) buf[w++] = n%10 + '0', n/=10;
	while (w--) pc(buf[w]);
}

#define MAX_N 500002
#define INF   0x7f7f7f7f

int a[MAX_N];
int w[MAX_N/2+2];
int cnt;

void merge_sort(int low, int high) 
{ 
	int i, j, k, p, mid; 

	if (low < high) {
		mid = (low + high) >> 1;
		merge_sort(low,   mid);
		merge_sort(mid+1, high);

cnt += high-low+1;

		p = mid-low+1;
		memcpy(w, a+low, p << 2);
		i = mid+1, j = 0; k = low;

		w[p] = INF;
		while (i <= high) {
			if (w[j] <= a[i]) a[k++] = w[j++];
			else              a[k++] = a[i++];
		}
		memcpy(a+k, w+j, (p-j) << 2);
	}
}

int main()
{
	int n, i;
	
	n = in(); for (i = 0; i < n; i++) a[i] = in();

	cnt = 0;
	merge_sort(0, n-1);

	mypr(a[0]); for (i = 1; i < n; i++) pc(' '), mypr(a[i]); pc('\n');
	mypr(cnt); pc('\n');
	return 0;
}


Measured memory_bytes: 4556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N = 85;
ll a[N];
void solve(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    ll mn = 1000;
    ll cr = 0;
    for(int i=1;i<n;i++){
        if(a[i]<a[i+1]){
            ll x =(mn)/a[i];
            cr+=x;
            mn-=x*a[i];
        }
        else if ( a[i]>a[i+1]){
            mn+=cr*a[i];
            cr = 0;
        }
    }
    mn+=cr*a[n];
    cr = 0;
    cout<<mn<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int MAX_N=200000;

int main(){
    ios::sync_with_stdio(false);
    int n;
    int a[MAX_N+5];
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    vector<int> ans={};
    if(n%2==1){
        for(int i=0;i<=((n-1)/2);i++){
            ans.push_back(a[n-1-2*i]);
        }
        for(int i=0;i<=((n-3)/2);i++){
            ans.push_back(a[2*i+1]);
        }
    }
    else{
        for(int i=0;i<=((n-2)/2);i++){
            ans.push_back(a[n-1-2*i]);
        }
        for(int i=0;i<=((n-2)/2);i++){
            ans.push_back(a[2*i]);
        }
    }
    rep(i,n){
        cout << ans[i] << " ";
    }
    return 0;
}

Measured memory_bytes: 3956
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int T;
    cin >> T;
    rep(i, T) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if(a < b || b > d) {
            output("No");
            continue;
        }
        ll tmp = a - ((a - b) / gcd(b, d) + 1) * gcd(b, d);
//        output(tmp);
        if(tmp > c) {
            output("No");
            continue;
        }
        if(a % gcd(b, d) > c && a % gcd(b, d) < b) {
            output("No");
            continue;
        }
        output("Yes");
    }
    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define endl "\n"
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/any.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
inline lint mex(vector<lint> s){
    lint res=0;
    sort(all(s));
    while(binary_search(all(s),res))res++;
    return res;
}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};

int main(){
    lint n;
    cin>>n;
    vec a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    rep(i,n-1)a[i+1]+=a[i];
    rrep(i,n-1){
        if(a[i]*2>=a[i+1]-a[i])continue;
        else{
            cout<<n-i-1;
            return 0;
        }
    }
    cout<<n;
}

Measured memory_bytes: 1024
#include <string>
#include <iostream>
#include <stdio.h>
#include <stack>

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int cmd, index, val;
  int num_stack, num_query;

  cin >> num_stack >> num_query;
  stack<int> st[num_stack];

  for (int i = 0; i < num_query; i++) {
    cin >> cmd;

    switch (cmd) {
      // push
      case 0:
        cin >> index >> val;
        st[index].push(val);

        break;
      // top
      case 1:
        cin >> index;
        if (st[index].empty()) {
          break;
        }
        cout << st[index].top() << endl;
        break;
      // pop
      case 2:
        cin >> index;
        if (st[index].empty()) {
          break;
        }
        st[index].pop();
        break;
    }
  }
}




Measured memory_bytes: 4328
from collections import deque

N, M, K = map(int, input().split())
G = [[] for i in range(N)]
NG = [set() for i in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    G[A - 1].append(B - 1)
    G[B - 1].append(A - 1)
    NG[A - 1].add(B - 1)
    NG[B - 1].add(A - 1)

for _ in range(K):
    A, B = map(int, input().split())
    NG[A - 1].add(B - 1)
    NG[B - 1].add(A - 1)
C = [-1] * N
CNT = [0] * N
c = 0
for i in range(N):
    if C[i] >= 0: continue
    Q = [i]
    C[i] = c
    CNT[c] += 1
    while Q:
        x = Q.pop()
        for y in G[x]:
            if C[y] == -1:
                C[y] = C[x]
                CNT[C[y]] += 1
                Q.append(y)
    c +=1
Y = [0] * N
for i in range(N):
    Y[i] = CNT[C[i]] - 1
for i in range(N):
    for j in NG[i]:
        if C[i] == C[j]:
            Y[i] -= 1
print(*Y)


Measured memory_bytes: 84968
using System;
using System.IO;

namespace ConsoleApp1
{
    class Minimal_Backgammon
    {
        public static void Main(string[] args)
        {

            while (true)
            {
                

                string[] temp = Console.ReadLine().Split(' ');
                int N = int.Parse(temp[0]); int T = int.Parse(temp[1]); int L = int.Parse(temp[2]); int B = int.Parse(temp[3]);
                if (N == 0 & T == 0 & L == 0 & B == 0) break;
                int[] map = new int[N + 1];
                double answer = 0;
                for (int numofL = 0; numofL < L; numofL++)
                {
                    map[int.Parse(Console.ReadLine())] = 1; //??????????????????????????¨???1?????£??\
                }
                for(int numofB = 0; numofB < B; numofB++)
                {
                    map[int.Parse(Console.ReadLine())] = -1; //????????????????????????????????¨???0?????£??\
                }
                double[,] prob= new double[T + 1,N + 1]; //prob[t,n]???t???????????????n??????????¢???????????????????????????¨??????
                prob[0, 0] = 1;

                for (int t = 0; t < T; t++)
                {
                    for (int n = 0; n < N; n++)
                    {
                        for (int i = 1; i <= 6; i++)
                        {
                            
                            int nextPos = n + i;
                            if (nextPos > N)
                            {
                                nextPos = 2*N-nextPos;
                            }
                            switch (map[nextPos])
                            {
                                case 1:
                                    if (t + 2 <= T) prob[t + 2, nextPos] += prob[t, n] / 6.0;
                                    break;
                                case -1:
                                    prob[t + 1, 0] += prob[t, n] / 6.0;
                                    break;
                                case 0:
                                    prob[t + 1, nextPos] += prob[t, n] / 6.0;
                                    break;

                            }
                        }
                    }
                }
                for(int j = 0; j <= T; j++)
                {
                    answer += prob[j, N];
                }
                Console.WriteLine("{0:0.000000}", answer);       
            }
        }
    }
}

Measured memory_bytes: 9600
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 5e5 + 20 ;
int n , k , a[N] , res[N] ;
set <int> st ;

pii seg[N << 2] ;

void modify (int p , int val , int v = 1 , int s = 0 , int e = n) {
	if (s + 1 == e) {
		seg[v] = pii(val , s) ;
		return ;
	}

	int mid = (s + e) >> 1 , lc = v << 1 , rc = lc | 1 ;

	if (p < mid) modify(p , val , lc , s , mid) ;
	else modify(p , val , rc , mid , e) ;

	seg[v] = max(seg[lc] , seg[rc]) ;
}

pii get (int l , int r , int v = 1 , int s = 0 , int e = n) {
	if (s >= r || e <= l) return pii(-1 , 0) ;
	if (s >= l && e <= r) return seg[v] ;

	int mid = (s + e) >> 1 , lc = v << 1 , rc = lc | 1 ;

	return max( get(l , r , lc , s , mid) , get(l , r , rc , mid , e) ) ;
}

inline void rel (int b) {
	int xl = b * k , xr = min(n , xl + k) ;

	pii p = get(xl , xr) ;
	int index = p.S ;

	if (a[index] && p == get(max(0 , index - k + 1) , min(n , index + k)))
		st.insert(index) ;
}

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

	cin >> n >> k ;
	for (int i = 0 ; i < n ; i ++) cin >> a[i] ;

	for (int i = 0 ; i < n ; i ++) modify(i , a[i]) ;

	for (int i = 0 ; i < n ; i += k) rel(i / k) ;

	for (int i = 0 ; i < n ; i ++) {
		int index = *st.rbegin() ;
		res[index] = n - i ;
		st.erase(index) ;
		a[index] = 0 ;
		modify(index , a[index]) ;
		
		int b = index / k ;

		rel(b) ;
		if (b) rel(b - 1) ;
		if (b + 1 <= (n - 1) / k) rel(b + 1) ;
	}

	for (int i = 0 ; i < n ; i ++) cout << res[i] << '\n' ;
}


Measured memory_bytes: 42496
#include<iostream>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
using namespace std;
using ll=long long;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}


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

  int N; cin>>N;
  int H[20];
  REP(i,N) cin>>H[i];

  int max=0;
  int cnt=0;
  REP(i,N){
    if(H[i]>=max){
      ++cnt;
      max=H[i];
    }else continue;
  }

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

Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 2;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

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

  int n;
  cin >> n;
  int fr = 0;
  set<int> st;
  rep(i, n)
  {
    int a;
    cin >> a;
    if (a >= 3200)
    {
      fr++;
    }
    else
    {
      st.insert(a / 400);
    }
  }

  int Min;
  if (st.empty())
    Min = 1;
  else
    Min = st.size();
  int Max = st.size() + fr;
  cout << Min << " " << Max << endl;
  return 0;
}


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

int arr[10005];

int tot = 0;
bool isprime(int);
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    for (int i = 0; i < n; i++)
    {
        if (isprime(arr[i]))
            tot++;
    }

    cout << tot << endl;

    return 0;
}

bool isprime(int num)
{
    if (num % 2 == 0 && num != 2)
        return false;
    for (int i = 3; i <= int(sqrt(double(num))); i += 2)
    {
        if (num % i == 0)
            return false;
    }
    return true;
}

Measured memory_bytes: 3084
#include<stdio.h>

int main(void){
    int count= 0;
    char S[3]={};
    char T[3]={};
    scanf("%s",S);
    scanf("%s",T);
    for(int i=0;i<3;i++){
        if(S[i]==T[i]){
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
h, w = list(map(int, input().split()))
n = int(input())
xs = list(map(int, input().split()))


def foo(xs):
    for i, x in enumerate(xs):
        for j in range(x):
            yield str(i+1)

left_to_right = True
gen = foo(xs)
for i in range(h):
    ys = []
    for j in range(w):
        ys.append(next(gen))
    if left_to_right:
        print(" ".join(ys))
    else:
        print(" ".join(reversed(ys)))
    left_to_right = not left_to_right


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

long long go(int currentIndex, vector<int>& values, vector<int>& weights, int capacity, vector<vector<long long>>& dp){

    if(capacity <= 0 or currentIndex >= values.size()) return 0;

    long long &ans = dp[currentIndex][capacity];
    if(ans != -1) return ans;

    long long profit1 = 0;
    if(capacity - weights[currentIndex] >= 0){
        profit1 = go(currentIndex + 1,  values, weights, capacity - weights[currentIndex], dp) + values[currentIndex];
    }
    long long profit2 = go(currentIndex + 1, values, weights, capacity, dp);
    ans = max(profit1, profit2);

    return ans;
}

void testcase(){
    int n, w;
    cin >> n >> w;

    vector<int> values(n), weights(n);
    for(int i = 0; i < n; i++) cin >> weights[i] >> values[i];

    vector<vector<long long>> dp(n + 1, vector<long long>(w + 1, -1));
    go(0, values, weights, w, dp);
    cout << dp[0][w];
}

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

#ifdef AKP
    freopen("in.txt","r", stdin);
#endif

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

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

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

  set<string> st;
  bool flg=true;
  string s;
  cin >> s;
  st.insert(s);
  char t=s[s.size()-1];
  for (int i=1; i<n; i++) {
    cin >> s;
    st.insert(s);

    if (s[0]!=t) flg=false;
    t=s[s.size()-1];
  }

  if (st.size()==n && flg) cout << "Yes";
  else cout << "No";
}

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

/*
int stoi(string str){
    int num = 0;
    for(int i=0; i<str.length(); i++){
        num += num*10+ int(str[i])-'0';
    }
    return num;
}*/

void bubbleSort(string num[][3], int N){
    string temp[3];
    for(int i=0; i<N; i++){
        for(int j=N-1; j>i; j--){
            if(num[j][0] < num[j-1][0]){
                temp[0] = num[j][0];
                temp[1] = num[j][1];
                temp[2] = num[j][2];
                num[j][0] = num[j-1][0];
                num[j][1] = num[j-1][1];
                num[j][2] = num[j-1][2];
                num[j-1][0] = temp[0];
                num[j-1][1] = temp[1];
                num[j-1][2] = temp[2];
            }
            else if(num[j][0] == num[j-1][0]){
                if(stoi(num[j][1]) > stoi(num[j-1][1])){
                temp[0] = num[j][0];
                temp[1] = num[j][1];
                temp[2] = num[j][2];
                num[j][0] = num[j-1][0];
                num[j][1] = num[j-1][1];
                num[j][2] = num[j-1][2];
                num[j-1][0] = temp[0];
                num[j-1][1] = temp[1];
                num[j-1][2] = temp[2];
                }
            }
        }
    }
}

int main(){
    int N;
    string names[100][3];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> names[i][0] >> names[i][1];
        names[i][2] = to_string(i+1);
    }
    bubbleSort(names, N);
    for(int i=0; i<N; i++){
        cout << stoi(names[i][2])<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let k: i64 = read();
    let mut seq = vec![];
    for i in a..a + k {
        if i < a || b < i {
            continue;
        }
        seq.push(i);
    }
    for i in b - k + 1..b + 1 {
        if i < a || b < i {
            continue;
        }
        seq.push(i);
    }
    seq.sort();
    seq.dedup();
    for v in seq {
        println!("{}", v);
    }
}


Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
N, Q = [int(i) for i in input().split()]
tree = {i:[] for i in range(1,N+1)}
cost_ls = {i:0 for i in range(1,N+1)}

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


def plus(node, _from):
    #cost_ls[node] += num
    for child in tree[node]:
        if child == _from:
            continue
        cost_ls[child] += cost_ls[node]
        plus(child, node)
 
for _ in range(Q):
    p, x = map(int, input().split())
    cost_ls[p] += x
 
plus(1, 0)
 
print(' '.join(str(cost_ls[i]) for i in range(1,N+1)))

Measured memory_bytes: 267752