akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

vector<long long int> inverse;
vector<long long int> f, f_inverse;

void factorial_Initialize(int max){
    vector<long long int> a(max+1,1);
    inverse = a;
    f = a;
    f_inverse = a;

    for (int i=2; i<=max; i++){
        inverse[i]   = MOD - inverse[MOD % i] * (MOD / i) % MOD;
        f[i]         = f[i-1]         * i          % MOD;
        f_inverse[i] = f_inverse[i-1] * inverse[i] % MOD;
    }
}

long long int nCr(int n, int r){
    if(n < r || r < 0) return 0;
    if (n >= f.size()){
        factorial_Initialize(n);
    }
    return f[n] * f_inverse[r] % MOD * f_inverse[n-r] % MOD;
}

vector<vector<int>> graph;
long long int k;

int DFS(int v, int parent_v){
    long long int num = 1;
    int children = 0;
    for(int child_v : graph[v]){
        if(child_v == parent_v) continue;

        num *= DFS(child_v, v);
        num %= MOD;
        children += 1;
    }
    num *= nCr(k-2, children);
    num %= MOD;
    num *= f[children];
    num %= MOD;

    return num;
}

int main(){
    int n;
    cin >> n >> k;
    graph.resize(n);
    factorial_Initialize(k);// necessary since might not done in nCr

    for(int i=0; i<n-1; i++){
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    long long int ans = k;
    int count = 0;
    for(int depth1 : graph[0]){   
        count += 1;
        ans *= DFS(depth1, 0);
        ans %= MOD;   
    }
    ans *= nCr(k-1, count);
    ans %= MOD;
    ans *= f[count];
    ans %= MOD;

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

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

int main(){
    int n; //商品の種類の数
    int m; //人気商品を選ぶ個数
    cin >> n >> m;

    vector<int> votes(n); //要素数は商品の番号、要素は投票数
    for(int i=0; i<n; i++) cin >> votes[i];

    int count = 0; //人気商品になりうる商品の個数を数える
    int sum = 0; //総投票数
    for(int i=0; i<n; i++) sum += votes[i];
    for(int i=0; i<n; i++) if((double)votes[i]/sum >= (double)1/(4*m)) count += 1;

    if(count >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    string s;
    cin >> s;
    cout << "ABC" + s << endl;

    return 0;
}


Measured memory_bytes: 256
def find_idx(s, c):
  idx_lst = [len(i) for i in s.split(c)]
  return idx_lst

s = input()
res = float('inf')
for i in range(97, 97 + 26):
  tmp = find_idx(s, chr(i))
  if tmp:
    res = min(res, max(tmp))
print(res)


Measured memory_bytes: 9044
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using std::cout;
using std::cin;
using std::endl;
using std::pow;
using std::vector;
using std::string;

int main(){
    int res=0,n,i,j;
    cin >> n;
    for(i=1;i<=n;i+=2){
        int num = i,count = 1;
        for(j=2;num!=1;j++){
            int t=1;
            while(num % j == 0){
                t++;
                num /= j;
            }
            count *= t;
        }
        if(count == 8) res++;
    }
    cout << res;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
typedef vector<string> vecst;

int main(){
    ll N, X;
    cin  >> N >> X;
    vecll L(N);
    for(auto& i : L) cin >> i;

    ll ans = (0 <= X ? 1 : 0);
    ll now = 0;
    
    for(auto& i : L){
        now += i;
        if(now <= X) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#
# arc096 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1500 2000 1600 3 2"""
        output = """7900"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1500 2000 1900 3 2"""
        output = """8500"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1500 2000 500 90000 100000"""
        output = """100000000"""
        self.assertIO(input, output)


def resolve():
    A, B, C, X, Y = map(int, input().split())

    ans = float("inf")
    for i in range(2*max(X, Y)+1):
        t = A*max(X-i//2, 0) + B*max(Y-i//2, 0) + C*i
        ans = min(ans, t)
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16076
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const u32 n = scan<u32>();
  for (u32 a = 1; a <= 9; ++a) {
    for (u32 b = 1; b <= 9; ++b) {
      if (a * b == n) {
        std::cout << "Yes" << std::endl;
        return;
      }
    }
  }
  std::cout << "No" << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
n,k = map(int, input().split())
s = input()
ans=''
if s[k-1]=='A':
    ans=s[:k-1]+'a'+s[k:]
elif s[k-1]=='B':
    ans=s[:k-1]+'b'+s[k:]
elif s[k-1]=='C':
    ans=s[:k-1]+'c'+s[k:]
print(ans)

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

int main() {
  
  int N, K; cin >> N >> K; int ans = 0;
  
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  
  sort(vec.begin(), vec.end()); reverse(vec.begin(), vec.end());
  
  for (int i = 0; i < K; i++) ans += vec.at(i);
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        400005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}  

void solve(){
    int n,k;
    cin >> n >> k;
    vector<int>a(n+5);
    FOR(i,1,n+1)cin >> a[i];
    FOR(j,0,k){
        vector<int>pre(4*n+5);
        FOR(i,1,n+1){
            pre[i-a[i]+2*n]++;
            pre[i+a[i]+1+2*n]--;
        }
        FOR(i,1,4*n+1)pre[i] += pre[i-1];
        FOR(i,2*n+1,3*n+1){
            a[i-2*n] = pre[i];
        }
        int mi = inf;
        FOR(i,1,n+1)mi = min(mi,a[i]);
        if(mi >= n)break;
    }
    FOR(i,1,n+1)cout << min(a[i],n) << " ";
}   
signed main()
{
    showoff;
    int T = 1;
    //cin >> T;
    FOR(t,1,T+1){   
        solve();
        //cout << "\n";
    }
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...
 

Measured memory_bytes: 11112
//1

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b)for(int i=(a); i<(b); i++)
#define REP(i,n)FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b){if (a<b){a = b; return 1;}return 0;}
template<typename A, typename B> inline bool chmin(A &a, B b){if (a>b){a = b; return 1;}return 0;}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<int,pii>pip;

const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const bool debug = 0;

int N;
string pat[1000];
vector<int> g[1000];
ll dp[1000];

ll dfs(int u) {
	if (~dp[u]) return dp[u];
	
	ll &res = dp[u];
	res = 0;
	
	if (g[u].size() == 0) res++;
	
	switch (pat[u][0]) {
		case 'E': // ???????????????
			res = 1;
			REP(i, g[u].size()) res = res * dfs(g[u][i]) % MOD;
			break;
		case 'R': // OR
			FOR(i, 1, 1<<g[u].size()) {
				ll now = 1;
				REP(j, g[u].size()) if (i >> j & 1) now = now * dfs(g[u][j]) % MOD;
				res = (res + now) % MOD;
			}
			break;
		case 'A': // Alt
			REP(i, g[u].size()) res = (res + dfs(g[u][i])) % MOD;
			break;
	}
	
	if (pat[u].size() > 1) res++;
	return res %= MOD;
}

int main(){
	cin >> N;
	REP(i, N) cin >> pat[i];
	REP(i, N - 1) {
		int a, b;
		scanf("%d %d", &a, &b);
		g[a - 1].push_back(b - 1);
	}
	
	memset(dp, -1, sizeof(dp));
	cout << dfs(0) << endl;
	
	return 0;
}

Measured memory_bytes: 3304
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int H,A;
  cin>>H>>A;

  cout<<(H+A-1)/A<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n; 
int main(){
	cin>>n;
	if(n&1)cout<<0<<endl;
	else{
		ll sum=0,x=n;
		for(ll t=10;(x/t)!=0;t*=5)
			sum+=x/t;
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	set<string>substrings;
	rep(i, s.size()) {
		string substring;
		for (int j = 0;j < k&&i + j < s.size();j++) {
			substring.push_back(s[i + j]);
			substrings.insert(substring);
		}
	}
	rep(i, k - 1) {
		substrings.erase(substrings.begin());
	}
	cout << *substrings.begin() << endl;
	return 0;
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	int N; int M; int K;
	while(~scanf("%d%d%d", &N, &M, &K)) {
		vector<int> a(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &a[i]);
		vector<int> b(N);
		for(int i = 0; i < N; ++ i)
			scanf("%d", &b[i]);
		vpii ab;
		int ans = 0;
		rep(s, 1 << N) {
			ab.clear();
			rep(i, N) if(s >> i & 1) {
				ab.emplace_back(-a[i], b[i]);
			}
			if((int)ab.size() > K) continue;
			sort(ab.begin(), ab.end());
			int rem = M, sum = 0;
			for(auto p : ab) {
				int num = min(rem, p.second);
				sum += num * -p.first;
				rem -= num;
			}
			sum += rem;
			amax(ans, sum);
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3224
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int z[4]= {1,-1,0,0},zz[4]= {0,0,1,-1},q1,q2;
int n,a[510000],b,cd,mp[510][510],q[510][510],ans;
int dfs(int x,int y) {
	for(int xx=0; xx<4; xx++) {
		int cx=x+z[xx],cy=y+zz[xx];
		if(mp[cx][cy]>mp[x][y]+q[cx][cy]) {
			mp[cx][cy]=mp[x][y]+q[cx][cy];
			dfs(cx,cy);
		}
	}
	return 0;
}
int main() {
	cin>>n;
	for(int x=1; x<=n*n; x++) {
		cin>>a[x];
	}
	for(int x=1; x<=n; x++) {
		for(int y=1; y<=n; y++) {
			q[x][y]=1;
			mp[x][y]=min(min(x,n-x+1),min(y,n-y+1));
		}
	}
	for(int x=1; x<=n*n; x++) {
		q1=(a[x]-1)/n+1;
		q2=a[x]%n;
		if(q2==0) {
			q2=n;
		}
		q[q1][q2]=0;
		ans+=mp[q1][q2]-1;
		mp[q1][q2]-=1;
		dfs(q1,q2);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 21668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define repins(a,n) vector<string> a(n);rep(i,n){cin>>a[i];}
#define repind(a,n) vector<double> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define ins(a) string a;cin>>a;
#define ind(a) double a;cin>>a;
template<class T>
inline void out(T a){cout<<a<<endl; }
inline void out(double a){ printf("%.10f\n", a);} 
#define all(x) (x).begin(),(x).end()
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)
#define range(i,s,c) for(ll i=(s);i<(s+c);++i)
using vell = vector<ll>;
using ves = vector<string>;
using ved = vector<double>;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main()
{
	ins(s);
	ins(t);
	in(a);
	in(b);
	ins(u);
	if(u==s){
		out(a-1);
		out(b);
	}else{
		out(a);
		out(b-1);
	}
}

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

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

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

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

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

const ll MAX_N = 2e5;
ll n;
ll a[MAX_N];

void compress(ll *x){
    //xを座標圧縮
    vector<ll> xs;
    REP(i, n) xs.pb(x[i]);
    SORT(xs);
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    REP(i, n){
        x[i] = lower_bound(xs.begin(), xs.end(), x[i]) - xs.begin();
    }

}

//BIT
ll BIT[MAX_N + 1] = {};
ll sum(ll i){
    //s = A1 + ... + Ai
    ll s = 0;
    while (i > 0){
        s += BIT[i];
        i -= i & -i;
    }
    return s;
}
void add(ll i, ll x){
    //Ai += x
    while(i <= n){
        BIT[i] += x;
        i += i & -i;
    }
}


int main(){
    scanf("%lld", &n);
    REP(i, n) scanf("%lld", &a[i]);
    compress(a);
    
    ll ans = 0;
    REP(i, n){
        ans += i - sum(a[i] + 1);
        add(a[i] + 1, 1);
    }
    printf("%lld\n", ans);
    
}


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

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    string s;
    cin >> s;
    if(s == "a" || s == "i" || s == "u" || s == "e" || s == "o")puts("vowel");
    else puts("consonant");
}

Measured memory_bytes: 256
#include <iostream>
    #include <boost/multiprecision/cpp_int.hpp>
     
    using namespace std;
     
    typedef long long ll;
    typedef boost::multiprecision::uint128_t uint128_t;
     
    int main() {
        int n; ll x;
        cin >> n >> x;
        ll a[n];
        for(int i=0;i<n;++i) cin >> a[n-1-i];
        for(int i=1;i<n;++i) a[i] += a[i-1];
     
        uint128_t ans = (uint128_t(1) << 90);
        for(int k=1;k<=n;++k) {
            uint128_t tmp_ans = x * ll(k+n);
            tmp_ans += 5LL * a[k-1];
            for(int i=1;i<(n+k-1)/k;++i) {
                tmp_ans += ll(2*i+3) * (a[min(n-1,k*(i+1)-1)] - a[min(n-1, k*i-1)]);
            }
            ans = min(tmp_ans, ans);
        }
        cout << ans << endl;
    }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#ifdef LOCAL
#include "print_utils.h"
#endif
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(auto (i) = 0; (i) < (int)(n); ++(i))
#define for1(i, n) for(auto (i) = 1; (i) <= (int)(n); ++(i))
#define ford(i, n) for(auto (i) = (int)(n) - 1; (i) >= 0; --(i))
#define forab(i, a, b) for(auto (i) = (int)(a); (i) < (int)(b); ++(i))

int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}

template <class T>
T remin(T &x, T val) {
    if (x > val) {x = val;}
    return x;
}

template <class T>
T remax(T &x, T val) {
    if (x < val) {x = val;}
    return x;
}

const ll mod = 1000 * 1000 * 1000 + 7;

ll pw(ll a, ll n) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

ll gcd(ll a, ll b) {
    a = std::abs(a);
    b = std::abs(b);
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

struct Q {
    ll n, d;
    Q(): n(0), d(1) {}
    Q(ll nn, ll dd) {
        n = nn;
        d = dd;
        ll g = gcd(n, d);
        n /= g;
        d /= g;
        if (d < 0) {
            n *= -1;
            d *= -1;
        }
    }

    bool operator < (const Q &r) const {
        return n * r.d < r.n * d;
    }
    bool operator <= (const Q &r) const {
        return n * r.d <= r.n * d;
    }
    bool operator == (const Q &r) const {
        return n * r.d == r.n * d;
    }
};


void solve() {
    int a, b;
    a = nxt();
    b = nxt();

    int n = 100, m = 100;
    vector<string> ans(n, string(m, '.'));
    for (int i = n / 2; i < n; ++i) {
        forn(j, m) {
            ans[i][j] = '#';
        }
    }
    --a, --b;
    for (int i = 1; i < n && b > 0; i += 2) {
        for (int j = 1; j < m && b > 0; j += 2) {
            ans[i][j] = '#';
            --b;
        }
    }
    for (int i = n / 2 + 1; i < n && a > 0; i += 2) {
        for (int j = 1; j < m && a > 0; j += 2) {
            ans[i][j] = '.';
            --a;
        }
    }
    cout << n << " " << m << "\n";
    forn(i, n) {
        cout << ans[i] << "\n";
    }
}



int main(int argc, char **argv) {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    double cl0 = clock();
    int t = 1;
//    cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
    std::cerr << "time: " << (clock() - cl0) / CLOCKS_PER_SEC << std::endl;
    return 0;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))

cnt=0
for i in range(1,n):
    v = a[i]+a[i-1]-x
    if v>0:
        cnt+=v
        if a[i]>=v:
            a[i]-=v
        else:
            v-=a[i]
            a[i]=0
            a[i-1]-=v
        
print(cnt)

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;

bool is_odd(vector<int>& a) {
    int n = a.size();

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if ((i &~ (n-1)) == 0)
            ans ^= a[i] & 1;
    }
    return ans == 1;
}

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n; string t;
    cin >> n >> t;

    vector<int> a(n);
    bool has_one = false;
    for (int i = 0; i < n; i++) {
        a[i] = t[i] - '1';
        has_one |= a[i] == 1;
    }

    debug(
        for (int x : a)
            cout << x << ' ';
        cout << endl;
    )

    if (is_odd(a)) {
        cout << 1 << endl;
    } else if (has_one) {
        cout << 0 << endl;
    } else {
        for (int& x : a)
            x >>= 1;
        if (is_odd(a))
            cout << 2 << endl;
        else cout << 0 << endl;
    }

    return 0;
%>

Measured memory_bytes: 5276
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

using P = pair<string,ll>;
void solve(int N,int Q){
    map<ll,P> mp;
    rep(i,N){
        string s;
        ll b,w;
        cin >> s >> b >> w;
        mp[w] = P(s,b);
    }
    rep(i,Q){
        ll q;
        cin >> q;
        bool ok=false;
        for(auto p : mp){
            ll w = p.fi;
            ll b = p.se.se;
            if(q <= w and q>w-b){
                cout <<  p.se.fi << " " << q-(w-b) << endl;
                ok = true;
                break;
            }
        }
        if(!ok){
            cout << "Unknown" << endl;
        }
    }
}

int main(){
    while(1){
        int n,q;
        cin >> n >> q;
        if(n==0 and q==0) break;
        solve(n,q);
    }
}

Measured memory_bytes: 3248
#include<stdio.h>
main(){
  int ma;
  int a[10];
  int b[10];
  int aa;
  int bb;
  int c;
  int d;
  int counta;
  int countb;
  for(ma=0;ma<10;ma++){
    scanf("%d",&a[ma]);
  }
  for(ma=0;ma<10;ma++){
    scanf("%d",&b[ma]);
  }
  for(c=0;c<10;c++){
    for(d=10-1;d>c;d--){
      if(a[d]>a[d-1]){
	aa=a[d];
	a[d]=a[d-1];
	a[d-1]=aa;
      }
      if(b[d]>b[d-1]){
	bb=b[d];
	b[d]=b[d-1];
	b[d-1]=bb;
      }
    }
  }
  counta=a[0]+a[1]+a[2];
  countb=b[0]+b[1]+b[2];
  printf("%d %d\n",counta,countb);
  return 0;
}

Measured memory_bytes: 596
def main():
    k = int(input())
    if (k%2==0 or k%5==0):
        print("-1")
        return

    #7(10**i-1)が9Kで割り切れるような最小の整数iを求める。

    if k%7==0:
        L=9*k//7
    else:
        L=9*k
    i=1
    for n in range(1,L+1):
        i=(10*i)%L
        if i==1:
            print(n)
            return
    print("-1")
    return

main()

Measured memory_bytes: 8940
a=int(input())
yakusuu=[[],[]]

for i in range(2,a+1):
    while not i==1:
        for n in range(2,i+1):
            if i%n==0:
                i=int(i/n)
                if n not in yakusuu[0]:
                    yakusuu[0].append(n)
                    yakusuu[1].append(1)
                else:
                    yakusuu[1][yakusuu[0].index(n)]+=1
                break
count=1
for i in yakusuu[1]:
    count*=i+1

print(count%(10**9+7))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
const long long mod=1e9+7;
const long long INF=1LL<<60;

struct edge{long long to,cost;};
typedef pair<long long,long long> P;

vector<edge> G[100010];
long long d[100010];

void dijkstra(int s,int n){
    priority_queue<P,vector<P>,greater<P> > que;
    fill(d,d+n,INF);
    d[s]=0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top();que.pop();
        long long v=p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
   int n;
   cin>>n;
   vector<long long> u(n),t(n),w(n);
   for(int i=0;i<n-1;i++){
       cin>>u[i]>>t[i]>>w[i];
       u[i]--;t[i]--;
       G[u[i]].push_back({t[i],w[i]});
       G[t[i]].push_back({u[i],w[i]});
   }
   dijkstra(0,n);
   for(int i=0;i<n;i++){
       if(d[i]%2==0)cout<<0<<endl;
       else cout<<1<<endl;
   }

}

   


Measured memory_bytes: 11008
K = int(input())
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(arr[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <math.h>

using namespace std;


int main() {

	long long a, b;int b_f;
	scanf("%lld %lld.%d", &a, &b, &b_f);

	cout << a * b + (a * b_f) / 100 << endl;

	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
using namespace std;
const int maxs = 2e5 + 10;
int main()
{
	int n, m, arr0[maxs], arr1[maxs], a1, a2;
	cin >> n >> m;
	for(int i = 0; i < n; i++) {
		arr0[i] = 0;
		arr1[i] = 0;
	}
	for(int i = 0; i < m; i++) {
		cin >> a1 >> a2;
		if(a1 == 1 && a2 != 1) {
			arr1[a2 - 1] = 1;
		}
		if(a2 == 1 && a1 != 1) {
			arr1[a1 - 1] = 1;
		}
		if(a1 == n && a2 != n) {
			arr0[a2 - 1] = 1;
		}
		if(a2 == n && a1 != n) {
			arr0[a1 - 1] = 1;
		}
	}
	for(int i = 0; i < n; i++) {
		if(arr1[i] == 1 && arr0[i] == 1) {
			cout << "POSSIBLE";
			return 0;
		}
	}
	cout << "IMPOSSIBLE"; 
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
typedef long long ll;

int main(){
	ll n, k, a, dummy;
	scanf("%lld %lld",&n,&k);
	a = n%k;
	dummy = a-k;
	if(dummy<0) dummy*=-1;
	if(dummy<a) printf("%lld",dummy);
	else printf("%lld",a);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int t, x;
    cin >> t >> x;
    
    cout << (float)t/x << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int c = x/105;
    boolean flag = false;

    while(flag == false){
      if(c==1000000){
        break;
      }
      if(100*c<=x&&105*c>=x){
        flag = true;
      }else{
        c += 1;
      }
    }

    if(flag){
      System.out.println("1");
    }else{
      System.out.println("0");
    }



  }
}

Measured memory_bytes: 21972
import decimal


def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a % b)


def lcm(a, b):
    g = euclid(a, b)
    # print(g)
    # print(a * b)

    return a * b // g


if __name__ == '__main__':
    N = int(input())
    ans = 1
    for i in range(N):
        T = int(input())
        ans = lcm(ans, T)

    print(ans)


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

int main() {
  int N;
  cin >> N;
  if (((N%10 == N%100/10) && (N%100/10 == N%1000/100))
      || ((N%100/10 == N%1000/100) && (N%1000/100 == N/1000))){
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int arr[6];
	for(int i=0;i<5;i++)
		cin >> arr[i];
	for(int i=0;i<5;i++){
		if(arr[i]==0)
			cout << i+1 << endl;
	}
    return 0;
 }

Measured memory_bytes: 3596
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl
#define CE cout<<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[200010];
bool r,ra,rb,rc[200010];
string s,sa,sb,sc;
char ca,cb,cc,cd[200010];
vector<ll> va,vb,vc,vd,ve;
set<int> st;

int main(){
    cin>>s;
    cin>>n;
    int lp=0,ep=0,wlm=0,wl=0,wlem=0;
    bool looped=false,rp=true;
    for(int i=1;i<s.size();i++){
        lp=i;
        if(s[i]!=s[i-1]){
            rp=false;
            break;
        }
    }
    ep=s.size()-lp;
    //C ep<<" "<<lp E;
    
    
    for(int i=0;i<s.size();i++){
        int v=(lp+i)%s.size(),vb=v-1;

        if(v==0){
            looped=true;
            wlem+=wl/2;
        }

        if(vb<0)vb+=s.size();
        if(s[v]!=s[vb]){
            //C wl E;
            wlm+=wl/2;
            if(!looped)wlem+=wl/2;
            wl=1;
            
        }
        else{
            wl++;
        }
    }
    wlm+=wl/2;

    if(!rp)C (lp/2)+wlm*(n-1)+wlem E;
    else C s.size()*n/2 E;



    //C ep E;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

int main() {
	int N;
	cin >> N;
	vi a(N);
	rep(i, N) {
		cin >> a[i];
	}
	vi b(N);
	if (N % 2 == 0) {
		int r = N / 2;
		int l = r - 1;
		rep(i, N) {
			if (i % 2 == 0) {
				b[r] = a[i];
				r++;
			}
			else {
				b[l] = a[i];
				l--;
			}
		}
	}
	else {
		int l = N / 2;
		int r = l + 1;
		rep(i, N) {
			if (i % 2 == 0) {
				b[l] = a[i];
				l--;
			}
			else {
				b[r] = a[i];
				r++;
			}
		}
	}
	rep(i, N) {
		cout << b[i];
		if (i == N - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}


	return 0;
}

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

#define llint long long int

using namespace std;

int main()
{
    int N;
    llint D;

    cin >> N >> D;

    vector<llint> d(N);

    for (int i = 0; i < N; i++)
    {
        llint X, Y;

        cin >> X >> Y;

        d[i] = X * X + Y * Y;
    }
    sort(d.begin(), d.end());

    auto it = upper_bound(d.begin(), d.end(), D * D);

    cout << it - d.begin() << endl;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
int a[1000005];
int dp[1000005];
int ans=0;
int fun(int n)
{
	if(n==0)
		return 0;
	if(n==1)
		return abs(a[0]-a[1]);
	if(n==2)
		return min(abs(a[0]-a[2]),abs(a[0]-a[1]) + abs(a[1]-a[2]));
	
		
	 if(dp[n]!=-1)
	 	return dp[n];



	return dp[n]=min(abs(a[n]-a[n-1])+fun(n-1),abs(a[n]-a[n-2])+fun(n-2));
}

int main()
{
   
	  int n;
	  cin>>n;
	 memset(dp,-1,sizeof(dp));
	  for(int i=0;i<n;i++)
	  {
	  	cin>>a[i];
	  }
	  cout<< fun(n-1);

   
}

Measured memory_bytes: 7936
def tobin(num, pos):
    try:
        return int(format(num, 'b')[-(pos)])
    except:
        return 0

N = int(input())
shogens = {}
for person in range(1, N+1):
    Ai = int(input())
    inlist = []
    for i in range(Ai):
        x, y = map(int, input().split())
        inlist.append((x,y))
    shogens[person] = inlist

truth = [0]

for num in range(2**N):
    katei = []
    for pos in range(1, N+1):
        katei.append(tobin(num, pos))
    tf = True
    
    for person in range(1, N+1):
        if tf == False:
            break
        shogen = shogens[person]
        for tpl in shogen:
            if katei[person-1] == 1:
                if tpl[1] != katei[tpl[0]-1]:
                    tf = False
                    break
    if tf:
        truth.append(katei.count(1))
print(max(truth))

Measured memory_bytes: 3444
import sys
class ofa():
 def cal(self,n):
  list1=map(int,raw_input().split())
  dic={}
  #while True:
  x=0
  
  
  while True:
   for i in range(n):    
    if list1[i] not in dic:
     dic[list1[i]]=1
    else :
     dic[list1[i]]+=1
   pre=list(list1)
   for i in range(n):    
    for j in dic.keys():	 
	 if list1[i]==j:	  
	  list1[i]=dic[j]
	  break   
   x+=1   
   if pre==list1:
    break
   dic.clear()
  print x-1
  for i in range(n):
   if i==n-1:
    sys.stdout.write(str(list1[i]))
   else :
    sys.stdout.write(str(list1[i])+" ")
  print "" 
if __name__=="__main__":
 while True:
  n=input()
  if n==0:break
  ans=ofa()
  ans.cal(n)

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


int main()
{
    long long N, A, B;
    cin >> N >> A >> B;
    vector<long long> X(N+1);
    for( int i = 1; i <= N; ++i ) cin >> X[i];


    long long ans = 0;
    for( int i = 1; i < N; ++i ) ans += min( A*(X[i+1]-X[i]), B );
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	// read one word/char/int separated by space(s).
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 8000000), 8000000)

	// read one line.
	// sc.Split(bufio.ScanLines)
}

type node struct {
	val    int
	parent int
}

type nodes []node

func main() {
	// var n, q int
	// fmt.Scanf("%d %d", &n, &q)
	n := nextInt()
	q := nextInt()
	ns := make(nodes, n+1)
	for i := 0; i < n-1; i++ {
		// var parent, child int
		parent := nextInt()
		child := nextInt()
		fmt.Scanf("%d %d", &parent, &child)
		ns[child].parent = parent
	}

	for i := 0; i < q; i++ {
		// var a, b int
		// fmt.Scanf("%d %d", &a, &b)
		a := nextInt()
		b := nextInt()
		ns[a].val += b
	}
	for i := 1; i < len(ns); i++ {
		ns[i].val += ns[ns[i].parent].val
		fmt.Printf("%d", ns[i].val)
		if i == len(ns)-1 {
			fmt.Print("\n")
			continue
		}
		fmt.Print(" ")
	}
}


Measured memory_bytes: 22420
#include<bits/stdc++.h>
using namespace std;
void *wmem;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> int Factor_L(T N, T fac[], int fs[]){
  T i;
  int sz=0;
  if(N%2==0){
    fac[sz] = 2;
    fs[sz] = 1;
    N /= 2;
    while(N%2==0){
      N /= 2;
      fs[sz]++;
    }
    sz++;
  }
  for(i=3;i*i<=N;i+=2){
    if(N%i==0){
      fac[sz] = i;
      fs[sz] = 1;
      N /= i;
      while(N%i==0){
        N /= i;
        fs[sz]++;
      }
      sz++;
    }
  }
  if(N > 1){
    fac[sz] = N;
    fs[sz] = 1;
    sz++;
  }
  return sz;
}
template<class T> int Divisor_L(T N, T res[], void *mem = wmem){
  T *fc;
  int *fs, fsz, i, j, k, s, sz=0;
  fc = (T*)wmem;
  fs = (int*)(fc+100);
  fsz =Factor_L(N, fc, fs);
  res[sz++] = 1;
  for(i=0;i<fsz;i++){
    s = sz;
    k = s * fs[i];
    for(j=0;j<k;j++){
      res[sz++] = res[j] * fc[i];
    }
  }
  sort(res, res+sz);
  return sz;
}
template<class T> inline T GCD_L(T a,T b){
  T r;
  while(a){
    r=b;
    b=a;
    a=r%a;
  }
  return b;
}
char memarr[96000000];
int A;
int B;
int K;
int ds;
int d[100];
int main(){
  wmem = memarr;
  rd(A);
  rd(B);
  rd(K);
  ds =Divisor_L(GCD_L(A, B), d);
  wt_L(d[ds-K]);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int A, B, K;
// int ds, d[100];
// {
//   rd(A,B,K);
//   ds = Divisor(gcd(A,B), d);
//   wt(d[ds-K]);
// }


Measured memory_bytes: 256
#include<stdio.h>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;
struct renwu{
  char m[100];
  int t;
}a[100000];
int main()
{
    int n;int p;
    int x=0;
    scanf("%d%d",&n,&p);
    int k=0,l=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%s%d",a[i].m,&a[i].t);
    }
    int head=1;
    int tail=n+1;
    while(head!=tail)
    {
        k=min(p,a[head].t);
        x+=k;
        a[head].t-=k;
        if(a[head].t>0)
        {
           a[tail]=a[head];tail=(tail+1)%100005;
        }
        else
        {
          printf("%s %d\n",a[head].m,x);
        }
        head=(head+1)%100005;
    }
    return 0;
}

Measured memory_bytes: 12860
unittest
{
	assert( [ "5 7 5" ].parse.expand.solve == 7 );
	assert( [ "1 1 7" ].parse.expand.solve == 7 );
	assert( [ "-100 100 100" ].parse.expand.solve == -100 );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abc = input.front.split.to!( long[] );
	return tuple( abc[ 0 ], abc[ 1 ], abc[ 2 ] );
}

auto solve( long a, long b, long c )
{
	if( a == b ) return c;
	if( a == c ) return b;
	return a;
}


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

	int main(){
      long X,M,C;
      M = 100;
      C = 0;
      
      cin >> X;
      
      for(;;){
        M += M/100;
        C++;
        if(X <= M){
          cout << C;
          break;
        }
        
      }
        
      
      

	}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;
int A[1000011],n;
int binarySearch(int key){
  int left=0;
  int right=n;
  int mid;
  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid]){
      return 1;
    }
    if(key>A[mid]){
      left=mid+1;
    }else if(key<A[mid]){
      right=mid;
    }
  }
    return 0;
}
int main(){
  int i,q,k,sum=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> k;
    if(binarySearch(k)){
      sum++;
    }
  }
  cout << sum << endl;

  return 0;
}




Measured memory_bytes: 3384
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define rrng(obj) (obj).rbegin(), (obj).rend()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<pii>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,v.size())i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(v.size())o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
bool comp(pair<char,int> a,pair<char,int> b){
  return a.se<b.se;
}
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------
void Main(){
  int n;
  cin>>n;
  vi x(n);
  cin>>x;
  double ave=0;
  rep(i,n){
    ave+=x[i];
  }
  ave/=n;
  ave=floor(ave+0.5);
  ll ans=0;
  rep(i,n){
    ans+=(x[i]-ave)*(x[i]-ave);
  }
  cout<<ans<<endl;

} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque
import math

# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7

def divide(k):
    return pow(k, MOD-2, MOD)


def make_nck(n):
    ret = [1]
    for i in range(1, n+1):
        ret.append((ret[-1] * (n + 1 - i) * divide(i)) % MOD)

    # print(ret)
    return ret

def make_nigojyo(n):
    ret = [1]

    for i in range(1, n+1):
        ret.append((ret[-1] * 25) % MOD)

    # print(ret)
    return ret


def solve():
   a = getList()
   print(len(list(set(a))))



def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 65516
#include <stdio.h>

int main(void)
{
        int d, n, a;

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

        if (d == 0){
                a = n;
                if (n == 100) a = n + 1;
        }

        else if (d == 1){
                a = 100 * n;
                if (n == 100) a = 100 * (n + 1);
        }

        else{
                a = 10000 * n;
                if (n == 100) a = 10000 * (n + 1);
        }


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

        return 0;
}


Measured memory_bytes: 128