akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<string>
typedef long long ll;
using namespace std;

char a[100000];
int main()
{
	int i,j,l,cnt,flag;
	scanf("%s",a);
	l = strlen(a);
	for(i = 0;i < l; i++)
	{
		flag = 1;
		cnt = 0;
		for(j = 0; j < l ; j++)
		{
			if(a[j] == a[i])
			cnt++;
		}
		if(cnt % 2 == 1)
		{
			flag = 0;
			break;
		}
	}
	if(flag == 1 )
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  string s,t;
  cin >> n >> s >> t;
  REP(i,n){
    bool flag = true;
    FOR(p,i,n){
      if(s[p]!=t[p-i]){
        flag = false;
        break;
      }
    }
    if(flag){
      cout << 2*i+(n-i) << '\n';
      return 0;
    }
  }
  cout << 2*n << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> v(N);
  for (auto &e : v) {
    cin >> e;
  }
  sort(v.begin(), v.end());

  double max_value = v[0];
  for (size_t i = 1; i < N; ++i) {
    max_value = (max_value + v[i]) / 2;
  }
  cout << max_value << "\n";
}


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

int main() {
    string S, T;
    cin >> S >> T;

    for (int i = S.size() - T.size() + 1; i >= 0; i--) {
        bool ok = true;
        rep(j, T.size()) {
            if (S[i + j] != T[j] && S[i + j] != '?')
                ok = false;
        }
        if (ok) {
            rep(j, T.size()) S[i + j] = T[j];
            break;
        }
        if(i==0)
            S = "UNRESTORABLE";
    }

    rep(i, S.size()) S[i] == '?' ? cout << "a" : cout << S[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
#include<string.h>

int North(void);
int East(void);
int West(void);
int South(void);
int Right(void);
int Left(void);

int top,front,r,l,back,bottom;

int main(void){
  int n,sum,i;
  char s[7];
  
  while(1){
    scanf("%d",&n);
    if(n==0)break;

    top=1;
    front=2;
    r=3;
    l=4;
    back=5;
    bottom=6;

    sum=top;

    for(i=0;i<n;i++){
      scanf(" %s",s);

      if(strcmp(s,"North")==0)sum+=North();
      else if(strcmp(s,"East")==0)sum+=East();
      else if(strcmp(s,"South")==0)sum+=South();
      else if(strcmp(s,"West")==0)sum+=West();
      else if(strcmp(s,"Left")==0)sum+=Left();
      else if(strcmp(s,"Right")==0)sum+=Right();
    }
    printf("%d\n",sum);
  }
  return 0;
}

int North(void){
  int t;

  t=top;
  top=front;
  front=bottom;
  bottom=back;
  back=t;

  return top;
}

int East(void){
  int t;

  t=top;
  top=l;
  l=bottom;
  bottom=r;
  r=t;

  return top;
}

int West(void){
  int t;

  t=top;
  top=r;
  r=bottom;
  bottom=l;
  l=t;

  return top;
}

int South(void){
  int t;

  t=top;
  top=back;
  back=bottom;
  bottom=front;
  front=t;

  return top;
}

int Right(void){
  int t;

  t=front;
  front=r;
  r=back;
  back=l;
  l=t;

  return top;
}

int Left(void){
  int t;

  t=front;
  front=l;
  l=back;
  back=r;
  r=t;

  return top;
}

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

using namespace std;

#define int long long
#define sz(x) (int)x.size()
#define yes cout << "Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ft first
#define sd second
#define FOR(i, b, n) for(int i=b;i<n;i++)
#define REP(i, n) FOR(i, 0, n)
using pii = pair<int, int>;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vd = vector<double>;
mt19937_64 rnd(time(0));

void start() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    // cerr << fixed << setprecision(10);
#ifdef MY
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}

signed main() {
    start();
    int n, m, k, c = 0;
    cin >> n >> m >> k;
    vi a(n + 1), b(m + 1);
    for (int i = 0, l; i < n; ++i)cin >> l, a[i + 1] = a[i] + l;
    for (int i = 0, l; i < m; ++i)cin >> l, b[i + 1] = b[i] + l;

    for (int i = 0; i <= n; ++i) {
        if (a[i] > k)
            break;
        int l = 0, r = m, mt;
        while (r - l > 1) {
            mt = (l + r) / 2;
            if (a[i] + b[mt] > k)
                r = mt;
            else
                l = mt;
        }
        c = max(c, l + i);
        if (a[i] + b[r] <= k)
            c = max(c, r + i);
    }
    cout << c;


}








Measured memory_bytes: 6332
n=int(input())
sp=[list(map(str,input().split())) for l in range(n)]
sn=[]
ss=[]
sn2=[]
ss2=[]
for i in range(n):
    sn.append(sp[i][0])
    ss.append(sp[i][1])
sn2=sorted(sn)
ss=sorted(range(len(sn)), key=lambda k: sn[k])
for i in range(n):
    ss2.append(int(sp[ss[i]][1]))
for i in range(n):
    for j in range(n-1,i,-1):
        if sn2[j]==sn2[j-1]:
            if ss2[j-1]<ss2[j]:
                ss[j-1],ss[j]=ss[j],ss[j-1]
                ss2[j-1],ss2[j]=ss2[j],ss2[j-1]

for i in range(n):
    print(ss[i]+1)


Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
#define YMAX 250001
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,P[200001];
	int zoukaretu[200001]={0};
	scan(N);
	rep(i,N){
		scan(P[i]);
		if(zoukaretu[P[i]-1]==0){
			zoukaretu[P[i]]=1;
		}
		else{
			zoukaretu[P[i]]=zoukaretu[P[i]-1]+1;
		}
	}
	int zoukaretumax=0;
	rep1(i,N){
		zoukaretumax=max(zoukaretumax,zoukaretu[i]);
	}
	prin(N-zoukaretumax);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    ll N, H; cin >> N >> H;
    vel a(N), b(N); rep(i,N) cin >> a[i] >> b[i];

    sort(rall(a)); sort(rall(b));

    int cnt = 0;
    rep(i,N) {
        if(b[i] > a[0]) { H -= b[i]; cnt++; }
        else break;
        if(H <= 0) break;
    }
    if(H <= 0) {cout << cnt << endl; return 0;}
    
    while(true) {
        H -= a[0];
        cnt++;
        if(H <= 0) break;
    } 
    cout << cnt << endl;
    return 0;

    
}

Measured memory_bytes: 1792
package main

import "fmt"

func isPrime(x int) bool {
	if x < 2 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if x%i == 0 {
			return false
		}
	}

	return true
}

func main() {
	var cnt int

	//cnt = 0
	fmt.Scanf("%d", &cnt)
	for i := 1; 10*i+1 <= 55555 && cnt > 0; i++ {
		if isPrime(10*i + 1) {
			cnt--
			fmt.Printf("%d ", 10*i+1)
		}
	}

	fmt.Printf("\n")
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		long max = sc.nextLong();
		long count = 0;
		long[] c = new long[number];
		for(int i = 0; i < number; i++){
			long a = sc.nextLong();
			c[i]=a;
		}
		for(int i = 1; i < number; i++){
			if(c[i-1]+c[i]>max){
				count += c[i]-max+c[i-1];
				if(((c[i-1]+c[i])-max) < c[i]){
					
					c[i]=max-c[i-1];
				}else{
					
					
					c[i]=0;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 62524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> a(N, 1);
	for (int i = 0; i < K; ++ i) {
		int d;
		cin >> d;
		for (int j = 0; j < d; ++ j) {
			int x;
			cin >> x;
			a[x-1] = 0;
		}
	}
	int res = 0;
	for (int x : a) res += x;
	cout << res << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

void solve(){
	//write here
    int n,k;
    cin>>n>>k;
    vector<ll> w(n), v(n);
    rep(i,0,n){
        cin>>w[i]>>v[i];
    }
    ll dp[k+1];
    memset(dp,0,sizeof(dp));
    for (int i = 0 ; i<n ; i++){
        for (ll j = k;  j>=w[i] ; j--){
            dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
        }
    }
    cout<<dp[k]<<endl;
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	
		solve();
	return 0;
}

Measured memory_bytes: 4436
class uf_tree():

    def __init__(self,n):
        self.n = n
        self.par = [i for i in range(n)]

    def indep(self):
        dep =0
        for i in range(self.n):
            if i == self.par[i]:
                dep += 1

        return dep

    def unite(self,child,mas):
        if self.root(child) == self.root(mas):
            return
        else:
            self.par[self.root(child)] = self.root(mas)

    def root(self,i):
        if self.par[i] == i:
            return i
        else:
            self.par[i] = self.root(self.par[i])
            return self.par[i]

    def same(self,x,y):
        if self.root(x) == self.root(y):
            return True
        else:
            return False

n,m = map(int,input().split())
arr = list(map(int,input().split()))
tree = uf_tree(n)
for i in range(m):
    a,b = map(int,input().split())
    tree.unite(a-1,b-1)

ans = 0
for i in range(n):
    if tree.same(arr[i]-1,i):
        ans += 1

print(ans)



Measured memory_bytes: 13812
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

struct Guy{
	int sc;
	int L;
	bool ok;
};

typedef long long ll;
int n;
Guy guys[101];

ll dp[2][1<<17];

int main(){
	while(cin>>n&&n!=0){
		for(int i=0;i<n;i++){
			int m;
			cin>>m>>guys[i].L;
			guys[i].sc=0;
			guys[i].ok=true;
			for(int j=0;j<m;j++){
				int s,e;
				cin>>s>>e;
				s-=6;
				e-=6;
				for(int k=s;k<e;k++){
					if(!((guys[i].sc>>k)&1))guys[i].sc|=(1<<k);
					else guys[i].ok=false;
				}
			}
		}
		for(int j=0;j<(1<<17);j++)dp[n%2][j]=0;
		for(int i=n-1;i>=0;i--){
			int cur=(i+1)%2;
			int nxt=(i)%2;
			for(int j=0;j<(1<<17);j++)dp[nxt][j]=0;
			for(int j=0;j<(1<<17);j++){
				dp[nxt][j]=dp[cur][j];
				if(guys[i].ok)if(!(j&guys[i].sc))dp[nxt][j]=max(dp[nxt][j],dp[cur][j|guys[i].sc]+guys[i].L);
			}
		}
		ll res=dp[0][0];
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 2912
use std::io::Write;

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn main() {

    let (n, k): (usize, usize) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        let mut ws = s.split_whitespace();
        let a = ws.next().unwrap().parse().unwrap();
        let b = ws.next().unwrap().parse().unwrap();
        (a, b)
    };

    let (r, s, p): (usize, usize, usize) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        let mut ws = s.split_whitespace();
        let a = ws.next().unwrap().parse().unwrap();
        let b = ws.next().unwrap().parse().unwrap();
        let c = ws.next().unwrap().parse().unwrap();
        (a, b, c)
    };

    let t: String = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right().to_owned();
        s
    };

    const ROCK: usize = 0;
    const SCISSORS: usize = 1;
    const PAPER: usize = 2;
    let mut counts = vec![0; 3];
    for c in t.chars() {
        if c == 'r' {
            counts[ROCK] += 1;
        } else if c == 's' {
            counts[SCISSORS] += 1;
        } else {
            counts[PAPER] += 1;
        }
    }

    let mut ans = counts[ROCK] * p + counts[SCISSORS] * r + counts[PAPER] * s;

    let t: Vec<char> = t.chars().collect();
    for i in 0..k {
        let mut j = i;
        let mut count = 1;
        let mut previous = 'a';
        // debugln!("k: {}", k);
        while j < n {
            // debugln!("j: {}", j);
            // debugln!("previous: {}", previous);
            if t[j] == previous {
                count += 1;
                if count % 2 == 0 {
                    // debugln!("j: {}, {}", j, score(t[j], r, s, p));
                    ans -= score(t[j], r, s, p);
                }
            } else {
                previous = t[j];
                count = 1;
            }

            j += k;
        }
    }

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

fn score(hand: char, r: usize, s: usize, p: usize) -> usize {
    if hand == 'r' {
        p
    } else if hand == 's' {
        r
    } else {
        s
    }
}


Measured memory_bytes: 4352
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    x, y = _ia()
    if y % 2 == 0 and (2*x <= y <= 4*x):
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    print(main())


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

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		long[] min = a.clone();

		long answer = Long.MAX_VALUE;
		for (int k = 0; k < n; k++) {
			long cost = (long) k * x;
			for (int i = 0; i < n; i++) {
				min[i] = Math.min(min[i], a[(i - k + n) % n]);
				cost += min[i];
			}
			answer = Math.min(answer, cost);
		}

		System.out.println(answer);
	}
}


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

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

	int i = 0, a = 0;
	while (i < n)
	{
		do
		{
			a++;
		}
		while (a % 100 == 0);
		i++;
	}

	for (size_t i = 0; i < d; i++)
	{
		a *= 100;
	}

	cout << a << endl;
	return 0;
}


Measured memory_bytes: 764
function maxHeapify(heap, size, id) {
    const left = id * 2;
    const right = id * 2 + 1;
    let largest = id * 2 <= size && heap[left] > heap[id] ? left : id;

    if(id * 2 + 1 <= size && heap[right] > heap[largest]) {
        largest = right;
    }

    if(largest !== id){
        const temp = heap[id];
        heap[id] = heap[largest];
        heap[largest] = temp;
        maxHeapify(heap, size, largest);
    }
}

function insert(heap, key) {
    heap[heap.length] = -Infinity;
    heapIncreaseKey(heap, heap.length, key);
}

function heapIncreaseKey(heap, x, key) {
    if(key < heap[x]){
        return;
    }
    heap[x] = key;
    while(x > 1 && heap[Math.floor(x / 2)] < heap[x]){
        const temp = heap[x];
        heap[x] = heap[Math.floor(x / 2)];
        heap[Math.floor(x / 2)] = temp;
        x = Math.floor(x / 2);
    }
}

function extractMax(heap) {
    if(heap.length < 1){
        return;
    }
    const max = heap[1];
    heap[1] = heap.pop();
    maxHeapify(heap, heap.length, 1);
    return max;
}


function main(_stdin){
    const order = _stdin.split('\n');
    const heap = [null];

    order.forEach((e, i) => {
        const o = e.split(' ');
        if(o[0] === 'insert'){
            insert(heap, parseInt(o[1]));
        } else if(o[0] === 'extract'){
            console.log(extractMax(heap));
        }
    });
}


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





Measured memory_bytes: 292828
#include <iostream>
using namespace std;
#define fo(i,l,r) for (int i = l;i < r; i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    ll a[n];
    int ans = 0;
    fo(i,0,n) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            ll tmp = a[i];
            while (tmp > 0 && tmp % 2 == 0) {
                ans++;
                tmp /= 2;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string s, t;

	cin >> s >> t;

	cout << (int)(s[0] == t[0]) + (int)(s[1] == t[1]) + (int)(s[2] == t[2]) << endl;

	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	string a, b;
	cin >> a >> b;
	a += b;
	int num = 0;
	rep(i, a.size())num += (a[a.size() - 1 - i] - '0') * pow(10, i);
	for (int i = 1; i * i <= num; i++) {
		if (num == i * i) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
n=gets.to_i
a=gets.split.map(&:to_i)
x=[];y=[]

x[0]=a[0]
y[n-1]=a[-1]
(1..n-1).each{|i|
    x[i]=x[i-1].gcd a[i]
    y[n-1-i]=y[n-i].gcd a[n-1-i]
}
p [(1..n-2).map{|i|x[i-1].gcd y[i+1]}.max,x[-2],y[1]].compact.max

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

using namespace std;

/*int saiki(int i){
  int64_t x,y;
  if(i==0){
    x=2;
    y=0;
  }
  else if(i==1){
    x=1;
    y=0;
  }
  else{
    x=saiki(i-1);
    y=saiki(i-2);
  }
  return x+y;
}

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

  int64_t ans;

  ans=saiki(N);

  cout << ans << endl; 

}*/

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

  vector<int64_t> ans(N+1);
  ans.at(0)=2;
  ans.at(1)=1;
  for(int i=2;i<=N;i++){
    ans.at(i)=ans.at(i-1)+ans.at(i-2);
  }

  cout << ans.at(N) <<endl;

}



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

// m judge, v problems, first p problems
ll n, m, v, p;
ll a[100005], b[100005];

// score x is good
bool good(ll x) {
    // printf("Good %lld\n", x);

    if (x < p)
        return true;

    ll newsc = a[x] + m;

    {
        int j = 0;
        for (int i = 0; i < n; i++)
            if (i != x)
                b[j++] = a[i];
    }

    ll rem = m * (v - 1); // already burn m into newsc

    for (int i = 0; i < n - 1; i++) {
        ll canadd = i < p - 1 ? min(rem, m) : max(0ll, min(rem, min(newsc - a[i], m)));
        b[i] += canadd;
        rem -= canadd;
    }

    if (rem > 0) {
        // spend from front?
        // if v>p, i.e. judges can add many questions,
        // we have added every problem to newsc. i.e. if we add any more,
        // the problem cannot quality.
        // if v<p, i.e. judges can add few questions,
        // then the quota is already burnt.
        return false;
    }

    sort(b, b + n);
    reverse(b, b + n);

    return newsc >= b[p - 1];
}

bool obj(ll x) { return !good(x); }

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

    cin >> n >> m >> v >> p;
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }

    sort(a, a + n);
    reverse(a, a + n);

    ll req;
    {
        ll first = 0, last = n;
        ll it, cnt, step;
        cnt = last - first;

        while (cnt > 0) {
            it = first;
            step = cnt / 2;
            it += step;
            if (obj(it) < 1) {
                first = ++it;
                cnt -= step + 1;
            } else {
                cnt = step;
            }
        }

        cout << first << endl;
    }
}

Measured memory_bytes: 1792
n=int(input())
key=set()
j=0
c=0
for i in range(n):
    a,b=input().split()
    if a=='insert':
        key.add(b)
        j=j+1
    if a=='find':
        c=0
        if b in key:
            print("yes")
        else: print("no")


Measured memory_bytes: 30988
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var n = sc.nextInt()
  if(n >= 400 & n <= 599){println(8)}
  if(n >= 600 & n <= 799){println(7)}
  if(n >= 800 & n <= 999){println(6)}
  if(n >= 1000 & n <= 1199){println(5)}
  if(n >= 1200 & n <= 1399){println(4)}
  if(n >= 1400 & n <= 1599){println(3)}
  if(n >= 1600 & n <= 1799){println(2)}
  if(n >= 1800 & n <= 1999){println(1)}
}


Measured memory_bytes: 55212
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
ll cnt[10][10];//w,h
char vis[10][10];
ll maxcnt;
bool ban[10][10];
bool ok=false;
ll sharp;
void search(ll h,ll w){
 //cout<<h<<" "<<w<<endl;
 if(vis[h+1][w]=='#'&&!ban[h+1][w]){
  cnt[h+1][w]=cnt[h][w]+1;
  maxcnt=max(maxcnt,cnt[h+1][w]);
  //cout<<"h "<<h+1<<" "<<w<<" "<<cnt[h+1][j]<<" "<<cnt[h][w]<<endl;
  search(h+1,w);
 }
 if(vis[h][w+1]=='#'&&!ban[h][w+1]){
  cnt[h][w+1]=cnt[h][w]+1;
  maxcnt=max(maxcnt,cnt[h][w+1]);
 // cout<<"w "<<h<<" "<<w+1<<" "<<cnt[h][w+1]<<" "<<cnt[h][w]<<endl;
  search(h,w+1);
 }
}
int main(){
 ll x,y;
 sc(x);sc(y);
 maxcnt=0;sharp=0;
 rep(i,0,x){
  rep(j,0,y){
   cnt[i][j]=0;
   ban[i][j]=false;
   sc(vis[i][j]);
   //cout<<i<<" "<<j<<" "<<vis[i][j]<<endl;
   if(vis[i][j]=='#'){
    cnt[i][j]=1;
    sharp++;
   }
  }
 }
 //pr(sharp);
 search(0,0);
 if(maxcnt==sharp)puts("Possible");
 else puts("Impossible");
return 0;}

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

int main() {
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, n) cin >> d[i];
	sort(all(d));
	int ans = d[n/2] - d[n/2-1];
	
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;
long long calc(long long h) {
    assert(h != 0);
    if (h == 1) return 1;
    return (calc(h >> 1) << 1) + 1;
}
int main() {
#ifdef LDT
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long h;
    cin >> h;
    cout << calc(h);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 

  // input vector size
  int n;
  cin>>n;

  // input vector data
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }

  // bubble sort
  int cnt=0;
  for(int j=n;j>=1;j--){
    for(int i=1;i<j;i++){
      if(a.at(i-1)>a.at(i)){
        int wk = a.at(i-1);
        a.at(i-1)=a.at(i);
        a.at(i)=wk;
        cnt++;
      }
    }
  }

  // output sorted vector
  for(int i=0;i<n;i++){
    if(i<n-1)
      cout<<a.at(i)<<' ';
    else
      cout<<a.at(i)<<endl;
  }
  // output exchange number
  cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<stack>
using namespace std;
stack<char>s;

int main()
{
	char a;
	int res=0;
	while(cin>>a)
	{
		res++;
		if(a=='S') s.push(a);
		else if(!s.empty())
		{
			s.pop();
			res=res-2;
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int dpx[8]={1,1,1,-1,-1,-1,0,0};
int dpy[8]={-1,1,0,1,-1,0,-1,1};

int32_t main()
{
	fastIO
	inp_out();
	int n; 
	cin >> n; 

	int ans = (n * (n + 1)) / 2; 

	for(int i = 0; i < n - 1;  ++ i)
	{
		int x, y; 
		cin >> x >> y; 
		ans += ((n - i) * (n - i - 1)) / 2; 
		ans -= min(x, y) * (n - max(x, y) + 1); 
	}

	cout << ans; 

	return 0;
}

Measured memory_bytes: 3652
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
		solveA(args);
//		solveB(args);
//		solveC(args);
//		solveD(args);
//		solveE(args);
//		solveF(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solveA(String[] args) throws Exception{
		int N= nextInt();
		for(int i=1;i<=8;i++) {
			if(2000-i*200<=N && N<=2199-i*200) {
				pw.println(i);
				break;
			}
		}

	}
	public static void solveB(String[] args) throws Exception{

	}
	public static void solveC(String[] args) throws Exception{

	}

	public static void solveD(String[] args) throws Exception{

	}


	public static void solveE(String[] args) throws Exception{

	}

	public static void solveF(String[] args) throws Exception{

	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



Measured memory_bytes: 25412
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

int main() {
    int h, w, k, x1, y1, x2, y2;
    cin >> h >> w >> k >> x1 >> y1 >> x2 >> y2;

    vector<vector<bool>> c(h + 2, vector<bool>(w + 2, false));
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;

        for (int j = 0; j < w; j++) {
            c[i + 1][j + 1] = (s[j] == '.');
        }
    }

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

    long long inf = 1LL << 61;

    vector<vector<vector<long long>>> dp(h + 2, vector<vector<long long>>(w + 2, vector<long long>(4, inf)));
    priority_queue<tuple<long long, int, int, int>,
            vector<tuple<long long, int, int, int>>,
            greater<tuple<long long, int, int, int>>> que;
    for (int i = 0; i < 4; i++) {
        dp[x1][y1][i] = 0;
        que.push(make_tuple(0, x1, y1, i));
    }

    while (!que.empty()) {
        tuple<long long, int, int, int> q = que.top();
        que.pop();

        int x = get<1>(q);
        int y = get<2>(q);
        int d = get<3>(q);

        for (int i = 0; i < 4; i++) {
            if (i == d && c[x + dx[i]][y + dy[i]] && dp[x + dx[i]][y + dy[i]][i] > dp[x][y][d] + 1) {
                dp[x + dx[i]][y + dy[i]][i] = dp[x][y][d] + 1;
                que.push(make_tuple(dp[x + dx[i]][y + dy[i]][i], x + dx[i], y + dy[i], i));
            } else if (i != d && dp[x][y][i] > ((dp[x][y][d] + k - 1) / k) * k) {
                dp[x][y][i] = ((dp[x][y][d] + k - 1) / k) * k;
                que.push(make_tuple(dp[x][y][i], x, y, i));
            }
        }
    }

    long long r = *min_element(dp[x2][y2].begin(), dp[x2][y2].end());
    cout << (r < inf ? (r + k - 1) / k : -1) << endl;
}

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

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;

#define IOSWORK ios::sync_with_stdio(0); cin.tie(0)
#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define VAR(v, n) typeof(n) v = (n)
#define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)

#define SCAN_INT(n) scanf("%i",&n)
#define SCAN_P_INT(n,m) scanf("%i %i",&n,&m)
#define PRINT_P_INT(n,m) printf("%i %i\n",n,m);
#define PRINT_INT(n) printf("%i\n",n)


#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 1000000007


#define MAXSIZE 

int n;
VI cyfry;
string wynik = "0";

void operacja(int suma,int p,string ciag){
	if(p==4){
		if(suma==7)
			wynik=ciag;
	}
	else if(wynik=="0"){
		operacja(suma+cyfry[p],p+1,ciag+'+');
		operacja(suma-cyfry[p],p+1,ciag+'-');
	}
}

int main(){
	

	string temp;
	cin>>temp;

	REP(i,SIZE(temp)){
		cyfry.PB((int)temp.at(i)-'0');
	}

	operacja(cyfry[0],1,"");
	
	cout<<cyfry[0]<<wynik.at(0)<<cyfry[1]<<wynik.at(1)<<cyfry[2]<<wynik.at(2)<<cyfry[3]<<"=7\n";
	
   return 0;
}


Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

ll s[100001];
ll parents[100001];
ll p[100001];
ll root(ll x){
  if(parents[x] == x){
    return x;
  }else{
    return parents[x] = root(parents[x]);
  }
}

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

void unite(ll x, ll y){
  x = root(x);
  y = root(y);
  if(x == y) return;
  parents[x] = y;
}

int A[100001];
int B[100001];
ll ansDiff[100001];
ll ans[100002];

int main(){
  ll N, M;
  cin >> N >> M;
  rep(i, 1, N + 1){
    parents[i] = i;
    s[i] = 1;
  }
  rep(i, M){
    cin >> A[i];
    cin >> B[i];
  }

  rrep(i, M, 0){
    int a = A[i];
    int b = B[i];
    if(!same(a, b)){
      int sizeA = s[root(a)];
      int sizeB = s[root(b)];
      unite(a, b);
      s[root(a)] = sizeA + sizeB;
      ansDiff[i] = sizeA * sizeB;
    }else{
      ansDiff[i] = 0;
    }
    if(i == M - 1){
      ans[i] = N * (N - 1) / 2;
    }else{
      ans[i] = ans[i + 1] - ansDiff[i + 1];
    }
  }
  rep(i, M){
    cout << ans[i] << endl;
  }
  return 0;
}


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

int main(void){
    int h,w;
    cin>>h>>w;
    vector<string> M(h);
    rep(i,h) cin>>M[i];
    queue<pair<int,int>> que;
    vector<vector<int>> seen(h,vector<int>(w,-1));
    rep(i,h) rep(j,w){
        if(M[i][j]=='#'){
            que.push(make_pair(i,j));
            seen[i][j]=0;
        }
    }
    int dx[]={1,0,-1,0};
    int dy[]={0,1,0,-1};
    while(!que.empty()){
        int x=que.front().first;
        int y=que.front().second;
        que.pop();
        rep(dir,4){
            int nx=x+dx[dir];
            int ny=y+dy[dir];
            if(nx<0 || nx>=h || ny<0 ||ny>=w) continue;
            if(seen[nx][ny]!=-1) continue;
            seen[nx][ny]=seen[x][y]+1;
            que.push(make_pair(nx,ny));
        }
    }
    
    int ans=0;
    rep(i,h){
        rep(j,w){
            //cout<<seen[i][j]<<" ";
            ans=max(ans,seen[i][j]);
        }
        //cout<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 17228
from sys import stdin
import numpy as np
import sys

N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = np.array(list(map(int, [stdin.readline().rstrip() for _ in range(N)])))

h.sort()
hmin = 2**30

for i in range(0, N-K+1):
    hdiff = h[i+K-1] - h[i]
    if hdiff < hmin:
        hmin = hdiff

print(hmin)



Measured memory_bytes: 23408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;

string str = "357";

int dfs(ll s, ll n){
    if (s > n) return 0;
    bool flag = true;
    string S = to_string(s);
    for (int i = 0; i < str.size(); i++){
        for (int j = 0; j < S.size(); j++){
            if (str[i] == S[j]){
                flag = true;
                break;
            }
            flag = false;
        }
        if (!flag) break;
    }
    int ans = (flag)? 1 : 0;
    
    ans += dfs(s*10 + 3, n);
    ans += dfs(s*10 + 5, n);
    ans += dfs(s*10 + 7, n);

    return ans;
}

int main(){
    int n;
    cin >> n;
    cout << dfs(0, n) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,m,a[100010],b,i,c;
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d %d",&a[R],&b);
    hin(b);
  }
  for(i=0;C>0;i++){
    c=N[hout()];
    while(a[H[1]]<c&&C>0)hout();
  }
  printf("%d\n",i);
  return 0;
}
    


Measured memory_bytes: 5120
import java.util.*;

public class Main {
  public static void main(String[] args){

      /* Scanner */
      Scanner sc = new Scanner(System.in);
      int length = sc.nextInt(); /* 文字数の長さ */

      /* 各配列へのデータの格納 */
      int[] data = new int[length]; /* データ配列の作成 */
      for (int i = 0; i < length; i++){
        data[i] = sc.nextInt();
      }

      for (int k = 0; k < length; k++){
        System.out.print(data[k]);
        if (k != length - 1) System.out.print(" ");
        else System.out.print("\n");
      }

      /* 挿入ソート */
      for (int i = 1; i < length; i++){
        int temp = data[i];
        int j = i - 1;
        while (j >= 0 && data[j] > temp){
          data[j + 1] = data[j];
          j--;
        }
        data[j + 1] = temp;

        /* 途中経過を表示 */
        for (int k = 0; k < length; k++){
          System.out.print(data[k]);
          if (k != length - 1) System.out.print(" ");
          else System.out.print("\n");
        }
      }
  }
}


Measured memory_bytes: 34572
NIL = -1

class Node:
    def __init__(self, parent=NIL, left=NIL, right=NIL):
        self.parent = parent
        self.left = left
        self.right = right


def setDepth(tree, depthList, u, depth):
    if u == NIL:
        return
    depthList[u] = depth
    setDepth(tree, depthList, tree[u].left, depth + 1)
    setDepth(tree, depthList, tree[u].right, depth + 1)


def setHeight(tree, heightList, u):
    h1 = 0
    h2 = 0
    if tree[u].left != NIL:
        h1 = setHeight(tree, heightList, tree[u].left) + 1
    if tree[u].right != NIL:
        h2 = setHeight(tree, heightList, tree[u].right) + 1
    heightList[u] = max(h1, h2)
    return heightList[u]


def getSibling(tree, u):
    if tree[u].parent == NIL:
        return NIL
    if tree[tree[u].parent].left not in (u, NIL):
        return tree[tree[u].parent].left
    if tree[tree[u].parent].right not in (u, NIL):
        return tree[tree[u].parent].right
    return NIL


def printNode(tree, depthList, heightList, u):
    result = 'node %d: ' % u
    result += 'parent = %d, ' % tree[u].parent
    result += 'sibling = %d, ' % getSibling(tree, u)
    deg = 0
    if tree[u].left != NIL:
        deg += 1
    if tree[u].right != NIL:
        deg += 1
    result += 'degree = %d, ' % deg
    result += 'depth = %d, ' % depthList[u]
    result += 'height = %d, ' % heightList[u]

    if tree[u].parent == NIL:
        result += 'root'
    elif tree[u].left == NIL and tree[u].right == NIL:
        result += 'leaf'
    else:
        result += 'internal node'
    print(result)


n = int(input())
tree = [Node() for i in range(n)]

for i in range(n):
    value, left, right = [int(v) for v in input().split()]
    tree[value].left = left
    tree[value].right = right
    if left != NIL:
        tree[left].parent = value
    if right != NIL:
        tree[right].parent = value

root = 0
for i in range(n):
    if tree[i].parent == NIL:
        root = i
        break

depthList = [-1] * n
heightList = [-1] * n
setDepth(tree, depthList, root, 0)
setHeight(tree, heightList, root)
for i in range(n):
    printNode(tree, depthList, heightList, i)


Measured memory_bytes: 5624
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut xs: [i32; n],
    };
    let mut cnt = 0;
    loop {
        if xs.iter().any(|x| x % 2 == 1) {
            break;
        }
        xs = xs.iter().map(|x| x / 2).collect();
        cnt += 1;
    };
    println!("{}", cnt);
}


Measured memory_bytes: 2184
#include<iostream>
#include<cstdio>

using namespace std;

typedef long long LL;

const int maxn=2e5+5;
const int sentinel=0x3f3f3f3f;

int l[maxn/2+2],r[maxn/2+2],a[maxn],n;

LL merge(int left,int mid,int right)
{
    int i,j,k;
    LL cnt=0;
    int n1=mid-left;
    int n2=right-mid;
    for(int i=0;i<n1;i++){
        l[i]=a[left+i];
    }
    for(int i=0;i<n2;i++){
        r[i]=a[mid+i];
    }
    l[n1]=r[n2]=sentinel;
    i=j=0;
    for(int k=left;k<right;k++){
        if(l[i]<=r[j]){
            a[k]=l[i++];
        }else{
            a[k]=r[j++];
            cnt+=n1-i;
        }
    }
    return cnt;
}

LL mergesort(int left,int right)
{
    int mid;
    LL v1,v2,v3;
    if(left+1<right){
        mid=(left+right)>>1;
        v1=mergesort(left,mid);
        v2=mergesort(mid,right);
        v3=merge(left,mid,right);
        return v1+v2+v3;
    }else{
        return 0;
    }
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    LL ans=mergesort(0,n);
    cout<<ans<<endl;
    return 0;
}
/*
5
3 5 2 1 4
*/



Measured memory_bytes: 4784
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

import numpy as np

def main():
	k,n=MI()
	A=LI()
	A=np.array(A)
	A=np.append(A,A+k)

	B=A[n-1:]-A[:n+1]
	print(min(B))
















if __name__ == "__main__":
	main()


Measured memory_bytes: 46060
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 0;

string a[] = {"AC", "WA", "TLE", "RE"};
map<string, ll> mp;
string s;
ll n;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	while(n--){
		cin >> s;
		mp[s]++;
	}
	for(ll i = 0; i < 4; i++){
		cout << a[i] << " x " << mp[a[i]] << '\n';
	}
}



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

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

Measured memory_bytes: 256
from sys import stdin


def input():
    return stdin.readline().strip()


def main():
    X = int(input())

    y = 100
    for i in range(1, 10 ** 20):
        y = int(1.01 * y)
        if y >= X:
            print(i)
            return
    

if __name__ == "__main__":
    main()


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

int main() {
  int N,M,Z=0;
  cin>>N>>M;
  vector<vector<int>> p(N);
  for(int i=0;i<M;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    p.at(a).push_back(b);
    p.at(b).push_back(a);
  }
  vector<int> r(N);
  for(int i=0;i<N;i++){
    if(r.at(i)==1){
      continue;
    }
    else{
      Z++;
      queue<int> q;
      q.push(i);
      r.at(i)=1;
      while(!(q.empty())){
        int a=q.front();
        q.pop();
        for(int x:p.at(a)){
          if(r.at(x)==0){
            r.at(x)=1;
            q.push(x);
          }
        }
      }
    }
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 6904
N=int(input())
X=input()
def popcount(n):
    s=str(bin(n))
    return len([i for i in s if i=='1'])
def f(n):
    c=1
    while n!=0:
        n=n%popcount(n)
        c=c+1
    return c
x=int(X,2)
P=popcount(x)
F=list(X)
L=[1,2]# L[i]=2**i%(P+1)
M=[1,2]# M[i]=2**i%(P-1)
if P!=1:
    for i in range(1,N):
        L.append((L[i]*2)%(P+1))
        M.append((M[i]*2)%(P-1))
    s=x%(P+1)
    t=x%(P-1)
    for i in range(N):
        if F[i] == '1':
            q = (t - M[N-i-1])%(P-1)
            print(f(q))
        else:
            Q = P + 1
            q = (s + L[N-i-1])%(P+1)
            print(f(q))
else:
    for i in range(1,N):
        L.append(0)
    s=x%2
    for i in range(N):
        if F[i] == '1':
            print(0)
        else:
            q = (s + L[N - i - 1])%2
            print(f(q))

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

using namespace std;

const long long INF = LONG_LONG_MAX;
const int maxsum = (int) (1e5 + 1);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s, t;
    cin >> s >> t;
    int n = (int) (s.length());
    int m = (int) (t.length());
    vector<vector<long long >> dp(n + 1);
    for (int i = 0; i < n + 1; ++i) {
        dp[i].resize(m + 1);
    }
    for (int i = 1; i < n + 1; ++i) {
        for (int j = 1; j < m + 1; ++j) {
            if (s[i - 1] == t[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    vector<char> ans;
    int i = n;
    int j = m;
    while (i > 0 && j > 0) {
        if (s[i - 1] == t[j - 1]) {
            ans.push_back(s[i - 1]);
            i--;
            j--;
        } else {
            if (dp[i][j] == dp[i - 1][j]) i--;
            else j--;
        }
    }
    reverse(ans.begin(), ans.end());
    for (char c : ans) {
        cout << c;
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 70784
#include <bits/stdc++.h>
 
using namespace std;
const int MAX = 600005;
const int MAX1 = 1e6 + 5;
int tree[MAX], p[MAX1], ans[MAX], a[MAX];
pair <int, pair<int, int> > pr[MAX];
 
void update(int idx, int val)
{
    while(idx < MAX)
    {
        tree[idx] += val;
        idx += (idx & -idx);
    }
}
 
int read(int idx)
{
    int sum = 0;
    while(idx > 0)
    {
        sum += tree[idx];
        idx -= (idx & -idx);
    }
    return sum;
}
 
int main()
{
    //ifstream cin("input.txt");
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, q, x;
    cin>>n>>q; // scanf("%d", &n);
    // scanf("%d", &q);
    for(int i = 1;i <= n;++i)
        cin>>a[i]; //scanf("%d", &a[i]);
    for(int i = 0;i < q;++i)
    {
        cin>>pr[i].second.first>>pr[i].first; // pr[i].second.first[scanf("%d %d", &pr[i].second.first, &pr[i].first);
        pr[i].second.second = i;
    }
    sort(pr, pr + q);
    memset(p, -1, sizeof(p));
    memset(tree, 0, sizeof(tree));
    x = 0;
    for(int i = 1;i <= n;++i)
    {
        if(p[a[i]] != -1)
            update(p[a[i]], -1);
        p[a[i]] = i;
        update(i, 1);
        while(x < q and pr[x].first == i)
        {
            ans[pr[x].second.second] = read(pr[x].first) - read(pr[x].second.first-1);
            x++;
        }
    }
    for(int i = 0;i < q;++i)
        cout << ans[i] << "\n"; // printf("%d\n", ans[i]);
    return 0;
}

Measured memory_bytes: 19772