akhauriyash/Code-Regression huggingface dataset:
A,B,C=map(int,input().split())
odd = A%2+B%2+C%2
answer = 0
if odd == 1:
  answer = 1
  if not A%2:
    A += 1
  if not B%2:
    B += 1
  if not C%2:
    C += 1
elif odd == 2:
  answer = 1
  if A%2:
    A += 1
  if B%2:
    B += 1
  if C%2:
    C += 1
D = sorted([A,B,C])
answer += (D[2]-D[0])//2+(D[2]-D[1])//2
print(answer)

Measured memory_bytes: 9216
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);
    int prev = 0;
    int res = 0;
    int tmp;
    for (int i = 0; i < n; i++) {
      scanf("%d", &tmp);
      if (prev < tmp) {
        res += tmp-prev;
      }
      prev = tmp;
    }
    printf("%d", res);
}

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

int main() {
  string S, T, U;
  int A, B;
  
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if (S == U) A--; 
  else B--;

  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
import copy
D = int(input())
c = list(map(int,input().split()))
s = [ [0 for j in range(26)] for i in range(D)]
for i in range(D):
    tmp = list(map(int,input().split()))
    for j in range(26):
        s[i][j] = tmp[j]
t = []
v = [0] * D
last = [ [0 for j in range(26)] for i in range(D)]
sum = 0
for i in range(D):
    max = -10000
    tmp_last = copy.deepcopy(last)
    for j in range(26):
        tmp_sum = sum
        if j != 0:
            tmp_last[i][j-1] = last[i][j-1]
        tmp_sum += s[i][j]
        tmp_last[i][j] = i+1
        for k in range(26):
            tmp_sum -= c[k] * ( (i+1) - tmp_last[i][j] )
        if tmp_sum > max:
            max_j = j
            max = tmp_sum
            last[i][j] = i+1
    sum = max
    t.append(max_j+1)


for i in range(D):
    print(t[i])

Measured memory_bytes: 9916
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

	if (n<=m) {
		for (int i = 0; i < m;i++) {
			cout << n;
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			cout << m;
		}
	}

	

	return 0;
}


Measured memory_bytes: 3592
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def solve():
    n = II()
    V = sorted(LI())
    ans = V[0]
    for i in range(1, n):
        ans = (ans + V[i]) / 2
    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

int const maxn = 3e5 + 5;

ll ans[maxn];

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n;
	ll x, y; cin >> x >> y;
	for (ll i = 1; i <= n; i++) {
		for (ll j = i + 1; j <= n; j++) {
			ll d = j - i;
			ll ix = abs(x - i);
			ll jx = abs(x - j);
			ll iy = abs(y - i);
			ll jy = abs(y - j);


			d = min({ d, ix + jy + 1, iy + jx + 1});
			ans[d]++;
		}
	}
	for (ll i = 1; i <= n - 1; i++) {
		cout << ans[i] << '\n';
	}
	return 0;
}

/*
8 6

4 5 1 2 3 5 3 3

*/

Measured memory_bytes: 256
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N;
    cin >> N;
    int ans;
    for (int i = 1; i*i <= N; i++){
        ans = i*i;
    }
    cout << ans << endl;


    return 0;
}


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

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

    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;

    REP(i, N){
        string S;
        cin >> S;
        if(S.compare("AC") == 0){
            ac++;
        }
        else if(S.compare("WA") == 0){
            wa++;
        }
        else if(S.compare("TLE") == 0){
            tle++;
        }
        
        else if(S.compare("RE") == 0){
            re++;
        }
    }

    cout << "AC x " << ac << "\n";
    cout << "WA x " << wa << "\n";
    cout << "TLE x " << tle << "\n";
    cout << "RE x " << re << "\n";

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#define C 1000
using namespace std;
int main()
{
	int price,change;
	cin>>price;
	if(price%C==0)
	{
	cout<<0;
	exit(0);}
	int n=price/C;
	int other =price-C*(n+1);
	change =other *(-1);
	cout<<change;
 } 

Measured memory_bytes: 3192
height, width = gets.split.map &:to_i

c = []
(0...height).each do |i|
  c[i] = gets.split.map &:to_i
end

h = Array.new(height).map { Array.new(width) }

(0...height).each do |i|
  (0...width).each do |j|
    if c[i][j] == 1
      h[i][j] = 0
    else
      h[i][j] = i > 0 ? h[i-1][j] + 1 : 1
    end
  end
end

stack = []
max = 0

class Rect
  attr_accessor :h, :pos

  def initialize(h, pos)
    @h, @pos = h, pos
  end
end

(0...height).each do |i|
  h[i][width] = 0
  (0..width).each do |j|
    rect = Rect.new(h[i][j], j)
    if stack.empty?
      stack.push rect
    else
      if stack[-1].h < rect.h
        stack.push rect
      elsif stack[-1].h > rect.h
        pos = j
        while !stack.empty? && stack[-1].h >= rect.h
          pre = stack.pop
          area = pre.h * (j - pre.pos)
          max = max > area ? max : area
          pos = pre.pos
        end
        rect.pos = pos
        stack.push rect
      end
    end
  end
end

puts max

Measured memory_bytes: 47292
N = int(input())
H = [int(x) for x in input().split()]
j = 0
Ans = True

for i in range(N-1):
    if H[i] > H[i+1] + 1:
        Ans = False
    elif H[i] == H[i+1] + 1:
        if H[i-j] == H[i]:
            j = 1
            continue
        else:
            Ans = False
            break
    elif H[i] == H[i+1]:
        j += 1
    else:
        j = 0
        continue

if Ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14228
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, n) for(int i = 0; i < n; i = i + 2)
#define repv(i, n, v) for(int i = 0; i < n; i = i + v)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define sortI(a, b, c) c == 0 ? sort(a, a + b) : sort(a, a + b, greater<int>())
#define sortS(s, a) a == 0 ? sort(s.begin(), s.end()) : sort(s.begin(), end(), greater<char>)
#define vi vector<int>
#define vf vector<float>
#define vc vector<char>
#define vs vector<string>
#define ll long long
#define lint long int
#define llint long long int
#define atoz abcdefghijklmnopqrstuvwxyz
#define atoZ abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
#define AtoZ ABCDEFGHIJKLMNOPQRSTUVWXYZ

int digit(int n){
  int res = 0;
  while(n > 0){
    res += n%10;
    n /= 10;
  }
 
  return res;
}

int main(void){

  //入力
  int W, H, N;
  cin >> W >> H >> N;
  
  //配列
  int area[W][H] = {0};
  int x[N], y[N], a[N];
  rep(i, N){
    cin >> x[i] >> y[i] >> a[i];
    switch(a[i]){
      case 1:
        rep(j, x[i]) rep(k, H) area[j][k] = 1;
        break;
      case 2:
        for(int j = x[i]; j < W; j++) rep(k, H) area[j][k] = 1;
        break;
      case 3:
        rep(j, y[i]) rep(k, W) area[k][j] = 1;
        break;
      case 4:
        for(int j = y[i]; j < H; j++) rep(k, W) area[k][j] = 1;
        break;
    }
  }
  
  //白(0)の分を数える
  int ans = 0;
  rep(i, W) rep(j, H) if(area[i][j] == 0) ans++;
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

int main(){
    string s;
  	int i;
  	char c;
  	cin>>s;
  	c = s[0];
  	for(i =1;i<3;i++){
      	if (c != s[i]){
          	cout<<"Yes"<<endl;
          	break;
        }
    }
  	if (i ==3){
      cout<<"No"<<endl;
    }
  	return 0;
}


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


int main() {

	int N;
	cin >> N;
	vector<vector<int>> A(2,vector<int>(N));
	for (int i = 0;i < 2;i++) {
		for (int j = 0;j < N;j++) {
			cin >> A.at(i).at(j);
		}
	}

	int ans = 0;
	for (int i = 0;i < N;i++) {
		int ans_i = 0;
		for (int j = 0;j < N;j++) {
			if (j <= i) {
				ans_i += A.at(0).at(j);
			}
			if(j>=i)
				ans_i += A.at(1).at(j);
		}
		ans = max(ans, ans_i);
	}

	cout << ans;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int val1 = int.Parse(Console.ReadLine());
            String[] input = Console.ReadLine().Split(' ');
            int[] val = Array.ConvertAll(input, int.Parse);
            Array.Sort(val);

            int sum = 0;
            for (int i = 0; i < val1; i++){
                sum += val[val.Length-(2+(2*i))];
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <iostream> 
using namespace std;
int main(){
	long long int n,c=0;
	cin>>n;
	char a[n+5];
	int l=0,r=n-1;
	scanf("%s",a);
	while(l<r){
			if((a[l]=='W' && a[r]=='R')){
			l++;
			r--;
			c++;
			// break;
			// if(a[i-1]=='W')
			// c++;
		}
		else if(a[l]=='R' && a[r]=='R'){
			l++;
		}
		else if((a[l]=='W' && a[r]=='W')){
			// l++;
			r--;
		}
		else if((a[l]=='R' && a[r]=='W')){
			l++;
			r--;
		}
	}
	printf("%lld\n",c);
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;
int rem[100100];
int ra=0;
ll dp[100100][13];
int main(){
	cin>>s;
	rem[0]=1;
	REP(i,100100){
		REP(j,13){
			dp[i][j]=0;
		}
	}
	
	for(int i=1;i<100100;i++){
		rem[i]=(rem[i-1]*10)%13;
	}
	for(int i=s.size()-1;i>=0;i--){
		int t=s.size()-i-1;
		if(s[i]>='0'&&s[i]<='9')ra+=(s[i]-'0')*rem[t];
		ra%=13;
	}
	ra=(18-ra)%13;
	//cout<<ra<<endl;
	int now=-1;
	for(int i=s.size()-1;i>=0;i--){
		int t=s.size()-i-1;
		if(s[i]=='?'){
			if(now==-1){
				for(int j=0;j<10;j++){
					dp[i][(j*rem[t])%13]++;
				}
				now=i;
			}else{
				for(int j=0;j<10;j++){
					for(int k=0;k<13;k++){
						dp[i][(j*rem[t]+k)%13]+=dp[now][k];
						dp[i][(j*rem[t]+k)%13]%=MOD;
					}
				}
				now=i;
			}
		}
	}
	if(now==-1){
		if(ra==0)cout<<1<<endl;
		else cout<<0<<endl;
	}else{
		cout<<dp[now][ra]<<endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto &e: a) cin >> e;
    partial_sum(a.begin(), a.end(), a.begin());

    ll r = 1e18;
    for(ll i=0; i<n-1; i++)
        r = min(r, abs(a[n-1]-a[i]-a[i]));
    cout << r << endl;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, start_index, num)  (a).begin()+(start_index),(a).begin()+(num)


int main() {
	int n;
	cin >> n;
	vector<int> memo(n + 1);
	FOR(i, 1, n) {
		for (int j = i; j <= n; j += i) {
			memo[j]++;
		}
	}
	ll res = 0;
	FOR(i, 1, n) {
		res += memo[i] * i;
	}
	pv(res);
	return 0;
}

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

int main(){
	using ll = long long int ;
	ll n,k ;
	cin >> n >> k ;
	vector<ll> a(n) ;
	for(int i=0;i<n;i++) cin >> a.at(i) ;
	sort(a.begin(),a.end()) ;
	reverse(a.begin(),a.end()) ;
	ll ans = 0 ;
	if(k>=n) cout << 0 << endl ;
	else{
		for(int i=k;i<n;i++){
			ans += a.at(i) ;
		}
		cout << ans << endl ;
	}
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,x;
  cin >> n >> x;
  int ans=1;
  int w=0;
  rep(i,n){
    int r;
    cin >> r;
    w+=r;
    if(w<=x)ans++;
  }
  cout << ans << endl;
}  


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
typedef long long ll;
int main(){
    int n,a,b;scanf("%d%d%d",&n,&a,&b);
    //if(n == 1){puts("0");return 0;}
    ll l = 1LL*a*(n-1) + b,r = 1LL*b*(n-1) + a;
    if(l > r) {puts("0");return 0;}
    else printf("%lld\n",(r-l+1));
    return 0;
}


Measured memory_bytes: 128
x = int(input())
flag = False
for i in range(120):
    if flag:
        break
    k = i**5
    for j in range(120):
        l = j**5
        if k - l == x:
            print(i, j)
            flag = True
            break
        if k + l == x:
            print(j, -i)
            flag = True
            break

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
     ordered_set s;
     s.insert(1);
     cout<<*s.find_by_order(1); //print kth smallest element
     cout<<s.order_of_key(3);  //print number of strictly smaller element of 3;
*/
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define pi acos(-1)
#define bp __builtin_popcount
#define ll long long int
#define ld long double
#define endl '\n'
#define pii pair<ll , ll>
#define tii tuple<ll,ll,ll>
//aaaccess element of tuple ex. 3rd element(index 2) cout<< get<2>(tuppleName);

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<pii,vector<pii>,greater<pii> >
#define minq priority_queue <int, vector<int>, greater<int> >
#define maxQueue priority_queue<ll>
#define pb push_back
#define mx3(a,b,c) max(a,max(b,c))
#define pf push_front
#define ff first
#define ss second
#define FILL(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
const ll N = 1000005;
const ll M = 1e6 + 10;
const ll mod = 998244353;

ll power(ll x, ll y, ll p)
{
	ll res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}
ll modinv(ll n, ll p)
{
	return power(n, p - 2, p);
}
ll ncr(ll n, ll r, ll p)
{
	if (r == 0)
		return 1;
	int n1 = n;
	ll fac[n1 + 1];
	fac[0] = 1;
	for (int i = 1 ; i <= n; i++)
		fac[i] = fac[i - 1] * i % p;

	return (fac[n] * modinv(fac[r], p) % p *
	        modinv(fac[n - r], p) % p) % p;
}
/*vector<bool> prime(N, true);
void sieve()
{
	for (int i = 2; i <= sqrt(N); ++i) {
		if (prime[i]) {
			for (int j = i * i; j <= N; j += i) {
				prime[j] = false;
			}
		}
	}
}/*

/*int Prime[M];
void MinPrimeFactor()
{
	for (ll i = 1; i < M; i++) Prime[i] = i;
	for (int p = 2; p * p <= M; p++)
	{
		if (Prime[p] == p)
		{
			for (int i = 2 * p; i <= M; i += p)
			{
				Prime[i] = min(p, Prime[i]);
			}
		}
	}
}*/

/*vector<int> getFactorization(int x)
{
	vector<int> ret;
	while (x != 1)
	{
		ret.push_back(Prime[x]);
		x = x / Prime[x];
	}
	return ret;
}
*/
bool isPowerOfTwo(int x)
{
	return (x && !(x & (x - 1)));
}
int main()
{
	FAST;
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ll i, j, k, c = 0, a, b, m, n, l, r, t, sum = 0, x;
	cin >> i >> j >> k;
	k = j / k - (i - 1) / k;
	cout << k;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define ss cout << " ";
#define nn cout << "\n";
#define ct(x) cout << x;
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
const int maxn = 200200;
 
void solve(){

    return;
}
 
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    int64 rs = 0;
    for (int i = 0; i < s.size(); i++){
        rs+= int(s[i] - 48);
    }
    if (rs % 9 == 0){
        ctn("Yes");
    }
    else{
        ctn("No");
    }
    return 0;
}


Measured memory_bytes: 3740
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 200005
#define oo 1000000007
#define sz(a) (int)a.size()
#define MOD 1000000007
#define next PleaseLetMeUseThisName

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, next[maxN][26], dp[maxN], trace[maxN];
char s[maxN];

int main () {
    scanf("%s", s);
    n = strlen(s);
    fto(c, 0, 25) next[n][c] = n;

    dp[n] = 1; trace[n] = 0;
    fdto(i, n-1, 0) {
        fto(c, 0, 25) next[i][c] = next[i+1][c];
        next[i][s[i]-'a'] = i;

        dp[i] = oo;
        fto(c, 0, 25) {
            int x = (next[i][c] == n) ? 1 : dp[next[i][c]+1]+1;
            if (x < dp[i]) {
                dp[i] = x;
                trace[i] = c;
            }
        }
    }

    string ans;
    int i = 0;
    while (i <= n) {
       ans += trace[i]+'a';
        i = next[i][trace[i]]+1;
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 22272
import java.util.*
import java.io.PrintWriter

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val n = Integer.parseInt(sc.next())
    val aList = (1..n).map { Integer.parseInt(sc.next()) }.toIntArray()
    val sortedAList = aList.sorted()

    val out = PrintWriter(System.out)
    (1..n).forEach { i ->
        val ai = aList[i - 1]
        val max = sortedAList[sortedAList.size - 1]
        if (max == ai) {
            out.println(sortedAList[sortedAList.size - 2])
        } else {
            out.println(max)
        }
    }
    out.flush()
}

Measured memory_bytes: 63488
N = int(input())
le = [int(input()) for i in range(N)]
le.sort()#昇順
#３数以上の最小公倍数を求める問題
#a,b2数の最小公倍数とcの最小公倍数で求められる
#２数の最小公倍数はユークリッドの互除法を利用して再帰関数で求められる。

def GCD(a,b):
    if b == 0:
        return a
    return GCD(b,a%b)


def LCM(a,b):
    return int(a*b//GCD(a,b))

def multi_LCM(le):
    # print(le)
    if len(le)==1:
        return
    mxle=le[-1]
    del(le[-1])
    le[-1]=LCM(le[-1],mxle)
    multi_LCM(le)

if(len(le)==2):
    le[0]=LCM(le[0],le[1])
if(len(le)>=2):
    multi_LCM(le)

print(le[0])


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> m(n);
    for(int i=0;i<n;i++){
        cin >> m[i];
        x-=m[i];
    }
    sort(m.begin(),m.end());

    cout << n+x/m[0] << endl;
    return 0;
}



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

#define INF 1e+9

int dp[100000];
int n;
vector<int> a;

void solve(){
    fill(dp, dp+n, INF);
    for (int i=0; i<n; i++) {
        *lower_bound(dp, dp+n, a[i])=a[i];
    }
    cout<<lower_bound(dp, dp+n, INF)-dp<<endl;
}

int main(){
    cin>>n;
    a.resize(n);
    for (int i=0; i<n; i++) cin>>a[i];
    solve();
    return 0;
}

Measured memory_bytes: 3612
pub struct Scanner{
    line : Vec<String> ,
    idx : usize
}

#[allow(dead_code)]
impl  Scanner{
   fn new() -> Scanner{
       return Scanner{ line: vec![], idx : 0}
   }
   fn next<T: std::str::FromStr> (&mut self) -> T{
       if self.idx == self.line.len() {
           let mut buffer = String::new();
           std::io::stdin().read_line(&mut buffer).ok();

           let a : Vec<&str>  = buffer.trim().split(' ').collect();
           self.line = a.iter().map(|&s| String::from(s)).collect();
           self.idx = 0;
       }
       let ret : T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
       self.idx += 1;
       ret
   }
   fn next_string(&mut self) -> Vec<char> {
       let s : String = self.next();
       return s.chars().collect::<Vec<char>>();
   }
   fn next_vec<T: std::str::FromStr>  (&mut self, n: usize) -> Vec<T>{
       let mut v : Vec<T>= Vec::with_capacity(n);
       for _i in 0..n {
           v.push(self.next());
       }
       v
   }
}


fn main() {
    let mut scan = Scanner::new();
    let n:i32  = scan.next();
    let m:i32  = scan.next();
    let a:Vec<i32>  = scan.next_vec(n as usize);

    let mut s: i32 = 0;
    for x in a.iter() {
        s += *x;
    }
    let mut c : i32 = 0;
    for x in a.iter() {
        if x*4*m >= s{
            c += 1;
        }
    }
    if c >= m {
        println!("Yes");
    }else{
        println!("No");
    }
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> sgt(2 * N);
    {
        string S;
        cin >> S;
        for(unsigned long i{0}; i < N; ++i)sgt[i + N] = 1UL << S[i] - 97;
        for(unsigned long i{N}; --i; )sgt[i] = sgt[2 * i] | sgt[2 * i + 1];
    }
    const auto& update = [&N, &sgt](unsigned long i, unsigned long c) -> void {
        i += N;
        sgt[i] = 1UL << c;
        while(i >>= 1)sgt[i] = sgt[2 * i] | sgt[2 * i + 1];
    };
    const auto& query = [&N, &sgt](unsigned long L, unsigned long R) -> unsigned long {
        L += N;
        R += N;
        unsigned long ret{0};
        while(L != R){
            if(L & 1){
                ret |= sgt[L];
                ++L;
            }
            if(R & 1){
                --R;
                ret |= sgt[R];
            }
            L >>= 1;
            R >>= 1;
        }
        return __builtin_popcountl(ret);
    };
    unsigned long Q;
    cin >> Q;
    for(unsigned long i{0}, t; i < Q; ++i){
        cin >> t;
        if(t == 1){
            unsigned long idx;
            cin >> idx;
            char c;
            cin >> c;
            update(--idx, c - 97UL);
        }else{
            unsigned long L, R;
            cin >> L >> R;
            cout << query(--L, R) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8708
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <random>
using namespace std;
typedef long long int ll;

struct SCC{
	vector<vector<int> > gg,rg;
	vector<int> comp,order;
	vector<bool> used;
	vector<vector<int> > ng,vs;
	int n,nn;
	SCC(){}
	SCC(int v):gg(v),rg(v),comp(v,-1),used(v,0),n(v){}
	void add_edge(int x,int y){
		gg[x].push_back(y);
		rg[y].push_back(x);
	}
	int operator[](int k){
		return comp[k];
	}
	void dfs(int v){
		used[v]=1;
		for(int i:gg[v]){
			if(!used[i])dfs(i);
		}
		order.push_back(v);
	}
	void rdfs(int v,int k){
		used[v]=1;
		comp[v]=k;
		for(int i:rg[v]){
			if(!used[i])rdfs(i,k);
		}
	}
	int build(){
		for(int i=0;i<n;i++){
			if(!used[i])dfs(i);
		}
		for(int i=0;i<n;i++){
			used[i]=0;
		}
		int k=0;
		for(int i=order.size()-1;i>=0;i--){
			if(!used[order[i]])rdfs(order[i],k++);
		}
		nn=k;
		// それぞれの強連結成分に含まれる頂点の番号
		vs.resize(k,vector<int>());
		for(int i=0;i<n;i++){
			vs[comp[i]].push_back(i);
		}
		// 強連結成分をまとめた後のグラフ
		ng.resize(k,vector<int>());
		for(int i=0;i<n;i++){
			for(int j:gg[i]){
				if(comp[i]!=comp[j]){
					ng[comp[i]].push_back(comp[j]);
				}
			}
		}
		for(int i=0;i<nn;i++){
			sort(ng[i].begin(),ng[i].end());
			ng[i].erase(unique(ng[i].begin(),ng[i].end()),ng[i].end());
		}
		return k;
	}
	int size(){
		return nn;
	}
	vector<vector<int> > graph(){
		return ng;
	}
	vector<int> vertices(int v){
		return vs[v];
	}
};

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int v,e,q; cin >> v >> e;
	SCC scc(v);
	for(int i=0;i<e;i++){
		int s,t; cin >> s >> t;
		scc.add_edge(s,t);
	}
	scc.build();
	cin >> q;
	for(int i=0;i<q;i++){
		int u,v; cin >> u >> v;
		cout << (scc[u]==scc[v]) << endl;
	}
}



Measured memory_bytes: 4528
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
//--------------------

int main() {

	long res;
	long A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;

	res = min(A * X + B * Y, C * 2 * max(X, Y));

	if (X > Y) res = min(res, C * 2 * Y + A * (X - Y));
	else       res = min(res, C * 2 * X + B * (Y - X));

	cout << res << endl;
}

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

typedef long long ll;

const int N=1e5+66;

int n;
int h[N];
int dp[N];

int f(int i=0){
    if(i==n-1)return 0;
    int &res=dp[i];
    if(res!=-1)return res;
    res=f(i+1)+abs(h[i+1]-h[i]);
    if(i+2<n)
        res=min(res, f(i+2)+abs(h[i+2]-h[i]));
    return res;
}

int main(){
    memset(dp, -1, sizeof dp);
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&h[i]);
    printf("%d\n", f());
}


Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cassert>
//#include <tuple>
#include <cmath>
using namespace std;

signed main() {
	int a, b;
	cin >> a >> b;
	cout << a * b - a - b + 1 << endl;
	return 0;
}

Measured memory_bytes: 888
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m, d = map(int, readline().split())

    if d == 0:
        x = 1 / n * (m - 1)
    else:
        x = max(0, n - d) * (1 / n ** 2) + (n - d) * (1 / n ** 2)
        x *= (m - 1)

    print(x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61820
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int H[N];
  for (int i = 0; i < N; i++) cin >> H[i];

  if (K >= N) {
    cout << 0 << endl;
  } else {
    sort(H, H + N); //昇順
    reverse(H, H + N); //降順

    long long Ans = 0;
    for (int i = K; i < N; i++) {
      Ans += H[i];
    }

    cout << Ans << endl;
  }

  
  
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define print(x) cout << x << endl;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, tmp;
    cin >> A;
    cin >> B;
    tmp = max(A+B, A-B);
    tmp = max(tmp, A*B);
    print(tmp);
    
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports, non_snake_case)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

#[fastout]
fn main() {
    input!{
        N:usize,
        X:usize,
        M:usize,
    }
    let mut g = vec![0; M];
    let mut cur = X;
    let mut cursum = X;

    for i in 1..M*10 {
        if i == N {
            println!("{}", cursum);
            break;
        }
        if g[cur] == 0 {
            g[cur] = i;
        } else {
            let rot = i - g[cur];
            let mut rotsum = cursum;
            for j in 0..M {
                if 0 < g[j] && g[j] <= g[cur] {
                    rotsum -= j;
                }
            }
            let rest = N - i;
            cursum += rotsum * (rest / rot);
            for _ in 0..rest%rot {
                cur = cur * cur % M;
                cursum += cur;
            }
            println!("{}", cursum);
            break;
        }
        cur = cur * cur % M;
        cursum += cur;
    }
}


Measured memory_bytes: 2824
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long m = 0;
  long long sum = 0;
  for(int i = 0; i < n; i++){
    long long p;
    cin >> p;
    m = max(p, m);
    sum += p;
  }
  cout << sum - m/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N; string S;
int R = 1, G = 2, B = 4;
int RGB = 7;
int cnt[8];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> S;
	fore(c, S) {
		if (c == 'R') c = R;
		else if (c == 'G') c = G;
		else c = B;
	}

	int r = 0, g = 0, b = 0;
	ll ans = 0;
	rep(j, 0, N) {
		rep(k, j + 1, N) {
			if (S[j] == S[k]) continue;

			int Si = RGB - S[j] - S[k];
			ans += cnt[Si];

			int i = j - (k - j);
			if (0 <= i) {
				int msk = S[i] | S[j] | S[k];
				if (msk == RGB) ans--;
			}
		}

		cnt[S[j]]++;
	}
	cout << ans << endl;
}







Measured memory_bytes: 3644
#include<iostream>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main(){
 int n,x,y;
  int minLen = 0;
    cin >> n >> x >> y;
  int a[n];
  for(int i=0;i<n;i++) a[i] = 0;
  for(int i=1;i<=n;i++){
  	for(int j=i+1;j<=n;j++){
  		minLen = min(min(abs(j-i),abs(abs(x-i)+1+abs(y-j))),abs(abs(y-i)+1+abs(x-j)));
      	a[minLen]++;
    } 
  }
  for(int i=1;i<n;i++) cout << a[i] << endl;                   

}


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

int h[100002];
long long f[100002];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
   
    int n;
    cin>>n;
    for (int i=1;i<=n;i++) cin>>h[i];
    f[1] = 0;
    f[2] = abs(h[2] - h[1]);
    for (int i=3;i<=n;i++){
        f[i] =  min(f[i-1] + abs(h[i] - h[i-1]), f[i-2] + abs(h[i] - h[i-2]));
    }
    cout<<f[n];
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(){

  int i,j;
  int minj,count =0;
  int N,temp;
  int flag;
  int A[100];
  
  scanf("%d",&N);

  for(i = 0; i < N ; i++)
    scanf("%d",&A[i]);

  for( i = 0 ; i < N ; i++){
    minj = i;
    flag = 0;

    for(j = i; j < N ; j++){
      if (A[j] < A[minj]){
	minj = j;
	flag = 1;
      }
    }

    if (flag ==1){
      
      temp = A[i];
      A[i] = A[minj];
      A[minj] = temp;
      count++;

    }
  }

  //output

  for( i = 0;i < N; i++){
    printf("%d",A[i]);
    
  if(i<N-1) printf(" ");
}
  printf("\n");
  printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 604
import java.util.*;
import java.io.*;
class Main {
    
    public static long memo(int[][] arr, int n, int prev, long[][] memo){
        if(n < 0)
            return 0;
        if(memo[n][prev+1] > 0)
            return memo[n][prev+1];
        long ans = Long.MIN_VALUE;
       if(prev != 0)
        ans = Math.max(ans,arr[n][0] + memo(arr,n-1,0,memo));
    if(prev != 1)
    ans = Math.max(ans,arr[n][1] + memo(arr,n-1,1,memo));
    if(prev != 2)
       
    ans = Math.max(ans,arr[n][2] + memo(arr,n-1,2,memo));
       
        return memo[n][prev+1] = ans;
    }



    public static void solve(int[][] arr, int N){
        long ans = Long.MIN_VALUE;
        long[][] dp = new long[N][3];
        for(int i = 0; i < 3; i++){
            dp[0][i] = arr[0][i]; 
            ans = Math.max(ans,dp[0][i]);
        }

        for(int i = 1; i < dp.length; i++){
            for(int j = 0; j < dp[0].length; j++){
                long max = Long.MIN_VALUE;
                int picked = arr[i][j]; 
               for(int k = 0; k < dp[0].length; k++ ){
                    if(j != k){
                        max = Math.max(max, picked + dp[i-1][k]);
                    }
               } 
               dp[i][j] = max;
               ans = Math.max(ans,dp[i][j]);
            }
            
        }
        
        System.out.println(ans);
    }

    public static void main(String[] args) throws Exception{
        StringTokenizer str;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine().trim());
        int[][] arr = new int[n][3];
        for(int i = 0; i < arr.length; i++){
            int j = 0;
            str = new StringTokenizer(br.readLine().trim()," ");
            while(str.hasMoreTokens()){
                arr[i][j] = Integer.parseInt(str.nextToken());
                j++;
            }
        }
       //solve(arr,n);      
       long[][] memo = new long[arr.length][4];      
        System.out.println(memo(arr, arr.length-1, -1,memo));
    }
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll X, Y;
    cin >> X >> Y;

    ll ans = 0;
    if (X == 1 && Y == 1) {
        cout << 1000000 << endl;
    } else {
        if (X == 1) {
            ans += 300000;
        } else if (X == 2) {
            ans += 200000;
        } else if (X == 3) {
            ans += 100000;
        }
        if (Y == 1) {
            ans += 300000;
        } else if (Y == 2) {
            ans += 200000;
        } else if (Y == 3) {
            ans += 100000;
        }
        cout << ans << endl;
    }
    return 0;
}

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

res = []

res.append((sum(range(1,p[0]+1)))/p[0])

for i in range(1,N):
  #res.append(res[i-1] + p[i]*(p[i]+1)/(2*p[i]))
  res.append(res[i-1] + 0.5*(p[i]+1))
  #res.append(res[i-1] + 1 + 0.5*(p[i]-1))

ans=res[K-1]

for i in range(1,N-K+1):
  ans = max(ans,res[i+K-1] - res[i-1])
print(ans)

Measured memory_bytes: 25060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		int N = Integer.parseInt(lines[0]);
		int M = Integer.parseInt(lines[1]);
		int[] A = new int[N];
		double Tokuhyousuu = 0;
		int sum = 0;

		line = sc.nextLine();
		lines = line.split(" ");
		for(int i = 0; i < A.length; i++) {
			A[i] = Integer.parseInt(lines[i]);
			sum = sum + A[i];
		}
		Tokuhyousuu = (double)sum / (4 * M);
//		System.out.println(Tokuhyousuu);

		int count = 0;
		for(int i = 0; i < A.length; i++) {
			if(A[i] < Tokuhyousuu) {
			}else {
				count++;
			}
		}

		if(count >= M) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
import sys

s = input()
s_x = s.replace('x', '')

if len(s) == 1:
	print(0)
	sys.exit()

middle, mod = divmod(len(s_x),2)
middle += mod
if s_x[:middle] != s_x[::-1][:middle]:
	print(-1)
	sys.exit()

x_count = []
cnt = 0
for i in range(len(s)):
	if s[i] != 'x':
		x_count.append(cnt)
		cnt = 0
	else:
		cnt += 1
x_count.append(cnt)

ans = 0
for i in range(len(x_count)):
	ans += abs(x_count[i] - x_count[-(1+i)])

print(ans//2)

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(i);
// sort(arr, arr+n, greater<int>());
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int n;
	cin>>n;
	vector<int> v(n+1,0);
	int a[n-1];
	for(int i=0;i<n-1;i++)
	{
	    cin>>a[i];
	    v[a[i]]++;
	}
	for(int i=1;i<n+1;i++)
	{
	    cout<<v[i]<<endl;
	}
}

Measured memory_bytes: 4784
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){
	int n;
	scanf("%d", &n);
	REP(i, n / 4 + 1) {
		REP(j, n / 7 + 1) {
			if (i * 4 + j * 7 > n)break;
			if (i * 4 + j * 7 == n) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;
//ここから

void solve(){
  string s;
  cin>>s;
  int n=s.size();
  for(int i=0;i<n;i+=2)cout<<s[i];
}

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


Measured memory_bytes: 592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char S[] = sc.next().toCharArray();
        
        int W = 0;
        int E = 0;
        for(int i = 1; i < N; i++ ) {
            if( S[i] == 'E' ) {
                E++;
            }
        }
        
        int min = W + E;
        for( int i = 1; i < N; i++ ) {
            if( S[i-1] == 'W' ) {
                W++;
            }
            if( S[i] == 'E' ) {
                E--;
            }
            min = Math.min( min, W + E );
        }

        System.out.println(min);
    }
}


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

#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

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

    map<ll, ll> acc_sum;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        ll A;
        cin >> A;
        sum += A;
        acc_sum[sum]++;
    }

    ll output = 0;
    for (auto e : acc_sum) {
        // cout << e.first << " " << e.second << endl;
        if (e.first == 0) {
            output += e.second * (e.second + 1) / 2;
            continue;
        }
        if (e.second != 1) {
            output += e.second * (e.second - 1) / 2;
        }
    }
    cout << output << endl;

    return 0;
}


Measured memory_bytes: 16080
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
int main()
{
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i],sum+=a[i];
    sort(a.rbegin(),a.rend());
    ll k=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]>=(1.0*sum/(4*m)))k++;
    }
    if(k>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
// -*- coding:utf-8-unix -*-

#[macro_use]
extern crate lazy_static;
extern crate num_bigint; // 0.2.2
extern crate num_traits; // 0.2.8
use num_bigint::BigInt;
use num_traits::Pow;

// use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
// use std::convert::TryInto;
use libm::*;
use std::cmp::*;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::*;
use std::ops::Range;
use std::str::FromStr;
use superslice::*;

use lazy_static::lazy_static;
use std::sync::Mutex;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

lazy_static! {
    static ref H: Mutex<Vec<i32>> = Mutex::default();
    static ref W: Mutex<Vec<i32>> = Mutex::default();
}

//abc163-D
#[fastout]
fn main() {
    input![n: usize, a: [usize; n]];

    let a_sum_div2: usize = a.iter().sum::<usize>() / 2;

    let mut idx = 2;
    let mut a1 = a_sum_div2;
    loop {
        if idx - 1 >= a.len() {
            break;
        }

        a1 -= a[idx - 1];
        idx += 2;
    }

    let mut anss = vec![0; n];
    anss[0] = a1;
    // print!("{} ", a1);
    for i in 1..n {
        anss[i] = a[i - 1] - anss[i - 1];
    }

    // let ans = anss.iter().fold(String::new(), |mut mid_res, item| {
    //     mid_res.push_str(&format!("{} ", item * 2));
    //     mid_res
    // });

    for i in anss.iter() {
        print!("{} ", i * 2);
    }

    // println!("{}", ans);
}

// let mut values = VALUES.lock().unwrap();
// values.extend_from_slice(&[1, 2, 3, 4]);
// assert_eq!(&*values, &[1, 2, 3, 4]);

// -100000000
//  1000000000


Measured memory_bytes: 4524
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim().split(' ');
    var W = Number(inputs[0]);
    var H = Number(inputs[1]);
    var x = Number(inputs[2]);
    var y = Number(inputs[3]);
    var r = Number(inputs[4]);
 
    var x0 = W - x - r;
    var x1 = W - x + r;
    var y0 = H - y - r;
    var y1 = H - y + r;
 
    if ((x0 >= 0 && x1 <= W) && (y0 >= 0 && y1 <= H)) {
        console.log('Yes');
    } else {
        console.log('No');
    }
 
 
 
 
 
 
 
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15564
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
const int sz = 1e5 + 10;
int p[sz];
set<int> s, t;
main()
{
    int a, b;
    cin >> a >> b;
    for (int i = 0; i < a; i++)
        cin >> p[i];
    int m = 0;
    int ke = 0;
    long long pat = 0;
    int best = 0;
    for (int i = a - 1; i >= 0; i--)
    {
        int t = m - p[i];
        if (best < t)
        {
            pat = ke;
            best = t;
        }
        else if (best == t)
        {
            pat += ke;
        }

        if (m == p[i])
            ke++;
        if (m < p[i])
        {
            ke = 1;
            m = p[i];
        }
    }
    int A = 0, B = 0;
    for (int i = 0; i < a; i++)
    {
        if (s.count(p[i] - best))
            A++;
        s.insert(p[i]);
    }
    for (int i = a - 1; i >= 0; i--)
    {
        if (t.count(p[i] + best))
            B++;
        t.insert(p[i]);
    }
    cout << min(A, B) << endl;
    return 0;
}

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


int gcd(int a, int b){
    if(b==0)return a;
    return gcd(b,a%b);
}



int main(void){

    int a,b;

    while(cin >> a >> b){

        int lcm = a/gcd(a,b)*b;

        cout << gcd(a,b) << " " << lcm << endl;

    }

    return 0;

}

Measured memory_bytes: 1160