akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;

    for (int i=0; i<N; ++i) {
        bool eq = true;
        for (int j=i; j<N; ++j) {
            if (s[j] != t[j-i]) {
                eq = false;
                break;
            }
        }
        if (eq) {
            cout << i+N << endl;
            return 0;
        }
    }
    cout << N*2 << endl;

    return 0;
}

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

int main(void){
    long long int i,N,A[100000],ans = 1;

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

    for(i=0;i<N;i++){
        if(A[i]==0){
            printf("0\n");
            return 0;
        }
    }

    for(i=0;i<N;i++){
        if(A[i] > 1000000000000000000/ans){
            ans = -1;
            break;
        }else{
            ans *= A[i];
        }
    }

    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2480
import Data.List
toYN :: Bool -> String
toYN False = "No"
toYN True = "Yes"

x -: f = f x

getInts = ((fmap ((fmap read) . words)) getLine) :: IO [Int]
main = do
  [n,k] <- getInts
  a <- getInts
  putStrLn $ (zip (take (n-k) a) (drop k a)) -:
    (fmap (\(a,b)-> toYN (b>a))) -:
    (intercalate "\n")

kDiff :: Int -> [Int] -> [Int]
kDiff k l = take ((length l) - k) (kDiff' k l)
  where
  kDiff' :: Int -> [Int] -> [Int]
  kDiff' k [] = []
  kDiff' k l = ((head $ drop k l) - (head l)):(kDiff' k (drop 1 l))


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

using namespace std;

int n, m, a[1000], votes=0, counter=0;

int main() {
	cin >> n >> m;
	for (int i=0; i<n; ++i) {
		cin >> a[i];
		votes += a[i];
	}
	float required = (float) votes / (4*m);
	for (int x : a) 
		if (x >= required)
			++counter;
	cout << ((counter >= m) ? "Yes" : "No") << '\n';	
}


Measured memory_bytes: 256
import sys

def main():
    N, X = map(int, input().split())
    A = list(map(int, input().split()))

    cnt = 1
    D = 0
    for a in A:
        D += a
        if D > X:
            break
        cnt += 1

    return cnt


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>
#include <cstdio>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
//priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

llint a,b,c;

void solve(){
  cin >> a >> b >>c;
  if(a<b && b <c)cout << "Yes";
  else cout << "No";
  cout << endl;
}

int main() {
  solve();
  return 0;
}



Measured memory_bytes: 3120
import math

n, k = map(int, input().split())

dic = {} #ここに結果を保存していく。
ans = 0
moddo = 10**9+7

for i in range(k):
    t = k - i #これで大きいほうから順にとる。
    if t > k/2: #tがk/2より大きいときはすべてtじゃないと最大公約数はtにならない。
        dic[t] = 1
        ans += t
    else:
        temp = pow(k//t,n,moddo)
        #print(temp)
        fac = 2
        while fac*t <= k:
            temp -= dic[fac*t]
            fac += 1
        dic[t] = temp%moddo
        ans = (ans+((temp*t)%moddo))%moddo

print(ans)

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, c, x;
  cin >> n >> m >> c;
  vector <int> b(m);
  int cnt = 0;
  for (int i = 0; i < m; ++i){
	cin >> b[i];
  }
  for (int i = 0; i < n; ++i){
	  int sum = 0;
	for (int j = 0; j < m; ++j){
		cin >> x;
		sum += x*b[j];	
	}
	sum += c;
	if (sum > 0) ++cnt;
  }
  cout << cnt << "\n";
return 0;
}


Measured memory_bytes: 256
mod = 10 ** 9 + 7


def f(n, r):
    X = 1
    Y = 1
    for i in range(r):
        X *= n - i    # nCr の分子
        X %= mod
        Y *= i + 1    # nCr の分母
        Y %= mod

    # フェルマーの小定理より (X/Y)%mod = X*Y^(mod - 2) % mod
    return X * pow(Y, mod - 2, mod) % mod


N, A, B = map(int, input().split())
res = pow(2, N, mod) - 1

for i in [A, B]:
    res -= f(N, i)

print(res % mod)

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N,M;
    int[] a,b;
    boolean[][] graph;
    boolean[] visited;

    private boolean dfs(int s,int t) {
        if (s == t) {
            return true;
        }

        if (visited[s]) {
            return false;
        }
        visited[s] = true;

        for(int i = 0;i < N;i++) {
            if (visited[i]) {
                continue;
            }

            if (graph[s][i] && graph[i][s]) {
                if(dfs(i,t)) {
                    return true;
                }
            }
        }
        visited[s] = false;
        return false;
    }

    private void solve() {
        N = nextInt();
        M = nextInt();

        a = new int[M];
        b = new int[M];
        graph = new boolean[N][N];
        for(int i = 0;i < M;i++) {
            a[i] = nextInt() - 1;
            b[i] = nextInt() - 1;

            graph[a[i]][b[i]] = true;
            graph[b[i]][a[i]] = true;
        }

        int ans = 0;
        visited = new boolean[N];
        for(int i = 0;i < M;i++) {
            int s = a[i];
            int t = b[i];
            graph[s][t] = graph[t][s] = false;
            Arrays.fill(visited,false);
            if(!dfs(s,t)) {
                ans++;
            }
            graph[s][t] = graph[t][s] = true;
        }

        out.println(ans);
    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21972
// https://atcoder.jp/contests/abc153/tasks/abc153_e

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll H, N;
  cin >> H >> N;

  struct Mg {
    ll h, m;
  };

  V<Mg> mgs(N);

  rep(i, N) {
    ll h, m;
    cin >> h >> m;

    mgs[i] = {h, m};
  }

  // dp[i][h] // i 番目の魔法までで h 減らすのに必要な m
  VVL dp(N + 1, VL(H + 1, INF));
  dp[0][0] = 0;

  // 同じ要素ありのナップサック
  rep(i, N) rep(h, H + 1) {
    auto mg = mgs[i];
    chmin(dp[i + 1][h], dp[i][h]);
    chmin(dp[i + 1][min(H, h + mg.h)], dp[i + 1][h] + mg.m);
  }

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

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 78592
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
	int n, i;
	double s[1001],sum,m;
	
	while( 1 ) {
		cin>>n;
		if( 0 == n ) { break; }
		
		
		sum = m = 0;
		for( i=0; i<n; i++ ) {
			cin>>s[i];
			m += s[i];
		}
		m /= n;
		for( i=0; i<n; i++ ) {
			sum += pow(s[i]-m,2)/n;
		}
		cout.setf( ios::fixed );
		cout<<sqrt( sum )<<endl;
	}
	
	return 0;
}




Measured memory_bytes: 3228
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    int cur = 0;
    int m = n;
    while(m > 0){
        cur += m % 10;
        m /= 10;
    }

    bool ok = (n % cur == 0);
    cout << (ok ? "Yes":"No") << endl;

    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        // 整数の入力
        //int a = int.Parse(Console.ReadLine());
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        // 文字列の入力
        string s = Console.ReadLine();
        char[] cs = s.ToCharArray();
        cs[b-1] = char.ToLower(cs[b-1]);
        string s2 = new string(cs);
        //出力
        Console.WriteLine(s2);
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;



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

    int a[m][n];
    rep(i, m)
    {
        rep(j, n){
            a[i][j] = 0;
        }
    }

    rep(i, m)
    {
        int k;
        cin >> k;
        rep(j, k)
        {
            int s;
            cin >> s;
            s--;
            a[i][s] = 1;
        }
    }

    vector<int> p(m);
    rep(i, m) cin >> p.at(i);
    
    int ans = 0;

    rep(i, 1<<n)
    {
        vector<int> y(m);
        rep(j, n)
        {
            if(i>>j&1)
            {
                rep(k, m)
                {
                    if(a[k][j])
                    y.at(k) ^= 1;
                }
            }
        }
        bool flag = true;
        rep(l, m){
            if(p[l] != y[l]) flag = false;
        }

        if(flag) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int a,b;
  cin >> a >> b;
  int c,d,e;
  c = a+b;
  d = a-b;
  e = a*b;

  cout << max(c,max(d,e));

}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
char c[4009];
int p[4009],n,p1,p2,dp[4009][4009],w[2][4009][4009],cnt;
int main()
{
	cin>>n;
	for (int i=1;i<=2*n;i++) cin>>c[i]>>p[i];
	for (int i=1;i<=2*n;i++)
	{
		for (int j=i+1;j<=2*n;j++)
		{
			if (c[i]==c[j] && p[i]>p[j]) cnt++;
		}
	}
	p1=n;
	p2=n;
	for (int i=1;i<=2*n;i++)
	{
		int W=0,B=0;
		for (int j=1;j<=2*n;j++)
		{
			if (p[j]>=i)
			{
				if (c[j]=='W') W++;
				if (c[j]=='B') B++;
			}
			if (c[j]=='W') w[0][p[j]][i]=B;
			else w[1][p[j]][i]=W;
		}
	}
	for (int i=0;i<=2*n;i++)
	{
		for (int j=0;j<=2*n;j++) dp[i][j]=(1<<30);
	}
	dp[0][0]=0;
	for (int i=0;i<=p1;i++)
	{
		for (int j=0;j<=p2;j++)
		{
			if (i<p1) dp[i+1][j]=min(dp[i+1][j],dp[i][j]+w[0][i+1][j+1]);
			if (j<p2) dp[i][j+1]=min(dp[i][j+1],dp[i][j]+w[1][j+1][i+1]);
		}
	}
	cout<<cnt+dp[p1][p2]<<endl;
	return 0;
}

Measured memory_bytes: 129024
#Selection sort

N=int(input())
A=list(map(int,input().split()))
counter=0

for i in range(N):
    minj=i
    for j in range(i,N):
        if A[j]<A[minj]: #最小値探し
            minj=j
    A[i],A[minj]=A[minj],A[i]
    if minj!=i:
        counter+=1

A_str=map(str,A)
string=" ".join(A_str)
print(string)
print(counter)



Measured memory_bytes: 5600
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

int n, a[200100], p, q; ll k;
vector<int> v;
bool vis[200100];
int s[200100];

void dfs(int x, int cnt) {
  if (vis[x]) {
    p = s[x];
    q = cnt - p;
    return;
  } else {
    vis[x] = true;
    s[x] = cnt;
    dfs(a[x], cnt + 1);
    return;
  }
  return;
}

int main(void) {
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  rep(i, n) a[i]--;
  dfs(0, 0);

  ll P = p, Q = q;
  if (k >= P) {
    k = (k - P)%Q + P;
  }
  
  rep(i, n) {
    if (s[i] == k) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 int a,b,t;
 cin>>a>>b>>t;
 int ans=0;
 for(int i=1;a*i<=t;i++){
  ans+=b;
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,tune=native")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const int mod = 998244353;
const ll inf = 1e18;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
string s;
set<int> pos[10];
int lb(int i, int x) {
	auto t = pos[i].upper_bound(x);
	return t==pos[i].end()?n+1:*t;
}
bool check(int i, int j, int k) {
	return lb(k, lb(j, lb(i, -1)))<n+1;
}
int main() { //DINIC ORZ
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> s;
	for(int i = 0; i < s.size(); i++)
		pos[s[i]-'0'].insert(i);
	int ans = 0;
	for(int i = 0; i < 10; i++)
		for(int j = 0; j < 10; j++)
			for(int k = 0; k < 10; k++)
				if(check(i, j, k)) ans++;
	cout << ans;
}



Measured memory_bytes: 1664
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
	using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll N; cin >> N;
	vector<ll> A(N+ 1);
	for (int i = 2; i <= N; i++) cin >> A[i];

	map<ll, ll> p;
	for (int i = 2; i <= N; i++) {
		p[A[i]]++;
	}

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

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

int main() {
    long long N;
    cin >> N;
    if(N%2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    long long ans = 0;
    ans += N/10;
    N/=10;
    while(N != 0) {
        ans+=N/5;
        N/=5;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
#include <sstream>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define REV(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define setp(x) setprecision(x)
using LL = long long;
using ULL = unsigned long long;

// xに配列の数字が含まれているか
bool inc(int x, vector<int> d) {
	string x_s = to_string(x);
	for (auto& i : x_s) {
		for (auto& j : d) {
			if (i - '0' == j) return true;
		}
	}
	return false;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> d(k);
	rep(i, 0, k) cin >> d[i];

	int ans = n;
	while (inc(ans, d)) {
		ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
    ll x; cin>>x;
    cout<<x*x*x<<endl;
  return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <string> 
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <vector>
using namespace std;

int main(void) {
	int x, y;
	cin >> x >> y;
	if (x == 2) {
		if (y == 2) {
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	else if (x == 4 || x == 6 || x == 9 || x == 11) {
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	else if (y != 2 && y != 4 && y != 6 && y != 9 && y != 11) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 640
Max = 1000000

def dijkstraDG graph, start
  #初期化
  dist = Array.new(graph.size, Max)
  visited = Array.new(graph.size, false)
  dist[start] = 0
  
  loop do
    #未訪問節点でコスト最少の点を決定
    u = -1
    sd = Max
    (0...graph.size).each do |i|
        if ! visited[i] && dist[i] < sd
          sd = dist[i]
          u = i
      end
    end
    break if u == -1
    
    #未訪問節点から隣接節点へのコストが最少であれば更新する
    visited[u] = true
    graph[u].each do |p|
      v = p[0]
      w = p[1]
      newLength = dist[u] + w
      if(newLength < dist[v])
        dist[v] = newLength
      end
    end
  end
  dist
end

n = $stdin.gets.to_i
m = $stdin.gets.to_i

Graph = Array.new(n).map{Array.new}

m.times do |t|
  a,b,c,d = $stdin.gets.chomp.split(",").map(&:to_i)
  Graph[a - 1] << [b - 1,c]
  Graph[b - 1] << [a - 1,d]
end

start, dest, money, price = $stdin.gets.chomp.split(",").map(&:to_i)

outward = dijkstraDG(Graph, start - 1)
homeward = dijkstraDG(Graph, dest - 1)
p money - price - outward[dest - 1] - homeward[start - 1]

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

int main() {

  int N; 
  cin >> N;

  bool isFour = false;
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      isFour = true;
      break;
    }
  }
  
  if (isFour) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

def nim(x):
  bx = [format(i,'030b') for i in x]
  bz = ''.join([str( sum([int(bx[xi][i]) for xi in range(len(x))]) % 2)  for i in range(30)])
  return int(bz, 2)

nima = nim(a)
ans = [ str(nim([nima,aa])) for aa in a ]
print(' '.join(ans) )

Measured memory_bytes: 213868
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,a[200002],ans,b[200002];
signed main(){
	n=read();
	for(re int i=1;i<=n;++i)++a[b[i]=read()];
	for(re int i=1;i<=n;++i){
		ans+=(a[i]*(a[i]-1))/2;
	}
	for(re int i=1;i<=n;++i)printf("%lld\n",ans-a[b[i]]+1);
}

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

int main() {
    int n;
    cin >> n;
    set<string> s;
    string w;
    cin >> w;
    s.insert(w);
    char e = w.back();
    for (int i = 1; i < n; i++) {
        string w;
        cin >> w;
        if (s.count(w) > 0 || e != w.front()) {
            puts("No");
            return 0;
        }
        s.insert(w);
        e = w.back();
    }
    puts("Yes");
}

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

#define st first
#define nd second
#define pb push_back

typedef long long   ll;
typedef double      db;
typedef long double ldb;

typedef pair <int, int> pii;
typedef pair <ll,  ll>  pll;
typedef pair <ll,  db>  pdb;
typedef pair <ldb, ldb> pldb;

template <typename T>
void   Debug (T begin, T end);
int    si    ();
ll     sl    ();
string ss    (int); 
db     sf    ();
ldb    slf   ();
void   pi    (int, char = '\n');
void   pl    (ll, char = '\n');
void   pf    (db, char = '\n');
void   plf   (ldb, char = '\n');
void   ps    (string, char = '\n');

ll russian(ll, ll, ll);
ll fast_power(ll, ll, ll);
ll slow_power(ll, ll, ll);
ll _gcd(ll, ll);
ll _lcm(ll, ll);

const int INF  = 1e9;
const ll  LINF = 1e18;

int main()
{
    ll a = sl(), b = sl();
    ll gcd = _gcd(a, b);

    int result = 1;
    for (ll i = 2; i * i <= gcd; ++i)
    {
        if (gcd % i == 0)
        {
            ++result;
            while (gcd % i == 0)
                gcd /= i;
       }
    }
    pi(result + (gcd == 1 ? 0 : 1));

    return 0;
}

template <typename T>
void Debug(T begin, T end)
{
    printf("\nDEBUG:\n");
    while (begin != end)
        printf("%d ", *begin),
        begin++;
    printf("\n\n");
}

template <typename T>
T scanf_t(string s)
{
    T a;
    scanf(s.c_str(), &a);
    return a;
}

template <typename T>
void printf_t(T a, string s, char end_l)
{
    s.push_back(end_l);
    printf(s.c_str(), a);
}

int si() { return scanf_t<int>("%d"); }
ll sl() { return scanf_t<ll>("%lld"); }
db sf() { return scanf_t<db>("%f"); }
ldb slf() { return scanf_t<ldb>("%Lf"); }

void pi(int a, char end_l) { printf_t<int>(a, "%d", end_l); }
void pl(ll a, char end_l) { printf_t<ll>(a, "%lld", end_l); }
void pf(db a, char end_l) { printf_t<db>(a, "%lf", end_l); }
void plf(ldb a, char end_l) { printf_t<ldb>(a, "%Lf", end_l); }

void ps(string a, char end_l)
{
    string s = "%s";
    s.push_back(end_l);
    printf(s.c_str(), a.c_str());
}

string ss(int NN)
{
    char T[NN];
    scanf("%s", T);
    return (string)T;
}

ll fast_power(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = (r * a) % m;
        a = (a * a) % m;
        k >>= 1LL;
    }
    return r;
}

ll slow_power(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = russian(r, a, m);
        a = russian(a, a, m);
        k >>= 1LL;
    }
    return r;
}

ll russian(ll a, ll k, ll m)
{
    ll r = 0LL;
    while (k)
    {
        if (k & 1LL)
            r = (r + a) % m;
        a = (a + a) % m;
        k >>= 1LL;
    }
    return r;
}

ll _gcd(ll a, ll b)
{
    while (b)
        swap(a %= b, b);
    return a;
}

ll _lcm(ll a, ll b)
{
    return a / _gcd(a, b) * b;
}


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

using ll =long long;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b == 0){
       return(b);
   }else{
       return(gcd(b, a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a * b / gcd(a, b);
}

//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//数字判定　isdigit
//
//

int main(){
cout<<fixed<<setprecision(10);

  
int A,B,C;
  cin>>A>>B>>C;
  int M=max(A,max(B,C));
  int m=min(A,min(B,C));
  int W=A+B+C-M-m;
  cout<<M*10+W+m<<endl;

}


Measured memory_bytes: 256
import fractions
import sys
sys.setrecursionlimit(10**8)


def lcm2(x, y):
    return (x * y) // fractions.gcd(x, y)


a, b, c, d = map(int, input().split())


def solve(v):
    return v - v // c - v // d + v // lcm2(c, d)


print(solve(b) - solve(a-1))


Measured memory_bytes: 63980
n = int(input())
ls = list(map(int,input().split()))
j = 0
k = 0
p = 0
for i in range(n):
    if ls[i] % 4 == 0:
        j += 1
    elif ls[i] % 2 == 0:
        k += 1
if len(ls) % 2 == 0:
    if j >= len(ls)/2:
        print("Yes")
    else:
        p = (len(ls)/2 - j) * 2
        if k >= p:
            print("Yes")
        else:
            print("No")
else:
    if j >= int(len(ls)/2):
        print("Yes")
    else:
        p = (int(len(ls)/2) - j) * 2 +1
        if k >= p:
            print("Yes")
        else:
            print("No")

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    int now = 1;
    for (int i = 0; i < N; i++) {
        if (A[i] == now) now++;
    }
    int ans = -1;
    if (now != 1) ans = N-now+1;
    cout << ans << endl;
    return 0;
}

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

int main() {
  double a, b, c, d, e, f, x, y;
  while (cin >> a >> b >> c >> d >> e >> f) {
    x = (b * f - e * c) / (b * d - a * e);
    y = (c - a * x) / b;
    cout << fixed << setprecision(3) << x + 0 << " " << y + 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 3224
import queue

H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]


def srch(h,w):
    ans = 0
    cnt = [[-1 for _ in range(W)] for _ in range(H)]
    que = queue.Queue()
    li1 = [1,0,-1,0]
    li2 = [0,1,0,-1]
    ans = 0
    res = 0

    que.put([h,w,0])
    cnt[h][w]=0

    while not(que.empty()):
        plc = que.get()
        y = plc[0]
        x = plc[1]
        ans = plc[2]

        for i in range(4):
            ny,nx = y+li1[i], x+li2[i]
            # print(ny,nx)
            if ny>=0 and ny<H and nx>=0 and nx<W and cnt[ny][nx]==-1 and S[ny][nx]==".":
                cnt[ny][nx]= ans+1
                que.put([ny,nx,ans+1])
                res = ans +1
    # if h==4 and w==6:
    #     for h in range(H):
    #         for j in range(W):
    #             print("{:>3}".format(cnt[h][j]),end="")
    #         print()
            

    return res


ans = 0

for h in range(H):
    for w in range(W):
        if S[h][w]==".":
            ans = max(ans,srch(h,w))

print(ans)



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

#define int long long

using namespace std;

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

	int ans = 0;

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
				ans += __gcd(i, __gcd(j,k));
		}
	}

	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;


int main() {

    int a, b;
    cin >> a >> b;
    if (a == 1) {
        a = 14;
    }
    if (b == 1) {
        b = 14;
    }

    if (a < b) {
        cout << "Bob" << endl;
    } else if (a == b) {
        cout << "Draw" << endl;
    } else {
        cout << "Alice" << endl;
    }


}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
	int n, m;
	cin >> n;
	int A[n];
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	int G[n];
	int i = 1;
	int j = 0;
	while(i <= n){
		G[j] = i;
		i = 3*i+1;
		j++; 
	}
	m = j; 
	cout << m << endl;
	for(int i = m-1; i > 0; i--){
		cout << G[i] << " ";
	}
	cout << G[0] << endl;
	int cnt = 0; 
	for(int k = m-1; k >= 0; k--){
		for(int i = G[k]; i < n; i++){
			int v = A[i];
			int j = i - G[k];
			while(j >= 0 && A[j] > v){
				A[j+G[k]] = A[j];
				j = j-G[k];
				cnt++;
			}
			A[j + G[k]] = v;
		}
	}	
	cout << cnt << endl;
	for(int i = 0; i < n; i++){
		cout << A[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 6980
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
 
using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;
 
const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;
 
vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
 
//<<-----Declare Variable Here------->>//
int t=1;
ll n;
ll count1;
ll i;
//<<-----Implement Functions Here---->>//
 
 
//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n;ll sum1 =0;
		for(ll i=1;i<=n;i++)
		{
			if(i%3==0&&i%5==0)sum1+=0;
			else if(i%3==0)sum1+=0;
			else if(i%5==0)sum1+=0;
			else sum1+=i;
		}
		cout<<sum1<<endl;
}
int main(){
	fastio;randomINIT;
 
	//cin>>t;
	while(t--){
		MAIN();
	}
 
   
}

Measured memory_bytes: 6000
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var i=0;i<Arr.length;i=i+2){
   if(Arr[i]=="0")break;
   var val=Arr[i+1];
   var arr=val.split(" ").map(Number);
   var sum=arr.reduce(function(a,b){return a+b;});
   var ave=sum/arr.length;
   var a=0;
   arr.forEach(function(v){
      a+=Math.pow(v-ave,2);
   });
   console.log(Math.sqrt(a/arr.length).toFixed(4));
}

Measured memory_bytes: 8676
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,s=0;cin>>n;
    int k[n];
    for(int i=0;i<n;i++)
        cin>>k[i];
        sort(k,k+n);
    for(int i=0;i<n;i++)
        if(k[i]!=k[i+1])
            s++;

    cout<<s;
    return 0;
   }

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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define MOD 1000000007

const int MAX_M = 100000;


int main(){
  //ll n;
  string s;
  cin >> s;
  
  //vector<ll> a(n);
  //queue<ll> q;
  //map<string,ll> d{};
  
  
  cout << ((s == "ABC")? "ARC" : "ABC") << endl;
}

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

int main(){
    int64_t S;
    cin >> S;
    const constexpr int64_t d = 1e9;
    printf("%ld %ld %ld %ld %ld %ld\n", 0, 0, d, 1, (d - S % d) % d, S / d + (S % d == 0 ? 0 : 1));
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define LL long long


#define pii pair<int,int>
#define pLL pair<LL,LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e,v) for(auto e:v)
#define rep(i, a, n) for(LL i = a; i < n;i++)

using namespace std;

int inp(){
	int x;
	scanf("%d",&x);
	return x;
}
LL linp(){
	LL x;
	scanf("%lld",&x);
	return x;
}

void outp(int i){
	printf("%d",i);
}

void loutp(LL i){
	printf("%lld",i);
}

LL mod(LL i){
	return i % 1000000007;
}



int Lucky_7(){
	LL N = inp();

	while(N > 0){
		int i = N % 10;
		if(i == 7) {
			printf("Yes");
			return 0;
		}
		N = N / 10;
	}
	printf("No");

	return 0;

}

int FizzBuzz_Sum(){
	LL N = inp();

	LL sum = 0;

	for(int i = 1;i <= N;i++){
		if(i % 3 != 0 && i % 5 != 0){
				sum += i;
		}
	}

	loutp(sum);

	return 0;

}

int gcd(int i,int j){
	if(j != 0)
		return gcd(j, i % j);
	else
		return i;
}

int SogoT(){

	int K = inp();
	int sum = 0;
	for(int i = 1;i <= K ;i++){
		for(int j = 1;j <= K ;j++){
			for(int k = 1;k <= K ;k++){
					sum += gcd(gcd(i,j), k);
			}
		}
	}

	outp(sum);

	return 0;
}

int RGBTs(){
	LL N = linp();
	char S[N];
	LL countR,countG,countB;

	countR = countG = countB = 0;

	rep(i, 0, N){
		cin >> S[i];
		if(S[i] == 'R') countR++;
		if(S[i] == 'G') countG++;
		if(S[i] == 'B') countB++;
	}

	LL  count = countR*countG*countB;//S_i != S_j != S_kとなるものの総和

	rep(i, 0, N){
		rep(j , i + 1 , N){

			if( S[i] == S[j]) continue;

			LL k = 2*j - i;

			if( k >= N  || S[j] == S[k] || S[k] == S[i]) continue;

			count--;//S_i != S_j != S_kかつj - i == k-jとなるものを引いていく

		}
	}

	loutp(count);

	return 0;
}
signed main() {
	//Lucky_7();
	//FizzBuzz_Sum();
	//SogoT();
	RGBTs();
	return 0;
}




Measured memory_bytes: 3792
n = int(input())
lucas_number = [0] * (n + 1)
lucas_number[0] = 2
lucas_number[1] = 1
for i in range(2, n + 1):
    lucas_number[i] = lucas_number[i - 1] + lucas_number[i - 2]
print(lucas_number[n])


Measured memory_bytes: 9188
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef int status;
typedef long long ll;
typedef unsigned long long ull;
const ull base = 343;
const int INF = int(1e9);
const int MAX = 200005;

int N,M;
int a[MAX];
int b[MAX];

int main()
{
    scanf("%d%d",&N,&M);
    for(int i = 0;i<MAX;i++)
        b[i] = INF;
    int sum = 0;
    for(int i =1;i<=N;i++)
    {
         scanf("%d",&a[i]);
         if(b[a[i]]==INF)
         {
             sum++;
             b[a[i]] = 0;
         }

         b[a[i]]++;
    }
    if(sum <= M)
    {
        printf("%d",0);
        return 0 ;
    }

    sort(b,b+MAX);
    int x= 0;


    for(int i = 0;i<sum-M;i++)
        x += b[i];

    cout<<x<<endl;


     return 0;
}


Measured memory_bytes: 1792
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! printvec {
    ( $item:expr ) => {
        for &i in &$item {
            print!("{} ", i);
        }
        println!("");
    }
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);
impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}
impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}
#[derive(PartialEq, PartialOrd, Clone, Debug)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}
#[allow(dead_code)]
const MOD: usize = 1000000007;


fn main() {
    input!{
        N: usize, K: usize,
        S: chars,
    }

    let mut tmp = 0;
    
    for i in 0..N-1 {
        if S[i] == S[i+1] {
            tmp += 1;
        }
    }
    println!("{}", min(tmp + 2 * K, N - 1));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a;
  cin>>a;
  string b;
  cin>>b;
  rep(i,b.size()){
    b[i]+=a;
  if(b[i]>90)
    b[i]-=26;
    cout<<b[i];
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  string s;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << "\n";
  }
  if (s == "Cloudy") {
    cout << "Rainy" << "\n";
  }
  if (s == "Rainy") {
    cout << "Sunny" << "\n";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, a, s, d, mx=-1e9, f[105], p[105][15];
int main() {
	int i, j, t;
	cin>>n;
	for(i=1; i<=n; i++) for(j=0; j<10; j++) cin>>a, f[i] = f[i]<<1|a;
	for(i=1; i<=n; i++) for(j=0; j<=10; j++) cin>>p[i][j];
	for(j=1; j<1024; j++) {
		for(i=1, s=0; i<=n; i++) {
			t = j & f[i];
			for(d=0; t; t>>=1) d += t&1;
			s += p[i][d];
		}
		mx = max(mx, s);
	}
	cout<<mx;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([b,a])
l.sort()
time=0
cnt=0
for i in range(n):
    time+=l[i][1]
    if time>l[i][0]:
        print("No")
        break
    else:
        cnt+=1
if cnt==n:
    print("Yes")

Measured memory_bytes: 35608
"use strict"

const main =(input)=>{
const Array=input.split("\n").map((n)=>parseInt(n,10))
const a= Array[0]
const b= Array[1]
const c= Array[2]
const x= Array[3]
let result = 0;

for(let i=0;i<=a;i++)for(let j=0;j<=b;j++)for(let k=0;k<=c;k++){
  if(500*i+100*j+50*k==x) result ++;
}
console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <queue>
#include <set>
#include <string>

std::vector<size_t> f(std::string const& s, size_t k, size_t c) {
  std::vector<size_t> res;
  size_t i = 0;
  while (res.size() < k) {
    while (s[i] == 'x') ++i;
    res.push_back(i);
    i += c+1;
  }
  for (; i < s.length(); ++i) {
    if (s[i] == 'o') return {};
  }
  // for (size_t i = 0; i < res.size(); ++i)
  //   fprintf(stderr, "(%zu)%c", res[i], i+1<res.size()? ' ': '\n');
  return res;
}

int main() {
  size_t n, k, c;
  scanf("%zu %zu %zu", &n, &k, &c);

  char buf[262144];
  scanf("%s", buf);
  std::string s = buf;

  std::vector<size_t> a = f(s, k, c);
  std::vector<size_t> z = f(std::string(s.rbegin(), s.rend()), k, c);

  for (size_t i = 0; i < z.size(); ++i) z[i] = n-1-z[i];
  std::reverse(z.begin(), z.end());

  std::set<size_t> tmp(a.begin(), a.end());
  std::set<size_t> res;
  for (auto zi: z)
    if (tmp.count(zi)) res.insert(zi);

  for (auto ri: res) printf("%zu\n", ri+1);
}


Measured memory_bytes: 23792
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define why 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
  return (x&(-x));
}
void solve(){
  ll n,x; cin>>n;
  map<ll,ll> ma;
  rep(i,n-1){
    cin>>x; ma[x]++;
  }
  for(ll i=1;i<=n;i++){
    cout<<ma[i]<<endl;
  }
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
      solve();
    }
}

Measured memory_bytes: 16116