akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int32_t main()
{
	fastIO
	inp_out();

	int x, y; 
	cin >> x >> y; 

	if(y & 1)
		cout << "No"; 
	else
	{
		int min = x * 2; 
		int max = x * 4; 

		if(y >= min && y <= max)
			cout << "Yes"; 
		else cout << "No"; 
	}

	return 0;
}

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

int main() {

	string s; cin >> s;
	const int p = 26;
	vector<int> num(p, 0);
	for (int i = 0; i < s.size(); i++) {
		num[s[i] - 'a']++;
	}
	bool allDifferent = true;
	for (int i = 0; i < p; i++) {
		if (2 <= num[i]) allDifferent = false;
	}
	if (allDifferent) cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}

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

int main() {
	string S, A , B;
    A = "";
    B = "";
    int F = 0;
  	getline(cin,S);
	for(int i = 0; i < S.size(); i++){
    	if(S.at(i) == ' '){
            if(S.at(i+1) == '+'){
            	F = 1;
            }
        	for(int j = 0; j < i ; j++){
            	A += S.at(j);
            }
          	for(int k = i + 3; k < S.size(); k++){
            	B += S.at(k);
            }
        break;
        }
    }
    if(F == 0){
    	cout << std::stoi(A) - std::stoi(B) << endl;
    } else{
    	cout << std::stoi(A) + std::stoi(B) << endl;
    }
}


Measured memory_bytes: 256
var count = 0;

function Main(input) {
    input = input.trim();
    input = input.split("\n")
    var a = parseInt(input[0]);

saiki(a,100);

console.log(count);

    // var a = input[0].split(" ");
  //  var b = input[1].split(" ");
// a = a.map(e=>{
//     return parseInt(e);
// })
// b = b.map(e=>{
//     return parseInt(e);
// })


}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 


function saiki(a,num){
    var b = parseInt(num*1.01);
    count++;
if(b>=a)return;
saiki(a,b);
}

Measured memory_bytes: 30428
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pii x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pii>> vvpii;
typedef vector<vector<pll>> vvpll;
typedef unordered_map<int, int, int_hash> umpii;
typedef unordered_map<ll, ll, int_hash> umpll;
typedef unordered_set<int, int_hash> usi;
typedef unordered_set<ll, int_hash> usll;
typedef unordered_set<pii, pair_hash> uspii;
typedef queue<int> qi;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = numeric_limits<int>::max();
const int MX = 100001; //check the limits, dummy

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

    int m1, d1, m2, d2; 
    cin >> m1 >> d1 >> m2 >> d2;
    cout << (m1 != m2) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,i,count=0;
    scanf("%d",&n);
    int a[n];

    for(i=0;i<n;i++)
        scanf("%d",&a[i]);

    for(i=1;i<n-1;i++)
            if((a[i-1]<a[i] && a[i]<a[i+1])||(a[i-1]>a[i] && a[i]>a[i+1]))
            {
                count++;
            }


                printf("%d",count);
}


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

const double PI=acos(-1.0);

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

    int cnt = 0;
    while(true) {
        bool exist_odd = false;
        for(int i = 0; i < n; i++) {
            if(a[i] % 2 != 0) exist_odd = true;
        }

        if(exist_odd) break;

        for(int i = 0; i < n; i++) {
            a[i] /= 2;
        }
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

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

void solve() {
    long long N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    map<long long, long long> M;
    set<long long> S;
    M[N] = 0; S.emplace(N);
    auto f = [&](auto x, auto c) {
        if (!M.count(x)) M[x] = c;
        M[x] = min(M[x], c);
    };
    auto g = [&](auto x, auto y, auto d, auto X) {
        long long a = x % d;
        long long b = d - a;
        if ((x-a)/d < x) {
            f((x-a)/d, a * D + y + X);
            S.emplace((x-a)/d);
        }
        if ((x+b)/d < x) {
            f((x+b)/d, b * D + y + X);
            S.emplace((x+b)/d);
        }
    };
    constexpr long long inf = 2e18;
    long long ans = inf;
    while (!S.empty()) {
        long long x = *S.rbegin();
        S.erase(x);
        long long y = M[x];
        if (inf / D >= x) ans = min(ans, y + D * x);
        M.erase(x);
        g(x, y, 2, A);
        g(x, y, 3, B);
        g(x, y, 5, C);
    }
    /*
    for (auto &[x, y]: M) {
        if (inf / D <= x) continue;
        ans = min(ans, y + x * D);
    }
    */
    // cout << M.size() << "\n";
    cout << ans << "\n";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int T; cin >> T;
    while (T--) solve();
    return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define fi first
#define se second
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define IT iterator 
#define vi vector<int>
#define TP template<class o>
#define SZ(a) ((int)a.size())
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20,mod=998244353,inf=2e9;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
    char c=gc; x=0; int f=1;
    while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
    while(isdigit(c)) x=x*10+c-'0',c=gc;
    x*=f;
}
template<class o> void qw(o x) {
    if(x/10) qw(x/10);
    putchar(x%10+'0');
}
template<class o> void pr1(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
    if(x<0)x=-x,putchar('-');
    qw(x); putchar('\n');
}

bool pd(int x) {
    int n=0;
    while(x) x/=10,n++;
    return n&1;
}

int main() {
    int n,ans=0;
    qr(n);
    for(int i=1;i<=n;i++) ans+=pd(i);
    pr2(ans); return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int keta(long long n){
    int ret=0;
    while(n){
        ret++;
        n/=10;
    }
    return ret;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long n;
    cin>>n;
    int ans=20;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){ans=min(max(keta(n/i),keta(i)),ans);}
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// オイラーのファイ関数　1からnまで数でnと互いに素である数の個数が求められる
ll eulerphi(ll n){
  if(n == 0) return 0;
  int res = n;
  for(ll i = 2; i*i <= n; i++){
    if(n%i == 0){
      res -= res/i;
      while(n%i == 0) n /= i;
    }
  }
  if(n > 1) res -= res/n;
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  cout << eulerphi(N) << endl;
}


Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <stack>
#include <algorithm>

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

using namespace std;

string S;
void solve(){
	char ans[100]={};
	stack<int> st;
	int now = 0, sf = 0;
	rep(i,S.length()){
		if( S[i] == '[' ){
			st.push( now );
		}else if( S[i] == ']' ){
			int b = st.top();
			st.pop();
			for(int l=b, r=now-1; r-l>0; l++, r--){
				swap(ans[l], ans[r]);
			}
		}else if( S[i] == '+' ){
			sf++;
		}else if( S[i] == '-' ){
			sf--;
		}else if( S[i] == '?' ){
			ans[now++] = 'A';
			sf = 0;
		}else{
			sf %= 26;
			char tmp = S[i] + sf;
			if( S[i] + sf > 'Z' ) tmp = 'A' + sf - ('Z' - S[i] + 1);
			if( S[i] + sf < 'A' ) tmp = 'Z' + sf + (S[i] - 'A' + 1);
			ans[now++] = tmp;
			sf = 0;
		}
	}
	ans[now] = '\0';
	cout << ans << endl;
}

int main(){
	while(cin>>S, S != "."){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

void solve() {
    int N;
    cin >> N;
    int A[200005];
    rep(i, N) {
        cin >> A[i];
    }
    ll sum = A[N-1];
    ll cur = 0;
    REPR(i, N-2, 0) {
        cur = (cur + sum * A[i]) % MOD;
        sum = (sum + A[i]) % MOD;
    }

    cout << cur;
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    solve();

    return 0;
}


Measured memory_bytes: 4384
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict
import math


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    ret = math.factorial(x)
    ret = ret // (math.factorial(x - y) * math.factorial(y))

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)


###############################################################################


def main():
    a, p = intin()

    p += a*3
    print(p // 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	int a[100000],n,flag2=0,flag4=0,flag1=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]%4==0)flag4++;
		else if(a[i]%2==0)flag2++;
		else flag1++;
	}
	if(flag2==0&&flag1<=(flag4+1))cout<<"Yes"<<endl;
	else
	if(flag2!=0&&flag4>=flag1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
} 

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

constexpr double INF = 1e18;
constexpr double eps = 1e-8;

using pii = pair<int, int>;
using pdd = pair<double, double>;

struct state {
    int l, r;
    double d;
    bool operator<(state const& s) const {
        return d > s.d;
    }
};

int main() {
    int N;
    while(cin >> N, N) {
        vector<pdd> v(N);
        for(int i=0; i<N; ++i) {
            cin >> v[i].first >> v[i].second;
        }
        for(int i=0; i<N; ++i) {
            int h = v[i].second;
            for(int j=0; j<N-1; ++j) {
                int mi = min(v[j].second, v[j+1].second);
                int ma = max(v[j].second, v[j+1].second);
                if(mi <= h && h <= ma && h != mi && h != ma) {
                    double a = (v[j+1].second - v[j].second) / (v[j+1].first - v[j].first);
                    double b = v[j].second - a * v[j].first;
                    double x = (h - b) / a;
                    v.push_back(make_pair(x, (double)h));
                }
            }
        }
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        N = v.size();
        map<pii, double> memo;
        priority_queue<state> que;
        que.push(state{0, N-1, 0});
        auto dist = [&](int i, int j) {
            return hypot(v[i].first - v[j].first, v[i].second - v[j].second);
        };
        double res = INF;
        while(!que.empty()) {
            auto now = que.top();
            que.pop();
            if(now.l == now.r) {
                res = now.d;
                break;
            }
            if(memo.count(make_pair(now.l, now.r)) != 0) {
                continue;
            }
            memo[make_pair(now.l, now.r)] = now.d;
            for(int dl=-1; dl<=1; ++dl) {
                for(int dr=-1; dr<=1; ++dr) {
                    int nl = now.l + dl;
                    int nr = now.r + dr;
                    if(nl < 0 || N <= nl || nr < 0 || N <= nr) {
                        continue;
                    }
                    if(abs(v[nl].second - v[nr].second) < eps) {
                        que.push(state{nl, nr, now.d + dist(now.l, nl) + dist(now.r, nr)});
                    }
                }
            }
        }
        cout << fixed << setprecision(10) << res << endl;
    }
}


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

int over, just;
vector<int> E[2020];

void dfs(int pv, int v, int k)
{
    if (k == 1) just++;
    if (k <= 0) over++;
    for (int nv : E[v])
        if (nv != pv) dfs(v, nv, k-2);
}

int main()
{
    int N, K;
    cin >> N >> K;
    for(int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    
    int ans = -1;
    for (int i = 0; i < N ; i++)
    {
        over = 0;
        vector<int> jvec;
        for (int j : E[i])
        {
            just = 0;
            dfs(i, j, K);
            jvec.push_back(just);
        }
        sort(jvec.begin(), jvec.end());
        for (int jj : jvec) over += jj;
        over -= jvec[E[i].size() - 1];

        if (ans == -1) 
            ans = over;
        else
            ans = min(ans, over);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int n; cin>>n;
    cout << ((n>=1200)?"ARC":"ABC") << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

#define INF 100000000
int main(){
    int n, m;
    while(cin >> n >> m, n||m){
        vector<int> v;
        vector<int> sum;
        for(int i=0; i<n; ++i){
            int a; cin >> a;
            v.push_back(a);
            sum.push_back(a);
        }
        
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                sum.push_back(v[i]+v[j]);
                //cout << sum[i*n+j] << end;
            }
        }
        sort(sum.begin(), sum.end());
        int ans=0;
        for(int i=0; i<sum.size(); i++){
            
            int a = sum[lower_bound(sum.begin(), sum.end(), m-sum[i])-sum.begin()-1];
            if(a+sum[i]==m){
                ans = m;
            }else if(sum[i]+a<=m){
                ans = max(ans, sum[i]+a);
            }
        }
        cout << ans << endl;
        v.clear(); sum.clear();
    }
}


Measured memory_bytes: 10724
#include <iostream>
// #include<queue>
//   #include<vector>
// // #include <cmath>
 #include <string>
// #include <bits/stdc++.h>
using namespace std;
 
 
 
int main(){
	string s1, s2;
	//cin.ignore();

	getline(cin, s1);
// 	cin.ignore();
// 	getline();
cout<<endl;
	getline(cin,s2);
	int count =0;
	//cout<<s1<<s2<<endl;
	for (int i = 0; i < s1.length(); ++i)
	{
		if (s1[i] != s2[i])
	
		{ 
			/* code */ count++;//cout<<s1[i]<<s2[i]<<endl;
		}
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3924
#include<stdio.h>
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a*(b/gcd(a,b));}
int main(){
  long long a,b;
  scanf("%lld %lld",&a,&b);
  printf("%lld\n",lcm(a,b));
  return 0;
}


Measured memory_bytes: 128
a,b,n=map(int,input().split())

def floor(m):
    return int(m)

if n>=b:
    x=b-1
    c= floor(a*x/b) - a*floor(x/b)
else:
    x=n
    c= floor(a*x/b) - a*floor(x/b)

print(c)


Measured memory_bytes: 9116
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

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

  if(n%2) cout<<(double)((n/2)+1)/n<<endl;
  else cout<<(double)1/2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int l=s.length();
    if(l==6)
    {
        if(s[2]==s[3] && s[4]==s[5])
        {
            cout<<"Yes\n";
        }
        else cout<<"No\n";
    }
    else cout<<"No\n";

}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long n, k;
  cin>>n>>k;
  long long l = 0, r = 0;
  for(long long i = 0; i < k; i++) l += i;
  for(long long i = n; i > n - k; i--) r += i;
  long long ans = 0;
  for(long long i = 0; i <= n - k; i++){
    ans += mod(r - l + 1);
    ans = mod(ans);
    l += k + i;
    r += n - k + 1 - (i + 1);
  }
  ans++;
  ans = mod(ans);
  cout << ans <<endl;
  return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;

#define INF 999999999
#define REP(i,n) for(int i=0; i<(int)(n); i++)

int main(){
	int i, j, n, w, b[100], hi;
	double ans;
	
	while(1){
		cin >> n >> w;
		if(!n) break;
		REP(i,100)b[i]=0;
		hi = 0;
		REP(i,n){
			int ins;
			cin >> ins;
			b[ins/w]++;
			if(hi < b[ins/w])hi = b[ins/w];
		}
		int d=0;
		REP(i,100) if(b[i]) d = i;
		ans = 0.01;
		REP(i,d){
			ans += (1-(double)i/(double)d)*((double)b[i]/(double)hi);
		}
		printf("%.13f\n",ans);
	}
	return 0;
}

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


int main(void) {
  int a, b;
  cin >> a >> b;

  cout << (a + b) % 24 << endl;
  
  return 0;
}

Measured memory_bytes: 3512
#include<iostream>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;

int main() {
    int n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    bool ok = true;
    REP(i, a, c) {
        if (s.substr(i-1, 2) == "##") ok = false;
    }
    REP(i, b, d) {
        if (s.substr(i-1, 2) == "##") ok = false;
    }
    if (ok && c > d) {
        ok = false;
        REP(i, b, d+1) {
            if (s.substr(i-2, 3) == "...") ok = true;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}

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

int count(ll N){
  int dig = 0;
  while(N>0){
    N /= 10;
    dig++;
  }
  return dig;
}

int main(void){
  ll N;
  cin >> N;
  int ans=count(N);
  
  for(ll A=1; A*A<=N;A++){
    if(N%A==0){
      ll B=N/A;
      int cur=max(count(A),count(B));
      if(cur<ans) ans=cur;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

if dx > 0 and dy > 0:
    ptn = ['U', 'R', 'D', 'L', 0]
elif dx < 0 and dy > 0:
    ptn = ['U', 'L', 'D', 'R', 0]
elif dx > 0 and dy < 0:
    ptn = ['D', 'R', 'U', 'L', 0]
elif dx < 0 and dy < 0:
    ptn = ['D', 'L', 'U', 'R', 0]
elif dx == 0 and dy > 0:
    ptn = ['U', 'R', 'D', 'L', 1]
elif dx == 0 and dy < 0:
    ptn = ['D', 'R', 'U', 'L', 1]
elif dx > 0 and dy == 0:
    ptn = ['U', 'R', 'D', 'L', 2]
elif dx < 0 and dy == 0:
    ptn = ['D', 'R', 'U', 'L', 2]

ans = ''
if ptn[4] == 0:
    ans += ptn[0] * dy
    ans += ptn[1] * dx

    ans += ptn[2] * dy
    ans += ptn[3] * dx

    ans += ptn[3]
    ans += ptn[0] * (dy + 1)
    ans += ptn[1] * (dx + 1)
    ans += ptn[2]

    ans += ptn[1]
    ans += ptn[2] * (dy + 1)
    ans += ptn[3] * (dx + 1)
    ans += ptn[0]
elif ptn[4] == 1:
    ans += ptn[0] * dy

    ans += ptn[1]
    ans += ptn[2] * dy
    ans += ptn[3]

    ans += ptn[4]
    ans += ptn[0]
    ans += ptn[1]

    ans += ptn[0]
    ans += ptn[1] * 2
    ans += ptn[2] * (dy + 2)
    ans += ptn[3] * 2
    ans += ptn[0]
else:
    ans += ptn[1] * dx

    ans += ptn[0]
    ans += ptn[3] * dx
    ans += ptn[2]

    ans += ptn[2]
    ans += ptn[1] * dx
    ans += ptn[0]

    ans += ptn[1]
    ans += ptn[0] * 2
    ans += ptn[3] * (dy + 2)
    ans += ptn[2] * 2
    ans += ptn[1]
print(ans)

Measured memory_bytes: 3192
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
ll f(ll x){if(x==0) return 0;else return x%10+f(x/10);}
int main(){
    int k;cin>>k;
    int num=0;ll ans=1;ll p=1;
    while(num<k){
        cout<<ans<<endl;
        ll ans1=ans+p;
        ll ans2=ans+p*10;
        if(ans1*f(ans2)<=ans2*f(ans1)){ans=ans1;}
        else{ans=ans2;p*=10;}
        num++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll n, m;
ll a[30];
double p[30];
ll dp[1<<21];

ll INF = 1e18+10;

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

ll lcm( ll a, ll b )
{
  ll d = a/gcd(a,b);

  if( d > (INF+b-1)/b )
    return -1;
  else
    return d*b;
}

int main()
{
  std::cin >> n >> m;

  rep( i, n )
    std::cin >> a[i];

  rep( i, n )
    std::cin >> p[i], p[i] /= 100.0;

  rep( i, 1<<n ) if( i )
  {
    ll mul = 1;

    rep( j, n ) if( i>>j&1 )
    {
      mul = lcm( mul, a[j] );

      if( mul == -1 )
      {
        dp[i] = 0;

        goto end;
      }
    }

    dp[i] = m/mul;

end:;
  }

  rep( i, n ) rep( bit, 1<<n ) if( bit>>i&1 )
    dp[bit] -= dp[bit^(1<<i)];
  
  double ans = 0.0;

  rep( i, 1<<n )
  {
    double prob = 1.0;

    rep( j, n )
      prob *= (i>>j&1 ? p[j] : 1.0-p[j]);

    ans += prob*llabs(dp[i]);
  }

  printf( "%.12f\n", ans );

  return 0;
}


Measured memory_bytes: 11400
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<int> p(n);
		REP(i,n){
			cin >> p[i];
			p[i]--;
		}
		vector<int> v(n);
		REP(i,n) v[p[i]] = i;
		vector<int> a(n);
		vector<int> b(n);
		int mi = INF;
		a[0]  = 1;
		b[0] = v[0]-a[0];
		REP(i,n-1){
			a[i+1] = max(v[i+1]-b[i],a[i])+1;
			b[i+1] = v[i+1]-a[i+1];
			mi = min({mi,b[i+1]-1,a[i+1]-1});
		}
		dpite(ALL(v));
		dpite(ALL(a));
		dpite(ALL(b));
		REP(i,n){
			a[i] -= mi;
			b[i] -= mi;
		}
		pite(ALL(a));
		pite(ALL(b));
	}
	return 0;
}


Measured memory_bytes: 896
import java.util.*;

class UnionFindNode {
  public int index;
  public UnionFindNode parent;

  UnionFindNode(int index) {
    this.index = index;
    this.parent = null;
  }

  public UnionFindNode getRoot() {
/*
    if (this.parent == null) {
      return this;
    }
    UnionFindNode root = this.parent.getRoot();
    this.parent = root;
    return root;
*/

    ArrayList<UnionFindNode> notRoots = new ArrayList<UnionFindNode>();
    UnionFindNode current = this;
    while (current.parent != null) {
      notRoots.add(current);
      current = current.parent;
    }
    UnionFindNode root = current;
    for (UnionFindNode ufn: notRoots) {
      ufn.parent = root;
    }
    return root;
  }

  public static void merge(UnionFindNode n1, UnionFindNode n2) {
    UnionFindNode root1 = n1.getRoot();
    UnionFindNode root2 = n2.getRoot();
    if (root1 != root2) {
      root1.parent = root2;
    }
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);

    int n = s.nextInt();
    int m = s.nextInt();
    int[] p = new int[n+1];
    UnionFindNode[] ufns = new UnionFindNode[n+1];
    for (int i = 1; i <= n; i++) {
      p[i] = s.nextInt();
      ufns[i] = new UnionFindNode(i);
    }

    for (int i = 0; i < m; i++) {
      int x = s.nextInt();
      int y = s.nextInt();
      UnionFindNode.merge(ufns[x], ufns[y]);
    }

    int count = 0;
    for (int i = 1; i <= n; i++) {
      if (ufns[i].getRoot() == ufns[p[i]].getRoot()) {
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 96760
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#define INF 1000001LL
#define INF2 100000001000000LL
using namespace std;

typedef long long ll;

struct cord{
  int d,k;
  vector<ll> c;
  cord(void){d = k = 0;c.clear();}
  cord(vector<ll> v){d = v.size(); k = 0; c = v;}
  bool operator<(const cord a)const{return c[k]<a.c[k];}

  ll dis(cord &a){
    if(a.d != d)return INF;
    ll res = 0;
    for(int i=0;i<d;i++)res += (a.c[i]-c[i]) * (a.c[i]-c[i]);
    return res;
  }
};

struct KDTree{
  int n,d;
  vector<cord> v;

  KDTree(void){n = d = 0;v.clear();}
  KDTree(vector<cord> x){
    n = x.size();
    if(!n)return;
    d = x[0].c.size();
    if(!d)return;
    v = x;
    compose(0,n,0);
  }

  void compose(int l, int r, int depth){
    if(r-l<1)return;
    for(int i=l;i<r;i++)v[i].k = depth;
    sort(v.begin()+l,v.begin()+r);

    compose(l,(l+r)/2,(depth+1)%d);
    compose((l+r)/2+1,r,(depth+1)%d);
  }

  void search(int l,int r,vector<ll>& b, cord& p, int depth, ll& dist){
    if(r-l<1)return;

    int mid = (l+r)/2;
    ll tmp;
    dist = min(dist,p.dis(v[mid]));

    for(int i=0;i<d;i++){
      tmp = b[2*i]-p.c[i];
      if(tmp>0 && tmp*tmp >= dist)return;
      tmp = b[2*i+1]-p.c[i];
      if(tmp<0 && tmp*tmp >= dist)return;
    }

    for(int i=0;i<3;i++){
      if(p.c[depth]>v[mid].c[depth] && i==2)continue;
      if(p.c[depth]<=v[mid].c[depth] && i==0)continue;
      int f = i&1;
      tmp = b[2*depth+f];
      b[2*depth+f] = v[mid].c[depth]; 
      if(f)search(l,mid,b,p,(depth+1)%d,dist);
      else search(mid+1,r,b,p,(depth+1)%d,dist);
      b[2*depth+f] = tmp;
    }
  }
};

int n,q,m;
vector<cord> v;
cord p,r;
vector<ll> tmp;   

int main(){
  vector<ll> box;
  for(int i=0;i<3;i++){
    box.push_back(-INF); 
    box.push_back(INF);
  }

  while(scanf("%d%d",&n,&q)!=EOF,n||q){
    v.resize(n); tmp.resize(3);

    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++)scanf("%lld",&tmp[j]);
      v[i] = cord(tmp);
    }

    KDTree kd(v);

    for(int i=0;i<q;i++){
      scanf("%d",&m);
      double ans = 0;
      ll now, prv;

      for(int j=0;j<3;j++)scanf("%lld",&tmp[j]);
      p = cord(tmp); prv = INF2;
      kd.search(0,n,box,p,0,prv);

      for(int j=1;j<m;j++){
	for(int k=0;k<3;k++)scanf("%lld",&tmp[k]);
	r = cord(tmp); now = INF2;
	kd.search(0,n,box,r,0,now);

	ans += min(sqrt(prv) + sqrt(now), sqrt(p.dis(r)) );
	prv = now; p = r;
      }
      printf("%.9lf\n",ans);
    }
  }
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 107;

struct eT
{
	void setd ( int _u, int _v, int _l )
	{
		u = _u, v = _v, last = _l;
	}

	int u, v, last;
}edge[MAXN*2];

int n;
int ke, la[MAXN];
bool vis[MAXN];
int deg[MAXN];
AR ( int ) q[MAXN];

void init ();
void input ();
void work ();

int dfs ( int now, int nf );

LL getval ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	cin >> n;
	int u, v;
	INIT ( la, -1 ); 
	lp ( i, 1, n ) {
		cin >> u >> v;
		edge[ke].setd ( u, v, la[u] );
		la[u] = ke++;
		edge[ke].setd ( v, u, la[v] );
		la[v] = ke++;
	}
}

void work ()
{
	// main work

	AR ( int ) mp;
	int mini = INF, ret;
	lpi ( i, 1, n ) {
		ret = dfs ( i, -1 );
		if ( ret < mini ) mini = ret, mp.clear (), mp.push_back ( i );
		else if ( ret == mini ) mp.push_back ( i );
	}

	LL ans = 0;
	if ( mp.size () == 1 ) {
		q[0].push_back ( mp[0] );
		ans = getval ();
		for ( int i = la[mp[0]]; ~i; i = edge[i].last ) {
			q[0].clear ();
			q[0].push_back ( mp[0] ), q[0].push_back ( edge[i].v );
			ans = min ( ans, getval () );
		}
	} else {
		for ( auto x : mp ) q[0].push_back ( x );
		ans = getval ();
		--mini;
	}
	cout << mini << " " << ans << endl;
}



int dfs ( int now, int nf )
{
	int ans = 1;
	for ( int i = la[now]; ~i; i = edge[i].last ) if ( edge[i].v ^ nf ) ans = max ( ans, dfs ( edge[i].v, now ) + 1 );
	return ans;
}



LL getval ()
{
	lp ( i, 1, MAXN ) q[i].clear ();
	INIT ( vis, false );
	for ( auto x : q[0] ) vis[x] = true;

	LL nc = q[0].size ();
	int v, size, nd;
	lp ( i, 0, n ) {
		if ( q[i].empty () ) break;
		int size = q[i].size ();
		lp ( j, 0, size ) {
			deg[j] = 0;
			int u = q[i][j];
			for ( int e = la[u]; ~e; e = edge[e].last ) {
				if ( !vis[v = edge[e].v] ) {
					q[i + 1].push_back ( v );
					vis[v] = true;
					++deg[j];
				}
			}
		}
		nd = *max_element ( deg, deg + size );
		if ( !nd ) break;
		nc *= nd;
	}

	return nc;
}

Measured memory_bytes: 256
#include <stdio.h>
 
#define MAX 25
 
typedef struct{
  int l,r,par;
} node;
 
node N[MAX];
 
void init(int);
void Preorder(int);
void Inorder(int);
void Postorder(int);
 
int main(){
  int n,i,id,l,r;
  int p;
   
  scanf("%d" ,&n); 
  init(n);  
 
  for(i = 0 ; i < n ; i++){
    scanf("%d%d%d" ,&id ,&l ,&r);
 
    if(l != -1){
      N[id].l = l;
      N[l].par = id;
    }
    if(r != -1){
      N[id].r = r;
      N[r].par = id;
    }
  }
 
  for(i = 0 ; i < n ; i++){
    if(N[i].par == -1){
      p = i;
      break;
    }
  }
  
  puts("Preorder");
  Preorder(p);
  puts("");
 
  puts("Inorder");
  Inorder(p);
  puts("");
 
  puts("Postorder");
  Postorder(p);
  puts("");
 
  return 0;
}
 
void init(int n){
  int i;
 
  for(i = 0 ; i < n ; i++){
    N[i].par = N[i].l = N[i].r = -1;
  }
}
 
void Preorder(int p){
  if(p != -1){
    printf(" %d" ,p);
    Preorder(N[p].l);
    Preorder(N[p].r);
  }
}
 
void Inorder(int p){
  if(p != -1){
    Inorder(N[p].l);
    printf(" %d" ,p);
    Inorder(N[p].r);
  }
}
 
void Postorder(int p){
  if(p != -1){
    Postorder(N[p].l);
    Postorder(N[p].r);
    printf(" %d" ,p);
  }
}

Measured memory_bytes: 612
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N; scanf("%d", &N);
    vec ans(N+1, 0);
    rep(i, N-1){
        int A; scanf("%d", &A);
        ans[A]++;
    }
    rep(i,N){
        printf("%lld\n", ans[i+1]);
    }
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int A,B,C,X;cin >> A >> B >> C >> X;
  int count = 0;
  rep(i,A+1){
    rep(j,B+1){
      rep(k,C+1){
        if(i*500+j*100+k*50 == X)count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,num=0;
    cin>>n;
    ll ans=log2(n)+1;
    for(int i=0;i<ans;i++)
        num+=pow(2,i);
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 25
 
typedef struct{
  int p;
  int l;
  int r;
}Node;
 
Node T[N];

void preorder(int root){
  int i, j;

  printf(" %d", root);

  if(T[root].l != -1){
    i = T[root].l;
    preorder(i);
    if(T[root].r != -1){
      j = T[root].r;
      preorder(j);
    }
  }else{
    if(T[root].r != -1){
      j = T[root].r;
      preorder(j);
    }
  }
}
 
void inorder(int root){
  int i, j;

  if(T[root].l != -1){
    i = T[root].l;
    inorder(i);
    printf(" %d", root);
    if(T[root].r != -1){
      j = T[root].r;
      inorder(j);
    }
  }else{
    if(T[root].r != -1){
      printf(" %d", root);
      j = T[root].r;
      inorder(j);
    }else{
      printf(" %d", root);
    }
  }
}
 
void postorder(int root){
  int i, j;
  if(T[root].l != -1){
    i = T[root].l;
    postorder(i);
    if(T[root].r != -1){
      j = T[root].r;
      postorder(j);
    }
    printf(" %d", root);
  }else{
    if(T[root].r != -1){
      j = T[root].r;
      postorder(j);
      printf(" %d", root);
    }else{
      printf(" %d", root);
    }
  }
}
 
int main(){
  int i, j, n, id, child, judge;
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    T[i].p = T[i].l = T[i].r = -1;
  }
  for(i = 0; i < n; i++){
    scanf("%d", &id);
    for(j = 0; j < 2; j++){
      scanf("%d", &child);
      if(child != -1){
        T[child].p = id;
        if(j == 0){
          T[id].l = child;
        }else{
          T[id].r = child;
        }
      }
    }
  }
  for(i = 0; i < n; i++){
    if(T[i].p == -1){
      judge = i;
      break;
    }
  }
  printf("Preorder\n");
  preorder(judge);
  printf("\nInorder\n");
  inorder(judge);
  printf("\nPostorder\n");
  postorder(judge);
  printf("\n");

  return 0;
}

Measured memory_bytes: 616
import heapq

n=int(input())
v=list(map(int,input().split()))

heapq.heapify(v)
for i in range(n-1):
    x=heapq.heappop(v)
    y=heapq.heappop(v)
    heapq.heappush(v,(x+y)/2)
print(heapq.heappop(v))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
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 ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

const ll MOD = 1e9+7;
ll n;
string s;

int main() {
    cin >> n >> s;
    vector<ll> alp(26, 1);
    for(int i = 0; i < n; ++i) {
        int check = s.at(i) - 'a';
        alp.at(check)++;
    }

    ll ans = 1;
    for(int i = 0; i < 26; ++i) {
        ans *= alp.at(i);
        ans %= MOD;
    }
    ans--;
    if(ans < 0) cout << ans+MOD << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 512
n = input()
a = list(map(int, input().split()))
m = 0
for i in a:
  if i < 0:
    m += 1
b = list(map(abs, a))
if m % 2 == 0:
  print(sum(b))
else:
  print(sum(b) - 2*min(b))

Measured memory_bytes: 20032
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
 
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
 
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
 

ll n;

bool shichi(int y){
	string yy=to_string(y);
	ll e=0,s=0,t=0;
	rep(i,yy.size()){
		if(yy[i]==*"3"){
			e++;
		}
		if(yy[i]==*"5"){
			s++;
		}
		if(yy[i]==*"7"){
			t++;
		}
	}
	if(e>0&&s>0&&t>0){
		return true;
	}
	else{
		return false;
	}
}

ll dfs(ll x){
	if(x>n){
		return 0;
	}
	ll ret;
	if(shichi(x)&&x!=0){
		ret=1;
	}
	else{
		ret=0;
	}
	ret+=dfs(10*x+3)+dfs(10*x+5)+dfs(10*x+7);
	return ret;
}

int main(){
	cin>>n;
	cout<<dfs(0)<<endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N, M = map(int, input().split())

succ = [0] * N
fail = [0] * N

for i in range(M):
    p, S = input().split()
    p = int(p) - 1

    if S == 'AC':
        succ[p] = 1
    else:
        if succ[p] == 0:
            fail[p] += 1


succ = np.array(succ)
fail = np.array(fail) * succ

print(succ.sum(), fail.sum())


Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1 << 29;
const int MOD = 1000000007;

// 繰り返し二乗法
// a^n mod pを高速に求める
long long modPow(long long a, long long n, long long p) {
    if (n == 0)
        return 1;
    if (n == 1)
        return a % p;
    if (n % 2 == 1)
        // 奇数のとき
        return (a * modPow(a, n - 1, p)) % p;
    // 偶数のとき
    long long t = modPow(a, n / 2, p);
    return (t * t) % p;
}

int main() {
    long long l, r;
    cin >> l >> r;

    // R - L >= 2019 だと (mod 2019) 取ると必ず0
    // その場合、2019^2調べる間に必ず0になりその時点で打ち切ればよい

    long long mod_min = 2020;

    for (long long i = l; i <= r; i++) {
        for (long long j = i + 1; j <= r; j++) {
            long long num = i * j;
            num = modPow(num, 1, 2019);
            // 0になったら出力して終了
            if (num == 0) {
                cout << 0 << endl;
                return 0;
            }
            // 0でなくmod_minより小さかったらmod_minを更新
            if (num < mod_min) mod_min = num;
        }
    }
    cout << mod_min << endl;
}


Measured memory_bytes: 3608