akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}



int main(){
    int n,m;
    map<int,int> mp;
    cin >> n;
    rep(i,n){
        int d;
        cin >> d;
        mp[d]++;
    }

    cin >> m;
    rep(i,m){
        int t;
        cin >> t;
        if(mp[t]<1){
            cout << "NO" << endl;
            return 0;
        }else{
            mp[t]--;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

const int max_n = 500 + 10;
const int max_a = 1e6;

template <class T>
bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main()
{
    int k, x;
    cin >> k >> x;

    int n = 1e6;
    int a = x - k + 1;
    while (a <= x + k - 1)
    {
        if (-n <= a && a <= n)
        {
            cout << a << " ";
        }
        ++a;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  char b;
  scanf("%c",&b);
  if(b=='A'){
    printf("T");
  }else if(b=='T'){
    printf("A");
  }else if(b=='C'){
    printf("G");
  }else{
    printf("C");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <queue>
#include <deque>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long
#define int ll
#define INF (1LL<<60)
#define mod 1000000007
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

// aとbの最大公約数
ll gcd(ll a, ll b) {
	if (a < b) gcd(b, a);
	ll r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}

signed main(){
	int N, K;
	cin >> N >> K;
	int g, m = -INF;
	for (int i = 0; i < N; i++){
		int a;
		cin >> a;
		if (i == 0){
			g = a;
			m = a;
		}
		else{
			g = gcd(g, a);
			m = max(m, a);
		}
	}

	if (K%g == 0 && K<=m) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

	return 0;
}


Measured memory_bytes: 256
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def dfs(G, v):
	seen[v] += 1
	#print('v :', v)
	
	for nv in G[v]:
		if seen[nv]: continue
		#print('v nv :', v, nv, 'Recursion')
		dfs(G, nv)

N, M = MAP()
A = [MAP() for _ in range(M)]

#print(A)

ans = 0
for i in range(M):
	G = [[] for _ in range(N)]
	for j, m in enumerate(A):
		# i!=jのとき辺を追加しない
		if i != j:
			a, b = m
			G[a-1].append(b-1)
			G[b-1].append(a-1)
		
	seen = [0] * N
	dfs(G, 1)
	#print(i, j, seen)
	
	if sum(seen) != N: ans += 1

print(ans)

Measured memory_bytes: 42460
int main(void){
  int x,count;

  while(1){
    scanf("%d",&x);
    if(!x) break;

    count=0;
    while(x!=1){
      if(x%2==0) x/=2;
      else x=x*3+1;
      count++;
    }
    printf("%d\n",count);
  }

  return 0;
}

Measured memory_bytes: 0
n, m = map(int, input().split())
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))
a.sort()
pm = s = 0
for item in a:
    if pm + item[1] >= m:
        print(s + item[0] * (m - pm))
        break
    else:
        pm += item[1]
        s += item[0] * item[1]


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

using ll = long long;
#define rep(i, a, b) for(auto i = (a); i < (b); ++i)

const int MOD = 998244353;
auto add(ll a, ll b){return (a + b) % MOD;}
auto sub(ll a, ll b){return (a - b + MOD) % MOD;}
auto mult(ll a, ll b){return a * b % MOD;}
auto exp(ll n, ll p) {
  ll acc = 1;
  for (auto pwr = n; p; pwr = mult(pwr, pwr), p >>= 1)
    if (p & 1)
      acc = mult(acc, pwr);
  return acc;
}
auto mdiv(ll a, ll b){return mult(a, exp(b, MOD - 2));}

const int MAXN = 3 * 1e5;
ll factorial[MAXN + 5];
ll nck(ll n, ll k) {
  return mdiv(factorial[n], mult(factorial[k], factorial[n - k]));
}

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

  factorial[0] = 1;
  rep(i, 1, MAXN + 5) {
    factorial[i] = mult(factorial[i - 1], i);
  }

  int n, m, k;
  cin >> n >> m >> k;
  ll total = exp(m, n);
  ll acc = 0;
  rep(i, k + 1, n) {
    ll rem = n - i;
    ll choices = nck(n - 1, i);
    ll ways = mult(m, exp(m - 1, rem - 1));
    ll delta = mult(choices, ways);
    acc = add(acc, delta);
  }
  auto res = sub(total, acc);
  cout << res << '\n';
}


Measured memory_bytes: 5948
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	int a[n+2];
	unordered_map<int,int>freq;
	for(int i=0;i<n;i++){
		cin>>a[i];
		freq[a[i]]++;
	}
	unordered_map<int,int>:: iterator it;
	long long ans = 0;
	for(it = freq.begin(); it!=freq.end(); it++){
		int v = it->first, cnt = it->second; 
		//printf("%d %d\n",v,cnt);
		if(cnt>=v) {// in a good sequence number v should be present v times
			ans+=(cnt-v);
		}
		else ans+=cnt;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4644
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

int main() {
    string s;
    cin >> s;
    ll ans = 0;
    REP(i, s.length() - ans) {
        if(s[i] == 'A') {
            for(int j = i + 1; j < s.length(); j++) {
                if(s[j] == 'Z') {
                    ans = max(ans, j - i + 1);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	vector<int> v(3);
	for(int i=0 ; i<3 ; i++){
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	for(int i=0 ; i<3 ; i++){
		if(i<2 && v[i] != 5){
			cout << "NO" << endl;
			break;
		}else if(i==2 && v[i] != 7){
			cout << "NO" << endl;
		}else if(i==2){
			cout << "YES" << endl;
		}
	}
}

Measured memory_bytes: 256
package main

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

func min(a ...int) int {
	m := a[0]
	for i, v := range a {
		if i == 0 {
			continue
		}
		if m > v {
			m = v
		}
	}
	return m
}

func max(a ...int) int {
	m := a[0]
	for i, v := range a {
		if i == 0 {
			continue
		}
		if m < v {
			m = v
		}
	}
	return m
}

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - /\/\/\/
	var n int
	fmt.Scan(&n)

	sc.Split(bufio.ScanWords)
	v := make([]int, n)
	temp1 := make(map[int]int, n)
	temp2 := make(map[int]int, n)

	var count1, count2 int
	for i := 0; i < n; i++ {
		v[i] = nextInt()
		if i%2 == 0 {
			temp1[v[i]]++
			count1++
		} else {
			temp2[v[i]]++
			count2++
		}
	}
	temp1[1000000] = 0
	temp2[1000000] = 0

	sortTemp1 := make([]int, 0)
	for _, v := range temp1 {
		sortTemp1 = append(sortTemp1, v)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(sortTemp1)))

	sortTemp2 := make([]int, 0)
	for _, v := range temp2 {
		sortTemp2 = append(sortTemp2, v)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(sortTemp2)))

	var maxNum1 int
	for i, v := range temp1 {
		if v == sortTemp1[0] {
			maxNum1 = i
		}
	}

	var maxNum2 int
	for i, v := range temp2 {
		if v == sortTemp2[0] {
			maxNum2 = i
		}
	}

	var ans int
	if maxNum1 != maxNum2 {
		fmt.Println(count1 - temp1[maxNum1] + count2 - temp2[maxNum2])
	} else {
		var maxNum1New, maxNum2New int
		for i, v := range temp1 {
			if v == sortTemp1[1] {
				maxNum1New = i
			}
		}
		for i, v := range temp2 {
			if v == sortTemp2[1] {
				maxNum2New = i
			}
		}
		ans = min(count1-temp1[maxNum1]+count2-temp2[maxNum2New], count1-temp1[maxNum1New]+count2-temp2[maxNum2])
		fmt.Println(ans)
	}
}


Measured memory_bytes: 11036
H, W, _ = map(int, input().split())
L = [list(str(input())) for _ in range(H)]
ans = [[] * W for _ in range(H)]
k = 1
cnt = 1
for h in range(H):
    if '#' not in L[h]:
        cnt += 1
    else:
        pre = -1
        for w in range(W):
            if L[h][w] == '#':
                for i in range(cnt):
                    ans[h-i].extend([k] * (w - pre))
                k += 1
                pre = w
        else:
            for i in range(cnt):
                ans[h-i].extend([k-1] * (W - 1 - pre))
            cnt = 1
cnt = 0
i = 1
while True:
    if '#' not in L[-i]:
        cnt += 1
        i += 1
    else:
        break
for i in range(cnt):
    ans[-cnt+i] = ans[-cnt-1]
for row in ans:
    print(*row)


Measured memory_bytes: 8264
#include <vector>
#include <list>
#include <map>
#include <set>
#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 <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#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(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
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 MT make_tuple
#define SZ(a) int((a).size())
#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())
#define FILL(a, x) memset(a, x, sizeof(a))

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

const LL MOD = 998244353;
int sb[200005], sw[200005];

int main() {
	int n;
	string s;
	cin >> n >> s;
	REP(i, n)sb[i + 1] = sb[i] + (s[i] == '#');
	REP(i, n)sw[i + 1] = sw[i] + (s[i] == '.');
	int ret = n + 5;
	REP(i, n+1) {
		ret = min(ret, sb[i] - sb[0] + sw[n] - sw[i]);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2180
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
using namespace std;
int main(){
    int x1,y1,x2,y2,x3,y3,x4,y4,c,d;
    cin >> x1 >> y1 >> x2 >> y2;
    int a,b;
    a = x2 - x1;
    b = y2 - y1;
    x3 = x2 - b;
    y3 = y2 + a;
    c = x3;
    d = y3;
    x4 = c - a;
    y4 = d - b;
    cout << c << " " << d << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef int Weight;

struct Edge {
    int src, dst;
    Weight weight;

    Edge(int src, int dst, Weight weight) :
        src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int ch, cv;
const int INF = 1e9;
const Weight CH = -1;
const Weight CV = 1;
const int N = 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1;
Graph g(N);
vector<string> node(N);

inline int FindIndex(const string s)
{
    return lower_bound(node.begin(), node.end(), s) - node.begin();
}

void Init()
{
    string perm = "012345678";
    int cnt = 0;

    do {
        node[cnt] = perm;
        cnt++;
    } while (next_permutation(perm.begin(), perm.end()));

    do {
        string tmp = perm;
        int src = FindIndex(perm);
        int index = perm.find("0");

        // right
        swap(tmp[index], tmp[(index + 1) % 9]);
        g[src].push_back(Edge(src, FindIndex(tmp), CH));
        swap(tmp[index], tmp[(index + 1) % 9]);

        // left
        swap(tmp[index], tmp[(index + 8) % 9]);
        g[src].push_back(Edge(src, FindIndex(tmp), CH));
        swap(tmp[index], tmp[(index + 8) % 9]);

        // down
        swap(tmp[index], tmp[(index + 3) % 9]);
        g[src].push_back(Edge(src, FindIndex(tmp), CV));
        swap(tmp[index], tmp[(index + 3) % 9]);
        // up
        swap(tmp[index], tmp[(index + 6) % 9]);
        g[src].push_back(Edge(src, FindIndex(tmp), CV));
    } while (next_permutation(perm.begin(), perm.end()));
}

// ダイクストラ法 O(|E|log|V|)
int ShortestPath(int start, int end)
{
    typedef pair<int, int> P;
    priority_queue<P, vector<P>, greater<P> > que;
    vector<int> d(N);

    fill(d.begin(), d.end(), INF);
    d[start] = 0;
    que.push(P(0, start));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;

        if (d[v] < p.first)
            continue;
        for (Edges::iterator e = g[v].begin(); e != g[v].end(); ++e) {
            Weight cost = (e->weight == CV) ? cv : ch;

            if (d[e->dst] > d[v] + cost) {
                d[e->dst] = d[v] + cost;
                que.push(P(d[e->dst], e->dst));
            }
        }
    }

    return d[end];
}

int main()
{
    Init();

    while (cin >> ch >> cv, ch || cv) {
        string start, end;
        char c;

        for (int i = 0; i < 3; ++i)
            for (int j = 0; j < 3; ++j) {
                cin >> c;
                start.push_back(c);
            }
        for (int i = 0; i < 3; ++i)
            for (int j = 0; j < 3; ++j) {
                cin >> c;
                end.push_back(c);
            }

        int s = FindIndex(start), e = FindIndex(end);
        cout << ShortestPath(s, e) << endl;
    }

    return 0;
}

Measured memory_bytes: 56596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int n;
	std::cin >> n;
	std::cout << n*n*n<< std::endl;
}


Measured memory_bytes: 3116
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
        String s = sc.next();
        List<String> list = new ArrayList<>(Arrays.asList("SUN","MON","TUE","WED","THU","FRI","SAT"));

        System.out.println(7 - list.indexOf(s));
    }

}

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

LL A, B, N, ans;

LL calc(LL A, LL B, LL x) {
    return floor(A*x/B) -A*floor(x/B);
}
int main() {
    cin >> A >> B >> N;
    cout<< calc(A, B, min(B-1, N)) << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define ll uint64_t
using namespace std;

int main(){
  ll A,B,N,ans;
  cin >> A >> B >> N;
  ans = min(B-1,N);
  ans = floor((ans*A)/B) - A * floor(ans/B);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MAXCOST 5000
double dp[51][MAXCOST+1];
int v[4];
struct INFO{
	int type,val;
	INFO(){type=0;val=0;};
};
INFO mass[51]; 

int main(){
	int x,y,z;
	while(cin >> x >> y >> z , x){
		rep(i,51)mass[i] = INFO();
		rep(i,51)rep(j,MAXCOST+1)dp[i][j] = 0;
		rep(i,x)cin >> v[i];
		
		int mxcost = 0;
		
		rep(i,z){
			int N;
			cin >> N;
			cin >> mass[N].type >> mass[N].val;
			if(mass[N].type == 2)mxcost += mass[N].val;
		}
		double baseProb = 1.0/x;
		dp[0][0] = 1;
		for(int pos = 0; pos < y ; pos++){
			for(int cost = 0 ; cost <= mxcost ; cost++){
				rep(i,x){
					int nextPos = pos+v[i];
					if(nextPos > y)nextPos = y;

					if(mass[nextPos].type == 0){
						dp[nextPos][cost] += dp[pos][cost] * baseProb;
					}					
					if(mass[nextPos].type == 1){
						int newPos = nextPos + mass[nextPos].val;
						if(newPos > y)newPos = y;
						dp[newPos][cost] += dp[pos][cost] * baseProb;
					}
					if(mass[nextPos].type == 2){
						int newCost = mass[nextPos].val + cost;
						dp[nextPos][newCost] += dp[pos][cost] * baseProb;
					}
					if(mass[nextPos].type == 3){
						int newCost = cost - mass[nextPos].val;
						if(newCost < 0)newCost = 0;
						dp[nextPos][newCost] += dp[pos][cost] * baseProb;
					}
				}
			}
		}
		double sum = 0;
		for(int i = 0; i <= mxcost ;i++){
			sum += dp[y][i] * i;
		}
		cout << (int)sum << endl;	
	}
}

Measured memory_bytes: 2860
#include <iostream>
#include <vector>
 
using namespace std;
 
#define INF (1<<29)
 
typedef pair<char,int> P;
 
int solve(vector<P> &A,int p,int r){
  int x = A[r].second;
  int i = p - 1;
 
  for(int j = p ; j < r ; j++){
    if(A[j].second <= x){
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
 
  return i + 1;
}
 
void QuickSort(vector<P> &A,int p,int r){
  if(p < r){
    int q = solve(A,p,r);
    QuickSort(A,p,q-1);  
    QuickSort(A,q+1,r);  
  }
}
 
void MergeSort(vector<P> &A){
  int n = (int)A.size();
 
  if(n <= 1) return;
 
  vector<P> L(A.begin(), A.begin() + n / 2);
  vector<P> R(A.begin() + n / 2, A.end());
 
  MergeSort(L);
  MergeSort(R);
 
  int l = (int)L.size(), r = (int)R.size();
  for(int i = 0,j = 0,k = 0 ; i < n ; i++){
    if(k == r){
      A[i] = L[j++];
    }else if(j == l){
      A[i] = R[k++];
    }else if(L[j].second <= R[k].second){
      A[i] = L[j++];
    }else{
      A[i] = R[k++];
    }
  }
}
 
int main(){
  int n;
 
  cin >> n;
  vector<P> v(n);
  for(int i = 0 ; i < n ; i++){
    cin >> v[i].first >> v[i].second;
  }
 
  vector<P> check = v;
  QuickSort(v,0,n-1);
  MergeSort(check);
 
  if(v == check){
    cout << "Stable" << endl;
  }else{
    cout << "Not stable" << endl;
  }
 
  for(int i = 0 ; i < n ; i++){
    cout << v[i].first << " " << v[i].second << endl;
  }
 
  return 0;
}

Measured memory_bytes: 5940
import java.io.*;

class Main{
	public static void main(String[] args){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
			int n1=0,n2=0,n3=0;
			for(int i = 0;i<10;++i){
				String line = reader.readLine();
				int n = Integer.parseInt(line);
				if(n1 <= n){
					n3 = n2;
					n2 = n1;
					n1 = n;
				}
				else if(n2<=n){
					n3=n2;
					n2=n;
				}
				else if(n3<=n){
					n3=n;
				}
			}
			System.out.println(n1);
			System.out.println(n2);
			System.out.println(n3);
		}catch (IOException e){
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 24132
#include<iostream>
#include<cmath>
//#include<math.h>
#include<iomanip>       //???????°???°?????????????????????

using namespace std;

int main(){

double r=0;                        //??????????????¨?????°??????
double d=0,l=0;                  //d?????¢??????l????????¨????????????????´????????????°

cin >> r;

d=1.0*r*r*M_PI;                   //??¢????¨????
l=1.0*2*r*M_PI;                   //?????¨??????????¨????

cout << fixed << setprecision(8) << d << " " << fixed << setprecision(8) << l << endl;       //??¨???

return 0;

}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Q;
int A[201010];
int B[201010];
multiset<int> p,n;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	ll S=0,T=0;
	FOR(i,2*N) cin>>A[i], S+=A[i];
	FOR(i,2*N) {
		cin>>B[i];
		B[i]-=A[i];
		if(i!=0 && i!=2*N-1) {
			if(B[i]>0) {
				p.insert(B[i]);
				T+=B[i];
			}
			else {
				n.insert(-B[i]);
			}
		}
	}
	while(Q--) {
		cin>>i>>x>>y;
		i--;
		S-=A[i];
		if(i!=0 && i!=2*N-1) {
			if(B[i]>0) {
				p.erase(p.find(B[i]));
				T-=B[i];
			}
			else {
				n.erase(n.find(-B[i]));
			}
		}
		
		A[i]=x;
		S+=x;
		B[i]=y-A[i];
		if(i!=0 && i!=2*N-1) {
			if(B[i]>0) {
				p.insert(B[i]);
				T+=B[i];
			}
			else {
				n.insert(-B[i]);
			}
		}
		
		ll ma=0;
		if(p.size()%2==0) ma=S+T;
		else ma=S+max(T-*p.begin(),T-*n.begin());
		cout<<ma<<endl;
		
		
		
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


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

    int n,m; cin>>n>>m;
    vec b(n+5,0);
    rep(i,m){
        int l,r; cin>>l>>r;
        b[l]++; b[r+1]--;

    }

    for(int j=1; j<n; j++) b[j+1]+=b[j];

    int ans=0;
    for(int i=1; i<=n; i++){
        if(b[i]==m) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3656
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include<math.h>

using namespace std;

int main(){

	string s,t;
	cin >> s >>t;
	string ans;
	for(int i = 0; i < s.size(); i++){
		if(s == t){
			cout << "Yes" <<endl;
			return 0;
		}
		else{
			ans = s.back();
			 s.pop_back();
			s = ans + s;
		}
	}
	cout << "No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
    int n;
    int m;
    std::cin >> n >> m;
    std::vector<std::pair<int, int> > works;
    for (int i = 0; i < n; i++) {
      int a;
      int b;
      std::cin >> a >> b;
      works.push_back(std::make_pair(b, a));
    }
    std::sort(works.begin(), works.end());
    std::reverse(works.begin(), works.end());
    std::set<int> undecided;
    for (int i = 1; i < m + 1; i++) {
      undecided.insert(i);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a = works[i].second;
        int b = works[i].first;
        auto result = undecided.lower_bound(a);
        // std::cerr << *result << std::endl;
        if (result == undecided.end()) {
            continue;
        }
        ans += b;
        undecided.erase(result);
    }
    std::cout << ans << std::endl;
}

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

int main() {
  cout << fixed << setprecision(10);
  long long a, b, c, res = 0;
  cin >> a >> b;
  cout << a / b << " " << a % b << " " << (long double)a / b
       << endl;
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
const ll INF = 4e18;
const ll MOD = 1e9+7;

typedef pair<ll,ll> P;

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

  ll w, h;
  cin >> w >> h;
  priority_queue<P,vector<P>,greater<P>> pq;
  for (int i = 0; i < w; i++) {
    ll x;
    cin >> x;
    pq.push(P(x,0));
  }
  for (int i = 0; i < h; i++) {
    ll x;
    cin >> x;
    pq.push(P(x,1));
  }

  ll a[2] = {h+1LL,w+1LL};
  ll ans = 0;
  while (!pq.empty()) {
    P tp = pq.top();
    pq.pop();
    ans += tp.first * a[tp.second];
    a[!tp.second]--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6384
#include <iostream>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;

    if(a == 1) a += 13;
    if(b == 1) b += 13;

    if(a > b){
        cout << "Alice" << endl;
    }else if(b > a){
        cout << "Bob" << endl;
    }else{
        cout << "Draw" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
l = list(map(int, input().split()))

key = lcm_list(l)
ans = 0

for i in l:
  ans += key // i
print(ans % (10** 9 + 7))


Measured memory_bytes: 6140
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
from decimal import *
 
# N以上でMを割り切ることができる最小の数nを求める　→ 答え M//n
N, M = MAP()

m = [] #Mの約数を格納
for i in range(1, int(M**0.5)+1):
    if M%i == 0:
        m.append(i)
        if i != M//i:
            m.append(M//i)

m.sort()
n = m[bisect_left(m, N)]

print(M//n)


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

int main(void){
   int N;
   cin>>N;
   vector<vector<int>> A(2,vector<int>(N));
   for(int i=0;i<2;i++){
      for(int j=0;j<N;j++){
         cin>>A[i][j];
      }
   }
   int ans=0;
   for(int i=0;i<N;i++){
      int sum=0;
      for(int k=0;k<=i;k++){
         sum+=A[0][k];
      }
      for(int j=i;j<N;j++){
         sum+=A[1][j];
      }
      ans=max(ans,sum);
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
int n;
signed main(){
    cin>>n;
    int m=n;
    n=n*100;
    if(n%108==0)n=n/108;
    else n=n/108+1;
    int x=n*1.08;
    if(x==m)cout<<n<<endl;
    else cout<<":("<<endl;
    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 a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    System.out.println(c + " " + a + " " + b);
  }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>

int main (void) {
    int n;
    int i;
    scanf("%d", &n);

    for ( i=1; i<=9; i++ ) {
        if ( n%i == 0 && n/i <= 9 ) {
            printf("Yes\n");
            return EXIT_SUCCESS;
        }
    }
    printf("No\n");
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstring>
#include <queue>

using namespace std;

typedef long long ll;

const int MAX_V=1001;
const ll INF=1000000000000000LL;

class edge{
public:
    int to,rev;
    ll cap;
    edge(int to_,ll cap_,int rev_){
        to=to_;
        cap=cap_;
        rev=rev_;
    }
};
vector<edge> G[MAX_V];
// s©çÌ£
int level[MAX_V];
// Ç±ÜÅ²×IíÁ½©
int iter[MAX_V];
void add_edge(int from,int to,ll cap){
    G[from].push_back(edge(to,cap,G[to].size()));
    G[to].push_back(edge(from,0,G[from].size()-1));
}
// s©çÌÅZ£ðßé
void bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
        int v=que.front();que.pop();
        for(int i=0;i<G[v].size();i++){
            edge &e=G[v][i];
            if(e.cap>0&&level[e.to]<0){
                level[e.to]=level[v]+1;
                que.push(e.to);
            }
        }
    }
}
// ÁpXðdfsÅT·
ll dfs(int v,int t,ll f){
    if(v==t)return f;
    for(int &i=iter[v];i<G[v].size();i++){
        edge &e=G[v][i];
        if(e.cap>0&&level[v]<level[e.to]){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
// s©çtÖÌÅå¬ðßé
ll max_flow(int s,int t){
    ll flow=0;
    while(1){
        bfs(s);
        if(level[t]<0)return flow;
        memset(iter,0,sizeof(iter));
        ll f;
        while((f=dfs(s,t,INF))>0)flow+=f;
    }
}

int N;
ll W;
ll ts[101];
int cs[101];
int main(){

    while(cin>>N>>W&&(N|W)){
        ll sum=0;
        for(int i=0;i<MAX_V;i++)G[i].clear();
        int sn,gn;
        for(int i=0;i<N;i++){
            cin>>ts[i]>>cs[i];
            sum+=ts[i];
            // jú©çlÖ
            for(int j=0;j<cs[i];j++){
                string s;
                cin>>s;
                int id=0;
                if(s=="Monday")id=0;
                else if(s=="Tuesday")id=1;
                else if(s=="Wednesday")id=2;
                else if(s=="Thursday")id=3;
                else if(s=="Friday")id=4;
                else if(s=="Saturday")id=5;
                else id=6;
                add_edge(id,7+i,INF);
            }
        }
        // start©çjúÖ
        sn=N+7;gn=sn+1;
        for(int i=0;i<7;i++)add_edge(sn,i,W);
        // l©çgoalÖ
        for(int i=0;i<N;i++)add_edge(7+i,gn,ts[i]);
        ll res=max_flow(sn,gn);
        if(res==sum)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1004
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define pi 3.141592653589793238

int main(){
    long double a, b, ans; 
    long double h, m;
    cin >> a >> b >> h >> m;
    long double theta=0.0, ar=0.0, br=0.0;
    ar = h * (pi/6) + m * (pi/360);
    br = m * (pi/30);
    theta = abs(ar-br);
    ans = sqrt(a*a + b*b - 2*a*b*cos(theta));
    std::cout << std::setprecision(21) << ans; 
    return 0;
}

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  vector<int> dx = {1,0,-1,0,1,-1,1,-1};
  vector<int> dy = {0,1,0,-1,1,1,-1,-1};
  for(int i = 0; i < h; i++)cin >> s.at(i);
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(s.at(i).at(j)=='#'){
        cout<<'#';
        if(j==w-1)cout<<endl;
        continue;
      }
      int ans =0 ;
      if(s.at(i).at(j)=='.'){
        for(int dir = 0; dir < 8; dir++){
          int nx = i+dx.at(dir);
          int ny = j+dy.at(dir);
          if(nx<0||nx>=h||ny<0||ny>=w)continue;
          if(s.at(nx).at(ny)=='#')ans++;
        }
      }
      cout<<ans;
      if(j==w-1)cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(int i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
ll dp[2][N];
pll val[N];
ll pre[N];
int main()
{
       ll a,b,c,d;
       cin>>a>>b>>c>>d;
       ll tot = b-a+1;
       ll xx = b/c - (a-1)/c;
       tot -= xx;
       xx = b/d - (a-1)/d;
       tot -= xx;
       ll gg = __gcd(c,d);
       gg = (c*d)/gg;
       xx = b/gg - (a-1)/gg;
       tot += xx;
       cout<<tot<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = [input() for i in range(n)]
alpha = "abcdefghijklmnopqrstuvwxyz"
cnt_alpha = [[0]*len(alpha) for i in range(n)]

for i in range(len(alpha)):
  for j in range(n):
    cnt_alpha[j][i] = a[j].count(alpha[i])

cnt_alpha = [[row[i] for row in cnt_alpha] for i in range(len(alpha))]
for i in range(len(alpha)):
  print(alpha[i]*min(cnt_alpha[i]),end="")
print()

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

int main() {
	int W,a,b;
	cin >> W >>a>>b;
	
	if(a+W>=b){
		if(b+W<a){
			cout<<a-b-W;
		}else{
			cout<<0;
		}
	}else{
		cout << b-a-W;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = input()
B = input()
C = input()
cnt = 0
for i in range(N):
    if A[i]==B[i] and B[i]==C[i] and C[i]==A[i]:
        cnt+=0
    elif A[i]!=B[i] and B[i]!=C[i] and C[i]!=A[i]:
        cnt+=2
    else:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
typedef long long ll;
typedef priority_queue<int> PQI;
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int a;
    cin>>a;
    cout<<a*a*a<<endl;
    
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    int A[M];
    REP(i, M) {
        cin >> A[i];
    }
    int index = 0;
    REP(i, M) {
        if(X < A[i]) {
            index = i;
            break;
        }
    }
    cout << min(M - index, index) << endl;
    return 0;
}



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

maxA = max(A)
memo = [0] * (maxA + 1)

seen = set()
for a in A:
    for mul_a in range(a, maxA+1, a):
        if a not in seen and mul_a == a: 
            continue
        memo[mul_a] += 1
    seen.add(a)

ans = 0
seen = set()
for a in A:
    if memo[a] == 0 and a not in seen:
        seen.add(a)
        ans += 1

print(ans)


Measured memory_bytes: 157396
from operator import itemgetter
import sys


class BIT:
    def __init__(self, size: int):
        self.size = size + 1
        self.array = [0] * self.size

    def add(self, i, x):
        if not i > 0:
            return
        while i < self.size:
            self.array[i] += x
            i += i & -i

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


def read():
    return sys.stdin.readline().rstrip()


def main():
    n, q = map(int, read().split())
    c = [int(i) for i in read().split()]
    queries = [() for _ in range(q)]
    for i in range(q):
        l, r = map(int, read().split())
        queries[i] = (i, l, r)
    queries.sort(key=itemgetter(2))
    last = [0] * n
    bit = BIT(n)
    ans = [-1] * q
    cr = 0
    for i, l, r in queries:
        for ri in range(cr, r):
            ci = c[ri] - 1
            bit.add(last[ci], -1)
            last[ci] = ri + 1
            bit.add(last[ci], 1)
            cr = ri
        ans[i] = bit.sum(r) - bit.sum(l - 1)
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


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

using namespace std;

#define M (ll)(1e9+7)
#define EPS (double)(1e-12)
#define ll long long
#define N (ll)(2*1e5)

/*class Graph {
    
    public:
        int V;
        vector<int> *adj;
        bool *visited;

        Graph(int V) {
            this->V = V;
            adj = new vector<int>[V];
            visited = new bool(V);
            memset(visited, 0, V*sizeof(bool));
        }
        void addEdge(int u, int v) {
            adj[u].push_back(v);
            adj[v].push_back(u);
        }
        void dfs(int u);
        void bfs(int u);
};

void Graph::dfs(int u) {
    if(visited[u])
        return;
    visited[u] = true;
    cout << u << " ";

    for(auto a : adj[u]) {
        dfs(a);
    }
}

void Graph::bfs(int u) {
    queue<int> fila;

    fila.push(u);
    visited[u] = true;
    while(!fila.empty()) {
        int s = fila.front();
        cout << s << " ";
        fila.pop();

        for(auto a : adj[s]) {
            if(!visited[a]) {
                visited[a] = true;
                fila.push(a);
            }
        }
    }
}*/
int freq[N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, val;

    cin >> n;

    for(int i = 0; i < n-1; i++) {
        cin >> val;
        freq[--val]++;
    }
    for(int i = 0; i < n; i++) {
        cout << freq[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4392
fun main(args: Array<String>) {
    val L = nextInt()
    var l = L
    var dl = 0
    var ce = 0
    val f = BooleanArray(20)
    val str = StringBuilder()
    while (l > 0) {
        if (l and 1 != 0) {
            f[dl] = true
            ce += 1
        }
        l /= 2
        dl += 1
    }
    str.append("${dl} ${(dl - 1) * 2 + ce - 1}\n")
    l = L
    var t = 1
    for (n in 1 until dl) {
        str.append("${n} ${n + 1} ${0}\n")
        str.append("${n} ${n + 1} ${t}\n")
        if (f[n - 1]) {
            str.append("${n} ${dl} ${l - t}\n")
            l -= t
        }
        t *= 2
    }
    print(str.toString())
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 33608
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 文字列の入力
		String[] n = sc.next().split("");
      
		// 出力
		System.out.println(n[0].equals(n[2]) ? "Yes" : "No");
	}
}


Measured memory_bytes: 21844
using System;


namespace ConsoleApp1
{
    class Program
    {
        static int[] dx = { 1, 1, 0, -1, -1, -1, 0, 1 };
        static int[] dy = { 0, 1, 1, 1, 0, -1, -1, -1 };
        static void Main(string[] args)
        {

            while (true)
            {
                int w, h;
                int answer = 0;
                string[] s = Console.ReadLine().Split();
                w = int.Parse(s[0]); h = int.Parse(s[1]);
                if (w == 0 && h == 0) break;
                int[,] table = new int[w, h];
                for(int i = 0; i < h; i++)
                {
                    string[] num = Console.ReadLine().Split();
                    for(int j = 0; j < w; j++)
                    {
                        table[j, i] = int.Parse(num[j]);
                    }
                }
                for(int i = 0; i < w; i++)
                {
                    for(int j = 0; j < h; j++)
                    {
                        answer += checker(table, i, j, w, h);
                    }
                }
                Console.WriteLine(answer);
            }
        }

        static int checker(int[,] table, int x, int y, int w, int h)
        {
            if (x < 0 || y < 0 || y > h - 1|| x > w - 1) return 0;
            if (table[x, y] == 0) return 0;
            table[x, y] = 0;
            for (int i = 0; i < 8; i++)
            {
                checker(table, x + dx[i], y + dy[i], w, h);
            }

            return 1;
        }
    }
}

Measured memory_bytes: 9516
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(200010);
  int N,K;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    int b;
    cin>>b;
    a[b]++;
  }
  sort(a.rbegin(),a.rend());
  int counter=0;
  for(int i=0;i<K;i++){
    counter+=a[i];
  }
  cout<<N-counter<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>

struct weighted_union_find {
	long long N;					// the number of nodes
	long long M;					// the number of trees
	std::vector<long long> parent;	// parent[i] := the direct parent of i
	std::vector<long long> size;	// size[i] := the number of nodes in the tree containing i
	std::vector<long long> weight;	// weight[i] := the weight of the edge from i to parent[i]

	weighted_union_find(long long n) : N(n), M(n) {
		parent.resize(n, -1);
		size.resize(n, 1);
		weight.resize(n, 0);
	}

	long long weight_sum_to_root(long long i) {
		if (parent[i] == -1) return 0;
		else return weight[i] + weight_sum_to_root(parent[i]);
	}

	long long root(long long i) {
		if (parent[i] == -1) return i;
		long long x = root(parent[i]);
		weight[i] += weight[parent[i]];
		return parent[i] = x;
	}

	bool is_united(long long i, long long j) {
		return (root(i) == root(j));
	}

	long long dist(long long i, long long j) {
		if (!is_united(i, j)) return LLONG_MAX;
		else return weight_sum_to_root(j) - weight_sum_to_root(i);
	}

	// false : detected confliction
	bool unite(long long i, long long j, long long w) {
		w += weight_sum_to_root(i) - weight_sum_to_root(j);
		i = root(i); j = root(j);
		if (i == j) return (w == 0);
		if (size[i] < size[j]) {
			std::swap(i, j);
			w *= -1;
		}
		parent[j] = i;
		size[i] += size[j];
		weight[j] = w;
		return true;
	}
};

int main() {
	long long n, q;
	std::cin >> n >> q;
	weighted_union_find uf(n);
	while (q--) {
		long long w, x, y;
		std::cin >> w >> x >> y;
		w--; x--;
		if (!uf.unite(w, x, y)) {
			std::cout << "No" << std::endl;
			return 0;
		}
	}std::cout << "Yes" << std::endl;
}

Measured memory_bytes: 5648
#include<stdio.h>
int main(){
	int a,b;
	
	scanf("%d %d",&a,&b);
	if(1<=a&&a<=9&&1<=b&&b<=9){
	
	printf("%d",a*b);}
	if(a>=10&&a<=20||b>=10&&b<=20){
	printf("-1");}
	return 0;
} 


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

string S;

int main() {
    cin >> S;

    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == '1') ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N,M = map(int,input().split())
uf = UnionFind(N)
for i in range(M):
    A,B = map(int,input().split())
    uf.union(A-1,B-1)
ans = 0
for i in uf.roots():
    ans = max(uf.size(i),ans)
print(ans)

Measured memory_bytes: 87916
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[15][100006];
int t = 0;
int s=0;
int sum = 1e9;
int n, m, x;
int tt = 0;
int b[15];
bool solve()
{
    for (int i = 1; i <= m;i++)
        if(b[i]<x)
            return false;
    return true;
}
void dfs(int k)
{

    if(k==n)
    {
        if(solve())
            sum = min(s, sum);
        return;
    }
    for (int j = 1; j <= m; j++)
        b[j] += a[k][j];
    s += a[k][0];
    dfs( k + 1);
    for (int j = 1; j <= n; j++)
        b[j] -= a[k][j];
    s -= a[k][0];
    dfs(k + 1);
}
int main()
{

    memset(b, 0, sizeof(b));
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i][0];
        for (int j = 1; j <= m; j++)
            cin >> a[i][j];
    }
    dfs( 0);
    if(sum==1e9)
        cout << "-1" << endl;
    else
        cout << sum << endl;
    system("pause");
}

Measured memory_bytes: 3224