akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
int n;
ll l[104];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	REP(i, 0, n){
		cin >> l[i];
	}
	sort(l, l + n);
	ll ans = 0;
	REP(i, 0, n){
		REP(j, 0, i){
			REP(k, 0, j){
				if (l[i] == l[j]) continue;
				if (l[j] == l[k]) continue;
				if (l[k] == l[i]) continue;
				if (l[k] + l[j] > l[i]){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

//cout.flush()
//cout << fixed << setprecision(9) << x << endl;

Measured memory_bytes: 3656
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <fstream>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const char INF = 40;
const double eps = 1e-6;
const ll MOD = 1000000007;

typedef char Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void shortestPath(const Graph &g, int s,
	vector<Weight> &dist, vector<int> &prev) {
	int n = g.size();
	dist.assign(n, INF); dist[s] = 0;
	prev.assign(n, -1);
	priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
	for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
		Edge e = Q.top(); Q.pop();
		if (prev[e.dst] != -1) continue;
		prev[e.dst] = e.src;
		for (auto f = g[e.dst].begin();f != g[e.dst].end();f++) {
			if (dist[f->dst] > e.weight + f->weight) {
				dist[f->dst] = e.weight + f->weight;
				Q.push(Edge(f->src, f->dst, e.weight + f->weight));
			}
		}
	}
}

int main() {
	ll N;
	cin >> N;
	vector<ll> node(N);
	for (int i = 0;i < N - 1;i++) {
		ll x, y, a;
		cin >> x >> y >> a;
		node[x] ^= a;
		node[y] ^= a;
	}
	vector<ll> num(16);
	ll ans = 0;
	for (auto &&x : node) {
		if (x == 0)
			continue;
		if (num[x]) {
			num[x] = 0;
			ans++;
		}
		else
			num[x] = 1;
	}
	ll start = 0;
	for (ll i = 1;i < 16;i++)
		start |= num[i] << (i - 1);
	Graph g(1 << 15);
	for (ll from = 0;from < 1 << 15;from++) {
		ll a = 0;
		while (a < 15) {
			while ((from & (1 << a)) == 0 && a < 15)
				a++;
			if (a >= 15)
				break;
			ll b = a + 1;
			while (b < 15) {
				while ((from & (1 << b)) == 0 && b < 15)
					b++;
				if (b >= 15)
					break;
				for (ll use = 1;use <= 15;use++) {
					ll ak = a + 1;
					ll an = ak ^ use;
					ll bk = b + 1;
					ll bn = bk ^ use;
					ll cost = 1;
					ll next = from;
					next ^= 1 << a;
					next ^= 1 << b;
					an--;
					if (an != -1 && next & (1 << an))
						cost++;
					if(an >= 0)
						next ^= 1 << an;
					bn--;
					if (bn != -1 && next & (1 << bn))
						cost++;
					if(bn >= 0)
						next ^= 1 << bn;
					g[from].push_back(Edge(from, next, cost));
				}
				b++;
			}
			a++;
		}
	}
	vector<Weight> dist;
	vector<int> prev;
	shortestPath(g, start, dist, prev);
	cout << dist[0] + ans << endl;
	return 0;
}


Measured memory_bytes: 219756
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n, m;
    cin >> n >> m;

    vector<pair<int64_t, pair<int64_t, int64_t>>> events;
    vector<int64_t> cost(m);
    for (auto i : irange(0L, m)) {
        int64_t l, r;
        cin >> l >> r >> cost[i];

        events.emplace_back(l, make_pair(1, i));
        events.emplace_back(r, make_pair(-1, i));
    }

    sort(events.begin(), events.end());

    vector<bool> active(m);
    priority_queue<pair<int64_t, int64_t>, vector<pair<int64_t, int64_t>>,
                   greater<pair<int64_t, int64_t>>>
            q;
    constexpr auto kInfinity = numeric_limits<int64_t>::max();
    vector<int64_t> total_cost(n + 1, kInfinity);
    total_cost[1] = 0;
    for (auto e : events) {
        auto current = e.first;

        if (!q.empty()) {
            total_cost[current] = min(total_cost[current], q.top().first);
        }

        if (e.second.first == -1) {
            // R
            active[e.second.second] = false;

            while (!q.empty() && !active[q.top().second]) {
                q.pop();
            }
        } else {
            // L
            if (total_cost[current] != kInfinity) {
                active[e.second.second] = true;
                q.emplace(total_cost[current] + cost[e.second.second],
                          e.second.second);
            }
        }
    }

    if (total_cost[n] == kInfinity) {
        cout << -1 << endl;
    } else {
        cout << total_cost[n] << endl;
    }
}

Measured memory_bytes: 10988
#include <iostream>

using namespace std;
int x, ans, mx;
string s;
int main()
{
    cin >> x >> s;
    for(int i = 0; i < x; i++){
        if(s[i] == 'I'){
            ans++;
            mx = max(mx, ans);
        }else{
            ans--;
        }
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int x,a,b;
    cin >> x >> a >> b;
    x-=a;
    while(x-b >= 0)x-=b;
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
  int x,y,r;
  
  scanf("%d %d",&x,&y);

  r=x%y;

  while(r!=0){
    x=y;
    y=r;
    r=x%y;

  }
  printf("%d\n",y);

  return 0;
}



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

int main(){
  
  int r,D,x;
  cin >> r >> D >> x;
  
  vector<int> a(10);
  
  a[0] = r * x - D;
  
  for (int i = 1; i < 10; i++){
    a[i] = r * a[i-1] - D;
  }
  
  for (int i = 0; i < 10; i++){
    cout << a[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        if(line.equals("Sunny"))    System.out.println("Cloudy");
        else if(line.equals("Cloudy"))  System.out.println("Rainy");
        else    System.out.println("Sunny");
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

bool vector_find(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}

int main(int argc, char *argv[]){
    string result = "";
    string S;
    cin >> S;
    if(stoi(S.substr(0, 2)) == 0 || stoi(S.substr(0, 2)) > 12){
        if(stoi(S.substr(2, 2)) == 0 || stoi(S.substr(2, 2)) > 12){
            result = "NA";
        }else{
            result = "YYMM";
        }
    }else if(stoi(S.substr(2, 2)) == 0 || stoi(S.substr(2, 2)) > 12){
        if(stoi(S.substr(0, 2)) == 0 || stoi(S.substr(0, 2)) > 12){
            result = "NA";
        }else{
            result = "MMYY";
        }
    }else{
        result = "AMBIGUOUS";
    }
    
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 256
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        a: [isize; n],
    }
    let mut sum_map = HashMap::new();
    for (i, &ai) in a.iter().enumerate() {
        *sum_map.entry(i as isize + ai).or_insert(0) += 1isize;
    }
    let mut result = 0;
    for (i, &ai) in a.iter().enumerate() {
        result += *sum_map.get(&(i as isize - ai)).unwrap_or(&0);
    }
    println!("{}", result);
}


Measured memory_bytes: 11768
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define inputv(arr,n) for(ll i=0;i<n;i++){ll value;cin>>value;arr.pb(value);}
#define sz(a) ((ll)(a).size())
#define len(a) ((ll)(a).length())
#define F first
#define S second
#define vi vector <int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b)
{if(b==0) return a;a%=b;return gcd(b,a);}
#define nl cout<<"\n"
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
// hashing for pairs
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};
//sort in reverse order
bool compare(ll x, ll y){
    return x>y;
}
void solve()
{
  ll n;
  cin>>n;
  unordered_map<ll,ll>cnt;
  ll sum=0;
  for (ll i = 0; i < n; i++)
  {
    ll val;
    cin>>val;
    sum+=val;
    cnt[val]++;
  }
  ll q;
  cin>>q;
  for (ll i = 0; i < q; i++)
  {
    ll b,c;
    cin>>b>>c;
    if(cnt.find(b)!=cnt.end())
    {
      auto it = *cnt.find(b);
      sum-=(it.first*it.second);
      sum+=(it.second*c);
      cout<<sum;nl;
      ll val = it.second;
      cnt.erase(b);
      cnt[c]+=val;
    }
    else
    {
      cout<<sum;nl;
    }
  }
  
  return;
}
int main()
{
    IOS;
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 6536
#include <cstdio>

/*
g(L, R) := \prod_{i=L}^{R} (1 + q^{A_i})
f(L, R) = [q^S] g(L, R)
\sum_{1<=L<=R<=N} f(L, R)
p[i] := \sum_{1<=L<=i} g(L, i)
p[i] = (p[i-1] + 1) * (1 + q^{A_i})
*/

constexpr unsigned mod = 998244353;

int n, s;
unsigned long long dp[3001];

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

  int ans = 0;
  for(int i = 0; i < n; i++){
    int a;
    scanf("%d", &a);
    dp[0]++;
    for(int j = s; j >= a; j--){
      dp[j] += dp[j - a];
    }
    if(i % 31 == 30){
      for(int j = 0; j <= s; j++)
        dp[j] %= mod;
    }
    ans = (ans + dp[s]) % mod;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
from numpy import array, ones

mod = 10 ** 9 + 7

N, M, *ST = map(int, open(0).read().split())
S, T = ST[:N], array(ST[N:])

dp = ones(M + 1, dtype="int64")
for s in S:
    dp[1:] = ((dp[:-1] * (s == T)).cumsum() + dp[1:]) % mod

print(dp[-1])

Measured memory_bytes: 14548
import sys
from bisect import bisect_left, bisect_right

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
d= LI()

d.sort()

ans = 0
for i in range(d[-1]):
    right = bisect_right(d, i)
    if right == N / 2:
        ans += 1

print(ans)

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

int w,h;
int area[21][21];

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

void rec( int x, int y, int n ){
  //    cout << "rec : " << x << " " << y << " " << n << endl;

  int nn=n+1;
  bool f;
  if( n>10 ) return;
  if( n>=ans ) return;

  for( int i,j, k=0;k<4;k++ ){
    //    cout << "k="<<k<<endl;
    i=x; j=y; f=true;
    while( f ){
      i+=dx[k]; j+=dy[k];
      if(j<0) break;      if(i<0) break;
      if(i>=h) break;     if(j>=w) break;
	 //	 cout << " i="<<i<< " j="<<j<< " "<<area[i][j] << endl;
      switch( area[i][j] ){
      case 3:  ans=min(ans,nn);return;
      case 1:{
	if( i-dx[k]!=x || j-dy[k]!=y ){
	  area[i][j]=0;
	  rec(i-dx[k],j-dy[k],nn);
	  area[i][j]=1;
	}
	f=false;
	break;
      }
      }	 
    }
  }
    //    cout << "ret="<<ret<<endl;
}

  void pr(){
    for( int i=0;i<h;i++ ){
      for( int j=0;j<w;j++ )
	cout << area[i][j] << " " ;
      cout << endl;
    }
  }

int main(){
  int sx,sy;

  while( cin>>w>>h && (w|h) ){
    //    cout << " h="<<h << " w="<<w << endl;

    for( int i=0;i<h;i++ )
      for( int j=0;j<w;j++ ){
	cin >> area[i][j];
	if( area[i][j]==2 ){ sx=i;sy=j;area[i][j]=0; }
      }
    /*
    cout << "area"<<endl;
    pr();
    cout<< "answer"<<endl;
    */
    ans=100;
    rec( sx,sy,0 );
    //    cout << "ans="<<ans<<endl;

    if( ans>10 ) ans=-1;
    cout << ans << endl;

  }

  return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  int n;
  cin >> n;
  vector<ll> cnt(10'000'000 + 1, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      cnt.at(j)++;
    }
  }
  ll res = 0;
  for (int i = 1; i <= n; i++) {
    res += (ll) i * cnt.at(i);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 81400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i,j;
	int n;
	cin>>n;
	VI v(2020202,0);
	VI w(n);
	for(i=0;i<n;i++){
		int a;
		cin>>a;
		v[a]++;
		w[i]=a;
	}
	ll sum=0;
	for(i=0;i<2020202;i++) sum+=v[i]*(v[i]-1)/2;
	for(i=0;i<n;i++){
		cout<<sum-v[w[i]]+1<<endl;
	}

}

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

int main() {
	int n,i;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)cin>>a[i];
	if(n%2==0){
	    for(i=n-1;i>=0;i-=2){
	        cout<<a[i]<<" ";
	    }
	    for(i=0;i<n;i+=2){
	        cout<<a[i]<<" ";
	    }
	    cout<<endl;
	}
	else{
	    for(i=n-1;i>=0;i-=2){
	        cout<<a[i]<<" ";
	    }
	    for(i=1;i<n;i+=2){
	        cout<<a[i]<<" ";
	    }
	    cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 2944
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int main(void)
{
  int A, B;
  cin >> A >> B;
  if ((A * B) % 2 == 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 103
#define inf LLONG_MAX
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    SPEED

    int n,m;
    cin>>n>>m;
    pii p1[m+1],p2[m+1];
    int i,j,a,b;
    for(i=1;i<=m;++i)
        cin>>a>>b,p1[i]={a,b},p2[i]={b,a};
    
    sort(p1+1,p1+m+1);
    sort(p2+1,p2+m+1);
    cout<<max(0LL,p2[1].first-p1[m].first+1);
    
    
    return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

typedef long long int ll;
const int MAX_N = 100010;
struct UnionFind {
    int node[MAX_N];
    UnionFind() {}
    void init() {
        memset(node, -1, sizeof(node));
    }

    int find(int x) {
        return (node[x] < 0 ? x : node[x] = find(node[x]));
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return -node[find(x)];
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if(same(x, y)) return;
        // y を x に統合
        node[x] += node[y];
        node[y] = x;
    }
};

struct Query {
    // q: mark -> 0, query -> 1
    int q, v;
    Query() {}
    Query(int a, int b) : q(a), v(b) {}
};

vector< vector<int> > G;
int N, Q, mark[100010], parent[100010];
Query qs[100010];
UnionFind uf;

int main() {
    while(1) {
        // init
        uf.init();
        memset(mark, 0, sizeof(mark));
        memset(parent, -1, sizeof(parent));
        G.clear();

        scanf("%d%d", &N, &Q);
        if(N == Q && Q == 0) break;
        G.resize(N);

        for(int i=1; i<N; i++) {
            int par; scanf("%d", &par); par--;
            G[par].push_back(i);
            parent[i] = par;
        }

        for(int i=0; i<Q; i++) {
            char mode; int v;
            scanf(" %c%d", &mode, &v); v--;
            qs[i] = Query(mode == 'Q', v);
            if(mode == 'M') mark[v]++;
        }

        for(int i=1; i<N; i++) {
            if(!mark[i]) {
                uf.unite(parent[i], i);
            }
        }

        ll ans = 0;
        for(int i=Q-1; i>=0; i--) {
            // mark
            if(qs[i].q == 0) {
                if(--mark[qs[i].v] == 0) {
                    int par = parent[qs[i].v];
                    if(par < 0) continue;
                    uf.unite(par, qs[i].v);
                }
            }
            // query
            else {
                ans += uf.find(qs[i].v) + 1;
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 9768
program greedy_customers
  implicit none
  integer :: n, a(100000), x, i
  integer(8) :: m
  a = 0
  read(*,*) n
  do i = 1, n
    read(*,*) a(i)
  end do
  x = 1
  m = int(a(1)-1,8)
  do i = 2, n
    if (a(i).le.x+1) then
      x = max(x,a(i))
    else
      m = m+int((a(i)-1)/(x+1),8)
    end if
  end do
  write(*,'(i0)') m
  stop
end program greedy_customers

Measured memory_bytes: 640
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> a){
    map<int, int>m;
    REP(i, N){
        m[a[i]]=0;
    }
    REP(i, N){
        if(m[a[i]]){cout<<"NO"<<endl;return;}
        m[a[i]]++;
    }cout<<YES<<endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>

int main(void) {
	int e[12];
	int i, j;
	for (i = 0; i < 12; i++) {
		if (scanf("%d", &e[i]) != 1) return 1;
	}
	for (i = 11; i > 0; i--) {
		for (j = 0; j < i; j++) {
			if (e[j] > e[j + 1]) {
				int t = e[j];
				e[j] = e[j + 1];
				e[j + 1] = t;
			}
		}
	}
	for (i = 0; i < 12; i += 4) {
		for (j = 1; j < 4; j++) {
			if (e[i] != e[i + j]) {
				puts("no");
				return 0;
			}
		}
	}
	puts("yes");
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;

int main(){
  int n; 
  string s;
  cin>>n>>s;
  int res=1;
 
  FOR(i,1,n){
    if(s[i]!=s[i-1])res++;
    }
  
 cout<<res<<endl;
}

Measured memory_bytes: 512
n = STDIN.gets
lines = STDIN.read.split("\n")
cards = []
%w(S H C D).each do |s|
  (1..13).each do |n|
    cards << "#{s} #{n}"
  end
end
lines.each do |line|
  cards.delete(line)
end
cards.each do |card|
  print "#{card}\n"
end

Measured memory_bytes: 8716
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] team=new int[n];
		int teamA,teamB,scoreA,scoreB,cnt;
		for(int i=0;i<n*(n-1)/2;i++){
			teamA=sc.nextInt();
			teamB=sc.nextInt();
			scoreA=sc.nextInt();
			scoreB=sc.nextInt();
			if(scoreA>scoreB){
				team[teamA-1]+=3;
			}
			else if(scoreA<scoreB){
				team[teamB-1]+=3;
			}
			else{
				team[teamA-1]+=1;
				team[teamB-1]+=1;
			}
		}
		for(int i=0;i<n;i++){
			cnt=1;
			for(int j=0;j<n;j++){
				if(team[i]<team[j]){
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 42060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#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 FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int N;
  scanf("%d", &N);
  int a[N],b[N],c[N-1];
  int sum = 0;
  int fuse = 0;
  FOR(i,0,N-1) {
    cin >> a[i];
    }
  FOR(i,0,N-1) {
    cin >> b[i];
    sum += b[i];
  }
  FOR(i,0,N-2) {
    cin >> c[i];
  }

  FOR(i,1,N-1){
    if(a[i]-a[i-1]==1){
      sum += c[a[i-1]-1];
    }
  }

  cout << sum << endl;
  
  

}



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

int main(){

int R;
  cin >> R;
  
  if(R < 1200) cout << "ABC" << endl;
  else if((R >= 1200) && (R < 2800)) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  
return 0;
  
}

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

int main(){
   int N;
   std::cin >> N;
   std::string S;
   std::cin >> S;
   int max = 0;
   int x = 0;
   for (int i=0; i<N; ++i){
      if (S.at(i) == 'I'){
         x++;
      } else{
         x--;
      }
      max = std::max(max, x);
   }
   std::cout << max << std::endl;
}



Measured memory_bytes: 256
from sys import stdin


def get_result(data):
    A, B, C, K = data
    if (A + B) >= K:
        return K if A > K else A
    else:
        return A - (K-(A+B))


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip().split(' ')))
    result = get_result(data)
    print(result)


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

int main(void){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for(int i=0; i<=a; i++){
        for(int j=0; j<=b; j++){
            for(int k=0; k<=c; k++){
                if(i*500 + j*100 + k*50 == x){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string> 
#include <vector>  
#include<math.h>

#define INF 1000000000
using namespace::std;



long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int a) {
	if (a < 0) {
		return -a;
	}
	return a;
}

long long N, M,wa, K, W, ans,k[5];
string s;

int main() {
	cin >> N >> K>>W;
	if (N + K >= W) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;

int main()
{
	int Max = 1005;
	int n, m; cin >> n >> m;
	vector<pair<int, int>> su(m);
	rep(j, m) {
		cin >> su[j].first >> su[j].second;
		su[j].first--;
	}
	rep(i, Max) {
		vector<int> aa(n);
		int w = 1;
		rep(d, n)
			w *= 10;
		if (i >= w and i!=0) continue;
		int j = 0;
		int t = i;
		int gg = 0;
		while (t) {
			aa[j] = t % 10;
			t /= 10;
			j++;
		}
		if (i == 0) {
			j = 1;
			aa[0] = 0;
		}
		if (j != n) continue;
		reverse(aa.begin(), aa.end());
		bool ok = true;
		rep(q, m) {
			if (aa[su[q].first] != su[q].second)
				ok = false;
		}
		if (ok) {
			cout << i;
			return 0;
		}
	}
	cout << -1;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;	cin>>n;
	int a[n],i,j;
	ll ans=0;
	for(i=0;i<n;i++){
		cin>>a[i];
	}

	if(a[0]>0){
		printf("-1\n");	return 0;
	}

	for(i=0;i<n-1;i++){
		if(a[i+1]>a[i]+1)	break;
		if(a[i+1]==a[i]+1)	ans++;
		else	ans+=a[i+1];
	}

	if(i<n-1)	printf("-1\n");
	else	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int tate,yoko,takasa,mn,md;
	int n;
	while(cin>>tate>>yoko>>takasa, tate|| yoko || takasa){
		cin>>n;
		int* r = new int [n];
		mn=min(min(tate , yoko) , takasa);
		if(tate>=yoko){
			if(yoko>=takasa) {
			    md=yoko;
			} else if (yoko<takasa) {
				if(tate>=takasa)  md=takasa;
				else if (tate<takasa)  md=tate;
			}
			
		} else if (tate<yoko){
			if (tate>=takasa){
				md=tate;
			} else if(tate<takasa){
				if(yoko>=takasa) md=takasa;
				else if(yoko<takasa) md=yoko;
			}
		}
		for(int i=0;i<n;++i){
			cin>> r[i];
			cout << ((r[i]*r[i]*4>mn*mn+md*md) ? "OK" : "NA") << endl;
		}
		delete [] r;
	}
	return 0; 
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N; cin >> N;
  map<ll, vector<int>> mp;
  REP(i, N) {
    ll a; cin >> a;
    mp[a].emplace_back(i);
  }

  vector<ll> height, counter;
  vector<int> indices;
  int min_idx = N;
  ll cnt = 0;
  for (auto it = mp.rbegin(); it != mp.rend(); it++) {
    for (int idx : it->second) {
      min_idx = min(min_idx, idx);
    }
    cnt += it->second.size();
    height.emplace_back(it->first);
    counter.emplace_back(cnt);
    indices.emplace_back(min_idx);
  }

  height.emplace_back(0);

  vector<ll> ans(N, 0);
  REP(i, counter.size()) {
    ans[indices[i]] += (height[i] - height[i+1]) * counter[i];
  }
  for (ll a : ans) cout << a << endl;

  return 0;
}


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

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

  vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  x.push_back(X);

  vector<int> y(M);
  for (int i = 0; i < M; i++) {
    cin >> y[i];
  }
  y.push_back(Y);

  int l = *max_element(begin(x), end(x));
  int r = *min_element(begin(y), end(y));

  bool ans = (l < r);
  cout << ( (!ans) ? "War" : "No War" ) << endl;

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,m = map(int,readline().split())
#lrx = [tuple(map(int,readline().split())) for _ in range(m)]
#lrx.sort(key=lambda x: x[1])
cond = [[] for _ in range(n+1)]
for _ in range(m):
    l,r,x = map(int,readline().split())
    cond[r].append((l,x))

"""
dp[i][j][k] = iまで見て 2 色目は j個前に、3 色目は k個前 に登場
1 <= j < k
"""
N = n+3
dp = [[0]*(N) for _ in range(N)]
dp[1][2] = 1

MOD = 10**9+7

def f(r,j,k,v,ndp):
    if j >= N or k >= N: return
    for l,x in cond[r]:
        if x==1 and l <= r-j: return
        if x==2 and (r-j < l or l <= r-k): return
        if x==3 and r-k < l: return
    ndp[j][k] += v
    ndp[j][k] %= MOD
    return

for i in range(1,n+1):
    ndp = [[0]*(N) for _ in range(N)]
    for q in range(1,N):
        for r in range(q+1,N):
            v = dp[q][r]
            if v:
                f(i,q+1,r+1,v,ndp)
                f(i,1,r+1,v,ndp)
                f(i,1,q+1,v,ndp)
    dp = ndp
    #print(dp)



ans = sum(sum(i) for i in dp)
print(ans%MOD)





Measured memory_bytes: 219728
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <queue>
using namespace std;
using ll=long long;
//using R=double;

const int INF = 10000000;
typedef pair<int, int> p;


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

    sort(B, B+N);

    ll median;
    if(N%2 == 0){
        median = B[N/2-1];
    }else{
        median = B[N/2];
    }

	ll result = 0;

    for(int i = 0; i < N; i++){
        result += abs(B[i] - median);
    }

    cout << result << endl;

	return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>

int main(void){
    int a[10001];
    int n,num,min,max;
    long sum=0;
    int i,j;
    
    scanf("%d",&n);
    
    for(j=0;j<n;j++){
        scanf("%d",&num);
        a[j]=num;
    }
    
    for(i=0;i<n;i++){
        sum+=a[i];
        if(i==0){
            min=a[i];
            max=a[i];
        }else if(a[i]<min){
            min=a[i];
        }else if(a[i]>max){
            max=a[i];
        }
    }
    
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 1856
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define db double 
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define clr(x) memset(x,0,sizeof(x))
const ll siz=1e6+7;
const ll mod=1e9+7;
ll arr[siz];
ll n,k;
ll solve(ll x)
{
    ll ans=(ll)(ceil((x-1.0)/(k-1.0)));
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll t=n;
    ll s=0;
    while(t!=0)s+=(t%10),t=t/10;
    if(n%s==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#define TOUMAX 4
#define KAIMAX 3
#define ROOMMAX 10

int main(void)
{
	int n,b,f,r,v;
	int i,j,k,l;
	int num[TOUMAX][KAIMAX][ROOMMAX] = {0};

	cin >> n;

	for (i=0; i<n; i++) {
		cin >> b;
		cin >> f;
		cin >> r;
		cin >> v;

		num[b-1][f-1][r-1] += v;
	}

	for (i=0; i<TOUMAX; i++) {
		for (j=0; j<KAIMAX; j++) {
			for (k=0; k<ROOMMAX; k++) {
				cout << " " << num[i][j][k];
			}
			cout << endl;
		}
		if (i < (TOUMAX-1)) {
			cout << "####################";
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n; cin >> n;
	int a[n+1];
	for(int i=1;i<=n;i++) cin >> a[i];
	
	int cnt = 0;
	int curr = 1;
	
	for(int i=1;i<=n;i++){
		if(curr == 2){
			cout << cnt;
			return 0;
		}
		curr = a[curr];
		cnt++;
	}
	
	cout << -1;
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(){
    long long a;
    string b;
    cin >> a >> b;
    long long b1 = b[0] - '0';
    long long b2 = b[2] - '0';
    long long b3 = b[3] - '0';
    cout << a * (b1 * 100 + b2 * 10 + b3) / 100;
    return 0;
}

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

char janken(char c){
    if(c == 'r'){
        return 'p';
    }else if (c == 's')
    {
        return 'r';
    }else if(c == 'p'){
        return 's';
    }else{
        return 0;
    }
}

int main(){
    ll n,k,r,s,p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    vector<char> prediction;
    ll total_score = 0;
    for(int i=0;i<n;i++){
        if(i < k){//k回まで
            prediction.push_back(janken(t[i]));
            if(janken(t[i]) == 'r'){
                total_score += r;
            }else if (janken(t[i]) == 's')
            {
                total_score += s;
            }else{
                total_score += p;
            }
        }else{
            if(janken(t[i]) != prediction[i-k]){
                prediction.push_back(janken(t[i]));
                if(janken(t[i]) == 'r'){
                    total_score += r;
                }else if (janken(t[i]) == 's')
                {
                    total_score += s;
                }else{
                    total_score += p;
                }
            }else{
                prediction.push_back('0');
                total_score += 0;
            }
        } 
    }
    cout << total_score;
    return 0;
}


/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int main() {
  int X, Y, Nx, Ny, Nz, c=0;
  cin >> X >> Y;
  
  for(int x = 0; x <= X; x++){
    for(int y = 0; y <= (X-x); y++){
      int z;
      z = X - x- y;
      if(x*10000+y*5000+z*1000 == Y && z >= 0){
        c = 1;
        cout << x << " " << y << " " << z << endl;
        break;
      }
    }
   if(c == 1) break; 
  }
  if(c == 0){
    cout << "-1 -1 -1" << endl;
  }
}

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

int main() {
  int i, n;
  bool c = false;
  string s;
  cin >> s;
  n = s.size();
  if (s.substr(n - 7, 7) == "keyence") {
    c = true;
  } else if (s.substr(0, 1) == "k" && s.substr(n - 6, 6) == "eyence") {
    cout << s.substr(0, 1) << "\n";
    c = true;
  } else if (s.substr(0, 2) == "ke" && s.substr(n - 5, 5) == "yence") {
    c = true;
  } else if (s.substr(0, 3) == "key" && s.substr(n - 4, 4) == "ence") {
    c = true;
  } else if (s.substr(0, 4) == "keye" && s.substr(n - 3, 3) == "nce") {
    c = true;
  } else if (s.substr(0, 5) == "keyen" && s.substr(n - 2, 2) == "ce") {
    c = true;
  } else if (s.substr(0, 6) == "keyenc" && s.substr(n - 1, 1) == "e") {
    c = true;
  } else if (s.substr(0, 7) == "keyence") {
    c = true;
  }
  if (c) {
    cout << "YES"
         << "\n";
  } else {
    cout << "NO"
         << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

struct node{
    string m;
    vi to;
};

vector<node> t;

void print(int i,int d){
    rep(_,d)cout<<'.';
    cout<<t[i].m<<endl;
    for(int j:t[i].to){
        print(j,d+1);
    }
}

void run(){
    int n;
    cin>>n;
    t.resize(n);
    rep(i,n){
        int k;
        cin>>k>>t[i].m;
        if(i){
            k--;
            t[k].to.pb(i);
        }
    }
    print(0,0);
}    


Measured memory_bytes: 3440
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}




int main(void) {
  ll N;
  cin >> N;
  ll i;
  vector<pair<ll, P>> v;
  
  for(i=0; i<N; i++) {
    ll a, b;
    cin >> a >> b;
    v.push_back({a+b, {a, b}});
  }
  sort(v.rbegin(), v.rend());
  
  ll ans=0;
  for(i=0; i<N; i++) {
    if(i%2==0) ans+=v[i].sc.ft;
    else ans-=v[i].sc.sc;
  }
  
  pt(ans);
  
  
}
  
  


Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    int ans;
    scanf("%d%d%d",&a,&b,&c);
    int len=min(a,min(b,c));
    if(len==a)
    {
        ans=len+min(b,c);
    }
    else if(len==b)
    {
        ans=len+min(a,c);
    }
    else ans=len+min(a,b);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    /**
     * ABC 081 A - Placing Marbles 
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int count = 0;
        if( s.charAt(0) ==  '1') count++;
        if( s.charAt(1)  == '1') count++;
        if( s.charAt(2)  == '1') count++;
         
        System.out.println(count);
    }
}


Measured memory_bytes: 21972
#include<iostream>
#include<climits>
#include<cstring>
using namespace std;
#define ll long long int

ll profit = 0;

ll maxProfit(ll weight[], ll value[], ll n, ll w, ll idx,ll mem[105][100005]) {
    
     //cout<<idx<<" "<<value[idx]<<" "<<w<<endl;
    
    if(idx>=n || w==0)
      return 0;
      
    if(mem[idx][w]!=-1)
       return mem[idx][w];
      
   
    
    ll profit1 = INT_MIN;
    if(weight[idx]<=w){
	profit1 = value[idx] + maxProfit(weight, value, n, w - weight[idx], idx + 1,mem);
    }
	
	ll profit2 = maxProfit(weight, value, n, w, idx + 1,mem);
	
	//cout<<profit1<<" "<<profit2;
	
	profit = max(profit1, profit2);
	mem[idx][w] = profit;

	return profit;
}



int main() {
	ll weight[105];
	ll n, w;
	cin >> n >> w;
	ll value[105];

	for (int i = 0; i < n; i++) {
		ll w1, v1;
		cin >> w1 >> v1;
		weight[i] = w1;
		value[i] = v1;
	}
	
	ll mem[105][100005];
	memset(mem,-1,sizeof mem);

	/*for (int i = 0; i < n; i++) {
		cout << weight[i] << " " << value[i] << endl;
	}*/

	cout << maxProfit(weight, value, n, w, 0,mem) << endl;







	return 0;
}

Measured memory_bytes: 85612
#include<iostream>
using namespace std;
int n, p;
char s[200005];
long long ans;
int cnt[10005];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n >> p;
	cin >> s;
	if(p == 2 || p == 5){
		for(int i = 0; i < n; ++i)
			if(!((s[i] - '0') % p)) ans += i + 1;
		cout << ans << endl;
		return 0;
	}
	else {
		cnt[0] = 1;
		int pow = 1, res = 0;
		for(int i = n - 1; i >= 0; --i){
			res = (res + (s[i] - '0') * pow) % p;
			ans += cnt[res]; 
			cnt[res]++;
			pow *= 10;
			pow %= p;
		}
		cout << ans << endl;
		return 0;
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) max_element(x.begin(),x.end())
#define MIN(x) min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
//cout << std::fixed << std::setprecision(15);
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
signed main(){
    int n,m; cin >> n >> m;
    if(n==m) couty;
    else coutn;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d%d", $N, $M);
$A = array_map("intval", explode(" ", trim(fgets(STDIN))));
sort($A);

//累積和を作る
$AS[-1] = 0;
foreach($A as $i => $a){
    $AS[$i] = ($AS[$i-1] ?? 0) + $a;
}
//二分探索 -- $k以上の値の個数がMを超えるなかで最大のkを求める
//めぐる式二分探索
$ok = 0; 
$ng = 10**5*2+1;
for($i = 0; $i < $ng; $i++){
    $lbmemo[$i] = lower_bound($A, $i);
}
while(abs($ok - $ng) > 1){
    $mid = intdiv($ok+$ng, 2);
    $sum = 0;
    $count = 0;
    if(isOK($mid)){
        $ok = $mid;
    }else{
        $ng = $mid;
    }
}
echo $sum - $ok * ($count - $M);
function isOK($bound){
    global $M, $A, $AS, $N, $sum, $count, $lbmemo;
    foreach($A as $a){
        $i = $lbmemo[$bound - $a] ?? 0;
        $ok = $N - $i;
        $count += $ok;
        $sum += $AS[$N - 1] - $AS[$i - 1] + $a * $ok;
    }
    return $count >= $M;
}
function lower_bound($array, $key){
    global $N;
    $min = -1;
    $max = $N;
    while($max - $min > 1){
        $c = intdiv($min + $max, 2);
        if($array[$c] >= $key){
            $max = $c;
        }else{
            $min = $c;
        }
    }
    return $max;
}


Measured memory_bytes: 27120
#include<bits/stdc++.h>
using namespace std;
main(){
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  string s=string()+s1.front()+s2.front()+s3.front();
  for(auto& c:s)c=toupper(c);
  cout<<s<<endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int n, m, q;
vi a, b, c, d;
int ans;

void calc(vi A) {
    int tmp = 0;
    rep(i, q) {
        if(A[b[i]] - A[a[i]] == c[i]) tmp += d[i];
    }
    ans = max(ans, tmp);
    return;
}

void dfs(vi A) {
    if(A.size() == n) {
        calc(A);
        return;
    } 

    int last = (A.empty() ? 1 : A.back());
    for(int add = last; add <= m; add++) {
        A.push_back(add);
        dfs(A);
        A.pop_back();
    }
}

int main()
{
    cin >> n >> m >> q;
    a = b = c = d = vi(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }

    vi A;
    dfs(A);

    cout << ans << endl;

    return 0;
}


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


int32_t main()
{
    int T;
    T = 1;
    while (T--)
    {
        int N;
        cin>>N;
        int ans = ceil((double )N/2);
        cout<<setprecision(10)<<fixed<<(double )ans/N<<endl;

    }
}

Measured memory_bytes: 256