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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16

ll mod_pow(ll a,ll n,ll mod){
  ll res=1;
  while(n>0){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll p;
vector<ll> a,b,c;
ll dp[3001][3001];

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

  cin>>p;
  a.resize(p);
  b.resize(p,0);
  c.resize(p);
  rep(i,p)cin>>a[i];

  rep(X,p){
    ll S=0;
    ll crt=1;
    rep(j,X){
      S+=c[j]*crt%p;
      S%=p;
      crt*=(X-j+p)%p;
      crt%=p;
    }
    c[X]=((a[X]-S+p)%p)*mod_pow(crt,p-2,p)%p;
  }

  dp[0][0]=1;
  rep(i,p){
    rep(j,i+1){
      b[j]+=c[i]*dp[i][j]%p;
      b[j]%=p;
    }
    if(i==p-1)continue;
    rep(j,i+1){
      (dp[i+1][j]+=dp[i][j]*(p-i)%p)%=p;
      (dp[i+1][j+1]+=dp[i][j])%=p;
    }
  }

  rep(i,p)cout<<b[i]<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 69120
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	int n;
	int[] num;
	public void run(){
		n = sc.nextInt();
		num = new int[10];
		for(int i = 0; i< n; i++){
			for(int k = 0; k < 10; k++){
				num[k] = sc.nextInt();
			}
			solve();
		}
	}
	public void solve(){
		if(dfs(0,0,0)) System.out.println("YES");
		else System.out.println("NO");
	}
	
	boolean dfs(int l, int r, int k){
		if(k == 10) return true;
		
		int now = num[k];
		boolean left = false;
		boolean right = false;
		if(now > l) left = dfs(now, r, k+1);
		if(now > r) right = dfs(l, now, k+1);
		
		return left || right;
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
	static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }	
}

Measured memory_bytes: 26220
dp=[.0]*100001
dp[1]=1.
for i in range(2,100001):
    a,b,j=.5,1,1
    while j<i and b>1e-15:
        dp[i]+=b*(1-a)*(j+dp[i-j-1])
        b*=a;a/=2;j+=1
    dp[i]+=i*b
while 1:
    n=int(input())
    if n==0:break
    print(dp[n])

Measured memory_bytes: 10580
import itertools

N = int(input())
L = list(map(int, input().split()))

def valid(a, b, c):
    x = max(a, b, c)
    return x < a+b+c-x and len({a, b, c}) == 3

ways = 0
for i, j, k in itertools.combinations(range(N), 3):
    if valid(L[i], L[j], L[k]):
        ways += 1

print(ways)


Measured memory_bytes: 74356
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


struct P{
	double x,y;
	P(double x,double y) : x(x) , y(y) {}
	P(){}
};
bool operator <(const P &a,const P &b){ return a.x != b.x ? a.x < b.x : a.y < b.y; }

const double EPS = 1e-9;
const double PI = acos(-1);

double fix(double p){
	while( p < EPS ) p += PI;
	return p;
}


vector<P> convex_hull( vector<P> g){
	sort(g.begin(),g.end());
	vector<P> r;
	int idx = 0;
	double deg = -PI/2;
	do{
		r.push_back(g[idx]);
		int best = 0;
		double value = 1e10;
		
		for(int i = 0 ; i < g.size() ; i++){
			if( i != idx){
				double next = fix( atan2(g[i].y-g[idx].y,g[i].x-g[idx].x) - deg );
				if( value > next ){
					value = next;
					best = i;
				}	
			}
		}
		
		deg = atan2(g[best].y-g[idx].y,g[best].x-g[idx].x);
		idx = best;
	}while(idx != 0);

	return r;
}



int main(){
	int n;
	while(cin >> n && n){
		vector<P> g(n);
		for(int i = 0 ; i < n ; i++) scanf("%lf,%lf",&g[i].x,&g[i].y);
		cout << n - convex_hull(g).size() << endl;
	}
}

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

typedef long long ll;

ll e, m, x, min_;

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

    while (cin >> e, e) {
        min_ = m = (int)(1e9 + 7);

        for (int y = 0; y <= sqrt((double)e); y++) {
            for (int z = 0; z <= sqrt((double)e); z++) {
                x = e - y * y - z * z * z;
                if (x < 0) break;
                else {
                    m = x + y + z;
                    //cout << "x, m = " << x << " " << m << endl;
                    if (min_ > m) min_ = m;
                }
            }
        }

        cout << min_ << endl;
    }

    return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
string s;
map<string,int>f;
map<string,int>g;
int F(string s);
int G(string s)
{
    if(g.find(s)!=g.end())
    return g[s];
    if(s.size()==1)
    return g[s]=s[0]-'0'+1;
    for(int i=1;i<s.size();++i)
    {
        if(s.size()%i==0)
        {
            string t;
            for(int j=0;j<i;++j)
            {
                int r=1;
                for(int k=0;k<s.size()/i;++k)
                if(s[i*k+j]=='0')
                r=0;
                t+=(char)(r+'0');
            }
            g[s]=(g[s]+F(t))%mod;
        }
    }
    return g[s];
}
int F(string s)
{
    if(f.find(s)!=f.end())
    return f[s];
    for(int i=1;i<=s.size();++i)
    f[s]=(f[s]+1ll*F(s.substr(0,s.size()-i))*G(s.substr(s.size()-i,i))%mod)%mod;
    return f[s];
}
int main()
{
    cin>>s;
    f[""]=1;
    cout<<F(s)<<endl;
    return 0;
}

Measured memory_bytes: 12928
import sys
n,m = map(int,input().split())
l = [-1 for _ in range(n)]
for i in range(m):
  s,c = map(int,input().split())
  if(n > 1 and s == 1 and c == 0):
    print(-1)
    sys.exit()
  elif(l[s-1] != -1 and l[s-1] != c):
    print(-1)
    sys.exit()
  else:
    l[s-1] = c
for k in range(n):
  if(l[k] == -1):
    l[k] = 0
if(n > 1 and l[0] == 0):
  l[0] = 1
l=[str(a) for a in l]
l="".join(l)
print(l)
    

Measured memory_bytes: 3064
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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::collections::HashSet;
fn main() {
    input! {
        s: i64,
    }
    let mut s = s;
    let mut m = HashSet::new();
    let mut res = 1;
    loop {
        if m.contains(&s) {
            break;
        }
        m.insert(s);
        s = if s % 2 == 0 { s / 2 } else { 3 * s + 1 };
        res += 1;
    }
    println!("{}", res);
}


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

int main() {
	int n;
	cin >> n;
	int dp[n][3];
	int a[n],b[n],c[n];
	for(int i = 0;i < n;i++)
	cin >> a[i] >> b[i] >> c[i];
	dp[0][0] = a[0],dp[0][1] = b[0],dp[0][2] = c[0];
	for(int i = 1;i < n;i++)
	{
		dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
		dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
		dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
	}
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << "\n";
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int N, M; cin >> N >> M;
    vector<int> H(N);
    rep(i,N) cin >> H[i];
    vector<bool> ans(N, true);
    rep(i,M) {
        int a, b; cin >> a >> b;
        --a; --b;
        if(H[a] <= H[b]) ans[a] = false;
        if(H[b] <= H[a]) ans[b] = false;
    }
    int cnt = 0;
    rep(i,N) if(ans[i]) cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
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(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}
template<class T>istream&operator>(istream&i,T&t){return i>>t;}
#ifndef LOCAL
struct ostdmy{
template<class T>ostdmy&operator<<(const T&t){return*this;}
template<class T>ostdmy&operator<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif

class UnionFind{
private:
    vi data;
public:
	UnionFind(int size):data(size,-1){}
	bool unite(int x,int y){
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x])swap(x,y);
			data[x]+=data[y];data[y]=x;
		}
		return x!=y;
	}
	bool find(int x,int y){
		return root(x)==root(y);
	}
    inline bool isroot(int x){return data[x]<0;}
	int root(int x){
		return data[x]<0?x:data[x]=root(data[x]);
	}
	int size(int x){
		return -data[root(x)];
	}
};

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n,m;
    cin>n>m;
    UnionFind uf(n);
    REP(i,m){
        int x,y,z;
        cin>x>y>z;
        uf.unite(x-1,y-1);
    }
    int c=0;
    REP(i,n){
        if(uf.isroot(i))++c;
    }
    cout<c<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a!=c)cout<<1<<endl;
	else cout<<0<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int A[50],n;

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

}
int main(){
  int i,j;
  int q;
  int m;

  scanf("%d",&n);
  if(n<0 || n>20)return 0;

  for(i = 0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]<1||A[i]>2000)return 0;
  }

  scanf("%d",&q);
  if(q<0 || q>200)return 0;

  for(i = 0;i<q ;i++){
    scanf("%d",&m);
    if(solve(0,m) == 1)printf("yes\n");
    else printf("no\n" );
  }

  return 0;
}



Measured memory_bytes: 2108
public class Main {
	public static void main(String[] args){
		String in = new java.util.Scanner(System.in).nextLine();
		String[] nums = in.split(" ");
		int a = Integer.parseInt(nums[0]);
		int b = Integer.parseInt(nums[1]);
		int c = Integer.parseInt(nums[2]);
		if(a <= c && c <= b){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    vector< pair<int, int> > tile;
    for (int i = 0; i < n * n; i++) {
      int x, y;
      cin >> x >> y;
      tile.push_back(pair<int, int>(y, x));
    }

    int count = 0;
    vector < vector<int> > root;
    for (int i = 0; i < n * n; i++) {
      vector<int> hoge;
      int j = i;
      while (true) {
        hoge.push_back(j);
        //cout << j << '(' << tile[j].first << ',' << tile[j].second << ')' << endl;                                                                                      
        j = tile[j].first * n + tile[j].second;
        bool found = false;
        for (int k = 0; k < root.size(); k++) {
        vector<int> piyo = root[k];
        if (find(piyo.begin(), piyo.end(), j) != piyo.end())
          found = true;
        }
        if (found == true) {
          //cout << "found root : " << j << endl;                                                                                                                         
          break;
        }
        if (find(hoge.begin(), hoge.end(), j) != hoge.end()) {
          //cout << "wryyyyyyyy : " << j << endl;                                                                                                                         
          root.push_back(hoge);
          count++;
        break;
        }
      }
    }

    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define MOD 1000000007
#define INF 1000000000000000007LL

const int N = 100005;
 
// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    string s[3];
    For(i, 0, 3){
        cin>>s[i];
        reverse(all(s[i]));
    }
    int cur = 0;
    while(true){
        char player = 'a'+cur;
        if(sz(s[cur])==0){
            char c = 'A'+cur;
            cout<<c;
            return 0;
        }
        int temp = (s[cur].back())-'a';
        s[cur].pop_back();
        cur = temp;
    }
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map <int,int> Map;
int main(){
    int n,a,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        if(Map[a]==0)Map[a]=1,ans++;
        else Map[a]=0,ans--;
    }
    cout<<ans<<endl;
    return 0;
 } 

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e2 + 10;
int a[MAXN], b[MAXN];
int n, mx = 0;
template <class T>
inline void _read(T &x)
{
    x = 0;
    char t = getchar();
    while (!isdigit(t) && t != '-') t = getchar(); 
    if (t == '-')
    {
        _read(x);
        x *= -1;
        return ;
    }
    while (isdigit(t))
    {
        x = x * 10 + t - '0';
        t = getchar();
    }
}
int main()
{
    _read(n);
    for (int i = 1; i <= n; ++i) _read(a[i]), mx = max(mx, a[i]), ++b[a[i]];
    if(mx & 1)
    {
        for(int i = mx; i >= (mx + 1) / 2; --i)
            if(b[i] < 2)
            {
                puts("Impossible");
                return 0;
            }
        for(int i = 1; i < (mx + 1) / 2; ++i)
            if(b[i])
            {
                puts("Impossible");
                return 0;
            }
        if(b[(mx + 1) / 2] > 2)
        {
            puts("Impossible");
            return 0;
        }
    }
    else
    {
        for(int i = mx; i > mx / 2; --i)
            if(b[i] < 2)
            {
                puts("Impossible");
                return 0;
            }
        for(int i = 1; i < mx / 2; ++i)
            if(b[i])
            {
                puts("Impossible");
                return 0;
            }
        if(b[mx / 2] != 1)
        {
            puts("Impossible");
            return 0;
        }
    }
    puts("Possible");
    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;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(d.begin(), d.end());
  int mid = n/2;
  int ans;
  ans = d[mid] - d[mid-1];
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;


	void doIt() {
		char[] s = sc.next().toCharArray();
		for(int i = 1; i < 4; i++) {
			if(s[i - 1] == s[i]) {
				System.out.println("Bad");
				return;
			}
			
		}
		System.out.println("Good");
		
	}

	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    for (int i = 1; i < N; i++)
    {
        cin >> A[i];
        B[A[i]]++;
    }
    for (int i = 1; i < N;i++)
    {
        cout << B[i] << endl;
    }
    cout << A[0] << endl;
}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define inf         1e9+8
#define mp          make_pair
#define rep(i,n)    for(int i=0;i<n;i++)
#define repo(i,m,n) for(int i=m;i<=n;i++)
#define ll          long long
#define pii         pair<int,int >
#define sc(n)       scanf("%d",&n)
#define sc2(m,n)    scanf("%d%d",&m,&n);
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define mem(x,i)    memset(x,i,sizeof x)
#define PI          acos(-1.0)
#define ff          first
#define ss          second
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/
using namespace __gnu_pbds;
using namespace std;
template <typename T>  using orderedSet =
    tree<T, null_type, less<T>,
    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key


const int mod=1e9+7;
ll arr[2000005];
ll bigmod(ll a,ll p,ll m)
{
    ll res=1;
    ll x=a%m;
    while(p)
    {
        if(p&1)
            res=(res*x)%m;
        x=(x*x)%m;
        p>>=1;
    }
    return res;
}
int main()
{
    arr[0]=1;
    for(int i=1; i<=2000000; i++)
        arr[i]=(i*arr[i-1])%mod;
    ll x,y;
    cin>>x>>y;
    for(int i=x+x%2; i<=10000000; i+=2)
    {
        if(i-x==y-i/2)
        {
            ll div=abs(i-x);
            ll n=i/2;
            //cout<<i<<' '<<n<<' '<<div<<endl;
            if(div>n) break;

            div=(arr[div]%mod*arr[n-div]%mod)%mod;
            ll ans=bigmod(div,mod-2,mod);
            ans=(ans%mod*arr[n]%mod)%mod;
            cout<<ans<<endl;
            return 0;
        }

    }
        cout<<0<<endl;


}



Measured memory_bytes: 15872
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#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 PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 19;

int T[maxN];
char S[maxN];
int res[maxN];

int f(int n, int m)
{
	if (m == 1)
		return 0;
	int ret = 0, p = 1;
	FORD(i, n-1, -1)
	{
		int b = S[i] - '0';
		ret = (ret + p * b) % m;
		p = p * 2 % m;
	}
	return ret;
}

void solve()
{
	FOR(i, 1, maxN)
		T[i] = T[i % PPC(i)] + 1;
	int n;
	scanf ("%d %s", &n, S);
	int b = count(S, S+n, '1');
	
	int r1 = b < 2 ? -1 : f(n, b-1);
	int r2 = f(n, b+1);
	int p1 = 1, p2 = 1;
	
	FORD(i, n-1, -1)
	{
		if (S[i] == '0')
		{
			res[i] = (r2 + p2) % (b+1);
			res[i] = T[res[i]] + 1;
		}
		
		else
		{
			if (b == 1)
			{
				res[i] = 0;
				continue;
			}
			
			res[i] = (r1 - p1 + (b-1)) % (b-1);
			res[i] = T[res[i]] + 1;
		}
		
		p1 = b == 1 ? 0 : p1 * 2 % (b-1);
		p2 = p2 * 2 % (b+1);
	}
	
	FOR(i, 0, n)
		printf("%d\n", res[i]);
}

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


Measured memory_bytes: 6816
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))


typedef long long lint;

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

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


inline std::vector<lint> enum_div(lint n)//nの約数を列挙
{
	std::vector<lint> ret;

	for (lint i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i*i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}

lint digit(lint n) {
	lint ret = (bool)n;
	while (n / 10) {
		ret++;
		n /= 10;
	}
	return ret;
}

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

	lint n; cin >> n;
	vector<lint> a = enum_div(n);
	a.push_back(n);
	vsort(a);
	lint mn = INT_MAX;
	lint l = a.size();
	mn = max(digit(a[(l + 1)/ 2 - 1]), digit(a[l - (l + 1) / 2]));
	co(mn);
	gc();
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long int s;
	while(cin>>s){
		int h=0;
		while(s>=3600){
			h=s/3600;
			s=s-h*3600;
		}
		int m=0;
		while(s>=60){
			m=s/60;
			s=s-m*60;
		}
		cout<<h<<':'<<m<<':'<<s<<endl;
	}
	return 0;
}


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

int main(){
    int n; 
    cin >> n;
    vector<int> t(n);
    int min = 1000000000, max= -1000000000;

    for (int i=0; i<n; i++){
        cin >> t.at(i);
        if (i==0){
            min = t.at(i);
            continue;
        }
        if (max < t.at(i) - min) max = t.at(i) - min;
        if (min > t.at(i)) min = t.at(i);
    } 
    cout << max << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int, int> P;
double dist(int x,int y){
  return sqrt(x*x + y*y);
}
int main(){
  int N, M;
  ll R;
  while(cin>>N>>M>>R && N){
    R *= 4;
    vector<int> combat[10000];
    REP(i, N){
      int x, y; scanf("%d %d", &x, &y);
      combat[x].push_back(y);
    }
    REP(i, 10000)sort(combat[i].begin(), combat[i].end());
    int ans = 0;
    REP(i, M){
      int x, y; scanf("%d %d", &x, &y);
      for(int xx = max(x-R, 0LL); xx <= min(x + R, 9999LL); xx++){
        int dx = xx - x;
        vector<int>::iterator b = lower_bound(combat[xx].begin(), combat[xx].end(), y - sqrt(R*R - dx*dx) - 1);
        vector<int>::iterator e = upper_bound(combat[xx].begin(), combat[xx].end(), y + sqrt(R*R - dx*dx)  + 1);
        while(b != e){
          int yy = *b;
          if(dist(x-xx, y-yy) < (double)R + EPS) ans++;
          b++;
        }
      }
    }
    cout<< ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1580
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    dump(a.size());

    var(size_t, K);
    output(a[K - 1]);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int h = scan.nextInt();
		int w = scan.nextInt();
		String[] c = new String[h];
		for(int i =0;i<h;i++) {
			c[i]=scan.next();
		}
		String[] c2 = new String[h*2];
		for (int i=0,m=0;i<h*2;i=i+2,m++) {
			c2[i]=c[m];
			c2[i+1]=c[m];
		}
		for(int i =0;i<h*2;i++) {
			System.out.println(c2[i]);
		}
	}

}


Measured memory_bytes: 22224
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll n;
    cin >> n;
    ll r = n % 1000;
    if (r == 0)
    {
        cout << 0 << endl;
    }
    else
    {
        ll c = 1000 - r;
        cout << c << endl;
    }
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>	
#define ll long long
#define inf 0x3f3f3f3f 
using namespace std;
const int maxn = 1e5+10;
int main()
{
	int k;
	scanf("%d", &k);
	ll n = 7;
	int ans = 1;
	if(k%2==0 || k%5==0)
	{
		printf("-1");
		return 0;
	}
	while(1)
	{
		if(n % k==0)
		{
			printf("%d", ans);
			break;
		}
		ans ++;
		n = n*10+7;
		n%=k;
	}

	return 0;
}


Measured memory_bytes: 3824
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Two Currencies
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;
const int MAX_M = 100;
const int MAX_A = 50;
const int MAX_S = MAX_N * MAX_A;
const unsigned long long LINF = ~0ULL;

/* typedef */

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

struct Stat {
  ull d;
  int i, s;
  Stat() {}
  Stat(ull _d, int _i, int _s): d(_d), i(_i), s(_s) {}
  bool operator<(const Stat &s) const { return d > s.d; }
};

/* global variables */

vpii nbrs[MAX_N];
int as[MAX_M], bs[MAX_M], cs[MAX_N], ds[MAX_N];
ull dists[MAX_N][MAX_S + 1];

/* subroutines */

/* main */

int main() {
  int n, m, s;
  scanf("%d%d%d", &n, &m, &s);

  int maxa = 0;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d%d%d", &u, &v, as + i, bs + i);
    u--, v--;
    nbrs[u].push_back(pii(v, i));
    nbrs[v].push_back(pii(u, i));
    if (maxa < as[i]) maxa = as[i];
  }
  int maxs = maxa * n;
  s = min(s, maxs);

  for (int i = 0; i < n; i++) scanf("%d%d", cs + i, ds + i);

  for (int i = 0; i < n; i++) fill(dists[i], dists[i] + maxs + 1, LINF);

  dists[0][s] = 0;
  priority_queue<Stat> q;
  q.push(Stat(0, 0, s));

  while (! q.empty()) {
    Stat u = q.top(); q.pop();
    int ci = cs[u.i], di = ds[u.i];
    vpii &nbru = nbrs[u.i];

    for (vpii::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int vi = vit->first, ae = as[vit->second], be = bs[vit->second];
      ull vd = u.d + be;
      for (int vs = u.s - ae;; vs += ci, vd += di) {
	if (vs > maxs) vs = maxs;
	if (vs >= 0 && dists[vi][vs] > vd) {
	  dists[vi][vs] = vd;
	  q.push(Stat(vd, vi, vs));
	}
	if (vs >= maxs) break;
      }
    }
  }

  for (int i = 1; i < n; i++) {
    ull mind = LINF;
    for (int j = 0; j <= maxs; j++)
      if (mind > dists[i][j]) mind = dists[i][j];
    printf("%llu\n", mind);
  }
  return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
lli n;
vector<lli> a;

int main(void){
    cin >> n;
    for(lli i = 1; i <= n; i++){
        if(i%3 == 0 || i%5 == 0) a.push_back(0);
        else a.push_back(i);
    }
    lli sum = 0;
    rep(i, n){
        sum += a.at(i);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 11580
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cmath>
#include <deque>
#include <bitset>
#define ll long long
#define PI 3.1415926535897932384626433832795
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define readN(N,X) for(int i=0;i<N;i++) cin>>X[i];
#define pff pair<double,double>
#define MOD 1000000007

using namespace std;
int N;
int c[200005];
int warp[200005];
int last[200005];
int dp[200005];

int main(){
   std::ios::sync_with_stdio(false); 
   cin>>N;
   for (int i=0;i<N;i++) 
   cin>>c[i];   

   memset(last, -1, sizeof(last));

   for (int i=0;i<N;i++) {
   	warp[i] = last[c[i]];
   	last[c[i]] = i;
   }


   dp[0] = 1;
   for (int i=1;i<N;i++) {
   	int jump = 0;
   	if (warp[i] != i-1 && warp[i] != -1) jump = dp[warp[i]];
   	dp[i] = (dp[i-1] + jump) % MOD;
   }
   cout<<dp[N-1]<<endl;
}




Measured memory_bytes: 3328
#include <stdio.h>
#include <math.h>
int main()
{
  int n, i ;
  double ave, s[1005], sum, d, e ;

  while( scanf("%d", &n) && n != 0 ){
    sum = d = 0 ;
    for( i = 0 ; i < n ; i++ ){
      scanf("%lf", &s[i]) ;
      sum += s[i] ;
    }
    ave = sum / n ;
    for( i = 0 ; i < n ; i++ ){
      d += ( s[i] - ave )*( s[i] - ave ) ;
    }
    e = d / n ;
    printf("%10.8f\n", sqrt(e)) ;
  }

  return 0 ;
}


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

int cnt;

void merge(int *A, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	int *L = new int[n1 + 1];
	int *R = new int[n2 + 1];
	int i, j, k;
	for (i = 0; i < n1; i++)
		L[i] = A[left + i];
	L[n1] = INT_MAX;
	for (i = 0; i < n2; i++) 
		R[i] = A[mid + i];
	R[n2] = INT_MAX;
	i = 0; j = 0;
	for (k = left; k < right; k++) 
	{
		if (L[i] <= R[j])
		{
			A[k] = L[i];
			i++;
		}
		else
		{
			A[k] = R[j];
			j++;
		}
		cnt++;
	}
}

void mergeSort(int *A, int left, int right) 
{
	if (left + 1 < right)
	{
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main(void) {
	int n, *A, i;
	cnt = 0;
	cin >> n;
	A = new int[n];
	for (i = 0; i < n; i++) {
		cin >> A[i];
	}
	mergeSort(A, 0, n);
	for (i = 0; i < n; i++) {
		if (i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << cnt << endl;
}


Measured memory_bytes: 65748
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
//	cut here before submit 
//	freopen ("testcase.dat", "r", stdin );
	string str = "";
	while (getline (cin, str ) ){
		stringstream ss (str );
		double v;
		ss >> v;
		double t = v/9.8;
		double y = 4.9*t*t;
		int N = ceil ((y + 5.) / 5. );
		cout << N << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1248
import java.io.*;

public class Main{
  public static void main(String[] args) {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    try{
      String line = reader.readLine();
      int x = Integer.parseInt(line);
      System.out.println(x*x*x);
    }catch(IOException e){
      System.out.println(e);
    }catch(NumberFormatException e){
      System.out.println(e);
    }
  }
}


Measured memory_bytes: 24172
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX_N = 100000;
const int INF = (1 << 30);

class Edge {
public:
    int t, w;
    Edge() {}
    Edge(int t, int w): t(t), w(w) {}
};

vector<Edge> G[MAX_N];
int n, d[MAX_N];

void bfs(int s) {
    for (int i = 0; i < n; i++) d[i] = INF;
    queue<int> Q;
    Q.push(s);
    d[s] = 0;

    int u;
    while (!Q.empty()) {
        u = Q.front(); Q.pop();
        for (auto i = 0; i < G[u].size(); i++) {
            Edge e = G[u][i];
            if (d[e.t] == INF) {
                d[e.t] = d[u] + e.w;
                Q.push(e.t);
            }
        }
    }
}

int solve(void) {
    bfs(0);
    int maxv = 0;
    int tgt = 0;
    for (int i = 0; i < n; i++) {
        if (d[i] == INF) continue;
        if (maxv < d[i]) {
            maxv = d[i];
            tgt = i;
        }
    }

    bfs(tgt);
    maxv = 0;
    for (int i = 0; i < n; i++) {
        if (d[i] == INF) continue;
        maxv = max(maxv, d[i]);
    }

    return maxv;
}

int main(void) {
    int s, t, w;
    cin >> n;
    for (int i = 0; i < n-1; i++) {
        cin >> s >> t >> w;
        G[s].push_back(Edge(t, w));
        G[t].push_back(Edge(s, w));
    }

    int ans = solve();
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n, 0), b(n, 0), c(n, 0);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
    }
    sort(c.begin(), c.end());

    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll x = b[i];
        ll cnt1 = lower_bound(a.begin(), a.end(), x) - a.begin();
        ll cnt2 = n - (upper_bound(c.begin(), c.end(), x) - c.begin());

        ans += cnt1 * cnt2;
    }

    cout << ans << endl;

}

Measured memory_bytes: 2688
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size() - 1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min + (max - min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n, vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());

}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n) {
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n;
	cin >> n;
	vector<ll> p(n);
	rep(i, n) {
		cin >> p[i];
	}
	ll ans = 0;
	rep(i, n) {
		if (i + 1 == p[i]) {
			ans++;
			i++;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
import sys

a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

card = [
    [0, 0, 0],
    [0, 0, 0],
    [0, 0, 0]
]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if(b[i] == a[j][k]):
                card[j][k] = 1

if card[0].count(1) == 3:
    print("Yes")
    sys.exit()

if card[1].count(1) == 3:
    print("Yes")
    sys.exit()

if card[2].count(1) == 3:
    print("Yes")
    sys.exit()

if card[0][0] == 1 and card[1][0] == 1 and card[2][0] == 1:
    print("Yes")
    sys.exit()

if card[0][1] == 1 and card[1][1] == 1 and card[2][1] == 1:
    print("Yes")
    sys.exit()

if card[0][2] == 1 and card[1][2] == 1 and card[2][2] == 1:
    print("Yes")
    sys.exit()

if card[0][0] == 1 and card[1][1] == 1 and card[2][2] == 1:
    print("Yes")
    sys.exit()

if card[0][2] == 1 and card[1][1] == 1 and card[2][0] == 1:
    print("Yes")
    sys.exit()

print("No")


Measured memory_bytes: 61820
N = int(input())
T = [0] * N
for i in range(N) :
    T[i] = int(input())
ans = 1
import fractions
from fractions import gcd
def lcm(x,y) :
    return(x*y) // fractions.gcd(x,y)
for i in range(N) :
    ans = lcm(ans,T[i])
print(ans)

Measured memory_bytes: 5048
import math
 
N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'
 
input()
d = None
u = set()
for x in map(int, input().split()):
  d = math.gcd(d or x, x)
  s = set()
  while x > 1:
    p = spf[x]
    if p in u:
      r = 'setwise'
    s.add(p)
    x //= p
  u |= s
print((r, 'not')[d > 1], 'coprime')


Measured memory_bytes: 179452