akhauriyash/Code-Regression huggingface dataset:
package main

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

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	var n, r, min int
	max := math.MinInt32
	sc.Scan();
	n, _ = strconv.Atoi(sc.Text())
	sc.Scan();
	min, _ = strconv.Atoi(sc.Text())
	for i := 1; i<n; i++ {
		sc.Scan();
		r, _ = strconv.Atoi(sc.Text())
		a := r-min
		if a > max { max = a }
		if r < min { min = r }
	}
	fmt.Printf("%d\n", max)
}



Measured memory_bytes: 4156
import sys
cnt = 0

def merge_sort(a, left, right):
	if left + 1 < right:
		mid = int(left + (right - left) / 2)
		merge_sort(a, left, mid)
		merge_sort(a, mid, right)
		merge(a, left, mid, right)

def merge(a, left, mid, right):
	n1 = mid - left
	n2 = right - mid
	L = a[left:left+n1]
	R = a[mid:mid+n2]
	L.append(sys.maxsize)
	R.append(sys.maxsize)
	i = j = 0
	for k in range(left, right):
		if L[i] <= R[j]:
			a[k] = L[i]
			i += 1
		else:
			if i < n1:
				global cnt
				cnt += n1 - i
			a[k] = R[j]
			j += 1
	
n = int(input())
a = list(map(int, input().split()))
merge_sort(a, 0, len(a))
print(cnt)



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

int main() {
  int n;
  cin >> n;
  vector<int> a(n),ans(n);
  for(int i = 0;i < n;i++){
    cin >> a.at(i);
    ans.at(a.at(i)-1) = i+1;
  }
  cout << ans.at(0);
  for(int j = 1;j < n;j++){
	cout << " " << ans.at(j);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1664
//AOJ-ALDS-1-5-D
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

/*
    1-indexed であることに注意 !! 
*/
template <typename T>
struct BIT{
    int n;
    vector<T> dat;

    BIT(int n) : n(n), dat(n + 1, 0) {}

    T sum(int a){
        T res = 0;
        for(int i = a; i > 0; i -= (i & (-i))) res += dat[i];
        return res;
    }

    T sum(int a, int b){
        return sum(b - 1) - sum(a - 1);
    }

    void add(int k, T x){
        if(k == 0) return;
        for(int i = k; i <= n; i += (i & (-i))) dat[i] += x;
    }

    /*
        a[0] + a[1] + ... + a[res] >= x
    */
    int lower_bound(T x){
        if(x <= 0) return T(0);
        int res = 0, k = 1;
        while(k < n) k <<= 1;
        for(; k > 0; k >>= 1){
            if(res + k <= n && dat[res + k] < x){
                x -= dat[res + k];
                res += k;
            }
        }
        return res + 1;
    }
};

/*
    vector<long long> a(n) を座圧する場合 : 
    auto v = compress(a);
    auto m = dict(v);
    i番目の要素の取り出し方 : 
    m[a[i]]
*/
template<typename T>
vector<T> compress(vector<T> vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

template<typename T>
map<T, int> dict(vector<T> & vec){
    map<T, int> res;
    for(int i = 0; i < (int)vec.size(); i++){
        res[vec[i]] = i;
    }
    return res;
}

signed main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }
    auto v = compress(a);
    auto m = dict(v);
    BIT<int> bit(m.size());
    ll ans = 0;
    REP(i,n){
        ans += i - bit.sum(m[a[i]] + 1);
        bit.add(m[a[i]] + 1, 1);
    }
    cout << ans << endl;
    return 0;
}


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

int a[8][8];

int main(void)
{
    int n, m;
    cin >> n >> m;
    
    rep(i, m){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        a[x][y] = 1;
        a[y][x] = 1;
    }

    vector<int> p(n);
    rep(i, n) p.at(i) = i + 1;

    int ans = 0;

    do{
        bool flag = true;
        if(p[0] != 1) continue;
        rep(i, n - 1)
        {
            if(a[p[i] - 1][p[i+1] - 1] == 0)
            {
                flag = false;
            }
        }
        if(flag) ans++;
    }while(next_permutation(p.begin(), p.end()));

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

Measured memory_bytes: 256
N, K = map(int, input().split())
d = []
A = []
sunuke = [0] * N
for _ in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))
    for i in A[-1]:
        sunuke[i-1] += 1
print(len([i for i in sunuke if i == 0]))




Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] h = new int[n];
        for(int i=0; i<n; i++) {
            x[i] = in.nextInt();
            y[i] = in.nextInt();
            h[i] = in.nextInt();
        }
        boolean ok = false;
        int ans_x = -1;
        int ans_y = -1;
        int ans_h = -1;
        for(int cy = 0; cy <= 100; cy++) {
            for(int cx = 0; cx <= 100; cx++) {
                ok = true;
                int H = -1;
                for(int i=0; i<n; i++) {
                    if(h[i]==0) {
                        continue;
                    }
                    if(H==-1) {
                        H = h[i] + Math.abs(cx-x[i]) + Math.abs(cy-y[i]);
                    }
                    else if(H == h[i] + Math.abs(cx-x[i]) + Math.abs(cy-y[i])) {
                        continue;
                    }
                    else {
                        ok = false;
                        break;
                    }
                }
                for(int i=0; i<n; i++) {
                    if(h[i]!=0) {
                        continue;
                    }
                    if(H - Math.abs(cx-x[i]) - Math.abs(cy-y[i]) > 0) {
                        ok = false;
                        break;
                    }
                }
                if(ok) {
                    ans_x = cx;
                    ans_y = cy;
                    ans_h = H;
                    break;
                }
            }
            if(ok) {
                break;
            }
        }
        System.out.print(ans_x);
        System.out.print(' ');
        System.out.print(ans_y);
        System.out.print(' ');
        System.out.print(ans_h);
        System.out.println();
    }
}


Measured memory_bytes: 22228
S = int(input())
INF = 10 ** 9 + 7
dp = [0] * (S + 1)
dp[0] = 1

for i in range(1, S + 1):
    for j in range(i - 2):
        dp[i] += dp[j]
        dp[i] %= INF

print(dp[S])

Measured memory_bytes: 9020
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, m;
    cin >> n >> m;
    string a[n], b[m];
    fore(i,0,n) cin >> a[i];
    fore(i,0,m) cin >> b[i];
    bool ans = false;
    fore(i,0,n-m+1) {
        fore(j,0,n-m+1) {
            bool ok = true;
            fore(k,0,m) fore(l,0,m) {
                if (a[i+k][j+l] != b[k][l]) {
                    ok = false;
                }
            }
            if (ok) ans = true;
        }
    }
    if (ans) cout << "Yes\n";
    else cout << "No\n";
}


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


#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


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

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {
    int x, a, b;
    cin >> x >> a >> b;

    int ad = abs(a - x);
    int bd = abs(b - x);

    if (ad < bd) {
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }

}

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

typedef long long ll;
const ll INF = (1ll<<60);
const int N = 200006;

ll dp[5][N];
ll a[N];

int main () {
    int n;
    scanf("%d",&n);
    for (int i=1;i<=n;++i) {
        scanf("%lld",&a[i]);
    }
    //all zero first
    for (int i=1;i<=n;++i) {
        dp[0][i] = dp[0][i-1] + a[i];
    }
    //make even number
    for (int i=1;i<=n;++i) {
        ll cost = 0;
        if (a[i] == 0) cost = 2;
        else if (a[i]%2 == 1) cost = 1;
        dp[1][i] = min(dp[0][i-1],dp[1][i-1]) + (cost);
    }
    //make odd
    for (int i=1;i<=n;++i) {
        dp[2][i] = min(dp[2][i-1],min(dp[0][i-1],dp[1][i-1])) + (a[i]%2==1?0:1);
    }
    //make even
    for (int i=1;i<=n;++i) {
        ll cost = 0;
        if (a[i] == 0) cost = 2;
        else if (a[i]%2 == 1) cost = 1;
        dp[3][i] = min( dp[3][i-1],min( dp[2][i-1] ,min(dp[0][i-1],dp[1][i-1]))) + (cost);
    }
    //make zero
    for (int i=1;i<=n;++i) {
        dp[4][i] = min(min(dp[0][i-1],dp[1][i-1]) , min(dp[2][i-1],dp[3][i-1])) + a[i];
        dp[4][i] = min(dp[4][i],dp[4][i-1] + a[i]);
    }


    ll ans = INF;
    for (int i=0;i<5;++i) {
        ans = min(ans,dp[i][n]);
    }
    printf("%lld\n",ans);
}



Measured memory_bytes: 9728
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    
    cout << H*W/2 << " ";
    if(x==W/2 && y==H/2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
n, a, b = map(int,input().split())


ope1 = n//(a+b)
ope2 = n%(a+b)

if ope1 == 0:
    if n > a:
        print(a)
    else:
        print(n)
elif ope2 == 0:
    print(a*ope1)
elif ope2 < a:
    print(a*ope1 + ope2)
else:
    print(a*ope1 + a)


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

int main() {
 int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(string &x: s) cin>>x;
  vector<int> dx={1,1,1,0,0,-1,-1,-1};
  vector<int> dy={1,0,-1,1,-1,1,0,-1};
  for(int x=0;x<w;x++){
    for(int y=0;y<h;y++){
      if(s[y][x]=='.'){
        int count=0;
     	 for(int i=0;i<8;i++){
       	 int X=x+dx[i];
       	 int Y=y+dy[i];
       	 if(X>=0&&X<w&&Y>=0&&Y<h&&s[Y][X]=='#') count++;
         }
        string S=to_string(count);
        s[y][x]=S[0];
      }
    }
  }
  for(int i=0;i<h;i++) cout<<s[i]<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while ((s = Console.ReadLine()) != null)
			{
				var input = s.Split(' ');

				if (input[0] == "u")
				{
					var node = Union(Parse(input[1]), Parse(input[2]));
					Console.WriteLine(node.ToString());
				}
				else if (input[0] == "i")
				{
					var node = Intersection(Parse(input[1]), Parse(input[2]));
					Console.WriteLine(node.ToString());
				}
			}
		}

		public static Node Union(Node tree1, Node tree2)
		{
			var union = new Node();
			Union(union, tree1, tree2);
			return union;
		}

		public static void Union(Node union, Node tree1, Node tree2)
		{
			if (tree1 == null) tree1 = new Node();
			if (tree2 == null) tree2 = new Node();

			if (tree1.HasLeft() || tree2.HasLeft())
			{
				union.Left = new Node();
				Union(union.Left, tree1.Left, tree2.Left);
			}
			if (tree1.HasRight() || tree2.HasRight())
			{
				union.Right = new Node();
				Union(union.Right, tree1.Right, tree2.Right);
			}
		}

		public static Node Intersection(Node tree1, Node tree2)
		{
			var intersection = new Node();
			Intersection(intersection, tree1, tree2);
			return intersection;
		}

		public static void Intersection(Node intersection, Node tree1, Node tree2)
		{
			if (tree1.HasLeft() && tree2.HasLeft())
			{
				intersection.Left = new Node();
				Intersection(intersection.Left, tree1.Left, tree2.Left);
			}
			if (tree1.HasRight() && tree2.HasRight())
			{
				intersection.Right = new Node();
				Intersection(intersection.Right, tree1.Right, tree2.Right);
			}
		}

		public static Node Parse(string s)
		{
			var rootNode = new Node();
			var currentNode = rootNode;

			for (int i = 0; i < s.Length; i++)
			{
				if (s[i] == '(')
				{
					currentNode.Left = new Node();
					currentNode = currentNode.Left;
				}
				else if (s[i] == ')')
				{
					currentNode = currentNode.Parent;
				}
				else if (s[i] == ',')
				{
					i++;
					if (s[i] == '(')
					{
						currentNode.Right = new Node();
						currentNode = currentNode.Right;
					}
					else if (s[i] == ')')
					{
						currentNode = currentNode.Parent;
					}
				}
			}
			return rootNode.Left;
		}
	}

	public class Node
	{
		public Node Parent { get; set; }

		private Node left;
		public Node Left
		{
			get { return left; }
			set
			{
				left = value;
				left.Parent = this;
			}
		}

		private Node right;
		public Node Right
		{
			get { return right; }
			set
			{
				right = value;
				right.Parent = this;
			}
		}

		public bool HasLeft()
		{
			return Left != null;
		}

		public bool HasRight()
		{
			return Right != null;
		}

		public override string ToString()
		{
			string leftstring = Left == null ? "" : Left.ToString();
			string rightstring = Right == null ? "" : Right.ToString();
			return string.Format("({0},{1})", leftstring, rightstring);
		}
	}
}

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

int main() {
 int N, L;
  cin >> N >> L;
  if (L + 1 - 1 > 0) {
    cout << (N - 1) * (L - 1) + ((N - 1) * (N + 2)) / 2 << endl;
  }
  else if (L + N - 1 < 0) {
    cout << (N - 1) * (L - 1) + ((N - 1) * N) / 2 << endl;
  }
  else {
    cout << N * (L - 1) + (N * (1 + N)) / 2 << endl;
  }
}

Measured memory_bytes: 3544
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {in_n: usize, in_a: [i64; in_n]};
    let mut xor = 0;

    for a in &in_a {
        xor ^= *a;
    }

    for a in &in_a {
        println!("{} ", xor ^ *a);
    }
}


Measured memory_bytes: 6580
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
cin >> N;

double heikin = 0;
vector<double> A(N);
for( int i = 0; i < N; i++ ){
cin >> A.at(i);
heikin += A.at(i);
}

heikin = heikin/ (double)N;

double sa = 1000;
int ans;
for( int i = 0; i < N; i++){
if( abs( heikin - A.at(i) ) < sa ){
ans = i;
sa = abs( heikin - A.at(i) );
}
}

cout << ans << endl;




            
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
//vector<string> vs;
int main(){
  ll n;
  cin>>n;
  ll ans=0;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ll m=(n/i)-1;
      if(m>i) ans+=m;
    }
  }
  cout<<ans<<endl;
}


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

int main() 
{

	int n; cin>>n; int a[n];
	for(int i=0;i<n-1;i++)
	{
		cin>>a[i];
	}
	int res[n];
	memset(res,0,sizeof(res));
	res[0]=a[0]; res[1]=a[0];
	for(int i=1;i<n-1;i++)
	{
		if(a[i]>=max(res[i],res[i+1]))
		{
			res[i+1]=a[i];
		}
		else
		{
			res[i+1]=a[i]; res[i]=a[i];
		}
		
	}
	int sm=0;
	for(int i=0;i<n;i++)
	{
		sm+=res[i];
		//cout<<res[i]<<" ";
	}
	cout<<sm;
	
	
	
	
	
	
	
	
	
	

}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int D, Q, x[131072], ls, rs, es, a, b; vector<int> seg[262144];
int query(int k, int l, int r) {
	if (r <= ls || rs <= l) return 0;
	if (ls <= l && r <= rs) return lower_bound(seg[k].begin(), seg[k].end(), b) - lower_bound(seg[k].begin(), seg[k].end(), a);
	int lc = query(2 * k, l, (l + r) / 2);
	int rc = query(2 * k + 1, (l + r) / 2, r);
	return lc + rc;
}
int main() {
	scanf("%d", &D);
	for (int i = 0; i < D; i++) {
		scanf("%d", &x[i]);
		int t = i + 131072;
		while (t > 0) {
			seg[t].push_back(x[i]);
			t >>= 1;
		}
	}
	for (int i = 1; i < 262144; i++) {
		if (seg[i].size() > 1) {
			sort(seg[i].begin(), seg[i].end());
		}
	}
	scanf("%d", &Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d%d%d", &ls, &rs, &es); ls--;
		a = min(x[ls], x[rs - 1]) - es;
		b = max(x[ls], x[rs - 1]) + es + 1;
		printf("%d\n", rs - ls - query(1, 0, 131072));
	}
	return 0;
}

Measured memory_bytes: 21224
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
s = [0] * 1000000
for i in range(n):
  s[i+1] = s[i] + a[i]
  
max_s = 0
for i in range(n):
  if max_s < s[i+k] - s[i]:
    max_s = s[i+k] - s[i]
print((max_s+k) / 2)

Measured memory_bytes: 26604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int n;
vector<int> G[200010];
bool used[200010];
vector<int> v[2];
int ans[200010];

void dfs(int k, int d) {
    used[k] = 1;
    v[d].push_back(k);
    for (int i = 0; i < G[k].size(); i++) {
        int to = G[k][i];
        if (used[to]) continue;
        dfs(to, (d? 0:1));
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int f,t;
        cin >> f >> t;
        G[f].push_back(t);
        G[t].push_back(f);
    }

    dfs(1,0);

    // for (int i = 0; i < 2; i++) {
    //     for (int j = 0; j < v[i].size(); j++) {
    //         cout << v[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    int sz[2] = {(int)v[0].size(), (int)v[1].size()};
    if (sz[0] <= n / 3 || sz[1] <= n / 3) {
        int g;
        if (sz[0] <= n / 3) g = 0;
        else g = 1;
        int cnt = 3;
        for (int i = 0; i < v[g].size(); i++) {
            ans[v[g][i]] = cnt;
            cnt += 3;
        }
        if (g == 1) g = 0;
        else g = 1;
        for (int i = 0; i < v[g].size(); i++) {
            if (cnt > n) {
                if (cnt % 3 == 0) {
                    cnt = 1;
                } else {
                    cnt = 2;
                }
            }
            ans[v[g][i]] = cnt;
            cnt += 3;
        }
    } else {
        int cnt1 = 1;
        int cnt2 = 2;
        int cnt = 3;
        for (int i = 0; i < v[0].size(); i++) {
            if (cnt1 > n) {
                ans[v[0][i]] = cnt;
                cnt += 3;
                continue;
            }
            ans[v[0][i]] = cnt1;
            cnt1 += 3;
        }
        for (int i = 0; i < v[1].size(); i++) {
            if (cnt2 > n) {
                ans[v[1][i]] = cnt;
                cnt += 3;
                continue;
            }
            ans[v[1][i]] = cnt2;
            cnt2 += 3;
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << " \n"[i == n];
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }

int main(){
  int A,B,C,D; cin>>A>>B>>C>>D;
  string ans;
  while(1){
    C -= B;
    if(C<=0){ans = Liny; break;}
    A -= D;
    if(A<=0){ans = Linn; break;}
  }
  cout << ans;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<limits>
#include<list>
#include <stdio.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0;i < (n); ++i)
#pragma GCC optimize("Ofast")



int main() {
	int a;
	cin >> a;
	if (a >= 30)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <map>
#include <vector>
#include <tuple>
#include <cstdio>
#include <algorithm>
#include <set>
#include <iostream>
using namespace std;
typedef long long ll;

const int maxn = 300005;

tuple<ll, ll> bombs[maxn];
map<ll, ll> cnt;
vector<tuple<ll, ll>  > c;
set<ll> my;

int main() {
  int H, W, M; scanf("%d%d%d", &H,&W,&M);
  ll xx, yy;
  for(int i = 0; i < M; i++) {
    scanf("%lld%lld", &xx, &yy);
    bombs[i] = {xx, yy};
    ll sss = cnt[yy];
    cnt[yy] = sss + 1;
  }
  for(auto [k, v] : cnt) {
    c.push_back({v, k});
  }
  sort(c.begin(), c.end());
  sort(bombs, bombs + M);
  int left = 0, right = 0;
  ll ans = -1;
  ll mcnt = get<0>(c.back());
  for(auto [k, v] : cnt) {
    if(v == mcnt) {
      my.insert(k);
    }
  }
  while(left != M) {
    auto [cur_x, cur_y] = bombs[0];
    auto [x, y] = bombs[right];
    int ccc = 0;
    while(x == get<0>(bombs[left]) && right < M) {
        cerr << x << ", " << y << endl;
      if(my.find(y) != my.end()) ccc += 1;
      right++;
      if(right < M) {
        std::tie(x, y) = bombs[right];
      }
    }
    if(ccc == my.size()) {
      ans = max(ans, right - left + mcnt - 1);
    } else {
      ans = max(ans, right - left + mcnt);
    }
    left = right;
  }
  printf("%lld\n", ans);
  return 0;
}

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

int main()
{
	//#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    //freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    //freopen("output.txt", "w", stdout);
//#endif

	int n,k;
	cin>>n>>k;
	if(k!=1)
		cout<<n-k<<endl;
	else
		cout<<0<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void outputArray(int arr[], int s){
	int i;
	for(i=0;i<s;i++){
		printf("%d",arr[i]);
		if(i!=s-1){putchar(' ');}
		else      {putchar('\n');}
	}
}

int main(){
	int n, i, v, swipes = 0;
	int flag = 1;
	scanf("%d", &n);
	int a[n];
	for(i=0;i<n;i++){
		scanf("%d", &a[i]);
	}

	//bubble sort
	while(flag){
		flag = 0;

        for(i=n-1;i>=1;i--){
            if(a[i-1]>a[i]){

				v = a[i-1];
				a[i-1] = a[i];
				a[i] = v;
				swipes++;
				flag = 1;
            }
        }

	}
	outputArray(a, n);
	printf("%d",swipes);
	putchar('\n');

}



Measured memory_bytes: 2096
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#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 FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    string s;
    while (cin >> s) {
        const int yy = 10*(s[0]-'0') + s[1]-'0';
        const int mm = 10*(s[2]-'0') + s[3]-'0';
        if (1 <= mm && mm <= 12 && 1 <= yy && yy <= 12)
            cout << "AMBIGUOUS" << endl;
        else if (1 <= mm && mm <= 12)
            cout << "YYMM" << endl;
        else if (1 <= yy && yy <= 12)
            cout << "MMYY" << endl;
        else
            cout << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
use std::collections::VecDeque;

fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let s = sc.chars();
    let mut stack: VecDeque<char> = VecDeque::new();
    for &c in s.iter() {
        if let Some(&value) = stack.back() {
            if value != c {
                stack.pop_back();
                continue;
            }
        }
        stack.push_back(c);
    }
    println!("{}", s.len() - stack.len());
    
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self.stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .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: 8572
import java.io.*;
import java.util.*;

public class Main {
  private static boolean solve(char[] cs) {
    int[] counts = new int[26];
    for (char c : cs) {
      counts[c - 'a']++;
    }
    for (int count : counts) {
      if (count % 2 == 1) {
        return false;
      }
    }
    return true;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    char[] cs = reader.nextCharArray();
    out.println(solve(cs) ? "Yes" : "No");
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

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

using namespace std;

int main(){
  char c;
  cin>>c;

  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout<<"vowel";
  }else{
    cout<<"consonant";
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
#define int long long int

int gcd(int a, int b) {
  if (a < b) {
    swap(a, b);
  }

  while (b != 0) {
    int r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int lcs(int a, int b) { return b / gcd(a, b) * a; }

void solve() {
  int N;
  cin >> N;

  int ans;
  cin >> ans;
  for (int i = 1; i < N; i++) {
    int a;
    cin >> a;
    ans = lcs(ans, a);
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		sc.close(); 
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				if (i * j == n) {
					System.out.println("Yes");
					System.exit(0);
				}				
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
llong h[10];
llong cnt[10][10];

llong head_num(llong x) {
    llong res;
    do {
        res = x % 10;
        x /= 10;
    } while (x);

    return res;
}

int main() {
    cin >> n;

    for (llong i = 1; i <= n; i++) {
        cnt[head_num(i)][i % 10]++;
    }

    llong ans = 0;
    for (llong i = 1; i <= n; i++) {
        ans += cnt[i % 10][head_num(i)];
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {
    priority_queue<double, vector<double>, greater<int>> v;
    int n,tmp;
    double x,y;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        v.push(tmp);
    }

    while (v.size() != 1) {
        x = v.top();
        v.pop();
        y = v.top();
        v.pop();
        v.push((x + y) / 2);
    }
    cout << v.top() << endl;
    return 0;
}


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

flg = False

for i in range(26):
  t = n - i*4
  if(t < 0):
    break
  elif(t == 0):
    flg = True
    break
  else:
    if(t % 7 == 0):
      flg = True
      break

if(flg):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    var (N, K) = pairIntLong()
    val AB = Array(N) { pairIntLong() }.sortedBy { it.first }
    for (n in AB.indices) {
        if (AB[n].second >= K) return println(AB[n].first)
        K -= AB[n].second
    }
}
fun pairIntLong() = listOfLong().let { Pair(it[0].toInt(), it[1]) }

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 80988
// Aizu 1129: Hanafuda Shuffle
// 2017.9.13 bal4u@uu

#include <stdio.h>
#include <string.h>

char card[2][53];

int main()
{
	int n, r, p, c, i, k1, k2;
	
	while (scanf("%d%d", &n, &r) && n) {
		for (i = 1; i <= n; i++) card[0][n-i] = i;
		for (k1 = 0, k2 = 1, i = 0; i < r; i++, k1 = k2, k2 = !k2) {
			scanf("%d%d", &p, &c);
			memcpy(card[k2], card[k1], n);
			memcpy(card[k2], card[k1]+p-1, c);
			memcpy(card[k2]+c, card[k1], p-1);
		}
		printf("%d\n", card[k1][0]);
	}
	return 0;
}

Measured memory_bytes: 1724
// AOJ 1142 列車の編成
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
 
public class Main{
	
	static String reverse(String ss) {
		StringBuffer s = new StringBuffer(ss);
		s.reverse();
		return s.toString();
	}
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = Integer.parseInt(sc.nextLine());
        for(int i = 0; i < m; i++) {
        	String arrive = sc.nextLine();
        	int n = arrive.length();
        	Set<String> train = new HashSet<String>();
        	for(int j = 1; j <= n - 1; j++) {
        		String f = arrive.substring(0, j);
        		String b = arrive.substring(j);        	
        		String fre = reverse(f);
        		String bre = reverse(b);
        		//System.out.println(f + " " + b + " " + fre + " " + bre);
        		train.add(f + b);
        		train.add(f + bre);
        		train.add(fre + b);
        		train.add(fre + bre);
        		train.add(b + f);
        		train.add(b + fre);
        		train.add(bre + f);
        		train.add(bre + fre);
        	}
        	
        	System.out.println(train.size());
        }
    }
}



Measured memory_bytes: 61256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  for (int i = 0; i < n; ++i) {
    cin >> l[i];
  }
  sort(l.rbegin(), l.rend());
  int ans = 0;
  for (int i = 0; i < k; ++i) {
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
vector<int>Z(char *s)
{
	vector<int>z(1000010);
	int l=0,r=0;
	int ln=strlen(s);
	for(int k=2;k<=ln;k++)
	{
		if(s[k-1]!=s[0])continue;
		if(k>r)
		{
			l=r=k;
			while(r<=ln && s[r-1]==s[r-l])r++;
			r--;
			z[k]=r+1-l;
		}
		else
		{
			int tk=k+1-l;
			if(z[tk]<r+1-k)
			{
				z[k]=z[tk];
			}
			else
			{
				l=k;
				while(r<=ln && s[r-1]==s[r-l])r++;
				r--;
				z[k]=r+1-l;
			}
		}
	}
	return z;
}
char s[200010];
long long l,r;
int p;
int n;
long long sum[200010][26];
long long gtans(long long x,int y)
{
	if(x<=n)return sum[x][y];
	if(x<=2*n)return sum[x-n][y]+sum[n][y];
	long long s1=sum[n][y]+sum[p][y],s2=sum[n][y],a=n+p,b=n;
	while(x>a+b)
	{
		s1+=s2;s2=s1-s2;a+=b;b=a-b;
	}
	return s1+gtans(x-a,y);
}
long long solve(long long x,int y)
{
	if(x<=n)return sum[x][y];
	if(n%p==0)
	{
		long long t=(x-n)/(long long)p*sum[p][y]+sum[n][y];
		x%=(long long)p;
		return t+sum[x][y];
	}
	else return gtans(x,y);
}
int main()
{
	scanf("%s",s);
	scanf("%lld%lld",&l,&r);
	n=strlen(s)/2;
	vector<int>res=Z(s);
	for(int i=n+2;i<=strlen(s);i++)
	{
		if(res[i]==strlen(s)+1-i)
		{
			p=res[i];
			break;
		}
	}
	p=n-p;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<26;j++)sum[i][j]+=sum[i-1][j];
		sum[i][s[i-1]-'a']++;
	}
	for(int i=0;i<26;i++)
	{
		printf("%lld ",solve(r,i)-solve(l-1,i));
	}
	return 0;
}

Measured memory_bytes: 24832
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


int main(){
  int n;
  cin>>n;
  int p[n];
  bool flag=true;
  int c=0;
  for(int i = 1; i <= n; i++){
    cin>>p[i];
    if(p[i]==i){
      if(flag){
        flag=false;
        c++;
      }
      else{
        flag=true;
      }
    }
    else{
      flag=true;
    }
  }
  cout<<c<<endl;
  return 0;
}


Measured memory_bytes: 640
import sys


class UnionFind:
    def __init__(self, node_size):
        self._node = node_size
        self.par = [i for i in range(self._node)]
        self.rank = [0] * self._node

    def find(self, ver):
        if self.par[ver] == ver:
            return ver
        else:
            self.par[ver] = self.find(self.par[ver])
            return self.par[ver]

    def unite(self, ver1, ver2):
        ver1, ver2 = self.find(ver1), self.find(ver2)
        if ver1 == ver2:
            return
        if self.rank[ver1] < self.rank[ver2]:
            ver1, ver2 = ver2, ver1
        self.par[ver2] = ver1
        if self.rank[ver1] == self.rank[ver2]:
            self.rank[ver1] += 1

    def same(self, ver1, ver2):
        return self.find(ver1) == self.find(ver2)


class Kruskal:

    class Edge:
        def __init__(self, u, v, cost):
            self.u, self.v, self.cost = u, v, cost

        def __lt__(self, another):
            return self.cost < another.cost

    def __init__(self, node_size):
        self._node = node_size
        self._edge_list = []

    def add_edge(self, u, v, cost):
        self._edge_list.append(self.Edge(u, v, cost))

    def solve(self):
        uf = UnionFind(self._node)
        res = 0
        self._edge_list.sort()
        for e in self._edge_list:
            if not uf.same(e.u, e.v):
                uf.unite(e.u, e.v)
                res += e.cost
        return res

if __name__ == '__main__':
    n, m = map(int, sys.stdin.readline().split())
    kr = Kruskal(n)
    for _ in range(m):
        s, t, w = map(int, sys.stdin.readline().split())
        kr.add_edge(s, t, w)
    print(kr.solve())



Measured memory_bytes: 33156
# -*- coding: utf-8 -*-
from collections import Counter

H, W = tuple(map(int, input().split()))
C = Counter()

for _ in range(H):
    C.update(input())


if H%2 == 0 and W%2 == 0:
    for v in C.values():
        if v%4 != 0:
            print("No")
            break
    else:
        print("Yes")

elif (H%2 == 1) and (W%2 == 1):
    values = list(C.values())
    v4 = [v//4 for v in values]
    l1 = [v%2 for v in values]
    if ((H-1)*(W-1)//4 <= sum(v4)) and sum(l1)==1:
        print("Yes")
    else:
        print("No")

else:
    if H%2 == 0:
        H, W = W, H
    values = list(C.values())
    v4 = [v//4 for v in values]
    l1 = [v%2 for v in values]
    if ((H-1)*(W)//4 <= sum(v4)) and sum(l1)==0:
        print("Yes")
    else:
        print("No")   

Measured memory_bytes: 3436
import sys
w=input()
l=[w[i] for i in range(len(w))]
l.sort()
m=[0]*26
m[0]+=1
i=0
v=0
for i in range(1,len(w)):
    if l[i] in l[:i]:
        m[v]+=1
    else:
        v+=1
        m[v]+=1
    i+=1
for c in m:
    if c%2==1:
        print("No")
        sys.exit()
print("Yes")

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

int main() {
	int n;cin>>n;
	vector<int> v(n,0);
	for(int i=0;i<n-1;++i){
		int t;cin >>t;
		++v[t-1];
	}
	
	for (int i=0;i<n;++i){
		cout << v[i] << endl;
	}
	return 0;
}

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

int main() {
    int n, l;
    cin>>n >>l;
    int ans=0;
    if(l>=0){
        for(int i=1;i<n;i++){
            ans=ans+l+i;
        }
    }else if(l>-n){
        rep(i,n){
            if(l+i==0) continue;
            ans=ans+l+i;
        } 
    }else{
        rep(i,n-1){
            ans=ans+l+i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	string str;
	cin >> str;
	bool d = false, x = false, n = false, b = false;
	for( char c : str ){
		if( c == 'E' ) d = true;
		else if( c == 'W' ) x = true;
		else if( c == 'S' ) n = true;
		else if( c == 'N' ) b = true;
	}
	if( ( (int)d + (int)x ) % 2 == 0 && ( (int)n + (int)b ) % 2 == 0 ){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(nk[1] * Math.Pow(nk[1] - 1, nk[0] - 1));
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<vector>

using namespace std;

#define INF 2147483647

class RMQ{
public:
  int n;
  vector<int> d;

  RMQ(int size){
    initRMQ(size);
  }

  void initRMQ(int size){
    n = 1;
    //the size of array is power of 2
    while(n < size) n *= 2;
    //initialize all node in the segment tree
    //d.resize(2*i, numeric_limits<float>::infinity());
    d.resize(2*n, INF);
  }

  void update(int k, int a){
    k += n-1; //convert array index to tree index
    d[k] = a;
    while(k > 0){
      k = (k-1)/2;
      d[k] = min(d[k*2+1], d[k*2+2]);
    }
  }

  //[a, b]
  int findMin(int a, int b){
    return query(a, b+1, 0, 0, n);
  }

  //[a, b)
  int query(int a, int b, int k, int l, int r){
    //if(r <= a || b <= l) return numeric_limits<float>::infinity();  //case 1
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return d[k]; //case 2
    //case 3
    int vl = query(a, b, k*2+1, l, (l+r)/2);
    int vr = query(a, b, k*2+2, (l+r)/2, r);
    return min(vl, vr);
  }
};

int main(){
  int n, q;
  int com, x, y;
  cin >> n >> q;

  RMQ rmq(n);

  for(int i=0 ; i<q ; ++i){
    cin >> com >> x >> y;
    if(com == 0) rmq.update(x, y);
    else if(com == 1) cout << rmq.findMin(x, y) << endl;
  }
}



Measured memory_bytes: 3876
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }


int main() {
	ll N,M;
	ll NC[50], ND[50];
	ll MC[50], MD[50];
	ll ans;
	ll sum,sum1;
	sum = 0;
	sum1 = 900000001;
	ans = 0;
	cin >> N >> M;
	REP(i, N) {
		cin >> NC[i] >> ND[i];
	}
	REP(i, M) {
		cin >> MC[i] >> MD[i];
	}
	REP(j, N) {
		REP(k, M) {
			sum = abs(NC[j] - MC[k]) + abs(ND[j] - MD[k]);
			if (sum < sum1) {
				sum1 = sum;
				ans = k+1;
			}
		}
		cout << ans << endl;
		sum1 = 900000001;
	}

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> cats;
  ll cum = 0;

  rep(i, n) {
    int a;
    cin >> a;
    cats.push_back(a);
    cum ^= a;
  }

  rep(i, n) {
    int t = cum ^ cats[i];
    cout << t << " ";
  }

  return 0;
}


Measured memory_bytes: 4324
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

int main() {
  int n;
  cin>>n;
  int ans = 0;

  int b1,b2;
  cin >> b1;
  ans += b1;
  for (int i=1; i<n-1; i++) {
    cin >> b2;
    ans += min(b1,b2);
    b1 = b2;
  }
  ans += (n==2? b1 : b2);

  cout << ans << endl;
}

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

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

int main() {
  int a,b;
  cin >> a >> b;
  cout << fixed;
  cout << a / b << " " << a % b << " " << setprecision(8) <<(double)a/b << endl;
  return 0;
}



Measured memory_bytes: 3260
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m, r;
string s;

int main() {
    cin >> n >> m >> r;
    V<V<Pii>> edges(n);
    REP(i, m) {
        int s,t,d; cin >> s >> t >> d;
        edges[s].push_back({d, t});
    }

    Vi d(n, 1e9);
    priority_queue<Pii, V<Pii>, greater<Pii>> q;
    q.push({0, r});
    d[r] = 0;
    while (!q.empty()) {
        int cost = q.top().first, node = q.top().second;
        q.pop();
        if (cost > d[node]) continue;
        FOR(i, edges[node]) {
            int c = cost + i->first, v = i->second;
            if (d[v] > c) {
                d[v] = c;
                q.push({c, v});
            }
        }
    }
    FOR(i, d) {
        if (*i == 1e9) {
            std::cout << "INF" << '\n';
        } else {
            std::cout << *i << '\n';
        }
    }

    return 0;
}



Measured memory_bytes: 12976