akhauriyash/Code-Regression huggingface dataset:
#ifdef _DEBUG
    #include "MyLib.h"
    #else
    #define main_D main
    #include "bits/stdc++.h" 
    #include <regex>
    #define _USE_MATH_DEFINES
    #include <math.h>
    #define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
    #define REP(i,e) FOR(i,0,e)
    #define INF (INT_MAX/2)
    #define EPS (1.0e-8)
    #define LINF (LLONG_MAX/2)
    const int MGN = 10;
    const int ARY_SZ_MAX = 10000000;
    using namespace std;
    using ll = long long; using ull = unsigned long long;
    using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
    using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
    using vl = vector<ll>; using vvl = vector<vl>;
    using vd = vector<double>; using vs = vector<string>;
    using pii = pair<int, int>; using pll = pair<ll, ll>;
    using psi = pair<string, int>;
    // functions
     
    #endif 
     
     
    int main_D() {
        cin.tie(0);
        ios::sync_with_stdio(false);
     
     
        const ll MOD = 1e9 + 7;
        int N;  cin >> N;
     
        auto dp = vector<map<string, ll>>(N + 1);
        char C[4] = { 'A','G', 'C', 'T' };
        for(char c1 : C) {
            for(char c2 : C) {
                for(char c3 : C) {
                    string last3 = { c1,c2,c3 };
                    if (last3=="AGC" || last3=="GAC" || last3=="ACG") {
                        dp[3][last3] = 0;
                    } else {
                        dp[3][last3] = 1;
                    }
                }
            }
        }
     
        FOR(i, 3, N) {
            for (auto p : dp[i]) {
                string s = p.first;
                if (dp[i][s] == 0) continue;  
              
                for(char c : C) {
                    string ns = s.substr(1, 2) + c;
                    if (ns == "AGC" || ns == "GAC" || ns == "ACG" 
                        || (s[0]=='A' && s[2]=='G' && c=='C')
                        || (s[0]=='A' && s[1]=='G' && c=='C')) {
                        continue;
                    }
     
                    dp[i + 1][ns] += dp[i][s];
                    dp[i + 1][ns] %= MOD;
                }
            }
        }
     
        ll ans = 0;
        for(auto p : dp[N]) {
            ans += p.second;
            ans %= MOD;
        }
     
        cout << ans << endl;
     
        return 0;
    }

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

int main() {
	
	string s; cin >>s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '1') s[i] = '9';
		else if (s[i] == '9') s[i] = '1';
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 1e7 + 5;
bool prime[MAX];
int smf[MAX];
void sieve()
{
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	for(int i = 2; i < MAX; i++){
		if(prime[i]) {
			smf[i] = i;
			for(int j = 2 * i; j < MAX; j += i) {
				if(prime[j]) smf[j] = i;
				prime[j] = false;
			}
		}
	}
}
int main()
{
	boost;
	sieve();
	int n, i;
	cin >> n;
	if(n == 1) cout << 1 << '\n';
	else {
		ll ans = 1;
		for(i = 2; i <= n; i++) {
			int x = i;
			ll res = 1;
			while(x > 1) {
				int y = smf[x], cnt = 0;
				while(x % y == 0) {
					cnt++;
					x /= y;
				}
				res *= (cnt + 1);
			}
			ans += 1ll * i * res;
		}
		cout << ans;
	}
}


Measured memory_bytes: 52480
from collections import deque

# input
N = int(input())
G = dict()
for i in range(N):
    G[i] = dict()

for _ in range(N - 1):
    a, b = map(int, input().split())
    G[a-1][b-1] = 1
    G[b-1][a-1] = 1

# find diameter of the tree
# 2 times dijkstra
queue1 = deque([0])
d1 = [1000000] * N
d1[0] = 0

while len(queue1) > 0:
    p = queue1.popleft()
    for q in G[p].keys():
        if d1[q] > d1[p] + 1:
            d1[q] = d1[p] + 1
            queue1.append(q)
# find farthest
far = 0
dd = 0
for i in range(N):
    if d1[i] > dd:
        far = i
        dd = d1[i]

queue2 = deque([far])
d2 = [1000000] * N
d2[far] = 0

while len(queue2) > 0:
    p = queue2.popleft()
    for q in G[p].keys():
        if d2[q] > d2[p] + 1:
            d2[q] = d2[p] + 1
            queue2.append(q)
diam = max(d2)
# print(diam)
if diam % 3 == 1:
    print("Second")
else:
    print("First")

Measured memory_bytes: 123916
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn=3e5+5;
map<pair<int,int>,bool>mp;
vector<int>a,b;
typedef long long ll;
int r[maxn],c[maxn];
int main(){
    int h,w,n,x,y,mxr,mxc;
    scanf("%d%d%d",&h,&w,&n);
    mxr=mxc=0;
    while(n--){
        scanf("%d%d",&x,&y);
        mp[{x,y}]=1;
        r[x]++;
        c[y]++;
        mxr=max(mxr,r[x]);
        mxc=max(mxc,c[y]);
    }
    for(int i=1;i<=h;++i)
        if(r[i]==mxr)a.push_back(i);
    for(int j=1;j<=w;++j)
        if(c[j]==mxc)b.push_back(j);
    for(auto&v:a)
        for(auto&q:b){
            if(mp[{v,q}]==0){
                cout<<mxr+mxc<<endl;
                return 0;
            }
        }
    cout<<mxr+mxc-1<<endl;
    return 0;
}

Measured memory_bytes: 23440
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s;
  int k;
  cin>>s>>k;
  int al[26] = {};
  rep(i, s.size()) {
    al[(int)(s[i] - 'a')] = 1;
  }
  vector<string> v;
  rep(i, 26) {
    if(al[i]) {
      rep(j, s.size()) {
        if(s[j] == (char)('a' + i)) {
          rep(l, 5) {
            if(j + l < s.size()) {
              v.push_back(s.substr(j, l + 1));
            }
          }
        }
      }
    }
    if(v.size() >= 20) break;
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  cout << v[k - 1] << endl;

  return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>
// 最大公約数gcd()
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;

int gcd(lint x, lint y){
	return y==0 ? x:gcd(y,x % y);
}

int main(){
  lint w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<fixed<<setprecision(6)<<double(w*h)/2.0<<" ";
  if(x+x==w&&y+y==h){
    cout<<"1";
  }
  else{
    cout<<"0";
  }
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    cin >> n;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(all(a));
    bool c = true;
    rep(i,n-1){
        if(a[i]==a[i+1]){
            c = false;
            break;
        }
    }
    cout << (c ? "YES" : "NO") << endl;
}

Measured memory_bytes: 4848
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <tuple>

using namespace std;

typedef long long ll;

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

int main(void){
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll bc = b / c;
    ll bd = b / d;
    ll ac = (a - 1) / c;
    ll ad = (a - 1) / d;
    ll cd = (c * d) / gcd(c,d);
    ll acxd = (a - 1) / cd;
    ll bcxd = b / cd;
    ll acd = ac + ad - acxd;
    ll bcd = bc + bd - bcxd;
    ll ans = (b - a + 1) - (bcd - acd);
    cout << ans << endl;
    return 0;
}


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

bool isKaibun(string &s1)
{
	string s2 = s1;
	reverse(s2.begin(), s2.end());
	return s1 == s2;
}

int main()
{
	string s1;
	cin >> s1;
	int n = s1.size();
	
	string s2 = s1.substr(0, (n-1)/2);
	string s3 = s1.substr((n+3)/2-1, n-1);

	if (isKaibun(s1) && isKaibun(s2) && isKaibun(s3))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

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

int main() {
    ll A, B;
    cin >> A >> B;
    ll G = gcd(A, B);
    set<ll> cand;
    for (ll n = 1; n * n <= G; n++) {
        if (G % n == 0) {
            cand.insert(n);
            cand.insert(G / n);
        }
    }

    vector<ll> d;
    for (ll s : cand) {
        d.push_back(s);
    }
    int N = d.size();
    vector<bool> ok(N, true);
    for (int i = 0; i < N; i++) {
        if (!ok[i])
            continue;

        for (int j = i + 1; j < N; j++) {
            if (gcd(d[i], d[j]) != 1) {
                ok[j] = false;
            }
        }
    }

    int ans = 0;
    for (bool b : ok) {
        if (b) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import sys
from collections import defaultdict
from itertools import groupby

read = sys.stdin.read

N, *C = map(int, read().split())
C = [i for i, _ in groupby(C)]
mod = 10 ** 9 + 7
cnt = defaultdict(int)
dp = 1
for idx, i in enumerate(C):
    prev = dp
    dp = (cnt[i] + dp) % mod
    cnt[i] = (cnt[i] + prev) % mod

print(dp)


Measured memory_bytes: 34712
#include <stdio.h>

int main(void)
{
  int n,x,i,j,k;

  while(1){

    scanf("%d %d",&n,&x);

    if(n==0 && x==0){
      break;
    }

    int count =0;
    
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	for(k=1;k<=n;k++){
	  if(i==j || i==k || j==k){
	    continue;
	  }
	  if(x==i+j+k){
	    count++;
	  }
	}
      }
    }
    
    printf("%d\n",count/6);
  }

  return 0;

}

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    int n;
    cin >> n;

    map<string, int> mp;

    roop(i, n){
        string s; cin >> s;
        mp[s]++;
    }

    cout << mp.size() << endl;

    return 0;
}


Measured memory_bytes: 19264
n=int(input(''))
l=[]

ac=[]
wa=[]
tle=[]
re=[]
for a in range(n):
    w=input('')
    if w=='AC':
        ac.append(w)
    elif w=='WA':
        wa.append(w)
    elif w=='TLE':
        tle.append(w)
    elif w=='RE':
        re.append(w)

print('AC x '+str(len(ac)))
print('WA x '+str(len(wa)))
print('TLE x '+str(len(tle)))
print('RE x '+str(len(re)))

Measured memory_bytes: 16604
n = int(input())
a = list(map(int,input().split()))
rate = [0]*9
for i in a:
    if i < 400:
        rate[0] += 1
    elif i < 800:
        rate[1] += 1
    elif i < 1200:
        rate[2] += 1
    elif i < 1600:
        rate[3] += 1
    elif i < 2000:
        rate[4] += 1
    elif i < 2400:
        rate[5] += 1
    elif i < 2800:
        rate[6] += 1
    elif i < 3200:
        rate[7] += 1
    else:
        rate[8] += 1
counter = 0
for j in range(len(rate)-1):
    if rate[j] > 0:
        counter += 1

if counter == 0:
    print("1 " + str(rate[-1]))
else:
    print(str(counter) + " " + str(counter + rate[-1]))

Measured memory_bytes: 3064
#include <iostream>
#include <string>


int main() {
   int n; std::cin >> n;
   std::string s; std::cin >> s;
  
   for (int i = 0; i < (int)s.size(); ++i) {
      char c = s[i] - 65; // 0~25に変換
      c += n;
      c %= 26;
      c += 65;
      std::cout << c;
   }
   std::cout << std::endl;

   return 0;
}


Measured memory_bytes: 3596
N, K = map(int, input().split())
X, Y = [], []
D = []
for i in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    D.append((x, y))

X = sorted(X)
Y = sorted(Y)
num = float("inf")
for i in range(N - 1):
    for j in range(i + 1, N):
        for k in range(N - 1):
            for l in range(k + 1, N):
                tmp = 0
                for m in range(N):
                    if X[i] <= D[m][0] <= X[j] and Y[k] <= D[m][1] <= Y[l]:
                        tmp += 1
                if tmp >= K:
                    num = min(num, (X[j] - X[i]) * (Y[l] - Y[k]))

print(num)

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

int main(){
  int k,t;
  priority_queue<int,vector<int> > q;
  scanf("%d %d",&k,&t);
  for(int i=0;i<t;i++){
    int a;
    scanf("%d",&a);
    q.push(a);
  }
  if(q.top()*2>k) printf("%d\n",q.top()-(k-q.top()+1));
  else printf("0\n");
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int *)b - *(int *)a;
}

int main(){
    int N, M;
    int A[101] = {0}, sum_A;
    int i;
    double chk;

    scanf("%d %d", &N, &M);

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

    qsort(A, N, sizeof(int), compare_int);

    chk = ((double)sum_A / (double)(4 * M));
    for (i = 0; i < M; i++)
    {
        if(A[i] < chk){
            printf("No");
            return 0;
        }
    }
    printf("Yes");

    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int cnt = 1;
		List<int> L = new List<int>();
		char c = 'R';
		for(int i=1;i<N;i++){
			if(S[i] == c){
				cnt++;
			} else {
				L.Add(cnt);
				c = S[i];
				cnt = 1;
			}
		}
		L.Add(cnt);
		
		int[] ans = new int[N];
		int k = 0;
		for(int i=0;i<N-1;i++){
			if(S[i] == 'R' && S[i+1] == 'L'){
				int l = L[k];
				int r = L[k+1];
				ans[i] += l - l / 2;
				ans[i+1] += l / 2;
				ans[i] += r / 2;
				ans[i+1] += r - r / 2;
				k += 2;
			}
		}
		Console.WriteLine(String.Join(" ",ans));
		
		
		
		
		
	}
	int N;
	String S;
	public Sol(){
		S = rs();
		N = S.Length;
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 14176
#include<bits/stdc++.h>
#define ll long long
#define REP(i,a,n) for(ll i=a;i<(n);i++)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define IT iterater
#define FOR(i,a,n) for(ll i=a;i<=(n);i++)
#define B(s) s.back()
#define all(a) a.begin(),a.end()
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    string ch="abcdefghijklmnopqrstuvwxyz";
	ll n;
	cin>>n;
	string s="";
	if(n<=26)
	{
		cout<<ch[n-1];
		return 0;
	}
	while(n){
		int x=n%26;
		if(x){
		s=ch[x-1]+s;
		}
		else{
		s='z'+s;
		}
		if(!x){
			n/=26;
			n--;
		}
		else
		n/=26;
	}
	cout<<s;
    return 0;
}


Measured memory_bytes: 3596
object Main extends App{

val n = scala.io.StdIn.readInt

var cnt = 0
for (i <- 1 to n) {
  if (i%2 != 0){
      var yakusuu = 0
      for (j <- 1 to i){
        if (i % j == 0) yakusuu += 1
        // 8を超えたらbreakしたい
      }
      if (yakusuu == 8){
        cnt += 1
      }
  }
}

println(cnt)
}

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

#define ll long long 

using namespace std;

string s;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    for (int i=1; i<s.size(); i++){
        if (s[i]==s[i-1]){
            return cout<<"Bad",0;
        }
    }
    cout<<"Good";
    return 0;
}

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

using namespace std;

int n;
string s;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	cin >> s;
	int ans = 1;
	for (int i = 1; i < n; ++i) {
		if (s[i] == s[i-1]) continue;
		++ans;
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;


int main() {
    int N;
    int M;
    int X[100000];
    int d[100000];
    int res = 0;

    cin >> N;
    cin >> M;

    if (N >= M) {
        cout << 0;
        return 0;
    }
    for (int i = 0; i < M; i++) {
        cin >> X[i];
    }

    sort(X, X + M);
    for (int i = 0; i < M - 1; i++) {
        d[i] = X[i + 1] - X[i];
    }

    sort(d, d + M - 1);
    for (int i = 0; i < M-N; i++) {
        res += d[i];
    }

    cout << res;

    return 0;
}

Measured memory_bytes: 1024
<?php 
  fscanf(STDIN,"%d",$n);
  $str = substr($n,-1);
  if ($str == 2 || $str == 4 || $str == 5 || $str == 7 || $str == 9) {
    // code...
    echo "hon";
  }elseif($str == 0 || $str == 1 || $str == 6 || $str == 8){
    echo "pon";
  }else{
    echo "bon";
  }

Measured memory_bytes: 16064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
#define ll long long
#define kd int
#define fors(i,a,b) for(int i=(a);i<=(b);++i)
int main(){
    ios::sync_with_stdio(0);
    register int a,wh[9],b,c,d,e,f,g,h,i;
	cin>>a>>b>>e;
	fors(c,0,600){
		wh[1]=a+b+c;
		if(wh[1]<a+e) continue;
		fors(i,-100,200){
			wh[7]=a+e+i;
			if(wh[7]!=wh[1]) continue;
			fors(f,-100,200)
			{
				wh[6]=c+f+i;
				if(wh[6]!=wh[7]) continue;
				fors(d,-100,200){
					wh[2]=d+e+f;
					if(wh[2]!=wh[6]) continue;
					fors(g,-100,200)
					{
						wh[4]=g+d+a;
						wh[8]=c+e+g;
						if((wh[8]!=wh[4])) continue;
						fors(h,-100,200){
							wh[3]=g+h+i;
							wh[5]=b+e+h;
							if((wh[3]!=wh[5]) || (wh[3]!=wh[4])) continue;
								cout<<a<<" "<<b<<" "<<c<<endl;
								cout<<d<<" "<<e<<" "<<f<<endl;
								cout<<g<<" "<<h<<" "<<i<<endl;
								return 0;
						}
					}		
				}
			}
		}
	}
    return 0;
}

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

using namespace std;

int n;
vector<int> g[200010];
int c[200010];
const int md = 1000000007;
int d[200010];
int a[200010];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> c[i];
    }
    a[1] = c[1];
    int lo = 2;
    for(int i = 2; i <= n; i++){
        if(c[i] != c[i-1]){
            a[lo] = c[i];
            lo++;
        }
    }
    n = lo - 1;
    for(int i = 1; i <= n; i++){
        g[a[i]].push_back(i);
    }

    int cur = 1;
    d[0] = cur;
    for(int i = 1; i <= n; i++){
        auto it = lower_bound(g[a[i]].begin(), g[a[i]].end(), i);
        it++;
        if(it != g[a[i]].end()){
            int pos = *it;
            d[pos] = (d[i] + (d[pos] + cur) % md) % md;
        }
        cur = (cur + d[i]) % md;
    }
    int an = 0;
    for(int i = 0; i <= n; i++){
        an = (an + d[i]) % md;
    }
    cout << an;
    return 0;
}


Measured memory_bytes: 12800
fun main(arg: Array<String>) {
    val s = readLine()!!
    val m = mutableMapOf<Char, Int>(Pair('E', 0), Pair('W', 0), Pair('S', 0), Pair('N', 0))
    s.forEach { var d = m[it] ?: 0; m[it] = ++d }
    val (E, W, S, N) = listOf<Int>(m['E']!!, m['W']!!, m['S']!!, m['N']!!)
    val we = (E > 0 && W > 0) || (E == 0 && W == 0)
    val ns = (N > 0 && S > 0) || (N == 0 && S == 0)
    println(if (we && ns) "Yes" else "No")
}


Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i,n,*F;
  scanf("%d",&n);
  F = malloc(n*sizeof(int));
  F[0] = 1;
  F[1] = 1;
  for(i = 2; i <= n;i++){
    F[i] = F[i - 1] + F[i - 2];
  }
  printf("%d\n",F[n]);
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
        using namespace std;
        using ll = long long;
        using ull = unsigned long long;
        using pii = pair<int, int>;
        using pll = pair<ll, ll>;

        const int MAXN = 1e5 + 5;
        const int MOD = 1e9 + 7;
        const int INF = 0x3f3f3f3f;
        const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
        const double EPS = 1e-9;
        #define NMAX 100005
        #define LAST 1000000000002


        int main(){
            int size,n,price=0;
            cin>>size>>n;
            int tab[size];
            for (int i = 0; i < size; ++i)
            {
                cin>>tab[i];
            }
            sort(tab,tab+size);
            for (int i = n-1; i >=0; --i)
            {
                price += tab[i];
            }
            cout<<price;
           return 0;

        }


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll A, B;
    cin>>A>>B;
    cout<<max((ll)0,A-B*2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a;
    int b;
    int c;
    cin >> a >> b >> c;
    int result = 0;
    for(int i = a; i <= b; i++){
        if(c % i == 0){
            result++;
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 3120
#include <stdio.h>

int n, A[50];

int solve(int i, int m){
    if (m==0) return 1;
    if (i>=n) return 0;
    int res = solve(i+1,m) || solve(i+1,m-A[i]);
    return res;
}

int main(){
    int q, M, i;

    scanf("%d",&n);
    for (int i = 0; i < n; ++i) scanf("%d", &A[i]);
    scanf("%d",&q);
    for (int i = 0; i < q; ++i)
    {
        scanf("%d",&M);
        if (solve(0,M)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int N, R; cin >> N >> R;
	if(N >= 10) {
		cout << R << endl;
	}
	else {
		cout << R + 100*(10-N) << endl;
	}

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = n - 1; i>= 0; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;

const int MAXN = 100005;
ll mod=1000000007;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	if ( k < a){
		cout<<k;
	}
	else if ( k < a + b ){
		cout<<a;
	}
	else if ( k <= a + b + c){
		cout<<a + ( k - ( a+ b))*-1; 	
	}
	return 0;
}



Measured memory_bytes: 3592
#include<stdio.h>
int main(){
	int a;
	while(scanf("%d",&a),a){
		int sum=0;
		for(int i=0;i<a;i++){
			int b,c,d,e;
			scanf("%d%d%d%d",&b,&c,&d,&e);
			int f=b+c+d;
			if(f<=60&&e<=2)sum+=600;
			else if(f<=80&&e<=5)sum+=800;
			else if(f<=100&&e<=10)sum+=1000;
			else if(f<=120&&e<=15)sum+=1200;
			else if(f<=140&&e<=20)sum+=1400;
			else if(f<=160&&e<=25)sum+=1600;
		}
		printf("%d\n",sum);
	}
}

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

#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;

ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();

ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}

ll pow_mod(ll a, ll e, ll m){
	if(e<0) return 0;
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}

ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

int knap_sack(int t, vint &wt, vint &val, int n) {
   	int W=t+100;
   	vvint K(n+1,vint(W+1,0));
   	for (int i = 1; i <= n; i++) {
       	for (int w = 1; w <= W; w++) {
			if (wt[i] <= w) {
           		if(w-wt[i]<t) K[i][w] = max(val[i] + K[i-1][w-wt[i]],  K[i-1][w]);
           		else K[i][w]=max(K[i-1][w], K[i][w-1]);
           	} else {
           		K[i][w] = max(K[i-1][w], K[i][w-1]);
           	}

           	// cout<<i<<" "<<w<<" "<<K[i][w]<<endl;
        }
    }
   	return K[n][W];
}

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

	int n, t;
	cin>>n>>t;
	vpii wt(n);
	for(int i=0; i<n; i++) cin>>wt[i].fst>>wt[i].scd;
	sort(all(wt));
	unordered_map<int,int> etv, tmp;
	etv[0]=0;
	for(int i=0; i<n; i++){
		unordered_map<int,int> tmp;
		for(auto x : etv){
			if(x.fst<t-0.5){
				auto fitr=tmp.find(x.fst+wt[i].fst);
				if(fitr!=tmp.end()){
					fitr->scd=max(fitr->scd,x.scd+wt[i].scd);
				} else {
					tmp.insert({x.fst+wt[i].fst, x.scd+wt[i].scd});
				}
			}
		}

		for(auto x : tmp){
			auto fitr=etv.find(x.fst);
			if(fitr!=etv.end()){
				fitr->scd=max(fitr->scd,x.scd);
			} else {
				etv.insert(x);
			}
		}
	}

	int ans=0;
	for(auto x : etv) ans=max(ans, x.scd);
	cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
        }
        List<Integer> dp = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            if (dp.size() == 0) {
                dp.add(A[i]);
                continue;
            }
            if (dp.get(0) < A[i]) {
                dp.set(0, A[i]);
                continue;
            }
            if (A[i] <= dp.get(dp.size()-1)) {
                dp.add(A[i]);
                continue;
            }
            int insert_point = ~Collections.binarySearch(dp, A[i], new LowerBoundComparator<Integer>());
            dp.set(insert_point, A[i]);
        }
        System.out.println(dp.size());
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T> {
        public int compare(T x, T y) {
            return (x.compareTo(y) >= 0) ? -1 : +1;
        }
    }
}


Measured memory_bytes: 53648
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := readInt()
	idx := 1
	ans := 0
	for i := 0; i < n; i++ {
		a := readInt()
		if a != idx {
			ans++
			continue
		}
		idx++
	}

	if idx == 1 {
		fmt.Println(-1)
		return
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
using namespace std;
#define N 10000000;
int main(void)
{
  int n;
  int in;
  int num[8];
  int max, min;
  int keta=N;

  cin >> n;
  for(int a = 0 ; a < n ; a++) {
    cin >> in;
    
    num[0] = in / 10000000;
    in -= num[0] * 10000000;
    num[1] = in / 1000000;
    in -= num[1] * 1000000;
    num[2] = in / 100000;
    in -= num[2] * 100000;
    num[3] = in / 10000;
    in -= num[3] * 10000;
    num[4] = in / 1000;
    in -= num[4] * 1000;
    num[5] = in / 100;
    in -= num[5] * 100;
    num[6] = in / 10;
    in -= num[6] * 10;
    num[7] = in;

    keta = N;
    sort(num, num+8);
    for(int i = 0 ; i < 8 ; i++) {
      min += num[i] * keta;
      keta /= 10;
    }
    keta = N;
    for(int i = 7 ; i >= 0 ; i--) {
      max += num[i] * keta;
      keta /= 10;
    }
    cout << max - min << endl;
    max = 0; min = 0;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;


void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if(z->key < x->key ){
      x= x->left;
    }else{
      x=x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y ->right = z;
    }
  }



}

void inorder(Node u){
  if(u == NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 25228
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    const string out[] = {"null", "one pair", "two pair", 
                          "three card","straight",
                          "full house", "four card"};
    char ch;
    int input[6];

    while (cin >> input[0]) {
        // Input
        for (int i = 1; i < 5; i++) 
            cin >> ch >> input[i];
        input[5] = 100;

        // Initialization
        sort(input, input + 5);

        // Algorithm
        int card[5] = {0};
        int cnt = 0;
        
        for (int i = 0; i < 5; i++) {
            if (input[i] == input[i + 1])
                cnt++;
            else {
                card[cnt]++;
                cnt = 0;
            }
        }

        if (card[3] == 1) 
            cout << out[6] << endl;
        else if (card[1] == 1 && card[2] == 1) 
            cout << out[5] << endl;
        else if (card[2] == 1) 
            cout << out[3] << endl;
        else if (card[1] == 2)
            cout << out[2] << endl;
        else if (card[1] == 1)
            cout << out[1] << endl;
        else if (card[0] == 5) {
            int i;
            for (i = 1; i < 4; i++) 
                if (input[i + 1] != input[1] + i)
                    break;
            if (i == 4 && ((input[0] == input[1] - 1) || (input[0] == 1))) 
                cout << out[4] << endl;
            else 
                cout << out[0] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
int main()
{
 int i,j,a,b,c,sum,cnt=0;
 cin>>a>>b>>c;
 int a1[b];
 for(i=0;i<b;i++)
    cin>>a1[i];
 while(a--)
 {
     int a2[b];
     sum=0;
     for(i=0;i<b;i++)
        cin>>a2[i];
     for(i=0;i<b;i++)
        sum=sum+a1[i]*a2[i];
        if(sum+c>0)
            cnt++;
 }
 cout<<cnt<<endl;
      return 0;
}


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

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            AC141B();
        }

        static void AC141B()
        {
            var list = Console.ReadLine().ToArray().ToList();

            //インデックス番号とN文字目は0始まりと1始まりのためズレる
            //そのため、インデックス番号が偶数のものが文字列の奇数文字列目となる
            var kisu = list.Where((x, index) => index % 2 == 0).ToList();
            var gusu = list.Where((x, index) => index % 2 == 1).ToList();

            var retStr = "Yes";

            if(gusu.Contains('R') || kisu.Contains('L'))
            {
                retStr = "No";
            }

            Console.WriteLine(retStr);
            Console.ReadKey();
        }

    }
}


Measured memory_bytes: 13280
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def main():
#    h,w,a,b = map(int, input().split())
    s=input()
    a=0
    if s=="SUN":
        a=7
    elif s=="MON":
        a=6
    elif s == "TUE":
        a = 5
    elif s == "WED":
        a = 4
    elif s == "THU":
        a = 3
    elif s == "FRI":
        a = 2
    elif s == "SAT":
        a = 1
#    a = [[0] * i for i in range(h)]

    print(a)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
//============================================================================
// Name        : Hello.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	int a,b;
	cin>>a>>b;
	int c;
	c=1;

	for(int i=0;i<100;i++){
		if(c>=b){
			cout<<i<<endl;
			break;
		}
		c+=a-1;
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb(x) push_back(x)
#define TEST(t) int inox; for(inox=1;inox<=t;inox++)
using namespace std;
vector<ll> adj[200005];
void dfs(ll x, ll parent[]){
	for(auto j:adj[x]){
		if(parent[x]!=j){
			parent[j]=x; dfs(j,parent);
		}
	}
}
void dfs1(ll x, ll parent[], ll a[]){
  for(auto j: adj[x]){
  	if(parent[x]!=j){
  		a[j]+=a[x]; dfs1(j,parent,a);
  	}
  }
}
int main()
{
	ll n,q,i,u,v; cin>>n>>q;
   ll a[n+1],parent[n+1]; 
   for(i=0;i<n-1;i++){
   		cin>>u>>v;
   		adj[u].pb(v); adj[v].pb(u);
   }
   for(i=0;i<=n;i++){a[i]=0;parent[i]=-1;}
   	dfs(1,parent);
   for(i=1;i<=q;i++){
   	cin>>u>>v;
   	a[u]+=v;
   }
   dfs1(1,parent,a);
   for(i=1;i<=n;i++)cout<<a[i]<<" ";
	return 0;
}

Measured memory_bytes: 28928
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  string s;
  cin >> s;
  if (s[0] == '7'|| s[1] == '7' || s[2] == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      aa: [usize; n],
    }

    let mut upper = 0;
    let mut ans = 0;
    for i in 0..n {
        let mut a = aa[i];
        let num = (a-1)/(upper+1);
        ans += num;
        a -= num * (upper+1);
        if num == 0 && a > upper {
            upper = a;
        } else {
            a = max(upper, 1);
        }
        upper = max(upper, a);
        // debug!(i, a, num, ans, upper);
    }
    puts!("{}\n", ans);
}


Measured memory_bytes: 4352
#![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! 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;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        N: usize,
        A: [f64; N],
    }
    println!("{}", 1f64 / A.into_iter().fold(0f64, |acc, a| acc + 1f64 / a));
}

Measured memory_bytes: 4352
#pragma region Macros
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define REV(x) reverse(ALL(x))
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define SP << " " <<
#define INF2 1000000000000000037
#define INF  1000000007
#define lwb(x,n) distance(x.begin(),lower_bound(ALL(x),(n)))
#define upb(x,n) distance(x.begin(),upper_bound(ALL(x),(n)))
#ifdef _MY_DEBUG
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define de(...) CHOOSE((__VA_ARGS__,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define de(...)
#endif
using namespace std;
using ll = long long;
using ld = long double;
template<class T = ll> using v = vector<T>;
template<class T = ll> using vv = vector<vector<T>>;
template<class T = ll> using vvv = vector<vector<vector<T>>>;
template<class T> bool maxi(T &a, const T &b){ if(a<b){a=b;return 1;}return 0;}
template<class T> bool mini(T &a, const T &b){ if(b<a){a=b;return 1;}return 0;}
template<class T> ll sumer(const T& a){ return accumulate(ALL(a),0LL); }
template<class T, class U> ostream &operator<<(ostream &os, const pair<T,U> &pe) { os << pe.first << " " << pe.second; return os;}
template<class T> ostream &operator<<(ostream &os, const v<T> &ve) { rep(i,ve.size()) os<< (i?" ":"")<<ve[i]; return os;}
ll topbit(ll a) { return a==0?-1:63-__builtin_clzll(a);}
ll botbit(ll a) { return a==0?64:__builtin_ctzll(a);}
ll popcount(ll a) { return __builtin_popcountll(a);}
#define dame {cout<< retword <<"\n"; return;}
#pragma endregion
//--MODIFS---------------------------------
#pragma region Modifs
#define retword "-1"
#define MOD  1000000007
using P  = pair<ll,ll>;
using TP  = tuple<ll,ll,ll>;
#pragma endregion
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N;
    cin>>N;
    v<> ans(N,0);
    v<> A(N,0);
    rep(i,N-1){
        cin>>A[i];
        ++ans[A[i]-1];
    }
    for(auto& a: ans) cout<< a <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // ll Qkai; cin>>Qkai; while(Qkai--) Main();
    Main();
}
//-----------------------------------------

Measured memory_bytes: 6352
while True:
  s = list(map(int,input().split()))
  if sum(s) == -3:
    break
  if s[0] == -1 or s[1] == -1:
    print('F')
    continue
  if (s[0] + s[1]) >= 80:
    print('A')
  elif (s[0] + s[1]) >= 65:
    print('B')
  elif (s[0] + s[1]) >= 50:
    print('C')
  elif (s[0] + s[1]) >= 30:
    if s[2] >= 50:
      print('C')
    else:
      print('D')
  else:
    print('F')


Measured memory_bytes: 5596