akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end() //使うときはsort(all())という感じで
using ll = long long;
#define PI 3.14159265359

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

int main(){
  ll a,b;
  cin>>a>>b;
  ll n=gcd(a,b);
  int count=0;
  bool ju=false;
  for(int i=2;i<=static_cast<int>(sqrt(n))+2;i++){
    while(n%i==0){
      n/=i;
      ju=true;
    }
    if(ju) count++;
    ju=false;
  }
  if(n>1) count++;
  cout<<count+1<<endl;
}  

Measured memory_bytes: 256
class Array
  def cumsum!(s = 0); map!{|t| s += t } end
end

n, k = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }

if k >= 41
  puts [n] * n * ' '
  exit
end

ans = []
[k, 40].min.times do |i|
  
  ans = [0] * n
  a.each_with_index do |t, i|
    
    j = [i - t, 0].max
    ans[j] += 1
    
    j = i + t + 1
    ans[j] += -1 if j < n
  end
  
  ans.cumsum!
  
  a = ans.dup
end

puts ans * ' '

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

void solve() {
	int a, N, M; cin >> N >> M;
	vector<bool> issafe(N + 1, true);
	rep(i, M) {
		scanf("%d", &a);
		issafe[a] = false;
	}

	vector<llong> dp(N + 1, 0);
	dp[0] = 1;
	for (int now = 0; now < N; now++) {
		for (int next = now + 1; next <= min(N, now + 2); next++) {
			if (issafe[next]) dp[next] += dp[now];
			dp[next] %= MOD;
		}
	}

	cout << dp[N] << endl;
}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
 
int main(void) {
  int a, b, c, y;
  cin >> a >> b >> c >> y;
  int ans = 0;
  
for(int i=0; i<=a; ++i) {
  for (int j=0; j<=b; ++j) {
    for (int k=0; k<=c; ++k) {
      if (i*500+j*100+k*50 == y) ans++;
    }
  }
}
  cout << ans << endl;
}

Measured memory_bytes: 256
from math import floor
n = int(input())
noTax = n/1.08

noTax = floor(noTax)

# print(noTax)
# print(floor(noTax) * 1.08)

if floor(noTax * 1.08) == n:
    print(floor(noTax))
elif floor((noTax + 1) * 1.08) == n:
    print(noTax + 1)
else:
    print(":(")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(int)(b);++i)
#define rep(i,n) REP(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int num = n;
    int sum = 0;
    while (num != 0) {
        sum += num % 10;
        num /= 10;
    }
    cout << (n % sum == 0 ? "Yes" : "No") << endl;
    return 0;
}




Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for i in range (A+1):
    for j in range (B+1):
        for k in range (C+1):
            if 500*i+100*j+50*k==X:
                count+=1
print(count)


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

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

    int n,k,s;
    while(cin>>n>>k>>s,n)
    {
        int ans=0;
        REP(b,1<<n){
            if(__builtin_popcount(b)!=k) continue;
            int sum=0;
            REP(i,n){ 
                if(b>>i&1) sum+=i+1;
            }
            if(sum==s) ans++;
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3176
use std::cmp::{max, min};

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut ans = f(n, 1);
    for i in 1.. {
        if i * i > n {
            break;
        }
        if n % i == 0 {
            ans = min(ans, f(n / i, i));
        }
    }
    println!("{}", ans);
}

fn f(a: usize, b: usize) -> usize {
    max(a.to_string().len(), b.to_string().len())
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;
ll T, Na, A, B, C, D;
map<ll, ll> dp;
ll dfs(ll N) {
    if (N == 0) {
        return 0;
    } else if (N == 1) {
        return D;
    }
    if (dp[N]) {
        return dp[N];
    }

    ll l2 = (N / 2) * 2;
    ll r2 = (N / 2 + 1) * 2;
    ll l3 = (N / 3) * 3;
    ll r3 = (N / 3 + 1) * 3;
    ll l5 = (N / 5) * 5;
    ll r5 = (N / 5 + 1) * 5;
    ll ret = (N < 1e18 / D) ? N * D : 1e18;
    chmin(ret, dfs(l2 / 2) + A + (N - l2) * D);
    if (r2 / 2 < N) chmin(ret, dfs(r2 / 2) + A + (r2 - N) * D);
    chmin(ret, dfs(l3 / 3) + B + (N - l3) * D);
    if (r3 / 3 < N) chmin(ret, dfs(r3 / 3) + B + (r3 - N) * D);
    chmin(ret, dfs(l5 / 5) + C + (N - l5) * D);
    if (r5 / 5 < N) chmin(ret, dfs(r5 / 5) + C + (r5 - N) * D);
    dp[N] = ret;
    return ret;
}

int main() {
    cin >> T;
    vector<ll> ans(T);
    for (int i = 0; i < T; i++) {
        cin >> Na >> A >> B >> C >> D;
        dp = map<ll, ll>();
        ans.at(i) = dfs(Na);
    }
    for (int i = 0; i < T; i++) {
        cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 4824
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	
	int ans = 0;
	if( a < 0 ){
		if( b <= 0 ){
			ans = c * abs(a-b);
		}
		else{
			ans += c * abs(a) + d;
			a = 0;
		}
	}
	
	if( a >= 0 ){
		ans += e * (b-a);
	}

	cout << ans << endl;
	ret 0;
}


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

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

    vector<int> r(n);
    for (int i = 0; i < n; i++)
        cin >> r.at(i);

    int minimum = r.at(0);
    int profit = r.at(1) - r.at(0);
    for (int i = 2; i < n; i++)
    {
        minimum = min(minimum, r.at(i - 1));
        profit = max(profit, r.at(i) - minimum);
    }
    cout << profit << endl;
}


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

int main () {
 int n;
 cin >>n;
 vector<int>p(n);
 int counter =0;
 int cnt =0;
 for (int i=0;i<n;i++){
   cin>>p[i];
 }
  counter =p[0];
  for(int i=0;i<n;i++){
    if(counter >=p[i]){
      counter =p[i];
      cnt++;
    }
  }
cout <<cnt<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
using namespace std;
struct med{
    int pos, valor;
};

int n, x[200050];
med a[200050];

bool compare(med a, med b){
    return a.valor <b.valor;
}

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &x[i]);
        a[i].pos = i;
        a[i].valor = x[i];
    }
    sort(a, a+n, compare);
    int k = n/2;

    //for(int i=0; i<n; i++)
        //printf("%d ", a[i].valor);

    for(int i=0; i<n; i++){
        if(a[k-1].valor > x[i]){
            printf("%d\n", a[k].valor);
        } else if(a[k-1].valor  == x[i]){
            printf("%d\n", a[k].valor);
        } else {
            printf("%d\n", a[k-1].valor);
        }

        /*if(a[k-1].pos==i){
            printf("%d\n", a[k].valor);
        }

         else {
            printf("%d\n", a[k-1].valor);
        }*/
    }
}


Measured memory_bytes: 4480
'use strict'
function main(inp) {
  inp = inp.trim().split('\n')
  const N = inp.shift()
  
  inp = inp.sort()  
  let ans = new Set();
  let count = 0;
  let max = 0;
  	for(let i = 0; i < inp.length; i++){
    count++;
    if((i + 1 === N) || inp[i] !== inp[i+1]){
      if(count == max){
        ans.add(inp[i]);
      } else if(count > max){
        ans.clear();
        ans.add(inp[i])
        max = count;
      }     
      count = 0;
    }
  }
  ans.forEach(
    (n) => console.log(n)
  )
}

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


Measured memory_bytes: 46452
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define vec vector<int,int> 
#define int long long 


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ios_base& scientific (ios_base& str);
	
	int t=1;
//	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int dp[n+1]={0};
		int arr[n];
		//arr[0]=0;
		rep(i,n){
			cin>>arr[i];
		}
		dp[0]=0;
		dp[1]=abs(arr[1]-arr[0]);
		for(int i=2;i<n;i++){
			dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],dp[i-2]+abs(arr[i]-arr[i-2]));
		}
		cout<<dp[n-1]<<endl;
	}
	return 0;
}


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


#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	int sum = 0;
	for (int i = a; i <= b; i++) {
		string s = to_string(i);
		string old = s;
		reverse(s.begin(), s.end());
		if(s == old) sum++;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

static char CheckFormat(int a_iS);

int main(void) {
	int		iS;
	char	cFormat;	
	//長さ4の数字列を入力
	scanf("%d", &iS);
	
	//入力された値がYYMM,MMYYフォーマットのどちらかと考えられるか求める
	cFormat = CheckFormat(iS);
	//求めた結果を出力
	switch (cFormat){
	case 1:
		printf("AMBIGUOUS\n");
		break;
	case 2:
		printf("YYMM\n");
		break;
	case 3:
		printf("MMYY\n");
		break;
	case 4:
		printf("NA\n");
		break;

	default:
		break;
	}
	return 0;
}

/*****************
*	YYMM,MMYYのどちらのフォーマットに合うか確認する関数
*	a_iS 入力された長さ4の数字列
*/

static char CheckFormat(int a_iS) {
	int iHigh2, iLow2;
	int j;

	iHigh2	= a_iS / 100;
	iLow2	= a_iS % 100;

	//どちらの可能性も存在するとき
	if ((1 <= iHigh2 && iHigh2 <= 12) && (1 <= iLow2 && iLow2 <= 12)) {
		j = 1;
	}
	//YYMMフォーマットのとき
	else if (1 <= iLow2 && iLow2 <= 12) {
		j = 2;
	}
	//MMYYフォーマットのとき
	else if (1 <= iHigh2 && iHigh2 <= 12) {
		j = 3;
	}
	//どちらでもないとき
	else {
		j = 4;
	}
	return(j);
}


Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline void chmax(S &a, T b){
  if(a<b){
    a=b;
  }
}
int H[100], N, V[100], W, gain[4][100], sum[4][101], sz[4];
int main(){
  int a, b, c, d, res=0;
  long long minH, r;
  rd(N);
  rd(W);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(H[Lj4PdHRW]);
      rd(V[Lj4PdHRW]);
    }
  }
  minH = H[0];
  {
    int KL2GvlyY;
    for(KL2GvlyY= 0;KL2GvlyY< (N-1) + 1;KL2GvlyY++){
      H[KL2GvlyY] -= minH;
    }
  }
  {
    int Q5VJL1cS;
    for(Q5VJL1cS= 0;Q5VJL1cS< (N-1) + 1;Q5VJL1cS++){
      gain[H[Q5VJL1cS]][sz[H[Q5VJL1cS]]++] = V[Q5VJL1cS];
    }
  }
  {
    int e98WHCEY;
    for(e98WHCEY= 0;e98WHCEY< (3) + 1;e98WHCEY++){
      sort(gain[e98WHCEY], gain[e98WHCEY]+sz[e98WHCEY], greater<int>());
    }
  }
  {
    int cTE1_r3A;
    for(cTE1_r3A= 0;cTE1_r3A< (3) + 1;cTE1_r3A++){
      {
        int RZTsC2BF;
        for(RZTsC2BF= 1;RZTsC2BF< (sz[cTE1_r3A]) + 1;RZTsC2BF++){
          sum[cTE1_r3A][RZTsC2BF] += sum[cTE1_r3A][RZTsC2BF - (1) + (0)] + gain[cTE1_r3A][RZTsC2BF - (1) + (0)];
        }
      }
    }
  }
  for(a=0;a<sz[0]+1;a++){
    for(b=0;b<sz[1]+1;b++){
      for(c=0;c<sz[2]+1;c++){
        r = W - minH*a - (minH+1)*b - (minH+2)*c;
        if(r < 0){
          break;
        }
        d = min(r / (minH+3), (long long)sz[3]);
        chmax(res, sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d]);
      }
    }
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170429-1

// --- original code ---
// int N, W, H[100], V[100];
// int gain[4][100], sum[4][101], sz[4];
// {
//   int res = 0;
//   int a, b, c, d;
//   ll r, minH;
//   rd(N, W, (H,V)(N));
//   minH = H[0];
//   H[0..N-1] -= minH;
//   gain[H[0..N-1]][sz[H[0..]]++] = V[0..];
//   sort(gain[0..3], gain[0..]+sz[0..], greater<int>());
// 
//   sum[0...3][1..sz[0...]] += sum[0...][0..] + gain[0...][0..];
// 
//   rep(a,sz[0]+1) rep(b,sz[1]+1) rep(c,sz[2]+1){
//     r = W - minH*a - (minH+1)*b - (minH+2)*c;
//     if(r < 0) break;
//     d = min(r / (minH+3), (ll)sz[3]);
//     res >?= sum[0][a] + sum[1][b] + sum[2][c] + sum[3][d];
//   }
//   wt(res);
// }


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ITP1_5_B
{
	class Program
	{
		static void Main(string[] args)
		{
			List<Tuple<int, int>> ts = new List<Tuple<int, int>>();

			while(true) {
				string[] vs = Console.ReadLine().Split(' ');

				int h = int.Parse(vs[0]);
				int w = int.Parse(vs[1]);

				if(h == 0 && w == 0) {
					break;
				}

				ts.Add(Tuple.Create(h, w));
			}

			foreach(Tuple<int, int> t in ts) {
				for(int i = 0; i < t.Item1; i++) {
					for(int j = 0; j < t.Item2; j++) {
						if(i == 0 || i == t.Item1 - 1) {
							Console.Write("#");
						}
						else if(j == 0 || j == t.Item2 - 1) {
							Console.Write("#");
						}
						else {
							Console.Write(".");
						}
					}
					Console.WriteLine();
				}

				Console.WriteLine();
			}
		}
	}
}



Measured memory_bytes: 15932
#include<stdio.h>
int main(void){
	int a,b,c,i;
	i=0;
	scanf("%d %d %d",&a,&b,&c);
	while(a<=b){
		if(c%a==0){
			i++;
		}
		a++;
	}
	printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N, X;
	cin>>N>>X;
	vector<int> L(N);
	for(int i=0; i<N; i++) cin>>L[i];
	
	int sum=0, count=1;
	for(int i=0; i<N; i++) {
		sum+=L[i];
		if(sum<=X) count++;
		else break;
	}

	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
from bisect import bisect_left, bisect_right, insort_left
from collections import defaultdict

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 各アルファベットのindexのリストを作り,bisect_left()
N = ir()
S = list(sr())
dic = defaultdict(list)
for i, s in enumerate(S):
    dic[s].append(i)

Q = ir()
for _ in range(Q):
    a, b, c = sr().split()
    if a == '1':
        b = int(b) - 1
        if S[b] == c:
            continue
        dic[S[b]].remove(b)
        insort_left(dic[c], b)
        S[b] = c
    else:
        b = int(b) - 1; c = int(c) - 1
        kind = 0
        for x in range(26):
            word = chr(ord('a')+x)
            if len(dic[word]) == 0:
                continue
            i = bisect_left(dic[word], b)
            j = bisect_right(dic[word], c)
            if i != j:
                kind += 1
        print(kind)

# 07

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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());
#define vnn(x,y,name) vector<vector<int>> name(x, vector<int>(y));

string yes="Yes",no="No";

int main() {
    int n,m,q;
    cin>>n>>m>>q;
    vin a(q),b(q),c(q),d(q);
    rep(i,q) cin>>a[i]>>b[i]>>c[i]>>d[i];
    int ans=0;
    rep(i,524288){
        bitset<19> s(i);
        int j=0;
        int look=0;
        int sumd=0;
        
        vin ax(n,1);
        bool ok=true;
        while(ok){
            if(s[look]==0){
                ax[j]++;
                if(ax[j]>m){
                    ok=false;
                    break;
                }
            }
            else if(j<n-1){
                ax[j+1]=ax[j];
                j++;
            }
            else break;
            
            look++;
        }
        if(!ok) continue;
        rep(j,q){
            if(ax[b[j]-1]-ax[a[j]-1]==c[j]) sumd+=d[j];
        }
        ans=max(sumd,ans);
    }
    cout<<ans<<endl;
    

}


Measured memory_bytes: 3616
"use strict";
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});
/* 入力は 
fAIR, LATER, OCCASIONALLY CLOUDY.
 */

var re = /\s+|$/;
reader.on('close', () => {
    var l = lines[0];
    
    console.log(aux(l));
});

function aux(l)
{
    var s="";
    for (var i=0; i<l.length; i++) {
	var c=l[i]
	s += swapCase(c)
    }
    return s;
}

var rs=/[a-z]/;
var rc=/[A-Z]/;
function swapCase(c)
{
    if (rs.test(c)) {
	return c.toUpperCase();
    } else if (rc.test(c)) {
	return c.toLowerCase();
    } else {
	return c;
    }
}


Measured memory_bytes: 16616
use std::io;

fn main() {
    let _n = read::<i32>();
    let mut a = read_vec::<i32>();

    insertion_sort(&mut a);
    print_vec(a.to_vec());
}

pub fn insertion_sort<T: Ord + Copy + std::fmt::Display>(x: &mut [T]) {
    for i in 1..x.len() {
        print_vec(x.to_vec());
        let v = x[i];
        let mut j = i as i32 - 1;
        while x[j as usize] > v {
            x.swap((j + 1) as usize, j as usize);
            j -= 1;
            if j < 0 { break; }
        }
        x[(j + 1) as usize] = v;
    }
}

fn print_vec<T: std::fmt::Display>(v: Vec<T>) {
    for a in &v[0..v.len() - 1] {
        print!("{} ", a);
    }
    println!("{}", v[v.len() - 1]);
}

/// 標準入力から一行を読み取り、指定の型に変換する関数
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

/// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut line = String::new();
    io::stdin().read_line(&mut line)
        .ok()
        .expect("Faild to read Vec");
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 5032
// https://atcoder.jp/contests/agc034/tasks/agc034_a
#include <bits/stdc++.h>
using namespace std;

int main(void){
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  string S;
  cin >> S;
  int road[N];
  for (int i = 0; i < N; i++){
    if (S[i]=='.')  road[i] = 0;
    else  road[i] = 1;
  }

  string ans;
  if (C<D){
    ans = "Yes";
    for (int i = A-1; i < D; i++){
      if (road[i]==1 && road[i+1]==1)
        ans = "No";
    }
  }else{
    ans = "No";
    for (int i = B-1; i < D; i++){
      if (road[i-1]==0 && road[i]==0 && road[i+1]==0)
        ans = "Yes";
    }
    for (int i = A-1; i < C; i++){
      if (road[i]==1 && road[i+1]==1)
        ans = "No";
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1284
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/3/GRL_3_C"

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

// #include "../../library/graph/stronglyconnectedcomponents.cpp"

struct StronglyConnectedComponents {
    vector<vector<int>> const &edges_in;
    vector<vector<int>> edges, rev;
    vector<int> comp, order, used;

    StronglyConnectedComponents(vector<vector<int>> const &g)
        : edges_in(g), edges(g.size()), rev(g.size()), comp(g.size(), -1), used(g.size()) {
        for (int i = 0; i < (int)edges_in.size(); ++i) {
            for (auto &v : edges_in[i]) {
                edges[i].push_back(v);
                rev[v].push_back(i);
            }
        }
    }
    int operator[](int k) { return comp[k]; }
    void dfs(int c) {
        if (used[c])
            return;
        used[c] = true;
        for (auto &v : edges[c])
            dfs(v);
        order.push_back(c);
    }
    void rdfs(int c, int cnt) {
        if (comp[c] != -1)
            return;
        comp[c] = cnt;
        for (auto &v : rev[c])
            rdfs(v, cnt);
    }
    vector<vector<int>> build() {
        for (int i = 0; i < (int)edges.size(); ++i)
            dfs(i);
        reverse(order.begin(), order.end());
        int ptr = 0;
        for (auto &i : order) {
            if (comp[i] == -1)
                rdfs(i, ptr++);
        }
        vector<vector<int>> ret(ptr);
        for (int i = 0; i < (int)edges_in.size(); ++i) {
            int x = comp[i];
            for (auto &v : edges_in[i]) {
                int y = comp[v];
                if (x == y)
                    continue;
                ret[x].push_back(y);
            }
        }
        return ret;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edges(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        // u--, v--;
        edges[u].emplace_back(v);
    }
    StronglyConnectedComponents scc(edges);
    scc.build();
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int u, v;
        cin >> u >> v;
        if (scc[u] == scc[v])
            cout << 1 << "\n";
        else
            cout << 0 << "\n";
    }
    return 0;
}


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll n,p,ans=0,mini=inf;
	cin>>n;
	forn(i,n){
		cin>>p;
		if(p<mini)ans++;
		mini = min(p,mini);
	}
	cout<<ans<<'\n';
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""



Measured memory_bytes: 3656
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long K = sc.nextInt();
		long ans = 0;

		for(long k = K; k<=N+1; k++) {
			ans+=((2*N+1-k)*k/2-(k-1)*k/2+1);
			ans%=Math.pow(10,9)+7;
		}
		ans%=Math.pow(10,9)+7;
		System.out.println(ans);
	}
}

Measured memory_bytes: 35856
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			long N = long.Parse(Console.ReadLine());
            long[] A = new long[N];
            for(long i = 0; i < N; i++)
            {
                A[i] = long.Parse(Console.ReadLine());
            }
            var List = new List<long>();
            List.Add(A[0]);
            int len = 1;
            for(int i = 1; i < N; i++)
            {
                //for (int j = 0; j < len; j++) Console.Write(List[j]);
                //Console.WriteLine(' ');
                if (List[len-1] >= A[i])
                {
                    List.Add(A[i]);
                    len++;
                }
                else if(List[0] < A[i])
                {
                    List[0] = A[i];
                }
                else
                {
                    int min = 0, max = len-1;
                    while (true)
                    {
                        if ( (max-min) == 1)
                        {
                            List[max] = A[i];
                            break;
                        }
                        int mid = (min + max) / 2;
                        if (A[i] > List[mid])
                        {
                            max = mid;
                        }
                        else
                        {
                            min = mid;
                        }
                    }
                }
            }

            //for (int i = 0; i < len; i++) Console.Write(List[i]);
            Console.WriteLine(List.Count);
            Console.ReadLine();

		}
	}
}


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

int main(){
    int n,q; cin >> n >> q;
    vector<long long int> a(n); for(int i=0;i<n;i++) cin >> a[i];
    vector<long long int> x(q); for(int i=0;i<q;i++) cin >> x[i];

    for(int t=0;t<q;t++){
    long long int ans = 0;
    int l = 0, r = 0;
    long long int sum = 0;
    while(l != n){
        if(r > n-1){ans = ans + r - l; sum -= a[l]; l++;}
        else if(a[r] + sum <= x[t]){sum += a[r]; r++;}
        else{ans = ans + r - l; sum -= a[l]; l++;}
        //cout << l << ":" << r << ":" << sum << endl;
    }
    cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <boost/multi_array.hpp>

int main() {
    int N, Y;
    std::priority_queue<int> que;
    
    std::cin >> N >> Y;
    int ansa, ansb, ansc;
    ansa = ansb = ansc = -1;
    
    bool flag = false;
    // N<2000 O(4*10^6) 間に合うはず
    for (int a = 0; a <= N; a++) {
        for (int b = 0; b <= N-a; b++) {
            int c = N-a-b;
            int money = a*10000 + b*5000 + c*1000;
            if (Y == money) {
                ansa = a;
                ansb = b;
                ansc = c;
                flag = true;
            }
            if (flag) {
                break;
            }
        }
        if (flag) {
            break;
        }
    }
    
    std::cout << ansa << " " << ansb << " " << ansc << std::endl;

    return 0;
}


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

using namespace std;

template<class T> T sqr(T x){
  return x*x;
}

const double eps=1e-9;

int main(){
  for(int R,N;cin>>R>>N,R;){
    int x0[100],y0[100],r[100],v[100];
    vector<int> rem(N);
    for(int i=0;i<N;i++){
      cin>>x0[i]>>y0[i]>>r[i]>>v[i];
      rem[i]=i;
    }
    int ans=0;
    for(int i=1;;i++){
      auto d=[&](int x){
	return sqrt(sqr(x0[x])+sqr(y0[x]))-i*v[x];
      };
      auto it=remove_if(begin(rem),end(rem),[&](int x){
	  return d(x)<=R+eps;
	});
      ans+=end(rem)-it;
      rem.erase(it,end(rem));
      if(rem.empty())break;
      auto cl=min_element(begin(rem),end(rem),[&](int a,int b){
	  return d(a)<d(b);
	});
      double arg=atan2(y0[*cl],x0[*cl]);
      double xc=d(*cl);
      rem.erase(remove_if(begin(rem),end(rem),[&](int x){
	    complex<double> rp=polar(d(x),atan2(y0[x],x0[x])-arg);
	    return r[x]>=fabs(rp.imag())&&sqrt(sqr(r[x])-sqr(rp.imag()))+rp.real()>R;
	  }),end(rem));
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1272
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String S = in.readLine();
		String T = in.readLine();
		int count = 0;
		for (int i = 0; i < S.length(); ++i) {
			if (S.charAt(i) != T.charAt(i)) {
				++count;
			}
		}
		System.out.println(count);
	}

	void calc() {
	}

	void showResult() {
	}
}


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

typedef long long ll;
typedef unsigned long long ull;

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

    list<int> l;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string comm;
        int x;
        cin >> comm;
        if(comm=="insert"){
            cin >> x;
            l.push_front(x);
        }else if(comm=="delete"){
            cin >> x;
            for(auto it=l.begin();it!=l.end();it++){
                if(*it==x){
                    l.erase(it);
                    break;
                }
            }
        }else if(comm=="deleteFirst"){
            l.pop_front();
        }else{
            l.pop_back();
        }
    }
    for(auto it=l.begin();it!=l.end();it++){
        if(it!=l.begin()) cout << ' ';
        cout << *it;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 34332
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
A = LI()
B = [A[i]-i-1 for i in range(n)]
B.sort()
mid = B[n//2]
mid2 = B[(n-1)//2]
def sad(b, n):
    ret = 0
    for i in range(n):
        ret += abs(B[i]-b)
    return ret

ans = min(sad(mid, n), sad(mid2, n))
print(ans)


Measured memory_bytes: 117196
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n;
  cin >> n;
  set<int> s;
  vector<vector<int> > va(n + 1), vb(n + 1);
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    va[a[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    vb[b[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    s.insert(i);
  }
  for (int i = 1; i <= n; i++) {
    if (!va[i].empty() && !vb[i].empty()) {
      for (int j = vb[i][0] - va[i].back(); j <= vb[i].back() - va[i][0]; j++) {
        s.erase((j + 2 * n) % n);
      }
    }
  }
  if (s.empty()) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    int x = *s.begin();
    for (int i = 0; i < n; i++) {
      cout << b[(i + x + n) % n] << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 35864
# import itertools
# import math
import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
# import heapq
# from collections import deque

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
X, Y = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

if (X + Y) % 3 != 0:
    print(0)
    sys.exit()
if (2 * Y - X) < 0 or (2 * X - Y) < 0:
    print(0)
    sys.exit()

cnt = (X + Y) // 3

diff = abs(X - Y)



def comb(n, m, mod = 10 ** 9 + 7):
    numerator = 1
    denominator = 1
    for i in range(1, m + 1):
        numerator = numerator * (n - i + 1) % mod
        denominator = denominator * i % mod
    d_inv = pow(denominator, mod - 2, mod)
    return numerator * d_inv % mod

print(comb(cnt, (2 * Y - X) // 3) % (10 ** 9 + 7))

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

constexpr int64_t INF = 1e18;
constexpr int D = 365;
constexpr int N = 26;
int c[N];
int s[D + 1][N];
int last[D + 1][N];
int64_t score[D + 1];
int t[D + 1];

constexpr int64_t CYCLES_PER_SEC = 2800000000;
constexpr double TIMELIMIT = 2.05;
struct Timer {
	int64_t start;
	Timer() { reset(); }
	void reset() { start = getCycle(); }
	void plus(double a) { start -= (a * CYCLES_PER_SEC); }
	inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
	inline int64_t getCycle() {
		uint32_t low, high;
		__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
		return ((int64_t)low) | ((int64_t)high << 32);
	}
};
mt19937 mt{random_device{}()};
uniform_int_distribution<int> rnd_contest(0, N - 1);
// uniform_int_distribution<int> rnd_day(1, D);
normal_distribution<> rnd_day(0, 1);

void input() {
	int _d; cin >> _d;
	for(int i = 0; i < N; ++i) {
		cin >> c[i];
	}
	for(int i = 1; i <= D; ++i) {
		for(int j = 0; j < N; ++j) {
			cin >> s[i][j];
		}
	}
}

void greedy(int day, int contest = -1) {
	if(contest != -1) {
		for(int j = 0; j < N; ++j) {
			last[day][j] = last[day - 1][j];
		}
		last[day][contest] = day;
		++day;
	}
	for(int i = day; i <= D; ++i) {
		for(int j = 0; j < N; ++j) {
			last[i][j] = last[i - 1][j];
		}
		int64_t loss = 0;
		for(int j = 0; j < N; ++j) {
			loss += c[j] * (i - last[i][j]);
		}
		int64_t maxi = -INF;
		int midx = 0;
		for(int j = 0; j < N; ++j) {
			int64_t los = loss - c[j] * (i - last[i][j]);
			if(s[i][j] - los > maxi) {
				maxi = s[i][j] - los;
				midx = j;
			}
		}
		last[i][midx] = i;
		t[i] = midx;
	}
}

int64_t calc(int day) {
	int64_t ans = score[day - 1];
	for(int i = day; i <= D; ++i) {
		for(int j = 0; j < N; ++j) {
			last[i][j] = last[i - 1][j];
		}
		last[i][t[i]] = i;
		ans += s[i][t[i]];
		for(int j = 0; j < N; ++j) {
			int64_t loss = c[j] * (i - last[i][j]);
			ans -= loss;
		}
		score[i] = ans;
	}
	return ans;
}

void output() {
	for(int i = 1; i <= D; ++i) {
		cout << t[i] + 1 << '\n';
	}
}

int main() {
	Timer timer;
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	input();
	greedy(1);
	calc(1);
	int cnt = 0, update = 0;
	int valid = D;
	int64_t score_now = score[D];
	while(timer.get() < TIMELIMIT) {
		int q = rnd_contest(mt);
		double pro = rnd_day(mt);
		if(pro < 0) continue;
		++cnt;
		int d = max<int>(1, D - pro / 2 * D);
		int contest_pre = t[d];
		t[d] = q;
		valid = min(valid, d - 1);
		// greedy(d, q);
		int64_t score_nxt = calc(valid + 1);
		if(score_nxt > score_now) {
			score_now = score_nxt;
			update++;
			valid = D;
		} else {
			t[d] = contest_pre;
		}
	}
	cerr << cnt << " " << update << '\n';
	cerr << score_now << '\n';
	output();
	return 0;
}


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

int main()
{
  int n;
  cin >> n;
  int* a=new int[n];
  bool* f=new bool[n];
  for(int i=0;i<n;i++)
  {
    cin >> a[i];
    f[i]=false;
  }
  int cnt=0;
  while(true)
  {
    bool _f=true;
    for(int i=0;i<n;i++)
    {
      if(f[i])continue;
      if(a[i]%2==0)
      {
        a[i]/=2;
        _f=false;
        cnt++;
      }
    }
    if(_f)break;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
    int A, B, C, D, kotae;
    cin >> A >> B >> C >> D; 
    if(A * B > C * D){
        kotae = A * B;
    }
    else if(A * B < C * D){
        kotae = C * D;
    }
    else if(A * B == C * D){
        kotae = A * B;
    }
    cout << kotae << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a == b {
		fmt.Println("Draw")
		return
	}
	if a == 1 {
		fmt.Println("Alice")
		return
	}
	if b == 1 {
		fmt.Println("Bob")
		return
	}
	if a > b {
		fmt.Println("Alice")
		return
	} else {
		fmt.Println("Bob")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
     
#define pll pair <long long,long long>
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define vll vector <ll>
#define NFS ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define M 1000000007   
using namespace std;

void solve()
{
	ll n;
	cin>>n;
	int a[n+1],t;
	for(int i=1;i<n+1;i++)
			a[i]=0;
	for(int i=0;i<n-1;i++)
	{
		cin>>t;
		a[t]++;
	}
	for(int i=1;i<n+1;i++)
	{
		cout<<a[i]<<endl;
	}
}
 
int main()
{
    NFS
 	int t=1;
 	//cin>>t;
 	while(t--)
 	{
 		solve();
 	}
    return 0;
}

Measured memory_bytes: 4440
#include <bits/stdc++.h>
using namespace std;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef long long ll;

int main(){
    FASTER;
    int n,k;cin>>n>>k;
    vector<int> h(n),F(n,INT_MAX);for(int &i:h)cin>>i;

    if(k>=n){
        k=n;
    }

    for(int i=0;i<k;i++)F[i]=abs(h[0]-h[i]);

    for(int i=k;i<n;i++){
        for(int j=i-1;j>=i-k;j--){
            F[i]=min(abs(h[i]-h[j])+F[j],F[i]);
        }
    }
    cout<<F[n-1];
}


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


int main(void)
{
	int num, hasi;
	cin >> num >> hasi;
	int test[100000];
	for (int i = 0; i < num; i++) {
		cin >> test[i];
	}
	int ans = 0;
	for (int j = 0; j < num; j++) {
			if (hasi - test[j] >= test[j])
				ans += test[j] * 2;
			else
				ans += (hasi - test[j]) * 2;
	}
	cout << ans << endl;

	

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
ll dp[3010][3010];
ll dp2[3010][3010];
main(){
    int N,T;
    cin >> N >> T;
    vector<int> A(N),B(N);
    rep(i,0,N)cin >> A[i] >> B[i];
    ll sumt = 0;
    rep(i,0,N)sumt += A[i];
    if(sumt <= T){
        ll ans = 0;
        rep(i,0,N)ans += B[i];
        cout << ans << endl;
        return 0;
    }
    rep(i,0,N){
        rep(j,0,T+1){
            if(j >= A[i]){
                if(dp[i+1][j] < dp[i][j - A[i]] + B[i]){
                    dp[i+1][j] = dp[i][j-A[i]] + B[i];
                    dp2[i+1][j] = j - A[i];
                }
            }
            if(dp[i+1][j] < dp[i][j]){
                dp[i+1][j] = dp[i][j];
                dp2[i+1][j] = j;
            }
        }
    }

    //cout << "Selected items are..." << endl;
    set<int> used;
    int cur_w = T-1;
    for (int i = N - 1; i >= 0; --i)
    {
        // 選んでいた場合
        if (dp2[i + 1][cur_w] == cur_w - A[i])
        {
            //cout << i << " th item (weight = " << A[i] << ", value = " << B[i] << ")" << endl;
            used.insert(i);
        }

        // 復元テーブルをたどる
        cur_w = dp2[i + 1][cur_w];
    }
    ll ans = dp[N][T-1];
    ll remmax = 0;
    rep(i,0,N){

        if(used.count(i))continue;
        remmax = max(remmax, (ll)B[i]);
    }
    ans += remmax;
    cout << ans << endl;
}

Measured memory_bytes: 141696
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int c,d,e;
  c=a+b;
  d=a-b;
  e=a*b;
  if(c>=d&&c>=e) cout<<c<<endl;
  else if(d>=c&&d>=e) cout<<d<<endl;
  else cout<<e<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A, B;
    cin >> A >> B;
    int C = A+B;
    if(C%2 == 0){
        cout << abs(C/2);
    }
    else{
        cout << "IMPOSSIBLE";
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int r, g, b, ans;
  cin >> r >> g >> b;
  ans = 100 * r + 10 * g + b;

  cout << (ans % 4 == 0 ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
import math
n=int(input())
if n % 2 == 0 and n != 2:
        n += 1
while n <= n + 20:
    i=3
    while i <= math.sqrt(n):
        if n % i == 0:
            break
        else:
            i += 2
    if i >= math.sqrt(n):
        print(n)
        break
    else:
        n+=2

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

struct Node{
	Node *left;
	Node *right;
};

Node *null = new Node;

typedef struct Node Node;

int sz;
string s;
size_t cur;

void dfs(Node *n){
	n->left = null;
	n->right = null;
	cur++;
	if(s[cur] == '('){
		n->left = new Node;
		dfs(n->left);
		assert(s[cur] == ')');
		cur++;
	}
	cur++;
	if(s[cur] == '('){
		n->right = new Node;
		dfs(n->right);
		assert(s[cur] == ')');
		cur++;
	}
}

Node* make_tree(string str){
	s = str;
	sz = s.size();
	cur = 0;
	Node *res = new Node;
	dfs(res);
	return res;
}

bool ok(Node *n1, Node *n2, char c){
	if(c == 'i') return (n1 != null && n2 != null);
	else return (n1 != null|| n2 != null);
}

void output(Node *n1, Node *n2, char c){
	cout << '(';
	if(ok(n1->left, n2->left, c)) output(n1->left, n2->left, c);
	cout << ',';
	if(ok(n1->right, n2->right, c)) output(n1->right, n2->right, c);
	cout <<')';
}

int main(){
	null->left = null->right = null;
	char ch;
	string s1, s2;
	while(cin >> ch >> s1 >> s2){
		Node *r1 = new Node, *r2 = new Node;
		r1 = make_tree(s1);
		r2 = make_tree(s2);
		output(r1, r2, ch);
		cout << endl;
	}
	return 0;
}

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

int main(int argc, char* argv[]) {
  int h1=0, h2=0, h3=0, h;
  for(int i=1;i<11;i++){
    cin >> h;
    if(h>h3){
      h3 = h;
      if(h3>h2){
        swap(h3, h2);
        if(h2>h1){
          swap(h2, h1);
        }
      }
    }
  }
  cout << h1 << endl;
  cout << h2 << endl;
  cout << h3 << endl;

  return 0;
}

Measured memory_bytes: 1160
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    k = ni()
    c = 0
    for i in range(k):
        c = (c * 10 + 7) % k
        if c == 0:
            print(i+1)
            break
    else:
        print(-1)
    return

solve()


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

int main() {
  ll a;
  double b;
  cin >> a >> b;

  ll ib = b * 100 + 0.5;
  a *= ib;
  a /= 100;
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 3724
n = gets.to_i
sp = []

n.times do |i|
  sp << gets.split("\s")
end

sp_dup = sp.dup

n.times do |i|
  min = [nil, nil]
  sp.each do |x|
    if !min.first || min.first > x.first
      min = x
    elsif min.first == x.first
      min = x if x.last.to_i > min.last.to_i
    end
  end
  puts sp_dup.index(sp.delete(min)) + 1
end

Measured memory_bytes: 1788
using System;

class Program
{
  public static void Main(string[] args)
  {
    int count = int.Parse(Console.ReadLine());
    int[] numbers = new int[count];
    string[] read = Console.ReadLine().Split(' ');
    for(int i = 0;i < count;i++) numbers[i] = int.Parse(read[i]);



    for(int i = count - 1;i >= 0;i--){
      Console.Write(numbers[i]);
      if(i != 0) Console.Write(" ");
    }
    Console.WriteLine();
  }
}

Measured memory_bytes: 9100