akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size())cout << a[i] << " ";cout << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,M;
    cin >> N >> M;
    if(N + M == 15)cout << "+" << endl;
    else if(N * M == 15){cout << "*" << endl;}
    else cout << "x" << endl;
    
}

Measured memory_bytes: 3624
/*
Look at the star
Look at the shine for U
*/
#include<bits/stdc++.h>
#define ll long long
#define PII pair<int,int>
#define sl(x) scanf("%lld",&x)
using namespace std;
const int N = 1e6+5;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
ll inv(ll b){if(b==1)return 1; return (mod-mod/b)*inv(mod%b)%mod;}
ll fpow(ll n,ll k){ll r=1;for(;k;k>>=1){if(k&1)r=r*n%mod;n=n*n%mod;}return r;}

int main()
{
	ll n,x,y,a,b;
	ll sum  = 0;
	cin >> n >> x >> y;
	for(ll i = 0;i < n;i++)
	{
		cin >> a >> b;
		if(a >= x && b >= y)
			sum++;
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
typedef pair<int, int> P;

bool pairsort1(const P& element1, const P& element2)
{//first昇順
	return element1.F < element2.F;
}
bool pairsort2(const P& element1, const P& element2)
{//first降順
	return element1.F > element2.F;
}
bool pairsort3(const P& element1, const P& element2)
{//second昇順
	return element1.S < element2.S;
}
bool pairsort4(const P& element1, const P& element2)
{//second降順
	return element1.S > element2.S;
}

int main() {
	int N;
	scanf("%d",& N);
	vector<int>A(N);
	ll Max = 0;
	int Now = 0;
	rep(i, N) {
		scanf("%d",&A[i]);
		Max += abs(A[i] - Now);
		Now = A[i];
		if (i == N - 1) {
			Max += abs(Now);
		}
	}

	rep(i, N) {
		ll tmp = Max;
		if (i == 0) {
			tmp -= abs(A[0]-0)+ abs(A[1] - A[0]);
			tmp += abs(A[1]-0);
		}
		else if (i == N - 1) {
			tmp -=abs(A[N-1]-A[N-2])+ abs(0 - A[N - 1]);
			tmp += abs(0-A[N - 2]);
		}
		else {
			tmp -= abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i]);
			tmp += abs(A[i + 1] - A[i - 1]);
		}
		cout << tmp << endl;
	}

}



Measured memory_bytes: 1664
n, m, x, y = map(int, input().split())
xx = [int(i) for i in input().split()]
yy = [int(i) for i in input().split()]

war = False
for z in range(x + 1, y + 1):
    if max(xx) < z <= min(yy):
        war = True

print('No War') if war else print('War')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define MOD 1e9+7
#define MAX 1e12
#define MIN -10000000000
#define pi acos(-1)
#define esp 1e-6
#define memz(x) memset(x, 0, sizeof x)
#define memn(x) memset(x, -1, sizeof x)
#define pb push_back
#define nai string::npos
#define in1(a) scanf("%lld", &a)
#define in2(a,b) scanf("%lld%lld", &a, &b)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(i) printf("Case #%lld: ", ++i)
#define FILE    freopen("input.txt", "r", stdin); freopen("out.txt", "w", stdout);
using namespace std;
const ll N=100010;
ll s;
int main()
{
    in1(s);
    ll sq=sqrt(s);
    if(sq*sq<s)
        sq++;
    ll b=(sq*sq)-s;
    cout<<"0 0 "<<b<<" "<<sq<<" "<<sq<<" 1"<<endl;
    return 0;
}


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

#define N 100000

int aa[N];

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return aa[i] - aa[j];
}

int main() {
	static int ii[N];
	int n, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &aa[i]);
		ii[i] = i;
	}
	qsort(ii, n, sizeof *ii, compare);
	for (i = 0; i < n; i++)
		printf("%d ", ii[i] + 1);
	printf("\n");
	return 0;
}


Measured memory_bytes: 1532
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

void print(vector<int> a){
    for (int i = 0; i < a.size(); i++) {
        cout << a[i] ;
        if(i != a.size() - 1) cout << " ";
    }
    cout << endl;
}

void insertionSort(vector<int> a){
    for(int i = 1; i < a.size(); i++){
        print(a);
        int v = a[i];
        int j = i -1;
        while(j >= 0 && a[j] > v){
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = v;
    }
    print(a);
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    insertionSort(a);
    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int X; cin >> X;
  int result = 0;
  while (result*(result+1)/2<X) { result++; }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d);
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

char s[210];
int main(){
	ll k,n;
	scanf("%s %lld",s,&k);
	n=strlen(s);
	int flag=1;
	rep(i,0,n-1)flag&=s[i]==s[i+1];
	if(flag){
		//1種類
		printf("%lld",n*k/2);
		return 0;
	}
	//2種類以上
	ll a[110]={},cnt=0;
	rep(i,0,n){
		char c=s[i];
		int p=1;
		while(i+1<n&&s[i+1]==c)i++,p++;
		a[cnt++]=p;
	}
	ll ans=0;
	if(s[0]!=s[n-1]){
		rep(i,0,cnt)ans+=a[i]/2;
		ans*=k;
	}else{
		a[0]+=a[cnt-1];
		rep(i,0,cnt-1)ans+=a[i]/2;
		ans*=k;
		ans-=a[0]/2;
		a[0]-=a[cnt-1];
		ans+=a[0]/2+a[cnt-1]/2;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Security | diff Security.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Security.cpp && ./a.out

/*
 
 6/22/2019
 
 5:01-
 
 */

string S;

bool solve() {
  REP(i,3)if(S[i+1]==S[i]) return false;
  return true;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>S;
  cout<<(solve()?"Good":"Bad")<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[10000];

int main () {
int n;
int even=0;
int cnt = 0;
cin >> n;
for(int i  = 0;i<n;i++){
cin >> a[i];
}

while(true){
for(int i  = 0;i<n;i++){
if(a[i] % 2 != 0 || even != 0){
//a[i] *= 3;
}else{
a[i] /= 2;
even++;
}
}
if(even !=0){
cnt++;
even = 0;
continue;
}else if(even ==0){
cout << cnt << endl;
break;
}
}

return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define int long long 

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
  (1) 1 2 4 8 16 ...
*/

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

  vector<pii> pos(n);
  rep(i, n) cin >> pos[i].first >> pos[i].second;

  int par = (abs(pos[0].first) + abs(pos[0].second)) % 2;
  rep(i, n){
    int par2 = (abs(pos[i].first) + abs(pos[i].second)) % 2;
    pos[i] = mp(pos[i].first+pos[i].second, pos[i].first-pos[i].second);
    if(par != par2){
      cout << -1 << endl;
      return 0;
    }
  }

  vi d;
  for(int i = 30; i >= 0; i--) d.pb(1LL<<i);
  if(par%2 == 0) d.pb(1);
  cout << d.size() << endl;
  rep(i, d.size()) cout << d[i] << " ";
  cout << endl;

  rep(i, n){
    int xdir, ydir, xsum = 0, ysum = 0;
    rep(j, d.size()){
      if(xsum <= pos[i].first){
        xdir = 1;
        xsum += d[j];
      }else{
        xdir = -1;
        xsum -= d[j];
      }
      if(ysum <= pos[i].second){
        ydir = 1;
        ysum += d[j];
      }else{
        ydir = -1;
        ysum -= d[j];
      }

      if(xdir == 1 and ydir == 1) cout << "R";
      else if(xdir == 1 and ydir == -1) cout << "U";
      else if(xdir == -1 and ydir == -1) cout << "L";
      else cout << "D";

    }
    cout << endl;
  }

  return 0;
}


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

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

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

    int N, W;
    cin >> N >> W;

    vector<int> w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];

    vector<vector<ll> > dp(N + 1, vector<ll>(W + 1, 0));

    REP(i, N) REP(j, W + 1) {
        if (j - w[i] >= 0)
            chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
        chmax(dp[i + 1][j], dp[i][j]);
    }

    cout << dp[N][W] << '\n';
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 29);

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> c(m);
  for (int i = 0; i < m; i++)
  {
    cin >> c.at(i);
  }
  vector<vector<int>> dp(m + 1, vector<int>(n + 1, INF));
  dp.at(0).at(0) = 0;
  for (int i = 1; i < m + 1; i++)
  {
    for (int j = 0; j < n + 1; j++)
    {
      dp.at(i).at(j) = dp.at(i - 1).at(j);
      if (j - c.at(i - 1) >= 0)
      {
        dp.at(i).at(j) = min(dp.at(i).at(j), dp.at(i).at(j - c.at(i - 1)) + 1);
      }
    }
  }
  cout << dp.at(m).at(n) << endl;
}


Measured memory_bytes: 7128
from sys import setrecursionlimit
setrecursionlimit(10 ** 6)

N, M, *AB = map(int, open(0).read().split())

if M % 2 == 1:
    print(-1)
    quit()

E = [[] for _ in range(N + 1)]
for i, (a, b) in enumerate(zip(*[iter(AB)] * 2)):
    E[a].append((b, i))
    E[b].append((a, i))

used = [False] * M
visited = [False] * (N + 1)
ans = []
def dfs(cur, par):
    cnt = 0
    for nxt, c in E[cur]:
        if not visited[nxt]:
            visited[nxt] = True
            dfs(nxt, cur)
        if not used[c]:
            cnt += 1

    for nxt, c in E[cur]:
        if cnt % 2 == 1 and nxt == par:
            continue
        if not used[c]:
            used[c] = True
            ans.append((cur, nxt))

dfs(1, -1)
for c, d in ans:
    print(c, d)

Measured memory_bytes: 129880
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int N = sc.nextInt();
		int K = sc.nextInt();
		
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}
		int n = N - 1;
		int k = K - 1;
		int ans = 0;
		if (n % k != 0) {
			ans = (n / k) + 1;
		} else {
			ans = n / k;
		}
		System.out.println(ans);
	}
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
int n,k;
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  cin >> n >> k;
  ll left,right;
  ll res = 0;
  FOR(i,k,n+2){
    left = (ll)i*(i-1)/2;
    right = (ll)i*(n+n-i+1)/2;
    res+=(right-left+1);
    res %= MOD;
  }
  cout << res << endl;
  return 0;
}


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

#define debug(x) cout << #x << " = " << x << endl

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> P;


int main(){
   int n,m;
   int a[n];
   cin >> n;

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

   cin >> m;
   
   for(int i=0; i<m; i++){
	  int x,y;
	  cin >> x >> y;
	  int ans = 0;
	  for(int j=0; j<n; j++){
		 if(j+1 == x) ans += y;
		 else ans += a[j];
	  }
	  cout << ans << endl;
   }

   return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main() {

	int ninput;
	std::cin >> ninput;

	if (ninput < 1200) {
		std::cout << "ABC" << std::endl;
	}
	else if (ninput < 2800)
	{
		std::cout << "ARC" << std::endl;
	}
	else 
	{
		std::cout << "AGC" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
const double PI = acos(-1);
using namespace std;

int main() {

    zoom;    
    ll N; cin >> N;
    string s; cin >> s;
    map<unsigned char, ll> cnt;
    cnt['R'] = 0; cnt['G'] = 0; cnt['B'] = 0;
    for(ll i = 0; i < N; i += 1)
        cnt[s[i]] += 1;
    ll rem = 0;
    for(ll i = 1; i <= (N / 2) + 1; i += 1) {
        for(ll j = i; j <= N - 1 - i; j += 1) {
            if(j - i < 0)
                continue;
            if(j + i >= N)
                continue;
            set<unsigned char> x;
            x.insert(s[j - i]);
            x.insert(s[j]);
            x.insert(s[j + i]);
            if((ll)x.size() == 3LL)
                rem += 1;
        }
    }
    cout << (cnt['R'] * cnt['G'] * cnt['B']) - rem;
    return 0;
}

Measured memory_bytes: 3652
#include"stdio.h"
int n, q,count=0;
int S[10000];
int T[500];
int in() {
	int a;
	scanf("%d", &a);
	return a;
}
int main()
{
	n = in();
	for (int i = 0; i < n; i++)S[i] = in();
	q = in();
	for (int i = 0; i < q; i++)T[i] = in();
	for (int i = 0; i < q; i++) {
		for (int j = 0; j < n; j++) {
			if (T[i] == S[j]) {
				count++;
				break;
			}
		}
	}
	printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2744
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int s[105];
int main ()
{
	int a,b,x;
	scanf("%d%d%d",&a,&b,&x);
	int w = 0,e = 0;
	for (int i = 1; i <= b; i++)
	{
		scanf("%d",&s[i]);
		if (s[i] < x) w++;
		else e++;
	}
	printf("%d",min(w,e));
	return 0;
}


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

typedef pair<long long, long long> ii;


long long mod = 1000000007;
long long n, m, k;
int main(){
	//freopen("i.txt","r",stdin);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	
	long long ans = 0;
	int x, y;
	cin >> x >> y;
	if(x <= 3){
		ans += (4 - x);
	}
	if(y <= 3){
		ans += (4 - y);
	}
	if(x == 1 && y == 1) ans += 4;
	ans *= 100000;
	cout << ans;
	
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (m1 + 1 == m2) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
i = int(input())
l = [int(n) for n in input().split(' ')]

t = 0
bool = True
while bool:
    t += 1
    for j in range(len(l)):
        if l[j] % 2 == 1:
            bool = False
            break
        else:
            l[j] /= 2
print(t-1)


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 12 15:50:41 2019

@author: shinjisu
"""

#import numpy as np
#import math
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]

def zeros(n): return [0]*n
def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替

def getIntLines(n): return [int(input()) for i in range(n)]

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18


class Debug():
    def __init__(self):
        self.debug = True

    def off(self):
        self.debug = False

    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def digitSum(n):
    ds = 0
    while n > 0:
        ds += n % 10
        n //= 10
    return ds


def prob():
    d = Debug()
    d.off()
    N = getInt()
    minSum = INF
    for i in range(1, N//2+1):
        minSum = min(minSum, digitSum(i)+digitSum(N-i))
#        d.dmp(minSum)
    return minSum


ans = prob()
if ans is None:
    pass
else:
    print(ans)
#elif ans[0] == 'col':
#    for elm in ans[1]:
#        print(elm)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//struct area

//function area

//main area
int main(){
    string a, b;
    cin >> a >> b;
    bool check = true;
    if(a.size() == b.size()){
        rep(i,a.size()){
            if(a[i] == b[i]) continue;
            else{
                check = false;
                cout << (a[i] > b[i] ? "GREATER" : "LESS") << endl;
                break;
            }
        }
    }
    else{
        check = false;
        cout << (a.size() > b.size() ? "GREATER" : "LESS") << endl;
    }
    if(check) cout << "EQUAL" << endl;
}
/*

1 size比較
2 同じなら、位の大きい桁から比較
3 全て同じならEQUAL Aが大きいならGREATER

*/

Measured memory_bytes: 3636
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    A, B, C, K = iim()

    if K <= A:
        ans = K
    elif K <= A+B:
        ans = A
    else:
        ans = A - (K-A-B)
    print(ans)

if __name__ == "__main__":
    resolve()


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

int main() {
  string str;
  cin >> str;
  if (str.at(0) == '9') {
    cout << "Yes" << endl;
  } else if (str.at(1) == '9') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;
 
public class Program{
    public static void Main(){
        var A=Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
        var b=new int[]{A[0]+A[1],A[0]-A[1],A[0]*A[1]};
        Console.WriteLine(b.Max());
    }
}

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

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);
	std::vector<std::pair<int, int>> ab(N);
	for (auto& e: ab) scanf("%d%d", &e.first, &e.second);
	ab.push_back({1 << 30, -1});
	std::sort(ab.begin(), ab.end());
	int m_i{};
	int64_t ans{};
	std::priority_queue<int> pq;
	for (int i{M - 1}; i >= 0; i--)
	{
		int diff{M - i};
		while (diff == ab[m_i].first)
		{
			pq.push(ab[m_i].second);
			m_i++;
		}
		if (pq.empty()) continue;
		ans += pq.top();
		pq.pop();
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1904
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;


int main(){
    int n,a,b,c,d;
    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
    
    int ans = n / a * b;
    if(n % a != 0){
        ans += b;
    }
    
    if(n % c == 0){
        ans = min(ans,n / c * d);
    }else{
        ans = min(ans,n / c * d + d);
    }

    printf("%d\n",ans);

    return 0;
    
}


Measured memory_bytes: 2716
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

const ll mod = 998244353;

ll mod_pow(ll n, ll k) {
    ll ret = 1;
    ll cur = n;
    while(k) {
        if(k & 1) (ret *= cur) %= mod;
        cur = cur * cur % mod;
        k /= 2;
    }
    return ret;
}

ll mod_inv(ll n) { return mod_pow(n, mod - 2); }

const size_t SIZE = 1e6 + 10;
ll cnt_arr[SIZE];
ll sum_arr[SIZE];

int main() {
    ll N;
    cin >> N;
    while(N--) {
        ll a;
        cin >> a;
        cnt_arr[a]++;
    }

    ll ans = 0;
    ll inv2 = mod_inv(2);
    for(ll g = 1e6; 1 <= g; g--) {
        ll sum = 0;
        ll past_sum = 0;
        ll pow2_sum = 0;
        for(ll m = 1; g * m < SIZE; m++) {
            ll tmp = g * m;
            sum += cnt_arr[tmp] * tmp % mod;
            past_sum += sum_arr[tmp];
            pow2_sum += cnt_arr[tmp] * (tmp * tmp % mod) % mod;
        }
        sum %= mod;
        sum = sum * sum % mod;
        sum = sum + (mod - pow2_sum % mod) % mod;
        sum = sum * inv2 % mod;
        sum = sum + (mod - past_sum % mod) % mod;
        ans += sum * mod_inv(g) % mod;
        sum_arr[g] = sum;
    }

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


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

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

Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
    
    // resize buffer
    buf := make([]byte, 1000)
    sc.Buffer(buf, 200000000000) //頭悪い

    // input
    N := inputLineAsNumArray(1)[0]
    nums, max := inputLineAsNumArrayWithMax(N)
    
    // combination
    med := int(max / 2)

    diff_idx := 0
    diff := max
    for i := 0; i < N; i++ {
        if nums[i] == max {
            continue
        }
        if int(math.Abs(float64(med - nums[i]))) < diff {
            diff_idx = i
            diff = int(math.Abs(float64(med - nums[i])))
        } 
    }
    fmt.Println(max, nums[diff_idx])
}

func inputLineAsNumArray(length int) []int {

    line := strings.Split(readLine(), " ")
    var nums []int
    for i := 0; i < length; i++ {
        num, _ := strconv.Atoi(line[i])
        nums = append(nums, num)
    }
    return nums
}

func inputLineAsNumArrayWithMax(length int) ([]int, int) {

    line := strings.Split(readLine(), " ")
    var nums []int
    max := 0
    for i := 0; i < length; i++ {
        num, _ := strconv.Atoi(line[i])
        nums = append(nums, num)
        if max < num {
            max = num
        }
    }
    return nums, max
}

func readLine() string {

	sc.Scan()
	return sc.Text()
}

Measured memory_bytes: 8192
n = int(input())
a = [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
if a[n] == 0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	n := len(s)
	ans := 0
	for i := 0; i < n/2; i++ {
		if s[i] != s[len(s)-i-1] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll n; string  s, t;
    cin >> n >> s >> t;
    ll c = 0;
    for(ll i = 1; i <= n; i++){
        ll f = 0;
        for(ll j = 0; j < i; j++){
            if(t[j] != s[n-i+j]) f = 1;
        }
        if(!f) c = i;
    }
    cout << 2*n-c;
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
a = int(input())
time = 0
ch_1 = 2
ch_2 = 2
ch_4 = 2
while True:
    time += 1
    if a == 1:
        ch_1 -= 1
        if ch_1 == 0:
            break
    if a == 2:
        ch_2 -= 1
        if ch_2 == 0:
            break
    if a == 4:
        ch_4 -= 1
        if ch_4 == 0:
            break
    if a % 2 == 0:
        a = a / 2
    else:
        a = a * 3 + 1

print(int(time))


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    deque<int> dq;
    int flag = 0;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        if (flag == 0) {
            dq.push_back(t);
        } else {
            dq.push_front(t);
        }
        flag = 1 - flag;
    }
    if (flag == 0) {
        while (dq.size() > 0) {
            cout << dq.front() << " ";
            dq.pop_front();
        }
    } else {
        while (dq.size() > 0) {
            cout << dq.back() << " ";
            dq.pop_back();
        }
    }
    cout << endl;
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}

	int res = 0;
	int st = 0;
	int en = N - 1;
	int iv = 1;
	while (true) {
		int bres = res;
		swap(st, en);
		iv = -iv;
		for (int y = st;; y += iv) {
			//cerr << y << endl;
			int x = y - 1;
			if (x == -1)x = N - 1;
			int z = y + 1;
			if (z == N)z = 0;
			int sum = B[x] + B[z];
			if (B[y] - sum >= A[y]) {
				int t = (B[y] - A[y]) / sum;
				B[y] -= sum * t;
				res += t;
				//cerr << y << " " << t << endl;
			}
			if (y == en)break;
		}
		if (res == bres)break;

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

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

typedef long long ll;
 
int main(){
  ll n, t;
  cin >> n >> t;
  ll a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  ll ans = t;
  for(int i=1; i<n; i++){
    ans += min(t, a[i]-a[i-1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
// #define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007LL
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
    if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int MAXN = 2e5+5;

// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
const double eps=1e-8;
int dblcmp(double d){if (fabs(d)<eps)return 0;return d>eps?1:-1;}
ll euclid(ll x,ll y,ll a,ll b)
{
  return (a-x)*(a-x)+(b-y)*(b-y);
}
// Constants //
void solve()
{
  ll n,a,i;
  cin>>n;
  vector<ll> ans(n+1);
  for(i=2;i<=n;i++)
  {
    cin>>a;
    ans[a]++;
  }
  for(i=1;i<=n;i++)
    cout<<ans[i]<<endl;
}
int main()
{ 
  // ios;
  // freopen("inputt.txt", "w", stdout);
  ll t,i;
  t=1;

  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 4828
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 100020
using namespace std;

int a[N];

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

    scanf("%d", &n);
    for(i = 1; i <= n; i ++)
    {
        scanf("%d", &x);
        a[x] = i;
    }
    for(i = 1; i <= n; i ++)
        printf("%d ", a[i]);
    printf("\n");

    return 0;
}


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

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val x = sc.nextInt()
    val l = Array(n) { sc.nextInt() }
    var sum = 0
    var count = 1
    for (i in 0 until n) {
        sum += l[i]
        if (sum <= x) {
            count++
        } else {
            break
        }
    }
    println(count)
}

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

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

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

        return st.nextToken()
    }

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

Measured memory_bytes: 31280
import java.util.*;

class Main {
    // ABC152D
    static final long MOD = 1_000_000_007;
    // 10^9+7
    static final int MAX = 2_147_483_646;
    // intの最大値
    static final int INF = 1_000_000_000;

    // 10^9
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] enemy = new int[n];
        for(int i = 0;i < n;i++){
            enemy[i] = sc.nextInt();
        }
        Arrays.sort(enemy);
        long ans = 0;
        for(int i = n-1;i >= 0;i--){
            if(k > 0){
                k--;
                continue;
            }
            ans += enemy[i];
        }
        System.out.println(ans);
    }
   
}


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

int isPrime(int x){
  int i;
  if(x == 2) return 1;
  else if(x < 2 || x%2 ==0) return 0;
  i = 3;
  while(i <= sqrt(x)){
    if(x % i == 0) return 0;
    i = i +2;
  }
  return 1;
}

int main(void){

  int n,x,i,count=0;

  scanf("%d",&n);
  for(i=0; i < n; i++){
    scanf("%d",&x);
    if(isPrime(x)== 1)count++;
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    rep(i, 0, N) cin >> X[i];
    ll ans = 0;
    rep(i, 0, N-1) ans += min(B, A*(X[i+1]-X[i]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int n,purna,nadu,priya;
    scanf("%d",&nadu);
    n=nadu;
    priya=0;
    while(n!=0){
        purna=n%10;
        n=n/10;
        priya=priya+purna;}
        if(nadu%priya==0){
            printf("Yes\n");}
        else{
            printf("No\n");
        }

    return 0;
}


Measured memory_bytes: 128
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
 
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,m;
	cin>>n>>m;
	int N=n*m;
	vvi dp(N,vi(N,inf));
	vs in(n);
	rep(i,n)cin>>in[i];
	rep(i,N)dp[i][i]=0;
	rep(i,N)rep(j,N)if(i-j){
		int x1=i/m,y1=i%m,x2=j/m,y2=j%m;
		if(abs(x1-x2)+abs(y1-y2)-1)continue;
		if(in[x1][y1]==in[x2][y2]&&in[x1][y1]=='.')dp[i][j]=dp[j][i]=1;
	}
	
	rep(k,N)rep(i,N)rep(j,N)
		cmin(dp[i][j],dp[i][k]+dp[k][j]);
	int out=0;
	rep(i,N)rep(j,N)if(dp[i][j]-inf)cmax(out,dp[i][j]);
	cout<<out<<endl;
}









Measured memory_bytes: 1536
#include<stdio.h>
int a[200001];
int main(void)
{
    int n, i, x, l, r, k = 1;
    l = r = 100000;
    scanf("%d", &n);
    if(n % 2)k = 0;
    scanf("%d", &a[100000]);
    for (i = 1; i < n; i++)
    {
        if(k % 2)
        {
            scanf("%d", &a[--l]);
            k = 0;
        }
        else
        {
            scanf("%d", &a[++r]);
            k = 1;
        }
    }
    for ( i = l; i <= r; i++)
        printf(i == l ? "%d" : " %d", a[i]);
    return 0;
}


Measured memory_bytes: 2816
import java.util.Scanner;

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

		Scanner scan=new Scanner(System.in);

		int n=scan.nextInt();
		int x=scan.nextInt();

		int w=x;
		int s=0;

		int m[]=new int[n];

		for(int i=0;i<n;i++) {
			m[i]=scan.nextInt();
			w-=m[i];
			if(i==0||s>m[i]) {
				s=m[i];
			}
		}

		System.out.println(n+(int)(Math.floor(w/s)));
	}
}


Measured memory_bytes: 21844