akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 100010;
const int INF = 2147483600;

int T,N; 
int Node[MAXN<<1],Next[MAXN<<1],Root[MAXN+1],cnt;
int deg[MAXN+1],dg[MAXN+1];
vector<int> vec[MAXN+1],vec2[MAXN+1];

inline void insert(int u,int v,int d){
	Node[++cnt]=v; Next[cnt]=Root[u]; Root[u]=cnt;
	deg[u]+=d;
}
inline void Ins(int u,int v){
	dg[v]++; vec2[u].push_back(v);
} int top; int vis[MAXN+1]; int tim; bool ed[61][61];
inline void dfs(int k,int Fa){
	++top; vis[k]=tim;
	for(int x=Root[k];x;x=Next[x]){
		int v=Node[x]; if(v==Fa) continue;
		if(ed[k][v]) dfs(v,k);
	} return ;
} int fa[2][MAXN+1];
inline void dfs2(int k,int Fa){
	fa[0][k]=Fa;
	for(int x=Root[k];x;x=Next[x]){
		int v=Node[x]; if(v==Fa) continue;
		dfs2(v,k);
	}
}
inline void dfs3(int k,int Fa){
	fa[1][k]=Fa;
	for(int i=0,sz=vec[k].size();i<sz;i++){
		int v=vec[k][i]; if(Fa==v) continue;
		dfs3(v,k);
	} return ;
}
inline bool check(int K){
	dfs2(K,0); dfs3(K,0); queue<int> que;
	for(int i=1;i<=N;i++) dg[i]=0,vec2[i].clear();
	for(int i=1;i<=N;i++){
		if(vis[i]!=tim){
			if(vis[fa[0][i]]!=tim) Ins(i,fa[0][i]); 
			if(vis[fa[1][i]]!=tim) Ins(fa[1][i],i);
		} 
	} for(int i=1;i<=N;i++) if(!dg[i]) que.push(i); int n=0;
	while(!que.empty()){
		int k=que.front(); que.pop(); ++n;
		for(int i=0,sz=vec2[k].size();i<sz;i++){
			dg[vec2[k][i]]--; if(!dg[vec2[k][i]]) que.push(vec2[k][i]); 
		}
	} return (n==N);
}
inline int solve(int k){
	int ret=INF;
	for(int i=1;i<=N;i++) vis[i]=0; tim=0;
	for(int i=1;i<=N;i++){
		if(!vis[i]&&(!k||k==i)) {
			++tim,top=0,dfs(i,0);
			if(check(i)) ret=min(ret,N-top);
		}
	}
	return ret;
} int U[MAXN+1],V[MAXN+1];
inline void Rebuild(int ut,int vt){
	cnt=0; for(int i=1;i<=N;i++) Root[i]=0;
	for(int i=1;i<N;i++){
		int u=U[i],v=V[i];
		if(u==ut||v==ut) insert(ut,vt,0),insert(vt,ut,0);
		else insert(u,v,0),insert(v,u,0);
	} return ;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	T=read();
	while(T--){
		N=read(); cnt=0;
		for(int i=1;i<=N;i++) vec[i].clear(),Root[i]=0,deg[i]=dg[i]=vis[i]=0;
		for(int i=1;i<=N;i++) for(int j=1;j<=N;j++) ed[i][j]=0;
		for(int i=1;i<N;i++){
			int u=read(),v=read();
			insert(u,v,1); insert(v,u,1);
			U[i]=u,V[i]=v;
		}
		for(int i=1;i<N;i++){
			int u=read(),v=read();
			vec[u].push_back(v);
			vec[v].push_back(u);
			ed[u][v]=ed[v][u]=1;
		} int ans=solve(0);
		for(int i=1;i<=N;i++){
			if(deg[i]==1)
				for(int j=1;j<=N;j++){
					if(i==j) continue;
					Rebuild(i,j);
					ans=min(ans,solve(i)+1);
				}
		} if(ans<INF) printf("%d\n",ans);
		else puts("-1");
	} 
	return 0;
}

Measured memory_bytes: 6528
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLine().toInt()
    val a = sc.nextLine().split(" ").map { it.toLong() }
    val b = sc.nextLine().split(" ").map { it.toLong() }
    println(problem135_c(n, a, b))
}

fun problem135_c(n: Int, a: List<Long>, b: List<Long>): String {

    var result = 0L

    var killCount = 0L

    for (index in 0 until n) {

        // 正面の敵を倒す場合
        if (index == 0) {
            killCount = Math.min(a[0], b[0])
            result += killCount
        } else {
            killCount = Math.min(a[index] - killCount, b[index])
            result += killCount
        }

        // 斜め右の怪獣を倒す場合
        killCount = Math.min(a[index + 1], b[index] - killCount)
        result += killCount
    }

    return result.toString()
}



Measured memory_bytes: 90700
import numpy as np
n,s = map(int,input().split())
a = list(map(int,input().split()))
dp = np.zeros(s+1, dtype=np.int64)
"""
dp[i][j] := i番目までを選んで、和がちょうどjのときの場合の数
遷移 → 1増えると全体集合に選ぶ, Aには選ばない, Aに選ぶの3種類.
"""
mod = 998244353
dp[0] = 1
for i in range(n):
	p = (dp * 2) % mod
	p[a[i]:] += dp[:-a[i]]
	dp = p % mod
print(dp[s])

Measured memory_bytes: 27192
N = int(input())
l = list(map(int,input().split()))

f = False
#間違い,本来
pre = (0,0)
for i in range(N):
    if not l[i]==i+1:
        if f:
            print('NO')
            exit()
        if not pre[0]==0:
            if pre[0] == i+1 and pre[1]+1==l[i]:
                f = True
                continue
            else:
                print('NO')
                exit()
        else:
            pre = (l[i],i)
print('YES')

Measured memory_bytes: 3064
n = int(input())
col = {}
for i in range(n):
  s = list(input())
  s.sort()
  s2 =''.join(s)
  if s2 in col:
    col[s2]+=1
  else:
  	col[s2] = 1
com = lambda x : x*(x-1)/2
print(int(sum(com(col[k]) for k in col)))

Measured memory_bytes: 17808
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    ll k;
    cin >> s >> k;
    vector<int>diff(s.length());
    REP(i,s.length()){
        diff[i] = ('z'+1-s[i])%26;
    }
    REP(i,s.length()){
        if(diff[i] <= k){
            s[i] = 'a';
            k-=diff[i];
        }
    }
    if(k>0){
        k = k%26;
        s[s.length()-1]+=k;
        //if(s[s.length()-1]>'z')s[s.length()-1]-=26;
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3824
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Solve s= new Solve();
		s.solve();

	}

}

class Solve{
	 Scanner sc = new Scanner(System.in) ;

	 void solve() {
		 int x = sc.nextInt();
		 int a = sc.nextInt();
		 
		 if(x<a) {
			 System.out.println(0);
		 }else {
			 System.out.println(10);
		 }
	 }




	 }

Measured memory_bytes: 23252
// AOJ 2964 Restore Shortest Path
// 2019.8.10 bal4u

#include <stdio.h>
#include <stdlib.h>

int len(int a, int b) {
	int w;
	printf("? %d %d\n", a, b);
	fflush(stdout);
	scanf("%d", &w);
	return w;
}

typedef struct { int n, c; } T;
T a[305]; int sz;

int cmp(const void *a, const void *b) { return ((T *)a)->c - ((T *)b)->c; }

int main()
{
	int i, N, s, t, u, v, w;
	
	scanf("%d%d%d", &N, &s, &t);
	w = len(s, t);
	for (i = 1; i <= N; i++) if (i != s && i != t) {
		u = len(i, s), v = len(i, t);
		if (u + v == w) a[sz].n = i, a[sz++].c = u;
	}
	qsort(a, sz, sizeof(T), cmp);
	printf("! %d", s);
	for (i = 0; i < sz; i++) printf(" %d", a[i].n);
	printf(" %d\n", t);
	fflush(stdout);
	return 0;
}


Measured memory_bytes: 4668
x = int(input())

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)
 

Measured memory_bytes: 9176
/**
 * @Author:      H S-J
 * @DateTime:    2017-09-16 20:01:10
 * @Description: 
 */
#include <bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define DBG(x) cout << '#' << " = " << (x) << endl;
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define lson(x) (x) << 1
#define rson(x) (x) << 1|1
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define ech(x, y, z) for (auto x = z.begin(), y = z.end(); x != y; ++x)
#define lowbit(x) (x & (-x))
#define opr operator
#define _st first
#define _nd second
#define prior_q1(x) priority_queue<x>
#define prior_q2(x) priority_queue<x, vector<x>, greater<x> >
typedef long long LL;
typedef stringstream strstm;
struct FastIO {
    static const int S = 1310720;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int xchar() {
        static char buf[S];
        static int len = 0, pos = 0;
        if (pos == len)
            pos = 0, len = fread(buf, 1, S, stdin);
        if (pos == len) return -1;
        return buf[pos ++];
    }
    inline int xuint() {
        int c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x;
    }
    inline int xint() {
        int s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline LL xlongint() {
        LL s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline void xstring(char *s) {
        int c = xchar();
        while (c <= 32) c = xchar();
        for (; c> 32; c = xchar()) * s++ = c;
        *s = 0;
    }
    inline void wchar(int x) {
        if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
        wbuf[wpos ++] = x;
    }
    inline void wint(LL x) {
        if (x < 0) wchar('-'), x = -x;
        char s[24];
        int n = 0;
        while (x || !n) s[n ++] = '0' + x % 10, x /= 10;
        while (n--) wchar(s[n]);
    }
    inline void wstring(const char *s) {
        while (*s) wchar(*s++);
    }
    ~FastIO() {
        if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
    }
} io;
int main(int argc, char const *argv[]) {
	// ios::sync_with_stdio(0);cin.tie(0);
	int n, m;
	while (cin >> n >> m) {
		cout << n * n - m << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[21]:


N,X,Y = map(int, input().split())


# In[24]:


ans = [0]*N
for i in range(1,N):
    for j in range(i+1,N+1):
        dist = min(j-i,abs(X-i)+abs(Y-j)+1,abs(Y-i)+abs(X-j)+1)
        ans[dist] += 1
for i in range(1,N):
    print(ans[i])


# In[ ]:






Measured memory_bytes: 75060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int[] p = new int[n+1];
		
		int wrong = 0;
		for ( int i = 1; i <= n; i++ ) {
			p[i] = in.nextInt();
			if(p[i] != i) wrong++;
		}
		
		if(wrong <= 2)System.out.println("YES");
		else System.out.println("NO");
		
		
		in.close();
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
int i,b,c;
string s;
int main(){
  cin>>s;
  for(;i<s.size();i++){
    if(i&1&&s[i]=='1')c++;
    if(!(i&1)&&s[i]=='0')c++;
  }
  for(i=0;i<s.size();i++){
    if(i&1&&s[i]=='0')b++;
    if(!(i&1)&&s[i]=='1')b++;
  }
  cout<<min(b,c);
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

int main(){
    int H, W, N;
    cin >> H >> W >> N;

    int a, b;
    if(H >= W) {
        a = H;
        b = W;
    }else{
        a = W;
        b = H;
    }

int ans = 0, sum = 0;
    while(sum < N){
        sum += a;
        ans++;
    }
print(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int main(){
	int k;
	cin>>k;
	int cur=7%k;
	if(cur==0){
		cout<<1<<endl;
		return 0;
	}
	for(int i=2;i<=k;i++){
		cur=cur*10%k+7%k;
		cur%=k;
		if(cur==0){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 3232
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		int numN = N * (N - 1) / 2;
		int numM = M * (M - 1) / 2;

		int sum = numN + numM;

		System.out.println(sum);

		sc.close();

	}

}


Measured memory_bytes: 35744
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string w;
  cin >> w;
  int c[26];
  for (int i = 0; i < 26; ++i) c[i] = 0;
  for (int i = 0; i < w.size(); ++i) {
    c[w[i]-'a']++;
  }
  for (int i = 0; i < 26; ++i) {
    if (c[i]%2 != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#endif

using namespace std;


typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()) {
  v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t) {
  stringstream ss;
  ss << f;
  ss >> t;
}


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


#define MOD 1000000007LL
#define EPS 1e-8

int main() {
  long long A, B;
  char op;
  cin >> A >> op >> B;
  long long res;
  if (op == '+') {
    res = A + B;
  } else {
    res = A - B;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max({10 * a + b + c, a + 10 * b + c, a + b + 10 * c}) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 100000000;
const int MAX_N = 100000;



int main(int argc, char *args[]) {
	int N;
	cin >> N;
	int A[50], B[50], C[50];
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];
	for (int i = 0; i < N - 1; i++) cin >> C[i];

	int index = A[0] - 1;
	int ans = 0;
	ans += B[index];

	int temp = index;

	for (int i = 1; i < N; i++) {
		index = A[i] - 1;
		ans += B[index];
		if (index == temp + 1) {
			ans += C[temp];
		}
		temp = index;
	}
	cout << ans << endl;
}

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

string a, b;
int main() {
	int i;
	cin >> a >> b;
	for(i=0; a[i]; i++) if(a[i] != b[i]) break;
	cout << (i<a.size() ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 3640
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const ll INF = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

double calc(ll fx, ll fy, ll fr, ll tx, ll ty, ll tr)
{
	double xr = abs(fx - tx);
	double yr = abs(fy - ty);
	double r = xr * xr + yr * yr;
	return max(0.0, sqrt(r) - (double)(fr + tr));
}
typedef pair<double, int> pdi;
double tb[1010][1010];
double dis[1010];
void dij(int v) {
	int start = 0;
	fill(dis, dis + v, (double)INF * (double)INF);
	dis[start] = 0;
	priority_queue<pdi,vector<pdi>,greater<pdi>> q;

	q.push(pdi(0, 0));
	while (!q.empty())
	{
		pdi p = q.top();
		q.pop();
		if (p.first > dis[p.second]) continue;
		for (int i = 0; i <= v; i++)
		{
			if (dis[i] > dis[p.second] + tb[p.second][i]) {
				dis[i] = dis[p.second] + tb[p.second][i];
				q.push(pdi(dis[i], i));
			}
		}
	}

}
void solv() {
	ll xs, ys,xt,yt;
	cin >> xs >> ys >> xt >> yt;
	int n;
	cin >> n;
	
	ll x[1010], y[1010], r[1010];
	x[0] = xs;y[0] = ys;r[0] = 0;
	x[n + 1] = xt;y[n + 1] = yt;r[n + 1] = 0;
	for (size_t i = 1; i <= n; i++)
	{
		cin >> x[i] >> y[i] >> r[i];
	}
	tb[0][0] = 0;
	tb[n + 1][n + 1] = 0;
	for (int i = 0; i <= n + 1; i++)
	{
		for (int j = 0; j <= n + 1; j++)
		{
			tb[i][j] = calc(x[i], y[i], r[i], x[j], y[j], r[j]);
		}
	}

	dij(n + 2);
	cout << std::setprecision(12) << dis[n + 1] << endl;
}




int main() {
	solv();

	return 0;
}


Measured memory_bytes: 14064
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    string s; cin >> s;
    cout << count(s.begin(), s.end(), '2') << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> prl;
typedef vector<ll> vcl;
typedef map<ll,ll> mapl;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define all(v) v.begin(), v.end()
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    ll n;
    string s,t;
    cin >> s >> t;
    n=s.size();
    rep(i,0,n-1){
        if(s[i]!=t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
struct NUM{
	int count[11];
	int sum;
	bool operator>(const NUM& r) const{
		if(sum>r.sum) return true;
		else if(sum<r.sum) return false;
		else{
			for(int i=9;i>=1;i--){
				if(count[i]>r.count[i]) return true;
				else if(count[i]<r.count[i]) return false;
			}
			return false;
		}
	}
};
int main(){
	int N,M,A[10001];
	int kosu[12]={0,2,5,5,4,5,6,3,7,6};
	map<int,NUM> dp;
	NUM ininum;ininum.sum=0;rep(i,10) ininum.count[i]=0;
	bool alre[10001]={};
	alre[0]=1;
	scan(N);scan(M);
	rep(i,N+1) dp[i]=ininum;
	rep(i,M){
		scan(A[i]);
	}
	rep(i,N+1){
		if(alre[i]){
			rep(j,M){
				NUM tmp=dp[i];
				tmp.count[A[j]]++; tmp.sum++;
				if(tmp>dp[i+kosu[A[j]]]) dp[i+kosu[A[j]]]=tmp;
				alre[i+kosu[A[j]]]=1;
			}
		}
	}
	/*rep(i,N+1){
		printf("i:%d  ",i);
		if(alre[i]){
			for(int j=9;j>=1;j--){
				rep(k,dp[i].count[j]){
					printf("%d",j);
				}
			}
		}
		kaigyo;
	}*/
	for(int j=9;j>=1;j--){
		rep(k,dp[N].count[j]){
			printf("%d",j);
		}
	}
	kaigyo;
	return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	vector<int> A(3); cin >> A[0] >> A[1] >> A[2];
	sort(all(A));
	cout << 10*A[2] + A[1] + A[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fore(b,c) for(int val0=b;val0<c;val0++)
#define forr(k,c,s) for(int k=c;k<s;k++)
#define pb push_back
#define mmp make_pair
#define oset(T) tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long double ld;
typedef vector<vii> al;
typedef vector<ll> vl;
const int INF = 1e9;
const ll INFL = 1LL<<61;
int main() {
	ios::sync_with_stdio(0);cout.precision(20);cout.tie(0);cin.tie(0);
	int n;
	cin >> n;
	cout << (n-1)/2 << '\n';
}



Measured memory_bytes: 256
s=input()
s1=int(s[0:2])
s2=int(s[2:])

if (s1==0 or s1>12) and (s2==0 or s2>12):
    print("NA")
elif (s1>0 and s1<=12) and ((s2>0 and s2<=12)):
    print("AMBIGUOUS")
elif (s1>0 and s1<=12) and (s2==0 or s2>12):
    print("MMYY")
else:
    print("YYMM")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  
  int k;
  cin >> k;
  ll x; cin >> x;
  ll sum=500*k;
  if(x<=sum) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <cmath>
#include <string>
#include <set>
#include <map>
#define SIZE 100005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int A[SIZE],B[SIZE];

int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d %d",&A[i],&B[i]);
	ll ret=0;
	for(int i=0;i<n;i++) if((k|A[i])==k) ret+=B[i];
	for(int i=0;i<=30;i++)
	{
		if(!(k>>i&1)) continue;
		ll now=0;
		for(int j=0;j<i;j++) now|=1<<j;
		for(int j=i+1;j<=30;j++) if(k>>j&1) now|=1<<j;
		ll sum=0;
		for(int j=0;j<n;j++) if((now|A[j])==now) sum+=B[j];
		ret=max(ret,sum);
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>

using namespace std;
int ans[100000];

int main()
{
    int n;
    int h[100000];
    
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> h[n-1-i];
    }
    
    int ans[100000];
    ans[0] = 0;
    ans[1] = abs(h[1]-h[0]);
    if (n >= 3){
        for (int i = 2;i < n;i++){
            ans[i] = min(abs(h[i]-h[i-1])+ans[i-1],abs(h[i]-h[i-2])+ans[i-2]);
        }
    }
    cout << ans[n-1] << endl;
}


Measured memory_bytes: 1024
while True:
  a,op,b=input().split()
  a=int(a)
  b=int(b)

  if op=='?':
    break
  else:
    if op=='+':
      print(a+b)
    elif op=='-':
     print(a-b)
    elif op=='*':
      print(a*b)
    elif op=='/':
        print(a//b)


Measured memory_bytes: 5592
s = list(input())
s_ord = [ord(e) for e in s]
s_ord_ele = sorted(list(set(s_ord)))
# 1回の操作でできること: 語尾を削る,各文字を前にコピー
def operate(list1,str_ord,count):
    if len(list(set(list1))) == 1:
        return count
    for i in range(len(list1) - 1):
        if list1[i+1] == str_ord:
            list1[i] = list1[i+1]
    del list1[-1]
    return operate(list1,str_ord,count+1)
min_count = 100
for e in s_ord_ele:
    count = operate(s_ord[:],e,0)
    if count < min_count:
        min_count = count
print(min_count)

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

namespace ABC085_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            HashSet<int> set = new HashSet<int>();

            for (int i = 0; i < n; ++i)
            {
                int diameter = int.Parse(Console.ReadLine());

                set.Add(diameter);
            }

            Console.WriteLine($"{set.Count()}");
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct pos
{
    int x,y;
} a[10];
double b[10][10];
int main()
{
    ll n;
    cin>>n;
    memset(b,0,sizeof(b));
    for(int i=0; i<n; i++)
    {
        cin>>a[i].x>>a[i].y;
    }
    double ans=0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            double s=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y));
            ans=ans+s+s;
            // cout<<s<<endl;
        }
    }
    ans=ans*1.0/n;
    printf("%.6lf\n",ans);
   // cout<<ans<<endl;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,m; cin>>n>>m;
	int x,y;
	map<int,int> deg;
	for (int i=0; i<m; i++) {
		cin>>x>>y;
		deg[x]++; deg[y]++;
	}
	for (int i=1; i<=n; i++)
		cout << deg[i] << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from functools import reduce
import numpy as np
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, M: int, a: "List[int]"):

    def gcd_base(a: int, b: int):
        while b:
            a, b = b, a%b
        return a

    def gcd(*numbers):
        return reduce(gcd_base, numbers)
    
    def lcm_base(a: int, b:int):
        return a*b // gcd_base(a,b)

    def lcm(*numbers):
        return reduce(lcm_base, numbers, 1)

    def div_of_2(x: int):
        c = 0
        while x%2 == 0:
            c += 1
            x //= 2
        return c

    x = lcm(*a)
    t = x // 2
    y = div_of_2(x)

    if t > M or any([y != div_of_2(i) for i in a]):
        print(0)
        exit()

    ans = 1
    ans += (M-t)//x
    
    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26824
// In the name of God

#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define an size()

using namespace std;

const ll maxn=2e5+5;
const ll maxs=2e14;

int a[maxn];
ll t=0;
multiset <ll> st;
multiset <ll> ::iterator it;
map<ll,ll> fen;

void update(ll a)
{
    a++;
    while(a<2*maxs)
    {
        fen[a]++;
        a+=a&(-a);
    }
}
ll index(ll a)
{
    a++;
    ll ans=0;
    while(a>0)
    {
          if(fen.count(a)>0)
        ans+=fen[a];
        a-=a&(-a);
    }
    return ans;
}
int main()
{
    ll n,k,ans=0;
    cin>>n>>k;
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
        a[i]-=k;
    }
    for(ll i=n-1; i>=0; i--)
    {
        t+=a[i];
        st.insert(a[i]-t);
        update(a[i]-t+maxs);
        it=st.lower_bound(-t);
        if(it!=st.end())
            ans+=n-i-index((*it)-1+maxs);
    }
    cout<<ans;
}


Measured memory_bytes: 197760
#/usr/bin/env python

n, m = map(int, input().split())
MOD = int(1e9)+7
fac = [-1 for _ in range(100001)]
fac[1] = 1 

for i in range(1, 100000):
    fac[i+1] = ((i+1)*fac[i])%MOD

if abs(n-m) > 1:
    print(0)
    exit()

ans = 0 
if n == m:
    ans = (fac[n]*fac[m]*2)%MOD
else:
    ans = (fac[n]*fac[m])%MOD

print(ans)


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

namespace AC
{
    class Program
    {

        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var A = input[0];
            var B = input[1];
            var K = input[2];
            if (A <= K)
            {
                K -= A;
                A = 0;
            }
            else
            {
                A -= K;
                K = 0;
            }
            if (K > 0)
            {
                B -= Math.Min(B, K);
            }

            Console.WriteLine(A + " " + B);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  int maxx = 0;
  vector<int> num(100001);
  for(int i=0; i<n; i++){
    num[a[i]]++;
    if(a[i]-1>=0) num[a[i]-1]++;
    num[a[i]+1]++;
  }
  for(int i=0; i<100001; i++){
    maxx = max(maxx, num[i]);
  }
  cout << maxx << endl;
}

Measured memory_bytes: 1024
total_number = int(input())
input_list = input().split(" ")
list_count = 0
answer_count = 0
for i in input_list:
	list_count += 1
	if list_count % 2 == 1:
		if int(i) % 2 == 1:
			answer_count += 1
print(answer_count)

Measured memory_bytes: 9164
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)

Measured memory_bytes: 45268
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	char c;
	cin >> c;
	c++;
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define remax(a,b)         a=max(a,b)
#define remin(a,b)         a=min(a,b)
#define bitcount(x)        __builtin_popcountll(x)
#define iceil(n,x)         (((n)-1)/(x)+1)
#define flush              fflush(stdout)
#define pf                 push_front()
#define pob                pop_back()
#define ins                insert
#define mii                map<int,int> 
#define show(x)            for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define show2(x)           for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";
#define test()             int x;cin >> x;while(x--){solve();}
#define test2()            int x;cin >> x;for(int i=1;i<=x;i++){cout << "Case #" << i << " : ";solve();}
#define watch(x)           cout << (#x) << " is " << (x) << endl
using namespace std;


/* Mathematical Functions */
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);

const int inf = (int)1e17;
const int N = (int)3e5+5;

int32_t main(){


	FASTIO;
	char ch;
	cin >> ch;
	if(ch >= 'A' && ch <='Z'){
		cout << "A\n";
	}
	else
		cout << "a\n";
    return 0;

}
int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}
 
int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}
 
int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}
 
bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    char x, y;
    cin >> x >> y;
    if (x > y) cout << ">\n";
    else if (x < y) cout << "<\n";
    else cout << "=\n";
    return 0;
}

Measured memory_bytes: 256
import           Control.Monad
import           Data.List
import           Data.Maybe
import qualified Data.ByteString.Char8         as C8

getInt :: IO Int
getInt = fmap (fst . fromJust . C8.readInt) C8.getLine

getInts :: IO [Int]
getInts = fmap (map (fst . fromJust . C8.readInt) . C8.words) C8.getLine

main :: IO ()
main = do
    [n, k] <- getInts
    hs     <- replicateM n $ getInt
    print $ solve k (sort hs)

solve :: Int -> [Int] -> Int
solve k hs = minimum . zipWith (-) (drop (k - 1) hs) $ hs


Measured memory_bytes: 30972
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main{
    public static void main(String[] args) throws IOException {

	BufferedReader br = null;

	try {
	    br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();

	    for (String line = br.readLine(); line != null; line = br.readLine()) {
		lines.add(line);
	    }

	    /**

	    lines.add("aaaaaaaaaa");
	    lines.add("bb bb bb aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa");
	    lines.add("aaa aaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa");
	    lines.add("aaaaaaaaaa xxx xxxxxxxxx aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa");
	    lines.add("aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa b b b b b b b aaaaaaaaaa aaaaaaaaaa");
	    lines.add("aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaaa a a a a");
	    lines.add("aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa");
	    lines.add("aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa a a a a");
	    lines.add("aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa x");
	    lines.add("aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa x x x x");
	    lines.add("aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa x x xaaaaaaaaaa");
	    lines.add("END_OF_TEXT"); */

	    String keyword = lines.get(0).toLowerCase();
	    Integer count = 0;

	    for (int i = 1; i < lines.size() - 1; i++) {
		for (String e : lines.get(i).split(" ")) {
		    String word = e.toLowerCase();
		    if (word.equals(keyword)) {
			count++;
		    }
		}
	    }

	    System.out.println(count);
	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	} finally {
	    br.close();
	}
    }
}

Measured memory_bytes: 24388
#include<iostream>
using namespace std;
#include<stdio.h>

int main(void)
{
	int x,y,c,a,s,n,i=0,j[1000];
	scanf("%d%d%d",&x,&y,&c);
	if(x<y){
		s=x;
		x=y;
		y=s;
	}
	for(n=1;n<=y;n++){
		if(y%n==0){
			j[i]=n;
			i=i+1;
		}
	}
	for(n=0;n<i;n++){
		if(x%j[n]==0){
			a=j[n];
		}
	}
	x=x/a;
	y=y/a;
	printf("%d\n",x*y*c);
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

void solve(vector<vll>& graph, vll& counter, vll& ans, bool* visited, ll node, ll val){
  visited[node] = true;
  ans[node] = val;
  for(auto n : graph[node]){
    if(!visited[n]) solve(graph, counter, ans, visited, n, val + counter[n]);
  }
}

int main(){
  ll N, Q;
  cin >> N >> Q;
  vector<vll> graph(N+1);
  vll counter(N+1, 0), ans(N+1, 0);
  bool visited[N+1] = {};

  rep(i, N-1){
    ll a, b;
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  rep(i, Q){
    ll p, x;
    cin >> p >> x;
    counter[p] += x;
  }
  solve(graph, counter, ans, visited, 1, counter[1]);
  repi(i, 1, N+1){
    if(i < N) cout << ans[i] << " ";
    else cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 32256
line = gets.split(' ')

N = line[0].to_i
K = line[1].to_i

ans = 0.0
for i in 1..N do
  prob = 1.0 / N
  current = i
  while current < K do
    current *= 2
    prob /= 2
  end
  ans += prob
end
puts ans

Measured memory_bytes: 14240
#include <iostream>
#include <map>

using namespace std;

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

	int n;
	cin >> n;

	map<unsigned long, unsigned long> ls;

	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		if(ls.count(a) == 0)
		{
			ls[a] = 1;
		}
		else
		{
			ls[a]++;
		}
	}

	int side1 = 0;

	for (auto i = ls.rbegin(); i != ls.rend(); ++i)
	{
		if (side1 == 0 && i->second >= 4) {
			cout << i->first * i->first;
			return 0;
		}
		
		if (i->second >= 2)
		{
			if (side1 == 0) {
				side1 = i->first;
			}
			else
			{
				cout << side1 * i->first;
				return 0;
			}
		}
	}

	cout << 0;
	return 0;
}


Measured memory_bytes: 6528
n = int(input())
list_a = list(map(int, input().split()))
list_b = list(map(int, input().split()))

count = 0
prev = list_a[0]

for i in range(n):
    if list_b[i] <= prev:
        count += list_b[i]
        prev = list_a[i + 1]
    else:
        count += prev
        if list_b[i] - prev >= list_a[i + 1]:
            count += list_a[i + 1]
            prev = 0
        else:
            count += list_b[i] - prev
            prev = list_a[i + 1] - list_b[i] + prev

print(count)


Measured memory_bytes: 19156
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
	int a, b, x;
  	cin >> a >> b >> x;
 	if (x >= a && x <= a+b) {
    	cout << "YES" << endl;
    } else {
    	cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

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

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int main(){
    string s;
    cin >> s;
    if(*(s.end()-1) == 's'){
        s += "es";
    }else{
        s += "s";
    }
    cout << s << endl;
}

Measured memory_bytes: 3628
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main implements Runnable {
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        
        long ans = (n-2)*180;
        	
        System.out.println(ans);
    }

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21204
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

D = lines[0][0]

class Array
  def max_id
    max = - 10000000000
    tmp = -1
    for i in 1..self.length do
      if self[i-1] > max then
        tmp = i-1
        max = self[i-1]
      end
    end
    return tmp
  end
end
  
for i in 1..D do
  puts lines[i].max_id + 1
end

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

bool dfs(int a, int L, vector<vi>& g, vi& btoa, vi& A, vi& B) {
	if (A[a] != L) return 0;
	A[a] = -1;
	trav(b, g[a]) if (B[b] == L + 1) {
		B[b] = 0;
		if (btoa[b] == -1 || dfs(btoa[b], L + 1, g, btoa, A, B))
			return btoa[b] = a, 1;
	}
	return 0;
}

int hopcroftKarp(vector<vi>& g, vi& btoa) {
	int res = 0;
	vi A(g.size()), B(btoa.size()), cur, next;
	for (;;) {
		fill(all(A), 0);
		fill(all(B), 0);
		/// Find the starting nodes for BFS (i.e. layer 0).
		cur.clear();
		trav(a, btoa) if(a != -1) A[a] = -1;
		rep(a,0,sz(g)) if(A[a] == 0) cur.push_back(a);
		/// Find all layers using bfs.
		for (int lay = 1;; lay++) {
			bool islast = 0;
			next.clear();
			trav(a, cur) trav(b, g[a]) {
				if (btoa[b] == -1) {
					B[b] = lay;
					islast = 1;
				}
				else if (btoa[b] != a && !B[b]) {
					B[b] = lay;
					next.push_back(btoa[b]);
				}
			}
			if (islast) break;
			if (next.empty()) return res;
			trav(a, next) A[a] = lay;
			cur.swap(next);
		}
		/// Use DFS to scan for augmenting paths.
		rep(a,0,sz(g))
			res += dfs(a, 0, g, btoa, A, B);
	}
}

const int V = 1.1e7;
bool isPrime[V + 1];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	for (int i = 2; i <= V; i++) isPrime[i] = true;
	for (int p = 2; p <= V; p++) {
		if (!isPrime[p]) continue;
		for (int j = p+p; j <= V; j += p) isPrime[j] = false;
	}

	int N; cin >> N;
	vector<int> X(N);
	map<int, int> evtCnt;
	for (int i = 0; i < N; i++) {
		cin >> X[i];
		evtCnt[X[i]] ^= 1;
		evtCnt[X[i]+1] ^= 1;
	}
	vector<int> left;
	vector<int> right;
	for (auto it : evtCnt) {
		if (it.second == 0) continue;
		if (it.first & 1) right.push_back(it.first);
		else left.push_back(it.first);
	}

	int A = int(left.size());
	int B = int(right.size());
	vector<vector<int>> g(A);
	vector<int> btoa(B, -1);
	isPrime[2] = false;
	for (int i = 0; i < A; i++) {
		for (int j = 0; j < B; j++) {
			if (isPrime[abs(left[i] - right[j])]) {
				g[i].push_back(j);
			}
		}
	}

	int ans = hopcroftKarp(g, btoa); // number that can be paired
	cerr << ans << ' ' << A << ' ' << B << '\n';
	A -= ans, B -= ans;
	cout << ans + (A/2) * 2 + (B/2) * 2 + (A % 2 ? 3 : 0) << '\n';

	return 0;
}


Measured memory_bytes: 11008