akhauriyash/Code-Regression huggingface dataset:
//Author : Vipul Sharma
 
// LIBRARIES

#include<iostream>
#include<set>
#include<algorithm>
#include<map>
#include <bits/stdc++.h>
 
// MACROS
#define ll long long int
#define ld long double
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rev(i,b,a) for(ll i=b-1;i>=a;i--)
#define eqrep(i,b) for(ll i=1;i<=b;i++)
#define itrep(at) for (auto it = at.begin(); it != at.end(); it++)
#define ld long double
#define pb push_back
#define eb emplace_back
#define w(t) while (t--)
#define booster                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define deb1(x) cout << #x << " : " << x << endl;
#define deb2(x, y) cout << #x << " : " << x << "\t" << #y << " : " << y << endl;
#define deb3(x, y, z) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << endl;
#define deb4(x, y, z, w) cout << #x << " : " << x << "\t" << #y << " : " << y << "\t" << #z << " : " << z << "\t" << #w << " : " << w << endl;
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
using namespace std;
long long cost = 1e18;
 
 
 
int main()
{
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	booster;
	ll n,k;
	cin>>n>>k;
	ll a[n];
	rep(i,0,n) cin>>a[i];
	ll sum=0;
	sort(a,a+n);
	rep(i,0,k) sum+=a[i];
    cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3584
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

import re
# import numpy as np
# from scipy.misc import perm
# from scipy.misc import comb

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 # 10^9 + 7

########

N = i_inpl()
A = l_inpl()

ans = [0] * N
flag = True
for i in range(N)[::-1]:
    num = i+1
    cnt = N//num
    if cnt == 1:
        ans[i] = A[i]
    else:
        tmp = 0
        for j in range(1, cnt+1):
            tmp += ans[j*num-1]
        tmp %= 2
        if tmp == A[i]:
            ans[i] = 0
        elif tmp != A[i]:
            ans[i] = 1
        else:
            flag = False
            break
if flag:
    print(sum(ans))
    l = []
    for ind, i in enumerate(ans):
        if i != 0:
            l.append(str(ind+1))
    if sum(ans) != 0:
        print(" ".join(l))
else:
    print("-1")


Measured memory_bytes: 71524
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    ll a[5];
    cin >> n;
    REP(i,0,5) cin >> a[i];
    ll mn = *min_element(a,a+5);
    cout << (n+mn-1)/mn+4 << endl;
    return 0;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}

int main() {
  if( 0 ){
    srand((unsigned int)time(NULL));
    cout << 100000 << endl;
    rep(i,100000) {
      cout << rand() << " ";
    } puts(""); return 0;
  }
  int n;
  cin >> n;
  map<int,int> cnt[2];
  int len = n / 2;;
  rep(i,n) {
    int v;
    cin >> v;
    ++cnt[i&1][v];
  }
  int mini = INT_MAX;;
  int ca = 0;
  typedef pair<int,int> ii;
  vector<ii> va,vb;
  for(auto a : cnt[0]) {
    va.push_back(ii(a.second,a.first));
  }
  for(auto b : cnt[1]) {
    vb.push_back(ii(b.second,b.first));
  }
  sort(ALL(vb),greater<ii>());
  sort(ALL(va),greater<ii>());

  
  rep(i,(int)va.size()) {
    if( ca >= 100 ) break;
    ++ca;
    ii a = ii(va[i].second,va[i].first);
    int cb = 0;
    rep(j,(int)vb.size()) {
      if( cb >= 100 ) break;
      ++cb;
      int cost = 0;
      ii b = ii(vb[j].second,vb[j].first);
      if( a.first == b.first ) {
	cost += min( (len-a.second), (len-b.second) );
	cost += len;
      } else {
	cost += ( len - a.second );
	cost += ( len - b.second );
      }
      mini = min(mini,cost);
    }
  }
  cout << mini << endl;
  compute();
  return 0;
}


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

class tsort {
public:
  int V;
  vector<vector<int>> G;
  vector<int> deg, res;
  tsort(int node_size) : V(node_size), G(V), deg(V, 0) {}
  void add(int from, int to) {
    G.at(from).push_back(to);
    deg.at(to)++;
  }
  bool solve() {
    queue<int> que;
    for(int i = 0; i < V; i++) {
      if(deg.at(i) == 0) {
        que.push(i);
      }
    }
    while(!que.empty()) {
      int p = que.front();
      que.pop();
      res.push_back(p);
      for(int v : G.at(p)) {
        if(--deg.at(v) == 0) {
          que.push(v);
        }
      }
    }
    return (*max_element(deg.begin(),deg.end()) == 0);
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<pair<int, int>, int> MA;
  for (int i = 1, cnt = 0; i <= N - 1; i++) {
    for (int j = i + 1; j <= N; j++) {
      MA[{i, j}] = cnt++;
    }
  }
  int Q = N;
  N = N * (N - 1) / 2;
  tsort TS(N);
  for (int q = 1; q <= Q; q++) {
    vector<int> tmp(Q - 1);
    for (int i = 0; i < Q - 1; i++) cin >> tmp.at(i);
    for (int i = 0; i + 1 < Q - 1; i++) {
      int x1 = q, y1 = tmp.at(i);
      if (x1 > y1) swap(x1, y1);
      int X = MA[{x1, y1}];
      int x2 = q, y2 = tmp.at(i + 1);
      if (x2 > y2) swap(x2, y2);
      int Y = MA[{x2, y2}];
      TS.add(X, Y);
    }
  }
  bool b = TS.solve();
  if (!b) return cout << -1 << "\n", 0;
  vector<int> rank = TS.res;
  reverse(rank.begin(), rank.end());
  vector<int> DP(N);
  for (int i = 0; i < N; i++) {
    for (auto g :TS.G.at(rank.at(i))) {
      DP.at(rank.at(i)) = max(DP.at(rank.at(i)), DP.at(g) + 1);
    }
  }
  cout << *max_element(DP.begin(), DP.end()) + 1 << "\n";
}

Measured memory_bytes: 69672
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
#define mod 1000000007
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision
#define NO cout<<"NO\n"
#define YES cout<<"YES\n"
#define No cout<<"No\n"
#define Yes cout<<"Yes\n"
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
template<typename T> T abs(T a,T b){
    return max(a,b)-min(a,b);
}
template<typename T> T lcm(T a,T b){//最小公倍数
    return (a*b)/gcd(a,b);
}
int gcd(int a,int b){//最大公約数
    int c=a%b;
    while(true){
	if(c==0) break;
	a=b;
	b=c;
	c=a%b;
    }
    return b;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    if(n%2!=0) cout<<n/2+1<<"\n";
    else cout<<n/2<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,w;
long int weight[101],value[101];
void read()
{
cin>>n>>w;
for(int i=1;i<=n;i++)
{
cin>>weight[i];
cin>>value[i];
}
}
long int dp[101][100001];
int solve()
{
    int i,j;
for(i=0;i<=n;i++)
{
    dp[i][0]=0;
}for(i=0;i<=w;i++)
{
    dp[0][i]=0;
}

for(i=1;i<=n;i++)
{
    for(j=1;j<=w;j++)
    {
        if(weight[i]>j)
        {
            dp[i][j]=dp[i-1][j];
        }
        else
        {
            dp[i][j]=max(dp[i-1][j],value[i]+dp[i-1][j-weight[i]]);
        }
    }
}
cout<<dp[n][w];
return 0;
}
int main() {
	read();
	solve();
	
	return 0;
}


Measured memory_bytes: 79232
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"SCR SCC"# => "2",
r#"RCR SCC"# => "1",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: chars,
        t: chars,
    }

    let mut ans = 0;

    for i in 0..s.len() {
        if s[i] == t[i] {
            ans += 1;
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline

def MST(n, E):
    def par(m):
        if UF[m] == m:
            return m
        ret = par(UF[m])
        UF[m] = ret
        return ret
    
    UF = [i for i in range(n)]
    E = sorted(E, key=lambda x: x[2])
    ans = 0
    for i, j, d in E:
        if par(i) != par(j):
            ans += d
            UF[par(i)] = par(j)
    return ans

N = int(input())

X = []
append=X.append
for i in range(N):
    x, y = map(int, input().split())
    append((i, x, y))

F = []
Y = sorted(X, key = lambda x: x[1])
for i in range(len(Y)-1):
    F.append((Y[i][0], Y[i+1][0], abs(Y[i+1][1]-Y[i][1])))

Y = sorted(X, key = lambda x: x[2])
for i in range(len(Y)-1):
    F.append((Y[i][0], Y[i+1][0], abs(Y[i+1][2]-Y[i][2])))

print(MST(N, F))


Measured memory_bytes: 147396
#include <bits/stdc++.h>
#ifdef LOC
#include "debuglib.h"
#else
#define deb(...)
#define DBP(...)
#endif
using namespace std;
using   ll         = long long;
using   Vi         = vector<int>;
using   Pii        = pair<int, int>;
#define pb           push_back
#define mp           make_pair
#define x            first
#define y            second
#define rep(i, b, e) for (int i = (b); i < (e); i++)
#define each(a, x)   for (auto& a : (x))
#define all(x)       (x).begin(), (x).end()
#define sz(x)        int((x).size())

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(18);

	int a, b, c; cin >> a >> b >> c;
	int n = a+b+c;

	cout << (n >= 22 ? "bust\n" : "win\n");

	return 0;
}


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

void Draw(int h,int w)
{
	char startop,op;
	
	for(int i=0;i<h;i++){
		if (i%2==0)
			startop='#';
		else
			startop='.';
		op=startop;
		for(int j=0;j<w;j++){
			cout<<op;
			if (op=='#')
				op='.';
			else
				op='#';
		}		
		cout<<endl;
	}	
}

int main()
{
	int h ,w;
	while(true){
		cin>>h>>w;
		if(h==0&&w==0)
			break;
		Draw(h,w);
		cout<<endl;	
	}	
	return 0;
}


Measured memory_bytes: 3104
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin, (v).end);


typedef unsigned long long int ull;
typedef long long lint;

using namespace std;














int main(){
    string S;
    


    //入力
    cin >> S;

    if(S == "Sunny"){
        cout << "Cloudy" << endl;
    } else if(S == "Cloudy"){
        cout << "Rainy" << endl;
    } else if(S == "Rainy"){
        cout << "Sunny" << endl;
    }else{
        return -1;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
int n,m;
ll a[100003];
pl q[100003];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;

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

    for(int i=0;i<m;i++)
    {
        int b,c;
        cin >> b >> c;
        q[i] = {c, b};
    }
    sort(q, q+m);
    int pos = 0;
    for(int i=m-1;i>=0;i--)
    {
        while(q[i].second)
        {
            if(a[pos] >= q[i].first) pos = n;
            if(pos == n) break;
            a[pos] = q[i].first;
            q[i].second--;
            pos++;
        }
        if(pos == n) break;
    }
    ll ans = 0;
    for(int i=0;i<n;i++)
        ans += a[i];
    cout << ans;
}

Measured memory_bytes: 2560
#!/usr/bin/env python3
import sys
from bisect import bisect_left
INF = float("inf")


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


def solve(N: int, D: int, A: int, X: "List[int]", H: "List[int]"):

    bit = Bit(N+1)

    XH = [(x, h) for x, h in zip(X, H)]
    XH.sort()
    for i in range(N):
        if i == 0:
            bit.add(i+1, XH[i][1])
        else:
            bit.add(i+1, XH[i][1]-XH[i-1][1])
    # print(XH)

    tot = 0
    curr = 0
    while True:
        # Hが正であるうち、xが最も小さいxhを見つける すべてでO(N)
        # print([bit.sum(i+1) for i in range(N)])

        flag = False
        for i in range(curr, N):
            if bit.sum(i+1) > 0:
                flag = True
                break
        if flag:
            curr = i+1
        else:
            break
        # できるだけ多くを巻き込むようにバクダンを使う。 x ~ x+2D
        x, h = XH[i]
        h = bit.sum(i+1)
        kaisu = -(-h//A)
        damage = A*kaisu
        tot += kaisu

        # 巻き込むモンスターは i ~ jまで
        j = bisect_left(XH, (x+2*D+1, 0))
        bit.add(i+1, -damage)
        bit.add(j+1, +damage)
        # for k in range(i, j):
        #     x, h = XH[k]
        #     XH[k] = (x, h-damage)
    print(tot)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    X = [int()] * (N)  # type: "List[int]"
    H = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        X[i] = int(next(tokens))
        H[i] = int(next(tokens))
    solve(N, D, A, X, H)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65704
#include <bits/stdc++.h>
using namespace std;
int vs[100001];


int main() {
    int n,q,recebe,c,b;
    long long int soma=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> recebe;
        vs[recebe-1]+=1; //quant de 1 na posi 0, 2 -> [1]
        soma+=recebe;
    }
    cin >> q;
    for(int j = 0;j<q;j++){
        cin >> b >> c;
        soma+=vs[b-1]*(c-b);
        vs[c-1]+=vs[b-1];
        vs[b-1]=0;
        cout << soma << endl;
        //for(int i = 0; i < n; i++) cout << vs[i] << " ";
        //cout << endl;
        
        
        
    }
    
}

Measured memory_bytes: 3896
A, B, C, X, Y = map(int, input().split())
C *= 2
ans = 0

if A+B <= C:
    ans = A*X + B*Y
    print(ans)
else:
    ans = C*min(X,Y)
    if X>=Y:
        if A >=C:
            ans += (X-Y)*C
        else:
            ans += (X-Y)*A
    else:
        if B>=C:
            ans += (Y-X)*C
        else:
            ans += (Y-X)*B
    print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		int MOD = 1_000_000_007;
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long ans = 0;
		long[] suml = new long[N+2];
		long[] sumr = new long[N+2];
		for(int i = 1; i <= N; i++) {
			suml[i] = suml[i-1];
			suml[i] += i;
		}
		for(int i = N; i >= 0; i--) {
			sumr[i] = sumr[i+1];
			sumr[i] += i;
		}
		for(int i = K; i <= N+1; i++) {
			ans += sumr[N+1-i]-suml[i-1]+1;
			ans %= MOD;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 38856
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <cassert>
#define SIZE 25

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
	int n;
	scanf("%d",&n);
	int a,b;
	scanf("%d %d",&a,&b);
	int s=0,t=0,u=0;
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		if(x<=a) s++;
		else if(x<=b) t++;
		else u++;
	}
	printf("%d\n",min(min(s,t),u));
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  int count = 0;
  for(int i = 0; i < S.size(); i++) {
    if(S.at(i) == '1') {
      count++;
    }
  }
  cout << count;
}


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

int main(){
	int a, b, c;
	cin >> c >> a >> b;
	string s;
	if(a >=b) {
		s = "delicious";
	}else if(b <= a+c){
		s = "safe";
	}else{
		s = "dangerous";
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    string s;
    int sum=0;
    int m=3456;
    cin>>s;
    for(int i=0;i<s.size()-2;i++)
    {
        int sum=0;
        for(int j=i;j<i+3;j++)
        {
            sum=sum*10+(s[j]-'0');
        }
        m=min(m,abs(sum-753));
    }
    cout<<m<<endl;
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i, j, n, q, b, e, t;
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			int[] a = new int[n];
			for(i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			q = sc.nextInt();
			for(i = 0; i < q; i++) {
				b = sc.nextInt();
				e = sc.nextInt();
				t = sc.nextInt();
				for(j = 0; j < e - b; j++) {
					a[b + j] = a[b + j] ^ a[t + j];
					a[t + j] = a[b + j] ^ a[t + j];
					a[b + j] = a[b + j] ^ a[t + j];
				}
			}
			for(i = 0; i < n - 1; i++){
				System.out.print(a[i] + " ");
			}
			System.out.println(a[n - 1]);
		}
	}
}



Measured memory_bytes: 36384
#include <algorithm>
#include <array>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
constexpr int INF = 100100100;

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

using namespace std;

void solve(int pre, int post) {
  bool yymm = 1 <= post && post <= 12;
  bool mmyy = 1 <= pre && pre <= 12;
  if (yymm) {
    cout << (mmyy ? "AMBIGUOUS" : "YYMM") << endl;
  } else {
    cout << (mmyy ? "MMYY" : "NA") << endl;
  }
}

int main() {
  // cout << fixed << setprecision(10);

  int S;
  cin >> S;
  int pre = S / 100, post = S % 100;
  solve(pre, post);
  return 0;
}


Measured memory_bytes: 256
class GenomeDB
  class GenomeData
    def initialize
      @length = 0
      @num = 0
      @data_array = []
    end

    attr_accessor :num

    def size
      @length
    end

    def << data
      @length += data.size * @num
      @data_array << data
      self
    end

    def [] i
      return '0' if i >= @length
      index = i
      @num.times do
        @data_array.each do |data|
          if index >= data.size
            index -= data.size
            next
          end
          return data[index]
        end
      end
    end
  end

  class << self
    def parse seq
      result = GenomeData.new
      result.num = 1
      data_array = genome_parse(seq, 0).first
      if data_array.instance_of?(Array)
        data_array.each do |data|
          result << data
        end
      else
        result << data_array
      end
      result
    end

    private
    def genome_parse seq, start
      i = start
      result = []

      word = ''
      while i < seq.size
        case seq[i]
        when /[A-Z]/
          word << seq[i]
          i += 1
        when /[0-9]/
          unless word.size == 0
            result << word
            word = ''
          end
          genome_data,next_index = get_compress_data(seq, i)
          result << genome_data
          i = next_index
        when ")"
          unless word.size == 0
            result << word
            word = ''
          end
          i += 1
          break
        end
      end
      result << word unless word.size == 0
      [result, i]
    end

    def get_compress_data seq, start
      num = get_num_token(seq, start)
      data_array,next_index = get_data(seq, start + num.size)
      genome_data = GenomeData.new
      genome_data.num = num.to_i
      if data_array.instance_of?(Array)
        data_array.each do |data|
          genome_data << data
        end
      else
        genome_data << data_array
      end
      [genome_data, next_index]
    end

    def get_data seq, start
      i = start
      data_array = []
      case seq[i]
      when "("
        i += 1
        data_array,next_index = genome_parse(seq, i)
        i = next_index
      when /[A-Z]/
        data_array << seq[i]
        i += 1
      end
      [data_array, i]
    end

    def get_num_token seq, start
      num = ''
      i = start
      while i < seq.size
        if seq[i] =~ /[A-Z(]/
          break
        end
        num << seq[i]
        i += 1
      end
      num
    end
  end
end

def main
  loop do
    seq,index = gets.chomp.split(' ')
    break if seq.eql?('0') and index.eql?('0')
    puts GenomeDB.parse(seq)[index.to_i]
  end
end

if $0 == __FILE__
  main
end

Measured memory_bytes: 6200
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,x,m,n;
	cin>>a>>b>>x;
	m=a/x;
	if(a%x!=0)
		m++;
	n=b/x;
	cout<<n-m+1<<endl;
	return 0;
}

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

if "##" in s[a-1:c] or "##" in s[b-1:d]:
  print("No")
else:
  if c < d:
    print("Yes")
  else: # C > D
    if "..." in s[b-2:d+1]:
      print("Yes")
    else:
      print("No")

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<int, int> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };


int main() {

	int x;
	cin >> x;

	if (x < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}

	
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize
    }
    let d = 1000000007;
    let mut ans = 0;
    for i in k..=n + 1 {
        ans = (ans + i * (n + 1 - i) + 1) % d;
    }
    println!("{}", ans);
}


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    int zero = a[i] / 2;
    a[i] -= 2 * zero;
    ans += zero;
    int one = min(a[i], a[i + 1]);
    a[i] -= one;
    a[i + 1] -= one;
    ans += one;
  }
  ans += (a[n - 1] - (a[n - 1] & 1)) / 2;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <map>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i > (b); --i)
#define SZ(a) a.size()
#define ll long long
#define ull unsigned long long
using namespace std;



void str_sort(vector<string> &S, int N) {

	FOR(i, 0, N-1) {
		FOR(j, i, N-1) {
			if (S[j] > S[j + 1]) {
				swap(S[j], S[j + 1]);
			}
		}
	}

}


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

	int N;
	int L;
	vector<string> S;
	cin >> N >> L;
	FOR(i, 0, N) {
		string s;
		cin >> s;
		S.push_back(s);
	}

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

	FOR(i, 0, N)
		cout << S[i];

	


	system("pause");
	return 0;
}

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

int dp[1024][331];
int popcount(int x){
	int r = 0;
	while(x) r += x&1, x>>=1;
	return r;
}
int main() {
	int i,j,k;
	int n,s,r;
	dp[0][0]=1;
	for(i=1;i<1024;i++)for(j=0;j<=330;j++){
		int t = popcount(i), x;
		dp[i][j] = 0;
		for(k=0;k<10;k++)if((i>>k)&1) {
			x = j-t*k;
			if(x>=0)dp[i][j] += dp[i&~(1<<k)][x];
		}
	}
	while(~scanf("%d %d",&n,&s)){
		r=0;
		if(0<=s&&s<=330&&0<=n&&n<=10)for(i=0;i<1024;i++)if(popcount(i)==n)r+=dp[i][s];
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 1924
x = int(input())
if x <= 599:
  s = 8
elif x <= 799:
  s = 7
elif x <= 999:
  s = 6
elif x <= 1199:
  s = 5
elif x <= 1399:
  s = 4
elif x <= 1599:
  s = 3
elif x <= 1799:
  s = 2
elif x <= 1999:
  s = 1
print(s)

Measured memory_bytes: 61604
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr);    
    long long n, k;
    cin >> n >> k;
    long long ans = (n / k) * (n / k) * (n / k);
    if (!(k & 1)) {
        if (n % k >= k / 2) {
            ans += (n / k + 1) * (n / k + 1) * (n / k + 1);
        } else {
            ans *= 2;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

void koch(int n, double p1[2], double p2[2]){
    double s[2], t[2], u[2];
    rep(i,2)s[i] = (2*p1[i] + p2[i]) / 3;
    rep(i,2)t[i] = (p1[i] + 2*p2[i]) / 3;
    u[0] = (t[0] + s[0] - sqrt(3)*(t[1] - s[1])) / 2;
    u[1] = (sqrt(3)*(t[0] - s[0]) + t[1] + s[1]) / 2;
    
    if(n > 1){
        koch(n-1, p1, s);
        koch(n-1, s, u);
        koch(n-1, u, t);
        koch(n-1, t, p2);
    }else {
        printf("%.10f %.10f\n", p1[0], p1[1]);
        printf("%.10f %.10f\n", s[0], s[1]);
        printf("%.10f %.10f\n", u[0], u[1]);
        printf("%.10f %.10f\n", t[0], t[1]);
    }
}

int main(){
    int n;
    cin >> n;
    double start[2] = {0, 0};
    double end[2] = {100, 0};

    if(n == 0){
        printf("%.10f %.10f\n", start[0], start[1]);    
        printf("%.10f %.10f\n", end[0], end[1]);
        return 0;
    }
    koch(n, start, end);
    printf("%.10f %.10f\n", end[0], end[1]);
    return 0;
}


Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <queue>

using std::queue;
using std::vector;

class Edge {
  public:
    int to;
    int len;
    Edge() { to = -1; len = -1; }
    Edge(int _to, int _len) { to = _to; len = _len; }
};

int main()
{
  int n;
  std::cin >> n;
  vector<vector<Edge>> node(n);
  for (int i = 0; i < n; i++) {
    int x, y, len;
    std::cin >> x >> y >> len;
    node.at(x-1).push_back(Edge(y-1, len));
    node.at(y-1).push_back(Edge(x-1, len));
  }
  vector<int> color(n, -1);
  queue<int> q;
  color.at(0) = 0;
  q.push(0);
  while (!q.empty()) {
    int from = q.front();
    q.pop();
    for (const auto& v : node.at(from)) {
      if (color.at(v.to) != -1) {
        continue;
      }
      if (v.len % 2 == 0) {
        color.at(v.to) = color.at(from);
      } else {
        color.at(v.to) = color.at(from) ^ 1;
      }
      q.push(v.to);
    }
  }
  for (int c : color) {
    std::cout << c << '\n';
  }
  return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int A, B; cin >> A >> B;
    int cnt = 0;
    for (int i = A; i <= B; ++i) {
        string s1, s2;
        s1 = to_string(i);
        s2 = s1;
        reverse(all(s2));
        if (s1 == s2) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const int mod = 1e9+7;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> m(n);
  for(int i=0; i<n; i++){
    cin>>m.at(i);
    if(i>=k){
      if(m.at(i)>m.at(i-k)) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
  }
  
//    cout << fixed << setprecision(10);
}


Measured memory_bytes: 4048
N = int(input())

keta = len(str(N))
if keta%2 == 0:
    N = 10**(keta-1)-1
total = N
keta = len(str(N))
if keta == 3:
    total -= 90
elif keta == 5:
    total -= 100000-90910

print(total)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    string a,b;
    cin>>a>>b;
    int cnt=0;
    REP(i,a.size()){
        cnt+=a[i]==b[i];
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
import statistics

def main():
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        A[i] -= i + 1
    B = statistics.median_low(A)
    ans = 0
    for a in A:
        ans += abs(a - B)

    print(ans)



if __name__ == "__main__":
    main()

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

int main(){
  int n,u,k,v;
  int G[100][100]={};

  cin >> n;
  for (int i=0;i<n;i++){
    cin >>u>>k;
    for (int j=0;j<k;j++){
      cin >> v;
      G[u-1][v-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for (int j=0;j<n-1;j++){
      cout << G[i][j]<<" ";
    }
    cout << G[i][n-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
import string
import sys
S = input()
T = input()
sLst = [0] * 26
tLst = [0] * 26

for i in range(26):
    sLst[i] = S.count(string.ascii_lowercase[i])
    tLst[i] = T.count(string.ascii_lowercase[i])
sLst.sort(reverse=True)
tLst.sort(reverse=True)

for i in range(26):
    if sLst[i] != tLst[i]:
        print('No')
        sys.exit()

print('Yes')


Measured memory_bytes: 4272
#include<cstdio>
#include<algorithm>
using namespace std;
#define mod 1000000007
using namespace std;
typedef long long LL;
LL je[200010];
LL x,y;
void Build()
{
	je[0]=je[1]=1;
	for(int i=1;i<=200005;i++)
		je[i]=(je[i-1]*i)%mod;
	return;
}
LL Gcd(LL a, LL b, LL &x, LL &y)
{
    if(b==0)
	{
        x=1;
        y=0;
        return a;
    }
    LL gcd=Gcd(b,a%b,x,y);
    LL tmp=x;
    x=y;
    y=tmp-(a/b)*y;
    return gcd;
}
LL C(LL m,LL n)
{
    Gcd(je[m]*je[n-m]%mod,mod,x,y);
    return je[n]*(x+mod)%mod;
}
int main()
{
    LL H,W,A,B;
	Build();
    LL ans=0;
	scanf("%lld%lld%lld%lld",&H,&W,&A,&B);
    for(LL i=B+1;i<=W;i++)
    {
        LL tmp=(C(H-A-1,i-1+H-A-1)*C(W-i,W-i+A-1))%mod;
        ans=(ans+tmp)%mod;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>

using namespace std;

int binarySearch(int S[],int T[],int n,int q){
  int count =0;
  for(int i=0;i<q;i++){
    int left =0,right=n-1,center=(right+left)/2;
    int safeCheck=0;
    while(left<right){
      //cout<<center<<endl;
      if(T[i]==S[center]){
        count++;
        break;
      }else if(T[i]>S[center]){
        left=center+1;
        center=(right+left)/2;
        safeCheck++;
      }else{
        right=center;
        center=(right+left)/2;
        safeCheck++;
      }
      if(left>=right&&T[i]==S[n-1]&&right==n-1)count++;
      // if(safeCheck>n){
      //   cout<<"out!!"<<endl;
      //   break;
      // }
    }
  }
  return count;
}

int main(){
  int n,q;
  cin>>n;
  int S[n];
  for(int i=0;i<n;i++){
    cin>>S[i];
  }
  cin>>q;
  int T[q];
  for(int i=0;i<q;i++){
    cin>>T[i];
  }
  int count=binarySearch(S,T,n,q);
  cout<<count<<endl;
  return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (a == c - 1) << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(b-b%k > a || b-b%k == a){
            System.out.println("OK");
        }
        else{
            System.out.println("NG");
        }
        
    }
}

Measured memory_bytes: 35820
program main
  implicit none
  integer :: k, a(32) = (/ 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 /)
  read *, k
  print '(i0)', a(k)
end program

Measured memory_bytes: 768
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
    //cout << fixed << setprecision(8);

    int X;
    cin >> X;
    int ans = 1;
    for(int i=2; i<=X; ++i){
        int n = i;

        while(X>=n*i){
            n *= i;
            ans = max(ans, n);
        }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define gc getchar
#define ll long long
#define inf 1000009
typedef long long LL;
 LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
 LL Lcm(LL a, LL b) { return (a * (b / gcd(a, b))); }
LL isPrime(LL x)  { ll s = sqrt(x); for (ll i = 2; i <= s; i++) if (x % i == 0) return 0; return 1;} 
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ll n;cin>>n;
	ll a[n+4];
	int hash[300006]={0};
	for(int i=2;i<=n;i++){cin>>a[i];hash[a[i]]++;}
	for(int i=1;i<=n;i++)
	{
		cout<<hash[i]<<endl;
	}
	
	
}

Measured memory_bytes: 6316
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <algorithm>
using namespace std;

int dx[]={0,0,-1,1};
int dy[]={-1,1,0,0};

int dp[1005][1<<12];

int main()
{
	//ifstream cin("C.txt");
	int Hmi,Hma,R,C;
	while(cin >> Hmi >> Hma, (Hmi||Hma))
	{
		int dmg[100]={0};
		int heal[100]={0};

		string f[200];
		cin >> R >> C;

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

		int L;
		cin >> L;
		for(int i=0; i<L; i++)
		{
			string c;
			int d;
			cin >> c >> d;
			dmg[c[0]-'A']=d;
		}

		int dir[1005];

		int M,X=0;
		cin >> M;
		for(int i=0; i<M; i++)
		{
			int t,n;
			string d;
			cin >> d >> n;
			if(d[0]=='U')
			{
				t=0;
			}
			if(d[0]=='D')
			{
				t=1;
			}
			if(d[0]=='L')
			{
				t=2;
			}
			if(d[0]=='R')
			{
				t=3;
			}

			for(int j=0; j<n; j++)
				dir[X++]=t;
		}

		int H;
		cin >> H;
		for(int i=0; i<H; i++)
			cin >> heal[i];

		memset(dp,0,sizeof(dp));
		
		dp[0][0]=Hmi;

		int x=0, y=0;
		for(int i=0; i<X; i++)
		{
			x+=dx[dir[i]], y+=dy[dir[i]];
			for(int j=0; j<(1<<H); j++)
			{
				for(int k=0; k<H; k++)
				{
					if(j&(1<<k)) continue;
					if(dp[i][j]==0) continue;
					
					dp[i][j|(1<<k)] = max(dp[i][j|(1<<k)], min(Hma, dp[i][j]+heal[k]));
				}
				
				dp[i+1][j]=max(dp[i+1][j], dp[i][j]-dmg[f[y][x]-'A']);
			}
		}
		
		bool ok=false;
		for(int i=0; i<(1<<H); i++)
		{
			if(dp[X][i]>0) ok=true;
		}

		cout << (ok?"YES":"NO") << endl;

	}
}

Measured memory_bytes: 16000
n,m=map(int,input().split())
cnt=[0]*(n+1)
l=[0]*(n+1)
ac=0
wa=0
for i in range(m):
  p,s=input().split()
  p=int(p)
  if l[p]==1:
    continue
  if l[p]==0 and s=='WA':
    cnt[p]+=1
  if l[p]==0 and s=='AC':
    ac+=1
    l[p]=1
for i in range(1,n+1):
  if l[i]==1:
    wa+=cnt[i]
print(ac,wa)


Measured memory_bytes: 50664
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

long long n,m,a[200005],b[200005],top,flag;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	scanf("%d",&m);
	for(int i=1;i<=m;i++) scanf("%d",&b[i]);
	sort(b+1,b+m+1);
	top=1;
	flag=0;
	for(int i=1;i<=m;i++)
	{
		int c=top;
		for(int j=c;j<=n;j++)
		{
			if(a[j]<b[i]) top++;
			if(a[j]==b[i]) 
			{
				top++;
				break;
			}
			if(a[j]>b[i]) flag=1;
		}
		if(flag) break;
	}
	if(flag) cout<<"NO"<<endl;else cout<<"YES"<<endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int par[200001],ran[200001],box[200001];
int main(void){
	int n,m,x,y,i;
	cin >> n >> m;
	for(i = 1; i <= n; i++){
		par[i] = i;
		ran[i] = 0;
		box[i] = 0;
	}
	for(i = 0; i < m; i++){
		cin >> x >> y;
		if(x < y)	swap(x,y);
		while(x != par[x])	x = par[x];
		while(y != par[y]) 	y = par[y];
		if(x != y){
			if(ran[x] >= ran[y]){
				par[y] = x;
				ran[x]++;
			}
			else	par[x] = y;
		}
	}
	for(i = 1; i <= n; i++){
		x = i;
		while(x != par[x]) x = par[x];
		box[x]++;
	}
	int MAX = INT_MIN;
	for(i = 1; i <= n; i++)	MAX = max(MAX,box[i]);
	cout << MAX <<endl;
	return 0;
}

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

#define Yes(condition) cout << (condition ? "Yes" : "No") << endl

using namespace std;

int main() {
    vector< vector<int> > c(3, vector<int>(3));
    for (int i = 0; i < 3; ++i) for(int j = 0; j < 3; ++j) cin >> c.at(i).at(j);
    bool flag = true;
    for (int i = 1; i < 3; ++i) for(int j = 1; j < 3; ++j) flag &= (c.at(i).at(j) == c.at(i).at(0) + c.at(0).at(j) - c.at(0).at(0));
    Yes(flag);
    return 0;
}


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

int main() {
	int A1, A2, A3;
	cin >> A1 >> A2 >> A3;

	if (22 <= A1 + A2 + A3) {
		cout << "bust" << endl;
	}
	else
	{
		cout << "win" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin>>N;
  vector<pair<ll,ll>> BA(N);
  for(int i=0;i<N;i++){
    ll a,b;
    cin>>a>>b;
    BA[i]=make_pair(b,a);
  }
  sort(ALL(BA));
  ll sum=0ll;
  bool flag=true;
  for(int i=0;i<N;i++){
    sum+=BA[i].second;
    if(BA[i].first<sum){
      flag=false;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int[] a = new int[4];

		for(int i = 0; i < a.length; i++) {
			a[i] = Integer.parseInt(lines[i]);
		}

		boolean TakahashiWinFlag = true;
		for(;;) {
			a[2] = a[2] - a[1];
			if(a[2] <= 0) {
				TakahashiWinFlag = true;
				break;
			}
			a[0] = a[0] - a[3];
			if(a[0] <= 0) {
				TakahashiWinFlag = false;
				break;
			}
		}

		if(TakahashiWinFlag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct frac {
  int c0, c1;
  frac(int c0 = 0, int c1 = 0) : c0(c0), c1(c1) {}
  bool operator < (const frac &d) const {
    return (ll) c0 * d.c1 < (ll) d.c0 * c1;
  }
  frac operator + (const frac &d) const {
    return frac(c0 + d.c0, c1 + d.c1);
  }
};
const int N = 200010;
frac r[N];
priority_queue<pair<frac, int>> q;
int n, par[N], f[N];
ll ans = 0;
int F(int x) {
  while (x != f[x]) x = f[x] = f[f[x]];
  return x;
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &par[i]);
  }
  for (int i = 1, x; i <= n; i++) {
    scanf("%d", &x);
    if (x == 0) {
      r[i] = frac(1, 0);
    } else {
      r[i] = frac(0, 1);
    }
    if (i > 1) q.push(make_pair(r[i], i));
    f[i] = i;
  }
  while (!q.empty()) {
    int v = q.top().second;
    frac d = q.top().first;
    q.pop();
    if (v != F(v) || d.c0 != r[v].c0 || d.c1 != r[v].c1) continue;
    int u = F(par[v]);
    f[v] = u;
    ans += (ll) r[u].c1 * r[v].c0;
    r[u] = r[u] + r[v];
    if (u != 1) q.push(make_pair(r[u], u));
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 7668
N = int(input())
A = [int(x) for x in input().split()]

A.sort()

m = A[0]

while True:
    flag = True
    new = list()
    for a in A:
        tmp = a % m
        if tmp != 0 and tmp < m:
            new.append(tmp)
            flag = False

    if flag:
        break
    else:
        m = min(new)

print(m)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long a,b;
	vector <int> ve;
	cin>>a>>b;
	int k=0;
	for(int i=a;i<a*100;i++){
	for(int j=a;j<b*100;j++){
		if((int)(i*0.08)==a && (int)(j*0.1)==b && i==j) {
			ve.push_back(i);
			k+=1;
			break;}
		}
	}
	if(!ve.empty()) cout<<ve[0];
	else cout<<-1;
}


Measured memory_bytes: 256