akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int main(){
    int n, k, q;
    int a[100001], p[100001];
    cin >> n >> k >> q;
    for(int i = 1; i <= q; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) p[i] = k - q;
    for(int i = 1; i <= q; i++){
        p[a[i]]++;
    }
    for(int i = 1; i <= n; i++){
        if(p[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    while(true){
        int h,w;
        cin >> h >> w;
        if( h == 0 && w == 0) break;
        rep(i,h){
            rep(j,w){
                if(i % 2 == 0){
                    if(j % 2 == 0) cout << '#';
                    else cout << '.';
                }
                else{
                    if(j % 2 == 0) cout << '.';
                    else cout << '#';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
return 0;
}


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

int main(){
	int N,sum=0,r,l;
  	cin>>N;
  	for(int i=0;i<N;++i){
    	cin>>l>>r;
      	sum+=(r-l+1);
    }
  	cout<<sum<<endl;
  	return 0;
}

Measured memory_bytes: 256
import math
a, b, C = map(float, input().split())
S = a * b * math.sin(math.radians(C)) / 2
c = 0
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(C)))
L = a + b + c
h = 2 * S / a

print(S)
print(L)
print(h)



Measured memory_bytes: 5688
#include<stdio.h>

int main(){
	int N;
	scanf("%d",&N);
	char S[N+1];
	scanf("%s",S);
	int l=0;
	int pl=0;
	for(int i=0;i<N;i++){
		if(S[i]=='(')l++;
		else if(l==0)pl++;
			else l--;
	}
	for(int i=0;i<pl;i++)printf("(");
	for(int i=0;i<N;i++)printf("%c",S[i]);
	for(int i=0;i<l;i++)printf(")");
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main()
    {
        List<int> list = new List<int>();
        for(int i = 0; i<6;i++)
        {
            list.Add(int.Parse(Console.ReadLine()));
        }

        Console.WriteLine(list[4]-list[0] <= list[5] ? "Yay!" : ":(");

    }
}

Measured memory_bytes: 11092
N, M = map(int, input().split())
edges = [[] for i in range(N)]

for i in range(M):
  a, b = map(int, input().split())
  edges[a].append(b)

for i in edges[1]:
  if N in edges[i]:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")    

Measured memory_bytes: 29100
#include <stdio.h>
int main (void){

  int sco , i , sum=0;

  for (i = 0 ; i < 5 ; i++){
    scanf ("%d",&sco);
    if (sco < 40){
      sco = 40;
    }
    sum += sco;
  }

  printf ("%d\n",sum/5);

  return 0 ;

}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))

int R, G, B, N;

int ans = 0;
int ans2 = 0;

int main()
{
	cin >> R >> G >> B >> N;

	for (int i = 0; i <= 3000; i++)
	{
		for (int j = 0; j <= 3000; j++)
		{
//			for (int k = 0; k <= (N - i - j) / B; k++)
			{
				
				//if (i * R + j * G + k * B == N) ans++;
			}

//			cout << (N - (i * R + j * G)) << endl;
			if (i * R + j * G > N) continue;
			if ((N - (i * R + j * G)) % B == 0) ans2++;
//			ans2 += (N - (i * R + j * G)) % B;

		}
	}

	cout << endl;

	cout << ans2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


class Main {
	public static void main(String args[]) {
		
	    Scanner sc = new Scanner(System.in);
	    String  s1 = sc.next();
	    int a = Integer.parseInt(s1);
	    String  s2 = sc.next();
	    int b = Integer.parseInt(s2);
	    if( a < b ){
	        System.out.println( "a < b" );
    	}
	    else if( a > b ){
	    	System.out.println( "a > b" );
	    }
	    else{
	    	System.out.println( "a == b" );
	    }
	}

}

Measured memory_bytes: 17264
#include <bits/stdc++.h>
#define ll unsigned long long

using namespace std;

int m(char a, char b) {
    if(a == '0') {
        return b-'0';
    }
    return (a-'0')*10+(b-'0');
}

int main() {
    vector<char> s;
    for(ll i=0;i<4;i++) {
        char tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
    if(m(s[0],s[1]) == 0 || m(s[0],s[1]) > 12) {
        if(m(s[2],s[3]) == 0 || m(s[2],s[3]) > 12) {
            cout << "NA" << endl;
        }else {
            cout << "YYMM" << endl;
        }
    }else {
        if(m(s[2],s[3]) == 0 || m(s[2],s[3]) > 12) {
            cout << "MMYY" << endl;
        }else {
            cout << "AMBIGUOUS" << endl;
        }
    }
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-

def solve():
    K, X = list(map(int, input().split()))
    left = X - (K-1)
    right = X + (K-1)

    s = ""
    for i in range(left, right+1):
        s += "{} ".format(i)
    print(s[:-1])


if __name__ == "__main__":
    solve()


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

using namespace std;


int a,b,c;

typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<double> vdb;
typedef vector<bool> vbol;
typedef vector<string> vstr;

#define vvll(a,b,c) vector<vector<long long>> c(a,vector<long long>(b,0))
#define vvit(a,b,c) vector<vector<int>> c(a,vector<int>(b,0))
#define vvstr(a,b,c) vector<vector<string>> c(a,vector<string>(b,0))
#define vvbol(a,b,c) vector<vector<bool>> c(a,vector<bool>(b,0))
#define vvdb(a,b,c) vector<vector<double>> c(a,vector<double>(b,0))
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define f_i(a,b) for(int i=0;i<=b;i++)
#define f_j(a,b) for(int j=0;j<=b;j++)


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

    int n;
    cin >> n;
    long long count=0;
    set<long long> st;
    fi(0,n)
    {
        int a;
        cin >> a ;
        if(st.find(a)!=st.end())
        {
            continue;
        }
        else
        {
            count++;
            st.insert(a);
        }
    }
    cout << count << endl;

}

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

int main(){
    int a,b,k;
    bool res;
    cin >> k >> a >> b;
    for(int i = a;i<=b;i++){
        if(i %k== 0){
            cout << "OK" <<endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


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

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int N, M;
    cin >> N >> M;
    ll K = max(N, M);

    vector<vector<int>> x(1 << K, vector<int>(1 << K, -1));
    x[0][0] = x[0][1] = x[1][0] = 0;
    x[1][1] = 1;

    FOR(k, 1, K) {
        int z = 1 << k;
        rep(i, z) rep(j, z) {
            x[i + z][j] = x[i][j + z] = x[i][j];
            x[i + z][j + z] = 1 - x[i][j];
        }
    }

    rep(i, 1 << K) for(int j = 1 << K; --j;) x[i][j] ^= x[i][j - 1];
    rep(j, 1 << K) for(int i = 1 << K; --i;) x[i][j] ^= x[i - 1][j];

    FOR(i, 1, 1 << N) {
        FOR(j, 1, 1 << M) cout << x[i][j];
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 5376
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d,p,x,y;
  cin>>a>>b>>c>>d>>p;
  x=a*p;
  if(p<=c){
    y=b;
  }else{
    y=b+(p-c)*d;
      }
  if(x<y){
    cout<<x<<endl;
  }else{
    cout<<y<<endl;
  }
  return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
    
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
    
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int gcd(int a, int b){
    while(b){
        int t = a;
        a = b;
        b = t%b;
    }
    return a;
}

int lcm(int a, int b){
    return a*b/gcd(a, b);
}


int main() {
    int d; cin >> d;
    cout << "Christmas";
    while(25-d){
        d++;
        cout << " Eve";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
a,b,c,d = input()

for i in range(3**2):
    ls = ["+","+","+"]
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = "-"
    if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
        break
        

Measured memory_bytes: 3060
n, k = list(map(int, input().split()))
an = list(map(int, input().split()))
an = [a-1 for a in an]

visited = [0] * n

r = k
p = 0
detected = False
loop_length = None
while r > 0:
    visited[p] += 1
    if visited[p] >= 3 and not detected:
        detected = True
        loop_length = sum(1 for v in visited if v >= 2)
        #print('loop is found; length = ', loop_length, ' seqs=', [i+1 for i,v in enumerate(visited) if v >= 2])
        #print('shorten p={}, r={}, r_next={}'.format(p+1, r, r % loop_length))
        r %= loop_length
    else:
        p = an[p]
        r -= 1

print(p + 1)


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);


struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    long long N, M; cin >> N >> M;
    vector<int> A(M), B(M);
    for (int i = 0; i < M; ++i) {
        cin >> A[i] >> B[i], --A[i], --B[i];
    }
        
    UnionFind uf(N);
    long long cur = N * (N-1) / 2;
    vector<long long> res;
    for (int i = 0; i < M; ++i) {
        res.push_back(cur);
            
        int a = A[M-1-i], b = B[M-1-i];
        if (uf.issame(a, b)) continue;
        
        long long sa = uf.size(a), sb = uf.size(b);
        cur -= sa * sb;
        uf.merge(a, b);
    }
        
    reverse(res.begin(), res.end());
    for (int i = 0; i < res.size(); ++i) cout << res[i] <<endl;
}

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

#define ll long long
// #define MULTI_TEST

int n, k, q;
int v[100010];

void solve() {
	memset(v, 0, sizeof v);
	cin >> n >> k >> q;
	for(int i=1; i<=q; i++) {
		int a;
		cin >> a;
		v[a]++;
	}
	for(int i=1; i<=n; i++) {
		if(q-v[i] <= k-1) cout << "Yes\n";
		else cout << "No\n";
	}
}



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
#ifdef MULTI_TEST
	int t;
	cin >> t;
	while(t--) {
		solve();
		cout << "\n";
	}
#else
	solve();
	// cout << "\n";
#endif

	return 0;
}


Measured memory_bytes: 1024
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int D=int.Parse(Console.ReadLine());
      switch (D)
      {
        case 22:
        Console.WriteLine("Christmas Eve Eve Eve");
        break;
        case 23:
        Console.WriteLine("Christmas Eve Eve");
        break;
       case 24:
        Console.WriteLine("Christmas Eve");
        break;
        case 25:
        Console.WriteLine("Christmas");
        break;
      }
    
    }
    
  }

}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;
const int INF=1e9;

signed main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m,0);
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int x;
      cin>>x;
      x--;
      a[x]++;
    }
  }
  int ans=0;
  for(int i=0;i<m;i++)if(a[i]==n)ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
long b,r,g,c,s,t;
while(cin>>b>>r>>g>>c>>s>>t){
if(b*b+r*r+g*g+c*c+s*s+t*t==0)break;
cout<<100+b*95+r*63+g*7+c*2+s*3-t*3<<endl;
}
return 0;
}

Measured memory_bytes: 1160
/*************************************************************************
	> File Name: 1.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Blog: https://blog.csdn.net/Pig_cfbsl 
	> Created Time: 2020/6/27 20:02:22
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define LL long long
using namespace std;
int read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
const int maxx=2e5+10;
LL a[maxx],b[maxx],sa[maxx],sb[maxx],k;
int x=1,y=1,cnt=0,mx;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	int n=read(), m=read();
	k=read();
	For(i,1,n){
		a[i]=read();
		sa[i]=sa[i-1]+a[i];
		if(sa[i]<=k) mx=i;
	}
	For(i,1,m){
		b[i]=read();
		k-=b[i];
		if(k<0) break;
		++cnt;
		int j=lower_bound(sa+1,sa+n+1,k)-sa;
		if(sa[j]>k) --j;
//		cout<<j<<" "<<k<<endl;
		mx=max(cnt+j,mx);
	}
	cout<<mx<<endl;
	return 0;

}


Measured memory_bytes: 8248
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi;
vector<lln> vl;
vector<vector<pair<int, int> > > vii;
//vector<pii> vii;
vector<pll> vll;
//vii.clear();
//vii.resize(n + 1);


int arr[maxii];
int arr2[maxii];
bool check[maxii];
bool check2[1000][1000];
int n,m;
int x[]={1,-1,0,0};
int y[]={0,0,-1,1};
int x2[]={1,-1,0,0,1,-1,1,-1};
int y2[]={0,0,-1,1,1,-1,-1,1};
int bx[]={0,0,1,-1,-1,1,1,-1};
int by[]={1,-1,0,0,-1,-1,1,1};
int kx[] = {1,1,2,2,-1,-1,-2,-2};
int ky[] = {2,-2,1,-1,2,-2,1,-1};

bool isvisited(int xx,int yy)
{
    if(xx<1 || yy<1 || xx>n ||yy>m)
    {
        return false;
    }
    else if(check2[xx][yy]==true)
    {
        return false;
    }
    else return true;
}
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    lln x,y,z,a,p,q;
    cin>>x>>y>>z>>a;
    lln aa=x*a;
    lln bb=y*a;
    lln cc=x*z;
    lln dd=y*z;
    lln ans1=max(aa,bb);
    lln ans2=max(cc,dd);
    lln ans=max(ans1,ans2);
    cout<<ans;
}







Measured memory_bytes: 3616
from collections import Counter
N,T=map(int, raw_input().split())
A=map(int, raw_input().split())

A_r=[None for i in range(N)]
n=0
for i in range(N-1,-1,-1):
	n=max(A[i],n)
	A_r[i]=n

B=[]
for i in range(N-1):
	B.append(A_r[i+1]-A[i])


C=Counter(B)

print C[max(B)]

Measured memory_bytes: 23512
fun main(args: Array<String>) {
    val n = readInt()
    val l = readIntList()

    var ans = 0
    for (i in 0 until n) {
        for (j in i until n) {
            for (k in j until n) {
                if (l[i] == l[j] || l[j] == l[k] || l[k] == l[i]) continue
                if (l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) ans++
            }
        }
    }
    println(ans)
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 38656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		var s = Input();
		Console.WriteLine(Math.Max(0, s[0].ToLong() - s[1].ToLong()));
	}


	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

struct fr_t
{
	int c0, c1;
	fr_t(int z0 = 0, int z1 = 0) : c0(z0), c1(z1)
	{
	}
};

bool operator<(const fr_t& a, const fr_t& b)
{
	return 1LL * a.c1 * b.c0 < 1LL * a.c0 * b.c1;
}

fr_t operator+(const fr_t& a, const fr_t& b)
{
	return fr_t(a.c0 + b.c0, a.c1 + b.c1);
}

set<pair<fr_t, int> > que;
int n, par[200005], val[200005];
int rt[200005];
fr_t cdat[200005];

int root(int x)
{
	return rt[x] == x ? x : rt[x] = root(rt[x]);
}

int main()
{
	scanf("%d", &n);
	for(int i = 2; i <= n; i ++) scanf("%d", &par[i]);
	rep1(i, n) scanf("%d", &val[i]);
	rep1(i, n) cdat[i] = fr_t(1 - val[i], val[i]);
	
	rep1(i, n) if(i != 1) que.insert(MP(cdat[i], i));
	
	rep1(i, n) rt[i] = i;
	LL ans = 0;

	while(!que.empty()) {
		int cur = que.begin()->second;
		que.erase(que.begin());
		int cp = root(par[cur]);
		if(cp != 1) que.erase(MP(cdat[cp], cp));
		ans += 1LL * cdat[cp].c1 * cdat[cur].c0;
		cdat[cp] = cdat[cp] + cdat[cur];
		rt[cur] = cp;
		if(cp != 1) que.insert(MP(cdat[cp], cp));
	}
	
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 16640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in).useDelimiter("\\s*,\\s*|\\n");
		
		int VirticalLines = scan.nextInt();
		int hoirizontalLines = scan.nextInt();

		int[] lineNumber = new int[VirticalLines + 1];
		for(int i = 1; i <= VirticalLines; i++) lineNumber[i] = i;

		for(int i = 0; i < hoirizontalLines; i++) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			
			int tmp = lineNumber[a];
			lineNumber[a] = lineNumber[b];
			lineNumber[b] = tmp;
		}
		
		for(int i = 1; i <= VirticalLines; i++) System.out.println(lineNumber[i]);
	}
}

Measured memory_bytes: 17208
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
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<Pi> vPi;
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<Pi> > vvPi;

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

	int n;
	cin >> n;
	map<int, int> a;

	int t;
	rep(i, n) {
		cin >> t;
		if (a[t] == 0) {
			a[t] = 1;
		}
		else {
			a.erase(t);
		}
	}

	cout << a.size() << endl;

	return 0;
}


Measured memory_bytes: 4992
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n = read::<usize>();
    let mut dd = read_vec::<usize>();

    if n % 2 == 1 {
        println!("0");
        return;
    }

    dd.sort();

    let a = dd[n/2-1];
    let b = dd[n/2];
    println!("{}", b - a);
}

Measured memory_bytes: 6396
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<ctime>
#include<iostream>
typedef long long LL;
using namespace std;
const int Maxn = 1e6;
int main()
{
	LL D , N;
	while( cin >> D >> N ){
		if( N == 100 )	N = 101;
		for( int i = 0 ; i <= D ; i++ ){
			if( i == 0 )	N *= 1;
			else	N *= 100;
		}
		cout << N << endl;
	}
}

Measured memory_bytes: 256
//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

int main()
{
	#ifndef ONLINE_JUDGE
	if (fopen("INPUT.txt", "r"))
	{
		freopen ("INPUT.txt" , "r" , stdin);
		//freopen ("OUTPUT.txt" , "w" , stdout);
	}
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	clock_t clk;
	clk = clock();
//-----------------------------------------------------------------------------------------------------------//

	READV(N);
	READV(A);
	READV(B);
	ll ans=(N/(A+B))*A;
	N=N%(A+B);
	ans+=min(N,A);
	cout<<ans<<endl;

//-----------------------------------------------------------------------------------------------------------//


	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[120]; long long ans;
int main(void)
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for (int i=1;i<=n;i++)
        for (int j=i+1;j<=n;j++)
            ans += 1LL * a[i] * a[j];
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, k = [int(x) for x in input().split()]

ans = 0

for i in range(1, n + 1):
    score = i
    cnt = 0
    while score < k:
        cnt += 1
        score *= 2
    ans += (1/n) * (1/2)**cnt

print(ans)

Measured memory_bytes: 38896
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

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

int fpow(int b,int e)
{
	if(e==0) return 1;
	if(e==1) return b;
	int tmp=fpow(b,e/2);
	if(e%2) return b*tmp*tmp;
	else return tmp*tmp;
}

int fpowm(int b,int e,int mod)
{
	if(e==0) return 1;
	if(e==1) return b;
	int tmp=fpow(b,e/2)%mod;
	if(e%2) return b*tmp%mod*tmp%mod;
	else return tmp*tmp%mod;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	char ch;
	cin>>ch;
	if(ch=='A') cout<<"T\n";
	else if(ch=='T') cout<<"A\n";
	else if(ch=='C') cout<<"G\n";
	else if(ch=='G') cout<<"C\n";
	return 0;
}








Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		while(true){
			int temp = sc.nextInt();
			if(temp==0)break;
			else System.out.println(ans(temp));
		}
	}
	public static int ans(int temp){
		int j = 1;
		int count = 0;
		for(int i=2;true;i++){
			j += i;
			if(temp<j)break;
			if((temp-j)%i == 0){
				count++;
			}
		}
		return count;
	}
}

Measured memory_bytes: 18188
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  vector<ll> N(4);
  cin >> N[0] >> N[1] >> N[2] >> N[3];
  sort(N.begin(), N.end());
  if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
typedef pair<long,long> pll;

int n, m, j;
long a, b, t, ans;
vector<pll> ab;
priority_queue<long> q;

int main(){
	cin >> n >> m;
	for (int i = 0; i < n; ++i){
		cin >> a >> b;
		ab.emplace_back(a, b);
	}
	sort(ab.begin(), ab.end(), [](pll& a, pll& b){return a.first < b.first;});
	ans = 0;
	j = 0;
	for (int i = 1; i <= m; ++i){
		while (ab[j].first <= i && j < n){
			q.push(ab[j].second);
			j++;
		}
		if (!q.empty()){
			t = q.top(); q.pop();
			ans += t;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3568
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp34 {
    class Program {
        static void Main(string[] args) {
            int R = int.Parse(Console.ReadLine());

            if (R < 1200) {
                Console.WriteLine("ABC");
            } else if (R < 2800) {
                Console.WriteLine("ARC");
            } else {
                Console.WriteLine("AGC");
            }

        }

    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip> // 文字幅の指定 setw(int), 詰めたい文字の指定 setfill(char)
#include <algorithm> // sort
using namespace std;

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

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define p(x) cout << (x) << endl
#define FOR(i,r,n) for(ll i=(ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n); i>=r; i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) REP(i,0,n)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pb push_back

// 定義する？→左揃えで0埋め
// cout << setfill('0') << left << setw(4) << 12; // "0012"
// http://marycore.jp/prog/cpp/padding-left-right-zero/

const int inf = (int)1e9;
const ll INF = (ll)1e18;

// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

ll gcd (ll a, ll b) {
	while (b > 0) {
		ll t = a % b;
		a = b, b = t;
	}
	return a;
}

ll lcm (ll a, ll b) {
	return (a / gcd (a, b)) * b;
}

bool is_prime (ll n) {
		if (n < 2) return false;
		else if (n == 2) return true;
		else if (n % 2) return false;
		
		double sqrtn = sqrt(n);
		for (ll i = 3; i < sqrtn; i += 2) {
			if (n % i == 0) return false; 
		}
		return true;
}

ll ctoi(char c) {
	return (ll)(c - 48);
}

ll n, k, cnt=0, ans=0;
string s,t;

// ==================== template ============================

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

	cin >> s;
	cout << (s.at(0) == s.at(1) || s.at(1) == s.at(2) || s.at(2) == s.at(0) ? "No" : "Yes") << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,k;
  	ci(n>>k);
  ll ans=0;
  FOR(i,0,n){
    ll a;
    	ci(a);
    if(a>=k){
      ans++;
    }
  }
  co(ans)
}

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

#define endl "\n"
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void header() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void solve() {
    int h, a;
    cin >> h >> a;
    cout << h / a + (h % a != 0) << endl;
}

int main() {
    header();
    solve();
    return 0;
}

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

int main(void) {
	using namespace std;
	int N;
	cin >> N;
	if((N % 10 == 9) || ((N / 10) % 10 == 9)) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}



Measured memory_bytes: 256
#
# Setting Go Stones
#

while (n=gets.to_i)!=0

  stone=[]
  count=[]

  stone<<gets.chomp
  count<<1

  2.upto(n) do |i|
    s=gets.chomp
    if i.even?
      if stone[-1]!=s
        stone[-1]=s
        count[-1]+=1
        # マージ
        (stone.size-2).downto(0) do |j|
          if stone[j]!=s
            stone[j]=s
            count[j]+=count[j+1]
            stone.pop
            count.pop
          else
            break
          end
        end
      else
        count[-1]+=1
      end
    else
      if stone[-1]==s
        count[-1]+=1
      else
        stone<<s
        count<<1
      end
    end
  end

  sum=0
  stone.each_with_index do |s, i|
    sum+=count[i] if s=='0'
  end
  puts sum

end

Measured memory_bytes: 6100
#!/bin/python3

import sys


n = int(input().strip())
ar = list(map(int, input().strip().split(' ')))
ar = sorted(ar,reverse=True)
k = []
se = set(k)
for i in range(len(ar)-1):
    if(ar[i] == ar[i+1]):
        if(ar.count(ar[i])>=4 and len(se) == 0):
            print(ar[i]*ar[i])
            exit(0)
        se.add(ar[i])
    if(len(se)>1):
        break

se = list(se)
if(len(se)<2):
    print("0")
else:
    print(se[0]*se[1])

Measured memory_bytes: 14672
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  vector<int> v(10);
  REP(i,10){
    scanf("%d", &v[i]);
  }

  sort(ALL(v), greater<int>());
  REP(i,3){
    printf("%d\n", v[i]);
  }
  return 0;
}




Measured memory_bytes: 3256
def generate (n)
    $P = Array.new(n, false)
    i = 3
    until i > n
        $P[i] = true
        i += 2
    end
    i = 3
    $P[2] = true
    until i > n
        if ! $P[i]
            i += 2
            next
        end
        j = i + i
        until j > n do
            $P[j] = false
            j += i
        end
        i += 2
    end
end

def is_prime (n)
    return $P[n] ? 1 : 0
end

def solve (n)
    return ->() {
        res = 0
        (n+1).times {|v| res += is_prime(v) }
        res
    }.call
end

generate 1000000 
while s = gets do
    n = s.to_i
    p solve n
end

Measured memory_bytes: 13908
//#include "pch.h"
#include <iostream>

using namespace std;

long long a[100000];

int main() {

	long long n, x;

	cin >> n >> x;

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

	long long ans = 0;

	if (a[0] > x) {
		ans += a[0] - x;
		a[0] = x;
	}


	for (int i = 0; i < n - 1; i++) {
		if (a[i] + a[i + 1] > x) {
			long long buf = a[i] + a[i + 1] - x;
			ans += buf;
			a[i + 1] -= buf;
		}
	}

	cout << ans << endl;


//	system("pause");
	return 0;
}

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

using namespace std;

using ll=long long;

int main(){
	ll N,A,B;
	cin>>N>>A>>B;
	ll m=A-B;
	vector<ll>h(N);
	for(int i=0;i<N;++i){
		cin>>h[i];
	}
	sort(h.begin(),h.end(),greater<int>());
	ll l=-1,r=1e9;
	while(r-l>1){
		ll mid=(l+r)/2,a=0;
		for(auto x:h){
			if(x-mid*B>0)a+=(x-mid*B)/m;
			else break;
			if((x-mid*B)%m)a++;
		}
		if(a<=mid)r=mid;
		else l=mid;
	}
	cout<<r<<endl;
}


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

int main(){
    int n,i,j,swap,count=0;
    cin >> n;
    int a[n];

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

    for(i=0;i<n-1;i++){
        for(j=n-1;j>i;j--){
            if(a[j]<a[j-1]){
                swap = a[j];
                a[j] = a[j-1];
                a[j-1] = swap;
                count++;
            }
        }
    }
    for(i=0;i<n;i++){
        cout << a[i];
        if(i!=n-1) cout << " ";
    }
    cout << endl;
    cout << count << endl;
    return 0;

}



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

using namespace std;

#define pb push_back

const int N = 5e3 + 5, mod = 1e9 + 7;
int n, child[N], cen[2], pterCen, fact[N], invFact[N], a[N], pterA, g[N], pterG;
vector<int> gr[N];

int binpow (int aa, int mm) {
    int ret = 1;
    for (; mm; mm >>= 1, aa = (1LL * aa * aa) % mod) if (mm & 1) ret = (1LL * ret * aa) % mod;
    return ret;
}

void dfs (int u, int p) {
    child[u] = 1;
    bool isCentroid = 1;
    for (int v : gr[u]) if (v != p) {
        dfs(v, u);
        child[u] += child[v];
        if (child[v] > n / 2) isCentroid = 0;
    }
    if (n - child[u] > n / 2) isCentroid = 0;
    if (isCentroid) cen[pterCen ++] = u;
}

int C (int kk, int nn) { return (1LL * (1LL * fact[nn] * invFact[kk]) % mod * invFact[nn - kk]) % mod; }

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    fact[0] = 1;
    for (int i = 1; i < N; ++i) fact[i] = (1LL * fact[i - 1] * i) % mod;
    for (int i = 0; i < N; ++i) invFact[i] = binpow(fact[i], mod - 2) % mod;
    cin >> n;
    for (int _ = 1; _ < n; ++_) {
        int u, v; cin >> u >> v;
        gr[u].pb(v); gr[v].pb(u);
    }

    dfs(1, 1);

    if (pterCen == 2) return cout << (1LL * fact[n / 2] * fact[n / 2]) % mod, 0;

    dfs(cen[0], cen[0]);
    for (int u : gr[cen[0] ]) a[++pterA] = child[u];

    g[pterG] = 1;

    for (int i = 1; i <= pterA; ++i) {
        for (int j = pterG; j >= 0; --j) {
            for (int k = 1; k <= a[i]; ++k) {
                g[j + k] = (g[j + k] + (1LL * (1LL * (1LL * g[j] * C(k, a[i]) ) % mod * C(k, a[i]) ) % mod * fact[k]) ) % mod;
            }
        }
        pterG += a[i];
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
//        cout << g[i] << '\n';
        if (i & 1) ans = (ans - 1LL * g[i] * fact[n - i]) % mod;
        else ans = (ans + 1LL * g[i] * fact[n - i]) % mod;
    }

    cout << (ans + mod) % mod;

    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

  string S;
  vector<int> a(26);
  cin >> S;
  for(int i = 0; i < S.length(); i++){
    a[int(S[i]-'a')] = 1;
  }

  bool found = false;
  for(int i = 0; i < a.size(); i++){
    if(a[i] == 0){
      cout << char(int('a') + int(i)) << endl;
      found = true;
      break;
    }
  }

  if(!found){
    cout << "None" << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cmath>
using namespace std;
int main() {
	int a;
	int b = 2;
	cin >> a;
	for (;;) {
		b*=2;
		if (b > a) {
			b /= 2;
			break;
		}
	}

	cout << b<<endl;
}



Measured memory_bytes: 3120
while 1 do

  number_of_cards, shuffle_times = gets.split.map(&:to_i)
  if number_of_cards == 0 && shuffle_times == 0 then exit end

  cards = []
  for j in 1..number_of_cards do
    cards << j
  end

  for j in 1..shuffle_times do
    point, c = gets.split.map(&:to_i)

    s = number_of_cards - point - c + 1
    stay = []
    shuffle = []
    for k in 1..number_of_cards do
      if k <= s then
        stay << cards[k-1]
      elsif k <= s + c then
        shuffle << cards[k-1]
      else
        stay << cards[k-1]
      end
    end

    cards = stay + shuffle
  end

  puts(cards.pop)

end

Measured memory_bytes: 9804
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  double l;
  cin >> l;
  cout << PREC(20) << l * l * l / 27 << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	string s;
	cin >> s;
	REP(i, 2) {
		REP(q, 2) {
			REP(j, 2) {
				int mew = s[0] - '0';
				if (i == 0) {
					mew += s[1] - '0';
				}
				else mew -= s[1] - '0';
				if (q == 0) {
					mew += s[2] - '0';
				}
				else mew -= s[2] - '0';
				if (j == 0) {
					mew += s[3] - '0';
				}
				else mew -= s[3] - '0';
				if (mew == 7) {
					cout << s[0];
					if (i == 0) {
						cout << "+";
					}
					else cout << "-";
					cout << s[1];
					if (q == 0) {
						cout << "+";
					}
					else cout << "-";
					cout << s[2];
					if (j == 0) {
						cout << "+";
					}
					else cout << "-";
					cout << s[3] << "=7" << endl;
					return 0;
				}
			}
		}
	}
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, k, n) for (int i = (int)(k); i < (int)(n); ++i)
#define rrep(i, k, n) for (int i = (int)(n) - 1; i >= (int)(k); --i)

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vv_ii;
typedef pair<int,ii> i_ii;
typedef vector<i_ii> vi_ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;

template <class T>
inline ostream& operator<<(ostream & o, vector<T> const& v) {
    for (int i = 0; i < (int)(v.size()) - 1; ++i)
        o << v[i] << ' ';
    if (!v.empty())
        o << v.back();
    return o;
}

template <class T, class Q>
inline ostream& operator<<(ostream & o, pair<T,Q> const& p) {
    o << "(" << p.fi << "," << p.se << ")";
    return o;
}

string v[] = {"MON", "TUE", "WED", "THU", "FRI", "SAT"};

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    
    string s;
    cin >> s;
    if (s == "SUN") {
        cout << 7 << '\n';
    }
    else {
        rep(i, 0, 6) {
            if (s == v[i]) {
                cout << 6 - i << '\n';
                break;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack> 
#include <bitset>
#include <queue>
#include <assert.h>
#include <unordered_map>
using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
	    long long l = n - i + 1;
		ans += l * (l + 1) / 2;
	}

	for (int i = 1; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		if (x > y) swap(x, y);
		ans -= 1LL * x * (n - y + 1);
	}

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


Measured memory_bytes: 3296