akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

// use std::io::{stdout, Write, BufWriter}
// use std::cmp::min;

fn main() {
    input!{
        n: usize,
        d: [i32; n],
    }
    d.sort();
    println!("{}", d[n / 2] - d[n / 2 - 1]);
}


Measured memory_bytes: 6396
from functools import reduce


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm_base(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


N = int(input())
a = list(map(int, input().split()))

lcm_num = lcm_list(a) - 1
ans = 0
for i in range(N):
    ans += lcm_num % a[i]
print(ans)

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

typedef long long ll;
const int N = 2000006;
const ll MOD = 1e9+7;

int n;

int dp[N][2];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	ll ans = 0;
	vector<int> v;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(x == 0){
			v.push_back(0);
			continue;
		}
		ans += (x-1)/2;
		x -= 2*((x-1)/2);
		v.push_back(x);
	}
	int lst = 0;
	for(int x:v){
		if(lst == 0 && x == 1){
			lst = 1;
			continue;
		}
		if(lst == 0 && x == 2){
			ans++;
			continue;
		}
		if(lst == 1 && x == 1){
			ans++;
			lst = 0;
			continue;
		}
		if(lst == 1 && x == 2){
			ans++;
			continue;
		}
		if(lst == 1 && x == 0){
			lst = 0;
			continue;
		}
	}
	
	cout<<ans;
	
	
	return 0;
}


Measured memory_bytes: 3880
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;

int main(void){
	string s,t;
	cin>>s>>t;
	int trans[26];
	int nums[26],numt[26];
	rep(i,26){
		trans[i]=-1;
		nums[i]=0;
		numt[i]=0;
	}
	
	bool ans=true;
	rep(i,s.length()){
		int ids=s[i]-'0'-49,idt=t[i]-'0'-49;
		if(trans[ids] == -1)trans[ids]=idt;
		else if(trans[ids] != idt){
			ans=false;
			break;
		}
		nums[ids]++;
		numt[idt]++;
	}

	sort(nums,nums+26);
	sort(numt,numt+26);
	rep(i,26){
		if(nums[i] != numt[i])ans=false;
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;

}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define fi first 
#define se second
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1e9+7 ;
//998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}   ;
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}

 
 map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;  
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
   if(n!=1) ord[n]++;
   return ord ;
 }

int main(){
  ll n,m ; cin>>n>>m ;
  vector<mint> P(m+1); 
  P[0]=1 ;
  rep(i,m){
    P[i+1]= P[i]*(i+1) ;
  }
  mint base = mint(P[m]/P[m-n]) ;
  //cout<<base<<endl ;
  combination c(m+5) ;
  rep2(i,1,n){
    base += mint(mint(pow(-1,i)) * c(n,i) * P[m-i] / P[m-n]) ;
  }
  base = mint(base * P[m] /P[m-n]) ;
  cout<<base<<endl ;
    return 0;
  }
   

Measured memory_bytes: 15288
#include <iostream>
#include <string>
#include <algorithm>
#include <deque>

using namespace std;
typedef long long llong;

void solve_test()
{
	string buffer;
	cin >> buffer;
	deque<char> s;
	for (char symbol : buffer)
		s.push_back(symbol);
	int nQ, begin = 1, end = 2;
	cin >> nQ;
	while (nQ--)
	{
		int cmd;
		cin >> cmd;
		if (cmd == 1)
			swap(begin, end);
		else
		{
			int to;
			char value;
			cin >> to >> value;
			if (to == 1 && to == begin) s.push_front(value);
			else if (to == 1) s.push_back(value);
			else
			{
				if (to == end) s.push_back(value);
				else s.push_front(value);
			}
		}
	}
	if (begin != 1)
		reverse(s.begin(), s.end());
	for (char symbol : s)
		cout << symbol;
	cout << "\n";
}

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

	int tests = 1;
	//cin >> tests;
	while (tests--)
		solve_test();

	return 0;
}


Measured memory_bytes: 4032
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	int a = 0, b = 0;
	int c[100];
	cin >> a >> b;
	for (int i = 0; i < a; i++)
	{
		cin >> c[i];
	}
	for (int i = 1; i <= b; i++)
	{
		for (int j = 0; j < (a - 1); j++)
		{
			if ((c[j] % i)>(c[j + 1] % i))
			{
				int k = c[j];
				c[j] = c[j + 1];
				c[j + 1] = k;
			}
		}
	}
	for (int i = 0; i < a; i++)
	{
		cout << c[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
    using namespace std;
    const ll nax=100005;
    vector<int> a[nax];
    //ll dp[nax][2]={0};
    //bool v[nax]={false};
    ll mul(ll a,ll b)
    {
        return (ll)a*b%mod;
    }
    pair<ll,ll> dfs(int s,int p)
    {
        ll all_w=1;
        ll smth_blk=0;
       for(int i:a[s])
       {
            if(i!=p)
            {
                pair<ll,ll> p=dfs(i,s);
                ll m_all_w=all_w;
                all_w=mul(all_w,p.s);
                smth_blk=(mul(m_all_w,p.f)+mul(smth_blk,p.f+p.s))%mod;
            }
       }
       return make_pair(all_w,(all_w+smth_blk)%mod);
    }
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T=1;
        //cin>>T;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n;
            cin>>n;
            int u,v;
            for(int i=1;i<n;i++)
            {
                cin>>u>>v;
                a[u].push_back(v);
                a[v].push_back(u);
            }
            dfs(1,-1);
            pair<ll,ll> p=dfs(1,-1);
            cout<<(p.f+p.s)%mod;
        }
        return 0;
    }


Measured memory_bytes: 12672
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] cmds = Console.ReadLine().Split(' ');
            int cat = Convert.ToInt32(cmds[0]);
            int unk = Convert.ToInt32(cmds[1]);
            int allcat = Convert.ToInt32(cmds[2]);

            int needcat = allcat - cat;
            if (needcat == 0)
            {
                System.Console.WriteLine("YES");
                return;
            }
            if (needcat < 0)
            {
                System.Console.WriteLine("NO");
                return;
            }

            if (needcat <= unk)
            {
                System.Console.WriteLine("YES");
                return;
            }
            System.Console.WriteLine("NO");

        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(){

  int a[100],n;

  cin >>n;



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

  for(int j=1;(n-j)>= 0;j++){
    cout <<a[n-j];

    if((n-j) != 0){
      cout <<" ";
    }
  }
  cout <<"\n";

  return 0;
}

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

s = input()

numlist = [0] * 1000

ans = 0

for i in range(1000):
    nums = []
    top = i // 100
    mid = (i - top * 100) // 10
    bot = i - top * 100 - mid * 10
    nums.append(str(top))
    nums.append(str(mid))
    nums.append(str(bot))
    
    ind = -1
    for j in nums:
        ind = s.find(j, ind+1)
        if ind == -1:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
N=int(input())
li = []

for n in range(2):
  li.append(list(map(int,input().split())))

max = 0

for x in range(N):
  now = 0
  
  for y in range(x + 1):
    now += li[0][y]

  for y in range(N):
    if y < x:
      continue
    now += li[1][y]

  if max < now:
    max = now

print(max)

Measured memory_bytes: 3064
n, x = map(int, input().split())
a = [int(x) for x in input().split()]
ans = 0
for i in range(n-1):
  if a[i]+a[i+1] > x:
    k = min([a[i+1], a[i]+a[i+1]-x])
    a[i+1] -= k
    ans += k
    if a[i] > x:
      ans += a[i]-x
      a[i] = x

print(ans)

Measured memory_bytes: 14060
N,M = map(int, input().strip().split())
k = []
for i in range(N):
    a,b = map(int, input().strip().split())
    k.append((a,b))
k.sort(key = lambda x:x[0])
price = 0
for i in range(N):
    M -= k[i][1]
    price += k[i][0]*k[i][1]
    if M <1:
        break
print(price + M*k[i][0])

Measured memory_bytes: 18164
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	dm := make(map[int]int)
	for i := 0; i < n; i++ {
		d := nextInt()
		dm[d]++
	}

	m := nextInt()
	for i := 0; i < m; i++ {
		t := nextInt()
		if dm[t] <= 0 {
			fmt.Println("NO")
			return
		}
		dm[t]--
	}
	fmt.Println("YES")
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 12672
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include <iomanip>
using namespace std;

int main(){
    int h,w,n,c=1,d=1;
    cin>>h>>w>>n;
    vector<int>a(10000000);
    vector<vector<int>> b(1000,vector<int>(1000));
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++ ){
            if(i%2==0){
                b[i][j]=c;
            }
            else{
                b[i][w-j-1]=c;
            }
            d++;
            if(d>a[c-1]){
                c++;
                d=1;
            }
            else{
            	
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++ ){
           cout<<b[i][j]<<flush;
           if(j!=w-1){
               cout<<" "<<flush;
           }
        }
        cout<<endl;
    }


    return 0;
}

Measured memory_bytes: 43264
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
using namespace std;

int main(){
	int n, m; cin>>n>>m;
	set<int> a,b,Or;
	int p;
	for(int i=0;i<n;i++){ cin>>p; a.insert(p); Or.insert(p);}
	for(int i=0;i<m;i++){ cin>>p; b.insert(p); Or.insert(p);}
	vector<int> And;
	for(auto i=a.begin(); i!=a.end(); i++){
		if(b.count(*i)) And.push_back(*i);
	}
	cout<<And.size()<<" "<<Or.size()<<endl;
	for(int i=0; i<And.size(); i++) cout<<And[i]<<endl;
	for(auto i=Or.begin(); i!=Or.end(); i++)cout<<*i<<endl;


	return 0;
}


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

int main(void){
	int n;
	while(cin >> n){
		int count=0;
		for(int a=0; a<10; a++)
			for(int b=0; b<10; b++)
				for(int c=0; c<10; c++)
					for(int d=0; d<10; d++)
						if(a+b+c+d==n) count++;
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 0
//In the name of God:)
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long int
#define fast  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int MAXN = 1e5 + 10;
# define PI 3.14159265358979323846
int main(){
    double n;
    cin>>n;
    double ans = n * 2 * PI;
    cout<<fixed<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 3776
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
#define PI 3.14159265359
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
ll MOD = 1000000007;

int main(){
    int x,y;
    cin >> x >> y;
    int ans = 0;
    if(x == 1 && y == 1){
        ans += 400000;
    }
    if(x == 1){
        ans += 300000;
    }
    if(x == 2){
        ans += 200000;
    }
    if(x == 3){
        ans += 100000;
    }
    if(y == 1){
        ans += 300000;
    }
    if(y == 2){
        ans += 200000;
    }
    if(y == 3){
        ans += 100000;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
typedef long long llong;

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

int main(void) {
	int n; cin >> n;
	vector<int> a(3*n);
	for (int i = 0; i < 3*n; i++) cin >> a[i];

	sort(a.begin(), a.end(), greater<int>());
	llong res = 0;
	for (int i = 1; i < 2*n; i += 2) {
		res += a[i];
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  int n;
  cin >> n;
  long a[n];
  long max,min,maxitr,minitr;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(i==0){
      max = a[0];
      min = a[0];
      maxitr = 0;
      minitr = 0;
    }else{
      if(a[i]>max){max = a[i]; maxitr = i;}
      if(a[i]<min){min = a[i]; minitr = i;}
    }
  }
  if(max>0&&min<0){
    cout << 2*n-1 << endl;
    if(abs(max)>=abs(min)){
      for(int i = 0; i < n; i++){
        cout << maxitr+1 << " " << i+1 << endl;
      }
      goto plus;
    }else{
      for(int i = 0; i < n; i++){
        cout << minitr+1  << " " << i+1 << endl;
      }
      goto minus;
    }
  }else{
    cout << n-1 << endl;
    if(max>=0&&min>=0){
      plus:
      for(int i = 1; i < n; i++){
        cout << i << " " << i+1 << endl;
      }
    }else{
      minus:
      for(int i = n-1; i > 0; i--){
        cout << i+1 << " " << i << endl;
      }
    }
  }
}


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

n_list=[0]*N
p_list=[0]*N

ac_cnt=0
wa_cnt=0


for i in range(M):
    p,S=input().split()
    p=int(p)
    if S=="WA":
        p_list[p-1]+=1
    else:
        if n_list[p-1]==0:
            n_list[p-1]=1
            ac_cnt+=1
            wa_cnt+=p_list[p-1]

print(ac_cnt,wa_cnt)


Measured memory_bytes: 4596
n,m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

def distance(x,y,i,j):
    return abs(x-i) + abs(y-j)

for a,b in ab:
    # 各チェックポイントとの距離
    dists = [distance(a, b, c, d) for c,d in cd]
    print(dists.index(min(dists)) + 1)

Measured memory_bytes: 9072
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    
    if(S.length === 2) {
        console.log(S.join(""));
    } else {
        console.log(S.reverse().join(""));
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i, n) cin >> a[i] >> b[i];
    ll ans = 0;
    for ( int i = n - 1; i >= 0; --i ) {
//        cout << i << " " << ans << endl;
        ll x = ( a[i] + ans + b[i] - 1 ) / b[i];
        ans += b[i] * x - a[i] - ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
inline int read()
{
	char c=getchar(); int num=0,f=1;
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c<='9'&&c>='0') { num=num*10+c-'0'; c=getchar(); }
	return num*f;
}
long long A,B,C,X,Y,ans;
int main()
{
	A=read(); B=read(); C=read(); X=read(); Y=read();
	if (2*C>=A+B) { cout<<A*X+B*Y; return 0; }
	ans=min(X,Y)*2*C;
	if (X>Y) 
	{
		if (2*C<A) ans+=2*C*(X-Y); else ans+=A*(X-Y);
	}
	else
	{
		if (2*C<B) ans+=2*C*(Y-X); else ans+=B*(Y-X);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++ )
#define MAX 1000000
void simulate( int x, int y ){
    int R[MAX+1];
    rep(i, MAX+1) R[i] = -1;

    int q = x;
    int r;
    int i = 1;
    
    R[x] = 0;

    while(1){
	r = q % y;
	if ( r == 0 || R[r] > 0 ) {
	    if ( R[r] == -1 ){
		printf("%d %d\n", i-1, 0);
	    } else {
		printf("%d %d\n", R[r]-1, i-R[r]);
	    }
	    break;
	}
	R[r] = i;
	q = r*10;
	i++;
    }
    
}

main(){
    int x, y;
    while(1){
	scanf("%d %d", &x, &y);
	if ( x == 0 && y == 0 ) break;
	simulate(x, y);
    }
}

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	ll N;
  double M;
  cin >> N >> M;
  ll count = 0;
  froop1(0,N){
    double a,b;
    cin >> a >> b;
    if(M >= sqrt(a*a + b*b)) count++;
  }
  cout << count << endl;

return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){
	int l,r;
	cin>>l>>r;
	if((r/2019)>(l/2019)){
		cout<<0;
		return 0;
	}
	l%=2019;
	r%=2019;
	if(l>r){
		swap(l,r);
	}
	int ans = 1000000;
	for(int i=l;i<r;i++){
		for(int j=i+1;j<=r;j++){
			ans = min(ans,(i*j)%2019);
		}
	}
	cout<<ans;
}


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

int main(){
	string s, t="CODEFESTIVAL2016";
	cin >> s;
	int ans=0;
	for(int i=0; i<(int)s.length(); i++){
		if(s[i]!=t[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

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

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }



  int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    int ans = 0; int cnt = 1;
    REP(i, N - 1){
      if(a[i] == a[i + 1]) cnt++;
      else{
        ans += cnt / 2;
        cnt = 1;
      }
    }
    ans += cnt / 2;
    print(ans);
  }

Measured memory_bytes: 256
function Main(input) {
    let lines = input.split(`\n`);
    let arg1 = lines[0].split(` `);
    let points = [];

    for (let i = 1; i < lines.length; i++) {
        let point = lines[i].split(` `);
        points.push({x: parseInt(point[0]), y: parseInt(point[1])});
    }

    let pCount = arg1[0];
    let dThreshold = arg1[1];

    let targetP = 0;
    for (let i = 0; i < points.length; i++) {
        let distance = Math.sqrt(Math.pow(points[i].x, 2) + Math.pow(points[i].y, 2));
        if (distance <= dThreshold) {
            targetP++;
        }
    }

    console.log(targetP);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 93776
t_life, t_at, a_life, a_at = map(int,input().split())

count=0
while True:
    count+=1
    if t_life<=0:
        print('No')
        break
    elif a_life<=0:
        print('Yes')
        break
    elif count%2==0:
        t_life=t_life-a_at

    else:
        a_life=a_life-t_at


Measured memory_bytes: 61804
N=int(input())
S=input()
l,r=[0]*N,[0]*N
for i in range(N-1):
    l[i+1]+=l[i]+(S[i]=='W')
for i in range(N-1,0,-1):
    r[i-1]+=r[i]+(S[i]=='E')
ans=r[i]
for i in range(1,N):
    ans=min(ans,l[i]+r[i])
print(ans)


Measured memory_bytes: 32872
#include<bits/stdc++.h>
using namespace std;
int N,Q;
string s;
vector<char> t(200009),d(200009);
int lb,ub,LB,UB;

bool C(int x){
  for(int i=0;i<Q;i++){
    if(s[x]==t[i]){
      if(d[i]=='L')x--;
      else x++;
    }
    if(x<0)return false;
    if(x>=N)return true;;
  }
  return true;
}

bool Cc(int x){
  for(int i=0;i<Q;i++){
    if(s[x]==t[i]){
      if(d[i]=='L')x--;
      else x++;
    }
    if(x>=N)return false;
    if(x<0)return true;
  }
  return true;
}

int main(){
  cin >> N >> Q >> s;
  for(int i=0;i<Q;i++)cin >> t[i] >> d[i];
  lb=-1,ub=N,LB=-1,UB=N+1;
  while(ub-lb>1){
    int mid=(ub+lb)/2;
    if(C(mid))ub=mid;
    else lb=mid;
  }
  while(UB-LB>1){
    int mid=(UB+LB)/2;
    if(Cc(mid))LB=mid;
    else UB=mid;
  }
  //cout << LB << endl;
  //cout << ub << endl;
  cout << LB-ub+1 << endl;
}

Measured memory_bytes: 1028
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int N;
	cin >> N;
	int sum = 0;
	for (int i = 1; i <= N; i = i +2) {
		int yaksu = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) {
				yaksu++;
			}
		}
		if (yaksu == 8) {
			sum++;
		}
	}
	cout << sum;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
same = []
i = 0
while i <= N-2:
    if A[i] == A[i+1]:
        same.append(A[i])
        i += 2
    else:
        i += 1
if len(same) < 2:
    print("0")
else:
    print(str(same[0]*same[1]))

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

public class Main {
    static double BTCRate = 380000;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double total = 0;
        for(int n=0; n<N; n++){
            double x = sc.nextDouble();
            String u = sc.next();
            if(u.equals("JPY")) total += x;
            else if(u.equals("BTC")) total += x*BTCRate;
        }
        System.out.println(total);


    }
}

Measured memory_bytes: 24148
from itertools import permutations

M,K=map(int,input().split())
MX=2**(M)
if (M == 1 and K != 0) or K > MX-1:
    print(-1)
    exit()

# res = set()
# for li in permutations([0,0,1,1,2,2,3,3]):
#     st = set()
#     for i in range(4):
#         idx = li.index(i)
#         xor_rep = li[idx]
#         for j in range(idx+1, 8):
#             xor_rep ^= li[j]
#             if li[j] == i:
#                 st.add(xor_rep)
#                 break

#     # print(li)
#     if not 0 in st and len(st) == 1:
#         sol = st.pop()
#         if sol == li[0] and li[1] == 0 and li[7] == 0 and li[2] < li[3]:
#             res.add(li)

# print(res)

if K == 0:
    for i in range(MX):
        print(i,i,end=' ')
    print('')
else:
    print(K,end=' ')
    for i in range(MX):
        if i != K:
            print(i, end=' ')
    print(K, end=' ')
    for i in reversed(range(MX)):
        if i != K:
            print(i, end=' ')
    print('')


Measured memory_bytes: 5036
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

// http://drken1215.hatenablog.com/entry/2019/03/24/091900
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) { cin >> a[i]; }
    int cnt = 1;
    int ans = 0;
    REP(i, N - 1) {
        if(a[i] == a[i + 1]) {
            cnt++;
        } else {
            ans += cnt / 2;
            cnt = 1;
        }
    }
    cout << ans + cnt/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main(){
  int N,sum=0,a;
  cin >> N;
  a=N;
  while(N!=0){
    sum+=N%10;
    N=N/10;
  }
  if(a%sum==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
function Main(input) {
	let input = input.split("\n");
    let tmp = input[0].split(" ");
	let H = parseInt(tmp[0], 10);
	let W = parseInt(tmp[1], 10);
    tmp = input[1].split(" ");
	let h = parseInt(tmp[0], 10);
	let w = parseInt(tmp[1], 10);
    console.log((H-h) * (W-w));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

int		main(void)
{
	int n, x;
	cin >> n >> x;
	Vec l(n);
	for (int i = 0; i < n; i++)
		cin >> l[i];
	int d = 0;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (d > x)
			break ;
		d += l[i];
		ans++;
	}
	if (d <= x)
		ans++;
	cout << ans << endl;
}


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

using ll = long long;
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n; cin >> n;
  	ll a[n];
  	fr(i,0,n) cin>>a[i];
  	if (a[0] != 2) {
    	cout << -1 << endl;
    } else {
      	ll lo = 2, hi = 3;
    	f(i,1,n) {
        	ll nxtlo = ll(ceil(1.00*lo/a[i]))*a[i], nxthi = hi/a[i]*a[i]+a[i]-1;
			if (nxtlo/a[i]*a[i] > hi) {
				cout << -1 << endl;
				return 0;
			} 
			lo = nxtlo, hi = nxthi;
        }
		cout << lo << " " << hi << endl;
    }

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

lli data[200010]={0};
lli t[200010]={0};

signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n+1);
	REP(i,1,n+1)cin>>a[i];

	lli m;

	REP(i,0,200010){
		data[i]=0;
		t[i]=0;
	}

	for(lli i=n;i>0;i--){
		/*その倍数の状態とa[i]が一致しているか?*/
		/*していない場合ボールを投げざるを得ない*/
		if(data[i]%2==a[i])continue;
		/*投げてみる*/
		/*投げた場合、その箇所の倍数を増やす*/
		for(lli j=1;j*j<=i;j++){
			if(i%j == 0){
				if(DEBUG)cout<<"j="<<j<<" i/j="<<i/j<<endl;
				data[j]++;
				if(j!=i/j)data[i/j]++;
			}
		}
		/*最後にその操作をメモっておく*/
		t[i] = 1;
	}

	if(DEBUG){
		cout<<"data"<<endl;
		REP(i,1,n+1)cout<<data[i]<<" ";
		cout<<endl;
	}

	lli cnt=0;
	vector<lli> f;

	for(lli i=1;i<=n;i++){
		if(t[i]!=0){
			f.push_back(i);
		}
	}
	cout<<f.size()<<endl;

	lli flag=0;
	for(lli i=0;i<f.size();i++){
		cout<<f[i]<<" ";
		flag=1;
	}
	if(flag!=0)cout<<endl;


	return 0;
}

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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	ll n, k;
	cin >> n >> k;
	ll x = 1, ans = 0;
	for (; x <= n; x *= k, ++ans) ;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll a,b;
	cin>>a>>b;
	cout << max({a+b,a-b,a*b});
	// your code goes here
	return 0;
}

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

int n, q, b, c, a[100005];
long long r;

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

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

	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> b >> c;
		r += (c - b) * a[b];
		a[c] += a[b];
		a[b] = 0;
		cout << r << "\n";
	}
  
  	return 0;
}

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

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

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

struct edge{P to; int cost;};

int main() {
	int n, m;
	cin >> n >> m;
	map<P, vector<edge> > es;
	vector<set<int> > st(n);
	while (m--){
		int p, q, c;
		scanf("%d %d %d", &p, &q, &c);
		p--;
		q--;
		edge e;
		e.cost = 0;
		e.to.first = q;
		e.to.second = c;
		es[P(p,c)].push_back(e);
		e.to.first = p;
		es[P(q,c)].push_back(e);
		st[p].insert(c);
		st[q].insert(c);
	}

	REP(i,n){
		for (int x : st[i]){
			edge e;
			e.cost = 1;
			e.to.first = i;
			e.to.second = x;
			es[P(i,0)].push_back(e);
			e.cost = 0;
			e.to.first = i;
			e.to.second = 0;
			es[P(i,x)].push_back(e);
		}
	}

	map<P, int> d;
	d[P(0,0)] = 0;
    priority_queue<pair<int, P>, vector<pair<int, P> >, greater<pair<int, P> > > q;
    q.push(make_pair(0, P(0, 0)));
    while (!q.empty()){
        pair<int, P> a = q.top();
        q.pop();
        P now = a.second;
        if(d[now] < a.first) continue;
        REP(i,es[now].size()){
            edge e = es[now][i];
            P next = e.to;
            if (d.count(next) == 0 || d[next] > d[now] + e.cost){
                d[next] = d[now] + e.cost;
                q.push(make_pair(d[next], next));
            }
        }
    }

    cout << (d.count(P(n-1,0)) == 0 ? -1 : d[P(n-1,0)]) << endl;

    return 0;
}

Measured memory_bytes: 115124
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;


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

    vector<bool> b(N, false);

    for(int k = 0; k < K; k++) {
        int d;
        cin >> d;
        for(int i = 0; i < d; i++) {
            int a;
            cin >> a;
            b[a - 1] = true;
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(!b[i]) ans++;
    }

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

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define mod 1000000007
#define MAXN 200000 + 5
#define ll long long
#define int long long
using namespace std;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(arr) arr.begin() , arr.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i , a , n) for(int i = a ; i < n ; i++)
#define s(arr) sort(all(arr))
#define r(arr) reverse(all(arr))
#define rs(arr) s(arr) ; r(arr)
#define con continue
#define endl "\n"
 
//debug
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 
signed main(){
    int n , k;
    cin >> n >> k;
    vector<int> arr(n);
    rep(i , 0 , n)
        cin >> arr[i];
    rs(arr);
    int ans = 0;
    for (int i = k ; i < n ; i++)
        ans += arr[i];
    cout << ans << endl;
    return 0;
}

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

struct QuickFind{
	vector<int> par;
	vector<vector<int>> group;
	QuickFind(int n) : par(n),group(n){
		for(int i = 0;i < n;i++){
			par[i] = i;
			group[i].push_back(i);
		}
	}
	int find(int x){
		return par[x];
	}
	void unite(int x,int y){
		x = par[x],y = par[y];
		if(x == y) return;
		if(group[x].size() < group[y].size()) swap(x,y);
		for(int v : group[y]) par[v] = x;
		group[x].insert(group[x].end(),group[y].begin(),group[y].end());
		group[y].clear();
		par[y] = x;
	}
	bool same(int x,int y){
		return par[x] == par[y];
	}
};

signed main(){
	int n,q;
	cin >> n >> q;
	QuickFind qf(n);
	for(int i = 0;i < q;i++){
		int c,x,y;
		cin >> c >> x >> y;
		if(!c) qf.unite(x,y);
		else cout << qf.same(x,y) << endl;
	}
}


Measured memory_bytes: 3720
local mfl = math.floor
local n = io.read("*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end

local function solve(x)
  if x == 1 then
    for i = 1, n - 1 do
      if a[i + 1] <= a[i] then return false end
    end
    return true
  end
  local tasks = {}
  local ok = true
  for i = 1, n do
    if 0 == #tasks or tasks[#tasks][1] < a[i] then
      table.insert(tasks, {a[i], 1})
    else
      while 0 < #tasks and a[i] < tasks[#tasks][1] do
        table.remove(tasks)
      end
      if 0 == #tasks then
        table.insert(tasks, {a[i], 2})
      elseif tasks[#tasks][1] == a[i] then
        tasks[#tasks][2] = tasks[#tasks][2] + 1
      else
        table.insert(tasks, {a[i], 2})
      end
      while 0 < #tasks do
        if x < tasks[#tasks][2] then
          local pos = tasks[#tasks][1]
          if pos == 1 then
            ok = false
            break
          else
            table.remove(tasks)
            if 0 < #tasks and tasks[#tasks][1] == pos - 1 then
              tasks[#tasks][2] = tasks[#tasks][2] + 1
            else
              table.insert(tasks, {pos - 1, 2})
              break
            end
          end
        else
          break
        end
      end
      if 0 == #tasks or tasks[#tasks][1] < a[i] then
        table.insert(tasks, {a[i], 1})
      end
    end
    if not ok then break end
  end
  return ok
end

local min, max = 0, n
while 1 < max - min do
  local mid = mfl((max + min) / 2)
  if solve(mid) then
    max = mid
  else
    min = mid
  end
end
print(max)


Measured memory_bytes: 89628
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    
    vector<int> c(n), f(n), s(n);
    for(int i=0; i<n-1; i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    
    for(int i=0; i<n; i++){
        int ans=0;
        if(i!=n-1){
            ans=c[i]+s[i];
            for(int j=i+1; j<n-1; j++){
                if(ans<=s[j]) ans=s[j]+c[j];
                else{
                    int diff=ans-s[j];
                    int dep=s[j]+f[j]*(diff/f[j])+(diff%f[j]?f[j]:0);
                    ans=dep+c[j];
                }
            }
            
        }
        cout<<ans<<endl;
        
    }
    
    
    
    return 0;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int X, t;
    cin >> X >> t;
    if(X-t <= 0) cout << 0 << endl;
    else cout << X - t << endl;
}

Measured memory_bytes: 256
#include <iostream>
 
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <random>
#include <chrono>

#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
 
#define itn int
#define fro for
#define lowbit(x) (x & (-x))
#define Fast freopen("in.txt", "r", stdin)

using namespace std;
typedef long long ll;


/*------------------------------------------------------------------------------------*/
template <typename _t>
inline void read(_t &x){
    x = 0; _t fu = 1; char ch = getchar();
    while(ch < '0' || ch > '9'){if(ch == '-') fu = - 1; ch = getchar();}
    while(ch >= '0' && ch <= '9'){
        x = (x << 3) + (x << 1) + (ch & 15);
        ch = getchar();
    }
    x *= fu ;
}
/*------------------------------------------------------------------------------------*/
ll gcd(ll x, ll y){return !x? y: gcd(y % x, x);}
void exgcd(ll a, ll b, ll &x, ll &y){
    if(!b){x = 1; y = 0;return;}
    exgcd(b, a % b, y, x);
    y -= a / b * x;
}
/*------------------------------------------------------------------------------------*/
struct Mart{
    int a, b, c, d;
    Mart operator *(Mart &m){
        Mart temp;
        temp.a = a * m.a + b * m.c;
        temp.b = a * m.b + b * m.d;
        temp.c = c * m.a + d * m.c;
        temp.d = c * m.b + d * m.d;
        return temp;
    }
    Mart(){a = b = c = d = 0;}
    Mart(int x[4]){a = x[0]; b = x[1]; c = x[2]; d = x[3];}
    Mart(int u, int v, int w, int x){a = u; b = v; c = w; d = x;}
    int det(){return a * d - b * c;}
};
/*------------------------------------------------------------------------------------*/

const int maxn = 2e5 + 10;

int tong[maxn];


int main(){
//    Fast;
    int n; scanf("%d", &n);
    
    int x;
    for(int i = 2; i <= n; i++){
        scanf("%d", &x); tong[x]++;
    }
    for(int i = 1; i <= n; i++) printf("%d\n", tong[i]);
    return 0;
}


Measured memory_bytes: 4528
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/
Solved on 2019/3/
@author: shinjisu
"""


# ABC 076 C Explanation
# import math
import numpy as np


def getInt(): return int(input())


# def getIntList(): return [int(x) for x in input().split()]
def getIntList(): return np.array(input().split(), dtype=np.longlong)


# def zeros(n): return [0]*n
def zeros(n): return np.zeros(n, dtype=np.longlong)


# def getIntLines(n): return [int(input()) for i in range(n)]
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data


def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    mat = zeros((n, m))
    dmp(mat)
    for i in range(n):
        mat[i] = getIntList()
    return mat


# def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18


def dmp(x, cmt=''):
    global debug
    if debug:
        if cmt != '':
            print(cmt, ':  ', end='')
        print(x)
    return x


def prob_B():
    x1, y1, x2, y2 = getIntList()
    dmp((x1, y1, x2, y2))
    dx = x2-x1
    dy = y2-y1
    dmp((dx, dy), 'dx, dy')
    dx, dy = -dy, dx
    dmp((dx, dy), 'dx, dy')
    x3, y3 = x2+dx, y2+dy
    dmp((x3, y3), 'x3, y3')
    dx, dy = -dy, dx
    x4, y4 = x3+dx, y3+dy
    return x3, y3, x4, y4


debug = False  # True False
ans = prob_B()
#print(ans)
#for row in ans:
#    print(row)
for elm in ans:
    print(elm, end=' ')


Measured memory_bytes: 20324
function lcm(a,b) {
    var g = (n, m) => m ? g(m, n % m) : n;
    return a * b / g(a, b);
}

function Main(input) {
    var A = parseInt(input[0], 10);
    var B = parseInt(input[1], 10);

    console.log(lcm(A, B));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int solve(string& str) {
    for (int i = 0; i < str.size(); i++)
        if (i % 2 == 0 && str[i] == 'L')
            return 0;
        else if (i % 2 && str[i] == 'R')
            return 0;
    return 1;
}

int main() {
    ios::sync_with_stdio(false);
    string str;
    cin >> str;
    int ans = solve(str);
    if (ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}



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

int main() {
    long long n;
    cin >> n;
    long long ans = 0;
    if (n%2 != 0) {
        ans = 0;
    } else {
        n /= 2;
        while (n > 0) {
            ans += n/5;
            n /= 5;
        }
    }
    cout << ans << endl;
}

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

int main()
{
	int a, b, c, d;
	scanf("%d%d", &a, &b);
    if(b >= 10 && b < 100)
    	c = a * 100 + b;
    else if(b >= 100)
    	c = a * 1000 + b;
    else
    	c = a * 10 + b;
    d = sqrt(c);
    if(d * d == c)
    	printf("Yes\n");
    else
    	printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long int lld;
#define sq(x) x*x
#define fr(i,m,n) for(i=m;i<n;i++)
#define vec vector<int>
#define sint set<int>
#define qint queue<int>
#define mip map<int,int>
#define pint priority_queue<int>
#define pb push_back
#define pp pop_back()
#define ft first
#define sd second
#define full(v) v.begin(),v.end()

int main()
{
    int i,j,k,a,b,c,x,y,z,n,m,t;
    string s,u,v;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3600
#include<stdio.h>
int main(void)
{
  int count=0,tyo=0,ei=0,don=0;
  int a,b,c,tmp;
  while(1)
  {
    scanf("%d%d%d",&a,&b,&c);
    if(a>c) {tmp=a;a=c;c=tmp;}
    if(b>c) {tmp=b;b=c;c=tmp;}
    if(c>=a+b) break;
    if(c*c>(a*a+b*b)) {don++; count++;}
    else  if(c*c==(a*a+b*b)) {tyo++; count++;}
    else if(c*c<(a*a+b*b)) {ei++; count++;}
  }
  printf("%d %d %d %d\n",count,tyo,ei,don);
  return 0;
}



Measured memory_bytes: 2104
#!/usr/bin/env python
# encoding: utf-8

N, A, B = map(int, raw_input().split())

s = raw_input()

over = 0
cnt = 0
for i in xrange(N):
    if s[i] == 'c':
        print 'No'
    elif s[i] == 'a':
        if cnt < A + B:
            print 'Yes'
            cnt += 1
        else:
            print 'No'
    else:
        over += 1
        if cnt < A + B and over <= B:
            print 'Yes'
            cnt += 1
        else:
            print 'No'

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

#define M 1000000/* your task*/
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch)
{
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[])
{
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ )
  {
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key)
{ 
 return key % M; 
}

int h2(int key)
{
 return 1 + (key % (M - 1)); 
}

int find(char str[])
{

    long long i,n,k;
    k = getKey(str);
    for(i=0;;i++)
    {
      n = (h1(k)+i*h2(k))%M;
     if(strcmp(H[n],str) == 0) return 1;
     else if(strlen(H[n]) == 0) return 0;
    }
  return 0; 

}

int insert(char str[])
{
  long long k, i, n;
  k = getKey(str);
  for ( i = 0; ; i++ )
  {
    n = (h1(k)+i*h2(k))%M;
    if( strcmp(H[n],str) == 0 ) return 1;
    else if ( strlen(H[n]) == 0 )
    {
      strcpy(H[n], str);
      return 0;
    }
  }
  return 0;

}

int main()
{
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ )
    {
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' )
        {
	    insert(str);
	} 
         else 
        {
	    if (find(str))
            {
		printf("yes\n");
	    } 
             else
            {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 15408