akhauriyash/Code-Regression huggingface dataset:
// ===========================================
// 20.03.07 Atcoder Beginner Contest 157. D - Friend Suggestions (Union find)
// 
// 
// ===========================================


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=1; i<=n; i++)
#define ET "\n"
#define CLR(arr) memset(&arr, 0, sizeof(arr))
#define PAIR pair<int, int>
const ll INF = 1LL << 50;


struct sStat{
    int parent;     //union find parent
    int lv;         //highest level of union find
    int num;        //number of friend
};

int uFind(int u, struct sStat p[]){
    if(u == p[u].parent) return u;
    else return p[u].parent = uFind(p[u].parent, p);
}

void unite(int u, int v, struct sStat ss[]){
    u = uFind(u, ss);
    v = uFind(v, ss);
    
    if(u == v) return;
    if(ss[u].lv > ss[v].lv) u^=v^=u^=v;
    ss[v].lv += ss[u].lv + 1;
    ss[u].parent = v;
}

int main(){
    
    
    int n, m, k; cin >> n >> m >> k;
    
    const int MAXN = n + 5;
    sStat frnd[MAXN]; CLR(frnd);
    
    //-----------------------------------------
    
    rep(i,n){
        frnd[i].parent = i;
    }
    
    rep(i,m){
        int a, b; cin >> a >> b;
        frnd[a].num++;
        frnd[b].num++;
        unite(a, b, frnd);
    }
    
    /*
    rep(i,n){
        cout << "lv & num of " << i << " is now : ";
        cout << frnd[i].parent << "L ";
        rep(j,n) cout << frnd[i].lv << " ";
        rep(j,n) cout << frnd[i].num << " ";
        cout << ET;
    }
    
    cout << ET << ET;
    */
    
    rep(i,k){
        int a, b; cin >> a >> b;
        if(uFind(a, frnd) == uFind(b, frnd)){
            frnd[a].num++;
            frnd[b].num++;
        }
        
    }
    
    /*
    rep(i,n){
        cout << "lv & num of " << i << " is now : ";
        cout << frnd[i].parent << "L ";
        rep(j,n) cout << frnd[i].lv << " ";
        rep(j,n) cout << frnd[i].num << " ";
        cout << ET;
    }
    */
    
    
    //-----------------------------------------
    for(int i = 1; i <= n; i++){
        int p = uFind(i, frnd);
        cout << frnd[p].lv - frnd[i].num << " ";
    }
}


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

int main(){
  int d,n; cin >> d >> n;
  if(d==0) d=1;
  else if(d==1) d=100;
  else d=10000;
  
  if(n==100){
    cout << 101*d << endl;
  }else{
    cout << n*d << endl;
  }
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	str := strings.Split(nextString(), "")
	q, _ := nextInt()

	for i := 0; i < q; i++ {
		cmd := nextString()
		a, _ := nextInt()
		b, _ := nextInt()

		// fmt.Println(cmd, a, b, str)

		if cmd == "print" {
			fmt.Println(strings.Join(str[a:(b+1)], ""))
		} else if cmd == "reverse" {
			part := make([]string, b+1-a)
			copy(part, str[a:(b+1)])
			// fmt.Println(part)
			for j := 0; j <= b-a; j++ {
				// fmt.Println(str[a+j], part[(b-a)-j])
				str[a+j] = part[(b-a)-j]
			}
		} else {
			p := strings.Split(nextString(), "")
			for j := a; j <= b; j++ {
				str[j] = p[j-a]
			}
		}
	}
}



Measured memory_bytes: 1656
import math
X=int(input())
under = math.floor(X / 105)
top = math.floor(X/100)
#print("under,top = {},{}".format(under,top))
if X / 105==under or X/100==top or  top - under > 0:
#if top - under > 0:
    print("1")
else:
    print("0")
#for i in range(under, top + 1):
    

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define Test(tt) cout << "Case #" << tt << ": "

using namespace std;



int main() {
#ifdef HOME
    ifstream cin("B.in");
    ofstream cout("B.out");
#endif
   	int	i, j, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;

    vector<int> p(n * n + 1);
    for(i = 1; i <= n * n; i++) {
    	cin >> p[i];
    }

    vector<vector<int>> dst(n + 1, vector<int>(n + 1));
    for(i = 1; i <= n; i++) {
    	for(j = 1; j <= n; j++) {
    		dst[i][j] = min(min(j, n - j + 1), min(i, n - i + 1));
    	}
    }

    vector<int> dl = {-1, 0, 1, 0}, dc = {0, -1, 0, 1};
    vector<vector<bool>> vis(n + 1, vector<bool>(n + 1, 1));

    int ans = 0;
    for(i = 1; i <= n * n; i++) {
    	int l = (p[i] - 1) / n + 1;
    	int c = p[i] % n;

    	if(c == 0) {
    		c = n;
    	}

    	queue<pair<int, int>> Q;
    	Q.push({l, c});

    	dst[l][c]--;
    	vis[l][c] = 0;

    	while(Q.size()) {
    		auto cur = Q.front();
    		Q.pop();
    		for(int dir = 0; dir < 4; dir++) {
    			int l = cur.first + dl[dir];
    			int c = cur.second + dc[dir];
    			if(l > 0 && c > 0 && l <= n && c <= n && dst[l][c] > dst[cur.first][cur.second] + vis[l][c]) {
    				dst[l][c] = dst[cur.first][cur.second] + vis[l][c];
       				Q.push({l, c});
    			}
    		}
    	}

    	ans += dst[l][c];
    }

    cout << ans << "\n";
    
    return 0;
}

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

const int P = 1000000007;
int n, m, cnt[505], fac[505], ifac[505], dp[2][505][505];

int power(int a, int x) {
	int ans = 1;
	for (; x; x >>= 1, a = 1ll * a * a % P)
		if (x & 1) ans = 1ll * ans * a % P;
	return ans;
}

int main() {
	scanf("%d%d", &m, &n);
	for (int x; m--;) scanf("%d", &x), ++cnt[x];
	for (int i = fac[0] = 1; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % P;
	ifac[n] = power(fac[n], P - 2);
	for (int i = n; i; --i) ifac[i - 1] = 1ll * ifac[i] * i % P;
	dp[n + 1 & 1][0][0] = 1;
	for (int i = n; i >= 0; --i) {
		memset(dp[i & 1], 0, sizeof dp[i & 1]);
		for (int j = 0; j <= n + 1; ++j)
			for (int k = 0; k + max(0, j - 1) <= n; ++k)
				if (dp[i + 1 & 1][j][k])
					for (int l = 0; j + l <= n + 1 && k + l * i + max(0, j + l - 1) <= n; ++l)
						dp[i & 1][j + l][k + l * i] = (dp[i & 1][j + l][k + l * i] + 1ll * dp[i + 1 & 1][j][k] * ifac[l]) % P;
		for (int j = 0; j <= n + 1; ++j)
			for (int k = 0; k + max(0, j - 1) <= n; ++k)
				dp[i & 1][j][k] = 1ll * dp[i & 1][j][k] * power(max(0, k - j * (i - 1)), cnt[i]) % P;
	}
	int ans = 0;
	for (int j = 1; j <= n + 1; ++j)
		ans = (ans + 1ll * dp[0][j][n - j + 1] * (j & 1 ? 1 : -1) * fac[j]) % P;
	printf("%d\n", (ans + P) % P);
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1000000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll N;
char field[610][610];

int main(){
    cin >> N;
    rep(i,N) rep(j,N) cin >> field[i][j];
    rep(i,N*2) rep(j,N*2) field[i][j] = field[i%N][j%N];
    ll ans = 0;
    rep(i,N){
        rep(j,N){
            rep(k,N){
                if(field[i+j][k] != field[i+k][j]) goto ES;
            }
        }
        ans++;
        ES:;
    }
    cout << ans * N << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





string str_max(string &a, string &b){
    if(a.size() > b.size()) return a;
    if(a.size() < b.size()) return b;
    REP(i, a.size()){
        if(a[i] != b[i]){
            if(a[i] > b[i]) return a;
            if(a[i] < b[i]) return b;
        }
    }
    return a;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m);
    REP(i, m){
        cin >> a[i];
        a[i]--;
    }
    
    sort(a.begin(), a.end());
    
    vector<string> dp(10005);
    vector<ll> need = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    REP(i, m){
        dp[need[a[i]]] = to_string(a[i] + 1);
    }
    for(ll i = 0; i <= n; i++){
        for(ll j = 0; j < m; j++){
            if(i >= need[a[j]]){
                if(dp[i - need[a[j]]] == "") continue;
                string t = to_string(a[j] + 1) + dp[i - need[a[j]]];
                dp[i] = str_max(dp[i], t);
            }
        }
        // cout << dp[i] << endl;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 29568
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

#ifndef ULLONG
typedef unsigned long long ULLONG;
#endif
#ifndef LLONG
typedef long long LLONG;
#endif
template <class _Ty> static _Ty tp_abs(const _Ty& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _Ty> static _Ty tp_min(_Ty a, _Ty b) {
	return a < b ? a : b;
}
template <class _Ty> static _Ty tp_max(_Ty a, _Ty b) {
	return a > b ? a : b;
}
template<class T> static void getint(T& a) {
	const char* fmt = " %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class T> static void getint(T& a, T& b) {
	const char* fmt = " %d %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class T> static void getint(T& a, T& b, T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static const int EduDp_INF = 1100000000;
static const int MOD_NUM = 1000000007;
static void D_task();

#if 1
int main()
{
	D_task();
	fflush(stdout);
	return 0;
}
#endif

static void D_task()
{
	int N, W;
	getint(N, W);

	std::vector<int> wn(N + 1, 0);
	std::vector<LLONG> vn(N + 1, 0);
	
	for (int i = 1; i <= N; i++) {
		int w, v; getint(w, v);
		wn[i] = w;
		vn[i] = v;
	}
	
	std::vector<std::vector<LLONG>> dp(W + 1);
	for (int i = 0; i <= W; i++) {
		dp[i].resize(N + 1, 0);
	}

	for (int i = 1; i <= N; i++) {
		for (int w = 1; w <= W; w++) {
			dp[w][i] = dp[w][i - 1];
			if (w >= wn[i]) {
				dp[w][i] = tp_max<LLONG>(dp[w][i], dp[w - wn[i]][i - 1] + vn[i]);
			}
		}
	}
	
	printf("%lld\n", dp[W][N]);
}

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

// [l,r) の区間から tgt をにぶたん
template<typename T>
T *binSearch(T *l, T *r, T tgt){
  T *m = l + (r-l)/2;
  if (*m == tgt) return m;
  if (r-l <= 1) return NULL;
  return *m<tgt? binSearch(m+1, r, tgt): binSearch(l, m, tgt);
}
  
int main(void){
  int n,q,ans;
  int s[100000];
  
  cin >> n;
  for (int i=0; i<n; i++) cin >> s[i];
  cin >> q;
  ans = 0;
  for (int i=0; i<q; i++){
    int t, *pos;
    cin >> t;
    if (pos = binSearch(s,s+n,t)) ans++;
//    if (pos) cout << "(" << (pos-s) << ")" << endl;
//    else cout << "null" << endl;
  }
  cout << ans << endl;
  return 0;
}



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

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

int main(){
    int n, m; cin >> n >> m;
    vector <vector <int>> G(n + 1);
    rep(i, m){
        int from, to; cin >> from >> to;
        G.at(from).push_back(to);
        G.at(to).push_back(from);
    }

    // rep(i, n + 1){
    //     rep(j, G.at(i).size())cout << G.at(i).at(j) << " ";
    //     cout << endl;
    // }

    vector <int> one_pattern;
    rep(i, n){
        if(i == 0) continue;
        one_pattern.push_back(i + 1);
    }

    int ans = 0;

    do{
        vector <int> now_pattern(1, 1);
        copy(one_pattern.begin(), one_pattern.end(), back_inserter(now_pattern));
        // rep(i, one_pattern.size()) cout << one_pattern.at(i) << " ";
        // cout << endl;
        bool ok = true;
        rep(i, n){
            if(i == 0) continue;
            int now, pre;
            now = now_pattern.at(i); pre = now_pattern.at(i - 1);
            //if(find(G.at(pre).begin(), G.at(pre).end(), now)) continue;

            if(G.at(pre).size() == 0) ok = false;
            rep(j, G.at(pre).size()){
                if(G.at(pre).at(j) == now){
                    ok = true;
                    break;
                }
                ok = false;
            }
            if(ok) continue;
            break;
        }

        if(ok) ans += 1;
        // if(ok){
        //         rep(i, one_pattern.size()) cout << one_pattern.at(i) << " ";
        //         cout << endl;
        //     }

    } while (next_permutation(one_pattern.begin(), one_pattern.end()));

    cout << ans << endl;
}

Measured memory_bytes: 3516
N = int(input())

if N == 3:
    ret = [2, 5, 63]
else:
    ret = []
    
    if N <= 15000:
        if N % 3 == 0:
            b = 4
        else:
            b = 2
        a = N - b
    else:
        a = 15000 - N%2
        b = N - a
        
    for i in range(1, a+1):
        ret.append(2*i)
    for i in range(b):
        ret.append(3*(2 * i + 1))
    assert len(ret) == N
print(' '.join([str(_) for _ in ret]))

Measured memory_bytes: 5108
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define Phuong // <3
typedef pair<int,int> ii;

const int inf = 1e9+1;
const int mod = 1e9 +7;
int w,h;
vector<vector<int>> dp;


int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cin >> w >> h;
    dp = vector<vector<int>> (w+1,vector<int> (h+1,0));
    dp[1][1]=1;
    for(int i=1;i<=w;++i)
    {
        for(int j=1; j<=h; ++j)
        {
            char t;
            cin >> t;
            if (t=='.')
            if (i!=1 || j!=1)
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    cout << dp[w][h];
    return(0);
}


Measured memory_bytes: 4224
#include<stdio.h>

int selectionSort(int a[],int n){
    int sw=0,i,j,temp,minj;
    for( i=0;i<n-1;i++){
        minj=i;
        for( j=i;j<n;j++){
            if(a[minj]>a[j])minj=j;
        }
            temp=a[i];
            a[i]=a[minj];
            a[minj]=temp;
            if(minj!=i)sw++;
     }
     return sw;
}   


int main(){
    int sw=0,n,a[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    sw=selectionSort(a,n);
    for(int i=0;i<n;i++){
        if(i)printf(" ");
        printf("%d",a[i]);
    }
    printf("\n%d\n",sw);
    return 0;
}


Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define For(i, a, b) for(int i = (a); i < (b); i++)

int main() {
	int n, d;
	int ans = 0;
	double sum;
	cin >> n >> d;

	vector<vector<int>> x(n, vector<int>(d));
	rep(i, n) {
		rep(j, d) {
			cin >> x.at(i).at(j);
		}
	}

	For (i, 0, n - 1) {
		For (j, i + 1, n) {
			sum = 0.0;
			rep(k, d) {
				sum += pow((x.at(i).at(k) - x.at(j).at(k)), 2);
			}
			sum = sqrt(sum);
			if (floor(sum) == sum) {
				ans++;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define Arman_Sykot ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
 
using namespace std;

int main()
{
/*********************/
// Author:
        Arman_Sykot;
/*********************/
    
    int n;
    cin >> n;
    int arr[n];

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

    sort(arr, arr + n);

    for (int i = 1; i < n; i++) {
        if (arr[i] == arr[i - 1]) {
            cout << "NO" << "\n";
            return 0;
        }
    }

    cout << "YES" << "\n";
    return 0;
}


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

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

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
ll max(ll x,ll y){return x>y?x:y;}
ll min(ll x,ll y){return x>y?y:x;}

int main(){
    static ll n,k,h[200000];
    ll x,min=999999999;
    int i,j;

    scanf("%lld %lld",&n,&k);
    for(i=0;i<n;i++)scanf("%d",&h[i]);
    qsort(h,n,sizeof(ll),desc);

    for(i=0;i<n-k+1;i++){
        x=h[i]-h[i+k-1];
        if(min>x)min=x;
    }
    printf("%lld\n",min);
    return 0;
}

Measured memory_bytes: 1788
#include<iostream>
#include<math.h>

using namespace std;

int main() {
	long long n, x, ans = 0;
	cin >> n;
	x = sqrt(n);
	while(n % x != 0){
		x--;
	}
	x = n / x;
	while(x != 0){
		x /= 10;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#!python3

# input
N, M = list(map(int, input().split()))

# odd
def solve1():
    return [(i + 2, N - i) for i in range(M)]        


# even
def solve2():
    t = (N - 2) // 4
    l = [(i + 2, N - i) for i in range(t)]
    n = (N - 2) // 2 - t
    l = l + [(N // 2 + 1 + i, N // 2 - i) for i in range(n)]
    return l[:M]


def main():
    l = solve1() if N % 2 else solve2()
    for ans in l:
        print(*ans)
    

if __name__ == "__main__":
    main()


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

const int mod = 998244353;

long long int v1[1000001],v2[1000001],c[200001];

int a[200001];

long long int mp(long long int x,long long int b){
	long long int res=1;
	x%=mod;
	while(b){
		if(b&1)	res=res*x%mod;
		x=x*x%mod;
		b>>=1;
	}
	return res;
}
long long int g[1000001],f[1000001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i],c[i]=(long long int) a[i]*a[i];
	long long int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j*j<=a[i];j++){
			if(a[i]%j==0){
				v1[j]+=a[i];
				v2[j]+=c[i];
				if(j*j!=a[i]){
					int where=a[i]/j;
					v1[where]+=a[i];
					v2[where]+=c[i];
				}
			}
		}
	int N=0;
	for(int i=1;i<=n;i++)
		N=max(N,(int) a[i]);
	for(int i=1;i<=N;i++){
		v1[i]%=mod;
		v2[i]%=mod;
		g[i]=(v1[i]*v1[i]-v2[i]+mod)%mod;
		g[i]=g[i]*mp(2,mod-2)%mod;
	}
	for(int i=N;i>=1;i--){
		f[i]=g[i];
		for(int j=2;j*i<=N;j++)
			f[i]-=f[j*i];
		f[i]=(f[i]%mod+mod)%mod;
		ans=(ans+f[i]*mp(i,mod-2))%mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 33920
#include <stdio.h>

void Print(int N){
  int i;
  if(N <= 81){
    for(i = 9;i >= 1;i--) if(N % i == 0 && N / i <= 9) break;
    if(i >= 1){
      printf("Yes\n");
      return;
    }
  }
  printf("No\n");
}

int main(void){
  int N;
  scanf("%d", &N);
  Print(N);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

typedef struct NODE{
    int counter = 0;
    vector<int> children;
};

NODE node[200002];

void app(int par_num, int node_num, int addition){
    node[node_num].counter += addition;
    int value = node[node_num].counter;
    for(int j=0; j< node[node_num].children.size(); j++){
        if(node[node_num].children[j] == par_num) continue;
        app(node_num, node[node_num].children[j], value);
    }
}

int main(void){
    int N, Q;
    cin >> N >> Q;
    int par, chi;
    for(int i = 1; i < N; i++){
        cin >> par >> chi;
        node[par].children.push_back(chi);
        node[chi].children.push_back(par);
    }
    int p, x;
    for(int i = 0; i < Q; i++){
        cin >> p>> x;
        node[p].counter += x;
    }
    app(0, 1, 0);
    for(int i = 1; i < N; i++){
        cout << node[i].counter << " ";
    }
    cout << node[N].counter << endl;
}


Measured memory_bytes: 27392
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void)
{
	int N;
	int a[110];
	
	while (scanf("%d", &N)!=EOF)
	{
		for (int i = 0; i < N; i++)
		{
			scanf("%d", &a[i]);
			if (i != N - 1)
				printf("%d ", a[i]);
			else
				printf("%d\n", a[i]);
		}
		
		for (int i=1; i<N; i++)
		{
			int key = a[i];//从某个位子拿出一?牌，并且??那?牌的数?
			int j = i-1;//从拿去那?牌的前一?牌?始向前遍?
			
			while (j>=0&&a[j]>key)//如果所拿取的那?牌比前面的一?牌小，且不是最后一?牌???往前比?
			{
				a[j+1] = a[j];//第一次循??就已?将事先拿出牌的位子?覆盖了
				j--;
			}
			a[j+1] = key;//当??牌相?于其比?的牌比?小?，介?循?并且插入
			
			for (int i=0; i< N; i++)
			{
				if (i!=N-1)
					printf("%d ", a[i]);
				else
					printf("%d\n", a[i]);
			}
			
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 3228
import sys
for i in sys.stdin:
    try:
        sidelen = [int(j) for j in i.split(" ")]
        sidelen.sort(reverse=True)
        if(sidelen[0]**2 == sidelen[1]**2 + sidelen[2]**2):
            print("YES")
        else:
            print("NO")
    except:
        continue

Measured memory_bytes: 7764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	double a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	if(v<=w||abs(a-b)/abs(v-w)>t){
		puts("NO");
	}else{
		puts("YES");
	}
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    float ans = 1 - (N/2) / float(N);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
s=input()
count1=0
count2=0

char1=s[0]
char2='1'
count1+=1
if s[1]==char1:
    count1+=1
else :
    char2=s[1]
    count2+=1

if s[2]==char1:
    count1+=1
elif '1'==char2:
    char2=s[2]
    count2+=1
elif s[2]==char2:
    count2+=1

if s[3]==char1:
    count1+=1
elif '1'==char2:
    char2=s[3]
    count2+=1
elif s[3]==char2:
    count2+=1

if count1==2 and count2==2:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;
//for (int i = 0; i < N; i++){}
//for (int j = 0; j < M; j++){}

int main() {
    long long s;
    cin >> s;
    map<long long, long long> mp;
    long long an = s;
    mp[s]++;
    for (long long i = 1; i < 1000000; i++){
        if(an%2==0){
            if(mp[an/2]){
                cout << i+1 << endl;
                break;
            }else{
               mp[an/2]++;
            }
            an = an/2;
        }else{
            if(mp[3*an+1]){
                cout << i+1 << endl;
                break;
            }else{
                mp[3*an+1]++;
            }
            an = 3*an+1;
        }
    }
}

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

int main() {
  int H,W;
  while(1){
    cin >> H >> W;
    if(H==0 && W==0)
      break;
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
}



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

using namespace std;

int main()
{
    string s1="" , s2 ="";
    char n,m;

    cin>> n >> m;

    for(int i=0;i<(m-'0');i++) s1+=n;
    for(int i=0;i<(n-'0');i++) s2+=m;

    if(n<m) cout << s1 ;

    else cout << s2;

    return 0;
}


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

using namespace std;

typedef long long ll;

const ll M = 1000000007;
ll n, k;
ll ans;

int main()
{
    cin>>n>>k;
    for(ll i = k; i <= n + 1; i++)
    {
        ans += (n - i + 1) * i + 1;
        ans %= M;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int ha, aa, hb, ab; cin >> ha >> aa >> hb >> ab;
    while(ha > 0 && hb > 0){
        hb -= aa;
        if(hb<=0){
            cout << "Yes" << ln;
            break;
        }
        ha -= ab;
        if(ha<=0){
            cout << "No" << ln;
            break;
        }
    }
}


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

int main() {
	int a;
	cin >> a;
	vector<int>s(a * 2);
	for (int x = 0; x < a * 2; x++) {
		s[x] = x + 1;
	}
	int b;
	cin >> b;
	for (int c = 0; c < b; c++) {
		int d;
		cin >> d;
		vector<int>e(a * 2);
		for (int f = 0; f < a * 2; f++) {
			e[f] = s[f];
		}
		if (d == 0) {
			for (int g = 0; g < a * 2; g++) {
				if (g % 2 == 0) {
					s[g] = e[g / 2];
				}
				else {
					s[g] = e[a + (g - 1) / 2];
				}
			}
		}
		else {
			for (int i = 0; i <2*a-d; i++) {
				s[i] = e[d + i];
			}
			for (int i = 0; i < d; i++) {
				s[i+(2*a-d)] = e[i];
			}
		}
	}
	for (int q : s) {
		cout << q << endl;
	}
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

dd a;

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>a;
  a = a/3.0;
  printf("%.12f\n",a*a*a);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    string x;
    cin >> x;
    if (x[0]=='Y' && x[1]=='A' && x[2]=='K' && x[3]=='I'){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<typeinfo>
using namespace std;

typedef unsigned long long ull;
const int N_MAX = 300000;

struct raqSB{
    int dataSize;
    int bucketSize;
    ull data[N_MAX];
    ull bucket[N_MAX];

    raqSB(const int n){
        bucketSize = (int)sqrt(n) + 1;
        dataSize = bucketSize * bucketSize;
        for (int i=0;i<N_MAX;i++){
            data[i] = 0ull;
            bucket[i] = 0ull;
        }
    }

    void add(int s, int t, int x){
        int ss = s/bucketSize;
        int tt = t/bucketSize;
        if(ss==tt){
            for (int i=s;i<t+1;i++){
                data[i] += x;
            }
        }else{
            for(int i=s;i<(ss+1)*bucketSize;i++){
                data[i] += x;
            }
            for(int i=tt*bucketSize;i<t+1;i++){
                data[i] += x;
            }
            for(int i=ss+1;i<tt;i++){
                bucket[i] += x;
            }
        }
    }

    ull get(int i){
        return data[i] + bucket[i/bucketSize];
    }
};

struct Segment{
    int l, r;
    Segment(const int l, const int r): l(l), r(r) {}
};

int main(){
    int N, M, l, r;
    cin >> N >> M;
    vector< vector<Segment> > segList(M + 1);
    for (int i=0;i<N;i++){
        cin >> l >> r;
        Segment seg(l,r);
        segList[r-l+1].push_back(seg);
    }

    int A = N;
    int B;
    raqSB raqsb(M+1);
    for(int d=1;d<M+1;d++){
        B = 0;
        for (int k=1;d*k<M+1;k++){
            B += raqsb.get(d*k);
        }
        cout << A + B << endl;
        A -= segList[d].size();
        for(int m=0;m<segList[d].size();m++){
            raqsb.add(segList[d][m].l, segList[d][m].r, 1);
        }
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    for(int i = 1; i < n; i++){
        int cnt = 0;

        for (char j = 'a'; j <= 'z'; ++j) {
            bool le = false, ri = false;
            rep(k, i){
                if(s[k] == j) le = true;
            }

            for (int k = i; k < n; ++k) {
                if(s[k] == j) ri = true;
            }

            if(le && ri) cnt++;
        }

        ans = max(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    string x, y;
    cin >> x;
    cin >> y;
    int n = (int)x.size(), xk = 0;
    for (int i = 0; i<n; ++i) {
        if (x[i] != y[i]) {
            ++xk;
        }
    }
    cout << xk << "\n";
}




Measured memory_bytes: 3920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		int count = 0;

		Scanner sc = new Scanner(System.in);

		String[] s = sc.next().split("");

		for(int i = 0; i < 3; i++) {
			if(s[i].equals("1")) {
				count++;
			}
		}

		System.out.println(count);
	}
}

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

using ld=long double;
const ld PI=acos(-1);
void chmin(ld &a,ld b){
  if(a>b)a=b;
}
ld o;

signed main(){
  int N;cin>>N;
  vector<ld> x(N),y(N);
  for(int i=0;i<N;i++)cin>>x[i]>>y[i];
  vector<ld> kakudo(N-1);
  for(int i=0;i<N;i++){
    int cnt=0;
    for(int j=0;j<N;j++) if(i!=j) kakudo[cnt++]=atan2(y[j]-y[i],x[j]-x[i]);
    sort(kakudo.begin(),kakudo.end());
    ld the=10000;
    for(int j=0;j<N-1;j++){
      ld the2=kakudo[(j+N-2)%(N-1)]-kakudo[j];
      if(the2<0.0000000000000001)the2+=2*PI;
      chmin(the,the2);
    }
    if(abs(the-2*PI)<=0.000000001)the=0;
    the=PI-the;
    cout<<fixed<<setprecision(12)<<max(o,the/(PI*2))<<endl;
  }
}


Measured memory_bytes: 256
# your code goes here
s = input()
d = {}
flag = True
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
	
for k in d:
	if d[k] % 2 == 1:
		flag = False
		break
if flag:	
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define sz 1234567
using namespace std;
typedef long long ll;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    string tmp;
    for(int i=0;i<n;i++)
    {
        tmp+=s[i];
        if((tmp+tmp) == s)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
s=""

while True:
    try:
        s=input()
        if len(s)== s.count("B")+s.count("W"):
            break
    except:
        s=input()
count=0
b=s.count("B")
w=s.count("W")
for x in range(len(s)):
    if s[x:x+1] == "B":
        count += w
        b-=1
    elif s[x:x+1] == "W":
        w-=1

print(count)

Measured memory_bytes: 3500
n = int(input())
inp = []

for i in range(n):
    inp.append(list(map(lambda x: int(x), input().split(" "))))

dp = [[0]*(3) for i in range(n)]
dp[0][0] = inp[0][0]
dp[0][1] = inp[0][1]
dp[0][2] = inp[0][2]

for i in range(n):
    for j in range(3):
        if (i<n-1):
            m1 = dp[i][j] + inp[i+1][(j+1)%3]
            m2 = dp[i][j] + inp[i+1][(j+2)%3]
            if (dp[i+1][(j+1)%3] < m1):
                dp[i+1][(j+1)%3] = m1
            if (dp[i+1][(j+2)%3] < m2):
                dp[i+1][(j+2)%3] = m2

print(max(dp[-1]))

Measured memory_bytes: 74584
group1 = ['hon', '2', '4', '5', '7', '9']
group2 = ['pon', '0', '1', '6', '8']
group3 = ['bon', '3']

number = list(input()).pop()
if number in group1:
    print(group1[0])
elif number in group2:
    print(group2[0])
elif number in group3:
    print(group3[0])



Measured memory_bytes: 8960
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
#include<complex>
#include<array>
using namespace std;
#define rrep(i,m,n) for(int (i)=(int)(m);(i)>=(int)(n);(i)--)
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define M_PI 3.1415926535897932LL;
typedef pair<ll, ll> P;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1LL << 60;
constexpr long double EPS = 1e-10;
typedef vector<ll> Array;

//nCrとか
class Combination {
public:
	Array fact;
	Array inv;
	ll mod;
	ll mod_inv(ll x) {
		ll n = mod - 2LL;
		ll res = 1LL;
		while (n > 0) {
			if (n & 1) res = res * x % mod;
			x = x * x % mod;
			n >>= 1;
		}
		return res;
	}
	//if n >= mod use lucas 
	ll nCr(ll n, ll r) {
		if (n < r)return 0;
		if (n < mod)return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
		
		ll ret = 1;
		while (n || r) {
			ll _n = n % mod, _r = r % mod;
			n /= mod; r /= mod;
			(ret *= nCr(_n, _r)) %= mod;
		}
		return ret;
	}
	ll nPr(ll n, ll r) {
		return (fact[n] * inv[n - r]) % mod;
	}
	ll nHr(ll n, ll r) {
		return nCr(r + n - 1, r);
	}
	Combination(ll _n, ll _mod) {
		mod = _mod;
		ll n = min(_n+1, mod);
		fact.resize(n);
		fact[0] = 1;
		REP(i, n-1) {
			fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
		}
		inv.resize(n);
		inv[n-1] = mod_inv(fact[n-1]);
		for (int i = n-1; i > 0; i--) {
			inv[i - 1] = inv[i] * i % mod;
		}
	}
};

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

	ll n;
	cin >> n;
	string s;
	cin >> s;
	Array a(n);
	REP(i, n)a[i] = s[i] - '0' - 1;
	Combination comb(n, 2);
	ll ans = 0;
	ll cnt = 0;
	REP(i, n) if (a[i] == 1)ans += comb.nCr(n-1, i), cnt++;
	if (cnt) {
		cout << ans % 2 << endl;
		return 0;
	}
	REP(i, n) if (a[i] == 2)ans += comb.nCr(n-1, i);
	cout << ans % 2 * 2 << endl;
  
	return 0;
}


Measured memory_bytes: 9244
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int count = 0;

void insertSort(int *A,int n,int g);

int main(){
  int n,i,j;
  int *A;
  int G[20];
  int m = 0;

  scanf("%d",&n);
  A = malloc(n * sizeof(int));
  for(i = 0;i<n; i++){
    scanf("%d",&A[i]);
  }
   for(i = 0;i<20; i++){
     G[i] = 0;
  }

   while(1){
     if(n<3 * G[m] +1){
       break;
     }
     G[m+1] = 3*G[m] +1;
     m++;
   }

   for(i = m; i>0 ; i--){
     insertSort(A,n,G[i]);
   }

   printf("%d\n",m);
   for(i = m; i>=1 ; i--){
     printf("%d ",G[i]);
   }
     printf("\n");
     printf("%d\n",count);

     for(i = 0;i < n; i++){
       printf("%d\n", A[i]);
     }

       return 0;
     }


void insertSort(int *A,int n,int g){
  int i,j;
  int key;
  for(i = g; i<n; i++){
    j = i;
    key = A[i];
    while(0<=j-g){
      if(A[j-g] <= key)break;
      A[j] = A[j-g];
      j -= g;
      count++;
    }
    A[j] = key;
  }
}



Measured memory_bytes: 5608
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
constexpr ll mod = 1000000000 + 7;
int main()
{
    stat();
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> books(n, vector<int>(m));
    rep(i, n)
    {
        cin >> c[i];
        rep(j, m) { cin >> books[i][j]; }
    }
    ull ans = 100100100;
    for (int bit = 0; bit < (1 << n); ++bit) {
        vector<int> v(m);
        int cost = 0;
        rep(i, n)
        {
            if ((bit >> i) & 1) {
                cost += c[i];
                rep(j, m) { v[j] += books[i][j]; }
            }
        }

        bool ok = true;
        rep(i, m)
        {

            if (v[i] < x) { ok = false; }
        }
        if (ok) { ans = min(ans, (ull)cost); }
    }
    if (ans != 100100100) { cout << ans << endl; }
    else {
        cout << -1 << endl;
    }
    return 0;
}
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}


Measured memory_bytes: 3612
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int H,W;
char S[22][22];

int DFS(int x, int y, int max){

    return 0;
}


int main(void) {

    int N; cin>>N;
    if(N<1000) cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;

}

Measured memory_bytes: 256
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


table = [0]*26

letters = "abcdefghijklmnopqrstuvwxyz"
input_str = sys.stdin.read()

for A in input_str:
    index = 0
    for B in letters:
        if A == B or A == B.upper():
            table[index] += 1
            break
        index += 1

for i in range(len(letters)):
    print("%s : %d"%(letters[i],table[i]))



Measured memory_bytes: 5576
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li n;
    cin >> n;
    string s;
    cin >> s;

    vector<li> whites(n + 1, 0), blacks(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        whites[i + 1] = whites[i];
        blacks[i + 1] = blacks[i];
        if (s[i] == '#') {
            blacks[i + 1] += 1;
        } else {
            whites[i + 1] += 1;
        }
    }

    li ans = n;
    for (int i = 0; i <= n; ++i) {
        ans = min(ans, blacks[i] + whites[n] - whites[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3732
#include <fstream>
#include <iostream>
#include <vector>
#include <numeric>
#include<algorithm>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)

int main(){
    char a;
    cin >> a;
    if(isupper(a)) cout << 'A' << endl;
    else cout << 'a' <<endl;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		int maxA = -1; int minA = 1001001001;
		int maxB = -1; int minB = 1001001001;
		for(int i = 0 ; i < N ; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
			if(maxA < A[i]) maxA = A[i];
			if(minA > A[i]) minA = A[i];
			if(maxB < B[i]) maxB = B[i];
			if(minB > B[i]) minB = B[i];
		}
		long ans = maxA - minA + 1;
		ans += minA - 1;
		ans += minB;
		System.out.println(ans);
	}
}

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

int main() {
  int N;
  cin >> N;
  
  bool is_four = false;
  string S;
  
  for (int i = 0; i < N; i++) {
    cin >> S;
    if (S == "Y") {
      is_four = true;
      break;
    }
  }
  
  cout << (is_four ? "Four" : "Three") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;

struct V {
  int id;
  vector <V> next;
};

vector<V> list;

int dfs(int id,bool *vi, int N) {
  bool k = true;
  for(int i = 0; i < N; i++) {
    if(!vi[i]) {
      k = false;
      break;
    }
  }

  if(k) return 1;
  int sum = 0;
  for(V vv : list.at(id).next) {
    if(vi[vv.id]) continue;
    vi[vv.id] = true;
    sum += dfs(vv.id,vi,N);
    vi[vv.id] = false;
  }
  return sum;


}

int main() {
  int N,M;
  cin >> N >> M;
  int a[M],b[M];
  for(int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
  }

  for(int i = 0; i < N; i++) {
    list.push_back(V());
    list[i].id = i;
    list[i].next.clear();
  }

  for(int i = 0; i < M; i++) {
    list[a[i]-1].next.push_back(list[b[i]-1]);
    list[b[i]-1].next.push_back(list[a[i]-1]);
  }
  bool vis[N];
  for(int i = 0; i < N; i++) {
    vis[i] = false;
  }
  vis[0] = true;
  cout << dfs(0,vis,N) << endl;


}


Measured memory_bytes: 2760
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int gcd(int a, int b) {
	if (a < b)swap(a, b);
	while (b) {
		int r = a % b; a = b; b = r;
	}
	return a;
}
int main() {
	int n, s, x;
	cin >> n >> s;
	int out = 0;
	rep(i, n) {
		cin >> x;
		out = gcd(out, abs(x - s));
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define task "blist"

using namespace std;

const int maxn = 1e6 + 69;
const ll mod = 1e9 + 7;

ll mul[maxn], invmul[maxn];

ll Pow(ll x, ll k)
{
    if(k == 0) return 1;
    if(k == 1) return x % mod;
    ll t = Pow(x, k/2) % mod;
    if(k % 2 == 1) return ((t%mod*t%mod)%mod*x)%mod;
    return (t%mod*t%mod)%mod;
}

ll C(int k, int n)
{
    return ((invmul[k] * mul[n])%mod * invmul[n - k]%mod)%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    if(fopen(task".in", "r")){
        freopen(task".in", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    //cout << Pow(2, 10);
    int n;
    cin >> n;
    mul[0] = 1;
    invmul[0] = 1;
    for(int i = 1; i <= n; i ++){
        mul[i] = (mul[i - 1] * i) % mod;
        invmul[i] = Pow(mul[i], mod - 2)%mod;
    }

    ll ans = 0;

    for(int i = 2; i <= n; i ++){
        ans = (ans + ((C(i, n) * Pow(8, n - i))%mod * (Pow(2, i) - 2)%mod)%mod)%mod;
    }
    cout << ans;
}
/*
10 3
11 4
12 5
*/


Measured memory_bytes: 19144
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	ll r;
	cin>>r;
	cout<<r*r<<endl;
	return 0;
}


Measured memory_bytes: 256
def main(a, b, k):
    t = []
    _max = max(a, b)

    for i in range(1, _max + 1):
        if a % i == 0 and b % i == 0:
            t.append(i)

    print(t[-k])


if __name__ == "__main__":
    a, b, k = map(int, input().split())

    main(a, b, k)


Measured memory_bytes: 2940
inpl = lambda: list(map(int,input().split()))
MOD = 10**9 + 7
def inv_mod(a, p=MOD):
    p = abs(p)
    a %= p
    stack = []
    p0 = p
    while a > 1:
        d, a, p = p//a, p%a, a
        stack.append(d)
    x, y = 1, 0
    while stack:
        d = stack.pop()
        x, y = y-d*x, x
    return x % p0
N, K = inpl()
A = inpl()
A.sort()
min_count = [0]*N
max_count = [0]*N

ans = 0
C = 1
for i in range(K-1,N):
    ans += A[i] * C
    ans -= A[N-1-i] * C
    ans %= MOD
    C *= (i+1)*inv_mod(i-K+2)
    C %= MOD
print(ans)

Measured memory_bytes: 63344
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int n,cnt;
  double x0,y0,area,x1,y1,x2,y2;
  cnt=1;
  while(cin>>n,n){
    area=0;
    cin>>x0>>y0;
    x1=x0;y1=y0;
    while(n-->1){
      cin>>x2>>y2;
      area+=x1*y2-x2*y1;
      x1=x2;y1=y2;
    }
    area+=x2*y0-x0*y2;
    printf("%d %.1f\n",cnt,fabs(area/2.0));
    cnt++;
  }
}

Measured memory_bytes: 0
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const long long INF = 1LL << 60;
ll MOD = 1e9+7;

vector<int> Graph[2*100000+1];

vector<bool> visitGraph(2*100000+1,false);
vector<int> ansGraph(2*100000+1, 0);

void bfs(){
    queue<int> q;
    q.push(1);
    visitGraph[1] = true;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto v :Graph[u]) {
            if(visitGraph[v]==true) continue;
            visitGraph[v] = true;
            ansGraph[v] = u;
            q.push(v);
        }
    }


}

int main() {

    int N,M; cin>>N>>M;
    int A,B;
    for (int i = 0; i < M; ++i) {
        cin>>A>>B;
        Graph[A].push_back(B);
        Graph[B].push_back(A);
    }

    bfs();

    bool ok = true;
    for (int i = 2; i <= N; ++i) {
        if(ansGraph[i]==0){
            ok = false; break;
        }
    }

    if(!ok){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;

        for (int i = 2; i <= N; ++i) {
            cout<<ansGraph[i]<<endl;
        }

    }

    return 0;
}

Measured memory_bytes: 13112