akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using System.Numerics;
using System.Diagnostics;

class Program
{
    public void Slove()
    {
        int n = int.Parse(Console.ReadLine());
        int[] dp = Enumerable.Range(0, n)
            .Select(x => int.MaxValue)
            .ToArray();
        dp[0] = 0;
        int[] hs = Console.ReadLine().Split().Select(int.Parse).ToArray();
        foreach(int i in Enumerable.Range(0, n))
        {
            if(i > 0)
                dp[i] = Math.Min(dp[i], dp[i - 1] + Math.Abs(hs[i] - hs[i - 1]));
            if(i > 1)
                dp[i] = Math.Min(dp[i], dp[i - 2] + Math.Abs(hs[i] - hs[i - 2]));
        }   
        Console.WriteLine(dp[n - 1]);
    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


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


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
	
	while(test--)
	{
	    long a,b,c=0,k,d=0,i,n,j,temp,p,m,ex1,ex2,ex3,ex4,x,y;
	    string s;
	    long long ans=1;
	    cin>>n>>c;
	    ans=c;
	    for(i=1;i<n;i++)
	    {
	        ans*=(c-1);
	    }
	    
	    cout<<(ans);
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007

map<string,ll>m;
ll ann,n,i;
string s;

int main()
{
    Fast;

    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s;
        sort(s.begin(),s.end());
        m[s]++;
    }
    for(auto mp:m)
        ann+=(mp.second*(mp.second-1))/2;
    cout<<ann;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
int N, M;
vb box;

#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define debug2(x,y) cout<<"("<<#x<<","<<#y<<") = ("<<(x)<<","<<(y)<<")\n"

bool checkbox(int i, int a){
  //i番目の箱 余りa
  int buf = 0;
  for(int k=i; k<=N; k+=i){
    if(box[k])buf++;
    //debug(buf);
  }
  //debug2(buf, a);
  if(buf%2 == a){
    return false;
  }else{
    M++;
    //debug(M);
    return true;
  }
}

int main(){
  cin>>N;
  box.resize(N+1, false);
  vi a(N+1);
  for(int i=1; i<=N; i++)cin>>a[i];
  M=0;
  for(int i=N; i>=1; i--){
    box[i] = checkbox(i, a[i]);
    //debug(box[i]);
  }

  cout<<M<<endl;
  if(M==0)return 0;
  for(int i=1; i<=N; i++){
    if(box[i]){
      cout<<i<<" ";
    }
  }
  cout<<endl;
}

Measured memory_bytes: 1792
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Edge>[] g = new ArrayList[N + 1];
		for (int i = 0; i < N + 1; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < N - 1; ++i) {
			int a = Integer.parseInt(sc.next()) - 1;
			int b = Integer.parseInt(sc.next()) - 1;
			g[a].add(new Edge(a, b, 1));
			g[b].add(new Edge(b, a, 1));
		}

		int K = Integer.parseInt(sc.next());
		int[] V = new int[K];
		int[] P = new int[K];
		for (int i = 0; i < K; ++i) {
			V[i] = sc.nextInt() - 1;
			P[i] = sc.nextInt();
			g[N].add(new Edge(N, V[i], P[i]));
		}

		class State implements Comparable<State> {
			int cur;
			long dis;

			public State(int cur, long dis) {
				this.dis = dis;
				this.cur = cur;
			}

			public int compareTo(State arg0) {
				return Long.compare(dis, arg0.dis);
			};
		}

		PriorityQueue<State> pq = new PriorityQueue<>();

		long[] d = new long[N + 1];
		Arrays.fill(d, Long.MAX_VALUE / 10);
		d[N] = 0;
		pq.add(new State(N, 0));

		while (!pq.isEmpty()) {
			State s = pq.poll();
			if (d[s.cur] < s.dis)
				continue;
			else
				d[s.cur] = s.dis;

			for (Edge e : g[s.cur]) {
				if (d[e.dst] > d[e.src] + e.cost) {
					d[e.dst] = d[e.src] + e.cost;
					pq.add(new State(e.dst, d[e.dst]));
				}
			}
		}

		for (int i = 0; i < N; ++i) {
			for (Edge e : g[i]) {
				if (Math.abs(d[e.src] - d[e.dst]) != 1) {
					System.out.println("No");
					return;
				}
			}
		}
		for(int i=0;i<K;++i){
			if(d[V[i]]!=P[i]){
				System.out.println("No");
				return;
			}
		}
		PrintWriter pw = new PrintWriter(System.out);
		pw.println("Yes");
		for (int i = 0; i < N; ++i) {
			pw.println(d[i]);
		}
		pw.close();
	}

	static class Edge {
		int src;
		int dst;
		int cost;

		public Edge(int src, int dst, int cost) {
			this.src = src;
			this.dst = dst;
			this.cost = cost;
		}
	}
}


Measured memory_bytes: 100848
#include <stdio.h>
int main()
{
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x>=-100 && y>=-100 && x<=100 && y<=100)
  {
    if(W>0 && H>0 && r>0 && W<=100 && H<=100 && r<=100)
    {
      if((x+r)>W || (x-r)<0)printf("No\n");
      else if((y+r)>H || (y-r)<0)printf("No\n");
      else printf("Yes\n");
    }
  }
  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long 
int main() 
{ 
    // added the two lines below 
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    float D,T,S;
    cin>>D>>T>>S;
    if(D/S<=T)
       cout<<"Yes"<<"\n";
    else
	   cout<<"No"<<"\n";
	return 0;
}
    

Measured memory_bytes: 3736
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0]*(n + 1)

    def root(self, x):
        if self.par[x] == x:
            return x
        r = self.root(self.par[x])
        self.par[x] = r
        return r

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

    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        if self.rank[rx] < self.rank[ry]:
            self.par[x] = ry
            self.par[rx] = ry
        else:
            self.par[y] = rx
            self.par[ry] = rx
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

def main():
    N, M, *PXY = map(int, open(0).read().split())
    P = PXY[:N]
    # print(N, M, PXY)
    uf = UnionFind(N + 1)
    for i in range(M):
        x, y = PXY[N + 2*i + 0], PXY[N + 2*i + 1]
        uf.unite(x, y)
    ans = 0
    for i in range(N):
        is_same = uf.same(i + 1, P[i])
        if is_same:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 34292
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll powmod(ll base,ll exponent,ll mod){
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int arr[upperlimit];
int dp[upperlimit];
int main() {
	int n,k;
	sd(n);sd(k);
	for(int i = 1; i <= n; i++){
		sd(arr[i]);
		dp[i]=INF;
	}
	dp[1]=0;
	for(int i = 2; i <= n; i++){
		for(int j = i-1; j >= max(1,i-k); j--){
			dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
		}
	}
	pd(dp[n]);
	return 0;
}

Measured memory_bytes: 4736
import sys

lines = sys.stdin.readlines()
s, t = [line.rstrip("\n") for line in lines]

if s.islower() and t.islower():
    if len(s) <= 10 and len(s) >= 1:
        if len(t) == len(s) + 1:
            if s == t[:-1]:
                print("Yes")
                sys.exit(0)
print("No")


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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

typedef long long ll;
const int MOD = 1000000007;
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	string ans = string(tx - sx, 'R') + string(ty - sy, 'U');
	ans += string(tx - sx, 'L') + string(ty - sy, 'D');
	ans += "D" + string(tx - sx + 1, 'R') + string(ty - sy + 1, 'U') + "L";
	ans += "U" + string(tx - sx + 1, 'L') + string(ty - sy + 1, 'D') + "R";
	cout << ans << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

void solve(int test_case) {
	string s;
	cin>>s;
	int i = s.length()-1;
	while(i>0) {
		if(i-4<0)break;
		string sub = s.substr(i-4,5);
		if(sub=="dream"||sub=="erase") {
			i-=5;continue;
		}
		if(i-5<0)break;
		sub=s.substr(i-5,6);
		if(sub=="eraser"){
			i-=6;continue;
		}
		if(i-6<0)break;
		sub=s.substr(i-6,7);
		if(sub=="dreamer"){
			i-=7;continue;
		}
		break;
	}
	if(i==-1)cout<<"YES";
	else cout<<"NO";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3788
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var nk = Console.ReadLine().Split();
        var n = int.Parse(nk[0]);
        var k = int.Parse(nk[1]) * 2 + 1;
        var s = Console.ReadLine();

        var d = new List<int> { 1 };
        for (int i = 1; i < s.Length; i++)
        {
            if (s[i - 1] == s[i]) d[d.Count - 1]++;
            else d.Add(d[d.Count - 1] + 1);
        }

        d.Add(d[d.Count - 1]);

        var ans = 0;
        var j = s[0] == '0' ? 1 : 0;

        for (; j < d.Count; j += 2)
        {
            if (k <= j)
            {
                ans = Math.Max(ans, d[j] - d[j - k]);
            }
            else
            {
                ans = Math.Max(ans, d[j]);
            }
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13244
N, M = map(int, input().split())

l = 1
r = N
flag = False
for i in range(M):
    l_1, r_1 = list(map(int, input().split()))
    if l_1 > l:
        l = l_1
    if r_1 < r:
        r = r_1
    if l > r:
        flag = True
        break
    
if flag:
    print(0)
else:
    print(r - l + 1)


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

signed main(){
 int N;
 cin>>N;
 vector<int> A(N-1);
 rep(i,N-1)cin>>A[i];
 int AN[N];
 rep(i,N)AN[i]=0;
 rep(i,N-1)AN[A[i]-1]+=1;
 rep(i,N)cout<<AN[i]<<endl;
 }

Measured memory_bytes: 6424
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>

using namespace std;
int main()
{
    int n, a, b;

    cin >> n >> a >> b;

    if ((b-a-1)%2) {
        cout << "Alice" << endl;
    }
    else {
        cout << "Borys" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
int main(){
    string a,b,c;
    cin >> a >> b >> c;

    int a_ind = 0;
    int b_ind = 0;
    int c_ind = 0;
    char now = 'a';
    while(true){
        if(now == 'a'){
            if(a_ind == a.size()){
                cout << 'A' << endl;
                return 0;
            }
            now = a[a_ind];
            a_ind++;
        }
        else if(now == 'b'){
            if(b_ind == b.size()){
                cout << 'B' << endl;
                return 0;
            }
            now = b[b_ind];
            b_ind++;
        }
        else if(now == 'c'){
            if(c_ind == c.size()){
                cout << 'C' << endl;
                return 0;
            }
            now = c[c_ind];
            c_ind++;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int n;
    cin>>n;
    int x = 1000 - n%1000;
    if(x == 1000) x = 0;
    cout<<x<<'\n';
    return 0;
}

Measured memory_bytes: 3648
unittest
{
	assert( [ "5", "1", "2", "1", "2", "2" ].parse.expand.solve == 3 );
	assert( [ "6", "4", "2", "5", "4", "2", "4" ].parse.expand.solve == 5 );
	assert( [ "7", "1", "3", "1", "2", "3", "3", "2" ].parse.expand.solve == 5 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto cs = new long[ n ];
	foreach( ref c; cs )
	{
		input.popFront;
		c = input.front.to!( long );
	}
	return tuple( cs );
}

auto solve( long[] cs )
{
	long[ long ] pps;
	auto pc = 0L;
	auto pp = 0L;
	auto ans = 1L;
	foreach( c; cs )
	{
		if( pc == c ) continue;
		pc = c;
		pp = ans;
		
		if( c in pps )
		{
			ans = addMod( ans, pps[ c ] );
			pps[ c ] = addMod( pps[ c ], pp );
		}
		else
		{
			pps[ c ] = pp;
		}
	}
	return ans;
}

// 足し算
auto addMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x + y ) % MOD;
}


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

int main(){
  int s; cin >> s;
  int data[1000010];
  int cnt = 1;
  data[s] = 1;
  while(true){
    cnt++;
    if(s % 2 == 0) s /= 2;
    else s = 3 * s + 1;
    if(data[s] == 1) break;
    data[s] = 1;
  }
  cout << cnt << endl;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    string comp = "yuiophjklnm";
    while(true){
        string s; bool check = false; bool belong = true;
        cin >>s; if(s.size() == 1 && s[0] == '#') break;
        int ans = 0;
        // y u i o p h j k l n m
        rep(i,s.size()){
            if(i == 0)rep(k,11){if(s[i] == comp[k]) check=true;}
            belong = false;
            rep(k, 11)if(s[i] == comp[k]){belong = true;}
            if(belong)if(check == false){ans++;check = true;}
            if(!belong)if(check == true){ans++;check = false;}
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define ysf (1000000007)
int a[3005],f[3005],n,k,tot,ans;
inline int qpow(int a,int b){
  int ans=1;
  while (b){
    if (b&1) ans=1LL*ans*a%ysf;
    if (b>>=1) a=1LL*a*a%ysf;
  }
  return ans;
}
int main(){
  std::cin>>n>>k;
  for (int i=1;i*i<=n;++i){
    if (n%i) continue; a[++tot]=i;
    if (i*i!=n) a[++tot]=n/i;
  }
  std::sort(a+1,a+tot+1);
  for (int i=1;i<=tot;++i){
    f[i]=qpow(k,(a[i]+1)>>1);
    for (int j=1;j<i;++j)
      if (!(a[i]%a[j])) f[i]-=f[j],f[i]<0?f[i]+=ysf:0;
    if (a[i]&1) ans=(ans+1LL*a[i]*f[i])%ysf;
    else ans=(ans+1LL*a[i]*f[i]/2)%ysf;
  }
  std::cout<<ans; return 0;
}


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

void INSERT(int* A, int n, int g, int* cnt) {
    for(int i = g; i < n; ++i) {
        int tmp = A[i];
        int j = i - g;
        while(-1 < j && tmp < A[j]) {
            A[j + g] = A[j];
            j = j - g;
            ++*cnt;
        }
        A[j + g] = tmp;
    }
}

void SHELL(int* A, int n) {
    int cnt = 0;
    int m;
    int G[100];
    for(int i = 0; i < 100; ++i) {
        if(i == 0) {
            G[i] = n / 2 + 1;
        } else {
            G[i] = G[i - 1] / 2 - 1;
        }
        if(G[i] < 0) {
            G[i - 1] = 1;
            G[i] = 0;
            m = i;
            break;
        }
    }
    for(int i = 0; i < m; ++i) {
        INSERT(A, n, G[i], &cnt);
    }
    
    cout << m << endl;
    for(int i = 0; i < m; ++i) {
        if(i)   cout << ' ';
        cout << G[i];
    }
    cout << endl;
    cout << cnt << endl;
    for(int i = 0; i < n; ++i) {
        cout << A[i] << endl;
    }
}

int main(void) {
    int n;
    int A[1000000];
    
    cin >> n;
    for(int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    
    SHELL(A, n);
    
    return 0;
}



Measured memory_bytes: 7004
#include<bits/stdc++.h>
using namespace std;
const int maxn=400000+10;
int head[maxn];
bool vis[maxn];
int num[maxn];
int node[maxn];
int que[maxn];
int nod[maxn];
struct Edge {
	int u,v;
	int next;
} edge[maxn];
int n,m;
int tol;
int cnt;
int ans;
int S,T;
bool flag;
void init() {
	memset(head,-1,sizeof(head));
	memset(node,0,sizeof(node));
	memset(num,0,sizeof(num));
	tol=0;
	cnt=0;
	ans=1;
	flag=true;
}
void add(int u,int v) {
	edge[tol].u=u;
	edge[tol].v=v;
	edge[tol].next=head[u];
	head[u]=tol++;
}
int bfs(int s) {
	int l=0,r=0;
	memset(vis,0,sizeof(vis));
	memset(que,0,sizeof(que));
	que[r++]=s;
	vis[s]=1;
	while(l<=r) {
		s=que[l++];
		for(int i=head[s]; i!=-1; i=edge[i].next) {
			int v=edge[i].v;
			if(vis[v]==0) {
				vis[v]=1;
				que[r++]=v;
			}
		}
	}
	return que[r-1];
}
void dfs(int u) {
	if(!flag)
		return;
	int top=0;
	vis[u]=1;
	for(int i=head[u]; i!=-1; i=edge[i].next) {
		int v=edge[i].v;
		if(vis[v]==0) {
			dfs(v);
			node[u]=max(node[u],node[v]);
			if(node[v]>1) top++;
			if(v!=T&&node[v]==1)
				num[u]++;
		}
	}
	node[u]++;
	if(top>=2) {
		flag=false;
		return;
	}
	if(u!=S&&u!=T&&node[u]>=2)
		nod[cnt++]=num[u];
}
void printf_(int u) {
	int t=ans;
	vis[u]=1;
	if(num[u]>0) {
		for(int i=1; i<=num[u]; i++) {
			printf("%d ",++ans);
		}
	}
	printf("%d%c",t,u==T?'\n':' ');
	ans++;
	for(int i=head[u]; i!=-1; i=edge[i].next) {
		int v=edge[i].v;
		if(v==T||v==S||node[v]>1) {
			if(!vis[v])
				printf_(v);
		}
	}
}
int read() {
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch) {
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int main() {
	while(~scanf("%d",&n)) {
		init();
		m=n-1;
		int u,v;
		for(int i=0; i<m; i++) {
			//scanf("%d %d",&u,&v);
			u=read();
			v=read();
			add(u,v);
			add(v,u);
		}
		T=bfs(1);
		S=bfs(T);
		memset(vis,0,sizeof(vis));
		dfs(S);
		/*cout<<S<<" "<<T<<endl;
		cout<<cnt<<endl;
		for(int i=1; i<=n; i++)
			printf("%d%c",node[i],i==n?'\n':' ');
		for(int i=1; i<=n; i++)
			printf("%d%c",num[i],i==n?'\n':' ');
		for(int i=0; i<cnt; i++)
			printf("%d%c",nod[i],i==cnt-1?'\n':' ');
		*/
		reverse(nod,nod+cnt);
		for(int i=0; i<cnt; i++) {
			if(nod[i]<nod[cnt-i-1])
				break;
			else if(nod[i]>nod[cnt-i-1]) {
				swap(S,T);
				break;
			}
		}
		memset(vis,0,sizeof(vis));
		if(!flag)
			printf("-1\n");
		else
			printf_(S);
	}
}

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

#define ll long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define vi vector < int >
#define pii pair < int, int >

const int N = 3007;
const int INF = 1e18 + 7;

int dp[N][N];

string s, t, a;

main(){
    cin >> s >> t;
    s = ' ' + s;
    t = ' ' + t;
    for (int i = 1; i < s.length(); i++){
        for (int j = 1; j < t.length(); j++){
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (s[i] == t[j])
                dp[i][j] = dp[i - 1][j - 1] + 1;
        }
    }
    int i = s.length(), j = t.length();
    while (i > 0 && j > 0){
        if (dp[i - 1][j] < dp[i][j] && dp[i][j - 1] < dp[i][j]){
            a += s[i];
            i--;
            j--;
        }
        else if (dp[i - 1][j] > dp[i][j - 1])
            i--;
        else
            j--;
    }
    reverse(a.begin(), a.end());
    cout << a;
}


Measured memory_bytes: 35456
// Charan Sriramula
 
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
 
const ll lg=22;
const ll N=2e5+5;
const ll M=5e8;
const ll INF=1e18;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;
 
#define is(n) scanf("%d",&n)
#define io(n) printf("%d\n",n)
#define ls(n) scanf("%lld",&n)
#define lo(n) printf("%lld\n",n)
 
#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
 
inline ll mul(ll a, ll b, ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b, ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b, ll p){ ll c = a + b; if(c > p) c -= p; return c; }
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

ll n,m,a[55][55],b[55][55];

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++){cin>>a[i];}
    sort(a,a+n);
    ll mid=n/2;
    cout<<a[mid]-a[mid-1]<<endl;
}


Measured memory_bytes: 1024
#c
N=int(input())
XYH = [None]*N
for i in range(N):
    XYH[i] = list(map(int,input().split()))

for cx in range(101):
    for cy in range(101):
        found=False
        for i in range(N):
            d = abs(XYH[i][0]-cx)+abs(XYH[i][1]-cy)
            if XYH[i][2]>0 and not found:
                h = XYH[i][2]+d
                break
        for i in range(N):
            d = abs(XYH[i][0]-cx)+abs(XYH[i][1]-cy)
            if XYH[i][2]!= max(0,h-d):
                break
        else:
            print(cx,cy,h)

Measured memory_bytes: 74140
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <functional>

using namespace std;
typedef long long ll;
priority_queue<ll,vector<ll>,greater<ll>> lnow;//lは小さい順に取り出したい
priority_queue<ll> rnow;//rは大きい順に取り出したい
ll a[300000];
ll lsum[300000];
ll rsum[300000];
int main()
{
	int n;
	ll ans=-1e16+1;
	cin>>n;
	for(int i=0;i<n*3;i++)
		cin>>a[i];
	lsum[n-1]=0;
	for(int i=0;i<n;i++)
	{
		lnow.push(a[i]);
		lsum[n-1]+=a[i];
	}
	//l側
	for(int i=n;i<2*n;i++)
	{
		ll tmp=lsum[i-1];
		//lは最大値
		if(a[i]>lnow.top())
		{
			tmp-=lnow.top();
			lnow.pop();
			lnow.push(a[i]);
			tmp+=a[i];
		}
		lsum[i]=tmp;
	}
	rsum[2*n]=0;
	for(int i=2*n;i<3*n;i++)
	{
		rnow.push(a[i]);
		rsum[2*n]+=a[i];
	}
	//r側
	for(int i=2*n-1;i>n-1;i--)
	{
		ll tmp=rsum[i+1];
		//rは最小値
		if(a[i]<rnow.top())
		{
			tmp-=rnow.top();
			rnow.pop();
			rnow.push(a[i]);
			tmp+=a[i];
		}
		rsum[i]=tmp;
	}
	for(int i=n-1;i<2*n;i++)
	{
		ans=max(ans,lsum[i]-rsum[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7668
N,M = map(int,input().split())
X = sorted(list(map(int,input().split())))
#X.sort()
B=[]

if N>=M:
    print(0)
else:
    for i in range(M-1):
        B.append(X[i+1]-X[i])

    B.sort()
    print(sum(B[:M-N]))



Measured memory_bytes: 20432
//author:emre yazicioglu

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define fori(a,b,c) for(ll a = b;a < ll(c);a++)
#define ford(a,b,c) for(ll a = b;a >= ll(c);a--)
#define pb emplace_back

const int N = 2e6 + 7;
ll n,m,k,ans,cur,ar[N];
string str;
vector<ll> v;
ll mn = 1e18;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);

	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
	
	cin >> n;
	fori(i,0,n)
		cin >> ar[i];

	ford(i,n - 1,0){
		if(ar[i] < mn)
			mn = ar[i];
		if(ar[i] - mn > 1){
			cout << "No";
			return 0;
		}

	}

	cout << "Yes";

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
  	int n,m; cin >> n >> m;
    string s; cin >> s;
    int sl=s.length();
    //int times=0;
    int now=0;
    /*
    while(now<sl-1){
        bool can=false;
        for(int i=m; i>0; i--){
            if(now+i>=sl) continue;
            if(s[now+i]=='0'){
                now+=i;
                times++;
                can=true;
                break;
            }
        }
        if(!can){
            cout << -1 << endl;
            return 0;
        }
    }
*/
    vector<int> ans;
    now=sl-1;

    while(now>0){
        bool can=false;
        for(int i=m; i>0; i--){
            if(now-i<0) continue;
            if(s[now-i]=='0'){
                now-=i;
                ans.push_back(i);
                can=true;
                break;
            }
        }
        if(!can){
            cout << -1 << endl;
            return 0;
        }
    }
    reverse(all(ans));
    rep(i,ans.size()) printf("%d ",ans[i]);
    return 0;
}


Measured memory_bytes: 1144
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    string s, t;
    cin >> s >> t;
    cout << t << s << endl;

    return 0;
}

Measured memory_bytes: 256
/* ex5_4
   moka223711 */

#include <stdio.h>
#define SIZE 11

int main(void){
    char input;
    int count = 0, ans = 0;
    while((input = getchar()) != EOF){ // EOF = End Of File ファイルの終端に入っている文字、stdio.h内で定義されている
        if(input=='A'||input=='C'||input=='G'||input=='T')count++; // 受け取った入力が'A'、'C'、'G'、'T'のいずれかであればcountをインクリメント
        else{
            if(count > ans)ans = count; // 入力が'A'、'C'、'G'、'T'でなければcountとansの大小関係を比較して、大きければansにcountを代入
            count = 0; // countを0にする
        }
    }
    printf("%d\n", ans); // ansはACGT文字列の長さの最大値である
    return 0;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

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

	auto N=in(),W=in();
	vll w(N),v(N);
	REP(i,N){
		w[i]=in();
		v[i]=in();
	}

	vvll dp(N+1,vll(W+1,0));
	REP(i,N){
		REP(j,W+1){
			chmax(dp[i+1][j],dp[i][j]);
			if(j+w[i]<=W) chmax(dp[i+1][j+w[i]],dp[i][j]+v[i]);
		}
	}
	out(dp[N][W]);
	return 0;
}


Measured memory_bytes: 83144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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; }

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int X; 
    cin >> X;
    LL ans = 0;
    ans += X / 500 * 1000;
    X %= 500;
    ans += X / 5 * 5;
    cout << ans << endl;

}


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    int n; cin >> n;
    long double a[n]; rep(i,n) cin >> a[i];
    long double ans = 0;
    rep(i,n) {
        ans += 1 / a[i];
    }
    cout << setprecision(15) << 1 / ans << endl;
    return 0;
}


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

using namespace std;

const int maxn=200010;
map<int,int> mp;
int n,k;
int s[maxn];

/*
s[r]-s[l] %k==r-l;
s[l]-l=s[r]-r;
*/

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		s[i]=s[i-1]+x;
		s[i]%=k;
	}
	for(int i=1;i<=n;i++) s[i]=(((s[i]-i)%k)+k)%k;
	long long ans=0;
	mp[0]=1;
	for(int i=1;i<=n;i++){
		if(i>=k) mp[s[i-k]]--;
		ans+=mp[s[i]];
		mp[s[i]]++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10368
s = list(set(list(input())))
s.sort()
if len(s) == 4:
    print('Yes')
elif len(s) == 2:
    if s[0] + s[1] == 'NS' or s[0] + s[1] == 'EW':
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

int A, B, C, D, E, F;

int main()
{
    cin >> A >> B >> C >> D >> E >> F;

    double ma = 0.0;
    int maall = 0, mas = 0;

    double limit = (double)100.0 * E / (100.0 + E);

    for (int a1 = 0; 100 * A * a1 <= F; a1++)
    {
        for (int a2 = 0; 100 * A * a1 + 100 * B * a2 <= F; a2++)
        {
            if (A * a1 + B * a2 == 0)
                continue;

            for (int a3 = 0; 100 * A * a1 + 100 * B * a2 + C * a3 <= F; a3++)
            {
                for (int a4 = 0; 100 * A * a1 + 100 * B * a2 + C * a3 + D * a4 <= F; a4++)
                {
                    double c = (double)100 * (C * a3 + D * a4) / (double)(100 * A * a1 + 100 * B * a2 + C * a3 + D * a4);

                    if (c <= limit)
                    {
                        if (c >= ma)
                        {
                            ma = c;
                            maall = 100 * A * a1 + 100 * B * a2 + C * a3 + D * a4;
                            mas = C * a3 + D * a4;
                        }
                    }
                }
            }
        }
    }

    cout << maall << " " << mas << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}








int main()
{
	
	string str;
	cin >> str;

	vector<int> a(str.size() + 1 , 0);
	vector<int> b(str.size() + 1, 0);

	//forward
	for (int i = 1; i < a.size(); i++) {
		if (str[i - 1] == '<') {
			a[i] = a[i - 1] + 1;
		}
		else {
			a[i] = 0;
		}
	}


	//backward
	for (int i = b.size() - 2; i >= 0; i--) {
		if (str[i] == '>') {
			b[i] = b[i + 1] + 1;
		}
		else {
			b[i] = 0;
		}
	}
	
	for (int i = 0; i < a.size(); i++) {
		if (a[i] < b[i])a[i] = b[i];
	}

	long long int ans = 0;
	for (int i = 0; i < a.size(); i++) {
		ans += a[i];
	}


	cout << ans << endl;


	return 0;

}



Measured memory_bytes: 4740
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n, k = Scanf.sscanf (read_line ()) "%d %d" @@ fun n k -> (n - 1, k - 1)
let a = read_line () |> split_string ~pattern:" " |> List.map int_of_string

let () = Printf.printf "%d\n" @@ (n + k - 1)/ k

Measured memory_bytes: 16392
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+10,M=1e4+10;
char s[N];int n,p,f[M];
ll ans,sum=0,x=1;

int main() {
	scanf("%d %d",&n,&p);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++) s[i]-='0';
	if(p==2||p==5) {
		for(int i=1;i<=n;i++)
			if(s[i]%p==0)
				ans+=i;
	}
	else {
		for(int i=n; i;i--) {
			sum=(sum+x*s[i])%p;
			x=x*10%p;
			f[sum]++;
		}
		ans=f[0]+(1LL*f[0]*(f[0]-1)>>1);
		for(int i=1;i<p;i++)
			ans+=1LL*f[i]*(f[i]-1)>>1;
	}
	printf("%lld\n",ans);return 0;
}



Measured memory_bytes: 384
s = input()

n=len(s)
res = [0]*n
L = 0
R = 0
c = 0
Ri = 0
Li = 0
for i in range(n):
	if s[i] == "R" and c == 1:
		if R % 2 == 0:
			RtmpR = R // 2
			RtmpL = R // 2
		else:
			RtmpR = R // 2 + 1
			RtmpL = R // 2
		if L % 2 == 0:
			LtmpR = L // 2
			LtmpL = L // 2
		else:
			LtmpR = L // 2
			LtmpL = L // 2 + 1
		L = 0
		R = 1
		res[Ri-1] = RtmpR + LtmpR
		res[Li-1] = RtmpL + LtmpL
		c = 0
		Li = i+1
		Ri = i+1	
	elif s[i] == "L" and i == n-1:
		L += 1
		if c == 0:
			Li = i+1
		if R % 2 == 0:
                        RtmpR = R // 2
                        RtmpL = R // 2
		else:
                        RtmpR = R // 2 + 1
                        RtmpL = R // 2
		if L % 2 == 0:
                        LtmpR = L // 2
                        LtmpL = L // 2
		else:
                        LtmpR = L // 2
                        LtmpL = L // 2 + 1
		res[Ri-1] = RtmpR + LtmpR
		res[Li-1] = RtmpL + LtmpL
	elif s[i] == "L" and c == 0:
		L += 1
		c = 1
		Li = i+1
	elif s[i] == "R":
		R += 1
		Ri += 1
		Li += 1
	elif s[i] == "L":
		L += 1
print(*res)

Measured memory_bytes: 6400
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n=k()
l=l()
a=[]
for i in range(n):
  a.append(0)
for i in range(n-1):
  a[l[i]-1]+=1
for i in range(n):
  print(a[i])


Measured memory_bytes: 34376
using System;
using System.Linq;
public class B{
    public static void Main(){
        string[] nt = Console.ReadLine().Split().ToArray();
        
        int n= int.Parse(nt[0]); int t= int.Parse(nt[1]);
        int ans = 100100100;
        for (int i =0;i<n;i++){
            string[] ct = Console.ReadLine().Split().ToArray();
            int ci= int.Parse(ct[0]); int ti= int.Parse(ct[1]);
            if (ti<=t){
                ans=Math.Min(ans,ci);
            }
        }
        if (ans<100100100){
        Console.WriteLine(ans);
        }
        else{Console.WriteLine("TLE");}
        
        
    }
}


Measured memory_bytes: 27992
#include <iostream>

using namespace std;

int main(){

    int A, B, C;
    cin >> A >> B >> C;

    int count = 0;
    int oA = A, oB = B, oC = C;
    while(A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
        int a = A / 2;
        int b = B / 2;
        int c = C / 2;

        A = b + c;
        B = c + a;
        C = a + b;

        if (A == oA && B == oB && C == oC){
            count = -1;
            break;
        }
        
        count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
a = [ list(map(int,input().split())) for _ in range(3) ]
n = int(input())
b = [ int(input()) for _ in range(n) ]

import numpy as np
a = np.array(a)
# print(a)
# print(n)
# print(b)

# print(a[1,0])
# print(a[2,2])

# c = a[1,1]
# print(c)


for i in range(n):
    if b[i] in a:
        r = np.where(a==b[i])
        a[r[0][0],r[1][0]] = 0
    else:
        pass


# print(a)
# print(a[1,0])

if a[0,0]==0 and a[2,2]==0 and a[1,1]==0:
    print("Yes")
elif a[0,1]==0 and a[2,1]==0 and a[1,1]==0:
    print("Yes")
elif a[0,2]==0 and a[2,0]==0 and a[1,1]==0:
    print("Yes")
elif a[1,0]==0 and a[1,2]==0 and a[1,1]==0:
    print("Yes")
elif a[0,0]==0 and a[1,0]==0 and a[2,0]==0:
    print("Yes")
elif a[0,2]==0 and a[1,2]==0 and a[2,2]==0:
    print("Yes")
elif a[0,0]==0 and a[0,1]==0 and a[0,2]==0:
    print("Yes")
elif a[2,0]==0 and a[2,1]==0 and a[2,2]==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;


void ABC171A()
{
	char x;
	cin >> x;
	if (x - 'a' <= 26 && x - 'a' >= 0)
	{
		cout << 'a' << endl;
	}
	else
	{
		cout << 'A' << endl;
	}
}
int main()
{
	ABC171A();
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    string S;
    int N, M;
    cin >> N >> M >> S;

    int l = N; //! left most position we have reached (starting from N(the goal))
    vector<int> ans;
    while (0 < l) {
        int nl = -1;
        for (int s = 1; s <= M && 0 <= l-s; ++s) {
            if (S[l-s] == '0') {
                // ok[l-s] = true;
                nl = l-s;
            }
        }
        if (nl < 0) {
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(l - nl);
        l = nl;
    }

    for (auto it = ans.rbegin(); it != ans.rend(); ++it) {
        cout << *it << ' ';
    }
    cout << endl;

    return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }
    sort(A, A + N);
    ll ans = INF;
    REP(i, N) {
        ll r = i + K - 1;
        if (r >= N)
            break;
        ans = std::min(abs(A[i] - A[r]), ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
module Sort_Module
    implicit none
    public
    contains
    recursive subroutine mergesort(a, p, r, b)
        integer(8) a(:), b(:)
        integer(8) p, r
        integer(8) q
        if (p < r) then
            q = (p+r)/2
            call mergesort(a, p, q, b)
            call mergesort(a, q+1, r, b)
            call merge(a, p, q, r, b)
        end if
    end subroutine mergesort
    subroutine merge(a, p, q, r, b)
        integer(8) a(:), b(:)
        integer(8) p, r, q, i, j, k
        integer(8) t
        k = p;   i = p;   j = q+1
        do
            if (.not. (k <= r)) exit
            if (j > r) then
                t = a(i);   i = i+1
            else if (i > q) then
                t = a(j);   j = j+1
            else if (a(i) <= a(j)) then
                t = a(i);   i = i+1
            else
                t = a(j);   j = j+1
            end if
            b(k) = t;   k = k+1
        end do
        do i = p, r
            a(i) = b(i)  
        end do
    end subroutine merge
    subroutine sort(a)
      integer(8) a(:), b(size(a)),n
      n = size(a)
      call mergesort(a,1_8,n,b)
    end subroutine sort



end module Sort_Module

program atcoder
    use Sort_Module
    implicit none
    integer(8) :: a(4)
    read*,a(1),a(2),a(3),a(4)
    call sort(a)
    if(a(1)==1.and.a(2)==4.and.a(3)==7.and.a(4)==9)then
        write(*,'(a)')"YES"
    else
        write(*,'(a)')"NO"
    endif

    stop 
contains


end program atcoder

Measured memory_bytes: 256
import itertools as ite
import math

INF = 10 ** 18

ls = set()
ls1 = map(int, raw_input().split())
ls2 = map(int, raw_input().split())
for i in range(1, len(ls1), 2):
    h, m = ls1[i], ls1[i + 1]
    ls.add((h, m))
for i in range(1, len(ls2), 2):
    h, m = ls2[i], ls2[i + 1]
    ls.add((h, m))
ls = sorted(list(ls))
for i in range(len(ls)):
    h, m = ls[i]
    if m >= 10:
        ls[i] = str(h) + ":" + str(m)
    else:
        ls[i] = str(h) + ":0" + str(m)
print " ".join(ls)



Measured memory_bytes: 4788
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;

int main(void) {
	int d, n;
	cin >> d >> n;
	if (d == 0) {
		int i = 0, count = 0;
		while (count < n) {
			i++;
			if (i % 100 != 0)count++;
		}
		cout << i << endl;
	}
	else {
		if (d == 1) {
			int i = 0, count = 0;
			while (count < n) {
				i += 100;
				if ((i % 100 == 0) && (i % 10000 != 0)) count++;
			}
			cout << i << endl;
		}
		else {
			int i = 0, count = 0;
			while (count < n) {
				i += 10000;
				if ((i % 10000 == 0) && (i % 1000000 != 0)) count++;
			}
			cout << i << endl;
		}
	}
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int a, b, c, d, p;
  cin >> a >> b >> c >> d >> p;
  cout << min(p * a, b + (p > c) * (p - c) * d) << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int a[5];
int n,x,res=0;
int main()
{
//	cin>>a[1]>>a[2]>>a[3];
//	sort(a+1,a+4);
//	cout<<a[3]-a[1];

	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>x,res+=x-1;
	cout<<res;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  ll a;
  double b;
  cin >> a >> b;
  ll ib = b * 100 + 0.5;
    
  a *= ib;
  a /= 100;
  
  cout << a << endl;
  
}


Measured memory_bytes: 3692