akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
using namespace std;

int a[10],k;

int work(int a){
	if(a>0)return a;
	return -a;
}

int main(void){
	for(int i=1;i<=5;i++)
	scanf("%d",&a[i]);
	scanf("%d",&k);
	for(int i=1;i<=5;i++){
		for(int j=i+1;j<=5;j++)
		if(work(a[i]-a[j])>k){
			printf(":(\n");
			return 0;
		}
	}
	printf("Yay!\n");
} 

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
    char s2[100001];
    scanf("%s",s2);
    int s2len=strlen(s2);
    int q;
    scanf("%d",&q);
    char *s1,*s3;
    s1=(char*)malloc(sizeof(char)*(q+1));
    s3=(char*)malloc(sizeof(char)*(q+1));
    int s1len=0;
    int s3len=0;
    int t,f;
    char c;
    int reverse=1;
    for (int i = 0; i < q; i++)
    {
        scanf("%d",&t);
        if(t==1) reverse*=-1;
        else{
            scanf("%d %c",&f,&c);
            if (reverse==1)
            {
                if (f==1)
                {
                    s1[s1len]=c;
                    s1len++;
                }else if(f==2){
                    s3[s3len]=c;
                    s3len++;
                }
            }else if(reverse==-1){
                if (f==2)
                {
                    s1[s1len]=c;
                    s1len++;
                }else if(f==1){
                    s3[s3len]=c;
                    s3len++;
                }
            }
        }
        
    }
    if (reverse==1)
    {
        for (int i = 0; i < s1len; i++)
        {
            printf("%c",s1[s1len-1-i]);
        }
        printf("%s",s2);
        for (int i = 0; i < s3len; i++)
        {
            printf("%c",s3[i]);
        }        
    }else if (reverse==-1){
        for (int i = 0; i < s3len; i++)
        {
            printf("%c",s3[s3len-1-i]);
        }
        for (int i = 0; i < s2len; i++)
        {
            printf("%c",s2[s2len-1-i]);
        }
        for (int i = 0; i < s1len; i++)
        {
            printf("%c",s1[i]);
        }        

    }
    return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

int n;
string s, temp;
vector<int> vec;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    cout << 0 << "\n";
    cout.flush();
    cin >> s;
    temp = s;
    if(temp == "Vacant")
        exit(0);
    for(int i = 2; i < n; i+=2)
        vec.pb(i);
    int l = 0;
    for(int i = 20; i >= 0; i--){
        if(l + (1 << i) < n){
            cout << l + (1 << i) << "\n";
            cout.flush();
            cin >> s;
            if(s == "Vacant")
                exit(0);
            else{
                if(temp == s)
                    l += (1 << i);
            }
        }
    }
    cout << l + 1 << "\n";
    cout.flush();
    cin >> s;
    exit(0);
}


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

template<class T>
struct SegTree {
	int n;
	vector<T> node;
	function<T(T, T)> f;
	T iniV;
	SegTree(vector<T> v, function<T(T, T)> f, T iniV): iniV(iniV), f(f) {
		int sz = v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(n * 2 - 1, iniV);
		for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) {
			node[i] = f(node[i * 2 + 1], node[i * 2 + 2]);
		}
	}
	T getOneVal(int x) {
		return node[x + n - 1];
	}
	void update(int x, T val) {
		x += n - 1;
		node[x] = val;
		while (x > 0) {
			x = (x - 1) / 2;
			node[x] = f(node[x * 2 + 1], node[x * 2 + 2]);
		}
	}
	T getval(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		if (r <= a || b <= l) return iniV;
		if (a <= l && r <= b) return node[k];
		T vl = getval(a, b, k * 2 + 1, l, (l + r) / 2);
		T vr = getval(a, b, k * 2 + 2, (l + r) / 2, r);
		return f(vl, vr);
	}
};

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep (i, 0, N) cin >> A[i];

    vector<int> dp(300005, 0);

    auto _max = [](int a, int b) { return a > b ? a : b; };
    SegTree<int> seg(dp, _max, 0);
    rep (i, 0, N) {
        int l = max(0, A[i] - K);
        int r = min(300003, A[i] + K);
        int now = seg.getval(l, r + 1) + 1;
        seg.update(A[i], now);
    }
    
    cout << seg.getval(0, 300003) << endl;
    return 0;
}

Measured memory_bytes: 10924
n, hp = map(int, input().split())
mat = [list(map(int, input().split())) for _ in range(n)]
mat.sort(key=lambda x:-x[1])
sword = max(mat, key=lambda x:x[0])[0]
s, t = mat[0]
idx = 0
ans = 0
for _, throw in mat:
    if throw > sword:
        hp -= throw
        ans += 1
        if hp <= 0:
            print(ans)
            exit()
    else:
        break
d, m = divmod(hp, sword)
ans += d + min(1, m)
print(ans)


Measured memory_bytes: 32080
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int n;
  cin>>n;
  vector<tuple<string,int,int>> t;
  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin>>s>>p;
    p=-p;
    t.push_back(tie(s,p,i));
  }
  sort(all(t));
  rep(i,n) cout<<get<2>(t[i])<<endl;
}

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

#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int,int>
#define fi first
#define se second
#define pb pushback;

using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<((c<=(a-b))?0:c-(a-b));
    return 0;
}



Measured memory_bytes: 256
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
const long long INF=9e15;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long id=0;id<N;id++) cin>>v.at(id)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(2);
  
  int N, K;cin >> N >> K;
  vector<int> a(N);
  rep(i, N) cin >> a[i];
  sort(all(a));
  ll res= 0;
  rep(i, K){
    res += a[i];
  }

  cout << res << endl;
}

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

#define ll long long
priority_queue<ll>q1;
priority_queue<ll,vector<ll>,greater<ll> >q2;
int main()
{
   int q,t;
   scanf("%d",&q);
    ll sum1=0,sum2=0;
    ll sum=0;
    ll a,b;
   while(q--)
   {
       scanf("%d",&t);
       if(t==1)
       {
           scanf("%lld%lld",&a,&b);
           sum+=b;
           if(q2.empty() || a<q2.top())
           {
               q1.push(a);
               sum1+=a;
           }
           else
           {
               ll rtop=q2.top();q2.pop();
                q2.push(a);
                sum2+=a-rtop;
                q1.push(rtop);
                sum1+=rtop;
           }
           if(q1.size()-q2.size()>1)
           {
               ll ltop=q1.top();
               q1.pop();
               sum1-=ltop;
               q2.push(ltop);
               sum2+=ltop;
           }
       }
       else
       {
           ll x=q1.top();
           a=(ll)q1.size(),b=(ll)q2.size();
           printf("%lld %lld\n",x,x*a-sum1 + sum2-x*b +sum);
       }
   }
    return 0;
}


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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    vector<int> cnt(4);
    for(int i = 0; i < 3; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        cnt[a]++, cnt[b]++;
    }
    sort(all(cnt));
    vector<int> ans = {1,1,2,2};
    if (cnt == ans) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int ans = 0, begin = 0, end = s.length() - 1;
    while(begin < end){
        if(s[begin] == s[end]){
            begin++;
            end--;
        }else if(s[begin] != s[end]){
            if(s[begin] == 'x'){
                begin++;
                ans++;
            }else if(s[end] == 'x'){
                end--;
                ans++;
            }else{
                cout << "-1\n";
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    int counter=0;
    getline(cin,a);
    int sizen=a.size();
    for(int i=0;i<sizen;i++)
    {
        if(a[i]=='1')
            counter++;
    }
    cout<<counter<<endl;
}


Measured memory_bytes: 256
import math
while True:
    n = int(input())
    if n == 0:
        break
    scr = list(map(int, input().split()))
    m = sum(scr) / len(scr)
    a = 0
    for i in scr:
        a += (i - m)**2
    print(math.sqrt(a / len(scr)))


Measured memory_bytes: 5696
#include<stdio.h>
int main(void)
{
  int S, h, m, s;
  scanf("%d", &S);
  s = S % 60;
  m = (S - s) / 60 % 60;
  h = ((S - s) / 60 - m) /60;
  printf("%d:%d:%d\n", h, m, s );
}



Measured memory_bytes: 2128
import sys
input = sys.stdin.readline

class Vec:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __str__(self):
        return '({}, {})'.format(self.x, self.y)

    def __add__(self, other):
        return Vec(self.x+other.x, self.y+other.y)

    def __sub__(self, other):
        return Vec(self.x-other.x, self.y-other.y)

    def __mul__(self, k):
        return Vec(self.x*k, self.y*k)

    def __truediv__(self, k):
        return Vec(self.x/k, self.y/k)

    def abs(self):
        return (self.x**2 + self.y**2)**.5

    def dot(self, other):
        return self.x*other.x + self.y*other.y

    def cross(self, other):
        return self.x*other.y - self.y*other.x

    def rot(self, ang):
        c = math.cos(ang)
        s = math.sin(ang)
        return Vec(c*self.x-s*self.y, s*self.x+c*self.y)

def convex_hull(points, eps=1e-12):
    n = len(points)
    points.sort(key=lambda p: (p.x, p.y))
    k = 0  # # of vertices in the convex hull
    ch = [None] * (2*n)
    # bottom
    for i in range(n):
        while k > 1 and (ch[k-1]-ch[k-2]).cross(points[i]-ch[k-1]) < eps:
            k -= 1
        ch[k] = points[i]
        k += 1
    t = k
    # top
    for i in range(0, n-1)[::-1]:
        while k > t and (ch[k-1]-ch[k-2]).cross(points[i]-ch[k-1]) < eps:
            k -= 1
        ch[k] = points[i]
        k += 1
    return ch[:k-1]

N = int(input())
xy = [Vec(*tuple(map(int, input().split()))) for _ in range(N)]
points = [Vec(0, 0)]
for v in xy:
    npoints = points[:]
    for u in points:
        npoints.append(u + v)
    points = convex_hull(npoints)
ans = max(v.abs() for v in points)
print(ans)

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

int main(){
 int n,x,min=1000;
 int ans,num;

 cin>>n>>x;
 num=x;
  
 vector<int> m(n);

 for(int i=0;i<n;i++){
    cin>>m.at(i);
    if(min>m.at(i)){
        min=m.at(i);
    }
    num-=m.at(i);
 }
 
 cout<<num/min+n;
 
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

count = 0
exist = [0] * 8

for ai in a:
    if ai < 3200:
        exist[ai // 400] = 1
    else:
        count += 1

temp = sum(exist)

if temp == 0:
    print(1, count)
else:
    print(temp, temp + count)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
ll INF=1000000007;

int main(){
    ll n;
    cin >> n;
    ll c[n],s[n],f[n];
    rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
    rep(i,n-1){
        ll ans=s[i];
        for(int j=i;j<n-2;j++){
            if(ans+c[j]<s[j+1]) ans = s[j+1];
            else if((ans+c[j])%f[j+1]==0) ans+=c[j];
            else ans = ((ans+c[j])/f[j+1]+1)*f[j+1];
        }
        cout << ans+c[n-2] << endl;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
    ll N;
    cin >> N;
    ll a[N];
    cinf(N,a) ;
    ll res = 0, ans = 1;
    for (int i = 1; i < N; i++) {
        int S = a[i] - a[i - 1];
        if (res < 0 && S > 0 || res > 0 && S < 0) {
            ans++;
            res = 0;
        }
        else if (S)
            res = S;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n,x,y,ans;
int main(){
	n=read();
	while(n--){
		x=read();
		if(x>y)ans+=x-y;
		y=x;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Memory Leak
public class Main{

	final int NULL = -1, NOT = -2;
	
	class R{
		int mem;
		public R(int mem) {
			this.mem = mem;
		}
	}
	
	class Manager{
		boolean error;
		int maxSize, alloc;
		public Manager(int maxSize) {
			this.maxSize = maxSize;
			alloc = 0;
			error = false;
		}
		R malloc(int s){
			if(maxSize<s+alloc)return new R(NULL);
			alloc+=s;
			return new R(s);
		}
		R clone(R r){
			if(r.mem==NOT){
				error = true;
				return new R(NULL);
			}
			if(r.mem==NULL)return new R(NULL);
			if(maxSize<r.mem+alloc)return new R(NULL);
			alloc+=r.mem;
			return new R(r.mem);
		}
		void free(R r){
			if(r.mem==NOT){
				error = true; return;
			}
			if(r.mem==NULL)return;
			alloc-=r.mem;
		}
	}
	
	R[] r;
	Manager manager;
	char[] s;
	int idx;
	char get(){
		return s[idx++];
	}
	
	void line(){
		if(get()=='f'){
			get();
			R e = exp();
			if(0<=e.mem)for(int i=0;i<26;i++)if(r[i]==e)r[i]=new R(NOT);
			manager.free(e);
			get();
		}
		else{
			idx--;
			exp();
		}
	}
	
	R exp(){
		char ch = get();
		if(ch=='('){
			R r = exp();
			get();
			return r;
		}
		if(ch=='m'){
			get();
			int x = 0;
			char c = get();
			do{
				x = x*10 + c-'0';
				c = get();
			}while(Character.isDigit(c));
			return manager.malloc(x);
		}
		if(ch=='c'){
			get();
			R r = manager.clone(exp());
			get();
			return r;
		}
		char nx = get();
		if(nx=='U'){
			get(); get();
			return new R(NULL);
		}
		if(nx=='='){
			R e = exp();
			if(e.mem<0)return r[ch-'A'] = new R(e.mem);
			return r[ch-'A'] = e;
		}
		idx--;
		return r[ch-'A'];
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		r = new R[26];
		for(int i=0;i<26;i++)r[i]=new R(NOT);
		manager = new Manager(sc.nextInt());
		while(sc.hasNext()){
			idx = 0;
			s = (sc.next().replace("malloc", "m").replace("free", "f").replace("clone", "c")+"$").toCharArray();
			line();
//			System.out.println(manager.alloc+" "+manager.error);
		}
		if(manager.error)System.out.println("Error");
		else{
//			for(int i=0;i<26;i++)System.out.println((char)(i+'A')+" MEM:"+r[i].mem);
			int u = 0;
			for(int i=0;i<26;i++){
				boolean ok = true;
				for(int j=0;j<i;j++)if(r[i]==r[j])ok = false;
				if(ok&&0<=r[i].mem)u+=r[i].mem;
			}
			System.out.println(manager.alloc-u);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <stdio.h>

int main()
{

 int x, y;
 while(1)
 {

     scanf("%d %d\n", &x, &y);
     if(x == 0 && y == 0)
     {
         break;
     }

     if(x > y)
     {
         printf("%d %d\n", y, x);
     }
     else
     {
         printf("%d %d\n", x, y);
     }
 }
 return 0;

}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll,ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll N, M;
    cin >> N >> M;
    ll a, sum = 0;
    REP(i,0,M) {
        cin >> a;
        sum += a;
    }

    ll d = N - sum;
    if(d < 0) _PR("-1");
    else _PR(d);
         

    return 0;
}

/*



*/

Measured memory_bytes: 3624
//In the name of Allah
#include <bits/stdc++.h>

using namespace std;
const int maxn=100005,inf=200000;
int n,m,mark[maxn],par[maxn],high[maxn],mini[maxn],minimomesh[maxn],dp[maxn],mark2[maxn];
vector<int> adj[maxn];
vector<pair<int,int>> v;
pair<int ,int > kol[maxn];
void dfs(int v)
{
    mark[v]=1;

    for(int u=0; u<adj[v].size(); u++)
    {
        int r=adj[v][u];
        if(mark[r]==0)
        {


            par[r]=v;
            high[r]=high[v]+1;

            dfs(r);
           // dp[v]=min(dp[r],dp[v]);




        }

    }




}
void dfs2(int v)
{
    mark2[v]=1;


    for(int c=0; c<adj[v].size(); c++)
    {
        int z=adj[v][c];
        if(mark2[z]==0)
        {
            dfs2(z);
            dp[v]=min(dp[z],dp[v]);
        }
    }

}
void minyab(int v)
{
    dp[v]=inf;
    for(int e=0; e<adj[v].size(); e++)
    {
        int t=adj[v][e];
        if(t!=par[v])
        {


        dp[v]=min(high[t],dp[v]);
    }
    }
    return;
}


int main()
{


    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(0);

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

    }
    dfs2(0);


  /*  for(int i=0; i<n; i++)
    {
        cout<<mini[i]<<' '<<high[i]<<' '<<high[par[i]]<<' '<<dp[i]<<' '<<minimomesh[i]<<endl;
    }*/

    for(int i=1; i<n; i++)
    {
        if(dp[i]>high[par[i]])
        {


            kol[i].first=i;
            kol[i].second=par[i];
            if(kol[i].first>kol[i].second)
            {
                swap(kol[i].first,kol[i].second);
            }
            v.push_back(kol[i]);
        }
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    {
        cout<<v[i].first<<' '<<v[i].second<<endl;
    }





    return 0;
}



Measured memory_bytes: 6768
#include <stdio.h>
#include <string.h>
int check(int a[],int n,int m){
  int sum=0;
  while(1){
    sum+=a[n++];
    if(sum==m)
      return n;
    if(sum>m)
      return -1;
  }
}
int tanku(int a[],int n){
  n=check(a,n,5);
  if(n==-1)
    return 0;
  n=check(a,n,7);
  if(n==-1)
    return 0;
  n=check(a,n,5);
  if(n==-1)
    return 0;
  n=check(a,n,7);
  if(n==-1)
    return 0;
  n=check(a,n,7);
  if(n==-1)
    return 0;
  return 1;
}
int main(void){
  int n,i,a[40];
  char s[11];
  while(1){
    scanf("%d",&n);
    if(!n)
      break;
    memset(a,0,sizeof(a));
    for(i=0;i<n;i++){
      scanf("%s",s);
      a[i]=strlen(s);
    }
    for(i=0;i<n;i++){
      if(tanku(a,i)){
	printf("%d\n",i+1);
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repe(i,n) for(int i=0;i<n;i++)
#define repa(i,j,n) for(int i=j;i<n;i++)
//#define v.all() v.begin(),v.end()
#define repr(i,n) for(int i=n;i>=0;i--)
#define int long long int
#define vi vector<int>
#define vpi vector<pair<int,int>>

signed  main(){
	int test=1;
	//cin>>test;
	rep(tt,test) {
		int a,b;
		cin>>a>>b;
		int ans=0;
		int soc=1;
		while(soc<b){
			soc+=a;
			soc--;
			ans++;
		}
		cout<<ans<<endl;
		
	}
	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>
#define INF 1000000007
//const int m=998244353;
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>PBDS;

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}



int32_t main(){
	
	//FIO();
	
		int n;cin>>n;
		vi a(n+1,0);
		//int sum=0;
		for(int i=0; i<n-1; i++){
			int x;cin>>x;
			//sum+=a[i];
			a[x]++;
		}
		for(int i=1; i<=n; i++){
			cout<<a[i]<<"\n";
		}
	
	return 0;
		
}
		
		



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

int main() {
  ll N, K;
  cin >> N >> K;
  ll rst = N%K;
  if(rst > K/2) rst = llabs(rst-K);
  cout << rst << endl;
}


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

int main(){
    int X, A, B;
    cin >> X >> A >> B;

    if((A-B) >= 0){
        cout << "delicious" << endl;
    }else{
        if((B-A) <= X){
            cout << "safe" << endl;
        }else{
            cout << "dangerous" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <cctype>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <limits>
#include <cmath>
#include <typeinfo>


using namespace std; 

  
int main() {
	int n = 0, k = 0, cnt = 0;
	cin >> n >> k;
	for(int i = 0; i < n; i++) {
		int h = 0;
		cin >> h;
		if(h >= k) {
			cnt++;
		}
	}
	cout << cnt << endl;
	
    return 0; 
}  

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
const int mod = 1e9 + 7;

int main(void){
    
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    ll ans = 0;
    
    rep(i, 61) {
        ll cnt = 0;
        rep(j, n) {
            if(a[j]>>i & 1) ++cnt; 
        }
        ans += ((cnt * (n - cnt)) % mod) * ((1LL<<i) % mod);
        ans %= mod;
    }
    
    cout << ans << endl;
    
}


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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        cans: [u64; 3],
    }
    let mut cans = cans;
    cans.sort();
    cans.dedup();
    println!("{}", cans.len());
}


Measured memory_bytes: 4352
from scipy.sparse import*;f=lambda*z:map(int,raw_input().split());n,=f();a,b=zip(*map(f,[0]*~-n));g,h=[csgraph.dijkstra(csr_matrix(([1]*~-n,(a,b)),[n+1]*2),0,s)for s in[1,n]];print['Snuke','Fennec'][sum(g[i]>h[i]for i in range(n+1))*2<n]

Measured memory_bytes: 37732
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

uint64_t ans=0;

void dfs(vector<int> S,int idx){
    if(idx>S.size()-1){
        int num=1;
        for(auto s:S) num*=s;
        if(num%2==0) ans++;
        return;
    }

    dfs(S,idx+1);
    vector<int> _S=S;
    _S.at(idx)=S.at(idx)-1;
    dfs(_S,idx+1);
    _S.at(idx)=S.at(idx)+1;
    dfs(_S,idx+1);
}

int main(){
    int N; cin>>N;
    vector<int> S(N);
    rep(n,0,N) cin>>S.at(n);

    dfs(S,0);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

ll mod_pow(ll x, ll n, ll mod = MOD) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

int N;
int A[212345], B[212345];
vector<int> g[212345];
int cnt[212345], par[212345];

int dfs(int u, int p) {
	int res = 1;
	for (int v : g[u]) if (v != p) {
		par[v] = u;
		res += dfs(v, u);
	}
	return cnt[u] = res;
}

int main() {
	cin >> N;
	REP(i, N - 1) {
		scanf("%d %d", A + i, B + i);
		--A[i]; --B[i];
		g[A[i]].push_back(B[i]);
		g[B[i]].push_back(A[i]);
	}
	
	dfs(0, -1);
	
	ll ans = 0;
	REP(i, N - 1) {
		int c[2];
		if (par[A[i]] != B[i]) swap(A[i], B[i]);
		c[0] = cnt[A[i]];
		c[1] = N - cnt[A[i]];
		ll pat = mod_pow(2, N) - 1;
		REP(j, 2) pat -= mod_pow(2, c[j]) - 1;
		pat = (pat % MOD + MOD) % MOD;
		ans = (ans + pat) % MOD;
	}
	// ans : S内の辺の合計本数
	ans = (ans * mod_pow(mod_pow(2, N), MOD - 2))% MOD; // S内の辺の合計本数の期待値
	ans = (ans + 1) % MOD; // S内の頂点の個数の期待値(空グラフを1とカウント)
	ans = (ans - mod_pow(mod_pow(2, N), MOD - 2) + MOD) % MOD; // S内の頂点の個数の期待値
	
	ans = (ans - N * mod_pow(2, MOD - 2) % MOD + MOD) % MOD;
	cout << ans << endl;
	return 0;
}


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

using namespace std;
void rot(int *dice, int a, int b, int c, int d){
	int tmp = dice[a];
	dice[a] = dice[b];
	dice[b] = dice[c];
	dice[c] = dice[d];
	dice[d] = tmp;
}

int main(){
	int n;
	while (cin >> n, n){
		int dice[6] = { 1, 2, 3, 4, 5, 6 }, ans = 1;
		for (int i = 0; i < n; i++){
			string command;
			cin >> command;
			if (command == "North"){
				rot(dice, 0, 1, 5, 4);
			} else if (command == "East"){
				rot(dice, 0, 3, 5, 2);
			} else if (command == "West"){
				rot(dice, 2, 5, 3, 0);
			} else if (command == "South"){
				rot(dice, 4, 5, 1, 0);
			} else if (command == "Right"){
				rot(dice, 2, 4, 3, 1);
			} else /* Left */{
				rot(dice, 1, 3, 4, 2);
			}
			ans += dice[0];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1212
using System;
using System.Collections.Generic;
using System.Linq;
class a{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    int angle = 360;
    int ans = 1;
    while(true){
      angle -= n;
      if(angle == 0){
        break;
      }
      if(angle < 0){
        angle += 360;
      }
      ans++;
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 17644
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;



void main() {
    string s;
    scan(s);
    auto ok = iota(3).all!(i => s[i] == s[0]);
    yes(!ok);
}




void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
count = 1

for ii in range(n):
    #print(ii, a[ii])
    if count == a[ii]:
        count += 1
#print(count)
if count == 1:
    print(-1)
else:
    ans = n - (count - 1)
    print(ans)


Measured memory_bytes: 26140
n = input()
a = map(int,raw_input().split())
flag = 0
count = 0
while 1:
    for i in range(n):
        if a[i] % 2 != 0:
            flag = 1
            break
        else:
            a[i] /= 2
    if flag == 1: break
    count+=1
print count

Measured memory_bytes: 2568
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
#include<math.h>
#include <iomanip>
using namespace std;

int main(){
    
    long double A, B, H, M;
    cin >> A >> B >> H >> M;
    
    long double answer = sqrt( A*A+B*B-2*A*B*cos( ( M_PI*(H-((11*M)/(60))) ) / (6) ) );
    
    cout << setprecision(20) << answer << endl;
    
    
    return 0;
}


Measured memory_bytes: 4164
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    accum = [0] * (N-1)
    accum[0] = A[0]
    for i in range(1, N-1):
        accum[i] = A[i] + accum[i-1]
    mini = -1
    s = sum(A)
    for i in range(N-1):
        if mini == -1:
            mini = abs(s - 2 * accum[i])
        else:
            mini = min(mini, abs(s - 2 * accum[i]))
    print(mini)
main()

Measured memory_bytes: 26764
#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;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;

int main(){
  int r,d,x[11] = {0};
  cin >> r >> d >> x[0];
  for(int i=1;i<11;i++){
    x[i] = r*x[i-1] -d;
  }
  for(int i=1;i<11;i++) {
    cout << x[i] << "\n";
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    int N;
    int W;
    int[] v;
    int[] w;
	public static void main(String[] args) {
        (new Main()).run();
    }
    
    void run(){
        input();
        long[][] dp = new long[N+1][W+1];
        for(int k=w[1]; k<=W; k++){
            dp[1][k] = v[1];
        }
        for(int i=2; i<=N; i++){
            for(int k=1; k<=W; k++){
                if(k>=w[i]){
                    //System.err.println(dp[i-1][k]+","+(dp[i-1][k-w[i]]+v[i]));
                    dp[i][k] = Math.max(dp[i-1][k], dp[i-1][k-w[i]] + v[i]);
                }else{
                    dp[i][k] = dp[i-1][k];
                }
            }
        }
       
        System.out.println(dp[N][W]);
    }
	void input(){
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        W = sc.nextInt();
        w = new int[N+1];
        v = new int[N+1];
        for(int i=1; i<=N; i++){
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
	}
}

Measured memory_bytes: 127316
#include <bits/stdc++.h>
using namespace std;
long long n, sum[3005], a[3005], dp[3005][3005], v[3005][3005];
long long solve (int l, int r){
	if (l==r) return a[l]; if (v[l][r]) return dp[l][r]; v[l][r]=1; 
	dp[l][r] = max(a[l]+(sum[r]-sum[l]-solve(l+1, r)), a[r]+(sum[r-1]-sum[l-1]-solve(l, r-1)));
	return dp[l][r];
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i=1; i<=n; i++){
	cin >> a[i]; 
	sum[i]=a[i]+sum[i-1];
}
cout << 2*solve(1, n)-sum[n];
return 0;
}


Measured memory_bytes: 96108
// Last Change: 03/24/2019 14:05:10.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  vector<int> ipt(3);
  for (int i = 0; i < 3; ++i) {
    cin >> ipt[i];
  }

  int K;
  cin >> K;

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

  for (int i = 0; i < K; ++i) {
    ipt[2] *= 2;
  }

  cout << ipt[0] + ipt[1] + ipt[2] << endl;

  //NS::LoopUntilZeroInpput();
}


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

#define ll long long int

int main() {

    ll n,m,i,a,b;
    cin>>n>>m;
    vector<ll> heights(n), gB(n,1);
    for(i=0;i<n;i++)
        cin>>heights[i];
    //1->good : 0->bad
    for(i=0;i<m;i++) {
        cin>>a>>b;
        a--;
        b--;
        if(heights[a] > heights[b])
            gB[b] = 0;
        else if(heights[b] > heights[a])
            gB[a] = 0;
        else {
            gB[a] = 0;
            gB[b] = 0;
        }
    }

    ll ans = 0;
    for(i=0;i<n;i++) {
        if(gB[i])
            ans++;
    }
    cout<<ans<<"\n";
    
    return 0;
}

Measured memory_bytes: 4848
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <climits>
#include <cmath>
#include <set>
#include <map>
#include <sstream>
#include <queue>
#include <stack>
using namespace std;
int c[105][105];
vector<int> a;
int main(){
	int level,h,w,n,k=1;
	scanf("%d %d",&h,&w);
	scanf("%d",&n);
	a.resize(n+1);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=h;i++){
		if(i&1){
			for(int j=1;j<=w;j++){
				if(a[k]){
					c[i][j]=k;
				}
				else{
					k++;
					c[i][j]=k;	
				}
				a[k]--;
			}
		}
		else{
			for(int j=w;j>=1;j--){
				if(a[k]){
					c[i][j]=k;
				}
				else{
					k++;
					c[i][j]=k;	
				}
				a[k]--;
			}
		}
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(j!=1) printf(" ");
			printf("%d",c[i][j]);
		}
		printf("\n");
	}
		
	return 0;
}

Measured memory_bytes: 384
/*I know about "bits/stdc++.h" 
But I am not using it for some technical issue*/

#include "iostream"
#include "algorithm"
#include "iomanip"
#include "vector"
#include "set"
#include "sstream"
#include "fstream"
#include "cstring"
#include "cmath"
#include "utility"
#include "map"
#include "bitset"
#include "cassert"
#include "deque"

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define mod (int)1e9 + 7
#define For(i,a,n) for(i=a;i<n;i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;
ll max(ll a,ll b){
	if(a>b) return a;
	return b;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b,c,k,sm = 0;
	cin>>a>>b>>c>>k;
	sm += min(k,a);
	k -= a+b;
	k = max(0,k);
	sm -= min(k,c);
	cout<<sm;
  return 0;
}

Measured memory_bytes: 3692
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=1e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s,t,u;
  cin >> s;
  for(int i=1; i<=7; i++) {
    t=s.substr(0,i);
    u=s.substr(s.size()-7+i,7-i);
    if(t+u=="keyence") {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ans := 1
	for i := 0; i < n; i++ {
		if ans + k > ans * 2 {
			ans = ans * 2
		} else {
			ans = ans + k
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

bool enough(long T, long h[], long A, long B, long N) {
	
	long time = 0;

	for (int i = 1; i <= N; i++) {
        if (h[i] <= B * T) continue;
		time += max((long)0, ((h[i] - B * T) - 1) / (A - B) + 1);
	}

	if (time <= T) return true; else return false;

}

void bi_search(long bigin, long end,long h[], long A, long B, long N) {

	if (end == bigin) { cout << end << endl; return; }


	long mid = (end - bigin) / 2 + bigin;

    if (!enough(mid, h, A, B, N)) bi_search(mid + 1, end, h, A, B, N);
	else bi_search(bigin, mid, h, A, B, N);

}

int main() {

	long N, A, B; cin >> N >> A >> B;

	long h[100009]; for (int i = 1; i <= N; i++) cin >> h[i];

	sort(h + 1, h + N + 1);

	bi_search(1, h[N], h, A, B, N);
    
}

Measured memory_bytes: 1024
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=5005;
struct eg{int v,nx;}e[N<<1];int head[N],tot;
inline void add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
int f[N][N][2],g[N][2],sz[N],cf[N],n,res;
void dfs(int u,int fa){
	sz[u]=1,f[u][1][0]=1;
	go(u)if(v!=fa){
		dfs(v,u);
		memset(g,0,sizeof(g));
		fp(i,1,sz[u])fp(j,0,1){
			R int tmp=f[u][i][j];
			fp(k,1,sz[v])fp(l,0,1)upd(g[i+k][j^l],mul(tmp,f[v][k][l]));
			for(R int k=2;k<=sz[v];k+=2)fp(l,0,1)
				upd(g[i][j^l^1],1ll*tmp*f[v][k][l]%P*cf[k]%P);
		}
		sz[u]+=sz[v];
		fp(i,1,sz[u])fp(j,0,1)f[u][i][j]=g[i][j];
	}
//	printf("Now %d\n",u);
//	fp(i,1,sz[u])fp(j,0,1)printf("%d %d %d\n",i,j,f[u][i][j]);
//	puts("-------------------");
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d",&n);
	for(R int i=1,u,v;i<n;++i)scanf("%d%d",&u,&v),add(u,v),add(v,u);
	cf[0]=1;for(R int i=2;i<=n;i+=2)cf[i]=mul(cf[i-2],i-1);
	dfs(1,0);
	for(R int i=2;i<=n;i+=2)upd(res,mul(f[1][i][0],cf[i])),upd(res,P-mul(f[1][i][1],cf[i]));
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 195072
fun main(args: Array<String>) {

    val N = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    var ans = 0
    var min = p[0]
    for (i in p.indices) {
        if (p[i] <= min) {
            ans++
            min = p[i]
        }
    }

    println(ans)
}

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

int main()
{

  string s;
  cin >> s;
  if (s == "ABC")
  {
    cout << "ARC" << endl;
  }
  else
  {
    cout << "ABC" << endl;
  }
}

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

int N;
vector<int> a;
int ans;

void solve() {
  ans = 0;
  sort(a.begin(), a.end(), greater<int>());
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0) ans += a[i];
    else ans -= a[i];
  }
  cout << ans << endl;
}

int main() {
  cin >> N;
  a.resize(N);
  for (int i = 0; i < N; ++i)
    cin >> a[i];
  solve();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int ans = (b / a < c) ? b / a : c;
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include <stdio.h>

int main()
{
	int a, b, c, d;
	int count = 0;
	int n;

	while (scanf("%d", &n) != EOF) {
		count = 0;
		for (a = 0; a <= 9; a++) {
		for (b = 0; b <= 9; b++) {
		for (c = 0; c <= 9; c++) {
		for (d = 0; d <= 9; d++) {
			if (a + b + c + d == n)
				count++;
		}}}}
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 0
#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;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

struct st{
	int op;
	int a,b,c;
};
const int D=2;
st dp[200000][D+1][D+1][D+1];
string s[200000];
char S[4];

int main(){
	int n,a,b,c;cin>>n>>a>>b>>c;
	rep(i,n){
		scanf("%s",S);
		s[i]=S;
	}
	a=min(a,D);b=min(b,D);c=min(c,D);
	rep(i,n+1)rep(j,D+1)rep(k,D+1)rep(t,D+1){
		dp[i][j][k][t]={-1,-1,-1,-1};
	}
	dp[0][a][b][c]={0,0,0,0};
	rep(i,n)rep(j,D+1)rep(k,D+1)rep(t,D+1){
		if(dp[i][j][k][t].op==-1)continue;
		if(s[i]=="AB"){
			if(j-1>=0){
				dp[i+1][j-1][min(D,k+1)][t]={'B',j,k,t};
			}
			if(k-1>=0){
				dp[i+1][min(D,j+1)][k-1][t]={'A',j,k,t};
			}
		}
		else if(s[i]=="AC"){
			if(j-1>=0){
				dp[i+1][j-1][k][min(D,t+1)]={'C',j,k,t};
			}
			if(t-1>=0){
				dp[i+1][min(D,j+1)][k][t-1]={'A',j,k,t};
			}
		}
		else if(s[i]=="BC"){
			if(k-1>=0){
				dp[i+1][j][k-1][min(D,t+1)]={'C',j,k,t};
			}
			if(t-1>=0){
				dp[i+1][j][min(D,k+1)][t-1]={'B',j,k,t};
			}
		}
	}
	st cur={-1,-1,-1,-1};
	int x=n,ni=-1,nj=-1,nk=-1;
	rep(i,D+1)rep(j,D+1)rep(k,D+1){
		if(dp[n][i][j][k].op!=-1){
			cur=dp[n][i][j][k];
			ni=i;nj=j;nk=k;
		}
	}
	if(cur.op==-1){
		puts("No");return 0;
	}
	puts("Yes");
	vector<char>ans;
	while(x){
		assert(cur.op!=-1);
		ans.push_back((char)cur.op);
		ni=cur.a;nj=cur.b;nk=cur.c;
		cur=dp[x-1][ni][nj][nk];
		x--;
	}
	reverse(ans.begin(),ans.end());
	for(char c:ans){
		cout<<c<<endl;
	}
}

Measured memory_bytes: 52288
str = input()
if str=="SUN":
  print(7)
elif str=="MON":
  print(6)
elif str=="TUE":
  print(5)
elif str=="WED":
  print(4)
elif str=="THU":
  print(3)
elif str=="FRI":
  print(2)
else :
  print(1)

Measured memory_bytes: 2940
using System;
using System.Linq;

namespace ABC081
{
    class B
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var res = int.MaxValue;
            for (var i = 0; i < N; i++)
            {
                var count = 0;
                while ((A[i] % 2) == 0)
                {
                    A[i] /= 2;
                    count++;
                }
                res = Math.Min(count, res);
                if (res == 0) break;
            }
            Console.WriteLine(res);
        }
    }
}

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

struct start { start() {
cin.tie(0);
ios::sync_with_stdio(0);
cout << fixed << setprecision(10);
}; }start;

typedef long long ll;


int main(){
    int n,memo;
    char s;
    cin >> n;
    bool is_exist[4][13];
    
    rep(i,0,4){
        rep(j,0,13){
            is_exist[i][j] = false;
        }
    }
    
    rep(i,0,n){
        cin >> s >> memo;
        switch(s){
            case 'S':
                is_exist[0][memo-1] = true;
                break;
            case 'H':
                is_exist[1][memo-1] = true;
                break;
            case 'C':
                is_exist[2][memo-1] = true;
                break;
            case 'D':
                is_exist[3][memo-1] = true;
                break;
        }
    }
    
    rep(i,0,4){
        rep(j,0,13){
            if(!is_exist[i][j]){
               switch(i){
                    case 0:
                        cout << "S " << j+1 << endl;
                        break;
                    case 1:
                        cout << "H " << j+1 << endl;
                        break;
                    case 2:
                        cout << "C " << j+1 << endl;
                        break;
                    case 3:
                        cout << "D " << j+1 << endl;
                        break;
               } 
            }
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 3176
#include <stdio.h>

int main(void)
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

    if (x>=r && y>=r)
    {
        if (x+r<=W && y+r<=H)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2140
import numpy as np
N,L=map(int,input().split())
taste=np.zeros(N)
for i in range(N):
  taste[i]=L+i
tot=sum(taste)
min_taste=abs(taste[0])
min_i=0
for i in range(N):
  if min_taste>abs(taste[i]):
    min_taste=abs(taste[i])
    min_i=i
print(int(tot-taste[min_i]))

Measured memory_bytes: 12508