akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>

using namespace std;

template <typename T>
class MyStack
{
private:
    const static size_t kStackMax = 100;
    T buff[kStackMax]{};
    int stackCnt;

public:
    MyStack(void) :
        stackCnt(0)
    {};

    void push(const T& item) {
        if (stackCnt == kStackMax){
            return;
        }
        buff[stackCnt] = item;
        stackCnt++;
        return;
    }

    T pop(void) {
        if (stackCnt == 0) {
            return T();
        }
        stackCnt--;
        return buff[stackCnt];
    }

    bool isEmpty(void) {
        return (stackCnt == 0) ? true : false;
    }
};


int main(void)
{
    MyStack<long> values;
    string str;


    getline(cin, str);
    stringstream ss(str);
    string word;
    while (getline(ss, word, ' ')) {
        if ((word.length() == 1) &&
            (word.at(0) == '+' || word.at(0) == '-' || word.at(0) == '*')) {
            // 演算子
            long valueB = values.pop();
            long valueA = values.pop();
            long ans = 0;

            if (word.at(0) == '+') {
                ans = valueA + valueB;
            } else if (word.at(0) == '-') {
                ans = valueA - valueB;
            } else {
                ans = valueA * valueB;
            }
            values.push(ans);
        } else {
            // 数値は値を積む
            values.push(atoi(word.c_str()));
        }
    }

    std::cout << values.pop() << "\n";
    return 0;
}


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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> s;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 10) {
      s.push_back(a);
    }
    sum += a;
  }

  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  while(s.size() > 0 && sum % 10 == 0) {
    sum -= s.back();
    s.pop_back();
  }

  if (sum % 10 == 0) {
    cout << 0 << endl;
  } else {
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
from collections import Counter
c=[0]
for i in a:
    c.append((c[-1]+i)%m)
cc=Counter(c)
ans=0
for i in cc.values():
    ans+=i*(i-1)//2
print(ans)


Measured memory_bytes: 16552
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
using namespace std;
typedef pair<int,int>pii;
int main(){
	int x,y;
	cin>>x>>y;
	int a=x*y,b=2*a,c=3*a;
	bool flg=(a&1)||(b&1)||(c&1);
	cout<<(flg==0?"No":"Yes")<<endl;
	return 0;
}


Measured memory_bytes: 256
//  Author: Tanuj Johal
//  It's a show time, Enjoy your everyday.

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll          long long
#define fio         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define vi          vector<ll>
#define pp          push_pop
#define pll         pair<ll,ll>
#define in          insert
#define ini(a,n)    memset(a,n,sizeof(a))
#define ff          first
#define ss          second
#define inf         1e18
#define all(p)      p.begin(), p.end()
#define que_max     priority_queue <int>
#define que_min     priority_queue <int, vi, greater<int>>
#define print(a)    for(auto i:a){cout<<i<<" ";}
#define print1(a)   for(auto i:a){cout<<i.ff<<" "<<i.ss<<endl;}
#define run_time cout << "\nTIME = " << clock() - tt << endl; tt = clock();

typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> Set;
unordered_map<ll,set<ll>> g;
unordered_map<ll,ll> vis;
ll tt;
const ll mod = 1e9+7;

ll power(ll x,ll y,ll p){ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;}
const ll N = 2e5 + 10;
ll dx[4]={-1, +1, 0, 0};
ll dy[4]={0, 0, +1, -1};
bool imp = false;


void solve()
{

    ll n; cin>> n;
    if(n >= 30)
        cout << "Yes\n";
    else
        cout << "No\n";

}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    fio
//    precompute();

    int t=1;
    if(imp) cin>>t;
    tt = clock();
    while(t--)
    {
        // cout<<"Case #"<<tc<<": ";
        g.clear();
        vis.clear();
        solve();
        // tc++;
    }
//    run_time;

}

Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9+5
#define MAXN 1005
#define MAXH 10005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

int H, N, A[MAXH], B[MAXH], dp[MAXN][MAXH], id;

void print_table(){
    rep(i, N+1){
        rep(j, H+1){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
}

void solve(){
    rep(i, N+1)rep(j, H+1) dp[i][j] = INF;
    rep(i, N+1) dp[i][0] = 0;

    // print_table();

    // cout << endl;

    for(int i = 1; i <= N; ++i){
        rep(j, H+1){
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            dp[i][min(j+A[i], H)] = min(dp[i][j]+B[i], dp[i][min(j+A[i], H)]); // 端の部分を何回も書き換えることに注意！！
        }
    }

    // print_table();
    // rep(i, N+1)
    //     cout << dp[i][H] << endl;

    cout << dp[N][H] << endl;
}

int main(){
    cin >> H >> N;
    A[0] = 0;
    B[0] = 0;

    rep(i, N){
        cin >> A[i+1] >> B[i+1];
    }

    solve();
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, M;
	cin >> N >> M;
	int wa[N] = {0};
	bool solved[N] = {false};
	
	int p;
	string s;
	int ans1 = 0, ans2 = 0;
	REP(i, 0, M){
		cin >> p >> s;
		if(s == "AC"){
			if(!solved[p-1]){
				solved[p-1] = true;
				ans2 += wa[p-1];
				++ans1;
			}
		}
		else{
			if(!solved[p-1]) ++wa[p-1];
		}
	}
	cout << ans1 << " " << ans2;

}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int a[500005];
int main(){
    int n;
    cin>>n;
    while(n--)
    {
        int x;
        cin>>x;
        a[x]++;
        a[x-1]++;
        a[x+1]++;
    }
    int maxv=0;
    for(int i=0;i<=500000;i++)
        if(a[i]>maxv)
            maxv=a[i];
    cout<<maxv<<endl;
    return 0;
} 

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

#define F first
#define S second

using namespace std;

/*long long int wop(long long int x, long long int y) {
    if(y===0)return 1;
    long long int ret=wop(x,y/2);
    ret=(ret*ret)%mod;
    if(y&1)ret*=x;
    return ret%mod;
}*/

/*long long int chos(long long int r, long long int n) {
    return fac[n]*rev[r]*rev[n-r]
}*/

const int N = 1e5+100;

int main () {
    long long int n, k, s;
    cin >> n >> k >> s;
    long long int sum=0;
    for(int i = 0 ; i < k ; i++ ) {
        cout << s << ' ';
    }
    if(s<1e6)
        for(int i = k ; i < n ; i++ )
            cout << (long long int)1000000000 << ' ';
    else
        for(int i = k ; i < n ; i++ )
            cout << 1 << ' ';
}


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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

   ll X;
   cin>>X;
   vector<ll>ans;
   for(ll i=1;i<=1000;i++){
      for(ll j=2;j<100;j++){
         ll n = pow(i,j);
         if(X>=n)ans.push_back(n);
      }
   }
   cout<<*max_element(ans.begin(),ans.end());
   return 0;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<tuple<ll,ll,ll>> vec(N);
    for(int i = 0;i < N;i++) {
        ll A,B;
        cin >> A >> B;
        vec.at(i) = make_tuple(A + B,A,B);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    ll t = 0;
    ll o = 0;
    for(int i = 0;i < N;i++) {
        if(i % 2 == 0) {
            t += get<1>(vec.at(i));
        }
        else {
            o += get<2>(vec.at(i));
        }
    }
    cout << t - o << endl;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;

struct Data
{
	int y, x, d, cost;
	Data(int y, int x, int d, int cost) : y(y), x(x), d(d), cost(cost) {}

	bool operator< (const Data& d)const
	{
		return cost > d.cost;
	}
};

int main()
{
	int w, h;
	while(scanf("%d%d", &w, &h), w){
		vvi field(h, vi(w));
		rep(i, h) rep(j, w)
			scanf("%d", &field[i][j]);

		int c[4];
		rep(i, 4) scanf("%d", &c[i]);

		vector<vvi> done(h, vvi(w, vi(4, 0)));

		int ans;
		priority_queue<Data> Q;
		Data start(0, 0, 0, 0);
		Q.push(start);
		while(!Q.empty()){
			Data d = Q.top();
			Q.pop();
			if(done[d.y][d.x][d.d])
				continue;

			done[d.y][d.x][d.d] = 1;
			if(d.y == h-1 && d.x == w-1){
				ans = d.cost;
				break;
			}

			const int dx[] = {1, 0, -1, 0, 1, 0, -1};
			const int dy[] = {0, 1, 0, -1, 0, 1, 0};
			rep(i, 4){
				int py = d.y + dy[i+d.d];
				int px = d.x + dx[i+d.d];
				if(py<0 || h<=py || px<0 || w<=px)
					continue;

				if(done[py][px][(i+d.d)%4])
					continue;
				
				int pc = d.cost + (i==field[d.y][d.x] ? 0 : c[i]);
				Q.push(Data(py, px, (i+d.d)%4, pc));
			}
		}

		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 952
#include<stdio.h>
 
int main(void)
{
    int n,x,a,b,c,ret;
     
    while(1)
	{
        scanf("%d %d",&n,&x);
        if(n==0&&x==0)
		{
			break;
		}
         
        ret = 0;
        for(c=1;c<=n;++c)
		{
            for(b=1;b<c;++b)
			{
                a=x-c-b;
                
				if(a<b&&a>0)
				{
                    ret++;
                }
            }
        }
        
		printf("%d\n",ret);
	}

	return 0;
}

Measured memory_bytes: 600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(st.nextToken());
		int K = Integer.parseInt(st.nextToken());
		int[] cost = new int[N+1];
		st = new StringTokenizer(br.readLine());
		for (int i = 1; i <= N; i++)
			cost[i] = Integer.parseInt(st.nextToken());
		int count = Integer.MAX_VALUE;
		for (int i = 1, j = i + K - 1; j <= N; i++, j++) {
			count = Math.min(count, cost[j] - cost[i] + Math.min(Math.abs(cost[i]), Math.abs(cost[j])));
		}
		System.out.println(count);
	}
}


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

int main()
{int N;
 int C[200000];
 cin >> N;
 for(int i=0; i<N; i++){
   cin >> C[i];}
 long long cnt_a=0;
 long long cnt_b=0;
 int sum_a=0;
 int sum_b=0;
 for(int i=0; i<N; i++){
   sum_a += C[i];
   if((i%2==0)&&(sum_a<=0)){
     cnt_a += 1 - sum_a;
     sum_a = 1;}
   if((i%2==1)&&(sum_a>=0)){
     cnt_a += sum_a + 1;
     sum_a = -1;}
 }
  for(int i=0; i<N; i++){
   sum_b += C[i];
   if((i%2==0)&&(sum_b>=0)){
     cnt_b += 1 + sum_b;
     sum_b = -1;}
   if((i%2==1)&&(sum_b<=0)){
     cnt_b += 1 - sum_b;
     sum_b = 1;}
 }
cout << min(cnt_a, cnt_b) << endl;
}

 

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int n,m;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  cin >> n >> m;
  vp ans;
  if(n&1){
    for(int l=1,r=n-1;l<r;l++,r--){
      ans.push_back(P(l,r));
    }
  }
      
  else{
    bool flag=false;
    for(int l=1,r=n-1;l<r;l++,r--){
      if(!flag && r-l<=n/2){
        r--;
        flag=true;
      }
      ans.push_back(P(l,r));
    }
  }
  rep(i,m){
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;     
}


Measured memory_bytes: 5308
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    string u=to_string(n);
    ll ans=u.length();
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            string s=to_string(n/i);
            string t=to_string(i);
            ll m=max(s.length(),t.length());
            ans=min(ans,m);
        }
    }
    cout << ans << endl;
    return 0;
}

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

words = []

blue_cards = {}
for i in range(N):
  s = input()
  if s in blue_cards:
    blue_cards[s] = blue_cards[s] + 1
  else:
    blue_cards[s] = 1
  if s not in words:
    words.append(s)

M = int(input())

red_cards= {}
for i in range(M):
  s = input()
  if s in red_cards:
    red_cards[s] = red_cards[s] + 1
  else:
    red_cards[s] = 1
  if s not in words:
    words.append(s)

max_money = 0
for word in words:
  get_money, lose_money = 0, 0
  if word in blue_cards:
    get_money = blue_cards[word]
  if word in red_cards:
    lose_money = red_cards[word]
  max_money = max(max_money, get_money - lose_money)

print(max_money)


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


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

	int kkt = 89;
	vector<int> sq;
	for (int i = 1; i * i <= (1LL << 15); i++) {
		sq.push_back(i * i);
	}
	vector<int> ssq;
	for (int i = 0; i < sq.size(); i++) {
		for (int j = i; j < sq.size(); j++) {
			if (sq[i] + sq[j] > (1LL << 15)) break;;
			ssq.push_back(sq[i] + sq[j]);
		}
	}
	sort(ssq.begin(), ssq.end());
	vector<int> sssq;
	for (int i = 0; i < sq.size(); i++) {
		for (int j = i; j < sq.size(); j++) {
			if (sq[i] + sq[j] > (1LL << 15)) break;
			for (int k = j; k < sq.size(); k++) {
				if (sq[i] + sq[j] + sq[k] > (1LL << 15)) break;
				sssq.push_back(sq[i] + sq[j] + sq[k]);
			}
		}
	}
	sort(sssq.begin(), sssq.end());
	vector<int> ssssq;
	for (int i = 0; i < sq.size(); i++) {
		for (int j = i; j < sq.size(); j++) {
			if (sq[i] + sq[j] > (1LL << 15)) break;
			for (int k = j; k < sq.size(); k++) {
				if (sq[i] + sq[j] + sq[k] > (1LL << 15)) break;
				for (int l = k; l < sq.size(); l++) {
					if (sq[i] + sq[j] + sq[k] + sq[l] > (1LL << 15)) break;
					ssssq.push_back(sq[i] + sq[j] + sq[k] + sq[l]);
				}
			}
		}
	}
	sort(ssssq.begin(), ssssq.end());
	while (kkt) {
		ll n; scanf("%lld", &n); if (n == 0) break;
		ll res = 0;
		res += upper_bound(sq.begin(), sq.end(), n) - lower_bound(sq.begin(), sq.end(), n);
		res += (upper_bound(ssq.begin(), ssq.end(), n) - lower_bound(ssq.begin(), ssq.end(), n));
		res += (upper_bound(sssq.begin(), sssq.end(), n) - lower_bound(sssq.begin(), sssq.end(), n));
		res += (upper_bound(ssssq.begin(), ssssq.end(), n) - lower_bound(ssssq.begin(), ssssq.end(), n));
		printf("%lld\n", res);
	}

	return 0;
}


Measured memory_bytes: 70616
#include <iostream>

using namespace std;

int main() {
    int n, p_max, q_max, r_max, c_max;
    int i[1000], p[1000], q[1000], r[1000];
    while (true) {
        bool has_found = false;
        cin >> n;
        if (n == 0) {
            return 0;
        }
        for (int k = 0; k < n; ++k) {
            cin >> i[k] >> p[k] >> q[k] >> r[k];
        }
        cin >> p_max >> q_max >> r_max >> c_max;
        for (int k = 0; k < n; ++k) {
            if (p[k] > p_max || q[k] > q_max || r[k] > r_max) {
                continue;
            }
            if (4 * (p[k] + r[k]) + 9 * q[k] > c_max) {
                continue;
            }
            has_found = true;
            cout << i[k] << endl;
        }
        if (!has_found) {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 1172
import math
n=int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

f=factorization(n) 
l=len(f)
x=0
for i in range(l):
    x+=int((-1+math.sqrt(1+8*f[i][1]))//2)
if n==1:
    x=0
print(x)
    

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

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var ans = new long[N];
        for (int i=0;i<N-1;++i)
        {
            var csf = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
            var C = csf[0];
            var S = csf[1];
            var F = csf[2];
            for (int j=0;j<=i;++j) {
                var count = 0L;
                if (i == j) count = C + S;
                else
                {
                    var before = ans[j];
                    if (before <= S) count = S+C;
                    else
                    {
                        before -= S;
                        var add = (before + (F - 1)) / F;
                        count = (add * F + S + C);
                    }
                }
                ans[j] = count;
            }
        }
        ans[N-1]=0;
        foreach (var a in ans)Console.WriteLine(a);
    }
}

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

using namespace std;

int n, m, k, col = 1;
int b[500][500];
int a[500][500];

void solve(int l, int r) {
	if(l > r) return;
	//cout << l << ' ' << r << endl;
	if(l == r) {
		int cnt = 0;
		vector <int> v;
		for(int j = 1; j <= n; j++)
			if(a[j][l]==1) cnt++, v.push_back(j);
		if(cnt == 1) {
			for(int j = 1; j <= n; j++)
				b[j][l]=col;
			col++;
		}else if(cnt>1){
			for(int j = 1; j < v[1]; j++)
				b[j][l]=col;
			col++;
			v.push_back(n+1);
			for(int i = 1; i < v.size() - 1; i++)	{
				for(int j = v[i]; j < v[i + 1]; j++)
					b[j][l]=col;
				col++;
			}
		}
	}else {
		solve(l,(l + r) / 2);
		solve((l+r) / 2 + 1,r);

		if(b[1][(l + r)/2]==0){
			//cout<<l<<' ' <<r<<endl;
			for(int f = l; f <= (l + r) / 2; f++)
			for(int s = 1; s <= n; s++)
				b[s][f]= b[s][(l + r) / 2 + 1];
		}else if(b[1][(l + r) / 2 + 1]==0) {
			//cout<<l<<' ' <<r<<endl;
				for(int f = (l+r)/2 + 1; f <= r; f++)
				for(int s = 1; s <= n; s++)
					b[s][f]= b[s][(l + r) / 2];
		
		}
	}
	
}
int main() {

	cin >> n >> m >> k;

	for(int i = 1; i <= n; i++)
	for(int j = 1; j <= m; j++) {
		char c;
		cin >> c;
		if(c == '#') a[i][j]=1;
		else a[i][j]=0;
	}

	solve(1, m);

	for(int i =1; i <= n; i++,cout<<endl)
	for(int j = 1; j <= m; j++)cout << b[i][j] << ' ';
}




Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n;
P p[222222];
set<int>st;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> p[i].first;
		p[i].second = i;
	}
	st.insert(-1); st.insert(n);
	sort(p, p + n);
	int ans = 0;
	rep(i, n) {
		auto it = st.lower_bound(p[i].second);
		auto it2 = it; it--;
		ans += (*it2 - p[i].second) * (p[i].second - *it) * (i + 1);
		st.insert(p[i].second);
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int Q;
int L;
int R;
char S[100001];
int sum[100001];
int main(){
  int Lj4PdHRW, i;
  rd(N);
  rd(Q);
  rd(S);
  for(i=1;i<N;i++){
    sum[i+1] = sum[i];
    if(S[i-1]=='A' && S[i]=='C'){
      sum[i+1]++;
    }
  }
  for(Lj4PdHRW=0;Lj4PdHRW<Q;Lj4PdHRW++){
    rd(L);
    rd(R);
    wt_L(sum[R]-sum[L]);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, Q, L, R;
// char S[100001];
// int sum[100001];
// {
//   int i;
//   rd(N,Q,S);
// 
//   rep(i,1,N){
//     sum[i+1] = sum[i];
//     if(S[i-1]=='A' && S[i]=='C') sum[i+1]++;
//   }
//   
//   rep(Q){
//     rd(L,R);
//     wt(sum[R]-sum[L]);
//   }
// }


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/2)
#define PI (2*acos(0.0))
#define EPS (1e-8)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

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

int main(void) {
  ios_base::sync_with_stdio(0);
  int _d, n, m, ans;
  while (cin >> _d, _d) {
    cin >> n >> m;
    
    vector<int> d(n+1), k(m);
    
    for (int i = 0; i < n - 1; i++) cin >> d[i];
    for (int i = 0; i < m; i++) cin >> k[i];
    d[n-1] = 0; d[n] = _d;

    sort(d.begin(), d.end());
    
    ans = 0;
    for (int i = 0; i < m; i++) {
      int target = k[i];
      int l = 0, u = n + 1, mid, min_dist;
      while (l + 1 < u) {
        mid = (l + u) / 2;
        if (target - d[mid] >= 0) l = mid;
        else u = mid;
      }
      min_dist = abs(target - d[l]);
      min_dist = min(min_dist, abs(target - d[l+1]));
      ans += min_dist;
    }
    
    cout << ans << endl;
  }
  return 0; 
}

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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n, m;
    cin >> n >> m;
    
    vector<bool> box(n,false);
    vector<int> box_cnt(n,1);
    box[0] = true;
    
    rep(i,m){
        int x,y;
        cin >> x >> y;
        
        x--;
        y--;
        
        box_cnt[x]--;
        box_cnt[y]++;
        
        
        if(box[x]) box[y] = true;
        if(box_cnt[x] == 0) box[x] = false;
    }

    int cnt = 0;
    rep(i,n) if(box[i]) cnt++;
    
    cout << cnt << endl;

}

Measured memory_bytes: 640
#include <iostream>
     
    using namespace std;
     
    int main(){
      int a;
      int b;
      int e;
      int k;
      cin >> a;
      cin >> b;
      cin >> b;
      cin >> b;
      cin >> e;
      cin >> k;
      if(e-a<=k){
      	cout << "Yay!";
      }else{
      	cout << ":(";
      }
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define int long long int
        #define pb push_back
        #define mk make_pair
        #define ft first
        #define sc second
        #define ppb pop_back
        #define sz size
        #define forn(i,a,n) for(i=a;i<n;i++)
        #define M 998244353 
        #define inf 2e18

        signed main() {
 

        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n;
        cin>>n;
        vector<int> v(n);
        for(int i=0;i<n;i++)
            {cin>>v[i];}

        sort(v.begin(),v.end());
        int ans=0;
        // int i=n-1;
        int t=n-1;
        for(int i=n-1; i>=0 && n-1>0; i--,n--){
            ans+=v[i];
            // cout<<v[i]<<"\n";
            if(i<t && n>2){
                // cout<<"*** ";
                ans+=v[i];
                n--;
                // cout<<v[i]<<"\n";
            }
        }

        cout<<ans;

        return 0;
    }


Measured memory_bytes: 4780
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	while(true){
	    int H=sc.nextInt();
	    int W=sc.nextInt();
	    if(H==0 && W==0){
		break;
	    }
	    for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
		    System.out.printf("#");
		}
		System.out.printf("\n");
	    }	
	    System.out.printf("\n");
	}
    }
}
	    

Measured memory_bytes: 63224
#include <algorithm>
#include <cstdlib>
#include <iostream>
using namespace std;

int mat[100][100];

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

	int n;
	cin >> n;

	for(int i = 0; i < n; ++i)
		for(int j = 0; j < n; ++j)
			cin >> mat[i][j];

	long long ans = 0;
	for(int i = 0; i < n; ++i)
		for(int j = i + 1; j < n; ++j)
			ans += min(mat[i][j], mat[j][i]);

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1232
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    ll n, m, ans=0; cin >> n >> m;
    ans += min(n, m/2);
    m -= 2 * min(n, m/2);
    ans += m / 4;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int h,w,k,ans;
int a[15][1010];
int b[15][1010];
char s[1010];
int c[15];
int main()
{
	ans=0x3f3f3f3f;
	scanf("%d%d%d",&h,&w,&k);
	for(int i=0;i<h;++i){
		scanf("%s",s);
		for(int j=0;j<w;++j){
			a[i][j]=s[j]-'0';
		}
	}
	for(int i=0;i<(1<<(h-1));++i){
		int num=0,e=0,s=0,t=0;
		memset(b,0,sizeof(b));memset(c,0,sizeof(c));
		for(int p=0;p<w;++p) b[0][p]=a[0][p];
		for(int j=0;j<h-1;++j){
			if(i&(1<<j)) ++num,++s,++t;
			else ++s;
			for(int p=0;p<w;++p) b[t][p]+=a[s][p];
		}
//		printf("i=%d,num=%d\n",i,num);
//		for(int j=0;j<=num;++j){
//			for(int p=0;p<w;++p) printf("%d",b[j][p]);
//			printf("\n");
//		}
		bool q=false;
		for(int j=0;j<=num;++j){
			c[j]=b[j][0];
			if(c[j]>k){
				q=true;
				break;
			}
		}
		if(q) continue;
		for(int p=1;p<w;++p){
			bool q=false;
			for(int j=0;j<=num;++j){
				if(c[j]+b[j][p]>k){
					q=true;break;
				}
			}
			if(q){
				++e;//printf("p=%d\n",p);
				for(int j=0;j<=num;++j) c[j]=b[j][p];
			}
			else{
				for(int j=0;j<=num;++j) c[j]+=b[j][p];
			}
		}
		if(e+num<ans){
			//printf("e=%d,num=%d\n",e,num);
			ans=e+num;
		}
	}
	printf("%d\n",ans);
}

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

using namespace std;

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

int main(){
    vector<int> a;
    while(1){
        int n;
        cin >> n;
        if(n == 0)break;
        a.push_back(n);
    }

    rep(i,a.size())printf("Case %d: %d\n", i+1, a[i]);
    return 0;
}



Measured memory_bytes: 3356
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;


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

    int N;
    cin >> N;
    vi a(N), b(N), c(N);

    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];
    REP(i, N) cin >> c[i];

    sort(ALL(a));
    sort(ALL(c));

    ll ans = 0;
    REP(i, N){
        ll x = distance(a.begin(), lower_bound(ALL(a),b[i]));
        ll y = distance(upper_bound(ALL(c),b[i]), c.end());
        ans += (x*y);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1408
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    let n: u64 = s.trim().parse().unwrap();

    let ans: u64 = n * (n+1) / 2
        - 3 * (n/3) * (n/3 + 1) / 2
        - 5 * (n/5) * (n/5 + 1) / 2
        + 15 * (n/15) * (n/15 + 1) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	vector<int> ans(N + 1, 0);
	vector<pair<int, int>> memo;
	for (int x = 1; x * x <= N; ++x) {
		for (int y = 1; y * y <= N; ++y) {
			memo.emplace_back( x + y, x*x + y*y + x*y );
		}
	}
	for (int z = 1; z * z <= N; ++z) {
		for (auto p : memo) {
			int sum = z*z + p.first*z + p.second;
			if (sum > 0 && sum <= N) { ans[sum] += 1; }
		}
	}

	for (int i = 1; i <= N; ++i) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>
#include<math.h>
 
int koch(double x1,double y1,double x2,double y2,int n){
  if(n==0){
    printf("%f %f\n",x2,y2);
    return 0;
  }
  double Sx,Sy,Tx,Ty,Ux,Uy;
  Sx=(x2-x1)/3+x1;
  Sy=(y2-y1)/3+y1;
  Tx=(x2-x1)*2/3+x1;
  Ty=(y2-y1)*2/3+y1;
  Ux=(cos(M_PI/3)*(Tx-Sx)-sin(M_PI/3)*(Ty-Sy))+Sx;
  Uy=(sin(M_PI/3)*(Tx-Sx)+cos(M_PI/3)*(Ty-Sy))+Sy;
  koch(x1, y1, Sx, Sy, n-1);
  koch(Sx, Sy, Ux, Uy, n-1);
  koch(Ux, Uy, Tx, Ty, n-1);
  koch(Tx, Ty, x2, y2, n-1);
   
}
int main(){
  int n;
  double x1=0.0,y1=0.0;
  double x2=100.0,y2=0.0;
  scanf("%d",&n);
  printf("0.00000000 0.00000000\n");
  koch(x1,y1,x2,y2,n);
  return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
// #pragma GCC diagnostic warning "-std=c++11"

#define ll long long
#define pb  push_back
#define mod  1000000007
#define inf  1000000000000000000
#define pi  acos(-1.0)
#define maxn  1000009
#define sorted(s)  sort(s.begin(),s.end())
#define slc(n) scanf("%I64d", &n)
#define sl(n)  scanf("%lld", &n)
#define sf(n)  scanf("%lf", &n)
#define si(n)  scanf("%d", &n)
#define sch(n)  scanf(" %c", &n)
#define ss(n)  scanf("%s", n)
#define pb  push_back
#define fr first
#define sc second
#define all(a)  a.begin(),a.end()

using namespace std;

ll i, j, val[100010][4], n, dp[100010][4];

long long rec(ll i, ll j)
{
	if(i==n)
		return val[i][j];
	if(dp[i][j]==-1)
	{
		ll x = 0;
		for(ll k=1;k<=3;k++)
		{
			if(k==j)
				continue;
			x = max(x, rec(i+1, k));
		}
		dp[i][j] = x;
	}
	return dp[i][j]+val[i][j];
}

int main()
{
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		for(ll j=1;j<=3;j++)
		{
			slc(val[i][j]);
		}
	}
	memset(dp, -1, sizeof dp);
	ll ans = 0;
	for(ll i=1;i<=3;i++)
	{
		ans = max(ans, rec(1,i));
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>

using namespace std;
int e[510][510];
int main(){
	int i,j,k,n;
	cin >> n;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(j==i) continue;
			for(k=0;k<10;k++){
				int x = (1<<k)&i,y = (1<<k)&j;
				if(x!=y){
					e[i][j] = k + 1;
					e[j][i] = k + 1;
					break;
				}
			}
		}
	}
	for(i=1;i<=n;i++){
		for(j=i + 1;j<=n;j++){
			cout << e[i][j] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 1536
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,m,k = map(int, input().split())
    for i in range(n+1):
        for j in range(m+1):
            if i*(m-j)+j*(n-i) == k:
                print("Yes")
                exit()
    print("No")





if __name__=="__main__":
    main()


Measured memory_bytes: 67476
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


#define H 0
#define V 1


bool feasible(const int x, const std::vector<int>& a)
{
  if (a.empty())
    return x == 0;
  
  bool dp[2][20000], *curr = dp[0], *next = dp[1];

  memset(dp, 0, sizeof(dp));

  curr[10000] = true;

  for (const auto& i : a) {
    for (int j = 0; j < 20000; j ++)
      if (curr[j]) {
        curr[j] = false;
        next[j - i] = next[j + i] = true;
      }

    std::swap(curr, next);
  }

  return curr[x + 10000];
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::string s;

  int x, y, size;

  std::cin >> s >> x >> y;

  size = s.size();

  std::reverse(ALL(s));

  while (! s.empty()) {
    char c = s.back();

    if (c == 'T')
      break;

    x --;

    s.pop_back();
  }

  int d = H;

  std::vector<int> h, v;

  while (! s.empty()) {
    char c = s.back();

    int n = 1;

    s.pop_back();

    while (! s.empty() && s.back() == c) {
      s.pop_back();

      n ++;
    }

    if (c == 'T') {
      if (n % 2)
        d = 1 - d;
    }
    else {
      (d == H ? h : v).push_back(n);
    }
  }

  std::cout << (feasible(x, h) && feasible(y, v) ? "Yes" : "No") << std::endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
typedef vector<pii> vpii;
#define reps(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define all(g) (g).begin(),(g).end()
#define pb push_back
const int mod = 1e9 + 7;
#define INF 1<<25
/*
input case
output case
*/
string s;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    rep(i,s.size()){
        if (i == 4){
            cout << " ";
        }
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void)
{
    int a, b, c, tunc = 0;
    scanf("%d %d %d", &a, &b, &c);
    if (b < a)
    {
        tunc = a;
        a = b;
        b = tunc;
    }
    if (c < a)
    {
        tunc = a;
        a = c;
        c = tunc;
    }
    if (c < b)
    {
        tunc = b;
        b = c;
        c = tunc;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;

int main()
{
   string s;
   cin >> s;
   cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
   return 0;
}

Measured memory_bytes: 256
//
// Created by kinok on 2020/04/19.
//
 
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
 
using namespace std;
 
 
#define ll long long
#define rep(t) for(int i=0;i<t;i++)
#define deb(a) cout<<#a<<" : "<<a<<endl
#define debv(v) do{cout<<#v<<" : ";for(auto a:v){cout << a <<" ";} cout<<endl;}while(0);
#define PI 3.141592653589793
 
 
 
void a(){
    int a;
    cin>>a;
    cout<<fixed<<setprecision(8)<<a*2*PI<<endl;
}
 
void b(){
    ll n,m,total=0,k;
    cin>>n>>m;
    rep(m){
        cin>>k;
        total+=k;
    }
    cout<<(n<total?-1:n-total)<<endl;
}
void c(){
ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> ans(n,0);
    rep(n-1){
        cin>>a.at(i);
        ans.at(a.at(i)-1)+=1;
    }
    rep(n){
        cout<<ans.at(i)<<endl;
    }
}
 
void d(){
 
}
 
void e(){
 
}
 
void f(){
 
}
 
 
int main(){
    c();
  return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;

int main(int argc, const char * argv[]) {
   
    //printf("\n");
    long double heikinutukusisa;
    long double n,m,d;
    cin >> n >> m >> d;
    long double fuctor = 2;
    if(d == 0){fuctor = 1;}
    heikinutukusisa = fuctor * (n - d ) * (m - 1) / (n * n);
    printf("%.40Lf",heikinutukusisa);
    

}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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);
  ll N; cin >> N;
  ll ans = 0;
  for(ll i=1; i<N/2+N%2; ++i) {
    ll b = N-i;
    if(N != i) ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in =new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int ans = 3;
		if(b==a) ans--;	
		if(c==a) ans--;
		if(c==b) ans--;
		if(ans==0) ans++;
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 9804
### constant

MAX_INT = 1 << 30

### main

while true
  m, n, k, d = gets.strip.split(' ').map{|s| s.to_i}
  break if m == 0

  nodes = (1..m).map{|i| "C#{i}"} + ['H', 'D'] + (1..n).map{|i| "L#{i}"}
  nodehash = {}
  nodes.each_with_index{|nd, i| nodehash[nd] = i}
  #p nodes
  #p nodehash

  cals = []
  gets.strip.split(' ').each_with_index do |s, i|
    cals[nodehash["C#{i + 1}"]] = s.to_i
  end
  #p cals

  edges = nodes.map{[]}
  nbrs = nodes.map{[]}
  d.times do
    lc0, lc1, dist = gets.strip.split(' ')
    i0 = nodehash[lc0]
    i1 = nodehash[lc1]
    edges[i0][i1] = edges[i1][i0] = dist.to_i * k
    nbrs[i0] << i1
    nbrs[i1] << i0
  end
  #p edges
  #p nbrs

  max_bits = (1 << m) - 1

  dists = (0..max_bits).map{nodes.map{MAX_INT}}
  dists[0][m] = 0
  q = [[0, m]]

  while ! q.empty?
    bits, id = q.shift
    next if id == m + 1 && bits == max_bits

    for nid in nbrs[id]
      if nid < m
        b = 1 << nid
        next if (bits & b) != 0
        nbits = (bits | b)
        d = dists[bits][id] + edges[id][nid] - cals[nid]
        if dists[nbits][nid] > d
          dists[nbits][nid] = d
          q << [nbits, nid]
        end
      else
        d = dists[bits][id] + edges[id][nid]
        if dists[bits][nid] > d
          dists[bits][nid] = d
          q << [bits, nid]
        end
      end
    end
  end

  min_dist = (0..max_bits).map{|bits| dists[bits][m + 1]}.min
  puts min_dist
end

Measured memory_bytes: 6244
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>
using namespace std;
const int maxn = 1e6+10;
         
int read(){
   	int x=0,f=1;
   	char c=getchar();
   	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
   	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
 	return x*f;
}
         
int k,m,n;
int a[maxn];
int main(){	
   	n=read();k=read();
   	long long sum=0,ans=0;
  	for(register int i=0;i<2*n;i++)sum+=k+i;
	for(register int i=2*n;i<3*n;i++)ans+=k+i;
  	if(ans<sum){puts("-1");return 0;}
	for(register int i=0;i<n*2;i++){
		if(i%2)a[i]=i/2+k;
		else a[i]=i/2+k+n;
	}
	if(n%2==0){
		for(register int i=0;i<n;i++){
			if(i%2==1)a[i]+=n;
			else a[i]-=n;
		}
	}
	for(register int i=0;i<n;i++)
		printf("%d %d %d\n",a[i],a[i+n],k+n*2+i);
  	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define INF 1000000007
using P = pair<int, int>;
using ll = long long;
int main(){
    bool c[8]={};
    int k=0;
    int n;
    cin>>n;
    int a[100];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]/400<8)c[a[i]/400]=true;
        else k++;
    }
    int ans=0;
    for(int i=0;i<8;i++)if(c[i]==true)ans++;
    cout<<max(1,ans)<<" "<<ans+k<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

struct Edge {
    i64 v, c;
};

int n, m;
vector<vector<Edge>> g;
int main() {
    cin >> n >> m;
    g.resize(n + 1);
    for (int u = 2; u <= n; ++u) {
        g[u].push_back({u - 1, 0});
    }
    for (int i = 0; i < m; ++i) {
        int l, r, c;
        cin >> l >> r >> c;
        g[l].push_back({r, c});
    }
    using P = pair<i64, int>;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0, 1});
    vector<i64> dist(n + 1, 1ll << 60);
    dist[1] = 0;
    while (!pq.empty()) {
        i64 u, d;
        tie(d, u) = pq.top();
        pq.pop();
        if (d > dist[u]) {
            continue;
        }
        for (auto e : g[u]) {
            i64 dv = dist[u] + e.c;
            if (dv < dist[e.v]) {
                pq.push({dv, e.v});
                dist[e.v] = dv;
            }
        }
    }
    i64 ans = dist[n];
    if (ans >= (1ll << 60)) ans = -1;
    cout << ans << endl;
    return 0;
}

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

const ll MOD = 1000000007;

ll mlpow(ll x, ll p) { //x^p(long long)%MOD
    ll tmp = 1;
    if(p == 0) return 1;
    while(p != 0) {
        if(p & 1) tmp = tmp*x % MOD;
        x = x*x % MOD;
        p = p >> 1;
    }
    return tmp;
}

int main() {
    int m, n;
    cin >> m >> n;

    cout << mlpow(m,n) << endl;

    return 0;
}



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

#if debug
#include "printer.hpp"
#define dump(a) cerr << #a << "(" << __LINE__ << ") = " << a << endl;
#else
#define dump(...)
#endif

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a, b) for (int i = (b)-1; i >= a; i--)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
const ll mod = 1000000007;

ll pow(ll x, ll y) {
  ll ret = 1, tmp = x;
  while (y) {
    if (y % 2) ret = ret * tmp % mod;
    tmp = tmp * tmp % mod;
    y /= 2;
  }
  return ret;
}

ll inverse(ll x) { return pow(x, mod - 2); }

int main() {
  ll N, K, S;
  cin >> N >> K >> S;
  ll X = 1000 * 1000 * 1000;
  vi A(N);
  if (S == X) {
    rep(i, 0, N) {
      if (i < K)
        A[i] = X;
      else
        A[i] = 1;
    }
  } else {
    rep(i, 0, N) {
      if (i < K)
        A[i] = S;
      else
        A[i] = X;
    }
  }
  rep(i, 0, N) {
    cout << A[i];
    if (i == N - 1)
      cout << endl;
    else
      cout << ' ';
  }
}


Measured memory_bytes: 2048