akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define NODEMAX 25

typedef struct {
  int parent;
  int left;
  int right;
} Node;

int measureheight(Node *,int,int);

int main()
{
  int i, j, n, id, sibling, degree, depth, height;
  Node T[NODEMAX];

  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++) {
    T[i].parent = -1;
  }
  
  for(i = 0; i < n; i++) {
    scanf("%d",&id);
    scanf("%d%d",&T[id].left,&T[id].right);
    T[T[id].left].parent = id;
    T[T[id].right].parent = id;
  }
  
  for(i = 0; i < n; i++) {

    /*sibling*/
    id = T[i].parent;
    if(id < 0) {
      sibling = -1;
    }
    else if(T[id].left == i) sibling = T[id].right;
    else sibling = T[id].left;

    /*degree*/
    degree = 0;
    if(T[i].left >= 0) degree++;
    if(T[i].right >= 0) degree++;

    /*depth*/
    depth = 0;
    id = i;
    while(T[id].parent >= 0) {
      id = T[id].parent;
      depth++;
    }

    /*height*/
    height = measureheight(T,i,0);

    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, T[i].parent, sibling, degree, depth, height);

    if(T[i].parent < 0) printf("root");
    else if(degree == 0) printf("leaf");
    else printf("internal node");

    printf("\n");
  }

  return 0;
}

int measureheight(Node * T, int id, int height)
{
  int lefth, righth;
  if(id >= 0) {
    lefth = measureheight(T,T[id].left,height+1);
    righth = measureheight(T,T[id].right,height+1);
    if(lefth > righth) return lefth;
    else return righth;
  }
  return height-1;
}




Measured memory_bytes: 2132
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<int>;


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

	mat wf(N, vec(N, 3000000001));

	for (int i = 0; i < N; ++i) { wf[i][i] = 0; }

	for (int i = 0; i < M; ++i)
	{
		int A, B, C;
		cin >> A >> B >> C;
		--A; --B;

		wf[A][B] = C;
		wf[B][A] = C;
	}

	for (int k = 0; k < N; ++k)
	{
		for (int i = 0; i < N; ++i)
		{
			for (int j = 0; j < N; ++j)
			{
				wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
			}
		}
	}

	mat edge(N);

	for (int i = 0; i < N; ++i)
	{
		for (int j = i+1; j < N; ++j)
		{
			if (wf[i][j] <= L)
			{
				edge[i].emplace_back(j);
				edge[j].emplace_back(i);
			}
		}
	}


	int Q; cin >> Q;
	for (int i = 0; i < Q; ++i)
	{
		int s, t;
		cin >> s >> t;
		--s; --t;
		
		lst Q;
		vec used(N, -1);

		Q.emplace_back(s);
		used[s] = 0;

		int ans = -1;
		bool flag = true;

		while (!Q.empty()&&flag)
		{
			int v = Q.front(); Q.pop_front();
			
			for (int u : edge[v])
			{
				if (used[u] != -1) { continue; }
				else if (u == t)
				{
					ans = used[v];
					flag = false;
					break;
				}
				else
				{
					used[u] = used[v] + 1;
					Q.emplace_back(u);
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <stdio.h>
using namespace std;


int n;
vector<int> adj[200200];
int sol[200200];
int deg[200200];
int arr[200200];

int mex(vector<int> a){
	sort(a.begin(),a.end());
	for(int i=0;i<a.size();i++){
		if(a[i] != i)return i;
	}
	return (int)a.size();
}
queue<int> bf;

pair<int,int> cycle[200200];

int h=0;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		sol[i]=-1;
		int x;
		scanf("%d",&x);
		arr[i]=x;
		deg[x]++;
		adj[x].push_back(i);
	}
	for(int i=1;i<=n;i++){
		if(deg[i]==0){
			bf.push(i);
		}
	}
	while(!bf.empty()){
		int nd=bf.front();
		bf.pop();

		vector<int> g;
		for(int i=0;i<adj[nd].size();i++){
			g.push_back(sol[adj[nd][i]]);
		}
		sol[nd] = mex(g);
		deg[arr[nd]] -- ;
		if(deg[arr[nd]] == 0 ){
			bf.push(arr[nd]);
		}
	}
	int st,cnt_all=0;
	for(int i=1;i<=n;i++){
		if(sol[i]!=-1)continue;
		st=i;
		cnt_all++;
	}
	int mn=1<<20,cnt=0,prv=1<<20;
	for(int i=1;i<=n;i++){
		if(sol[i]!=-1)continue;
		vector<int> g;
		for(int j=0;j<adj[i].size();j++){
			int ch=adj[i][j];
			if(sol[ch]==-1)continue;
			g.push_back(sol[ch]);
		}
		int mxxx=mex(g);
		if(mn==mxxx){
			cnt++;
		} else if( mxxx < mn){
			cnt = 1; 
			mn = mxxx;
		}
	}
	if( cnt_all % 2 && cnt == cnt_all){
		cout<<"IMPOSSIBLE"<<endl;
	} else {
		cout<<"POSSIBLE"<<endl;
	}
	return 0;

	/*
	bool is_first=true;
	while(true){
		vector<int> g;
		for(int j=0;j<adj[st].size();j++){
			int ch=adj[st][j];
			if(sol[ch]==-1)continue;
			g.push_back(sol[ch]);
		}
		int mxxx=mex(g);
		if(mxxx==mn && mxxx != prv && !is_first){
			break;
		} else {
			st= arr[st];
			prv= mxxx;
		}
		is_first=false;
	}

	bool ok=true;
	sol[st] = mn;
	int end= st;
	st=arr[st];
	while(st != end){
		vector<int> g;
		for(int j=0;j<adj[st].size();j++){
			int ch=adj[st][j];
			if(sol[ch]==-1)continue;
			g.push_back(sol[ch]);
		}

		int mxxx= mex(g);

		
	}
	*/
}

Measured memory_bytes: 12672
s = input()

flag = 0
while s != []:
  ss=s
  if s=='erase':
    s = []
  elif len(s)>5 and s[0:6]=='erasee':
    s = s[5:]
  elif len(s)>5 and s[0:6]=='erased':
    s = s[5:]
  elif s=='eraser':
    s = []
  elif len(s)>6 and s[0:7]=='erasere':
    s = s[6:]
  elif len(s)>6 and s[0:7]=='eraserd':
    s = s[6:]
  elif s=='dreamer':
    s = []
  elif len(s)>7 and s[0:8]=='dreamere':
    s = s[7:]
  elif len(s)>7 and s[0:8]=='dreamerd':
    s = s[7:]
  elif s=='dream':
    s = []
  elif len(s)>5 and s[0:6]=='dreamd':
    s = s[5:]
  elif len(s)>5 and s[0:6]=='dreame':
    s = s[5:]

  if ss==s:
    flag=1
    break

if flag==0:
  print("YES")
else:
  print("NO")
    
# dream dreamer erase eraser


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{   
    int r,c;
    cin>>r>>c;
    int matx[r][c],ans[r]={0},t;
    for(int i=0;i<r;i++)
        for(int j=0;j<c;j++)
            cin>>matx[i][j];
    
    for(int i=0;i<c;i++){
        cin>>t;
        for(int j=0;j<r;j++)
            ans[j] += t*matx[j][i];
    }
    for(int i=0;i<r;i++)
        cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 3120
import java.util.*;
public class Main
 {
     public static void main(String[] args)
   {
     Scanner s=new Scanner(System.in);
     int n=s.nextInt();
     int m=s.nextInt();
     int ans=0;
    ans=(n*(n-1)/2)+(m*(m-1)/2);
    System.out.println(ans);
   } 
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	char a, b;
	cin >> a >> b;

	int result = (b == 'D') ? 0 : 1;
	int value = 0;
	if (a == 'D') value = 1;

	cout << ((result ^ value) ? 'H' : 'D');

	return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, h;
string s;
int cnts[100001];		//cnts[i] = i桁(no leading 0)の数がいくつあるか. "0"や"00"は0桁としてカウント.
int begin_cnts[100001];

//spagetti-source, 動く形に書き直すのが難しかった()
struct SAComp {
  const int h, *g;
  SAComp(int h, int* g) : h(h), g(g) {}
  bool operator() (int a, int b) {
    return a == b ? false : g[a] != g[b] ? g[a] < g[b] : g[a+h] < g[b+h];
  }
};
vector<int> construct_sa(string s) {
  int n = s.length();
  int *g = new int[n+1];
  int *b = new int[n+1];
  int *v = new int[n+1];
  int i;
  rep(i,n+1) v[i] = i, g[i] = s[i];
  b[0] = 0; b[n] = 0;

  sort(v, v+n+1, SAComp(0, g));
  for(int h = 1; b[n] != n ; h *= 2) {
    SAComp comp(h, g);
    sort(v, v+n+1, comp);
    rep(i, n) b[i+1] = b[i] + comp(v[i], v[i+1]);
    rep(i, n+1) g[v[i]] = b[i];
  }
  delete[] g;
  delete[] b;
  
  vector<int> ret;
  rep(i, n + 1) ret.push_back(v[i]);
  delete[] v;
  return ret;
}

/*vector<int> construct_sa(string &s) {
	vector<string> vs;
	int i, j;
	
	rep(i, s.length() + 1) {
		string suf;
		for (j = i; j < s.length(); j++) suf += s[j];
		vs.push_back(suf);
	}
	sort(vs.begin(), vs.end());
	
	vector<int> sa;
	rep(i, vs.size()) sa.push_back(s.length() - vs[i].length());
	return sa;
}*/

signed main() {
	int i, j;
	
	cin >> n >> h >> s;
	
	j = 0;
	rep(i, n) {
		if (j < i) j = i;
		for (; j < n; j++) if (s[j] != '0') break;
		
		cnts[0] += j - i;
		cnts[1] -= j - i;
		cnts[1] += 1;
		cnts[n - j + 1] -= 1;
	}
	rep(i, n) cnts[i + 1] += cnts[i];
	
	int cnt = 0;
	rep(i, n + 1) {
		cnt += cnts[i];
		if (cnt >= h) break;
	}
	
	int keta = i;
	if (keta == 0) { cout << 0 << endl; return 0; }
	
	cnt = 0;
	rep(i, keta) { cnt += cnts[i]; }
	h = h - cnt;
	
	j = n - keta;
	for (i = n - keta; i >= 0; i--) {
		if (s[i] == '0') continue;
		if (j >= i) j = i - 1;
		for (; j >= 0; j--) if (s[j] != '0') break;
		begin_cnts[i] = i - j;
	}
	
	vector<int> sa = construct_sa(s);
	
	//rep(i, sa.size()) cout << "sa[" << i << "] = " << sa[i] << endl;
	
	rep(i, sa.size()) {
		if (sa[i] == s.length()) continue;	//空文字列
		if (s[sa[i]] == '0') continue;		//先頭が0のものは無視
		h -= begin_cnts[sa[i]];				//[0…0], s[sa[i]], …であって、桁数= ketaになるパターン数
		if (h <= 0) break;
	}
	
	int offset = sa[i];
	string ans;
	rep(i, keta) ans += s[offset + i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6836
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    n--;
    long dif = abs(a - b),
         q1 = (dif + n * c) / (c + d),
         q2 = (dif + n * d) / (c + d),
         r1 = (dif + n * c) % (c + d);
    if ((q1 < q2 && q1+1 <= n) || (r1 == 0 && q1 <= n))
        cout << "YES" << '\n';
    else 
        cout << "NO" << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
using namespace std;
int main(void){

	int n,i,j,pm,pe,pj,a,d=-1,c=-1,max=-1;
	scanf("%d",&n);
	while ( n > 0){
		for (i = 0; i < n; i++){
			scanf("%d %d %d",&pm,&pe,&pj);
			if ((pm == 100 || pe == 100 || pj == 100) || ((pm + pe) / 2>=90||(pe+pj+pm)/3>=80)){

				printf("A\n");
			}
			else if ((pe + pj + pm) / 3 >= 70 || ((pm + pj + pe) / 3 >= 50 && (pe >= 80 || pm >= 80))){
				printf("B\n");
			}
			else printf("C\n");
		}
			scanf("%d", &n);
	}
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i ++)
#define for1(i, n) for (int i = 1; i <= n; i ++)
#define repn(i, n) for (int i = n-1; i >= 0; i --)
#define rep1(i, n) for (int i = n; i >= 1; i --)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define f first
#define s second
using namespace std;
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
typedef long long ll;
const int INF = 1e9;
const ll INFl = 1e18;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef queue<int> qi;
typedef queue<pii> qpii;

void test_case() {
	int n; cin >> n;
	vi divs(20000005);
	ll ans = 0;
	for (int i = 1; i <= n; i ++) {
		for (int j = i; j <= n; j += i) 
			divs[j] ++;
	}
	for (int i = 1; i <= n; i ++) 
		ans += 1LL * divs[i] * i;
	cout << ans << '\n';
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int q = 1;
	//cin >> q; 
	while (q--) {
		test_case();
	}
	return 0;
}


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

int main(){
  int N; cin >> N;
  int A[100000], B[100000], C[100000];
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++) cin >> B[i];
  for(int i=0; i<N; i++) cin >> C[i];
  sort(A,A+N);
  sort(B,B+N);
  sort(C,C+N);
  long long AB[100000];
  int j=0;
  for(int i=0; i<N; i++){
    while(j<N&&A[j]<B[i]){
      j++;
    }
    AB[i]=j;
  }
  for(int i=1; i<N; i++){
    AB[i]+=AB[i-1];
  }
  j=0;
  long long result=0;
  for(int i=0; i<N; i++){
    while(j<N&&B[j]<C[i]){
      j++;
    }
    if(j!=0){
      result+=AB[j-1];
    }
  }
  cout << result << endl;
}

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

int main() {
	long long A,B,K;cin>>A>>B>>K;

	cout<<(K>=A?0:A-K)<<" "<<(K>=A?(K-A>=B?0:B-(K-A)):B)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    ll n;
    cin >> n;
    vector<string> s(n);
    map<string,ll> mp;
    rep(i,n){
        cin >> s[i];
        mp[s[i]]++;
    }
    ll m=-1;
    vector<string> t;
    for(auto x:mp){
        m=max(m,x.second);
    }
    for(auto x:mp){
        if(x.second==m){
            t.push_back(x.first);
        }
    }
    
    sort(t.begin(),t.end());
    rep(i,t.size()){
        cout << t[i] << endl;
    }
    return 0;
} 

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

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

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

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

fn main() {
    let k: u64 = read();
    let n = k / 50;
    let m = k % 50;
    println!("50");
    let v: Vec<u64> = (0..51).collect();
    let mut ans: Vec<u64> = vec![];
    for i in 0..51 {
        if i == 50 - m {
            continue;
        }
        ans.push(v[i as usize] + n);
    }
    for a in ans {
        println!("{}", a);
    }
}


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

using namespace std;
int main(void){
    string s;
    cin>>s;
    int sum=700;
    if(s[0]=='o')sum+=100;
    if(s[1]=='o')sum+=100;
    if(s[2]=='o')sum+=100;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    cnt = 0
    for i in range(N):
        if i % 2 == 0 and A[i] % 2 == 1:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 62004
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

#define ll long long
using vt = int; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

int main() {
	char c;
	cin >> c;
	c++;
	cout << c;
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PN printf("\n")
#define MODV 1000000007

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
void addmod(int &a, ll b){a=(a+b); if(a>=MODV)a-=MODV;}
void mulmod(int &a, ll b){a=(a*b)%MODV;}
template<class T>bool domin(T &a, const T &b){return a>b?a=b,1:0;}
template<class T>bool domax(T &a, const T &b){return a<b?a=b,1:0;}
int gi(){int a;scanf("%d",&a);return a;}
ll gll(){ll a;scanf("%lld",&a);return a;}

int main() {
  int n=gi(), mn=MODV, sm=0;
  for(int i=0;i<n;i++){
    int v=gi();
    sm+=v;
    if(v%10)domin(mn,v);
  }
  if(mn==MODV)mn=sm;
  if(sm%10)cout<<sm<<endl;
  else cout<<sm-mn<<endl;

  return 0;
}

Measured memory_bytes: 256
N, K = map(float, input().split())
N_ = N

ans = 0
cout = 0
while True:
  if N - K >= 0:
    ans += (N-K+1) / (2**cout)
    N = K - 1
  if K == 1:
    break
  K = (K+1) // 2
  cout += 1
print(ans / N_)

Measured memory_bytes: 2940
n = int(input())
 
a = list(map(int,input().split()))

#分母となる変数
ans = 0

#1/Aを次々に計算していき、分母を求めます
for i in range(n):
    ans += 1/a[i]
    
#分母の逆数を出力します
print(1/ans)

Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

i64 gcd(i64 a, i64 b) { return b ? gcd(b, a % b) : a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  // 整数列 A を全て 2 で割った整数列 B = b1, b2,...,bN
  // bk * (2p + 1) = X
  // つまりどの数にも奇数をかけて得られる最小公倍数がX
  // B に偶数が含まれていた場合、いずれのbkに対しても2がかけられている個数が同じでないといけない
  // そうでない場合は、個数は 0 になる
  // 最小公倍数を m とすると、m, 3m, 5m, 7m... が答えになるのでそれを数える
  
  int N, M;
  cin >> N >> M;

  vector<int> as(N);
  bool fail = false;

  cin >> as[0];
  as[0] >>= 1;
  int ns = 0;
  while (!(as[0] & 1)) {
    as[0] >>= 1;
    ns++;
  }

  FOR(i, 1, N) {
    cin >> as[i];
    as[i] >>= 1;

    int n = 0;
    while (!(as[i] & 1)) {
      as[i] >>= 1;
      n++;
    }
    if (n != ns) fail = true;
  }

  i64 result;
  if (!fail) {
    M >>= ns;

    i64 lcm = 1;
    F0R(i, N) {
      lcm = ::lcm(lcm, as[i]);
      if (lcm > M) {
        fail = true;
        break;
      }
    }
    if (!fail)
      result = (M / lcm + 1) / 2;
  }

  cout << (fail ? 0 : result);
}
#endif


Measured memory_bytes: 640
N = int(input())
count_dict = {}
answer = []
for i in range(N):
  key = input()
  if key in count_dict.keys():
    count_dict[key] += 1
  else:
    count_dict[key] = 1
sorted_dict = sorted(count_dict.items(), key=lambda x:x[1], reverse=True)
max_count = sorted_dict[0][1]
answer.append(sorted_dict[0][0])

for i in range(1, len(sorted_dict)):
  if sorted_dict[i][1] == max_count:
    answer.append(sorted_dict[i][0])
  else:
    break

for key in sorted(answer):
  print(key)

Measured memory_bytes: 47320
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using lld = long long int ;
#define mod 1000000007; 

int main(){
    lld N;
    cin >> N;
    lld ans10 =1;
    lld ans9 = 1;
    lld ans8 = 1;
    if(N<=2){
        cout << N*(N-1) <<endl;
        return 0;
    }else{
        for(int i=0;i<N;i++){
            ans10*=10;
            ans10%=mod;

            ans9*=9;
            ans9%=mod;
            
            ans8*=8;
            ans8%=mod;
        }
    }
    lld ans =(ans10+ans8)%mod;
    ans=(ans-ans9)%mod;
    ans=(ans-ans9)%mod;
    ans+=1000000007;
    ans%=1000000007;
    cout << ans <<endl;
    return 0;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    string s;
    cin>>s;
    for(ll i=0;i<3;++i){
        cout<<s[i];
    }
    cout<<endl;
}

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

int main(){
  int x;
  cin >> x;
  if(x)cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 3620
// Problem : C - Forbidden List
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define fi first
#define se second
#define pb push_back
 
#define ll long long
#define pii pair<int, int>
//#define int ll
const int MOD = 1000000007;

bool cot[105];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int x, n; cin >> x >> n;
    rep(i, n) {
    	int p; cin >> p;
    	cot[p] = 1;
    }
    int ans = 0;
    rep(i, 102) {
    	if(cot[i]) continue;
    	if(abs(ans-x) > abs(i-x)) ans = i;
    }
    cout << ans;
}



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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 200000, MAX_Q = 200000;
int n,q;
ll s[MAX_N];
ll t[MAX_N];
ll x[MAX_N];
set<pli> l;
set<pli> r;
ll d[MAX_Q];
set<pli> xs;

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> q;
  forn(i,n) {
    cin >> s[i] >> t[i] >> x[i];
    l.insert(mp(x[i]-s[i],i));
  }

  forn(i,q) cin >> d[i];

  forn(i,q) {
    while (!l.empty() && l.rbegin()->fst >= -d[i]) {
      int j = l.rbegin()->snd;
      r.insert(mp(x[j]-t[j],j));
      xs.insert(mp(x[j],j));
      l.erase(*l.rbegin());
    }

    while (!r.empty() && r.rbegin()->fst >= -d[i]) {
      xs.erase(mp(x[r.rbegin()->snd],r.rbegin()->snd));
      r.erase(*r.rbegin());
    }

    if (r.empty())
      printf("-1\n");
    else {
      printf("%lld\n", xs.begin()->fst);
    }
  }

  return 0;
}


Measured memory_bytes: 32512
n=int(input())

a=0
b=-1
c=[]
while b!=0:
  a=n%26
  b=n//26
  n=b
  
  c.append(a)

for i in range(0,len(c)-1):
  if c[i]==0 or c[i]==-1:
    c[i]+=26
    c[i+1]-=1


ss=""
for i in reversed(range(len(c))):
  if ss=="" and c[i]==0:
    continue
  ss+=chr(96+c[i])
  
print(ss)

Measured memory_bytes: 9212
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }

    val x = LongArray(n)
    val y = LongArray(n)
    val z = LongArray(n)

    for ( i in 0 until n) {
        val (a, b, c) = readLine()!!.split(" ").map { it.toLong() }
        x[i] = a
        y[i] = b
        z[i] = c
    }

    // 最大化させるときのシチュエーションを考える

    // 解説：それぞれ符号が変わってくることは考えていたが，そこから実際に符号を掛けて探索する方針を考えられなかった
    // それぞれの項目に絶対値演算をして総和
    // 絶対値 -> + or - をかける かどうか
    // -> 各項目を + or - をかける前提で足し合わせたときの Max を求める ( 2,2,2 = 8 パターン）
    // -> + or - をかけた後の上位 m 個を取ればOK

    var max = 0L
    val sign = listOf(-1, 1)

    for (i in sign) {
        for (j in sign) {
            for (k in sign){
                var xTmp = x.clone().map { i*it }.toLongArray()
                var yTmp = y.clone().map { j*it }.toLongArray()
                var zTmp = z.clone().map { k*it }.toLongArray()

                // ソート
                // WA x,y,z 個別にはソートできないので注意
                val sumArray = (0..n-1).map { xTmp[it] + yTmp[it] + zTmp[it]}.sortedDescending()
                var sum = 0L
                for ( l in 0 until m) {
                    sum += sumArray[l]
                }

                if ( sum >= max) {
                    max = sum
                }
            }
        }
    }

    println(max)
}

Measured memory_bytes: 39372
//# pragma GCC optimize("Ofast,no-stack-protector")
//# pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
# pragma GCC optimize("Ofast")
# pragma GCC optimization ("unroll-loops")
# include "bits/stdc++.h"
/*
# include <ext/pb_ds/tree_policy.hpp>
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/rope>
*/
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

/*
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
Tree<int>tr;
*/

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# define LOCAL
# define sim template < class c
# define ris return * this
# define dor > debug & operator <<
# define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define show(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int gcd(int a, int b)
{
if(b) return gcd(b,a%b);
return a;
}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int n,x;
multiset<int>ms;

int32_t main(){_
	//freopen("input","r",stdin);
	cin >> n;
	for(int i = 0;i < (1 << n);i++){
		cin >> x;
		ms.insert(x);
	}
	vector<int>vec;
	vec.pb(*(--ms.end()));
	ms.erase(--ms.end());
	for(int i = 1;i <= n;i++){
		sort(vec.rbegin(),vec.rend());
		vector<int>aux;
		for(auto it : vec){
			auto itt = ms.lower_bound(it);
			if(itt == ms.begin()) rc("No");
			itt--;
			aux.pb(*itt);
			ms.erase(itt);
		}
		for(auto it : aux) vec.pb(it);
	}
	rc("Yes");
}











Measured memory_bytes: 14012
n = int(input())
list_c = list(map(int,input().split()))
list_d = []

for i in range(n):
  list_d.append(list(map(int,input().split())))

now = [0]*26

max_happy = -100000000
index_max = -1
yesterday = -1

for day in range(1,n+1):
  max_happy = -100000000
  index_max = -1
  for i in range(26):
    if i != yesterday:
      score = list_d[day-1][i]
      for batu in range(26):
        if batu != i:
          score -= list_c[i] * (day - now[i]) 
      
      if score > max_happy:
        index_max = i
        max_happy = score
  
  now[index_max] = day
  yesterday = index_max
    
  print(index_max+1)
  
    


Measured memory_bytes: 9408
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

template<class T>
T gcd(T n,T m){
    if(n>m) return gcd(m,n);
    else if(n==0) return m;
    else return gcd(m-n*(m/n),n);
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,m;
    in>>n>>m;
    vector<ll> A(n);
    for(auto&i:A) in>>i;
    sort(A.rbegin(),A.rend());
    unsigned long long a,x=1,d;
    fr(i,n){
        a=A[i];
        if(x%a==0&&(x/a)%2==0)
            return cout<<0<<endl,0;
        d=gcd(a,x);
        if(x>2*m/(a/d)+1) return cout<<0<<endl,0;
        x*=a/d;
    }
    cout<<(m+x/2)/x<<endl;

}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
int main(void){
  int x,y,z,e,t,m;
  while(1){
    scanf("%d",&e);
    if(!e)
      break;
    m=1000000;
    z=(int)pow(e,1./3)+1;
    for(;z>=0;z--){
      if(z*z*z>e)
	continue;
      t=e;
      t-=z*z*z;
      y=(int)pow(t,1./2);
      t-=y*y;
      x=t;
      if(m>x+y+z)
	m=x+y+z;
    }
    printf("%d\n",m);
  }
  return 0;
}

Measured memory_bytes: 720
import bisect


n = int(input())
l = list(map(int,input().split()))


l.sort()
c = 0
for i in range(n)[::-1]:
    for j in range(i)[::-1]:
        d = l[i] - l[j]
        idx = bisect.bisect_right(l,d)
        c += max(0,j-idx)
print(c)


Measured memory_bytes: 3316
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll x,y,z,k;
    cin >>x>>y>>z>>k;
    ll a[1010],b[1010],c[1010];
    rep(i,x) cin>>a[i];
    rep(i,y) cin>>b[i];
    rep(i,z) cin>>c[i];

    priority_queue<ll> que;
    rep(i,x){
        rep(j,y){
            que.push(a[i]+b[j]);
        }
    }
    ll size = que.size();
    priority_queue<ll> res;
    rep(i,min(k,size)){
        ll current = que.top();
        que.pop();
        rep(j,z){
            res.push(current+c[j]);
        }
    }
    rep(i,k){
        ll current = res.top();
        res.pop();
        cout    << current << endl;
    }
}


Measured memory_bytes: 43364
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		boolean[] balls=new boolean[N];
		balls[0]=true;
		int[] ballvol=new int[N];
		for(int i=0; i<N; i++) {
			ballvol[i]=1;
		}
		for(int i=0; i<M; i++) {
			int s=sc.nextInt();
			int g=sc.nextInt();
			if(balls[s-1]) {
				if(ballvol[s-1]>1) {
					balls[g-1]=true;
					ballvol[s-1]--;
					ballvol[g-1]++;
					/*for(int j=0; j<N; j++) {
						System.out.print(ballvol[j]+" ");
					}*/
				}
				else if(ballvol[s-1]==1) {
					balls[s-1]=false;
					balls[g-1]=true;
					ballvol[s-1]--;
					ballvol[g-1]++;
					/*for(int j=0; j<N; j++) {
						System.out.print(ballvol[j]+" ");
					}*/
				}
			}
			else {
				ballvol[s-1]--;
				ballvol[g-1]++;
				/*for(int j=0; j<N; j++) {
					System.out.print(ballvol[j]+" ");
				}*/
			}
		}
		int count=0;
		for(int i=0; i<N; i++) {
			if(balls[i]) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 66284
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;

typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;

typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 
typedef vector<pd> vpd; 

#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 

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

const int MX  = 2e5+5; 
const int MOD = 1e9+7; // 998244353;
const ll  INF = 1e18; 
const ld  PI  = acos((ld)-1);

const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 

template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool ckmax(T& a, const T& b) { 
	return a < b ? a = b, 1 : 0; 
} 

constexpr int pct(int x) { return __builtin_popcount(x); } // number of ones 
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
template<class T> T cdiv(T a, T b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 

int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}

template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); 
}

// DEBUG
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << h; if (sizeof...(t)) cerr << ", ";
	DBG(t...); 
}
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

// FILE I/O
void setIn(str S) { freopen(S.c_str(),"r",stdin); }
void setOut(str S) { freopen(S.c_str(),"w",stdout); }
void setIO(str S = "") {
	ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(S)) { setIn(S+".in"), setOut(S+".out"); } // for USACO
}

int32_t main() { 
	
	setIO();

    int x; cin >> x;

    cout << !x << "\n";

}

Measured memory_bytes: 3608
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)

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

const int MOD = 1e9 + 7;
const int maxn = 1;
const double EPS = 1e-8;

class AOnTheWay {
public:
	void solve(std::istream& in, std::ostream& out) {
		int a, b, c;
		in>>a>>b>>c;
		bool f1 = a < c && c < b;
		bool f2 = b < c && c < a;
		if(f1 || f2)out << "Yes" << '\n';
		else out << "No" << '\n';
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	AOnTheWay solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, i, w[200003] = {}, r[200003] = {}, ans;
    string c;

    scanf("%d", &n);
    cin >> c;

    for (i = 1; i < n + 1; i++) {
        w[i] = w[i - 1];
        if (c[i - 1] == 'W') {
            w[i]++;
        }
    }
    for (i = n - 1; i >= 0; i--) {
        r[i] = r[i + 1];
        if (c[i] == 'R') {
            r[i]++;
        }
    }

    ans = INF;
    for (i = 0; i < n + 1; i++) {
        ans = min(ans, max(w[i], r[i]));
    }

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

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector< pair<ll, ll> > ba(n);
    for(int i=0; i<n; i++){
        cin >> ba[i].second >> ba[i].first;
    }
    sort(ba.begin(), ba.end());
    ll sum_a = 0;
    ll sum_b = 0;
    bool ans = true;
    for(int i=0; i<n; i++){
        sum_a += ba[i].second;
        if(sum_a > ba[i].first){
            ans = false;
            break;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e7 + 5;

int n;
int f[N];

int32_t main()
{
	IOS;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; i * j <= n; j++)
			f[i * j]++;
		ans += i * f[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 81760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


const ll MOD = pow(10, 9) + 7;

ll powmod(ll a, ll p, ll MOD) {
	ll ans = 1;
	ll mul = a;
	for (; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
		if ((p & 1) == 1)ans = (ans * mul) % MOD;
	}
	return ans;
}

ll combmod(ll n, ll r, ll MOD){
  if(n < r) return 0LL;
  if (n < 0 || r < 0) return 0LL;
  vector<ll> ff(n+1), vff(n+1);
  // 1! ~ n!
  ff[0] = 1;
  for(ll i = 1; i < n + 1; i++) {
    ff[i] = ff[i - 1] * i % MOD;
  }
  // n!^(MOD-2) (= n!^(-1))
  ll inv = powmod(ff[n], MOD - 2, MOD);

  // n!^(-1) ~ 1!^(-1)
  vff[n] = inv;
  for(ll i = n - 1; i >= 0; i--) {
    vff[i] = vff[i + 1] * (i + 1) % MOD;
  }

  // n combination r
  ll comb = (((ff[n] * vff[r]) % MOD) * vff[n - r]) % MOD;

  return comb;
}

ll calc(ll M, ll N){
  ll tmp = (M * M) % MOD;
  tmp = (tmp * M) % MOD;
  ll tmp2 = powmod(6, MOD-2, MOD);
  tmp = (MOD + tmp - M) % MOD;
  tmp = (tmp * tmp2) % MOD;
  ll tmp1 = (N * N) % MOD;
  tmp = (tmp * tmp1) % MOD;
  return tmp;
}

int main() {

  ll N, M, K;
  cin >> N >> M >> K;

  ll ans = 0;

  ll pat = combmod(N * M - 2, K - 2, MOD);

  ll tmp = calc(N, M) + calc(M, N);
  tmp %= MOD;

  tmp = (tmp * pat) % MOD;

  cout << tmp << endl;


  return 0;
}


Measured memory_bytes: 3328
/*
g++ -std=c++11 -o2 -Wall ABC104B.cpp -o ./out/ABC104B.out
./out/ABC104B.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

bool f1, f2, f3;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  if (s[0] == 'A') f1 = true;
  int cnt = 0;
  int idx = -1;
  for (int i = 2; i <= n - 2; ++i) {
    if (s[i] == 'C') {
      ++cnt;
      idx = i;
    }
  }
  if (cnt==1 && idx != -1) f2 = true;
  f3 = f2;
  if (f3) {
    for (int i = 0; i < n; ++i) {
      if ((i != 0 && i != idx) && (s[i] - 'A' >= 0) && (s[i] - 'Z' <= 0)) {
        f3 = false;
//        cout << i << "\n";
      }
    }
  }
//  cout << f1 << " " << f2 << " " << f3 << "\n";
  if (f1 && f2 && f3) cout << "AC\n";
  else cout << "WA\n";
}


Measured memory_bytes: 256
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define per(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003LL;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

int main() {
    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    vector<ll> w(n), z(n);
    rep(i, n) {
        w[i] = x[i] - y[i];
        z[i] = x[i] + y[i];
    }
    cout << max(*max_element(all(w)) - *min_element(all(w)), *max_element(all(z)) - *min_element(all(z))) << "\n";
}


Measured memory_bytes: 9476
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n,k,l[55];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  sort(l,l+n,greater<int>());
  int out=0;
  for(int i=0;i<k;i++){
    out+=l[i];
  }
  cout<<out<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i=0; i<n; i++)
 
using namespace std;
const double PI = acos(-1);
using Graph = vector<vector<int>>;
 
int main() 
{
	int l, r, d;
	cin >> l >> r >> d;
	int count = 0;
	int i = 1;
	int d_d = d;
	while (d <= r)
	{
		if (d <= r && d >= l)
			count++;
		d = d_d;
		i++;
		d *= i;
	}
	cout << count << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1<<17|3;
int n,fa[N];ll qz[N];Vi e[N];vector<Pll>a[N];
Pll b[N],c[N];ll mid;
void push(Pll *a, int &top, Pll x){
	if(!(top&&a[top].se<=x.se))a[++top]=x;
}
void dfs(int u){
	if(!SZ(e[u])){a[u].pb(Pll(qz[u],qz[u]));return;}
	rep(i,0,SZ(e[u])-1)dfs(e[u][i]);int x=e[u][0],y=e[u][1];
	if(SZ(a[x])>SZ(a[y]))swap(x,y);//x-->y
	int l1=0,l2=0;
	for(int i=0,j=-1;i<SZ(a[x]);i++){
		while(j+1<SZ(a[y])&&a[x][i].se+a[y][j+1].fi-2*qz[u]<=mid)j++;
		if(j>=0)push(b,l1,Pll(a[x][i].fi,a[y][j].se));
	}
	for(int i=0,j=0;i<SZ(a[x]);i++){
		while(j<SZ(a[y])&&a[x][i].fi+a[y][j].se-2*qz[u]>mid)j++;
		if(j<SZ(a[y]))push(c,l2,Pll(a[y][j].fi,a[x][i].se));
	}
	static Pll d[N];int len=0,p1=1,p2=1;
	while(p1<=l1||p2<=l2){
		if(p1>l1||p2<=l2&&c[p2].fi<=b[p1].fi)push(d,len,c[p2++]);
		else push(d,len,b[p1++]);
	}
	rep(i,1,len)a[u].pb(d[i]);
}
int main() {
	ll l=0,r=0;
	read(n);rep(i,2,n)read(fa[i]),read(qz[i]),e[fa[i]].pb(i),r+=qz[i];
	rep(i,2,n)qz[i]+=qz[fa[i]];
	
	while(l<r){
		mid=(l+r)>>1;
		rep(i,0,n)a[i].clear();
		dfs(1);if(SZ(a[1]))r=mid;else l=mid+1;
	}
	cout<<l;
	return 0;
}


Measured memory_bytes: 35448
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
    int N ,X,Y ;
    cin >> N>> X>>Y;
    vector<int> vec(N);
    int min;
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    
    for(int i=1;i<N;i++){
        for(int j=i+1;j<=N;j++){
            min=std::min(j-i,abs(X-i)+1+abs(Y-j));
            vec.at(min)++;
        }
    }
    
    for (int i=1; i < N; i++) {
        cout << vec.at(i) << endl;
    }
    
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    
    vector<long long int> X(N), sortedX(N);
    for(int n=0; n<N; n++) {
        cin >> X[n];
    }
    
    sortedX = X;
    sort(sortedX.begin(), sortedX.end());
    for(int n=0; n<N; n++) {
        if(X[n]<=sortedX[N/2-1]) {
            cout << sortedX[N/2] << endl;
        } else {
            cout << sortedX[N/2-1] << endl;
        }
    }


    return 0;
    
}

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

using namespace std;

using lint = long long;
using ldouble = long double;

const lint MOD = 1000000007;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> D(N);
    for (auto& d : D) cin >> d;

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

    lint ans = 1;
    for (int i = 0; i < N; ++i) {
        ans *= i - (lower_bound(D.begin(), D.end(), D[i] - T) - D.begin() - 1);
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define Maxn 200010

int n, a[Maxn], x, y, Ans[Maxn];
multiset<int >Rep; 
vector<int >Edge[Maxn];

inline void dfs(int u, int pre)
{
	Rep.insert(a[u]);
	auto cur = Rep.lower_bound(a[u]);
	int Keep = -1;
	if (++cur != Rep.end()) Keep = *cur, Rep.erase(cur);
	Ans[u] = Rep.size();
	
	for (auto v: Edge[u]) if (v != pre) dfs(v, u);
  
	if (Keep != -1) Rep.insert(Keep);
	Rep.erase(Rep.find(a[u]));
}

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++) scanf("%d", &a[i]);
	for (int i=1; i<n; i++)
	{
		scanf("%d%d", &x, &y);
		Edge[x].push_back(y);
		Edge[y].push_back(x);
	}
	
	dfs(1, 0);
	for (int i=1; i<=n; i++) printf("%d\n", Ans[i]);
}

Measured memory_bytes: 33448