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

int main()
{
    vector<int>x1;
    vector<int>y1;
    int w,h,n;
    cin>>w>>h>>n;
    for(int i=0;i<=w;i++)x1.push_back(i);
     for(int i=0;i<=h;i++)y1.push_back(i);
     while(n--)
     {
         int a,b,c;
         cin>>a>>b>>c;
         if(c==1)
         {
             for(int i=0;i<x1.size();i++)
             {
                 if(x1[i]<a)x1[i]=-9;
             }
         }
         else if(c==2)
         {
             for(int i=0;i<x1.size();i++)
             {
                 if(x1[i]>a)x1[i]=-9;
             }
         }
        else if(c==3)
         {
             for(int i=0;i<y1.size();i++)
             {
                 if(y1[i]<b)y1[i]=-9;
             }
         }
         else if(c==4)
         {
             for(int i=0;i<y1.size();i++)
             {
                 if(y1[i]>b)y1[i]=-9;
             }
         }
     }

     int counter=0,flag=0;
     for(int i=0;i<x1.size();i++)if(x1[i]!=-9)counter++;
      for(int i=0;i<y1.size();i++)if(y1[i]!=-9)flag++;
    //  cout<<counter<<" "<<flag<<endl;
     if(counter==0&&flag==0)cout<<0<<endl;
     else cout<<max(0,(counter-1)*(flag-1))<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(a+b==c+d)cout<<"Balanced"<<endl;
    else if(a+b>c+d)cout<<"Left"<<endl;
    else cout<<"Right"<<endl;
}


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

#define int     long long int
#define pii     pair<int, int>
#define vi      vector<int>
#define vii     vector<pair<int, int>>
#define pb      push_back
#define all(a)  (a).begin(),(a).end()
#define f       first
#define s       second
#define endl    '\n'
#define mod     1000000007    		

void solve()
{
	int n ;
	cin >> n ;
	int ans = (n + 999) / 1000 ;
	ans *= 1000 ;
	ans = ans - n ;
	cout << ans << endl ;
}

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

    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
        solve() ;
    }
    return 0 ;
}

Measured memory_bytes: 3648
/*
** 优先队列
** 为简化代码，本题去除了关于数组溢出的检查
*/

# include <cstdio>
# include <algorithm>
using namespace std;

const int MAX = 2000000 + 10;

int idx, key, a[MAX];

void heapInsert(int k) {
    idx++;
    a[idx] = k;
    int p = idx / 2, i = idx;
    while (i > 1 && a[p] < a[i]) {
        swap(a[p], a[i]);
        i = p;
        p = i / 2;
    }
}

void maxHeapify(int i) {
    int l = 2 * i;
    int r = 2 * i + 1;
    int largest;
    if (l <= idx && a[l] > a[i]) {
        largest = l;
    }
    else {
        largest = i;
    }
    if (r <= idx && a[r] > a[largest]) {
        largest = r;
    }

    if (largest != i) {
        swap(a[i], a[largest]);
        maxHeapify(largest);
    }
}

int heapExtract() {
    int max = a[1];
    a[1] = a[idx];
    idx--;
    maxHeapify(1);
    return max;
}

void solve() {
    idx = 0;
    char com[10];
    while (1) {
        scanf("%s", com);
        if (com[2] == 'd') {
            break;
        }
        if (com[2] == 's') {
            scanf("%d", &key);
            heapInsert(key);
        }
        else {
           printf("%d\n", heapExtract());
        }
    }
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    solve();
    return 0;
}


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

using namespace std;

  int main(){

  int t,ac=0,wa=0,tle=0,re=0;
  cin>>t;
  string x;
  while(t--){
    cin>>x;
    if(x=="AC"){
        ac++;
    }
    else if(x=="WA"){
        wa++;
    }
    else if(x=="TLE"){
        tle++;
    }
    else{
        re++;
    }
  }
  cout<<"AC"<<" x "<<ac<<endl;
  cout<<"WA"<<" x "<<wa<<endl;
  cout<<"TLE"<<" x "<<tle<<endl;
  cout<<"RE"<<" x "<<re<<endl;
    return 0;

}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

int main()
{
	int n; cin >> n;
	string s; cin >> s;
	int k; cin >> k;
	vector<char> ans(n);
	char sk = s[k-1];
	for (int i = 0; i < n; ++i) {
		if (sk != s[i])
			ans[i] = '*';
		else
			ans[i] = s[i];
	}
	for (int i = 0; i < n; ++i)
		cout << ans[i];
	cout << endl;
}



Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0

for i in range(n):
  left = min(A[i], B[i])
  ans += left
  A[i] -= left
  B[i] -= left

  right = min(A[i+1], B[i])
  ans += right
  A[i+1] -= right

print(ans)

Measured memory_bytes: 23912
function main(input) {
  const inputs = input.split('\n');
  var n = inputs[0].split(' ')[0] - 0;
  var m = inputs[0].split(' ')[1] - 0;

  var ds = [];
  for (var i = 0; i < m; i++) {
    ds.push(inputs[i + 1].split(' ').filter((n, i) => i > 0).map((n) => n - 1));
  }
  var p = inputs[1 + m].split(' ').map((n) => parseInt(n, 10));

  var counter = 0;
  // bit all search
  for (var bit = 0; bit < (1 << n); bit++) {
    var allOn = true;
    // all search for switches
    for (var swi = 0; swi < m; swi++) {
      var sum = 0;
      // a bit pattern
      for (var biti = 0; biti < n; biti++) {
        if (!(bit & (1 << biti))) continue;
        if (ds[swi].find((v) => v == biti) >= 0) sum++;
      }
      allOn = allOn && (sum % 2 == p[swi]);
    }
    if (allOn) counter += 1;
  }
  console.log(counter);
}

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


Measured memory_bytes: 12092
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


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


if __name__ == '__main__':
    N, M = map(int, input().split())
    PY = []
    for i in range(M):
        P, Y = map(int, input().split())
        PY.append([Y, P, i + 1])
    PY.sort()

    # cnt: key=県, value=すでに幾つの市がその県に属しているか
    # res: [市の番号, 県の番号, 順番]
    cnt = {}
    res = []
    for y, p, i in PY:
        if p not in cnt:
            cnt[p] = 1
        else:
            cnt[p] += 1
        res.append([i, p, cnt[p]])

    res.sort()
    for i, p, x in res:
        print('{:06}{:06}'.format(p, x))


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

vector<pair<long long, long long> > prime_factorize(long long N) {
	vector<pair<long long, long long> > res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0; // 指数

		 // 割れる限り割り続ける
		while (N % a == 0) {
			++ex;
			N /= a;
		}

		// その結果を push
		res.push_back({ a, ex });
	}

	// 最後に残った数について
	if (N != 1) res.push_back({ N, 1 });
	return res;
}

int main() {

	ll n; cin >> n;

	int ans = 0;
	for (ll i = 1; i <= n; i++) {
		if (i % 2 == 0) continue;
		vector<pair<long long, long long>> a_prime; // a^x ならば { a, x }
		a_prime = prime_factorize(i);

		ll tmp = 1;
		for (ll j = 0; j < a_prime.size(); j++) {
			tmp *= (a_prime[j].second + 1);
		}
		if (tmp == 8) ans++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use strict;
use warnings;
package ZAlgorithm;
sub z_algorithm(@){
	my$n=@_;
	my@z=($n);
	my$i=1;
	my$j=0;
	while($i<$n){
		$j++while$i+$j<$n&&$_[$j]eq$_[$i+$j];
		$z[$i]=$j;
		if($j==0){
			$i++;
			next;
		}
		my$k=1;
		while($i+$k<$n&&$k+$z[$k]<$j){
			$z[$i+$k]=$z[$k];
			$k++;
		}
		$i+=$k;
		$j-=$k;
	}
	return@z;
}
package main;
my($s,$t)=map{chomp;$_}<>;
my@s=split"",$s;
my@t=split"",$t;
my@ss=(@s,@s);
push@ss,@s while@ss<@t*2;
my@z=ZAlgorithm::z_algorithm(@t,@ss);
my@ok=map$z[$_+@t]>=@t,0..$#s;
my@memo=(-1)x@s;
sub dfs{
	my$u=shift;
	if($memo[$u]>=0){
		return$memo[$u];
	}
	elsif($memo[$u]==-2){
		return$memo[$u]=1e9;
	}
	if($ok[$u]){
		$memo[$u]=-2;
		return$memo[$u]=dfs(($u+@t)%@s)+1;
	}
	else{
		return$memo[$u]=0;
	}
}
my$ans=0;
for(0..$#s){
	my$now=dfs($_);
	$ans=$now if$ans<$now;
}
print$ans<1e9?$ans:-1,$/;


Measured memory_bytes: 794528
#include<iostream>
#include<algorithm>
#include<vector>
using lint=long long;
using namespace std;

lint N;
lint A[200010]={};

lint sadness(lint b)
{
	lint ret=0;
	for(lint i=1;i<=N;i++)
		ret+=abs(A[i]-(b+i));
	return ret;
}

int main()
{
	vector<lint> v;
	cin >> N;
	for(lint i=1;i<=N;i++)
	{
		cin >> A[i];
		v.push_back(A[i]-i);
	}
	sort(v.begin(),v.end());
	lint B=v[int(v.size())/2];
	cout << sadness(B) << endl;
	return 0;
}

Measured memory_bytes: 3444
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
V<int> v[500005],rv[500005];
int a[1005][1005],id[1005][1005],dp[500005];
bool vis[500005];
V<int> t;
void dfs(int p){
	if(vis[p])RE;
	vis[p]=1;
	for(auto u:v[p])if(!vis[u])dfs(u);
	t.PB(p);
}
void rdfs(int p,int k){
	if(vis[p])RE;
	vis[p]=1;
	for(auto u:rv[p]){
		if(!vis[u])rdfs(u,k);
		gmax(dp[p],dp[u]+1);
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,cnt=0;
	cin>>n;
	rep(i,1,n)FOR(j,i+1,n)id[i][j]=id[j][i]=++cnt,dp[cnt]=1;
	FOR(i,1,n){
		rep(j,1,n)cin>>a[i][j];
		rep(j,1,n-1)v[id[i][a[i][j]]].PB(id[i][a[i][j+1]]);
	}
	FOR(i,1,cnt)for(auto u:v[i])rv[u].PB(i);
	FOR(i,1,cnt)if(!vis[i])dfs(i);
	reverse(ALL(t));
	int k=0;FILL(vis,0);
	for(auto u:t)if(!vis[u])rdfs(u,++k);
	if(k<cnt){
		cout<<-1;RE 0;
	}
	int ans=0;
	FOR(i,1,cnt)gmax(ans,dp[i]);
	cout<<ans;
	RE 0;
}




Measured memory_bytes: 67448
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<sstream>
#include<vector>
#include<ctime>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int inf=0x3f3f3f3f;
int main()
{
	IOS;
	char c;
	cin>>c;
	c=c+1;
	cout<<c<<endl;
	return 0;
}


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

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];

    rep(i,n) {
        if (a[i] + 1 == a[i+1] && i != n-1) ans += c[a[i]-1];
        ans += b[a[i]-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;
int main(){
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
  	int sum=0;
    for(int i=0; i<N; i++){
        cin >> A.at(i);
      	sum += A.at(i);
    }
    sort(A.begin(),A.end());
  	reverse(A.begin(),A.end());
    double c;
    c=sum*0.25/M;
    if(A.at(M-1)<c) cout << "No" << endl;
    else cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int solve(vector<pair<int, int>>x) {
	int minx = 9999, minid = -1;
	for (int i = 0; i < x.size(); i++) {
		if (x[i].second == 0 && minx > x[i].first) { minx = x[i].first; minid = i; }
	}
	if (minx == 9999)return 0;
	int L = minid; while (L >= 1 && (x[L - 1].second == 0 || x[L - 1].first < minx))L--;
	int R = minid; while (R < x.size() - 1 && (x[R + 1].second == 0 || x[R + 1].first < minx))R++;
	vector<pair<int, int>>J;
	for (int i = 0; i < x.size(); i++) { if (L <= i && i <= R)continue; J.push_back(x[i]); }
	return solve(J) + 1;
}
int main() {
	vector<pair<int, int>>r; int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int t1; char c2; cin >> c2 >> t1;
		if (c2 == 'y')r.push_back(make_pair(t1, 0)); else r.push_back(make_pair(t1, 1));
	}
	cout << solve(r) << endl;
	return 0;
}

Measured memory_bytes: 6852
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=0;i<k;i++){
    if(i%2==0){
      if(a%2==1)a--;
      b+=a/2;
      a/=2;
    }
    else{
      if(b%2==1)b--;
      a+=b/2;
      b/=2;
    }
    //cout<<a<<' '<<b<<endl;
  }
  cout<<a<<' '<<b<<endl;
  return(0);
}


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

using namespace std;

int bitcount(int a) {
	return (a & 1) + ((a >> 1) & 1) + ((a >> 2) & 1) + ((a >> 3) & 1);
}

int validway[5] = {
	15, // 1111
	12, // 1100
	6,  // 0110
	3,   // 0011
	0
};

int main() {
	int h, n;

	cin >> h >> n;

	int T[10001] = {};

	for (int i = 0; n > i; i++) {
		int x, y;
		cin >> x >> y;

		T[y] ^= 1 << x;
	}


	int dp[10001][5] = {};

	for (int i = 0; 10001 > i; i++)
		for (int j = 0; 5 > j; j++) dp[i][j] = -1;

	for (int i = 0; 5 > i; i++) {
		int S = validway[i];
		if (((T[0] | T[1]) & S) == 0) {
			dp[0][i] = bitcount(S)/2;
		}
	}

	for (int y = 1; h > y; y++) {
		for (int i = 0; 5 > i; i++) {
			if (dp[y - 1][i] == -1) continue;
			for (int j = 0; 5 > j; j++) {
				int S = validway[i];
				int S2 = validway[j];
				if (((S | T[y] | T[y + 1]) & S2) == 0) {
					dp[y][j] = max(dp[y - 1][i] + bitcount(S2)/2, dp[y][j]);
				}

			}
		}
	}

	cout << max({ dp[h - 2][0], dp[h - 2][1], dp[h - 2][2], dp[h - 2][3], dp[h - 2][4] }) << endl;

	return 0;
}



Measured memory_bytes: 3340
mod = 10**9+7
def kai(n):
  i = n
  r = 1
  while i > 1:
    r = (r*i) % mod
    i -= 1
  return r
m,n = map(int,input().split())
m,n = max(m,n),min(m,n)
if m > n+1:
  print(0)
elif m == n+1:
  print((kai(n)**2*m)%mod)
else:
  print((2*kai(n)**2)%mod)

Measured memory_bytes: 38512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < s.length() - 2; i++) {
            String tmp = s.substring(i, i + 3);
            int tmp2 = Integer.parseInt(tmp);
            ans = Math.min(ans, Math.abs(753 - tmp2));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35548
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

# print(A)
cur = 1
Npush = 0
# History = []
# while 1:
#     History.append(cur)
#     cur = A[cur-1]
#     Npush+=1
#     if cur == 2:
#         break
#     elif cur in History:
#         Npush=-1
#         break
for i in range(N+1):
    cur = A[cur-1]
    Npush += 1
    if cur == 2:
        break
    # print(cur)
if cur==2:
    print(Npush)
else:
    print(-1)


Measured memory_bytes: 7084
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        long X = sc.nextLong();

        long[] levels = new long[M];
        Arrays.fill(levels, 0);

        // (id - 獲得経験値のマップ)
        Map<Long, List<Long>> booksMap = new HashMap<>();
        // (id - 金額のマップ)
        Map<Long, Long> valuesMap = new HashMap<>();

        for (int i = 0; i < N; i++) {
            long id = i + 1;
            long value = sc.nextLong();
            valuesMap.put(id, value);
            List<Long> bookList = new ArrayList<>();
            for (int l = 0; l < M; l++) {
                long exp = sc.nextLong();
                bookList.add(exp);
            }
            booksMap.put(id, bookList);
        }
        sc.close();
        // 全選択パターンの格納先
        List<List<Long>> allPatterns = new ArrayList<>();
        Object[] ids = booksMap.keySet().toArray();
        for (int i = 1; i <= N; i++) {
            getPatterns(i, 0, ids, allPatterns, new ArrayList<>(), 1);
        }

        List<Long> results = new ArrayList<>();
        // 全探索
        for (List<Long> selectItem : allPatterns) {
            long value = 0;
            for (Long id : selectItem) {
                List<Long> exps = booksMap.get(id);
                for (int i = 0; i < M; i++) {
                    long exp = levels[i];
                    exp += exps.get(i);
                    levels[i] = exp;
                }
                value += valuesMap.get(id);
            }
            boolean isOK = true;
            for (Long val : levels) {
                if (val < X) {
                    isOK = false;
                    break;
                }
            }
            if (isOK) {
                results.add(value);
            }
            Arrays.fill(levels, 0);
        }
        if (results.size() == 0) {
            System.out.println(-1);
        } else {
            Collections.sort(results);
            System.out.println(results.get(0));
        }
    }

    public static void getPatterns(int count, int curCount, Object[] idList, List<List<Long>> box, List<Long> init,
            long max) {
        List<Long> li = new ArrayList<>(init);
        if (curCount == count) {
            box.add(li);
            return;
        }
        for (int i = 0; i < idList.length; i++) {
            long val = Long.parseLong(idList[i].toString());
            if (val == 0) {
                continue;
            }
            if (val < max) {
                continue;
            }
            li.add(val);
            long befMax = max;
            max = val;
            idList[i] = 0;
            curCount++;
            getPatterns(count, curCount, idList, box, li, max);
            idList[i] = val;
            li = new ArrayList<>(init);
            curCount--;
            max = befMax;
        }
    }

}


Measured memory_bytes: 58840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T; cin >> S >> T;
    cout << T+S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

    int a[2][120], n;
int main()
{
    cin >> n;
    for (int i = 0 ; i < n; i++) {
        cin >> a[0][i];
    }
    for (int i = 0 ; i < n; i++) {
        cin >> a[1][i];
    }
    for (int i = 1 ; i < n; i++) {
        a[0][i] = a[0][i - 1] + a[0][i];
    }
    a[1][0] = a[1][0] + a[0][0];

    for (int i = 1 ; i < n; i++) {
        a[1][i] = a[1][i] + max(a[1][i - 1], a[0][i]);
    }
     cout << a[1][n - 1];
    return 0;
}


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

int main(){
    double A,B; cin>>A>>B;
    for(int i=0;i<1250;i++){
        if(i*8/100==A&&i/10==B){
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
#include <string.h>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL MAXN = 107;

int A[MAXN];
vector <int> M, D[MAXN];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n;
	cin >> n;
	FOR(i, 1, n + 1)
	{
		cin >> A[i];
		FOR(j, 1, i + 1)
			if (i % j == 0) D[i].push_back(j);
	}
	RFOR(i, n + 1, 1)
	{
		LL sum = 0;
		for (int j = i; j <= n; j += i)
			sum += A[j];
		if (A[i] <= 0 && sum < 0)
			for (int j = i; j <= n; j += i)
				A[j] = 0;
	}
	FOR(i, 1, n + 1)
		if (A[i] < 0 && SZ(M) < 30) M.push_back(i);
	LL ans = 0;
	REP(mask, 1 << SZ(M))
	{
		LL cur = 0;
		bool del[MAXN];
		memset(del, 0, MAXN);
		REP(i, SZ(M))
		{
			if (mask & (1 << i))
				for (int j = M[i]; j <= n; j += M[i])
					del[j] = 1;
		}
		FOR(i, 1, n + 1)
			if (!del[i]) cur += A[i];
		ans = max(ans, cur);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#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() {
    ll N;
    cin >> N;
    vector<int> L(N);
    REP(i, N) { cin >> L[i]; }
    sort(L.begin(), L.end());
    // print(L);
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        int s = L[i];
        for(int j = i + 1; j < N; j++) {
            int m = L[j];
            // cout << i << j << endl;
            for(int k = j + 1; k < N; k++) {
                if(s + m > L[k]) {
                    // stric triagnle
                    ans++;
                } else {
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  vector<int> V(N);
  vector<int> C(N);
  for(int i=0; i<N; i++)cin>>V[i];
  for(int i=0; i<N; i++)cin>>C[i];
  int X=0,Y=0;
  for(int i=0; i<N; i++){
    if(V[i]>C[i]){
      X+=V[i];Y+=C[i];
    }
  }
  cout<<X-Y<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int n,k=1;
void link(int a,int b){printf("%d %d\n",a,b);}
int main()
{
	scanf("%d",&n);while(k<n) k=k*2;
	if(k==n){puts("No");return 0;}
	puts("Yes");link(n+1,n+2);link(n+2,n+3);link(n+3,1);
	link(1,2);link(2,3);int tn=n;if(n%2==0) n--;
	for(int i=4;i<=n;i+=2){
		link(i,i+1);link(i+tn,i+tn+1);
		link(i,1);link(i+tn+1,1);
	}
	if(tn%2==0){
		for(int i=2;i<tn;i+=2){
			int tmp=(tn^1^i);
			if(tmp>1&&tmp<tn){link(tmp+tn,tn);link(i,2*tn);break;}
		}
	}
	return 0;
}

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

 int main (){
     int r,c,x,sum=0;
     cin >> r >> c;
     int a[r+1][c+1]={0};
     for (int i=0;i<r;i++){
         int b =0;
         for (int j=0;j<c;j++){
             cin >> x;
             a[i][j]=x;
             b+=x;
            
         }
         a[i][c]=b;
         sum+=b;
         
     }

      for (int i=0;i<r;i++){
         for (int j=0;j<c;j++){
             a[r][j]+=a[i][j];       
         }
         
         
     }
     a[r][c]=sum;


      for (int i=0;i<r+1;i++){
          for(int j=0;j<c+1;j++){
             if((j==c)){
				cout<<a[i][j];
			}else{cout<<a[i][j]<<" ";}
          }
          cout << endl;
      }

     return 0;

 }



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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; ++i){
        int x;
        cin >> x;
        a[i] = -(x + i + 1);
        b[i] = x - (i + 1);
    }

    sort(all(a));
    sort(all(b));

    ll ans = 0;
    for(int i = 0; i < n; ++i){
        ans += upper_bound(all(b), a[i]) - lower_bound(all(b), a[i]);
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 4768
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

char c;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> c;
    switch (c) {
        case 'A': c = 'T';break;
        case 'T': c = 'A';break;
        case 'C': c = 'G';break;
        case 'G': c = 'C';
    }
    cout << c << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans=max(a*c,a*d);
    ll ans1=max(b*c,b*d);
    cout<<max(ans,ans1)<<endl;

    return 0;
}


Measured memory_bytes: 3632
/*"You can do anything you set your mind to,man" - Eminem*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define llpow(a,b) (ll)(pow(a,b)+0.5)
#define l_b(a,val) min((int)a.size()-1, (int)(lower_bound(a.begin(),a.end(),val)-a.begin()))
#define f first
#define up(a,b) max(a,b)
#define s second
#define INF 9223372036854775807
#define pi 3.14159265359
const  int mod = 1000000007;
void add(ll& a, ll b){a+=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
void mul(ll& a, ll b){a*=b;while(a>=mod)a-=mod;while(a<0)a+=mod;}
void up_self(ll& a, ll b){a = up(a,b);}
void min_self(ll& a, ll b){a = min(a,b);}
ll binexpomodulo(ll x, ll y){ll res =1;x%=mod;if(!x)return 0;while(y){if(y&1){mul(res, x);}mul(x,x);y>>=1;}return res;}
ll nCrInOr(ll n, ll r){ll res = 1;if(r>n-r)r = n-r;ll rin = 1;for(ll i = 1; i <=r ; i++)rin = (rin*i)%mod;rin = binexpomodulo(rin,mod-2);for(ll i = 1; i <= r; i++)res = (res*(n-i+1))%mod;res = (res*rin)%mod;return res;}
int msb(ll n){int ans;for(int i = 0 ; i < 64;  i++)if(n&(1LL<<i))ans = i+1;return ans;}
void strrev(string& s){int n = (s.size());for(int i = 0 ; i < n/2; i++)swap(s[i],s[n-1-i]);}
int main()
{
	double r; cin>>r;
	cout<<fixed<<setprecision(5)<<2*pi*r<<endl;
	
	
  	return 0;
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	if (N == 1) co("No");
	else {
		bool dame = false;
		int k = 1;
		rep(i, 20) {
			k *= 2;
			if (N == k) dame = true;
		}
		if (dame) co("No");
		else if (N % 2 == 0) {
			co("Yes");
			int xs = 0;
			rep1(i, N) {
				xs ^= i;
			}
			int a = N - 1;
			int b = xs ^ a;
			int c = a ^ 1;
			int d = b ^ 1;

			cosp(c);
			co(1);
			cosp(a);
			co(c);
			cosp(1);
			co(a + N);

			cosp(1);
			co(d);
			cosp(b);
			co(d);
			cosp(1);
			co(b + N);

			int mae = d;
			rep1(i, N) {
				if (i != a && i != b && i != c && i != d && i != 1) {
					cosp(mae);
					co(i);
					mae = i;
				}
			}
			cosp(mae);
			co(c + N);
			mae = c + N;
			cosp(mae);
			co(1 + N);
			mae = 1 + N;
			cosp(mae);
			co(d + N);
			mae = d + N;
			rep1(i, N) {
				if (i != a && i != b && i != c && i != d && i != 1) {
					cosp(mae);
					co(i + N);
					mae = i + N;
				}
			}
		}
		else {
			co("Yes");
			rep1(i, N / 2) {
				int k = i * 2;
				cosp(1);
				co(k);
				cosp(k);
				co(k + 1);
				cosp(1);
				co(k + N + 1);
				cosp(k + N);
				co(k + N + 1);
			}
			cosp(1 + N);
			co(2 + N);
		}
	}

	Would you please return 0;
}

Measured memory_bytes: 2816
void main() {
	auto A = ri, B = ri, C = ri, D = ri;
	(min(A, B) + min(C, D)).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def solve():
    N, M = map(int, input().split())
    adjL = [[] for _ in range(N)]
    for _ in range(M):
        A, B = map(int, input().split())
        adjL[A-1].append(B-1)
        adjL[B-1].append(A-1)
    Q = int(input())
    querys = []
    for iQ in range(Q):
        v, d, c = map(int, input().split())
        querys.append((iQ, v-1, d, c))

    dp = [[-1]*(11) for _ in range(N)]

    def rec(vNow, d, c, iQ):
        if dp[vNow][d] == -1:
            dp[vNow][d] = iQ
            if d > 0:
                rec(vNow, d-1, c, iQ)
                for v2 in adjL[vNow]:
                    rec(v2, d-1, c, iQ)

    for iQ, v, d, c in reversed(querys):
        rec(v, d, c, iQ)

    anss = [0] * N
    for v in range(N):
        if dp[v][0] != -1:
            anss[v] = querys[dp[v][0]][3]

    print('\n'.join(map(str, anss)))

solve()


Measured memory_bytes: 63020
import java.util.*;

public class Main {

    public static class Shop implements Comparable<Shop> {
        long price;
        long sum;

        @Override
        public int compareTo(Shop shop) {
            return (int)(this.price - shop.price);
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String in[];
        int row, idx;
        long m, ret;

        in = scanner.nextLine().split(" ");
        row = Integer.parseInt(in[0]);
        m = Integer.parseInt(in[1]);

        ArrayList<Shop> list = new ArrayList<>();
        for (int i = 0; i < row; i++) {
            in = scanner.nextLine().split(" ");
            Shop shop = new Main.Shop();
            shop.price = Integer.parseInt(in[0]);
            shop.sum = Integer.parseInt(in[1]);
            list.add(shop);
        }

        Collections.sort(list);
        ret = 0;
        for (int i = 0; i < row; i++) {
            Shop shop = list.get(i);
            if (m > shop.sum) {
                ret += shop.price * shop.sum;
                m -= shop.sum;
            } else {
                ret += shop.price * m;
                break;
            }
        }

        System.out.println(ret);
    }
}

Measured memory_bytes: 121088
#include<iostream>
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if (a*a+b*b == c*c)
  {
    cout << a*b/2 << endl;
  }
  else if (a*a+c*c==b*b)
  {
    cout << a*c/2 << endl;
  }
  else
  {
    cout << b*c/2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin>>n;
  int times=0;
  for(int i=1;i<=n;i++){
    int a,b;
    cin>>a>>b;
    if(a==b)
      times++;
    else
      times=0;
    if(times>=3){
      cout<<"Yes";
      return 0;}
  	}
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3600
x = int(input())

if x % 100 == 0:
    print(1)
    exit()

if x >= 2099:
    print(1)
    exit()

num = x // 100
diff = x % 100

for i in range(num+1):
    for j in range(num - i+1):
        for k in range(num - i - j+1):
            for l in range(num - i - j - k+1):
                for m in range(num - i - j - k - l+1):
                    ans = 1 * i + 2 * j + 3 * k + 4 * l + 5 * m
                    if ans == diff:
                        print(1)
                        exit()

print(0)


Measured memory_bytes: 3064
import           Control.Monad (replicateM)
import           Data.IntMap   (IntMap)
import qualified Data.IntMap   as M (empty, insert, lookup)
import           Data.Monoid   (Sum (Sum, getSum))

main :: IO ()
main = do
  [_n, m] <- map read . words <$> getLine
  pss <- replicateM m $ do
    [p, s] <- words <$> getLine
    pure (read p, read s)
  let (accepted, wrongs) = solve pss
  putStrLn $ unwords $ map show [accepted, wrongs]

data Result = AC | WA
  deriving (Read, Eq)

type Problem = Int

solve :: [(Problem, Result)] -> (Int, Int)
solve pss =
  let
    f :: (Problem, Result) -> IntMap (Bool, Int) -> IntMap (Bool, Int)
    f (p, r) acc =
      case (M.lookup p acc, r) of
        (Nothing, WA)          -> acc
        (Nothing, AC)          -> M.insert p (True, 0) acc
        (Just (False, wa), WA) -> acc
        (Just (False, wa), AC) -> M.insert p (True, 0) acc
        (Just (True, wa), WA)  -> M.insert p (True, succ wa) acc
        (Just (True, wa), AC)  -> M.insert p (True, 0) acc

    aggregated = foldr f M.empty pss
  in
    (\(sn, sm) -> (getSum sn, getSum sm)) $ foldMap (\(b, m) -> (Sum (if b then 1 else 0), Sum m)) aggregated


Measured memory_bytes: 45436
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int[] input = new int[10];
		boolean[] checked = new boolean[10];
		
		for(int i = 0; i < 10; i++){
			input[i] = Integer.parseInt(br.readLine());
			checked[i] = false;
		}
		
		for(int i = 0 ; i < 3; i++){
			int maxIndex = -1;
			int max = -1;
			
			for(int j = 0; j < 10; j++){
				if(input[j] > max && checked[j] == false){
					max = input[j];
					maxIndex = j;
				}
			}
			
			checked[maxIndex] = true;
			System.out.println(input[maxIndex]);
		}
		
	}

}

Measured memory_bytes: 24136
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b = map(int, input().split())
    L = list(range(2, 14)) + [1]
    idx_a = L.index(a)
    idx_b = L.index(b)
    if idx_a == idx_b:
        print("Draw")
    elif idx_a < idx_b:
        print("Bob")
    else:
        print("Alice")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
t = int(input())
mod = 10**9 + 7

dp = [1 for _ in range(t+5)]
dp[0] = 0
dp[1] = 0
dp[2] = 0

for i in range(0, t+1):
  for j in range(3, i-3+1):
    dp[i] += dp[j]
    dp[i] = dp[i] % mod
    
print(dp[t])

Measured memory_bytes: 64704
// やるだけだがこれ緑difなんすね
// N=M=1のときのアレでミスって1WA
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	N, M := nextInt(), nextInt()
	A, T := make([][]string, N), make([][]string, M)
	for i := 0; i < N; i++ {
		A[i] = chars(next())
	}
	for i := 0; i < M; i++ {
		T[i] = chars(next())
	}
	if N == 1 && M == 1 {
		if A[0][0] == T[0][0] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
		return
	}
	for i := 0; i < N-M; i++ {
		for j := 0; j < N-M; j++ {
			flag := true
			for y := 0; y < M; y++ {
				for x := 0; x < M; x++ {
					if A[i+y][j+x] != T[y][x] {
						flag = false
					}
				}
			}
			if flag {
				fmt.Fprintln(out, "Yes")
				return
			}
		}
	}
	fmt.Fprintln(out, "No")
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


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

int main(){
  vector<int> A(5);
  int Min=10;
  int Ans=0;
  for(int i=0; i<5; i++){
    cin >> A.at(i);
    if(A.at(i)%10!=0){
      Min=min(Min, A.at(i)%10);
      Ans+=A.at(i)+10-A.at(i)%10;
    }
    else{
      Ans+=A.at(i);
    }
  }
  if(Min!=10){
    Ans-=10-Min;
  }
  cout << Ans << endl;
}

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

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

   cout << a + a*a + a*a*a << endl;
   return 0;  
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
#define INF 1e9+7

int main(){

    string s;
    cin >> s;
    string str = "abcdefghijklmnopqrstuvwxyz";
    vector<int> a(26,0);
    REP(i,s.length()){
        a[s[i]-'a']++;
    }

    int alpha_num=0;
    REP(i,26){
        if(a[i]){
            alpha_num++;
        }
    }

    if(s.length() != 26){
        REP(i,26){
            if(!a[i]){
                s.push_back(str[i]);
                cout << s << endl;
                return 0;
            }
        }
    }

    string s2 = s;
    string ans;
    //cout << s2 << endl;

    if(!next_permutation(s2.begin(),s2.end())){
        cout << "-1" << endl;
    }else{
        //cout << s2 << endl;
        int count = 0;
        REP(i,s.length()){
            if(s[i] == s2[i]){
                count++;
            }else{
                break;
            }
        }
        ans = s2.substr(0,count+1);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int x,y,i,j;
    int a[]={1,3,5,7,8,10,12},b[]={4,6,9,11};
    cin>>x>>y;
    if(x==2||y==2) cout<<"No";
    else {
        for(i=0;i<6;i++){
            for(j=i+1;j<7;j++)
                if(x==a[i]&&y==a[j]){
                    cout<<"Yes"; return 0;
                }
        }
        for(i=0;i<3;i++){
            for(j=i+1;j<4;j++)
                if(x==b[i]&&y==b[j]){
                    cout<<"Yes"; return 0;
                }
        }
        cout<<"No";
    }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define d1(x) cout<<#x<<" "<<x<<endl;
#define d2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define d2i(x,y,i) cout<<#x<<i<<" "<<x<<" "<<#y<<i<<" "<<y<<endl;

#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))
#define  mat vector<vector<ll>>
#define pi 3.14159265358979323846
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve(){
  ll n;
  cin>>n;
  map<ll,ll>mp;
  ll x;
  fr(i,1,n+1)
  mp[i]++;
  fr(i,1,n){
    cin>>x;
    mp[x]++;
  }
   for(auto &xx:mp)
   cout<<xx.ss-1<<endl;

}





int main(){
    ll t=1;
//cin>>t;
    while(t--){
     solve();
   cout<<endl;
    }
    return 0;
}


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

const int N = 100;

char a[N][N], b[N][N];
int n, m;

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; ++ i){
		scanf("%s", a[i]);
	}
	for (int i = 0; i < m; ++ i){
		scanf("%s", b[i]);
	}
	for (int i = 0; i <= n - m; ++ i){
		for (int j = 0; j <= n - m; ++ j){
			bool flag = true;
			for (int ii = 0; ii < m; ++ ii){
				for (int jj = 0; jj < m; ++ jj){
					if (b[ii][jj] != a[i + ii][j + jj]){
						flag = false;
					}
				}
			}
			if (flag){
				return printf("Yes\n"), 0;
			}
		}
	}
	return printf("No\n"), 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    S = in_s()

    ts = S
    while ts.count('()'):
        ts = ts.replace('()', '')

    S = '(' * ts.count(')') + S + ')' * ts.count('(')
    print(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
	static int count = 0;
	static int max = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		max = sc.nextInt();
		calDigit(8, 0);
		System.out.println(count);
	}

	private static void calDigit(int digit, int num) {
		for(int i = 0; i < 10; i ++) {
			int crt = num * 10 + i;
			if(crt > max) {

			}else if(i == 0 || i == 3 || i == 5 || i == 7){
				if(digit > 0) {
					calDigit(digit - 1, crt);
				}else {
					String st = String.valueOf(crt);
					if(st.indexOf("0") == -1 && st.indexOf("3") != -1 && st.indexOf("5") != -1 && st.indexOf("7") != -1) {
						count ++;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 37144
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<math.h>
using namespace std;

int main(){

    int H, W;
    int x = 0;
    int y = 0;

    cin >> H >> W;

    while(H != 0 && W != 0){
        while(y != H){
            if(y%2 == 0){
            while(x != W){
                if(x%2 == 0){
                    cout << '#';
                    x++;
                }
                else if(x%2 == 1){
                    cout << '.';
                    x++;
                }
            }
            }
            else if(y%2 == 1){
            while(x != W){
                if(x%2 == 0){
                    cout << '.';
                    x++;
                }
                else if(x%2 == 1){
                    cout << '#';
                    x++;
                }
            }           
            }
            cout << endl;
            x = 0;
            y++;
        }
        cout << endl;
        x = 0;
        y = 0;
        cin >> H >> W;
    }

    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
int ans=0;
int a[10000];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<k;i++)
		ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

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

class Program {
	static string ReadLine() { return Console.ReadLine(); }
	static int ReadInt() { return int.Parse(ReadLine()); }
	static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
	static string[] ReadStrings() { return ReadLine().Split(); }

	static void Main() {
		var ls = new List<int>();
		for (int i = 0; i < 10; i++) {
			ls.Add(ReadInt());
		}

		ls.Sort();
		ls.Reverse();
		foreach (var x in ls.Take(3)) {
			Console.WriteLine(x);
		}
	}
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}
/*
    (tx-sx+ty-sy)*2+(tx-sx+ty-sy+4)*2
*/

void solve(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    /*
    {
        string s;
        cin >> s;
        cout << (tx-sx+ty-sy)*2+(tx-sx+ty-sy+4)*2 << endl;
        cout << s.size() << endl;
    }
    */
    cout << string(tx-sx,'R') << string(ty-sy,'U');
    cout << string(tx-sx,'L') << string(ty-sy,'D');
    
    cout << string(1,'D');
    cout << string(tx-sx,'R');
    cout << string(1,'R');
    cout << string(ty-sy+1,'U');
    cout << string(1,'L');

    cout << string(1,'U');
    cout << string(tx-sx,'L');
    cout << string(1,'L');
    cout << string(ty-sy+1,'D');
    cout << string(1,'R');

    cout << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    ll N, D;
    cin >> N >> D;
    int ans = 0;
    rep(i, N) {
        ll X, Y;
        cin >> X >> Y;
        if ((X * X + Y * Y) <= (D * D)) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3628