akhauriyash/Code-Regression huggingface dataset:
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <utility>

namespace n91 {

void main_() {
  const std::string s = scan<std::string>();
  const std::string t = scan<std::string>();
  const usize n = s.size();

  std::vector<std::map<char, usize>> next(n);
  {
    std::map<char, usize> temp;
    for (char c = 'a'; c <= 'z'; ++c) {
      temp[c] = n;
    }
    for (const auto i : revrep(0_z, n)) {
      temp[s[i]] = i;
      next[i] = temp;
    }
    for (const auto e : t) {
      if (temp[e] == n) {
        std::cout << "-1" << std::endl;
        return;
      }
    }
  }

  u64 i = -static_cast<u64>(1);

  const auto find = [&](const char c) {
    ++i;
    usize j = i % static_cast<u64>(n);
    u64 k = i - j;
    if (next[j][c] == n) {
      i = k + static_cast<u64>(n);
      j = 0_z;
      k = i;
    }
    i = k + static_cast<u64>(next[j][c]);
  };

  for (const auto e : t) {
    find(e);
  }
  std::cout << i + static_cast<u64>(1) << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 167728
#include <bits/stdc++.h>
#include <boost/format.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>

#ifdef DEBUG
#include "libs/debug.cpp"
#define DEBUG 1
#else
#define DEBUG 0
#endif

#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n), 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a) - 1; (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
#define all(c) (c).begin(), (c).end()

using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
template<typename T>
using optional = boost::optional<T>;
const auto none = boost::none;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

ll dfs(ll v, ll parent, vector<vector<ll>> &graph, vector<ll> &children_depths, vector<ll> &parents) {
  ll ret = 0;
  each (u, graph[v]) {
    if (u == parent) {
      continue;
    }
    ret = max(ret, dfs(u, v, graph, children_depths, parents) + 1);
  }
  children_depths[v] = ret;
  parents[v] = parent;
  return ret;
}

int main() {
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (DEBUG) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N, V, U;
  cin >> N >> V >> U;
  vector<tuple<ll, ll>> AB( N - 1);
  rep (i,  N - 1) {
    cin >> get<0>(AB[i]) >> get<1>(AB[i]);
  }

  V -= 1ll;
  U -= 1ll;

  vector<vector<ll>> graph(N, vector<ll>());
  each (ab, AB) {
    ll a, b;
    tie(a, b) = ab;
    a -= 1;
    b -= 1;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  vector<ll> children_depths(N, -1);
  vector<ll> parents(N, -1);

  dfs(U, -1, graph, children_depths, parents);
  ll v = V;
  ll dist = 1;
  while (parents[v] != U) {
    v = parents[v];
    dist += 1;
  }

  ll p_cnt = 0;
  v = V;
  ll ans = 0;
  while (dist > 0) {
    ans = max(ans, dist - 1 + children_depths[v] + p_cnt);
    v = parents[v];
    p_cnt += 1;
    dist -= 2;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 15488
#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define MAX_N 102

int a[MAX_N];

void dump(int n)
{
	int i;

	printf("%d", a[0]);
	for (i = 1; i < n; i++) printf(" %d", a[i]);
	putchar('\n');
}

void insertion_sort(int n)
{
	int i, j, key;

	dump(n);
	for (i = 1; i < n; i++) {
		key = a[i];
		j = i-1;
		while (j >= 0 && a[j] > key) a[j+1] = a[j], j--;
		a[j+1] = key;
		dump(n);
	}
}

int main()
{
	int N, i;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	insertion_sort(N);
	return 0;
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define ll long long
#define rint register int
using namespace std;
string s; 
int delta=0,n,ans=0;
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
  cin>>s;
  n=s.size();
  int i=0;
  while(i<=n-1)
  {
  	if(s[i]=='T')
  	  if(delta==0) ans++;
  	  else delta--;
  	if(s[i]=='S')
  	  delta++;
  	i++;
  }
  printf("%d\n",ans+delta);
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1000000009;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int b1, b2, b3; cin >> b1 >> b2 >> b3;
  if( (b1 == 1 && b2 == 1) || (b3 == 1) ) cout << "Open" << endl;
  else cout << "Close" << endl;
  return 0;
}



Measured memory_bytes: 3212
using System;

class main
{
    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]), b = int.Parse(s[1]), c = int.Parse(s[2]);

        int count = 0;
        for (int i = a; i <= b; i++)
            if (c % i == 0)
                count += 1;

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL H,W;cin >> H >> W;
    vector<vector<LL>> maze(H,vector<LL>(W,0));
    rep(i,H) rep(j,W){
        char a;cin >> a;
        if(a == '#')maze[i][j] = 0;
        else maze[i][j] = 1;
    }

    vector<vector<LL>> dp(H+1,vector<LL>(W+1,0));
    dp[0][0] = 1;   //初期化

    rep(i,H) rep(j,W){
        if(maze[i][j]){
            dp[i+1][j] += dp[i][j] % MOD;
            dp[i][j+1] += dp[i][j] % MOD;
        }
    }

    LL ans = dp[H-1][W-1] % MOD;
    cout << ans << endl;
    

}



Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define mod 1000000007
map<int,int> m;
vector<pair<int,int> > g;
long long dp[105][100005];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;)
	{
		int f=n/i,r=n/f;
		g.push_back({i,r});
		m[r]=g.size();
		dp[1][g.size()]=dp[1][g.size()-1]+r-i+1;
		i=r+1;
	}
	for (int i=2;i<=k;i++)
	{
		for (int j=1;j<=g.size();j++)
		dp[i][j]=(dp[i][j-1]+dp[i-1][m[n/g[j-1].first]]*(g[j-1].second-g[j-1].first+1))%mod;
	}
	printf("%lld",dp[k][g.size()]);
}

Measured memory_bytes: 82552
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 100001
#define INF   1000000000
#define p     1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

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

    ll N, K;
    string S;
    cin >> N >> K;
    cin >> S;

    char S_comp[MAX_N];
    
    ll alone = 0;
    ll alone_edge = 0;

    ll happiness = 0;
    for(ll i = 1; i < N; i++) {
      if (S[i-1] == S[i]) happiness++;
    }

    ll cnt = 0;
    S_comp[0] = S[0];
    for(ll i = 1; i < N; i++) {
      if(S[i] == S_comp[cnt]) continue;
      else S_comp[++cnt] = S[i];
    }

    ll N_comp = cnt + 1;
    
    if (N_comp == 1) {
      cout << happiness << endl;
      return 0;
    }
    
    queue<ll> qa;
    queue<ll> qb;

    for(ll i = 1; i < N_comp - 1; i++) {
      if (S_comp[i] != S_comp[i-1] && S_comp[i] != S_comp[i+1]) qa.push(i);
    }

    
    while (K > 0) {
      
      if (!qa.empty()) {
	ll i = qa.front();
	qa.pop();

	if (S_comp[i] != S_comp[i-1] && S_comp[i] != S_comp[i+1]) {
	  if(S_comp[i] == 'R') S_comp[i] = 'L';
	  else S_comp[i] = 'R';
	  happiness += 2;
	  K--;
	}
      }
      else {
	if (S_comp[0] != S_comp[1]) {
	  if(S_comp[0] == 'R') S_comp[0] = 'L';
	  else S_comp[0] = 'R';
	  happiness += 1;
	  K--;
	}
	else if (S_comp[N_comp - 1] != S_comp[N_comp - 2]) {
	  if(S_comp[N_comp - 1] == 'R') S_comp[N_comp - 1] = 'L';
	  else S_comp[N_comp - 1] = 'R';
	  happiness += 1;
	  K--;
	}
	else break;
      }
    }
    
    cout << happiness << endl;
    return 0;
}
    


Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll Mod=1e9+7;
int n,q,a[3010];
ll f[3010][3010],inv2;
void upd(ll &x,ll v)
{
	x=(x+v)%Mod;
}
ll pw(ll x,ll y)
{
	ll res=1;
	while (y)
	{
		if (y&1)
		{
			res=res*x%Mod;
		}
		x=x*x%Mod;
		y>>=1;
	}
	return res;
}
int main()
{
	inv2=(Mod+1)/2;
	scanf("%d%d",&n,&q);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=n;j++)
		{
			if (a[i]>a[j])
			{
				f[i][j]=1;
			}
		}
	}
	for (int cas=0;cas<q;cas++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		ll tmp;
		tmp=f[x][y]+f[y][x];
		f[x][y]=f[y][x]=tmp*inv2%Mod;
		for (int i=1;i<=n;i++)
		{
			if (i==x || i==y)
			{
				continue;
			}
			tmp=f[x][i]+f[y][i];
			f[x][i]=f[y][i]=tmp*inv2%Mod;
			tmp=f[i][x]+f[i][y];
			f[i][x]=f[i][y]=tmp*inv2%Mod;
		}
	}
	ll ans=0;
	for (int i=1;i<n;i++)
	{
		for (int j=i+1;j<=n;j++)
		{
			upd(ans,f[i][j]);
		}
	}
	cout<<ans*pw(2,q)%Mod<<endl;
	return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N;cin >> N;
    ll K; cin >> K;
    vector<ll> A(N),bit(60);
    rep(i,N){
        cin >> A[i];
        for(int j=0;j<60;j++){
            if((A[i]>>j)&1)bit[j]++;
        }
    }
    // これで bit ごとにどれだけ数が立っているかわかった
    // Xはbitごとに見て0と1の数の少ない方にする
    // XはK以下なので
    ll X = 0;
    for(int j=59;j>=0;j--){
        if(X+(1LL<<j) <=K){
            if(bit[j]*2<N)X+=1LL<<j;
        }
    }
    ll ans = 0;
    rep(i,N)ans += X^A[i];
    cout << ans << endl;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Scan()
	lines, _ := strconv.Atoi(sc.Text())
	l := make([]int, lines)
	for i := 0; i < lines; i++ {
		l[i] = i + 1
	}

	sc.Scan()
	rows, _ := strconv.Atoi(sc.Text())
	for i := 0; i < rows; i++ {
		sc.Scan()
		s := strings.Split(sc.Text(), ",")
		a, _ := strconv.Atoi(s[0])
		b, _ := strconv.Atoi(s[1])

		l[a-1], l[b-1] = l[b-1], l[a-1]
	}
	for _, j := range l {
		fmt.Println(j)
	}
}



Measured memory_bytes: 1068
n, m = map(int, input().split())
x = list(map(int, input().split()))


x.sort()
diff = []
f = x[0]
if m <= n:
    print(0)
else:

    for i in x[1:]:
        diff.append(i-f)
        f = i

    diff.sort()
    if n == 1:
        print(sum(diff))
    else:
        print(sum(diff[:-n+1]))

Measured memory_bytes: 20400
integer N,M
integer X,Y
integer EDGE(100000,1000)!ここ、実は意地悪な問題が来ると溢れてしまいます、困った
integer Nindex(100000)
integer DP(100000)
integer ans
!読み込み
read*,N,M
EDGE(:,:)= 0
Nindex = 0
do i=1,M
  read*,X,Y
  Nindex(X)=Nindex(X)+1
  EDGE(X,Nindex(X))=Y
end do
!読み込み終了

DP = -1
!DP[i]とはノードiからのびる経路のうち最短のもの
!まだ調べていない状態は-1とする
ans = 0
do i=1,N
  if( DP(i)== -1)DP(i)=DFS(i)
  ans=max(ans,DP(i) )
end do

print"(I0)",ans

contains

recursive function DFS(u)result(res)
integer u,res

if(DP(u) >= 0)then
  res=DP(u)
else
  DP(u)=0
  do j=1,Nindex(u)
    DP(u)=max(DP(u),DFS(EDGE(u,j))+1)
  end do
  res=DP(u)
endif
end function DFS
end

Measured memory_bytes: 393728
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  ull n,m,a,b,cnt[51]={};
  cin>>n>>m;
  rep(i,0,m){
    cin>>a>>b;
    cnt[a-1]++;
    cnt[b-1]++;
  }
  rep(i,0,n){
    cout<<cnt[i]<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int x,i,p=1,ans[30]={0};
	scanf("%d",&x);ans[1]=1;
	while(x){
		for(i=1;i<=p;i++){ans[i]*=x;}
		for(i=1;i<=p;i++){while(ans[i]>=10){ans[i]-=10;ans[i+1]++;}}
		if(ans[i])p=i;x--;
	}
	for(i=p;i>0;i--)printf("%d",ans[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> a(n+1); //enemy
    vector<int> b(n); //braver
    long long count = 0;

    for (int i=0; i<n+1; i++) cin >> a[i];
    for (int i=0; i<n; i++) cin >> b[i];

    for (int i=0; i<n; i++) {
        if (b[i] <= a[i]) {
            count += b[i];
        }else{
            count += a[i];
            b[i] -= a[i];
            if (b[i] < a[i+1]) {
                count += b[i];
                a[i+1] -= b[i];
            }else{
                count += a[i+1];
                a[i+1] = 0;
            }
        }
    } 

    cout << count << endl;
    
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt();

		long ans = 0;
		int h = a[0];
		for (int i = 1; i < n; i++)
			if (a[i] < h)
				ans += h - a[i];
			else
				h = a[i];
		System.out.println(ans);
	}
}


Measured memory_bytes: 62004
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    cout << fixed << setprecision(10);
    
    string s, t; cin >> s >> t;
    vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1, 0));

    rep(i, s.size()) {
        rep(j, t.size()) {
            if (s[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
            } else {
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
    // dpテーブルを辿って復元
    int i = s.size(), j = t.size();
    string ans;
    while (i>0 && j>0) {
        if (dp[i][j] == dp[i-1][j]) {
            // iを下げても長さが一緒の場合
            i -= 1;
        } else if (dp[i][j] == dp[i][j-1]) {
            // jを下げても長さが一緒の場合
            j -= 1;
        } else {
            ans = s[i-1] + ans;
            i -= 1;
            j -= 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 1e5+23;

vector<pair<int, int>> v[N];
pair<int, int> ans[N];

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int p, y, i = 0; i < m; ++i) {
    scanf("%d%d", &p, &y);
    v[--p].emplace_back(y, i);
  }
  for (int i = 0; i < n; ++i) {
    sort(v[i].begin(), v[i].end());
    for (int j = 1; j <= (int)v[i].size(); ++j) {
      ans[v[i][j-1].second] = {i+1, j};
    }
  }
  for (int i = 0; i < m; ++i) {
    printf("%06d%06d\n", ans[i].first, ans[i].second);
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n;
    cin >> n;
    ll a[n-1];
    ll ans[n] = {};
    rep(i, n-1) {
        cin >> a[i];
        ans[a[i]-1]++;
    }

    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6756
fun main(args: Array<String>) {
    val (k, s) = readLine()!!.split(' ').map { it.toInt() }
    var ans = 0
    for (x in 0..k) {
        for (y in 0..k) {
            val z = s - x - y
            if (z in 0..k) ans++
        }
    }
    println(ans)
}


Measured memory_bytes: 38176
#include <iostream>
#include <string>
#include <numeric>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


int main(){
	  int a, b, x, y;
		cin>>a>>b>>x>>y;
	  cout<<double(a)*double(b)/2<<' '<< (x + x == a&&y + y == b)<<endl;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  set<int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  cout << s.size() << endl;
  return 0;
}

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

typedef long long lli;

struct Edge {
  int src, dst;
  lli w;
};

typedef vector<vector<Edge> > Graph;
typedef pair<lli,int> Pair;

const lli INF = 1LL<<60LL;

int main() {
  for(int N, M, X; cin >> N >> M >> X; ) {
    Graph g(N);
    vector<lli> H(N);
    for(int i = 0; i < N; ++i) cin >> H[i];
    for(int j = 0; j < M; ++j) {
      int a, b;
      lli t;
      cin >> a >> b >> t;
      --a; --b;
      if(t <= H[a]) g[a].push_back((Edge){a,b,t});
      if(t <= H[b]) g[b].push_back((Edge){b,a,t});
    }

    priority_queue<Pair, vector<Pair>, greater<Pair> > que;
    vector<lli> cost(N, INF);
    que.push(Pair(0, 0));
    cost[0] = 0;
    while(que.size()) {
      const Pair s = que.top();
      que.pop();
      if(s.first > cost[s.second]) continue;
      if(s.second == N-1) break;
      for(int i = 0; i < g[s.second].size(); ++i) {
        const Edge &e = g[s.second][i];
        Pair t(s.first + e.w, e.dst);
        if(X - t.first > H[t.second]) { // X - H[t.second] > t.first
          t.first = X - H[t.second];
        }
        if(t.first >= cost[t.second]) continue;
        que.push(t);
        cost[t.second] = t.first;
      }
    }
    if(cost[N-1] == INF) cout << -1 << endl;
    else cout << cost[N-1] + H[N-1] - (X - cost[N-1]) << endl;
  }
  return 0;
}

Measured memory_bytes: 18984
#include<iostream>
#include<string>
#include<limits>
#include<queue>
#include<stack>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include <algorithm>
#include<utility>
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define vi  vector<int>
#define ll long long
#define pb push_back
#define ff first
#define ss second 
#define rep(n) for(int i=0; i<n ; i++)
#define input(n) for(int i=0; i<n ; i++){cin>>arr[i];}
#define output(n) for(int i=0; i<n ; i++){cout<<arr[i]<<" ";}
#define tc int t; cin>>t; while(t--)
using namespace std;
int32_t main()
{
	int n;
	cin>>n;
	int k ;
	cin>>k;
	int arr[n];
	input(n);
	vi dp(n,1e9);
	dp[0]=0;

	dp[1] = abs(arr[1]-arr[0]);

	for(int i=2; i<n ; i++)
	{
		for(int j=1 ; j<=k  && i-j>=0 ; j++)
		{
		dp[i] = min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
		}
	}

	cout<<dp[n-1]<<endl;
	

	return 0;
}


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

const int d_num = 4;
const int num = 13;

int main() {
  char design[d_num] = {'S', 'H', 'C', 'D'};
  bool hasCards[d_num][num] = {false};
  int n;
  cin >> n;
  char d;
  int e;
  for (int i = 0; i < n; i++) {
    cin >> d;
    cin >> e;
    for (int j = 0; j < d_num; j++) {
      if (design[j] == d) hasCards[j][e-1] = true;
    }
  }
  for (int k = 0; k < d_num; k++) {
    for (int l = 0; l < num; l++) {
      if (hasCards[k][l] == false) cout << design[k] << " " << l + 1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3068
#include <stdio.h>
#include <math.h>

typedef struct {
	double x;
	double y;
} point;

void kock(int n, point p1, point p2) {
	point t, s, u;

	if (n == 0) return;
	
	s.x = (2 * p1.x + 1 * p2.x) / 3;
	s.y = (2 * p1.y + 1 * p2.y) / 3;
	t.x = (1 * p1.x + 2 * p2.x) / 3;
	t.y = (1 * p1.y + 2 * p2.y) / 3;

	u.x = (t.x - s.x) * cos(M_PI / 3) - (t.y - s.y) * sin(M_PI / 3) + s.x;
	u.y = (t.x - s.x) * sin(M_PI / 3) + (t.y - s.y) * cos(M_PI / 3) + s.y;
	

	kock(n-1, p1, s);
	printf("%f %f\n", s.x, s.y);
	kock(n-1, s, u);
	printf("%f %f\n", u.x, u.y);
	kock(n-1, u, t);
	printf("%f %f\n", t.x, t.y);
	kock(n-1, t, p2);
	
	
	return;
}

int main(void)
{
	int n;
	point p1, p2;
	p1.x = p1.y = 0;
	p2.x = 100;
	p2.y = 0;

	scanf("%d", &n);
	printf("%f %f\n", p1.x, p1.y);
	kock(n, p1, p2);
	printf("%f %f\n", p2.x, p2.y);
	
	return 0;
}

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

int main() {
	int N, P=1, a; cin >> N;
	for(int i=0; i<N; ++i){
	    cin >> a;
	    P *= (2-a%2);
	}
	cout << pow(3, N)-P << endl;
	return 0;
}


Measured memory_bytes: 256
s = input()
s1 = s[:1]
for i in range(1, 4):
  if(s[i:i+1] != s1):
    s2 = s[i:i+1]
if(s.count(s1) == 2 and s.count(s2) == 2):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9008
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define _ ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL);
#define dbg(x) cerr << #x << " is " << x << endl;
#define F(i,b) for(int i = 0 ; i < (int)(b) ; i++)
#define RF(j,b) for(int j = (int)(b)-1 ; j >= 0 ; j--)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 2e5+7 ;
const int INF = 1e9 ;
const int MOD = INF + 7 ;
string s ;

void solve(){
	int n , k ;
	cin >> n >> k ;
	int x = ((n-1) * (n-2)) / 2 ;

	if(k > x) return cout << -1 , void() ;
	vector<pii > v ;
	for(int i = 2 ; i <= n ; i++){
		v.pb({1,i}) ;
	}
	x -= k ;

	for(int i = 2 ; i <= n ; i++){
		for(int j = i+1 ; j <= n ; j++){
			if(x){
				v.emplace_back(i,j) ;
				x-- ;
			}
		}
	}

	cout << sz(v) << endl ;
	for(pii z : v){
		cout << z.ff << ' ' << z.ss << endl ;
	}

}

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

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

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

    int p[M];
    string S[M];

    vector<bool> A(N,false);
    vector<bool> AC(N,false);

    rep(i,0,M) {
        cin >> p[i] >> S[i];
        if (S[i]=="AC") {
            AC[p[i]] = true;
        }
    }

    int ac = 0;
    int wa = 0;
    rep(i,0,M) {
        if(A[p[i]]) {
            continue;
        }
        else {
            if(S[i]=="AC") {
                ac++;
                A[p[i]]=true;
            }
            else if (S[i]=="WA" && AC[p[i]])  {
                wa++;
            }

        }

    }
    cout << ac << " " << wa << endl;
}





Measured memory_bytes: 6144
#include <cstdio>
#include <algorithm>
#include <utility>
#include <queue>

#define N 40330

using namespace std;

typedef long long LL;

queue<int> que;
int *ckr;
int NN;

int ip[8];
int sample[8] = {0,1,2,3,4,5,6,7};
int **smps;

int SN(int si,int ei, LL p){
	LL pr=0;
	int md = (si+ei)/2;
	for(LL i=0;i<8;i++){
		pr = pr*8+smps[md][i];
	}
	if(pr==p) return md;
	if(pr<p) return SN(md,ei,p);
	if(pr>p) return SN(si,md,p);
}

int SvToN(int a[8]){
	LL pr=0;
	for(LL i=0;i<8;i++){
		pr = pr*8+a[i];
	}
	return SN(0, NN, pr);
}

void NToSv(int a[8], int n){
	for(int i=0;i<8;i++){
		a[i] = smps[n][i];
	}
}


void cng(int ip[8], int nxtv, int zp, int nz){
	ip[zp] = ip[nz];
	ip[nz] = 0;
	int nv = SvToN(ip);
	if(nxtv<ckr[nv]){
		ckr[nv] = nxtv;
		que.push(nv);
	}
	ip[nz] = ip[zp];
	ip[zp] = 0;
}



int main(){
	ckr = new int[N];
	smps = new int*[N];
	for(int i=0;i<N;i++){
		smps[i] = new int[8];
	}
	for(int i=0;i<N;i++) ckr[i] = 100000000;
	
	
	int cnt = 0;
	do {
		for(int i=0;i<8;i++){
			smps[cnt][i] = sample[i];
		}
		cnt++;
	} while(next_permutation(sample, sample+8));
	NN = cnt;
	
	int ps[8] = {0, 1, 2, 3, 4, 5, 6, 7 };
	int gl = SvToN(ps);
	que.push(gl);
	ckr[gl] = 0;
	
	while(que.size()){
		int nw = que.front(); que.pop();
		
		NToSv(ip,nw);
		int nxtv = ckr[nw]+1;
		
		int zp = -1;
		while(ip[++zp]!=0);
		
		int nz = (zp+4)%8;
		cng(ip,nxtv,zp,nz);
		
		if(zp%4>0){
			cng(ip, nxtv, zp, zp-1);
		}
		if(zp%4<3){
			cng(ip, nxtv, zp, zp+1);
		}
	}
	
	
	
	while(1){
		
		for(int i=0;i<8;i++){
			if(scanf(" %d",&ip[i])==EOF) return 0;
		}
		
		printf("%d\n", ckr[SvToN(ip)]);
	}
	delete [] ckr;
	for(int i=0;i<N;i++){
		delete [] smps[i];
	}
	delete [] smps;
	
	return 0;
}

Measured memory_bytes: 3424
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 510000;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;


int x, y, z;

int main() {

	cin >> x >> y >> z;

	swap(x, y);
	swap(x, z);

	cout << x << " " << y << " " << z << endl;

	return 0;
}

Measured memory_bytes: 256
x = int(input())
li = list(map(int, input().split()))
INF = float('inf')
dp = [INF]*x
for i in range(len(li)):
    if i == 0:
        dp[i] = 0
    elif i == 1:
        dp[i] = min(dp[i], dp[i-1]+abs(li[i]-li[i-1]))
    else:
        dp[i] = min(min(dp[i], dp[i-1]+abs(li[i]-li[i-1])), min(dp[i], dp[i-2]+abs(li[i]-li[i-2])))
print(dp[x-1])

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

int INF = 1001001001;

int main() {
    int N, M; cin >> N >> M;
    vector<P> key;
    rep(i, M){
        int a, b; cin >> a >> b;
        int s = 0;
        rep(j, b){
            int c; cin >> c;
            c--;
            s |= 1 << c;
        }
        key.push_back(make_pair(s, a));
    }

    vector<int> dp(1<<N, INF);
    dp[0] = 0;
    rep(i, 1<<N){
        rep(j, M){
            int k = i;
            k |= key[j].first;
            int cost = dp[i] + key[j].second;
            dp[k] = min(dp[k], cost);
        }
    }

    if(dp[(1<<N) -1] == INF){
        cout << -1 << endl;
    } else {
        cout << dp[(1<<N) -1] << endl;
    }

    return 0;
}

Measured memory_bytes: 3656
import java.util.*;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		long S = sc.nextLong();
		long x1 =0;
		int x2 =1000000000;
		long x3 =(x2-S%x2)%x2;
		long y1 =0;
		long y2 =1;
		long y3 =((S-1)/x2+1);
		System.out.println(x1 + " " + y1 + " " + x2 + " " + (int)y2 + " " + x3 + " " + y3);

	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 1e9 + 10;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1);
const int M = 1e3 + 10;
const int N = 1e6 + 10;

string s[M];

void solve() {
    int n;
    cin >> n;
    fr(i, 3)
        cin >> s[i];
    int ans = 0;
    fr(i, s[0].size()) {
        set<char> ch;
        ch.insert(s[0][i]);
        ch.insert(s[1][i]);
        ch.insert(s[2][i]);
        ans += ((int)ch.size() - 1);
    }
    cout << ans;
}

int main() {
    //ios_base::sync_with_stdio(false);
    //freopen("a.in", "r", stdin);
    solve();
}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n;
    cin >> n;
    cout << (long)((double)(n + 1) / 2) << '\n';
}



Measured memory_bytes: 256
/*
 ********************************************************************************
 *  Author: ThoseBygones
 *  Version: V1.0
 *  Date: 2018-07-06
 *  Subject: ACM-ICPC
 *  Language: C/C++11
 *  OJ: AOJ
 *  Algorithm:
 ********************************************************************************
 *  Algo-Description:
 ********************************************************************************
 */

//#include <bits/stdc++.h>  //For CodeForces only

//#pragma comment(linker,"/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <ctime>
#include <numeric>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <complex>
#include <deque>
#include <functional>
#include <list>
#include <map>
#include <string>
#include <sstream>
#include <set>
#include <stack>
#include <queue>
using namespace std;
template<class T> inline T sqr(T x)
{
    return x * x;
}
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<PII, int> PIII;
typedef pair<LL, LL> PLL;
typedef pair<LL, int> PLI;
typedef pair<LD, LD> PDD;
#define MP make_pair
#define PB push_back
#define sz(x) ((int)(x).size())
#define clr(ar,val) memset(ar, val, sizeof(ar))
#define istr stringstream
#define FOR(i,n) for(int i=0;i<(n);++i)
#define forIt(mp,it) for(__typeof(mp.begin()) it = mp.begin();it!=mp.end();it++)
const double EPS = 1e-6;
const int INF = 0x3fffffff;
const LL LINF = INF * 1ll * INF;
const double PI = acos(-1.0);

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define lowbit(u) (u&(-u))

int eulerPhi(int n)
{
    int ans=n;
    for(int i=2; i*i<=n; i++)
    {
        if(n%i==0)
        {
            ans-=ans/i;
            while(n%i==0)
                n/=i;
        }
    }
    if(n>1)
        ans-=ans/n;
    return ans;
}

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d\n",eulerPhi(n));
    return 0;
}



Measured memory_bytes: 3220
# 参考: https://atcoder.jp/contests/agc044/submissions/13654472

class TestCase
  def initialize(a, b, c, d)
    @a, @b, @c, @d = a, b, c, d
    @memo = {0 => 0, 1 => d}              # 初期値
  end
  
  def go(n)
    return @memo[n] if @memo.key? n
    ad, bd, cd = n/2, n/3, n/5
    ai, bi, ci = (n+1)/2, (n+2)/3, (n+4)/5
    # `n-bd*3` は `n%3` と同じ意味
    # `bi*3-n` は `(3-n%3)%3` と同じ意味
    @memo[n] ||= [
      @d * n,                             # ずっとD
      @a + @d * (n&1) + go(ad),           # Dで2の倍数に減らしてA
      @b + @d * (n-bd*3) + go(bd),        # Dで3の倍数に減らしてB
      @c + @d * (n-cd*5) + go(cd),        # Dで5の倍数に減らしてC
      @a + @d * (n&1) + go(ai),           # Dで2の倍数に増やしてA
      @b + @d * (bi*3-n) + go(bi),        # Dで2の倍数に増やしてB
      @c + @d * (ci*5-n) + go(ci)         # Dで2の倍数に増やしてC
      ].min
  end
end

gets.to_i.times do
  n, a, b, c, d = gets.chomp.split(" ").map(&:to_i)
  t = TestCase.new(a, b, c, d)
  puts t.go(n)
end

=begin
input:
5
11 1 2 4 8
11 1 2 2 8
32 10 8 5 4
29384293847243 454353412 332423423 934923490 1
900000000000000000 332423423 454353412 934923490 987654321

output:
20
19
26
3821859835
23441258666
=end

Measured memory_bytes: 17256
# https://atcoder.jp/contests/abc150/tasks/abc150_d
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---

# LCM -- START --
def lcm(x,y):
  return x*y//gcd(x,y)
# LCM --- END ---

def f(x):
  a=0
  while x%2==0:
    x//=2
    a+=1
  return a

def main():
  n,m=LI()
  _l=LI()
  l=[x//2 for x in _l]

  t=f(l[0])
  for i in range(n):
    b=l[i]
    if t!=f(b):
      return 0
    l[i]>>=t
  m>>=t

  _lcm=1
  for x in l:
    _lcm=lcm(_lcm,x)
    if _lcm>m:
      return 0

  # print(m,_lcm)
  m//=_lcm
  return (m+1)//2

# main()
print(main())


Measured memory_bytes: 16356
N, T = map(int, input().split())
push = list(map(int, input().split()))

if N == 1:
  print(T)
  exit()

ans = 0
for i in range(N-1):
  ans += min(push[i+1] - push[i], T)
else: ## 最後のスイッチ
  ans += T
  
print(ans)




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

int main(void) {
    string s;
    cin >> s;
    map<char, int> m;
    for (auto &&c : s) {
        m[c]++;
    }
    for (auto &&i : m) {
        if (i.second % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

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

	for (int i = 0; i < n; i++)
		printf("%c%c", s[i], t[i]);
	return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int flag=1,sum=0;
        int N=sc.nextInt();
        int[] A=new int[N];
        for(int i=0;i<N;i++)A[i]=sc.nextInt(); 
        for(int i=0;i<N;i++){
            int min=i,data;
            for(int j=i;j<N;j++){
                if(A[j]<A[min])min=j;
            }
            if(i!=min){
                sum++;
                data=A[i];
                A[i]=A[min];
                A[min]=data;
            }
        }
        for(int i=0;i<N;i++){
            if(i!=N-1)System.out.printf(A[i]+" ");
            else System.out.println(A[i]);
        }
        System.out.println(sum);
    } 
}


Measured memory_bytes: 26308
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define sz(x) x.size()

using namespace std;

int main(){
    map<char,int>m;
    string s;cin>>s;
    for(auto x:s){
        m[x]++;
    }
    if(m.size()!=2){
        cout<<"No";
    }
    else{
        cout<<((m.begin()->second == m.rbegin()->second)?"Yes":"No");
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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


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

int dp[101][4][4][4];

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

    //長さ0の文字列は1である。
    //0,1,2に関する制約しかないので、
    //Sは、333Sと考えても問題がない。
    dp[0][3][3][3] = 1;

    int mod = 1'000'000'007;

    //文字列の文字数
    REP(len,N)REP(c1,4)REP(c2,4)REP(c3,4){
        if (dp[len][c1][c2][c3] == 0) continue;
        REP(a,4){
            if (a == 2 && c1 == 1 && c2 == 0) continue;
            if (a == 2 && c1 == 0 && c2 == 1) continue;
            if (a == 1 && c1 == 2 && c2 == 0) continue;
            if (a == 2 && c1 == 1 && c3 == 0) continue;
            if (a == 2 && c2 == 1 && c3 == 0) continue;

            dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
            dp[len + 1][a][c1][c2] %= mod;
        }
    }
    
    int ans = 0;

    //長さNの全部の答えを纏める
    //最後から1文字目の文字
    REP(c1,4)REP(c2,4)REP(c3,4){
        ans += dp[N][c1][c2][c3];
        ans %= mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import copy
n,m,q=[int(_) for _ in input().split()]
lista=[[int(i) for i in input().split()] for j in range(q)]
v=list()  #0,0,0,0,0....,0
def make(a,b,c): #a=list b=maxlen c=max
    global v
    if len(a)==b:
        v.append(a)
    else:
        for i in range(a[-1],c+1):
            k=copy.copy(a)
            k.append(i)
            make(k,b,c)
for t in range(1,m+1):
    make([t],n,m)
max=0
for j in v:
    point=0
    for l in lista:
        if j[l[1]-1]-j[l[0]-1]==l[2]:
            point+=l[3]
    if max<point:
        max=point
print(max)


    
#

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

int main() {
  int n,x;
  cin >> n;
  int a[200010],b[200010];
  for (int i=0; i<n; i++){
  cin >> x;
  a[i] = x;
  b[i] = x;
  }
  int p,q;
  sort(b, b + n, greater< int >());
  p = b[0];
  q = b[1];
  //cout << p << q << endl;
  for (int i=0; i<n; i++){
  if (a[i] <= q) printf("%d\n",p);
  else printf("%d\n",q);
  }
}


Measured memory_bytes: 3200
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		
		String S[] = sc.nextLine().split(" ");
		int stack[] = new int[S.length];
		int idx = 0, a, b;  

		for(int i=0; i<S.length; i++){			
			try{
				int x = Integer.parseInt(S[i]);
				stack[idx++] = x;

			}catch(java.lang.NumberFormatException ex){
				b = stack[--idx];
				a = stack[--idx];

				switch (S[i]) {
					case "+":	stack[idx++] = a + b; break;
					case "-":	stack[idx++] = a - b; break;
					case "*":	stack[idx++] = a * b; break;
				}
			}
		}
		System.out.println(stack[--idx]);
	}	
}

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

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var n = h[0];
		var map = new int[n + 1].Select(_ => new List<int>()).ToArray();
		foreach (var r in new int[h[1]].Select(_ => read()))
		{
			map[r[0]].Add(r[1]);
			map[r[1]].Add(r[0]);
		}

		var c = 0;
		var used = new bool[n + 1];
		var q = new Queue<int>();
		for (int i = 1; i <= n; i++)
		{
			if (used[i]) continue;
			c++;
			used[i] = true;
			q.Enqueue(i);

			while (q.Any())
				foreach (var np in map[q.Dequeue()])
				{
					if (used[np]) continue;
					used[np] = true;
					q.Enqueue(np);
				}
		}
		Console.WriteLine(c);
	}
}


Measured memory_bytes: 29940
def func(i, x, a):
    global ans
    ans = a[0]
    if i == 1:
        if x == 7:
            return True
        else:
            return False

    if func(i-1, x+int(a[i-1]), a):
        ans += '+' + a[i-1]
        return True

    if func(i-1, x-int(a[i-1]), a):
        ans += '-' + a[i-1]
        return True

    else:
        return False

if __name__ == '__main__':
    a = input()
    n = len(a)
    x = int(a[0])
    if func(n, x, a):
        print(ans + '=7')
    else:
        pass


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  string s;
  cin>>n>>s;
  vector<set<char>>l(n);
  vector<set<char>>r(n);
  l[0].insert(s[0]);
  rep2(i,1,n){
    l[i]=l[i-1];
    l[i].insert(s[i]);
  }
  r[n-1].insert(s[n-1]);
  for(int i=n-2;i>=0;i--){
    r[i]=r[i+1];
    r[i].insert(s[i]);
  }
  int ans=0;
  rep(i,1000){
    string t;
    int x=i;
    rep(j,3){
      t+='0'+x%10;
      x/=10;
    }
    bool ok=false;
    rep2(j,1,n-1){
      if(s[j]==t[1]&&l[j-1].count(t[0])&&r[j+1].count(t[2])){
        ok=true;
      }
    }
    if(ok)ans++;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 31232
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int n, x, X[111];

int main() {
    scanf("%d%d", &n, &x);
    for(int i = 1; i <= n; i++) scanf("%d", &X[i]);
    sort(X + 1, X + n + 1);
    X[n + 1] = x + 1;
    for(int i = 1; i <= n + 1; i++) if(x < X[i]) {printf("%d\n", i - 1); return 0; }else {
        x -= X[i];
        if(i == n) {
            if(x == 0) printf("%d\n", n); else printf("%d\n", n - 1);
            return 0;
        }
    }
    return 0;
}

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

int main() {
    int H, W; cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10));
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            cin >> c[i][j];
        }
    }
    
    for (int k = 0; k < 10; k++)
    {
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
            }
        }
    }
    
    int ans = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            int a; cin >> a;
            if(a != -1){
                ans += c[a][1];
            }        
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define maxn 1000005
#define mod 1000000003
#define inf 1000000007
namespace lib
{
	using namespace std;
	
	
	class fastio
	{
		private:
			#define _NUMLEN 111
			char _num[_NUMLEN],_ch;
			int _f,_head;
			bool _useSTD;
		public:
			inline void ioSTD()
			{
				_useSTD=1;
				ios::sync_with_stdio(false);
				cin.tie(0),cout.tie(0);
			}
			inline void gc(char & _c)
			{
				if(_useSTD)cin>>_c;
				else _c=getchar();
			}
			inline void pc(char _c)
			{
				if(_useSTD)cout<<_c;
				else putchar(_c);
			}
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_x=0;
					while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch);
					while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch);
					_f&&(_x=-_x,_f=0);
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				if(_useSTD)cin>>_x;
				else
				{
					_T _k;
					if(_x==0) {pc('0'),pc(' ');return *this;}
					if(_x<0) pc('-'),_x=-_x;
					while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
					while(_head>0) pc(_num[_head]),--_head;
					pc(' ');
				}
				return *this; 
			}
			template<typename _T> inline fastio & operator >> (_T & _x) {cin>>_x;return *this;}
			template<typename _T> inline fastio & operator << (_T _x) {cout<<_x;return *this;}
			#define endln pc('\n')
		fastio() {_f=0,_head=0,_useSTD=0,_ch=' ';}
	}io;
	
	
	inline void fileio(string _r,string _w)
	{
		if(_r[0]!='-')freopen(_r.c_str(),"r",stdin);
		if(_w[0]!='-')freopen(_w.c_str(),"w",stdout);
	}
}using namespace lib;

string a,b;
signed main()
{
//	fileio("tt.in","tt.out");
	io.ioSTD();
	int n;
	io>>n>>a>>b;
	for(rgi i=0;i<n;++i)
		io<<a[i]<<b[i];
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int e=0;
	int f=0;
	e=a*b;
	f=c*d;
	cout<<max(e,f)<<endl;
	
	return 0;
}

Measured memory_bytes: 256