akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='x')cnt++;
    }
    if(cnt<=7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

  UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};



int main() {
  int n,m;
  cin>>n>>m;
  UnionFind UF(n);
  for (int i = 0; i < m; i++){
        int A, B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A, B);
  }
  
  set<int> roots;
  int count=0;
  
  rep(i,0,n){
    if(roots.count(UF.root(i))==0){
      roots.insert(UF.root(i));
      count++;
    }
  }
  cout<<count-1;
}

Measured memory_bytes: 7584
import sys
from operator import itemgetter
from collections import Counter
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    N = ii()
    S = Counter()
        
    for s in [input().rstrip() for _ in range(N)]:
        s = list(s)
        s.sort()
        s = "".join(s)
        S[s] += 1

    ans = 0
    for n in S.values():
        ans += (n * (n-1)) // 2

    print(ans)

    return

main()


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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18+7;
const int mxn = 3e5+7;

set<int>rw, cw;
int row[mxn], col[mxn], rowsum[mxn], colsum[mxn];
set<pii>st;

int main(){
	setIO();
	int r, c, m, mxr=0, mxc=0;
	cin >> r >> c >> m;
	for (int i = 0; i < m; i++){
		cin >> row[i] >> col[i];
		rowsum[row[i]]++;
		colsum[col[i]]++;
		mxr = max(mxr, rowsum[row[i]]);
		mxc = max(mxc, colsum[col[i]]);
		st.insert(mp(row[i], col[i]));
	}
	for (int i = 0; i < m; i++){
		if (rowsum[row[i]] == mxr)
			rw.insert(row[i]);
		if (colsum[col[i]] == mxc)
			cw.insert(col[i]);
	}
	for (int i : rw){
		for (int j : cw){
			if (!st.count(mp(i, j))){
				cout << mxc+mxr << endl;
				return 0;
			}
		}
	}
	cout << mxr+mxc-1 << endl;
}

Measured memory_bytes: 50424
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
    if i >= K:
        ans += 1/N
    else:
        x = 0
        while i < K:
            i *= 2
            x += 1
        ans += (1/N) * (1/2)**x
print(ans)

Measured memory_bytes: 9340
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()
#define tpl(...) make_tuple(__VA_ARGS__)

typedef long long LL;
typedef pair<int, int> P; typedef pair<int, P> IP; typedef pair<P, P> PP;
typedef vector<int> Array; typedef vector<vector<int> > Array2;
typedef vector<LL> LArray; typedef vector<P> PArray; typedef vector<string> SArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

inline int getInt() { int itiv; return (cin >> itiv, itiv); }
template <typename T> void readAll(vector<T>& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i]; }
template <typename T, typename U> void readAll(vector<pair<T, U> >& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i].first >> vec[i].second; }
template < typename T > inline string toString( const T &a ){ ostringstream oss; oss << a; return oss.str(); };
inline bool between(int min, int max, int n) { return min <= n && n <= max; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

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


int main(void)
{
	ios::sync_with_stdio(false);
	int h, w, n;
	while(cin >> h >> w >> n && n)
	{
		SArray stage(h);
		PArray cheese(n + 1);
		for (int i = 0; i < h; i++)
		{
			cin >> stage[i];
			for (int j = 0; j < w; j++)
			{
				char c = stage[i][j];
				if(c == 'S')
				{
					cheese[0] = P(i, j);
				}
				if(inRange(10, c - '0'))
				{
					cheese[c - '0'] = P(i, j);
				}
			}
		}

		int ans = 0;
		vector<vector<bool>> visited(h, vector<bool>(w));
		for (int i = 0; i < n; i++)
		{
			P start = cheese[i];
			P goal = cheese[i + 1];

			for (int i = 0; i < h; i++)
			{
				for (int j = 0; j < w; j++)
				{
					visited[i][j] = false;
				}
			}

			queue<IP> que;
			que.push(IP(0, start));
			while (!que.empty())
			{
				IP ip = que.front(); que.pop();
				P p = ip.second;
				visited[p.first][p.second] = true;

				if(p == goal)
				{
					ans += ip.first;
					break;
				}

				for (int j = 0; j < 4; j++)
				{
					int nr = p.first + dr[j], nc = p.second + dc[j];
					if(!inRange(h, nr) || !inRange(w, nc) || stage[nr][nc] == 'X' || visited[nr][nc]) continue;
					visited[nr][nc] = true;
					que.push(IP(ip.first + 1, P(nr, nc)));
				}
			}
		}

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

Measured memory_bytes: 2452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;

class SyntaxAnalysis
{
public:
    SyntaxAnalysis(const string& S) : S{S} {}
    ll Expression() { return pos = 0, expression(); }

private:
    static ll sf(const ll n, const ll k) { return k >= 64 ? 0 : n >> k; }
    static ll sq(const ll n) { return n * n % MOD; }
    ll number()
    {
        ll ans = 0;
        for (; pos < S.size() and isdigit(S[pos]); pos++) { ans = ans * 10 + S[pos] - '0'; }
        return ans;
    }
    ll factor()
    {
        if (S[pos] == '<') {
            ll ans;
            return pos++, ans = sq(expression()), pos++, ans;
        } else {
            return number();
        }
    }
    ll term()
    {
        ll ans = factor();
        for (ll f = 0; pos < S.size() and S[pos] == '%';) { pos++, f = factor(), ans = sf(ans, f); }
        return ans;
    }
    ll expression() { return term(); }
    int pos = 0;
    string S;
};

int main()
{
    while (true) {
        auto input = []() {
            string s;
            getline(cin, s);
            string ans;
            for (ll i = s.size() - 1, st = 0, v = false; i >= 0; i--) {
                const char c = s[i];
                if (isdigit(c)) { ans.push_back(c), v = true; }
                if (c == '>') {
                    if (v) {
                        ans.push_back('%'), v = false, i--;
                    } else {
                        ans.push_back('>'), st++;
                    }
                }
                if (c == '<') { ans.push_back('<'), v = true, st--; }
            }
            reverse(ans.begin(), ans.end());
            return ans;
        };
        const string S = input();
        if (S.empty()) { break; }
        SyntaxAnalysis sy(S);
        cout << sy.Expression() << endl;
    }
    return 0;
}



Measured memory_bytes: 5860
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,m,q;
int v[100010],d[100010],c[100010];
int co[100010],r[100010];
vector<int> G[100010];

void dfs(int s,int l,int a){
  if(co[s]==0)co[s]=a;
  if(r[s]>=l) return;
  
  r[s]=max(r[s],l);
  //cout << s << " " << r[s] << " " << co[s] << endl;
  for(int t:G[s]){
    if(r[t]<=l-1){
      dfs(t,l-1,a);
    }
  }
}

void solve(){
  cin >> n >> m;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  cin >> q;
  rep(i,q){
    cin >> v[i] >> d[i] >> c[i];
  }
  per(i,q){
    dfs(v[i]-1,d[i],c[i]);
  }
  rep(i,n){
    cout << co[i] << endl;
  }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 8440
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
  int k, n, a[200010], len = 0;
  scanf("%d%d", &k, &n);
  for(int i=0;i<n;i++) scanf("%d", &a[i]);
  for(int i=0;i<n-1;i++) {
    len = max(len, a[i+1] - a[i]);
  }
  len = max(len, k - a[n-1] + a[0]);
  printf("%d", k - len);
  return 0;
}

Measured memory_bytes: 896
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N=intput()
L=[]
for i in range(N):
    x,l=mint() 
    L.append([x+l,l])
L.sort()
tmp = -INF
ans = 0
for l in L:
    if l[0]-2*l[1]>=tmp:
        ans+=1
        tmp=l[0]
print(ans)

Measured memory_bytes: 89356
#include<stdio.h>
int main(){
  int n,s[10000],q,t[500],c=0,i,j,k;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&s[i]);
  scanf("%d",&q);
  for(j=0;j<q;j++){ 
    scanf("%d",&k);
    for(i=0;i<n;i++){
      if(s[i]==k){
	c++;
	break;
      }
    }
  }  
  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    vector<string> grid(h);
    rep(i,h) cin >> grid[i];
    bool ok = 1;
    rep(i,h){
        rep(j,w){
            if (grid[i][j] == '#'){
                rep(x,h){
                    rep(y,w){
                        if (grid[x][y] == '#' && ((x > i && y < j) || (x < i && y > j))) ok = 0;
                    }
                }
            }
        }
    }
    if (ok) PRINT("Possible");
    else PRINT("Impossible");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define endll '\n'

//container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i<=(a);--i)
#define RREP(i,n) RFOR(i,n,0)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";

const int INF = 1e9;

int n,m;
const int _N = 200000;

VI e[_N];
int dist[_N];

int main() {
	cin >> n >> m;
	REP(i,m){
		int a,b;
		cin >> a >> b;
		--a;--b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	REP(i,n)dist[i]=3;
	dist[0] = 0;
	queue<int> q;
	q.push(0);
	while(!q.empty()){
		if(dist[n-1]<3)break;
		int i= q.front();
		q.pop();
		EACH(j, e[i]){
			int to = *j;
			int nd = dist[i]+1;
			if(nd < dist[to]){
				dist[to] = nd;
				q.push(to);
			}
		}
	}
	cout << (dist[n-1] < 3 ? "POSSIBLE" : "IMPOSSIBLE") << endll;
}


Measured memory_bytes: 13168
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
#include <cmath>
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 ALL(v) v.begin(),v.end()
#define mod 1000000007


int main(){
  string s;
  ll n,q;
  cin >> n >> q;
  ll b[100010]={0};
  cin >>s;
  ll res=0;
  rep(i,n){
    if(i>0)if(s[i-1]=='A'&&s[i]=='C'){
      res++;
    }
    b[i]=res;
  }
  ll l,r;
  ll ans[100010]={0};
  rep(i,q){
    cin >> l >> r;
    ans[i]=b[r-1]-b[l-1];
  }
  //rep(i,n)cout << b[i]<<" ";
  rep(i,q)cout << ans[i]<<endl;

}


Measured memory_bytes: 2560
// Author: Sayantanu
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
vector<vector<int>> mat(1001,vector<int>(1001,0));
const int mod = 1e9 + 7;
vector<vector<ll>> dp(1001,vector<ll>(1001,-1));
ll answer(int x,int y){
//    cout<<x<<" "<<y<<endl;
    if(x==1 and y==1){
        dp[x][y] = 1;
        return 1;
    }
    if(x<1 or y<1){
        return 0;
    }
    if(dp[x][y]!=-1){
        return dp[x][y];
    }
    int x1 = x-1;
    ll ans = 0;
    if(mat[x1][y]==0 and x1>=1){
        ans = (ans + answer(x1,y))%mod;
    }
    int y1 = y-1;
    if(mat[x][y1]==0 and y1>=1){
        ans = (ans + answer(x,y1))%mod;
    }
    dp[x][y] = ans;
    return ans;
}

int main() {
    int w,h;
    cin>>w>>h;
    char c;
    for(int i=1;i<=w;i++){
        for(int j=1;j<=h;j++){
           cin>>c;
           if(c=='#')
               mat[i][j] = 1;
        }
    }
    ll a = answer(w,h);
    cout<<a<<endl;
    return 0;
}

Measured memory_bytes: 15576
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		ArrayList<Integer> list =new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(),ans=0;
		
		for(int i=0;i<N;i++) 
			list.add(sc.nextInt());
		Collections.sort(list);
		for(int i=0;i<N;)
		{
			int target  = list.get(i);
			int count = 0;
			while(i<N && list.get(i)==target)
			{
				count ++; i++;
			}
			ans +=  count % 2;
			
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 64628
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;


int main() {
	
	int w, h;



	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0)break;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if ((i + j) % 2 == 0)printf("#");
				else printf(".");

			}
			printf("\n");
		}
		printf("\n");
	}


	//system("pause");
	return 0;
}


Measured memory_bytes: 3036
N,K=map(int,input().split())
*H,=map(int,input().split())

D=[float("inf")]*N
D[0]=0
D[1]=abs(H[1]-H[0])
for i in range(2,N):
  # print(i, "before:",D)
  #  print(i,i-1,i-K, max(1, i-K))
  D[i]=min(abs(H[i]-H[k])+D[k] for k in range(max(0,i-K),i))
  # print(i, "after:",D)

print(D[-1])

Measured memory_bytes: 20596
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, S: "List[str]", P: "List[int]"):
    SP = []
    for i, (s, p) in enumerate(zip(S, P)):
        SP.append([i+1, s, p])
    SP.sort(key=lambda x: x[2], reverse=True)
    SP.sort(key=lambda x: x[1])
    for i, s, p in SP:
        print(i)


def main():

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


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

main() {
	long long int n, m, k = 0;
	char str[5];
	scanf("%lld%lld%lld",&n,&m,&k);
	if (k <= m) { printf("delicious"); }
	else if (k - m > n) { printf("dangerous"); }
	else { printf("safe"); }
	

}

Measured memory_bytes: 128
import sys
import math
if sys.version_info.minor >= 5:
    from math import gcd
else:
    from fractions import gcd


def inv(x, mod):
    return pow(x, mod-2, mod)


def lcm(arr, mod = 10 ** 9 + 7):
    ret = 1
    for a in arr:
        ret = ret * a // gcd(ret, a)
    return ret

mod = 10 ** 9 + 7

N = int(input())
A = [int(x) for x in input().split()]
a = lcm(A)
print(sum(a // x for x in A) % mod)


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

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

    rep(i, int(s.size()))
    {
        int ascii_no = (int)s.at(i) + n;
        if (ascii_no <= 90)
        {
            cout << (char)ascii_no;
        }
        else
        {
            ascii_no = ascii_no - 90 + 64;
            cout << (char)ascii_no;
        }
    }
    cout << endl;
}

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

int main() {
  int n,x2,x3;
  double x1;
  cin >> n;

  x1 = n / 1.08;
  //cout << x1 << endl;
  x2 = (x1 * 10 + 9) / 10;
  //cout << x2 << endl;
  x3 = x2 * 1.08;
  //cout << x3 << endl;
  
  if(x3 == n){
    cout << x2 << endl;
  }
  else {
    cout << ":(" << endl;
  }
}

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

using namespace std;

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

int h, w;
vector<string> f;

bool has_mine(int y, int x) {
    return y>=0 && y<h && x>=0 && x<w && f[y][x]=='#';
}

int main() {
    cin >> h >> w;
    vector<string> g;
    for(int i=0; i<h; i++) {
        string s;
        cin >> s;
        f.push_back(s);
        g.push_back(string(w, '0'));
    }

    for(int y=0; y<h; y++) for(int x=0; x<w; x++) {
        if(has_mine(y, x)) {
            g[y][x] = '#';
        } else {
            for(int i=0; i<8; i++) {
                if(has_mine(y+dy[i], x+dx[i])) g[y][x]++;
            }
        }
    }

    for(auto i=g.begin(); i!=g.end(); ++i)
        cout << *i << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector

int n,x;
std::deque<int>ans;
set<int>dc;
signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    cin>>n>>x;
    if(x==1 or x==2*n-1)
    {
        cout<<"No";
        return 0;
    }
    cout<<"Yes\n";
    if(n==2)
    {
        cout<<"1 2 3";
        return 0;
    }
    

    ans.push_back(x);
    
    if(x==2)
    {
        ans.pb(1);
        ans.push_front(3);
        ans.push_back(4);
    }
    else
    {
        ans.pb(x+1);
        ans.pb(x-2);
        ans.push_front(x-1);
    }
    
    int c = 0;
    
    forn(i,1,2*n-1)dc.insert(i);
    for(auto i : ans)
    {
        dc.erase(i);
    }
    
    while(dc.size())
    {
        c++;
        int x = *dc.begin();
        dc.erase(x);
        if(c%2)ans.push_front(x);
        else ans.pb(x);
    }
    for(auto i: ans)cout<<i<<" ";
    


    return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 10880
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;
const int maxn=2e5+10;

int a[maxn],b[maxn],c[maxn];
int n;

int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	b[0]=a[0];
	for(int i=1;i<n;i++) b[i]=b[i-1]^a[i];
	c[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--) c[i]=c[i+1]^a[i];
	for(int i=0;i<n;i++){
		int val=0;
		if(i!=0) val=val^b[i-1];
		if(i!=n-1) val=val^c[i+1];
		val^=(a[i]^a[i]);
		cout<<val<<" ";
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 5904
/*
Hey there stalker....

█▀▀▄░░░░░░░░░░░▄▀▀█
░█░░░▀▄░▄▄▄▄▄░▄▀░░░█
░░▀▄░░░▀░░░░░▀░░░▄▀
░░░░▌░▄▄░░░▄▄░▐▀▀
░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█
░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█
▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█
█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀
░▀▄░░▀░░▀▀▀░░▀░░░▄█▀
░░░█░░░░░░░░░░░▄▀▄░▀▄
░░░█░░░░░░░░░▄▀█░░█░░█
░░░█░░░░░░░░░░░█▄█░░▄▀
░░░█░░░░░░░░░░░████▀
░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀

Like what you see?
*/
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define present(container, element) (container.find(element) != container.end()) /* For set n maps */
#define cpresent(container, element) (find(all(container),element) != container.end()) /* For vectors */
#define all(a)      (a).begin(),(a).end()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define F           first
#define S           second
#define I           insert
#define sz(x)       (ll)x.size()
#define rep(i,a,b)    for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  i=a;i>b;i--)
#define trav(a, x) 	for(auto& a : x)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lcase(a) (char)tolower(a)
#define ll long long int
#define lld long double
#define endl "\n"
#define PI 3.14159265358979323844
#define MOD 1000000007
#define max(a, b) (a < b ? b : a)
#define min(a, b) ((a > b) ? b : a)
#define mod 1e9 + 7
const int N = 1e5 + 5;
/*	For Debugging	*/
#define DEBUG 		cerr<<"\n>>>I'm Here<<<\n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x)  cerr << #x << " is " << x << endl;

int32_t main()
{
   IOS

    int TESTS=1;
    //cin >> TESTS;
    while (TESTS--)
    {
    	ll h,n;
    	cin>> h >> n;
    	vi v(n);
    	rep(i,0,n)
    	{
    		cin>> v[i];
    	}
    	sort(v.begin(),v.end());
    	rep(i,0,n)
    	{
    		h-=v[i];
    	}
    	if(h<=0)
		{
			cout<< "Yes"<< endl;
		}
		else
		{
			cout<< "No"<< endl;
		}




    }
    return 0;
}


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

import heapq
que = []
for a in A:
    heapq.heappush(que, -1 * a)

for i in range(M):
    target = que[0]
    if target % 2 == 1:
        target = target + 1
    heapq.heapreplace(que, target // 2)

print(sum(que) * -1)


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

int main(){
int n;cin>>n;
vector<long long >v(n);
for(int i=0;i<n;i++)cin>>v[i];
map<long long,int> m;
for(int i=0;i<n;i++){
     m[v[i]]=(m[v[i]]+1)%2;
}
int ans=0;
for(auto it=m.begin();it!=m.end();it++){
    ans+=it->second;
}
cout<<ans;
}

Measured memory_bytes: 7296
#include<stdio.h>
int main(void){
    int a,b,c,d;
    int h1,h2,k1,k2;
    int h3,k3;

    scanf("%d%d%d%d",&h1,&h2,&k1,&k2);
    scanf("%d%d%d%d",&a,&b,&c,&d);
    h3=a*h1+b*h2+c*(h1/10)+d*(h2/20);
    k3=a*k1+b*k2+c*(k1/10)+d*(h2/20);

    if(h3>k3) printf("hiroshi\n");
    else if(h3==k3) printf("even\n");
    else printf("kenjiro\n");

    return 0;
}

Measured memory_bytes: 584
def func(k, a):
    bit = [0 for _ in range(50)]
    for i in range(len(a)):
        binnedA = bin(a[i])[2:]
        _a = [int(binnedA[_i]) for _i in range(len(binnedA))]
        _a.reverse()
        for j in range(len(_a)):
            bit[j] += _a[j]
        # print(bit)
    best = [0 if bit[i] > len(a) - bit[i] else 1 for i in range(len(bit))]
    # print("best:{}".format(best))
    upperBin = bin(k)[2:]
    upper = [int(upperBin[_i]) for _i in range(len(upperBin))]
    upper.reverse()
    for i in range(len(bit)-len(upper)):
        upper.append(0)

    limited = True
    upper.reverse()
    best.reverse()
    # print("upper:{}".format(upper))
    # print("best:{}".format(best))
    for i in range(len(upper)):
        if limited:
            if upper[i] == 1:
                if best[i] == 0:
                    best[i] = 0
                    limited = False
                    # print("unlock:{}".format(i))
                else:
                    best[i] = 1
            else:
                best[i] = 0
    _sum = 0
    best.reverse()
    # print("best:{}".format(best))
    # print("bit:{}".format(bit))
    for i in range(len(best)):
        if best[i] == 0:
            _sum += bit[i] * (2 ** i)
        else:
            _sum += (len(a) - bit[i]) * (2 ** i)
    return _sum
"""
print("func(7, [1, 6, 3]):{}".format(func(7, [1, 6, 3])))
print("func(9, [7, 4, 0, 3]):{}".format(func(9, [7, 4, 0, 3])))
print("func(0, [1000000000000]):{}".format(func(0, [1000000000000])))
"""
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
print(func(k, a))


Measured memory_bytes: 14596
def kakuketa(x):
    s = 0
    for i in range(len(str(x))):
        s += x%10
        x = int(x/10)
    return s

def kakuketaa(x):
    s = 0
    for i in range(len(str(x))):
        s += int(str(x)[i])
    return s


def main():
    N, A, B = list(map(int, input().split()))

    count = 0
    for i in range(N+1):
        sum = kakuketaa(i)
        if A <= sum <= B:
            count += i
    print(count)

main()

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

int main(){
    int number;
    cin >> number;
    int MyBoss[number];
    MyBoss[0] = 0;
    for(unsigned i = 1; i < number; i++) {
        cin >> MyBoss[i];
    }
    int MyStaff[number];
    for(unsigned i = 0; i < number; i++) {
        MyStaff[i] = 0;
    }
    for(unsigned i = 1; i < number; i++) {
        MyStaff[MyBoss[i]-1] += 1;
    }
    for(unsigned i = 0; i < number; i++) {
        cout << MyStaff[i] << endl;
    }
    return 0;
}

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

int main(void) {
    int n; cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] && b[i] == c[i]) ans += 0;
        else if (a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) ans += 1;
        else ans += 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
while True:
    try:
	n = input()
	if n ==	0:break
        L = [0]	* 10
	for i in range(n):
            L[input()] += 1
    	for i in range(10):
            print "*" *	L[i] if	L[i] !=	0 else "-"
    except SyntaxError:pass

Measured memory_bytes: 4528
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;

// 最大積載量PのトラックK台に幾つの荷物を積めるのかを返す
int countLoad(ll p,int k,vector<int> w){
    int count = 0;
    
    for(int i = 0; i < k;i++){
        ll sum = 0;
        while(p >= sum + w[count]){
            sum += w[count];
            count++;
            if(count == w.size()){
                return count;
            }
        }
    }

    return count;
}

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

    ll n,k;
    cin >> n >> k;
    vector<int> w(n);
    for(int i = 0; i < n;i++){
        cin >> w[i];
    }

    int v;

    ll left = 0;
    ll right = 100000*10000;
    ll p;
    while(right - left > 1){
        p = (left + right ) / 2; 
        v = countLoad(p,k,w);
        if(v >= n) right = p; 
        else left = p;
    }

    cout << right << endl;

    return 0;
}


Measured memory_bytes: 3700
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
struct Dice {
	int s[6];
	void roll(char c) {
		int b;
		if (c == 'E') {
			b = s[0];
			s[0] = s[3];
			s[3] = s[5];
			s[5] = s[2];
			s[2] = b;
		}
		if (c == 'W') {
			b = s[0];
			s[0] = s[2];
			s[2] = s[5];
			s[5] = s[3];
			s[3] = b;
		}
		if (c == 'N') {
			b = s[0];
			s[0] = s[1];
			s[1] = s[5];
			s[5] = s[4];
			s[4] = b;
		}
		if (c == 'S') {
			b = s[0];
			s[0] = s[4];
			s[4] = s[5];
			s[5] = s[1];
			s[1] = b;
		}
		if (c == 'R') {
			b = s[1];
			s[1] = s[2];
			s[2] = s[4];
			s[4] = s[3];
			s[3] = b;
		}
	}
	int top() {
		return s[0];
	}
	int right() {
		return s[2];
	}
	int left() {
		return s[3];
	}
	int front() {
		return s[1];
	}
};

int main(){
	Dice d;
	int i;
	for (i = 0; i < 6; i++) {
		cin >> d.s[i];
	}
	int n; cin >> n;
	while (n--) {
		int a, b; cin >> a >> b;
		if (d.left() == a) d.roll('E');
		if (d.right() == a) d.roll('W');
		while (d.top() != a) d.roll('N');
		while (d.front() != b) d.roll('R');
		cout << d.right() << endl;
	}
  return 0;
}



Measured memory_bytes: 3096
x1, y1, x2, y2 = [int(v) for v in input().split()]

x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1)
x4 = x1 - (y2 - y1)
y4 = y1 + (x2 - x1)
print('{0} {1} {2} {3}'.format(x3, y3, x4, y4))

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
  int t;
  t=1;
  while(t--){
long long int n;
cin>>n;

long long int ans =0;

while(n!=1)
{
  ///cout<<"n is "<<n<<endl;
  n=n/2;;
  ans++;
  ans = ans*2;
}

cout<<ans+1 <<endl;

}
}


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

int main(){
	int a,b;
	cin>>a>>b;
	int c=0;
	for(int i=0;i<=a;i++){
		int d=a-i;
		if(i*2+d*4 == b)c=1;
	}
	if(c==1){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

	return (0);
}


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

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

score = 0
for i in range(n):
  score += B[A[i] - 1]
  if i != 0 and A[i] - A[i - 1] == 1:
    score += C[A[i] - 2]
print(score)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int N; cin >> N;

    bool ans = false;
    for (int i = 0; i*7 <= N; i++) {
        if ((N-i*7)%4 == 0) {
            ans = true;
            break;
        } 
    }

    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
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;}
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
int main(){
	double n;
	cin >> n;
	cout << shosu(10) << n*n*pi << " " << n*2.0*pi << endl;
}

Measured memory_bytes: 1288
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;


public class Main {
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		long A=sc.nextLong();
		long B=sc.nextLong();
		long N=sc.nextLong();
		long c=0;
		if (N>=B-1) {
			c=B-1;
		}else {
			c=N;
		}
		System.out.println((A*c)/B);
	}
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 32504
use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(n: usize, a: [usize; n - 1]);
    let mut a_v = vec![0; n];
    for v in a {
        a_v[v - 1] += 1;
    }

    let ans = a_v.iter().take(n).join("\n");
    print!("{}", ans);
}


Measured memory_bytes: 5568
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	string s;
	cin>>s;
	rep(i,3)if(s[i]=='1')s[i]='9';
	else if(s[i]=='9')s[i]='1';
	
	cout<<s<<endl;
}





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

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

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

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

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

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

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

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


fn main() {
    input! {
        s: chars,
    }
    let ss: String = s.into_iter().collect();
    let sunny = String::from("Sunny");
    let cloudy = String::from("Cloudy");
    let rainy = String::from("Rainy");
    if ss == sunny {
        println!("Cloudy");
    } else if ss == cloudy {
        println!("Rainy");
    } else {
        println!("Sunny");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N, C, K;
	cin >> N >> C >> K;
	vector<int> B(N);
	for (int i = 0; i < N; i++)
		cin >> B[i];
	sort(all(B));
	int S = B[0];
	int ans = 1, num = 1;
	for (int i = 1; i < N; i++)
	{
		if (B[i]-S > K || num == C)
		{
			S = B[i];
			num = 1;
			ans++;
			continue ;
		}
		num++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <string.h>
#include <memory.h>

using namespace std;

const int maxn = 100;

int A, B;
bool tab[maxn][maxn];

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

	cin >> A >> B;
	memset(tab, 0, sizeof(tab));
	
	for (int i = 0; i < 25; i++)
		memset(tab[i], 1, sizeof(tab[i]));

	int wn = 1, bn = 1;
	bool flag = false;
	if (wn == A)
		flag = true;
	for (int i = 0; i <= 24; i += 2)
	{
		if (flag)
			break;
		for (int j = 0; j < 99; j += 2)
		{
			tab[i][j] = 0;
			wn += 1;
			if (wn == A)
			{
				flag = true;
				break;
			}
		}
	}

	flag = false;
	if (bn == B)
		flag = true;
	for (int i = 26; i <= 48; i += 2)
	{
		if (flag)
			break;
		for (int j = 0; j < 100; j += 2)
		{
			tab[i][j] = 1;
			bn++;
			if (bn == B)
			{
				flag = true;
				break;
			}
		}
	}

	cout << 100 << " " << 100 << "\n";
	for (int i = 0; i < 100; i++)
	{
		for (int j = 0; j < 100; j++)
		{
			if (tab[i][j])
				cout << "#";
			else
				cout << ".";
		}
		cout << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
'use strict';
(function(input){
  input=input.trim().split(/\n+/);
  const N=input.shift()-0;
  input=input.map(str=>str.split(/\s+/).map(x=>x-0));
  input.sort((a,b)=>(a[1]-b[1]));
  let sum=0
  for(let i=0;i<N;i++){
    sum+=input[i][0];
    if(sum<=input[i][1]){
      continue;
    }else{
      console.log('No');
      return;
    }
  }
  console.log('Yes');
})(require('fs').readFileSync('/dev/stdin','utf8'));


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

int main()
{
    int A, B;
    cin >> A >> B;
    int ans = A - 2 * B;
    if (ans < 0) {
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define dump(x)  cout << #x << " = " << (x) << endl
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

int main(){
    ll n;
    ll h[100005];
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> h[i];
    }
    ll maxCnt = 0;
    ll cnt = 0;
    for (ll i = 0; i < n-1; i++) {
        if(h[i] >= h[i+1]){
            cnt++;
        }else{
            cnt = 0;
        }
        maxCnt = max(maxCnt, cnt);
    }
    cout << maxCnt << endl;
    return 0;
}

Measured memory_bytes: 4252
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;



int main(int argc, char *args[]) {
	int A, B;
	cin >> A >> B;
	if (A <= 8 && B <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}


Measured memory_bytes: 256