akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

#define int ll


const int N = 2e5+33, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;        // #include <ext/pb_ds/assoc_container.hpp>
typedef pair <ll, ll> pll;         // #include <ext/pb_ds/tree_policy.hpp>
typedef vector <ll> vi;          // #include <ext/rope>
                // #include <ext/rope>
                                 // #include <ext/rope>
bool prime(int n) {             // template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0){return 0;}
    }return 1;}


void solve() {
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}

main() {
    srand(time(0));
//    ios;
    int tt = 1;
//    cin >> tt;
    while(tt --) {
        solve();
//        brute();
    }
    return 0;
}
/*
2 2
2 1

01
10

01
10
11
*/


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    
    if (N == M) {
      System.out.print("Yes");
    } else {
      System.out.print("No");
    }
  }
}

Measured memory_bytes: 23892
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.score", "r", stdin );
	string str = "";

	vector <vector <int> > score (2, vector <int> (4, 0 ) );
	int i, j;

	for (i = 0; i < 2; ++i){
		getline (cin, str );
		stringstream ss(str);
		
		for (j = 0; j < 4; ++j){
			ss >> score[i][j];
		} // end for
	} // end for
	
	vector <int> total (2, 0 );

	for (i = 0; i < 2; ++i){
		 total[i] = accumulate (score[i].begin(), score[i].end(), 0 );
	} // end for
	
	cout << max (total[0], total[1] ) << endl;

	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int S(int n){
    int x = 0;
    int d = 10;
    while(n > 0){
        x += n % 10;
        n /= d;
    }
    return x;
}

int main(){
    int N;
    cin >> N;
    if(N % S(N) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

using namespace std;

int main(){
    string s,t,tmp; cin >> s >> t;
    vector<string> kouho;
    bool isfit;
    if(s.size() < t.size()){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for(int i = 0; i <= s.size() - t.size();i++) {
        isfit = true;
        for(int j = 0; j < t.size(); j++){
            if(s[i+j] != t[j] && s[i+j] != '?'){
                isfit = false;
                break;
            }
        }
        if(isfit) {
            tmp = s;
            tmp.replace(i,t.size(),t);
            kouho.push_back(tmp);
        }
    }
    if(kouho.size() == 0){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for(int i = 0; i < kouho.size();i++){
        while(kouho[i].find('?') != -1){
            tmp = kouho[i];
            tmp.replace(tmp.find('?'),1,"a");
            kouho[i] = tmp;
        }
    }
    sort(kouho.begin(), kouho.end());
    cout << kouho[0] << endl;
}



Measured memory_bytes: 256
#Maximum Profit
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_D&lang=jp

n = int(input())
min = int(input())
profit = -999999999

for i in range(0,n-1):
    s = int(input())
    if (s - min > profit):
        profit = s - min
    if (min > s):
        min = s
print (profit)



Measured memory_bytes: 5612
n, k = list(map(int, input().split()))
d = list(input().split())
ans = n
find = False
while find == False:
    p = str(ans)
    find = True
    for i in range(len(p)):
        if p[i] in d:
            find = False
            break
    if find == False:
        ans += 1

print(ans)


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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 2e5 + 100;
const int mod = 1e9 + 7;

void hey ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main ()
{
	hey();
	string s;
	cin >> s;
	if (s == "ABC")
	{
		cout << "ARC";
	}
	else {
		cout << "ABC";
	}	
}




Measured memory_bytes: 3616
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  998244353
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
ll modularExponentiation(ll x,ll n)
{
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%MOD;
        x=(x*x)%MOD;
        n=n/2;
    }
    return result;
}
ll fact[N],inv[N];
ll ncr(ll n,ll r)
{
     ll ans = (fact[n]*inv[r])%MOD;
     ans = (ans * inv[n-r])%MOD;
     return ans;
}
void solve()
{
     fact[0] = inv[0] = 1;
     for(ll i=1;i<N;i++)
     {
          fact[i] = (fact[i-1] * i)%MOD;
          inv[i] = modularExponentiation(fact[i],MOD-2);
     } 
     ll ans = 0;
     ll n,m,k;
     cin >> n >> m >> k;
     for(ll i=0;i<=k;i++)
     {
          ll temp = ncr(n-1,i);
          temp = (temp * modularExponentiation(m-1,n-1-i))%MOD;
          ans = (ans + temp)%MOD;
     }
     ans = (ans * m)%MOD;
     cout<<ans;
}

int main()
{
     FAST;
     ll t = 1;
   //  cin >> t;
     while(t--)
     {
          solve();
     }
}

Measured memory_bytes: 6752
#!/usr/bin/env python
from __future__ import division, print_function
import itertools
import sys


def main():
    n = int(sys.stdin.readline().strip())
    scores = []
    for _ in range(n):
        scores.append(int(sys.stdin.readline().strip()))
    s = sum(scores)
    if s % 10 != 0:
        print(s)
        return

    for s in scores:
        if s % 10 != 0:
            break
    else:
        print(0)
        return

    scores.sort()

    for s in scores:
        if s % 10 != 0:
            print(sum(scores) - s)
            return



if __name__ == '__main__':
    main()


Measured memory_bytes: 2692
#include<cstdio>
#include<cmath>
#include<algorithm>
#define LL long long
#define MOD 1000000007
using namespace std;

LL n,m,ans;

LL cal(LL x){
	LL i;LL re=1;
	for(i=1;i<=x;i++){
		re=(re*i)%MOD;
	}
	return re;
}

int main(){
	scanf("%lld%lld",&n,&m);
	if(abs(m-n)>=2){
		printf("0\n");
		return 0;
	}
	if(m==n){
		LL t=cal(n);
		ans=(t*t*2)%MOD;
	}
	else{
		ans=(cal(m)*cal(n))%MOD;
	}
	printf("%lld\n",ans);
	return 0;
}


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

using namespace std;

int digit_sum(int num)
{
	int sum = 0;

	while (num > 0)
	{
		sum += num % 10;
		num /= 10;
	}

	return sum;
}

int main()
{
	int N, A, B;
	int ans = 0;

	cin >> N >> A >> B;

	for (int i = 1; i <= N; i++)
	{
		int d_sum = digit_sum(i);
		if (A <= d_sum && d_sum <= B)
		{
			ans += i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for (int i = 1;; i++) {
			int x = sc.nextInt();
			if (x != 0) {
				System.out.printf("Case %d: %d\n", i, x);
			} else {
				break;
			}
		}
	}
}

Measured memory_bytes: 62680
n = int(input())
s1 = input()
s2 = input()
mod = 10**9+7

if n == 1:
  print(3)
  exit()
  
ans = 6
for i in range(2,n):
  if s1[i] == s2[i]:
    if s1[i-1] == s2[i-1]:
      ans *= 2
      ans %= mod
  elif s1[i] != s2[i] and s1[i] != s1[i-1]:
    if s1[i-1] == s2[i-1]:
      ans *= 2
      ans %= mod
    else:
      ans *= 3
      ans %= mod

print(ans)

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

int main(){
  string S;
  cin >>S;
  if(S.at(0) == S.at(1) &&  S.at(2)== S.at(3) && S.at(0)==S.at(2)){
    cout << "No" << endl;
  }
  else if(S.at(0)==S.at(1) && S.at(2)==S.at(3)){
    cout << "Yes" << endl;
  }
  else if(S.at(0)==S.at(2) && S.at(1)==S.at(3)){
    cout << "Yes" << endl;
  }
  else if(S.at(0)==S.at(3) && S.at(1)==S.at(2)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	int k,m,n;
	int zd=-100000,zx=100000;
	for(register int i=1;i<=5;i++){
		scanf("%d",&n);
		zd=max(zd,n);
		zx=min(zx,n);
	}
	scanf("%d",&m);
	if(zd-zx>m)puts(":(");
	else puts("Yay!");
	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/dp/tasks/dp_h
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	int h,w;
	cin >> h >> w;
	vector<vector<char>> a (h, vector<char>(w));
	vector<vector<int>> dp (h, vector<int>(w));
	for (auto& x:a) {
		for (auto& y:x) {
			cin >> y;
		}
	}
	dp[0][0] = 1;
	int mod = 1e9+7;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '.') {
				if (j > 0) {
					dp[i][j] = (dp[i][j]%mod + dp[i][j-1]%mod)%mod; 
				}
				if (i > 0) {
					dp[i][j] = (dp[i][j]%mod + dp[i-1][j]%mod)%mod; 
				}
			}
		}
	}
	cout << dp[h-1][w-1] << endl;
	return 0;
}

Measured memory_bytes: 5248
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1int;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll d[26];

int main() {
  string s;
  cin>>s;
  ll n = s.sz;
  if(n==1){
    cout << 1 << endl;
    return 0;
  }
  clr(d,0);
  rep(i,0,s.sz){
    d[s[i]-'a']++;
  }
  ll ans1 = 0;
  rep(i,0,26){
    if(d[i]<2)continue;
    ans1 += d[i]*(d[i]-1)/2;
  }
  ll ans2 = n*(n-1)/2;
  printf("%lld\n",ans2-ans1+1);
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;

int main(void)
{
    char a,b,c,d,i,j,k,n,x[10];
    string s;
    char C[5];

    cin >> a >> b;


    if(a==b) cout << "H";
    else cout << "D";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string name[10];
	int a, b, c[10], d[10];
	for (int i = 1; i <= 9; i++) {
		cin >> name[i] >> a >> b;
		c[i] = a + b;
		d[i] = a * 200 + b * 300;
	}
	for (int i = 1; i <= 9; i++) {
		cout << name[i] << " " << c[i] << " " << d[i] << endl;
	}
}


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

int main() {
  int N,sum=0;
  cin>>N;
  for(int i=0; i<N; i++){
  int l,r;
    cin >> l >> r;
  
      sum+=r-l+1;
     
       
  }
  cout<<sum<<endl;
 }



Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val graph = Array(n) { emptyList<Int>().toMutableList() }
    for (i in 1 until n) {
        val (a, b) = readLine()!!.split(' ').map(String::toInt)
        graph[a - 1].add(b - 1)
        graph[b - 1].add(a - 1)
    }

    fun namazu(first: Int): Array<Int> {
        val score = Array(n) { 0 }
        val visited = Array(n) { false }
        val queue = ArrayDeque<Int>()
        visited[first] = true
        queue.add(first)
        while(queue.isNotEmpty()) {
            val po = queue.remove()
            graph[po].forEach {
                if (!visited[it]) {
                    queue.add(it)
                    visited[it] = true
                    score[it] = score[po] + 1
                }
            }
        }

        return score
    }

    val score1 = namazu(0)
    val score2 = namazu(n-1)
    var fenekku = 0
    for (i in 0 until n) {
        if (score1[i] <= score2[i]) {
            fenekku += 1
        }
    }
    println(if (fenekku > n - fenekku) "Fennec" else "Snuke")
}

Measured memory_bytes: 76240
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,M,X;
  cin>>N>>M>>X;
  vector<vector<ll>>A(N,vector<ll>(M+1));
  for(ll i=0;i<N;i++){
    for(ll j=0;j<M+1;j++){
      cin>>A[i][j];
    }
  }

  ll ans=1e+9;
  for(ll bit=0;bit<(1<<N);bit++){
    vector<ll>alg(M+1,0);
    ll flag=1;
    ll money=0;
    for(ll i=0;i<N;i++){
      if(bit&(1<<i)){
        money+=A[i][0];
        for(ll j=1;j<M+1;j++){
          alg[j]+=A[i][j];
          
          //cout<<"A"<<A[i][0]<<endl;
        }
      }
    }
    //cout<<"money"<<money<<endl;
    for(ll j=1;j<M+1;j++){
      if(alg[j]<X)flag=-1;
    }
    if(flag==1){
      ans=min(ans,money);
    }
  }
  if(ans==1e+9){
    cout<<-1<<endl;
    return 0;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3572
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <tuple>
#include <utility>
#include <limits>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cstdint>
#include <cassert>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)



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

    int mat[100][100];
    REP(i, n) {
        REP(j, n) {
            mat[i][j] = 0;
        }
    }

    REP(_, n) {
        int u, k;
        cin >> u >> k;

        REP(_, k) {
            int v;
            cin >> v;
            mat[u-1][v-1] = 1;
        }
    }

    REP(i, n) {
        REP(j, n) {
            cout << mat[i][j];
            cout << (j == n-1 ? '\n' : ' ');
        }
    }

    return 0;
}

Measured memory_bytes: 3108
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  int Bi, Bip1;
  cin >> Bi;
  int ans = Bi;
  for(int i = 2; i < N; i++) {
    cin >> Bip1;
    ans += min(Bi, Bip1);
    Bi = Bip1;
  }
  ans += Bi;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve2
  }

  def solve2(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val as = new Array[Long](n)
    for (i <- 0 until n) {
      as(i) = sc.nextLong
    }

    val l = new Array[Long](n + 1)
    l(0) = 0
    for (i <- 0 until n) {
      l(i + 1) = gcd(l(i), as(i))
    }
    var r = new Array[Long](n + 1)
    r(n) = 0
    for (i <- n - 1 until 0 by -1) {
      r(i) = gcd(r(i + 1), as(i))
    }

    var maxGCD = -1L
    for (i <- 0 until n) {
      maxGCD = math.max(maxGCD, gcd(l(i), r(i + 1)))
    }

    println(maxGCD)
  }


  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val as = new Array[Long](n)
    for (i <- 0 until n) {
      as(i) = sc.nextLong
    }

    var skipIndex = 0
    var maxGCD = -1L
    for (i <- 0 until n) {
      var tmpGCD = -1L

      for (j <- 0 until n) {
        if (j != skipIndex) {
          if (tmpGCD == -1) {
            tmpGCD = as(j)
          }
          else {
            tmpGCD = gcd(tmpGCD, as(j))
          }
        }
      }
      maxGCD = math.max(maxGCD, tmpGCD)
      skipIndex += 1
    }

    println(maxGCD)
  }

  def gcd(x: Long, y: Long): Long = {
    if (x == 0) y
    else gcd(y % x, x)
  }

}


Measured memory_bytes: 52364
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int ans;
int main() {
	string s, h;
	cin >> s;
	h = s;
	reverse(h.begin(), h.end());
	for (int i = 0; i < (h.length() - 1) / 2 + 1; ++i) {
		++ans;
		if (s[i] == h[i] && (s[i] == 'i' || s[i] == 'w')) { --ans; }
		if (s[i] != h[i] && ((s[i] == '('&&h[i] == ')') || (s[i] == ')'&&h[i] == '('))) { --ans; }
		if (i == (h.length() - 1) / 2 + 1 && (h[(h.length() - 1) / 2 + 1] == 'i' || h[(h.length() - 1) / 2 + 1] == 'w')) { --ans; }
	}
	cout << ans << endl;
}


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

int main(void) {
    int a, b, c;
    while (1) {
        cin >> a >> b >> c;
        if (a == -1 && b == -1 && c == -1) break;
        if (a == -1 || b == -1) cout << "F" << endl;
        else if (a + b >= 80) cout << "A" << endl;
        else if (a + b >= 65) cout << "B" << endl;
        else if (a + b >= 50) cout << "C" << endl;
        else if (a + b >= 30) {
            if (c >= 50) cout << "C" << endl;
            else cout << "D" << endl;
        }
        else cout << "F" << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
s = input()
flag = 0

for i in range(len(s)):
  if i%2 == 0 and s[i] == "L": #奇数文字目がL
    flag = 1
    break
  if i%2 == 1 and s[i] == "R": #偶数文字目がR
    flag = 1
    break

if flag == 1:
  print("No")
else:
  print("Yes")
  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const int N=3005;
int dp[N][N];
string s,t;
int f(int i, int j){
	if(SZ(s)==i||SZ(t)==j)return 0;
	int &r=dp[i][j];
	if(r!=-1)return r;
	r=max(f(i+1,j),f(i,j+1));
	if(s[i]==t[j])r=max(r,f(i+1,j+1)+1);
	return r;
}
void gen(int i, int j){
	if(SZ(s)==i||SZ(t)==j)return;
	int r=f(i,j);
	if(s[i]==t[j]&&r==f(i+1,j+1)+1){cout<<s[i];gen(i+1,j+1);}
	else if(f(i+1,j)==r)gen(i+1,j);
	else gen(i,j+1);
}

int main(){FIN;mset(dp,-1);
	cin >> s >> t;
	gen(0,0);cout<<"\n";
}

Measured memory_bytes: 36096
N, M = map(int, input().split())
pref = []
pref_dict = {i+1: [] for i in range(N)}
for _ in range(M):
    P, Y= map(int, input().split())
    pref.append((P, Y))
    pref_dict[P].append(Y)

for p, cities in enumerate(pref_dict.values()):
    pref_dict[p+1] = dict(zip(sorted(cities), range(1, len(cities)+1)))

for i, (p, y) in enumerate(pref):
    print('{0:06d}'.format(pref[i][0]) + '{0:06d}'.format(pref_dict[pref[i][0]][pref[i][1]]))

Measured memory_bytes: 72252
def bis(l,target,start, end):
    while(start<end):
        mid = (start + end )//2
        if target > l[mid]:
            end = mid
        else:
            start = mid + 1
    return start

l = []
n = int(input())
for i in range(n):
    x = int(input())
    if l == []:
        l.append(x)
    else:
        idx = bis(l,x,0,len(l)-1)
        #print(l)
        #print(x,idx)
        if x > l[idx]:
            l[idx] = x
        else:
            l.append(x)
#print(l)
print(len(l)) 


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

cnt = [[0] * 10 for _ in range(10)]

for i in range(1,N+1):
    S = str(i)
    cnt[int(S[0])][int(S[-1])] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)

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

typedef long long ll;

int main() {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    printf("%lld\n", min((ll)(a % 2) * b * c, min((ll)(b % 2) * a * c, (ll)(c % 2) * a * b)));
    return 0;
} 


Measured memory_bytes: 128
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val data = Array(n) { sc.nextInt() to sc.nextInt() }
    var ans = 0L
    var rem = m
    data.sortBy { it.first }
    for (i in 0 until n) {
        val c = Math.min(rem, data[i].second)
        rem -= c
        ans += c * data[i].first.toLong()
    }
    println(ans)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 67848
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int nt = 0;
        int nx = 0;
        int ny = 0;

        boolean isOk = true;
        for (int i = 0; i < n; i++) {
            int t = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();

            long distance = (Math.abs(nx - x) + Math.abs(ny - y));
            if (((t - nt) < distance || ((t - nt) - distance) % 2 != 0)) {
                isOk = false;
                break;
            }
        }
        System.out.println(isOk?"Yes":"No");
    }
}


Measured memory_bytes: 86840
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

int n,ans;
char a[1000005],t[1000005];
int pre;

queue<int>Q;

int same(){
	for(int i=1;i<=n;i++){
		if(a[i]!=t[i])return 0;
	}return 1;
}

int main(){
	scanf("%d",&n);
	scanf("%s",a+1);
	for(int i=1;i<=n;i++)a[i]-='a'-1;
	scanf("%s",t+1);
	for(int i=1;i<=n;i++)t[i]-='a'-1;
	if(same()){
		printf("0\n");
		return 0;
	}int i=n,pre=0;
	for(int j=n;j;j--){
		i=min(i,j);
		while(i&&a[i]!=t[j])i--;
		if(i==0){
			printf("-1");
			return 0;
		}if(i==pre)continue;
		pre=i;
		while((!Q.empty())&&j<=Q.front()-Q.size())Q.pop();
		Q.push(pre);
		ans=max(ans,(int)Q.size());
	}printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6272
<?php
  fscanf(STDIN, '%s', $code);
	$num = $code[0];
	$result = 'Good';
	for($i = 1; $i < 4; $i++){
      if($code[$i] == $num){
		$result = 'Bad';
        break;
      }else{
        $num = $code[$i];
      }
    }
	echo $result;

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

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

const ull mod = 1000000007;

int main(void)
{
	ll n, m;
	cin >> n >> m;
	vector<vector<ll>> g(n);
	rep(i, m) {
		ll u, v;
		cin >> u >> v;
		u--; v--;
		g[u].emplace_back(v);
	}
	ll s, t;
	cin >> s >> t;
	s--; t--;
	vector<map<ll,ll>> distance(n);
	queue<P> q;
	q.emplace(s, 0);
	while (!q.empty()) {
		auto top = q.front(); q.pop();
		if (distance[top.first].count(top.second % 3)) continue;
		distance[top.first].emplace(top.second % 3, top.second);
		if (top.first == t && top.second % 3 == 0) break;
		if (top.second > 1e6) break;
		auto nextDistance = top.second + 1;
		auto nextMod = nextDistance % 3;
		bool finish = false;
		for (auto p : g[top.first]) {
			if (distance[p].count(nextMod)) continue;
			q.emplace(p, nextDistance);			
			if (p == t && nextDistance % 3 == 0) {
				distance[t].emplace(0, nextDistance);
				finish = true;
				break;
			}
		}
		if (finish) break;
	}
	if (distance[t].count(0))
	{
		cout << distance[t][0] / 3 << endl;
		return 0;
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 29312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 100000000000000017
#define MAXN 100005
int n, a[MAXN], b[MAXN], c[MAXN];
ll dp[3][MAXN], w[3][MAXN];

int binaly_serch(int part, int num){
    int ub = n, lb = 0;
    while(ub - lb > 1){
        int mid = (ub + lb) / 2;
        if(w[part][mid] >= w[part + 1][num]){
            ub = mid;
        }
        else{
            lb = mid;
        }
    }
    return lb;
}

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    dp[0][0] = 1;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < n; j++){
            if(i == 0){
                w[i][j] = a[j];
                if(j)dp[i][j] = dp[i][j - 1] + 1;
            }
            else if(i == 1){
                w[i][j] = b[j];
            }
            else if(i == 2){
                w[i][j] = c[j];
            }
        }
    }
    for(int i = 1; i < 3; i++){
        for(int j = 0; j < n; j++){
            if(j > 0){
                if(w[i][j] > w[i - 1][0]){
                    dp[i][j] = dp[i][j - 1] + dp[i - 1][binaly_serch(i - 1, j)];
                }
                else{
                    dp[i][j] = 0;
                }
            }
            else {
                if(w[i][j] > w[i - 1][0]){
                    dp[i][j] = dp[i - 1][binaly_serch(i - 1, j)];
                }
                else{
                    dp[i][j] = 0;
                }
            }
        }
    }
    cout << dp[2][n - 1] << endl;

    return 0;
}


Measured memory_bytes: 6144
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

using Comb::exgcd;
using Comb::inv;

inline ll gcd(ll a, ll b) {
    if (!b) return a;
    else return gcd(b, a % b);
}

ll n, a[N], g, prod = 1, lcm = 1, ans;
int buc[N * 20], ub;

inline void div(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (x % i != 0) continue;
        int cnt = 0;
        while (x % i == 0) {
            cnt++;
            x /= i;
        }
        buc[i] = std::max(buc[i], cnt);
    }
    if (x != 1) buc[x] = std::max(buc[x], 1);
}

inline ll fpow(ll a, int n) {
    ll res = 1;
    for (; n; n >>= 1, a = a * a % MOD) if (n & 1) res = res * a % MOD;
    return res;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        div(a[i]);
        chkmax(ub, (int)a[i]);
    }
    for (int i = 2; i <= ub; i++) {
        // if (buc[i]) printf("%d %d\n", i, buc[i]);
        (lcm *= fpow(i, buc[i])) %= MOD;
    }
    for (int i = 1; i <= n; i++) {
        (ans += lcm * inv(a[i]) % MOD) %= MOD;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int val = 0, den = 1;
    string s;
    cin >> s;
    int f = 0;
    for (auto &&i : s) {
        if(!f){
            if(i == '.') f++;
            else {
                val = val*10+i-'0';
            }
        }else {
            if(i == '(') break;
            val = val*10+i-'0';
            den = den*10;
        }
    }
    f = 0;
    int val2 = 0, den2 = den;
    for (auto &&i : s) {
        if(!f){
            if(i == '(') f++;
        }else {
            if(i == ')') break;
            val2 = val2*10+i-'0';
            den2 = den2*10;
        }
    }
    if(den2 != den){
        den2 -= den;
        int g = __gcd(den, den2);
        val *= den2/g; val += val2*(den/g);
        den *= (den2/g);
    }
    int g = __gcd(val, den);
    val /= g; den /= g;
    cout << val << "/" <<  den << "\n";
    return 0;
}


Measured memory_bytes: 3220
N = int(input())
cnt = 0

for i in range(1,N+1):
	if i%2 == 1:
		yaku = 0
		for j in range(1,i+1):
			if i%j == 0:
				yaku += 1
		if yaku == 8:
			cnt+= 1


print(cnt)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
#define INF (1 << 31) - 1

int main() {
  ll N;
  cin >> N;
  ll K;
  cin >> K;
  int A[N];
  rep(i,N){
    cin >> A[i];
  }
  int city[2*N+1];
  city[0] = 1;
  //city[N]はN秒後にいる場所
  for(ll i=1; i<=2*N; i++){
    city[i] = A[city[i-1]-1];
  }
  ll cycle = 0;
  for(ll i=N-1; i>=0; i--){
    if(city[i] == city[N]){
      cycle = N-i;
      break;
    }
  }
  if(K<=2*N) cout << city[K] << endl;
  else{
    ll r = (K-N) % cycle;
    cout << city[N+r] << endl;
  }
    
}

Measured memory_bytes: 5976
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int H{}, W{};
  int A{}, B{};
  scanf("%d %d %d %d\n", &H, &W, &A, &B);

  int res{};
  for (int row = 0; row < H; ++row){
    res ^= 1;
    if(row == B) res ^= 1;
    for (int column = 0; column < W; ++column){
      if(column == A) res ^= 1;
      printf("%d", res);
    }
    printf("\n");
  }

  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;cin>>N>>M;
  vector<int> L(M);
  vector<int> R(M);
  for(int i=0;i<M;i++)cin>>L[i]>>R[i];
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
  int a=R.at(0)-L.at(M-1)+1;
  cout<<(a>=0?a:0)<<endl;
}

Measured memory_bytes: 1024
word = input()
n = int(input())
for _ in range(n):
    meirei = input().split()
    if meirei[0] == "print":
        print(word[int(meirei[1]):int(meirei[2])+1])
    elif meirei[0] == "reverse":
        word = word[:int(meirei[1])] + word[int(meirei[1]):int(meirei[2])+1][::-1] + word[int(meirei[2])+1:]
    elif meirei[0] == "replace":
        word = word[:int(meirei[1])] + meirei[3] + word[int(meirei[2])+1:]
        


Measured memory_bytes: 5620
# coding: utf-8
# Tasks: EDPC(Educational DP Contest) E - Knapsack 2
import sys
input = sys.stdin.readline

def f(n, W):
    dp = [float('inf')] * (100010)
    dp[0] = 0
    maxv = 0
    for i in range(n):
        wi, vi = map(int, input().split())
        maxv += vi
        for v in range(maxv, -1, -1):
            w_ = wi if v - vi < 0 else dp[v - vi] + wi
            if dp[v] > w_ and w_ <= W:
                dp[v] = w_
    return(dp.index(float('inf')) - 1)

n, w = map(int, input().split()) # 1 <= n <= 100, 1 <= w <= 10^9
print(f(n, w))


Measured memory_bytes: 6896
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include <string.h>
using namespace std;
typedef long long ll;
ll parent[300001],s[200005],v[1000005];
ll root(ll x)
{
    if (parent[x]==x)
        return x;
    else
        return parent[x]=root(parent[x]);
}
void bing(ll x,ll y)
{
    ll rx,ry;
    rx=root(x);
    ry=root(y);
    if(rx!=ry)
        parent[rx]=ry;
}
int main ()
{
    ll m,n,k,a,ans=0,i,b,z,x,j,ma=-1;
    scanf("%lld %lld",&n,&m);
    for(i=0; i<=300000; i++)
    {
        parent[i]=i;
    }
    for(i=1; i<=m; i++)
    {
        scanf("%lld",&a);
        scanf("%lld",&b);
        bing(a,b);
    }
    for(i=0; i<=n; i++)
    {
        v[root(parent[i])]++;
       ma=max(ma,v[root(parent[i])]);

    }
    printf("%lld\n",ma);

}



Measured memory_bytes: 12200
import heapq

n = int(input())
ll, rr = [], []
task = []
ans = 0
for _ in range(n):
    l, r = map(int, input().split())
    heapq.heappush(ll, -l)
    heapq.heappush(rr, r)
    task.append([l, r])
maxl1, minr1 = -heapq.heappop(ll), heapq.heappop(rr)
maxl2, minr2 = -heapq.heappop(ll), heapq.heappop(rr)
for i in range(n):
    ma = maxl1 if not task[i][0] == maxl1 else maxl2
    mi = minr1 if not task[i][1] == minr1 else minr2
    ans = max(ans, task[i][1] - task[i][0] + max(0, mi - ma + 1) + 1)
task.sort()
score = [0] * (n - 1)
l1, r1 = task[0][0], task[0][1]
l2, r2 = task[n - 1][0], task[n - 1][1]
i, j = 0, n - 1
for _ in range(n - 1):
    l1, r1 = max(l1, task[i][0]), min(r1, task[i][1])
    l2, r2 = max(l2, task[j][0]), min(r2, task[j][1])
    j -= 1
    score[i] += max(0, r1 - l1 + 1)
    score[j] += max(0, r2 - l2 + 1)
    i += 1
ans = max(ans, max(score))
print(ans)

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


int main(){
	char input;
	cin >> input;
	if(input == 'a'||input == 'i'||input == 'u'||input == 'e'||input == 'o'){
		cout << "vowel"  << endl;
	}else{
		cout << "consonant" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
 
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
#define INF (1LL<<61)
typedef long long int ll;
ll a, b, c, d;
ll sum[600][600], d_sum[600][600], d_sum2[600][600];
 
int main() {
	ll N, M, Q;
	scanf("%lld%lld%lld", &N, &M, &Q);
	loop(i, M) {
		scanf("%lld%lld", &a, &b);
		++d_sum[a][b];
	}
	loop(i, N+1) {
		ll tmp = 0;
		loop(n, N+1) {
			tmp += d_sum[i][n];
			d_sum2[i][n] = tmp;
		}
	}
	loop(n, N+1) {
		ll tmp = 0;
		loop(i, N+1) {
			tmp += d_sum2[i][n];
			sum[i][n] = tmp;
		}
	}
	while (Q--) {
		scanf("%lld%lld", &a, &b);
		printf("%lld\n", sum[b][b] - sum[b][a - 1] - sum[a - 1][b] + sum[a - 1][a - 1]);
	}
 
	return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;


void solve()
{ 
int n,i;
    cin>>n;
    vector<int>a(n);
    for(int &x:a)cin>>x;
    stack<int>s;
    ll have=1000;
    for(int i=0; i<a.size()-1; i++){
        if(a[i+1] > a[i]){
              ll  stock=have/a[i];
            have-=(stock*a[i]);
            have+=(stock*a[i+1]);
        }
        }
    cout<<have<<endl;
    
    
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 3516
S=input()
T=[]
result='None'
for i in range(len(S)):
  T.append(S[i])
T=list(set(T))
T.sort()
A='abcdefghijklmnopqrstuvwxyz'
for j in range(len(T)):
  if T[j]!=A[j]:
    result=A[j]
    break
  if j == (len(T)-1) and len(T) != len(A):
    result=A[j+1]
print(result)

Measured memory_bytes: 3956
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
    /*ld r;cin>>r;
    cout<<r*2*pi<<endl;*/
    ll n;cin>>n;
    vector<ll>ans(n,0);
    rep(i,n-1){
        ll a;cin>>a;a--;
        ans[a]++;
    }
    rep(i,n)cout<<ans[i]<<endl;
    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 4784
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  int K;
  cin>>K;
  vector<string> arr;
  map<string, int> amap;
  string tmp;
  int N = S.size();
  for(int i=0;i<S.size();++i) {
    for(int j=1;j<=min(K, N-i);++j) {
      tmp = S.substr(i, j);
      if(amap[tmp]==0) arr.push_back(tmp);
      amap[tmp]++;
    }
  }
  sort(arr.begin(), arr.end());
  cout<<arr[K-1]<<endl;
}



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

typedef long long ll;

int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n],b[n];
  for(int i=0;i<n;i++) cin >> a[i] >> b[i];
  ll count[100001];
  for(int i=0;i<100001;i++){
    count[i]=0;
  }
  for(int i=0;i<n;i++){
    count[a[i]]+=b[i];
  }
  ll ans=0;
  while(k>0){
    k-=count[ans];
    ans++;
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cctype>

using namespace std;
typedef long long ll;

char field[71][71];
string dp[71][71];

bool str_less(const string &a, const string &b){
	if(a.size() < b.size()){ return true; }
	if(a.size() > b.size()){ return false; }
	return a < b;
}

int main(){
	while(true){
		int W, H;
		cin >> W >> H;
		if(W == 0 && H == 0){ break; }
		memset(field, 0, sizeof(field));
		for(int i = 0; i < H; ++i){ cin >> field[i]; }
		for(int i = 0; i <= H; ++i){
			for(int j = 0; j <= W; ++j){ dp[i][j] = ""; }
		}
		string answer = "";
		for(int i = H - 1; i >= 0; --i){
			for(int j = W - 1; j >= 0; --j){
				if(isdigit(field[i][j])){
					if(str_less(dp[i + 1][j], dp[i][j + 1])){
						dp[i][j] = field[i][j] + dp[i][j + 1];
					}else{
						dp[i][j] = field[i][j] + dp[i + 1][j];
					}
					string value = "";
					for(int k = 0; k < dp[i][j].size(); ++k){
						if(dp[i][j][k] != '0'){
							value = string(dp[i][j].c_str() + k);
							break;
						}
					}
					if(str_less(answer, value)){ answer = value; }
				}
			}
		}
		cout << answer << endl;
	}
	return 0;
}

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

int main(){
  ll N, K, Q;
  
  cin >> N >> K >> Q;
  vector<ll> A(Q);
  for(int i=0; i<Q; i++) cin >> A[i];
  vector<ll> loss(N);
  for(int i=0; i<N; i++) loss[i] = Q;
  for(int i=0; i<Q; i++) loss[A[i]-1]--;
  
  for(int i=0; i<N; i++){
   if(K-loss[i]>0){
     cout << "Yes" << endl;
   } else{
     cout << "No" << endl;
   }
  }
  

  return 0;
}


Measured memory_bytes: 4728
#include<stdio.h>
int main(void){
    unsigned long int h,w;
    scanf("%ld%ld",&h,&w);
    if(h==1 || w == 1){
        printf("1");
    }else if(h != 1 && w != 1){
    if((h*w)%2 == 1){
        printf("%ld",(h*w)/2 + 1);
    }else if((h*w)%2 == 0){
        printf("%ld",(h*w)/2);
    }
    }
    return 0;
}

Measured memory_bytes: 128
k = int(input())
s = input()
len_s = len(s)
MOD = 1000000007

x_i = pow(26, k, MOD)
r = (25 * pow(26, -1, MOD)) % MOD
comb_i = 1

a = 0
for i in range(k + 1):  
  a += (comb_i  * x_i  ) % MOD
  a %= MOD
  
  x_i  = (x_i  * r) % MOD
  comb_i = (comb_i * (len_s + i) * pow(i + 1, -1, MOD)) % MOD


print(a)

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

px = 0
py = 0
pt = 0

for _ in range(N):
  T, X, Y = (int(i) for i in input().split())

  d = abs(X - px + Y - py)
  dt = (T - pt)
  if d > dt or (d % 2) != (dt % 2):
    print('No')
    import sys
    sys.exit()
  else:
    px = X
    py = Y
    pt = T

print('Yes')


Measured memory_bytes: 9036
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

#define REP(a,b) for(int i =(a);i < (b);i++)
#define FOR(n) for(int i = 0; i<(n); i++)
#define COUT(c)  cout<<(c)<<endl


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

int main(){
    int n;cin>>n;
    vector<ll> h(n);
    int ans=0,tmp=0;
    for(ll i =0;i < n;i++){
        cin >> h[i];
    }
    for(ll i=0;i < n-1;i++){
        //cout << i<< endl;
        //cout << h[i] << " " << h[i+1]<<endl;
        if(h[i+1] > h[i]){  
            if(ans < tmp){
                //cout << ans <<" " <<tmp<< endl;
                ans=tmp;
            }
            tmp=0;
        }else{
            tmp++;
        }
        if(ans < tmp){
            ans = tmp;
        }
        //cout << "tmp "<<tmp<<endl;
    }
    cout << ans << endl;
    return 0;    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int MOD=1e9+7;

int32_t main()
{
   IOS
   int n;cin>>n;
   vector<int>h(n+1);
   for(int i=1;i<=n;i++)
   cin>>h[i];
   vector<int>dp(n+1);
   dp[1]=0;
   for(int i=2;i<=n;i++){
	   dp[i]=1e9;
	   for(int j=i-1;j>=i-2;j--){
		   if( j >= 1 ){
			   dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
		   }
	   }
   }
   cout<< dp[n] << endl;
}


Measured memory_bytes: 1792