akhauriyash/Code-Regression huggingface dataset:
//////////////////////////////////////
////       ABHINASH GIRI          ////
/////////////////////////////////////
#include<bits/stdc++.h>
using namespace std;
#define pr 4294967296   // 2^32
#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define high 1000000001
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             -1e18
#define pinf              1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define e               1000000000
#define w(x)            int t; cin>>t; while(t--)
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define co(x) cout<<(x)<<"\n"
#define endl "\n"
typedef unsigned long int  ul;
typedef unsigned long long int ull;
typedef unsigned long long  int  li;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<long int> vl;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long int,long int>> vpl;
typedef vector<pair<long long int,long long int>> vpll;
typedef long long ll;
bool cmp(pair<char,int>a,pair<char,int>b)
{
    if(a.first==b.first)
        return a.second<b.second;
    return a.first>b.first;
}
int main() {
    std::chrono::time_point<std::chrono::high_resolution_clock> start_timer, end_timer;
    start_timer = std::chrono::high_resolution_clock::now();
    bool show_time = false;  //  change it to true when needed;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    #endif

    /* Cook your Code  */
    fast;
    int n,m;
    cin>>n>>m;
    vl h(n+1,0);
    for (int i = 1; i <=n ; ++i) {
        cin>>h[i];
    }
    map<int,vector<int>>mp;
    int a,b;
    for (int j = 0; j <m ; ++j) {
        cin>>a>>b;
        mp[a].push_back(h[b]);
        mp[b].push_back(h[a]);
    }
    ll ans=0;
//    for (auto &i:mp) {
//        cout<<i.first<<" ->>>>> ";
//        for(auto &j:i.second)
//        {
//            cout<<j<<" ,";
//        }
//        cout<<endl;
//    }
    for(auto &i:mp)
    {
        if(i.second.empty())
        {
            ans++;
        }
        else
        {
            sort(i.second.begin(),i.second.end());
            int it = lower_bound(i.second.begin(),i.second.end(),h[i.first])-i.second.begin();
            //cout<<it<< " it for i="<<i.first<<endl;
            if(it==i.second.size())
            {
                ans++;
            }
        }
    }
    cout<<ans+n-mp.size()<<endl;
    


    end_timer = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end_timer-start_timer).count();
    if(show_time)
    {cout << "\\nElapsed Time: " << elapsed_time << "ms\\n";}

    return 0;
}

Measured memory_bytes: 13476
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,data[10000];
  while(cin>>n&&n){
    int cnt=0,sum=0;
    for(int i=0;i<n;++i){
      cin>>data[i];
      sum+=data[i];
    }
    int ave=sum/n;
    for(int i=0;i<n;++i){
      if(data[i]<=ave) ++cnt;
    }
    cout<<cnt<<endl;
  }
  return 0;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 2e5 + 6;
const int M = 1e9 + 7;
int A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int n;

void solve()
{
	int a;
	cin >> a;
	a--;

	loop(i,0,32)
	{
		if(i == a)
		{
			cout << A[i];
		}
	}
}
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
    

 	
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}


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

using namespace std;

typedef long long ll;

int main(){
  ll N;
  cin >> N;
  vector<ll> a(N);
  for(int i=0; i<N; i++) cin >> a[i];

  ll s = 0;
  for(int i=0; i<N; i++) s ^= a[i];

  vector<ll> ret;
  for(int i=0; i<N; i++) ret.emplace_back(s^a[i]);

  for(int i=0; i<N; i++) cout << ret[i] << " ";
  cout << endl;
  return 0;
}

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

int counter[200010] = {0};
vector<vector<int> > v(200010);

void dfs(int corrent, int previous) {
  if(previous != -1) counter[corrent] += counter[previous];
  for(int i=0; i < v[corrent].size(); i++) {
    if(v[corrent][i] == previous) continue;
    dfs(v[corrent][i], corrent);
  }
}

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

  for(int i=0; i < q; i++){
    int p, x; cin >> p >> x;
    p--;
    counter[p] += x;
  }

  dfs(0, -1);

  for(int i=0; i < n; i++) {
    cout << counter[i] << (i == n-1 ? "" : " ");
  }
  cout << endl;
}


Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const int MAX_V = 200000;
typedef pair<int, int> P;
struct edge
{
    ll to;
    ll cost;
};
vector<vector<edge>> G(MAX_V);
vector<ll> dijkstra(ll s, ll N)
{
    vector<ll> value(N, INF);
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(P(0, s));
    value[s] = 0;
    while (!que.empty())
    {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (value[v] < p.first)
        {
            continue;
        }
        rep(i, G[v].size())
        {
            edge e = G[v][i];
            if (value[e.to] > value[v] + e.cost)
            {
                value[e.to] = value[v] + e.cost;
                que.push(P(value[e.to], e.to));
            }
        }
    }

    return value;
}
int main()
{
    int N, u, v;
    cin >> N >> u >> v;
    u--; v--;

    rep(i, N - 1) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        G[A].push_back({B, 1});
        G[B].push_back({A, 1});
    }

    auto du = dijkstra(u, N);
    auto dv = dijkstra(v, N);

    ll a1 = INF;
    rep(i, N) {
        if (du[i] == dv[i]) chmin(a1, du[i]);
    }

    ll a2 = 0;
    rep(i, N) {
        if ((int)G[i].size() <= 1) continue;
        if (dv[i] > du[i]) chmax(a2, dv[i]);
    }

    ll ans = a2;
    // cout << a1 << " " << a2 << endl;
    if (a1 != INF && a2 == 0) ans = a1;

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

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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(a, b);
  cout << ((a + b + 1) / 2) << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc =new Scanner(System.in);
		int n=sc.nextInt();
		String S=sc.next();
		int e[]=new int[n];
		char[] c=S.toCharArray();
		for(int i=1;i<n;i++) {
			if(c[i]=='E')e[0]++;
		}
		int ans=e[0];
		for(int i=1;i<n;i++) {
			e[i]=e[i-1];
			if(c[i]=='E')e[i]--;
			if(c[i-1]=='W')e[i]++;
			if(ans>e[i])ans=e[i];
		}
		System.out.println(ans);

	}

}




Measured memory_bytes: 30988
n,m=map(int,input().split())
a=[]
b=[]
for _ in range(n):
    x=[1 if s=='#' else 0 for s in input()]
    a.append(x)

for _ in range(m):
    x=[1 if s=='#' else 0 for s in input()]
    b.append(x)

for h in range(n-m+1):
    for w in range(n-m+1):
        tmpa=[a[x][w:w+m] for x in range(h,h+m)]
        if tmpa==b:
            print('Yes')
            exit()
print('No')

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

int main(){
  int n,cnt=0; cin >>n;
  bool three = false;
  rep(i,n){
    int a,b; cin >>a >>b;
    if(a==b) cnt++;
    else cnt=0;
    if(cnt==3) three = true;
  }
  if(three) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3564
#!/usr/bin/env python3
import math

n, d = map(int, input().split())
x = [0 for _ in range(n)]
y = [0 for _ in range(n)]
for i in range(n):
    x[i], y[i] = map(int, input().split())

def dist(x, y): 
    return math.sqrt(x*x + y*y)
   
ans = 0 
for i in range(n):
    if d >= dist(x[i], y[i]):
        ans += 1

print(ans)


Measured memory_bytes: 24672
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n=int(input())
    graph=[[]for _ in range(n)]
    for i in range(n-1):
        a,b=map(int,input().split())
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    C=list(map(int,input().split()))
    C.sort(reverse=True)#頂点の値が大きい順に
    node_c=[0]*n #各頂点の値 0なら初めて
    node_c[0]=C[0]
    queue=deque([0])
    i=1
    while queue:
        node=queue.popleft()
        for xnode in graph[node]:
            if node_c[xnode]>0:continue
            node_c[xnode]=C[i]
            i+=1
            queue.append(xnode)
    print(sum(C[1:]))
    print(' '.join(map(str,node_c)))

if __name__=='__main__':
    main()

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

const int N=101009,p=998244353,inv2=p+1>>1;
char A[N],B[N],C[N],D[N];
int fac[N<<2],inv[N<<2];
int n,m,ans;

inline int qpow(int A,int B){
	int res(1);while(B){
		if(B&1)res=(ll)res*A%p;
		A=(ll)A*A%p,B>>=1;
	}return res;
}

inline int Com(int nn,int mm){return (ll)fac[nn]*inv[mm]%p*inv[nn-mm]%p;}
void prework(int A){
	fac[0]=inv[0]=1;
	for(int i=1;i<=A;++i)fac[i]=(ll)fac[i-1]*i%p;
	inv[A]=qpow(fac[A],p-2);
	for(int i=A-1;i;--i)inv[i]=(ll)inv[i+1]*(i+1)%p;
}

void work(){
	int left=0,right=0,l=0,r=0,pre=1,val;
	for(int i=1;i<=n;++i)left+=A[i]-'0',right+=B[i]-'0';
	for(int i=m;i;--i)r+=C[i]-'0'+D[i]-'0';
	for(int i=1;i<=m;i++){
		l+=C[i]-'0'+D[i]-'0';
		r-=C[i]-'0'+D[i]-'0';
		if(C[i]=='0' and D[i]=='0')continue;
		if(C[i]=='1' and D[i]=='1')pre=2ll*pre%p;
		if(right)val=Com(right+r-1,r);
		else val=(!r);		ans=(ans+(ll)pre*val)%p;
		if(left)val=Com(left+l-1,l);
		else val=(!l);		pre=(pre+val)%p;
	}
}

int main(){//quiet!!!
	scanf("%d%d",&n,&m);
	prework(n+m+n+m);
	scanf("%s%s",A+1,B+1);
	scanf("%s%s",C+1,D+1);
	bool died=true;
	for(int i=1;i<=n;++i)
		if(A[i]=='1' or B[i]=='1' or C[i]=='1' or D[i]=='1')
			{died=false;break;}
	if(died){puts("1");return 0;}
	work();
	swap(n,m);swap(A,C);
	swap(B,D);swap(C,D);
	work();
	printf("%d\n",ans);
	return 0;
}

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

int N;
vector<vector<vector<double>>> dp;

double solve(int i, int j, int k){
    // cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
    if(dp[i][j][k]>=0) return dp[i][j][k];

    double ret = N;
    if(i>0) ret += i*solve(i-1, j, k);
    if(j>0) ret += j*solve(i+1, j-1, k);
    if(k>0) ret += k*solve(i, j+1, k-1);

    ret/=(i+j+k);
    dp[i][j][k] = ret;
    return dp[i][j][k];
}

int main(){
    cin >> N;
    dp.resize(N+1, vector<vector<double>>(N+1, vector<double>(N+1, -1.0)));
    dp[0][0][0] = 0;

    vector<int> cnt(3,0);
    for(int i=0; i<N; i++){
        int a;  cin >> a;
        cnt[a-1]++;
    }

    cout << setprecision(15) << solve(cnt[0], cnt[1], cnt[2]) << endl;
}


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

#define MP make_pair
#define PB push_back
#define ll long long int
#define F first
#define S second
#define MAX(x,y) (x)>(y)?(x):(y)
#define MIN(x,y) (x)<(y)?(x):(y)
#define REP(i,a,n) for(i=a;i<(n);i+=1)
#define REPL(i,a,n) for(i=a;i<=(n);i+=1)
#define REPr(i,n) for(i=n-1;i>=0;i-=1)

typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int>::iterator sit;
typedef unordered_set<int>::iterator usit;
typedef multiset<int>::iterator msit;
typedef unordered_multiset<int>::iterator umsit;
typedef vector<ll>::iterator vllit;

//cin.ignore(numeric_limits<streamsize>::max(),'\n');

ll MAX3(ll x, ll y, ll z){
    ll temp = max(x,y);
    return max(temp,z);
}

void min_self(ll& a, ll b){
    a = min(a,b);
}

const ll INF = 1e18L + 5;

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<int> weight(n), value(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d%d", &weight[i], &value[i]);
    }
    int sum_value = 0;
    for(int x : value) {
        sum_value += x;
    }
    vector<ll> dp(sum_value + 1, INF); // 0 ... W
    dp[0] = 0;
    // dp[i] - the minimum total weight of items with total value exactly i
    for(int item = 0; item < n; ++item) {
        for(int value_already = sum_value - value[item]; value_already >= 0; --value_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            min_self(dp[value_already+value[item]], dp[value_already] + weight[item]);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= sum_value; ++i) {
        if(dp[i] <= W) {
            answer = max(answer, (ll) i);
        }
        //~ min_self(answer, dp[i]);
    }
    printf("%lld\n", answer);

    return 0;
}

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

#define f first
#define s second
#define ins insert
#define eb emplace_back
#define endl '\n'
#define ll long long
#define ld long double
#define vl vector<ll>
#define tc ll t; cin >> t; while (t--)
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define sz(c) (ll) c.size()
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define trav(x,c) for(auto &x : c)
#define _for(i,a,n) for(ll i = a ; i < n ; ++i)
#define _rfor(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) trav(x,c) cout << x << " "; cout << endl;
#define dm(m) trav(x,m) cout << x.f << " " << x.s << endl;
#define godspeed ios::sync_with_stdio(0); cin.tie(0);

int main() {
    godspeed;
    ll n, k; cin >> n >> k;

    ll cnt = 0;
    while(n) {
    	cnt++;
    	n /= k;
    }

    cout << cnt;
}	

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }
    if(s.size() < 26){
        vector<bool> vis(26, false);
        rep(i, s.size())vis[s[i]-'a'] = true;
        char c;
        rep(i, 26)if(!vis[i]){
            c = 'a' + i;
            break;
        }
        cout << s + c << endl;
    }else{
        int idx = 0;
        rep(i, s.size()-1)if(s[i] < s[i+1])idx = i;
        vector<bool> vis(26, false);
        rep(i, idx+1)vis[s[i]-'a'] = true;
        for(char c = s[idx] + 1; c <= 'z'; c++){
            if(!vis[c-'a']){
                string ans = s.substr(0, idx);
                cout << ans + c << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3576
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
using namespace std;

int const MAX_N = 512 * 1024;

void my_gets(char * st) {
	int len = 0;
	char ch = getc(stdin);
	while (ch != '\n' && ch != '\r' && ch != 0 && !feof(stdin)) {
		st[len++] = ch;
		ch = getc(stdin);
	}
	st[len] = 0;
}

int s[100000];

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int c1 = 0, c2 = 0, c3 = 0;
	int n, a, b;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) cin >> s[i];
	for (int i = 0; i < n; i++)
		if (s[i] <= a) c1++;
		else if (s[i] <= b) c2++;
		else c3++;
	cout << min(c1, min(c2, c3));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,k,d[10],i,j,t;
int main(){
	string s;
	cin>>n>>k;
	for(i=1;i<=k;i++){
		cin>>t;
		d[t]=1;
	}
	for(i=n;i<=100*n;i++){
		stringstream ss;
		ss<<i;
		s=ss.str();
		for(j=0;j<s.size();j++)if(d[s[j]-'0']==1)break;
		if(j==s.size()){
			cout<<i;
			return 0;
		}
	}
	return 0;
} 

Measured memory_bytes: 256
h, w, k = map(int,input().split())
c = [0] * h
ans = 0

for i in range(h):
  c[i] = input()

for rows in range(1 << h):
  for cols in range(1 << w):
    black = 0
    for i in range(h):
      if (rows >> i) % 2 == 1:
        continue
      for j in range(w):
        if (cols >> j) % 2 == 1:
          continue
        if c[i][j] == '#':
          black += 1
    if black == k:
      ans += 1

print(ans)

Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  
  cin >> a >> b >> c;

  if ((a*100+b*10+c)%4 == 0) anss = "YES";
  else anss = "NO";
  
  cout << anss << endl;

}

Measured memory_bytes: 256
def main():
    H,W=map(int,input().split())
    m=[input() for _ in range(H)]
    is_ok = True
    for h in range(H):
        for w in range(W):
            if m[h][w] == "#":
                if -1 < h-1 and m[h-1][w] == "#":
                    pass
                elif -1 < w-1 and m[h][w-1] == "#":
                    pass
                elif h+1 < H and m[h+1][w] == "#":
                    pass
                elif w+1 < W and m[h][w+1] == "#":
                    pass
                else:
                    print("No")
                    return
    print("Yes")
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

bool comp(pair<int, string> a, pair<int, string> b) {
    if (a.first != b.first) {
        return a.first > b.first;
    } else {
        return a.second < b.second;
    }
}

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

    int N;
    cin >> N;
    map<string, int> mp;
    for (int i = 0; i < N; ++i) {
        string s;
        cin >> s;
        mp[s]++;
    }
    vector<pair<int, string> > V;
    for (auto &p : mp) {
        V.push_back(make_pair(p.second, p.first));
    }
    sort(V.begin(), V.end(), comp);
    for (int i = 0; i < V.size(); ++i) {
        cout << V.at(i).second << endl;
        if (i == V.size() - 1 || V.at(i).first > V.at(i + 1).first) {
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 28016
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    n = I()
    a = LI()
    b = [a[0]]
    for c in a[1:]:
        b.append(b[-1]+c)
    d = [0] * n
    d[-1] = a[-1]
    for i in range(n-2,-1,-1):
        d[i] = d[i+1] + a[i]

    g = [[] for _ in range(n)]
    g[0] = [0,inf]
    j = 0
    for i in range(1,n):
        t = b[i]
        k = abs((b[i] - b[j]) - b[j])
        while j < i-1 and k > abs((b[i] - b[j+1]) - b[j+1]):
            k = abs((b[i] - b[j+1]) - b[j+1])
            j += 1
        g[i].append(b[j])
        g[i].append(b[i] - b[j])

    g[-1] = [0,inf]
    g[-2] = [0,inf]
    j = n-1
    for i in range(n-2,-1,-1):
        t = d[i]
        k = abs((d[i] - d[j]) - d[j])
        while j > i+1 and k > abs((d[i] - d[j-1]) - d[j-1]):
            k = abs((d[i] - d[j-1]) - d[j-1])
            j -= 1
        g[i-1].append(d[i] - d[j])
        g[i-1].append(d[j])

    r = inf
    for i in range(n):
        t = max(g[i]) - min(g[i])
        if r > t:
            r = t

    return r



print(main())


Measured memory_bytes: 68340
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a[5];
  for(int i=0;i<5;i++)cin>>a[i];
  int x=10;
  for(int i=0;i<5;i++){
    if(a[i]%10<x&&a[i]%10>0){
      x = a[i]%10;
    }
  }
  int sum=0;
  for (int i=0;i<5;i++){
    if(a[i]%10!=0){
      sum = sum + (a[i]/10+1)*10;
    }
    else
      sum=sum+a[i];
  }
  cout<<sum-(10-x)<<endl;
}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    bool flag = false;
    for(int i = 0; i < s.length()-1; ++i)
    {
        if(s[i]==s[i+1]) {flag=true;break;}
    }
    if(flag) puts("Bad");
    else puts("Good");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = Integer.parseInt(sc.next());
      String S = sc.next();
      
      char[] ch = S.toCharArray();
      
      int result = 1;
      
      for (int i = 1; i < N; ++i) {
        if (ch[i - 1] != ch[i]) result++;
      }
      
      
      System.out.println(result);
    }

}

Measured memory_bytes: 26984
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))//0或-1
#define fs first
#define sc second
#define mp make_pair
#define L(x) (1<<x)
#define next Next
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=2e5+10;
const int maxm=1e3+10;
const int mod=1e9+7;
int n;
int A[maxn];
int dp[2][maxn][30];
int cnt;
struct node
{
    int x,y,t1,t2,t3;
    bool friend operator < (const node &a,const node &b)
    {
        return a.x>b.x;
    }
}ans[maxn];
void init()
{
    for(int i=1;i<=n;i++)
        dp[i%2][(i+1)/2][0]=i;
    for(int op=0;op<=1;op++)
        for(int j=1;L(j)<=(n+1)/2;j++)
            for(int i=1;i+L(j)-1<=(n+1)/2;i++)
            {
                int t1=dp[op][i][j-1],t2=dp[op][i+(1<<(j-1))][j-1];
                if(A[t1]<A[t2])
                    dp[op][i][j]=t1;
                else dp[op][i][j]=t2;
            }
}
int querry(int L,int R,int op)
{
    if(op==1)
    {
        L=(L+1)/2;
        R=(R+1)/2;
    }
    else
    {
        L=(L)/2;
        R=(R)/2;
    }
    int t1,t2;
    int x=(int)(log(R-L+1.0)/log(2.0));
    t1=dp[op][L][x];
    t2=dp[op][R-L(x)+1][x];
    if(A[t1]<A[t2])
        return t1;
    else return t2;
}
int solve(int l,int r,int k)
{
    int st=querry(l,r,l%2);
    int ed=querry(st+1,r,(st+1)%2);
    int temp=cnt++;
    ans[temp].x=A[st];
    ans[temp].y=A[ed];
    ans[temp].t1=ans[temp].t2=ans[temp].t3=-1;
    if(st>l)
        ans[temp].t1=solve(l,st-1,k+1);
    if(ed<r)
        ans[temp].t2=solve(ed+1,r,k+1);
    if(ed-st>=3)
        ans[temp].t3=solve(st+1,ed-1,k+1);
    return temp;
}
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d",&n))
    {
        cnt=0;
        for(int i=1;i<=n;i++)
            scanf("%d",&A[i]);
        init();
        solve(1,n,1);
        priority_queue<node> Q;
        Q.push(ans[0]);
        while(!Q.empty())
        {
            node t=Q.top();
            Q.pop();
            printf("%d %d",t.x,t.y);
            if(t.t1!=-1) Q.push(ans[t.t1]);
            if(t.t2!=-1) Q.push(ans[t.t2]);
            if(t.t3!=-1) Q.push(ans[t.t3]);
            if(!Q.empty()) printf(" ");
            else printf("\n");
        }
        /*for(int i=0;i<n/2;i++)
            printf("%d %d %d\n",i,ans[i].x,ans[i].y);*/
    }
    return 0;
}


Measured memory_bytes: 43904
using System;

namespace AtCoder.BC087
{
    public class B
    {
        public static void Main()
        {
            int count = 0;
            int a, b, c, x;
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            c = int.Parse(Console.ReadLine());
            x = int.Parse(Console.ReadLine());

            for (int i = 0; i <= a; i++)
            {
                for (int j = 0; j <= b; j++)
                {
                    for (int k = 0; k <= c; k++)
                    {
                        int tmp = 500 * i + 100 * j + 50 * k;
                        if (tmp == x) count++;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 27352
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int count=0;
	for(int i=0;i<3;i++)
	{
		if(s[i]==t[i])
		{
			count++;
		}
		
		
	}
	cout<<count;
	
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e6 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

ll calc(ll h){
  if (h == 1) return 1;
  ll tmp = calc(h / 2);
  return tmp * 2 + 1;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  ll h; cin >> h;
  cout << calc(h);
}




Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}
int roundup(int a,int b){return	(a-1)/b+1;}

signed main(){
	int n,x;cin>>n>>x;
	vi a(n);
	rep(i,n) cin>>a[i];
	sort(All(a));
	int ans=0;
	rep(i,n-1){
		x-=a[i];
		if(x>=0) ans++;
	}
	if(a.back()==x) ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def calc(n):
    return sum(ord(c) - ord('0') for c in str(n))

def solve():
    n = int(input())
    ans = 1 << 60
    for i in range(1, n):
        a = n - i
        ans = min(ans, calc(a) + calc(i))
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
#include<stdio.h>

int main(){
  int len = 0, i, p;
  char s[100000], list[26] = {0};
  scanf("%s", s);
  
  while(s[len]){
    p = s[len] - 'a';
    list[p] = 1;
    len++;
  }
 for(i = 0; i < 26; i++){
   if(list[i] == 0){
     printf("%c", 'a' + i);
     break;
   }
 }
  if(i == 26){
    printf("None\n");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    ll n,a,b;
    cin >> n >> a >> b;
    ll cnt = n / (a + b);
    ll ans = a * cnt;
    ll kek = (n - (cnt * (a + b)));
    if(kek >= a){
        ans += a;
    }
    else{
        ans += kek;
    }
    cout << ans << '\n';
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
maze = [input() for i in range(H)]
dp_holi = [[0] * W for i in range(H)]
dp_ver = [[0] * W for i in range(H)]


#まずは水平方向について数える
for i in range(H):
    for j in range(W):
        if maze[i][j] == ".":
            if j - 1 < 0 or maze[i][j -1] == "#":
                tmp = 0
                flag = False
                for k in maze[i][j:]:
                    if k == ".":
                        tmp += 1
                        flag = True
                    else:
                        dp_holi[i][j] = tmp
                        break
                if flag:
                    dp_holi[i][j] = tmp
            elif maze[i][j - 1] == ".":
                dp_holi[i][j] += dp_holi[i][j - 1]

#垂直方向にも同じことをする
for i in range(H):
    for j in range(W):
        if maze[i][j] == ".":
            if i - 1 < 0 or maze[i -1][j] == "#":
                tmp = 0
                flag = False
                for k in range(i, H):
                    if maze[k][j] == ".":
                        tmp += 1
                        flag = True
                    else:
                        dp_ver[i][j] += tmp
                        flag = False
                        break
                if flag:
                    dp_ver[i][j] += tmp
            elif i - 1 < 0:
                continue
            elif maze[i - 1][j] == ".":
                dp_ver[i][j] += dp_ver[i - 1][j]

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, dp_holi[i][j] + dp_ver[i][j] - 1)
print(ans)

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main() {
	int n;
	int v[50];
	cin >> n;
	for(int i=0; i!=n; i++){
		cin >> v[i];
	}
	qsort(v, n, sizeof(int), compare_int);
	float ans;
	ans = v[0];
	for(int i=1; i!=n; i++){
		ans = (ans + v[i]) / 2;
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    char b;
    cin >> b;
    if(b == 'A') { printf("T\n"); }
    else if(b == 'T') { printf("A\n"); }
    else if(b == 'C') { printf("G\n"); }
    else if(b == 'G') { printf("C\n"); }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <queue>
using namespace std;
int main() {
	int n;
    cin >> n;
    if(n == 1) cout << "Hello World" << endl;
    if(n == 2){
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
}

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

int main() {
   int n,m;
  cin>>n>>m;
  int ans=0;
  
    bool ok=true;
  vector<set<int>> a(n);
    rep(i,n){
    		int k;
   			 cin>>k;
      //cout<<k<<endl;
      rep(j,k){
        int c;
    	 cin>>c;
        a[i].insert(c);
      }
    }
  /////////////////
 for(int i=1;i<=m;i++){
   ok=true;
      rep(j,n){
    	 if(!(a[j].count(i))){
     	    ok=false;
         }
        //cout<<j<<endl;
      }
    if(ok) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
int main() {
	int W, H, x, y, r;
	scanf("%d %d %d %d %d",  &W, &H, &x, &y, &r);
    if ((x + r > W) || (x - r < 0) ||
        (y + r > H) || (y - r < 0)) {
            printf("No\n");
    } else {
        printf("Yes\n");
    } 
}


Measured memory_bytes: 2692
a,b=map(int,input().split())
def xor_sum(x):
  r=x%2^x//2%2
  p=2
  for i in range(len(bin(x))-3):
    r+=p*(x%2<1 and x%(p*2)>=p)
    p*=2
  return r
print(xor_sum(a-1)^xor_sum(b))

Measured memory_bytes: 3060
n, x, y = map(int, input().split())
ans = [0] * n
for i in range(1, n+1):
    for j in range(i, n+1):
        r = min(
            abs(i-j),
            abs(x-i) + 1 + abs(y-j),
            abs(y-i) + 1 + abs(x-j)
        )
        ans[r] += 1

print("\n".join(map(str, ans[1:])))



Measured memory_bytes: 3188
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}


int main() {
	ll d;
	cin >> d >> n;
	ll res = 0;
	ll i = 0;
	if (d == 0) {
		for (i = 1;; ++i) {
			if (i % 100 != 0) {
				++res;
			}
			if (res == n) {
				break;
			}
		}
	}
	else if (d == 1) {
		for (i = 100;; i+=100) {
			if ((i/100) % 100 != 0) {
				++res;
			}
			if (res == n) {
				break;
			}
		}
	}
	else if (d == 2) {
		for (i = 10000;; i += 10000) {
			if ((i / 10000) % 100 != 0) {
				++res;
			}
			if (res == n) {
				break;
			}
		}
	}
	cout << i << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

string s;

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> s;
    int ind1, ind2, n = s.size();
    for ( int i = 0; i < n; i++ ) {
        if ( s[i] == 'A' ) {
            ind1 = i;
            break;
        }
    }
    for ( int i = n - 1; i >= 0; i-- ) {
        if ( s[i] == 'Z' ) {
            ind2 = i;
            break;
        }
    }
    cout << ind2 - ind1 + 1;
}



Measured memory_bytes: 720
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, K = map(int, input().split())

    ans = 0
    half = pow(2, mod-2, mod)
    for k in range(K, N+2):
        m = k * (k-1) * half
        M = k * (N*2 - k + 1) * half
        ans = (ans + (M - m + 1)%mod)%mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67688
n, m = list(map(int, input().split()))

roads = [[] for _ in range(n)]
for _ in range(m):
    f, t = list(map(int, input().split()))
    roads[f-1].append(t-1)
    roads[t-1].append(f-1)
for i in range(n):
    print(len(roads[i]))

Measured memory_bytes: 3060
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;

int n;
vector<int> adj[MAXN];
int ans[MAXN];

int par[MAXN];
int mxproperanc[MAXN];

int cnt1[MAXN]; // cnt1[i] = number of nodes in maximal connected subtree rooted at i that are all smaller than largest proper ancestor of i
int cnt2[MAXN]; // cnt2[i] = number of nodes in maximal connected subtree rooted at i that are all smaller than largest proper ancestor of par[i]


void dfsinit(int at) {
	cnt1[at]=at<mxproperanc[at]?1:0;
	REPSZ(i,adj[at]) {
		int to=adj[at][i]; if(to==par[at]) continue;
		par[to]=at; mxproperanc[to]=max(mxproperanc[at],at);
		dfsinit(to);
		if(at<mxproperanc[at]) cnt1[at]+=cnt1[to];
	}
	REPSZ(i,adj[at]) {
		int to=adj[at][i]; if(to==par[at]) continue;
		cnt2[to]=mxproperanc[to]==mxproperanc[at]?cnt1[to]:-1;
	}
}

void dfssolve(int at,int outside) {
	int sum=0;
	REPSZ(i,adj[at]) {
		int to=adj[at][i]; if(to==par[at]) continue;
		sum+=cnt2[to];
	}
	ans[at]=sum+1+outside;
	REPSZ(i,adj[at]) {
		int to=adj[at][i]; if(to==par[at]) continue;
		dfssolve(to,sum-cnt2[to]+1+outside);
	}
}

vector<int> evnt[MAXN];
int ufpar[MAXN],ufsz[MAXN];
int uffind(int a) { if(ufpar[a]==a) return a; return ufpar[a]=uffind(ufpar[a]); }
void ufunite(int a,int b) { a=uffind(a),b=uffind(b); if(a==b) return; if(ufsz[a]<ufsz[b]) swap(a,b); ufpar[b]=a,ufsz[a]+=ufsz[b]; }

void solve() {
	par[0]=-1; mxproperanc[0]=-1; dfsinit(0);
	
	REP(i,n) if(par[i]!=-1&&mxproperanc[par[i]]!=-1) evnt[mxproperanc[par[i]]].PB(i);
	REP(i,n) ufpar[i]=i,ufsz[i]=1;
	REP(i,n) if(par[i]!=-1&&mxproperanc[par[i]]==-1) cnt2[i]=0;
	REP(at,n) {
		REPSZ(i,evnt[at]) {
			int to=evnt[at][i];
			if(mxproperanc[to]==par[to]) { assert(cnt2[to]==-1); cnt2[to]=to<mxproperanc[par[to]]?ufsz[uffind(to)]:0; }
		}
		REPSZ(i,adj[at]) { int to=adj[at][i]; if(to<at) ufunite(at,to); }
	}

	//REP(i,n) printf("%d: mxproperanc1=%d mxproperanc2=%d cnt1=%d cnt2=%d\n",i+1,mxproperanc[i]+1,par[i]!=-1?mxproperanc[par[i]]+1:0,cnt1[i],cnt2[i]);
	REPSZ(i,adj[0]) { int to=adj[0][i]; dfssolve(to,0); }
}

void run() {
	scanf("%d",&n);
	REP(i,n-1) { int a,b; scanf("%d%d",&a,&b); --a,--b; adj[a].PB(b); adj[b].PB(a); }
	solve();
	FOR(i,1,n) { if(i!=1) printf(" "); printf("%d",ans[i]); } puts("");
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 39288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ash[100001][4];
int f(ll a[],ll b[],ll c[],ll d, ll n,ll aa,ll bb,ll cc)
{
    ll hw=0,bug=0,sw=0;
    if(d==n)
    return 0;
    if(aa==0)
    {
 if(ash[d][0]!=-1)
    return ash[d][0];
    }
      if(bb==0)
    {
 if(ash[d][1]!=-1)
    return ash[d][1];
    }
      if(cc==0)
    {
 if(ash[d][2]!=-1)
    return ash[d][2];
    }
    if(aa==0)
    {
      //  aa=1,bb=0,cc=0;
        sw=a[d]+max(f(a,b,c,d+1,n,1,0,1),f(a,b,c,d+1,n,1,1,0));
    }
      if(bb==0)
    {
        bug=b[d]+max(f(a,b,c,d+1,n,0,1,1),f(a,b,c,d+1,n,1,1,0));
    }
      if(cc==0)
    {
        hw=c[d]+max(f(a,b,c,d+1,n,0,1,1),f(a,b,c,d+1,n,1,0,1));
    }
    //cout<<max(bug,max(hw,sw))<<" ";
    //ash[d]=max(bug,max(hw,sw));
    if(aa==0)
    return ash[d][0]=max(bug,max(hw,sw));
    if(bb==0)
    return ash[d][1]=max(bug,max(hw,sw));
    if(cc==0)
    return ash[d][2]=max(bug,max(hw,sw));
}
int main()
{
    memset(ash,-1,sizeof(ash));
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(int i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
    ll maxxfun=f(a,b,c,0,n,0,0,0);
    cout<<maxxfun<<" ";
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    
    int count = 0;
    for(int i=0; i<s.size()/2; i++) {
        if (s[i] != s[s.size()-i-1]) count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> P;
#define rep(i,n) for(ll i=0;i<n;++i)
const int INF=1001001001;
int main(){
  ll n;
  cin>>n;
  vector<vector<P>> g(n);
  vector<int> cn(n,INF);
  vector<int> ce(n-1,INF);
  rep(i,n-1){
    int a1,b1;
    cin>>a1>>b1;
    a1--;b1--;
    g[a1].push_back(make_pair(b1,i));
    g[b1].push_back(make_pair(a1,i));

  }


queue <int> q;
q.push(0);
int maxc=0;
while (!q.empty()){
  int now=q.front();
  q.pop();
  int cnt=1;

  for(auto to:g[now]){
    int nod=to.first;
    int edg=to.second;

    if (ce[edg]!=INF)continue;
    if (cn[now]==cnt) cnt++;
    ce[edg]=cnt;
    cn[nod]=cnt;
    maxc=max(maxc,cnt);
    q.push(nod);
    cnt++;
  }

}
cout<<maxc<<endl;
rep(i,n-1){
  cout<<ce[i]<<endl;
}






  }


Measured memory_bytes: 7424
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

a_s = (a + (10 - a%10) if (a%10 != 0) else a)
a_a = a%10
b_s = (b + (10 - b%10) if (b%10 != 0) else b)
b_a = b%10
c_s = (c + (10 - c%10) if (c%10 != 0) else c)
c_a = c%10
d_s = (d + (10 - d%10) if (d%10 != 0) else d)
d_a = d%10
e_s = (e + (10 - e%10) if (e%10 != 0) else e)
e_a = e%10

answer = (a_s + b_s + c_s + d_s + e_s)

List =[]
List.append(a_a)
List.append(b_a)
List.append(c_a)
List.append(d_a)
List.append(e_a)
List.sort()

for i in range(5):
    if(List[i] != 0):
        answer = answer - (10-List[i])
        break

print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main(){
  ll n;cin>>n;
  ll arr[n];
  for(ll i=0;i<n;i++){
    cin>>arr[i];
  }
  ll cur=arr[0],max=0,x=0;
  for(ll i=1;i<n;i++){
    if(cur>=arr[i]){
      x++;
//      cout<<"M";
        cur=arr[i];
        }
    else {
        if(x>max)
          max=x;
        x=0;
        cur=arr[i];
    }
  }
  //cout<<max<<" "<<x;
        if(max<x)
            max=x;
  cout<<max;
}
  

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

int main(){
    ll n, m, d;
    cin >> n >> m >> d;
    double dn = n, dm = m, dd = d;
    double ans;
    if(d == 0) ans = (dm - 1) / dn;
    else ans = (dm - 1) * 2.0 * (dn - dd) / (dn * dn);
    printf("%.10lf\n", ans);
    return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<ll> record (n);
    for(int i=0;i<n;i++){
        cin>>record[i];
    }
    ll ans = 0;
    for(int i=1;i<n;i++){
        if(record[i-1] > record[i]){
            ans += record[i-1] - record[i];
            record[i] = record[i-1];
        }
    }
    cout<<ans;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)


int main(){
    ll n, d, a;
    cin >> n >> d >> a;
    priority_queue<array<ll, 3>> que;
    REP(i, n){
        ll xi, hi;
        cin >> xi >> hi;
        que.push({xi, 1, hi});
    }

    ll ans = 0;
    ll cum_damage = 0;
    while(!que.empty()){
        const auto arr = que.top(); que.pop();
        if(arr.at(1) == 1){  // monster
            const ll xi = arr.at(0);
            ll hi = arr.at(2);
            hi -= cum_damage;
            if(hi > 0){
                const ll nbomb = (hi + a - 1) / a;
                ans += nbomb;
                cum_damage += a * nbomb;
                que.push({xi - 2 * d, 0, - a * nbomb});
            }
        }else{  // event
            cum_damage += arr.at(2);
            assert(cum_damage >= 0);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8304
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int n = str.length();
        int count = 0;
        for (int i = 0; i < n / 2; i++) {
            if (str.charAt(i) != str.charAt(n - i - 1)) {
                count++;
            }
        }
        
        System.out.println(count);
    }
}


Measured memory_bytes: 25300
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a <= 8 && b <= 8) {
            System.out.println("Yay!");
            return;
        }
        System.out.println(":(");
    }

}


Measured memory_bytes: 25172
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int n, d[100000];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d, d + n);
	
	cout << d[n / 2] - d[(n - 2) / 2] << endl;

	return 0;
}

Measured memory_bytes: 768
n = int(input())
p = 10**9+7
s1 = input() #sys.stdin.readlineは最後が改行
s2 = input() #sys.stdin.readlineは最後が改行

ans = 1
pat = 0
i=0
while i<n:
    if s1[i] == s2[i]:
        if pat==1:
            ans*=2
        elif pat==2:
            ans*=1
        else:
            ans *=3
        ans %=p
        pat=1
        i+=1
    elif s1[i] != s2[i]:
        if pat==1:
            ans*=2
        elif pat==2:
            ans*=3
        else:
            ans *=6
        ans %=p
        pat=2
        i+=2

print(ans%p)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		if (N < 1200) {
			System.out.println("ABC");
		} else if (N < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}
	}

}

Measured memory_bytes: 23636