akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll mod = 1e9 + 7;

int main() {
    ll n, k;
    cin >> n >> k;
    ll ans = 1ll;
    for (ll i = k; i <= n; i++) {
        ll lb = i * (i - 1) / 2;
        ll rb = i * n - lb;
        if (lb > rb) break;
        ans += rb - lb + 1ll;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3676
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  //char in[120];
  pair<pair<string, int>, int> p[110];
  int a; cin>>a;
  rep(i, a) {
    int t;
    string pl;
    cin>>pl>>t;
    p[i]=make_pair(make_pair(pl, -t), i);
  }
  sort(p,p+a);
  rep(i,a) cout<<p[i].second+1<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        String s=sc.next();
        String t=sc.next();
        HashSet<Character> setS=new HashSet<>();
        HashSet<Character> setT=new HashSet<>();
        int loop=s.length();
        int[] x=new int[114514];
        for (int i = 0; i < loop; i++) {
            char p=s.charAt(i);
            char q=t.charAt(i);
            setS.add(p);
            setT.add(q);
            if(x[p]==0){
                x[p]=q;
            }else if(x[p]!=q){
                out.println("No");
                exit(0);
            }
            
        }
        if(setS.size()!=setT.size()){
            out.println("No");
        }else{
            out.println("Yes");
        }
    }
    //階乗
static long fact(long a){
    long b=1;
    for (long i = 1; i <= a; i++) {
        b*=i;
    }
    return b;
}
//最大公約数
static int gcd (int a, int b) {
    int temp;
    while((temp = a%b)!=0) {
        a = b;
        b = temp;
    }
    return b;
}
//※最小公倍数はa*b/gcd(a,b)である
//二項係数
static long combi (long a, long b) {
    b=min(a-b,b);
    return permu(a,b)/fact(b);
}
//順列
static long permu(long a,long b){
    long temp=1;
    for (long i =a ; i > a-b; i--) {
        temp*=i;
    }
    return temp;
}
}

Measured memory_bytes: 29364
#!/usr/bin/env python3
import heapq
# import bisect

n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(a)
for i in range(m):
    value = heapq.heappop(a)
    value = (value+1)//2
    heapq.heappush(a, value)

# print(a)
print(-sum(a))


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

prev_t, prev_x, prev_y = 0, 0, 0
for _ in range(n):
    t, x, y = map(int, input().split())
    if (abs(x - prev_x) + abs(y - prev_y) <= t - prev_t and
        (abs(x - prev_x) + abs(y - prev_y)) % 2 == (t - prev_t) % 2):
        prev_t, prev_x, prev_y = t, x, y
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 9112
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int mm(int n, int r) {
	int x = 1;
	for(int i = n; i >= n - r + 1; i--) {
		x *= i;
		x /= 1 + (n - i);
	}
	return x;
}

int n, k;
int ans;

signed main() {
	cin >> n >> k;
	for (int i = k + 1; i <= n; i++) {
		ans += (n / i)*(i - k);
		if (n%i >= k)ans += (n%i) - k + 1;
		if (k == 0)ans--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int H, W;
	while (cin >> H >> W) {
		if (H == 0 && W == 0) {
			break;
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (j % 2 != 0) {
					if(i % 2 != 0){
						cout << "#";
					}
					else {
						cout << ".";
					}
				}
				else {
					if (i % 2 != 0) {
						cout << ".";
					}
					else {
						cout << "#";
					}
				}
			}
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 1152
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;

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



	int n,sum=0,m=0,l=0; cin >> n;
	cout << (n * 800) -(n/15)*200<< endl;;


		return 0;
	
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;



int main() {
    int n, v, p;
    ll m;
    cin >> n >> m >> v >> p;

    vector<ll> problems(n);
    rep(i, n) cin >> problems[i];

    sort(problems.rbegin(), problems.rend());

    auto ct = [&](ll x) -> int {
        return count_if(problems.begin(), problems.end(), [&](ll k) { return k >= x; });
    };

    auto check = [&](ll x) -> bool {

        ll border = problems[p - 1];

        if (x >= border) return true;
        if (x + m < border) return false;

        int vi = v;
        rep(i, n) {
            if (i < p - 1) vi--;
            else if (problems[i] <= x) vi--;
        }

        if (vi <= 0) return true;

        ll avc = vi * m;

        rep(i, n) {
            if (i < p - 1) continue;
            if (problems[i] <= x) continue;
            avc -= ((x + m) - problems[i]);
        }

        return avc <= 0;

    };

    ll floor = 0, ceil = INF;

    check(5);

    if (check(floor)) {
        cout << n << endl;
        ret();
    }

    while (floor + 1 < ceil) {
        ll mid = (floor + ceil) / 2;
        ll ok = check(mid);
        if (ok) ceil = mid;
        else floor = mid;
    }


    cout << ct(ceil) << endl;

}

Measured memory_bytes: 4036
import Data.Bool
import Data.List

main = getLine >>= putStrLn . bool "NO" "YES" . dd . Just . reverse

dd Nothing = False
dd (Just "") = True
dd (Just s@('m':_)) = dd (stripPrefix "maerd" s)
dd (Just s@('r':'e':'m':_)) = dd (stripPrefix "remaerd" s)
dd (Just s@('e':_)) = dd (stripPrefix "esare" s)
dd (Just s@('r':'e':'s':_)) = dd (stripPrefix "resare" s)
dd _ = False

Measured memory_bytes: 7548
#include<stdio.h>

int main(void)
{
	int n, x;
	int i, j, k;
	int y;

	scanf("%d", &n);
	scanf("%d", &x);

	while ((n != 0) || (x != 0))
	{
		y = 0;
		for (i = 1;i <= n - 2;i++)
		{
			for (j = i + 1;j <= n - 1;j++)
			{
				k = x -( i + j);
				if ((j < k) && (k <= n))
				{
					y++;
				}
			}
		}
		printf("%d\n", y);

		scanf("%d", &n);
		scanf("%d", &x);
	}

	return 0;
}


Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
#define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    deque<int> d;
    int q;
    cin>>q;
    rep(i,q){
        int Q,a,x;
        cin>>Q>>a;
        if(Q==0){
            cin>>x;
            if(a==1)d.push_back(x);
            else d.push_front(x);
        } else if(Q==1)fin(d[a]);
        else if(a==0)d.pop_front();
        else d.pop_back();
    }
}




Measured memory_bytes: 4588
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

long long int int_cmp(const void *a, const void *b)
{
    const long long int *ia = (const long long int *)a;
    const long long int *ib = (const long long int *)b;
    return *ia  - *ib;

}

int main (void) {
long long int n,k;

scanf("%lld %lld",&n,&k);

long long int array[n];
for (long long int i=0;i<n;i++){
    scanf("%lld",&array[i]);
}
qsort(array,n,sizeof(array[0]),int_cmp);

long long int sum=0;
long long int nb=n-k;
if (nb>0){
for (long long int i=0;i<nb;i++){
    sum+=array[i];
}
}
printf("%lld",sum);

return EXIT_SUCCESS;
}



Measured memory_bytes: 3324
// @author :: Amirul Islam 

#include <bits/stdc++.h>
using namespace std;
#define LLI long long int

const int mx = 1e5;
const double pi = acos(-1.0);

int main() {
    // freopen("in", "r", stdin);
    
    string a, b;
    cin >> a >> b;
    bool ok;
    for (int i = 0; i < a.size(); i++) {
        ok = 1;
        for (int j = 0; j < b.size(); j++) {
            if (a[(i+j) % a.size()] != b[j]) {
                ok = 0;
                break;
            }
        }
        if (ok) break;
    }
    cout << (ok ? "Yes\n" : "No\n");
}


Measured memory_bytes: 3196
import java.util.*;

////queue for round robin
public class Main{
    String processid ;
    int id = 0;
    int val = 0;
    Main(String a, int b,int c){
        processid = a;
        val = b;
        id = c;
    }

    public static void main(String[] args) {
        //
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int quantum = in.nextInt();
        int[] name = new int[n+1];
        Main[] res = new Main[n+1];
        res[0] = new Main("test",1000050,0);

        Queue<Main> q = new LinkedList<>();
        for(int i = 1; i<=n; i++){
            String te = in.next();
            name[i] =  in.nextInt();
            q.offer(new Main(te,name[i], i));
            Main temp = new Main(te,0, i);
            res[i] = temp;
        }
        //System.out.println(res.length);
        //howto deal with p1, p2, p3

        int count = 1;
        int length = n;
        int save = 0;
        while(!q.isEmpty()){
            //if(count>q.size()) count = 0;
            Main temp = q.poll();
            if(temp.val<=quantum){ //
                save += (quantum - temp.val);
                res[temp.id].val+=(count*quantum-save);

            }else if(temp.val > quantum){
                temp.val = temp.val-quantum;
                q.offer(temp);
                //res[temp.processid].val+=(quantum);
            }
            count++;
        }

        Arrays.sort(res, new Comparator<Main>() {
            @Override
            public int compare(Main o1, Main o2) {
                return o1.val-o2.val;
            }
        });
        for(int i = 0; i<n; i++){
            System.out.println(res[i].processid+" "+res[i].val);
        }

    }
}



Measured memory_bytes: 83996
#include <bits/stdc++.h>
using namespace std;
struct T{
    int v, loc;
    bool operator < (const T&x) const{
        return v < x.v;
    }
}a[(int)1e5 + 10];
int main(){
    ios::sync_with_stdio(false);
    int n; cin>>n;
    for(int i = 1; i <= n; i++) cin>>a[i].v, a[i].loc = i;
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++){
        cout<<a[i].loc<<' ';
    }
    return 0;
}

Measured memory_bytes: 1664
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

int me(int val) {
	for(int i=1;;i<<=1) {
		if(i&val)return log2(i);
	}
	return log2(val);
}
	
void solve(int test_case) {//227
	int n;
	cin>>n;
	int mi = 64;
	REP(i,1,n) {
		int val;
		cin>>val;
		mi=min(mi,me(val));
	}
	cout<<mi;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int yaku[100];
int main(){
  int n;cin>>n;
  for(int i = 2; n+1 > i; i++){
    int tmp = i;
    for(int j = 2; tmp != 1; j++){
      if(tmp % j == 0){
        yaku[j]++;
        tmp/=j;
        j--;
      }
    }
  }
  vector<int> kore;
  for(int i = 0; 100 > i; i++){
    if(yaku[i]>1)kore.push_back(yaku[i]);
    
  }
  sort(kore.begin(),kore.end());
  int k3 = 0;
  int k5 = 0;
  int k15 = 0;
  int k25 = 0;
  int k75 = 0;
  for(int i = 0; kore.size() > i; i++){
    if(kore[i] >= 74)k75++;
    if(kore[i] >= 24)k25++;
    if(kore[i] >= 14)k15++;
    if(kore[i] >=  4)k5++;
    if(kore[i] >=  2)k3++;
  }
  int ans = 0;
  
  //75
  ans += k75;//AC
  //5 15
  //for(int i = k5-1; k5-1-k15 < i; i--)ans += max(0,i);
  ans += k15*(k5-1);
  //3 25
  //for(int i = k3-1; k3-1-k25 < i; i--)ans += max(0,i);
  ans += k25*(k3-1);
  //3 5 5
  ans += k5*(k5-1)*(k3-2)/2;
  
  cerr << k3 << " " << k5 << " " << k15 << " " << k25 << " " << k75 << endl;
  cout << ans << endl;
}
    
      
  

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

int main(int argc, const char * argv[]) {
    int sum, i;
    string str;
    
    while(1){
        sum=0;
        getline(cin,str);
        
        if(str=="0"){
            break;
        }else{
            for(i=0;i<(int)str.size();i++){
                sum=sum+str[i]-'0';
            }
            cout << sum << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3196
#include<stdio.h>
#define MAXWI 100000
 
int gP,gSum,gMaxW;
int gw[MAXWI+1];
int gn,gk;
 
 
void carryPackage( int maxPackage )
{
    int i;
    int tmpk;
    int package;
      
    if( gMaxW <= maxPackage ) {
        tmpk=gk;
        package=i=0;
        while( i < gn ) {
            package+=gw[i];
            if( maxPackage <= package ) {
                if( maxPackage < package ) {
                    i--;
                }
                tmpk--;
                if( maxPackage*tmpk < gn-i ) { break; }
                if( tmpk == 0 ) { break; }
                package=0;     
            }
            i++;
        }
        if( 1<=tmpk || (0==tmpk && i == (gn-1)) ) {
            gP=maxPackage;
        } else {
        	if( gMaxW < maxPackage ) {
        		gMaxW=maxPackage;
        	}
        }
    }
    
    return;
}
 
int main( void ) 
{
    int i,j;
    int end;
    int maxPackage;
         
    scanf( "%d%d", &gn, &gk );

    end=gn/gk;
    maxPackage=gMaxW=gSum=0;
   for( i=0; i<end; i++ ) {
        scanf( "%d", &gw[i] );
        maxPackage+=gw[i];
        gSum+=gw[i];
    }   
    for( i=end; i<gn; i++ ) {
        scanf( "%d", &gw[i] );
        gSum+=gw[i];
    }
 
    if( 1 == gk ) {
        gP=gSum;    
    } else if( gk < gn ) {
		for( i=0; i<gn; i++ ) {
			if( gMaxW < gw[i] ) {
				gMaxW=gw[i];
			}
		}    
	    gP=gSum;
	  	i=0;
	  	j=end;
       if( gMaxW < gSum/gk ) { gMaxW=gSum/gk; }
        while( i < gn ) {
            while( end < gn ) {
                maxPackage+=gw[end];
                if(  maxPackage < gP ) {
                    carryPackage( maxPackage );
                } else {
                    break;
                }
                j++;
                end=i+j;
            }
            maxPackage-=gw[end];
            maxPackage-=gw[end-1];            
	        maxPackage-=gw[i];
           	end--;
            j-=2;
            i++;
            if( end <= i  ) {
                maxPackage=0;
                end=i;
                j=0;
            }
        }
    } else {
		gP=0;
		for( i=0; i<gn; i++ ) {
			if( gP < gw[i] ) {
				gP=gw[i];
			}
	    }
    }
    printf( "%d\n", gP );
 
    return 0;
}

Measured memory_bytes: 984
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define per(i,n) for (int i=n-1; i>=0; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using vi = vector<int>;
using vv = vector<vi>;
const int mod = 1000000007;
//const int mod = 998244353;

int main(){
    int n, k;
    cin >> n >> k;
    printf("%c\n", (n%k)?'1':'0');
    return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n;
void solve(vector<int>a){
    vector<int>ans(n,0);
    rep(i,n){
        if(i==0)continue;
        ans[a[i]]++;
    }
    rep(i,n){
        cout<<ans[i]<<endl;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n;
    vector<int>a(n);
    a[0]=-1;
    for(int i=1;i<n;i++){
        int ai;
        cin>>ai;
        ai--;
        a[i]=ai;
    }
    solve(a);
    return 0;
}

Measured memory_bytes: 5556
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    ll n;
    cin >> n;
    vll l(n);
    rep(i, n) cin >> l[i];
    Sort(l);

    ll r = 0;
    
    rep(i, n) {
        int k = i;
        for (int j = i+1; j < n; j++) {
            while (k < n && l[k] < l[i]+l[j]) k++;
            r += k - (j+1);
        }   
    }
    mes(r);
    
    
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int);
int pop(void);

int S[100];
int top=0;

int main(){
  int x;
  char s[100];

  while( scanf("%s", s) != EOF ){

    if ( s[0] == '+' ){
      push(pop() + pop());

    } else if ( s[0] == '-' ){
      x = pop();
      push(pop() - x);

    } else if ( s[0] == '*' ){
      push(pop() * pop());

    } else {
      x = atoi(s);
      push(x);
    } 

  }
  printf("%d\n", pop());
  return 0;
}

void push(int x){
  top++;
  S[top] = x;
  }

int pop(){
  top--;
  return S[top+1];
  }

Measured memory_bytes: 548
L, R = map(int, input().split())

if 2019 <= R - L:
	print(0)
	exit()

min_mod = 10 ** 12
for l in range(L, R):
	for r in range(l + 1, R + 1):
		min_mod = min(min_mod, (l * r) % 2019)
print(min_mod)


Measured memory_bytes: 2940
from itertools import permutations
import math
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

x_dis_list = []
y_dis_list = []
for i in range(n - 1):
    for j in range(i + 1, n):
        x_dis = (x[i] - x[j]) ** 2
        y_dis = (y[i] - y[j]) ** 2
        x_dis_list.append(x_dis)
        y_dis_list.append(y_dis)

tmp = 0
tmp_only = 0
if n == 2:
    tmp_only = math.sqrt(x_dis_list[0] + y_dis_list[0])
else:
    for i in range(len(x_dis_list)):
        tmp += math.sqrt(x_dis_list[i] + y_dis_list[i])

if n == 2:
    print(tmp_only)
else:
    print((2* tmp / n))

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

int point[105][11];
int shop[105][10];
int main() {
    int n; cin >> n;
    int ans = -1e9-1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 10; j++) {
            cin >> shop[i][j];
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < 11; j++) {
            cin >> point[i][j];
        }
    }
    for(int bit = 1; bit<(1<<10); bit++) {
        int cnt = 0;
        for(int i = 0; i < n; i++) {
            int cnt2 = 0;
            for(int j = 0; j < 10; j++) {
                if((bit>>j&1) && shop[i][j]) cnt2++;
            }
            cnt += point[i][cnt2];
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;

int a, b;

void read() {
  cin >> a >> b;
}

bool pal(int n) {
  int rev = 0, cl = n;
  while(cl) {
    int ci = cl % 10;
    cl /= 10;
    rev = rev * 10 + ci;
  }
  return n == rev;
}

void solve() {
  int ans = 0;
  for(int i = a; i <= b; ++i) {
    if (pal(i))
      ++ans;
  }
  cout << ans;
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t;           // PLEASE REMOVE IT IF NEEDED
  while(t) {
    --t;
    read();
    solve();
  }
  return 0;
}


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

AAA.sort()  # 昇順ソート

m = AAA[0]
M = AAA[N-1]
ANS = []

for i in range(1, N-1):
    if AAA[i] > 0:
        ANS.append((m, AAA[i]))
        m -= AAA[i]
        continue
    ANS.append((M, AAA[i]))
    M -= AAA[i]
ANS.append((M, m))

print(M-m)
for (x, y) in ANS:
    print(x, y)


Measured memory_bytes: 19368
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#include<map>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <algorithm>
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);

const double PI  = acos(-1.0);
using namespace std;
//typedef pair<double,double>pdd;
typedef long long  ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//char rv[4]={'D','R','L','U'};
const double EPS = 1e-9;
const int N = 100000 + 9;
int n,m,mem[N],d[N];
vector<int> adj[N];


int dp(int u)
{
    if(mem[u] != -1)return mem[u];
    int c = 0;
    for(auto v: adj[u])
    {
        c = max(c, 1 + dp(v));
    }
    return mem[u] = c;
}

 int main()
{
//freopen("calc.in","r",stdin);
//freopen("calc.out","w",stdout);
//__builtin_popcount()
input
        cin>>n>>m;
        int u,v;
        forr(i,1,m)
        {
            cin>>u>>v;
            adj[u].push_back(v);
            d[v]++;
        }
        memset(mem, -1,sizeof mem);
        int ans = 0 ;
        forr(i,1,n)
        {
            if(d[i] == 0)
            {
                ans = max(ans, dp(i));
            }
        }
        cout<<ans<<endl;






return 0;
}


Measured memory_bytes: 14460
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];

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

	int count = 0;
	for(int i = 1; i < n-1; i++){
		if ((a[i-1] < a[i] && a[i] < a[i+1]) ||
			(a[i-1] > a[i] && a[i] > a[i+1])) {
			count++;
		} ; 
	}

	cout << count;
	return 0;
}

Measured memory_bytes: 256
s = gets.chomp
n = s.length
a = 0
n.times do |i|
  if i.even?
    if s[i] != "0"
      a += 1
    end
  else
    if s[i] != "1"
      a += 1
    end
  end
end

b = 0
n.times do |i|
  if i.even?
    if s[i] != "1"
      b += 1
    end
  else
    if s[i] != "0"
      b += 1
    end
  end
end

puts [a, b].min

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

typedef long long ll;

#define PI M_PI

struct Point {
    double x;
    double y;

    void prt(){
        printf("%.8f %.8f\n",x,y);
    }
};

void koch(int n,Point p1,Point p2){
    if(n==0) return ;
    Point s,t,u;
    s.x = (2*p1.x + p2.x) / 3;
    s.y = (2*p1.y + p2.y) / 3;
    t.x = (p1.x + 2*p2.x) / 3;
    t.y = (p1.y + 2*p2.y) / 3;
    u.x = (t.x - s.x)*cos(PI/3) - (t.y - s.y)*sin(PI/3) + s.x;
    u.y = (t.x - s.x)*sin(PI/3) + (t.y - s.y)*cos(PI/3) + s.y;

    koch(n-1, p1, s);
    s.prt();
    koch(n-1, s, u);
    u.prt();
    koch(n-1, u, t);
    t.prt();
    koch(n-1, t , p2);
}

int main(){
    int n;
    cin >> n;
    Point s,g;
    s.x=s.y=g.y=0;
    g.x=100;
    s.prt();
    koch(n,s,g);
    g.prt();
}



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

N, K = map(int, input().split())
h = list(map(int, input().split()))
 
dp = [0] * N
for i, hi in enumerate(h):
  if i > 0:
    x = max(0, i - K)
    dp[i] = min([dpj + abs(hi - hj) for hj, dpj in zip(h[x:i], dp[x:i])])
print(dp[N - 1])

Measured memory_bytes: 14228
#define M 100
char m[M][M],s[M][M][M],r[M],*z;
cmp(char *p,char *q){
  int r=0;
  for(;*p=='0';p++);
  for(;*q=='0';q++);
  if(r=strlen(p)-strlen(q))return r;
  return strcmp(p,q);
}
main(w,h,i,j,k,l){
	for(;scanf("%d%d",&w,&h),w;puts(z)){
		memset(m,0xff,sizeof(m));
		memset(s,0,sizeof(s));
		memset(r,0,sizeof(r));
		for(j=1;j<=h;j++)scanf("%s",m[j]+1);
		for(i=1;i<=w+1;i++)for(j=1;j<=h;j++)if(m[j][i]<'0'||'9'<m[j][i])m[j][i]=-1;
		//for(k=1;k<M;k++){
		for(i=1;i<=w;i++)
			//for(j=i=k;i<=w;i++){
			for(j=1;j<=h;j++){
				if(m[j][i]==-1)continue;
				if(cmp(s[j][i-1],s[j-1][i])>0)strcpy(s[j][i],s[j][i-1]),s[j][i][strlen(s[j][i])]=m[j][i];
				else strcpy(s[j][i],s[j-1][i]),s[j][i][strlen(s[j][i])]=m[j][i];
				if(cmp(s[j][i],r)>0)strcpy(r,s[j][i]);
    		}
/*
			for(j=i=k;j<=h;j++){
				if(m[j][i]==-1)continue;
				if(cmp(s[j][i-1],s[j-1][i])>0)strcpy(s[j][i],s[j][i-1]),s[j][i][strlen(s[j][i])]=m[j][i];
				else strcpy(s[j][i],s[j-1][i]),s[j][i][strlen(s[j][i])]=m[j][i];
				if(cmp(s[j][i],r)>0)strcpy(r,s[j][i]);
			}
*/
		for(z=r;*z=='0';z++);
	}
return 0;}

Measured memory_bytes: 0
#49 ボツ
H,W = map(int,input().split())
a = []
for i in range(H):
    a.append(input())


for i in range(W+2):
    print("#",end = "")
print("")
for i in a:
    print("#",i,"#",sep = "")
for i in range(W+2):
    print("#",end = "")

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,-1,sizeof(a));

const ll N=3e5+5;
ll arr[N];
ll pos[N];
ll a[N];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll n,k;cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    mset(pos);
    a[0]=1;
    pos[1]=0;
    ll g=0;
    bool state=1;
    for(int i=1;i<=k;i++){
        a[i]=arr[a[i-1]];
        if(pos[a[i]]!=-1){
            g=i;state=0;break;
        }else pos[a[i]]=i;
    }
    if(state){
        cout<<a[k];return 0;
    }
    ll MOD=g-pos[a[g]];
    ll ab=(k-pos[a[g]])%MOD;
    cout<<a[pos[a[g]]+ab];
}


Measured memory_bytes: 8804
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

def prime_decomposition(n):
    table = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            table += [i]
            n //= i
        if n == 1:
            break
    if n != 1:
        table += [a]
    return table

pr = primes(10 ** 3 + 1)
n = I()
A = LI()
D = defaultdict(int)
for a in A:
    for p in pr:
        if a < p:
            break
        cnt = 0
        while a % p == 0:
            cnt += 1
            a //= p
        if cnt > D[p]:
            D[p] = cnt
    if a > 1 and D[a] == 0:
        D[a] = 1

lcm = 1
for v in D:
    lcm = lcm * pow(v, D[v], mod) % mod

ans = 0
for a in A:
    ans = (ans + pow(a, mod-2, mod) * lcm % mod) % mod



print(ans)

Measured memory_bytes: 5708
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<bool> vb;
long long int max(long long int a,long long int b){
  if(a>b)
    return a;
  else
    return b;
}
long long int min(long long int a,long long int b){
  if(a<b)
    return a;
  else
    return b;
}
long long int binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
    }
  return res;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
 
//############################ENDOFTEMPLATE############################

void solve(){
  lli a,b,x;
  cin>>a>>b>>x;

  lli lo = (x+a-1)/x;
  lli hi = (b/x);

  cout<<hi-lo+1; 
}
 
 
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  //freopen("moobuzz.in","r",stdin);
  //freopen("moobuzz.out","w",stdout);
  int t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 3656
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
	int n;
	while ((n = nextInt()) != 0) {
	    int[][] map = new int[21][21];
	    for (int i = 0; i < n; i++) {
		map[nextInt()][nextInt()] = 1;

	    }
	    int m = nextInt();
	    int x = 10;
	    int y = 10;
	    int count = 0;
	    for (int i = 0; i < m; i++) {
		char c = getChar();
		int l = nextInt();
		if (count != n) {
		    int dx = 0;
		    int dy = 0;
		    if (c == 'N') {
			dy = 1;
		    } else if (c == 'E') {
			dx = 1;
		    } else if (c == 'S') {
			dy = -1;
		    } else if (c == 'W') {
			dx = -1;
		    }
		    for (int j = 0; j < l; j++) {
			count += map[x][y];
			map[x][y] = 0;
			x += dx;
			y += dy;
		    }
		    count += map[x][y];
		    map[x][y] = 0;
		}
	    }
	    if (count == n) {
		System.out.println("Yes");
	    } else {
		System.out.println("No");
	    }
	}
    }

    private static char getChar() throws IOException {
	int c = ' ';
	while (c < 'E' || 'W' < c) {
	    c = System.in.read();
	}
	return (char) c;
    }

    private static int nextInt() throws IOException {
	int c = System.in.read();
	while ((c < '0' || '9' < c) && c != '-') {
	    c = System.in.read();
	}
	if (c == '-') {
	    return -nextInt();
	}
	int result = 0;
	while ('0' <= c && c <= '9') {
	    result = result * 10 + (c - '0');
	    c = System.in.read();
	}
	return result;
    }
}

Measured memory_bytes: 26284
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

int main(){

  int N; cin >> N;
  string S; cin >> S;

  int ans = 0, x = 0;

  for (int i = 0; i < N; i++){
    if (S[i] == 'I') x++;
    else x--;
    
    if (ans < x) ans = x; 
  }

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


Measured memory_bytes: 384
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))

res = 0
mod = 10**9 + 7
for i in range(61):
    cnt = np.count_nonzero(a >> i & 1)
    res += cnt * (n-cnt) << i
    res %= mod

print(res)


Measured memory_bytes: 49804
#import math

argN,argK = list(map(int,input().split()))

if argN < argK:
  ans = 0.0
else:
  ans = (argN - argK) / argN
#print(ans)

for i in range(1,min(argN,argK) + 1):
  check = i
  wkCount = 0
  while check < argK:
    check *= 2
    wkCount += 1
  ans += (1 / argN) * ((1 / 2) ** wkCount)
  #print(ans)

print(ans)

Measured memory_bytes: 3060
from collections import defaultdict
def inpl(): return list(map(int, input().split()))
H, W = inpl()
G = []

class UnionFindTree():
    
    def __init__(self, N):
        self.parent = [-1]*(N+1)
        self.rank = [1]*(N+1)
        self.size = [1]*(N+1)
  
    def find(self, i):
        if self.parent[i] == -1:
            group = i
        else:
            group = self.find(self.parent[i]) 
            self.parent[i] = group
        return group
      
    def unite(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.rank[px] == self.rank[py]: # rank is same
                self.rank[px] += 1
            elif self.rank[px] < self.rank[py]:
                px, py = py, px
                
            self.parent[py] = px
            self.size[px] += self.size[py]
    
    def getsize(self, x):
        return self.size[self.find(x)]


def binarize(h, w):
    return h*W + w

def reverse(g):
    h, w = divmod(g, W)
    return h, w

UFT = UnionFindTree(H*W)

for _ in range(H):
    G.append(input())

for h in range(H-1):
    for w in range(W):
        if G[h][w] != G[h+1][w]:
            UFT.unite(binarize(h, w),
                      binarize(h+1, w))

for h in range(H):
    for w in range(W-1):
        if G[h][w] != G[h][w+1]:
            UFT.unite(binarize(h, w),
                      binarize(h, w+1))

D = defaultdict(lambda: [0, 0])
for i in range(H*W):
    h, w = reverse(i)
    D[UFT.find(i)][G[h][w] == "."] += 1

ans = 0
for k, v in D.items():
    ans += v[0] * v[1]

print(ans)

Measured memory_bytes: 71408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    map<string,int>cnt;
    cin>>n;
    int ans=0;
    while(n--){ 
        cin>>s;
        cnt[s]++;
        if(cnt[s]==1)ans++;
    }
    cout<<ans<<'\n';
    

    return 0;
}


Measured memory_bytes: 19248
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

struct T{
    int height;
    vector<int> o;
};

int main(){
    int n;
    int m;
    cin >> n >> m;
    vector<int> h(n);
    T t[n];
    rep(i, n) {
        cin >> h[i];
        t[i].height = h[i];
    }
 
    int a, b;
    rep(i,m){
        cin >> a >> b;
        a--;
        b--;
        t[a].o.push_back(h[b]);
        t[b].o.push_back(h[a]);
    }
    int count = 0;
    rep(i,n){
        if (t[i].o.size()==0)
            count++;
        else {sort(t[i].o.begin(), t[i].o.end());
            if (t[i].o[t[i].o.size()-1] < t[i].height)
                count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int a, b, c;
	cin >> a >> b >> c;
    cout << min(c, b/a) << endl;

	return 0;
}


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

int main()
{
    int n,c=0;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    for(int i=0;i<n;i++)
    {
        if(b[i]!=a[i])
            c++;
    }
    if(c>2)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
    return 0;
}

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

r = [0] * N


def f(n):
    """
    nの倍数のボールの数
    """
    cnt = 0
    i = 2
    while n * i <= N:
        cnt += r[n*i-1]
        i += 1
    return cnt


for i in range(N):
    n = N - i
    x = f(n)
    if x % 2 == A[n-1]:
        pass
    else:
        r[n-1] += 1

# print(r)

ans = []
for i, ri in enumerate(r):
    if ri == 1:
        ans.append(str(i+1))

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(" ".join(ans))

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {

    int n,x;
    cin>>n>>x;
    vector<int> m(n);
    rep(i,n){ cin >> m[i]; x-=m[i];}
    
    sort(m.begin(),m.end());

    int ans = n + x/m[0];
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  cout << (n-1) * (m-1);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
char fie[13][13];
int ff[13][13];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
void check(int x,int y){
  ff[x][y]=1;
  for(int i=0;i<4;i++){
    int nx = x+dx[i];
    int ny = y+dy[i];
    if(nx < 0 || nx > 11 || ny < 0 || ny > 11) continue;
    if(ff[nx][ny]==1) continue;
    if(fie[nx][ny]=='0') continue;
    check(nx,ny);
  }
}
main(){
  string s;
  while(cin >> s){
    for(int i=0;i<s.size();i++) fie[i][0]=s[i];
    for(int i=1;i<12;i++)
      for(int j=0;j<12;j++) cin >> fie[j][i];

   
    memset(ff,0,sizeof(ff));

    int res=0;
    for(int i=0;i<12;i++){
      for(int j=0;j<12;j++){
	//	printf("%c",fie[j][i]);
	if(ff[j][i]==0 && fie[j][i]=='1'){
	  res++;
	  check(j,i);
	}
      }
      //   puts("");
    }
    
    cout << res << endl;
    
  }
}

Measured memory_bytes: 1184
function get_data_from_stdin()
	return Base.parse( Base.readline( Base.STDIN ) )
end

function abc088_a()

	# STEP.01
	# get the number of the slice of cake
	N = get_data_from_stdin()
	A = get_data_from_stdin()

	# STEP.02
	# output the result
	if Base.rem( N, 500 ) <= A
		Base.println( Base.STDOUT, "Yes" )
	else
		Base.println( Base.STDOUT, "No" )
	end

	# STEP.TRUE_END
	return Base.nothing

end

#==================================================================================================#

Main.abc088_a()


Measured memory_bytes: 166492
#include <stdio.h>
 
int main(void){
    int n,x,count;
    int i,j,k;
    for(;;){
        count = 0;
        scanf("%d %d",&n,&x);
        if(!n&&!x) break;
        for(i=1;i<=n;i++)for(j=i+1;j<=n;j++)for(k=j+1;k<=n;k++) if((i+j+k) == x) count++;
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 600
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
#define PI 3.14159265358979323846264338327950L

int main(void)
{
    long double a, b, h, m; cin >> a >> b >> h >> m;
    long double t = 60 * h + m;
    long double pi = PI;
    long double theta = m / 30.0 * pi - t / 360.0 * pi;

    long double c = sqrt(a*a + b*b - 2*a*b*cos(theta));
    cout << fixed << setprecision(20) << c << endl;
}

Measured memory_bytes: 4072