akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define MAX 100002

int n;

vector<int> v[MAX];

int dp[MAX];
int cnt[MAX];
multiset<int> vv[MAX];
multiset<int> tmp[MAX];

bool can;
int mx;
vector<int> unf[MAX];
int C;
inline void dfs(int b, int pr = -1) {
	vv[b].clear();
	unf[b].clear();
	int deg = 0;
	for (int go : v[b]) {
		if (go == pr)continue;
		dfs(go, b);
		deg++;
		vv[b].insert(dp[go] + 1);
	}
	tmp[b] = vv[b];
	C += deg/2;
	if (deg % 2 && b == 0) {
		C++;
	}
	if (vv[b].size()) {
		int la = (*vv[b].rbegin());
		if (la > mx) {
			can = true;
			dp[b] = 0;
			return;
		}
	}
	while (vv[b].size() > 1) {
		int bc = *vv[b].rbegin();
		vv[b].erase(prev(vv[b].end()));
		int able = mx - bc;
		auto it = vv[b].upper_bound(able);
		if (it == vv[b].begin()) {
			unf[b].push_back(bc);
			continue;
		}
		it = prev(it);
		vv[b].erase(it);
	}
	if (vv[b].size()) {
		unf[b].push_back(*vv[b].begin());
	}
	vv[b].clear();
	if (deg%2&&unf[b].size() > 1) {
		can = true;
		dp[b] = 0;
		return;
	}
	if (deg % 2) {
		dp[b] = unf[b][0];
		return;
	}
	else {
		if (unf[b].size() == 0) {
			dp[b] = 0;
			return;
		}
		else {
			if (b == 0) {
				can = true;
				dp[b] = 0;
				return;
			}
			vv[b] = tmp[b];
			unf[b].clear();
			vv[b].erase(prev(vv[b].end()));
			while (vv[b].size() > 1) {
				int bc = *vv[b].rbegin();
				vv[b].erase(prev(vv[b].end()));
				int able = mx - bc;
				auto it = vv[b].upper_bound(able);
				if (it == vv[b].begin()) {
					unf[b].push_back(bc);
					continue;
				}
				it = prev(it);
				vv[b].erase(it);
			}
			if (vv[b].size()) {
				unf[b].push_back(*vv[b].begin());
			}
			if (unf[b].size() == 1) {
				dp[b] = unf[b][0];
				return;
			}
			can = true;
			dp[b] = 0;
			return;
		}
	}
}
bool ok(int len) {
	can = false;
	mx = len;
	C = 0;
	dfs(0);
	return can == false;
}
int main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int mint = 1;
	int maxt = n;
	while (mint + 1 < maxt) {
		int mid = (mint + maxt) >> 1;
		if (ok(mid)) {
			maxt = mid;
		}
		else {
			mint = mid + 1;
		}
	}
	if (ok(mint)) {
		ok(mint);
		cout <<C<<" "<< mint << endl;
	}
	else {
		ok(maxt);
		cout << C<<" "<<maxt << endl;
	}
	return 0;
}

Measured memory_bytes: 38016
#include <cstdio>
#include <map>
using namespace std;
int n, k, l, a[200005], b[200005];
map<pair<int,int>,int> mp;

int f(int p, int x[]) {
	if(x[p]==p) return p;
	else return x[p] = f(x[p], x);
}

int main() {
	int i, u, v;
	scanf("%d%d%d", &n, &k, &l);
	for(i=1; i<=n; i++) a[i] = b[i] = i;
	while(k--) {
		scanf("%d%d", &u, &v);
		u = f(u,a), v = f(v,a);
		if(u!=v) a[u] = v;
	}
	while(l--) {
		scanf("%d%d", &u, &v);
		u = f(u,b), v = f(v,b);
		if(u!=v) b[u] = v;
	}
	for(i=1; i<=n; i++) {
		u = f(i,a), v = f(i,b);
		mp[{u,v}]++;
	}
	for(i=1; i<=n; i++) {
		u = f(i,a), v = f(i,b);
		printf("%d ", mp[{u,v}]);
	}
	return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
	int N;
	cin >> N;

	int ans = 0;
	for (int i = N; i >= 1; i--) {
		int A = i / 10;
		if (A == 0){
			ans++;
		}
		else if (10 <= A && A <= 99) {
			ans++;
		}
		else if (1000 <= A && A <= 9999) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
typedef long long ll;
int main(){
	int n,a[105];
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	int flg=0;
	for(int i=0;i<n;i++){
		if(a[i]%2!=0)continue;
		if(a[i]%3!=0&&a[i]%5!=0){
			flg=1;break;
		}
	}
	if(flg)puts("DENIED");
	else puts("APPROVED");
	return 0;
} 

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

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

using namespace std;
using ll = long long;

// MACRO
// for loop
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)

// for vector
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<int>())
#define RSORTS(x) sort(ALL(x), greater<string>())
#define FIND(x, n) find(ALL(x), n)
#define VFOR(e, x) for (auto &e : x)

// Constant
const ll INF = 1000000000000; // 10^12:  ∞
const int MOD = 1000000007;   // 10^9+7: Congruence ceremony MOD
const int MAXR = 100000;      // 10^5:   Array Max Range
const char EL = '\n';         // newline

// alias
#define EB emplace_back // push as last element
#define PP pop_back     // pop last element
#define MP make_pair    // pair constractor
#define F first         // first element of pair
#define S second        // second element of pair

// change max/min
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return 1;
  }
  return 0;
}

// optimize in/out
#define OPTIMIZE_CIN_COUT() \
  cin.tie(0);               \
  ios::sync_with_stdio(false);

template <typename... Args>
void input(Args... args)
{
  for (int &e : {args...})
  {
    cin >> e;
  }
}
#define INPUT1(a) \
  int a = 0;      \
  cin >> a;
#define INPUT2(a, b) \
  int a = 0;         \
  int b = 0;         \
  cin >> a >> b;
#define INPUT3(a, b, c) \
  int a = 0;            \
  int b = 0;            \
  int c = 0;            \
  cin >> a >> b >> c;
#define INPUTS(s) \
  string s = "";  \
  cin >> s;

#define INPUTA(n, a) \
  int n = 0;         \
  cin >> n;          \
  vector<int> a(n);  \
  REP(i, n)          \
  {                  \
    cin >> a[i];     \
  }
#define INPUTB(x, y, b)                     \
  int x = 0, y = 0;                         \
  cin >> x >> y;                            \
  vector<vector<int>> b(y, vector<int>(x)); \
  REP(i, y)                                 \
  {                                         \
    REP(j, x)                               \
    {                                       \
      cin >> b[i][j];                       \
    }                                       \
  }

int main()
{
  OPTIMIZE_CIN_COUT();

  // INPUT1(N);
  // INPUT2(A, B);
  INPUT3(A, B, C);
  // INPUTS(S);
  // INPUTA(N, A);
  // INPUTB(X, Y, B);

  int c = 0;
  vector<int> V{A, B, C};

  VFOR(e, V)
  {
    if (e == 5)
    {
      c += 1;
    }
    else if (e == 7)
    {
      c += 3;
    }
  }

  if (c == 5)
  {
    cout << "YES" << EL;
  }
  else
  {
    cout << "NO" << EL;
  }
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>

using namespace std;

int main() {
    int R,G,B,N; cin >> R >> G >> B >> N;
    int ans = 0;
    for(int r=0; r <= N; r++) {
        for(int g=0; g <= N; g++) {
            if(N >= (g*G + r*R) && (N - (g*G + r*R)) % B == 0) {
                ans++;
            }
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
from collections import deque
n,m = map(int,input().split())
map_li = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    map_li[a].append(b)
    map_li[b].append(a)

ans_li = [-1]*n
queue=deque([0])
visited = [False]*n

while queue:
    x = queue.popleft()
    for g in map_li[x]:
        if visited[g]==False:
            queue.append(g)
            if ans_li[g]==-1:
                ans_li[g]=x
                visited[g]=True 
if -1 in ans_li[1:]:
    print('No')
else:
    print('Yes')
    for ans in ans_li[1:]:
        print(ans+1)


Measured memory_bytes: 35440
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
int main(){
  string s;
  cin >> s;
  int count1=0,count2=0;
  int length = s.length();
  for(int i=0;i<length;i++){
    if(i%2 == 0 ^ s[i] == '0'){
      count1++;
    }else{
      count2++;
    }
  }
  cout << min(count1,count2);
}


Measured memory_bytes: 512
# https://atcoder.jp/contests/abc062/tasks/abc062_a

x, y = map(int, input().split())

a = {1, 3, 5, 7, 8, 10, 12}
b = {4, 6, 9, 11}
c = {2}

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print('Yes')

else:
    print('No')

Measured memory_bytes: 3060
// Problem : B - Golden Coins
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <cstdio>
int main()
{
 int x,ans=0;
 scanf("%d",&x);
 ans+=x/500*1000,x%=500;
 ans+=x/5*5;
 printf("%d\n",ans);
 return 0;
}

Measured memory_bytes: 128
main = do
  [n,k] <- map read . words <$> getLine
  let a = map (f 0) [g k x | x <- [1..n]]
  print $ average a
f :: Int -> Int -> Double
f z y
  | 2^z < y = f (z+1) y
  | otherwise = 0.5 ^^ z
g k w
  | k `mod` w == 0 = k `div` w
  | otherwise = k `div` w + 1
average :: (Real a) => [a] -> Double
average xs = realToFrac (sum xs) / fromIntegral (length xs)


Measured memory_bytes: 6396
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var d = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

            var max = d.Max();

            var dict = new int[n];

            for(int i = 0; i < n; i++) {
                dict[d[i]]++;
            }

            var ans = 0L;

            if(dict[0] == 1) {
                ans = 1;

                for(int i = 1; i <= max; i++) {
                    long temp = Pow(dict[i - 1], dict[i], 998244353);
                    ans *= temp;
                    ans %= 998244353;
                }
            }

            if(d[0] != 0) {
                ans = 0;
            }

            Console.WriteLine(ans);
        }

        public static long Pow(long a, long b, long mod = 0L)
        {
            var temp = a;
            var i = 0;

            var ans = 1L;

            while (true) {
                if (b >> i == 0) {
                    break;
                }

                var t = b >> i & 1;

                if(t != 0) {
                    ans *= temp;
                    if (mod != 0) {
                        ans %= mod;
                    }
                }

                temp *= temp;
                if (mod != 0) {
                    temp %= mod;
                }
                i++;
            }

            return ans;
        }
    }
}


Measured memory_bytes: 36736
import collections

def main():
    N = int(input())

    S = collections.defaultdict(int)
    for i in range(N):
        s = input()
        S[s] += 1
    
    M = int(input())
    for j in range(M):
        t = input()
        S[t] -= 1
    
    if max(S.values()) > 0:
        print(max(S.values()))
    else:
        print(0)

main()

Measured memory_bytes: 38256
n=int(input())

ta=0
xa=0
ya=0
count=0

for i in range(n):
  t,x,y=map(int,input().split())
  if (x-xa+y-ya)<=t-ta and (t-ta+x-xa+y-ya)%2==0:
    ta=t
    xa=x
    ya=y
    count+=1

print("Yes" if count==n else "No")

Measured memory_bytes: 3316
#include <iostream>
using namespace std;
int main(void){
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k<<endl;
    }
    else if(a<=k &&k<=a+b){
        cout<<a<<endl;
    }
    else{
        cout<<a*2-k+b<<endl;
    }
    
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int h,w; cin >>h>>w;

    vector<vector<char> > c(h, vector<char>(w)); REP(i,h) REP(j,w) cin >> c[i][j];

    vector<vector<char> > dc(2*h, vector<char>(w));

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << c[i][j];
        }
        cout << endl;
        for (int j = 0; j < w; j++) {
            cout << c[i][j];
        }
        cout << endl;
    }

    return 0;
}




Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int Div(int a, int b){
	int sign=1;
	if(a<0){
		a=-a;
		sign=-1;
	}
	if(b<0){
		b=-b;
		sign=-sign;
	}
	return sign*(a/b);
}
void f(string str, vector<int>& vals)
{
	//cout << str << endl;
	int level=0;
	int dsize=0;
	bool level0=false;
	for(int i=0;i<str.size();i++){
		switch(str[i]){
			case '(':
				level++;
				break;
			case ')':
				level--;
				break;
			case '+':
			case '-':
			case '*':
			case '/':
				if(level==0){
					level0=true;
					vector<int> v1;
					vector<int> v2;
					f(str.substr(0,i),v1);
					f(str.substr(i+1,str.size()-(i+1)),v2);
					for(auto a:v1){
						for(auto b:v2){
							switch(str[i]){
								case '+':vals.push_back(a+b);break;
								case '*':vals.push_back(a*b);break;
								case '-':
										 vals.push_back(a-b);
										 break;
								case '/':
									if(b!=0){
										vals.push_back(Div(a,b));
									}
									break;
							}
						}
					}
				}
				break;
			default:
				dsize++;
				break;
		}
	}
	if(vals.size()){
		sort(vals.begin(),vals.end());
		auto it=unique(vals.begin(),vals.end());
		vals.resize(it-vals.begin());
	}
	else if (dsize==str.size()){
		istringstream istr(str);
		int v;
		istr >> v;
		vals.push_back(v);
	}
	else if (!level0)
	{
		f(str.substr(1,str.size()-2),vals);
	}
	//cout << str << ", " << level0 << ", " << dsize << ", " << str.size() << ": " << vals.size() << endl;
}
int main() {
	string str;
	while(cin >> str){
		if(str=="#"){
			return 0;
		}
		vector<int> v;
		f(str,v);
		cout << v.size() << endl;
	}
}

Measured memory_bytes: 1272
N = int(input())
H = list(map(int, input().split()))
flag = True
for i in range(N-2, -1, -1):
    if H[i+1] < H[i] - 1:
        flag = False
        break
    elif H[i+1] == H[i] - 1:
        H[i] -= 1

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14396
n = int(input())
a = [0 for _ in range(n)]
for i in range(n):
    a[i] = int(input()) - 1
visited = [False for _ in range(n)]
visited[0] = True
next = a[0]
count = 1
while True:
    if next == 1:
        print(count)
        exit()
    elif not visited[a[next]]:
        visited[a[next]] = True
        count += 1
        next = a[next]
    else:
        print(-1)
        exit()

Measured memory_bytes: 8220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    ll a,b,k;cin>>a>>b>>k;
    if(a>k){
        a-=k;
        k=0;
    }
    else {
        k-=a;
        a=0;
    }
    if(k>0){
        b-=k;
        b=max(0LL,b);
    }
    cout<<a<<" "<<b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

main(){
	char str1,str2;
	int x,y;
	scanf("%c",&str1);
	scanf("%c",&str2);
	scanf("%c",&str2);
	x=(int)str1;
	y=(int)str2;
	 
	if(x>y){
		printf(">\n");
	}
	if(x<y){
		printf("<\n");
	}
	if(x==y){
		printf("=\n");
	}
	return 0;
}

Measured memory_bytes: 128
# coding: utf-8

N, M = map(int, input().split())
sum = {}
ans = 0

for i in range(0, N):
    K = list(map(int, input().split()))
    for j in range(1, K[0] + 1):
        if K[j] not in sum:
            sum[K[j]] = 1
        else:
            sum[K[j]] += 1

for k in sum:
    if sum[k] == N:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
int n, a[N], m, f, wa;
vector<int> G[N];
struct Rg {
    int l, r;
}b[N];
Rg dfs(int fa, int u) {
    if(f) {
        if(a[u] == INF) {
            if(fa == 0) {
                a[u] = b[u].l;
            } else {
                for(int i = a[fa] - 1; i <= a[fa] + 1; i += 2) {
                    if(i >= b[u].l && i <= b[u].r) {
                        a[u] = i;
                        break;
                    }
                }
                // assert(a[u] > 0);
            }
        }
    }
    Rg rg = Rg{-INF, INF};
    if(a[u] != INF) {
        rg.l = rg.r = a[u];
    }
    for(int v : G[u]) {
        if(v != fa) {

            Rg tmp = dfs(u, v);
            tmp.l--; tmp.r++;
            if(rg.l > -INF/2 && tmp.l > -INF/2 && (tmp.l - rg.l) % 2 != 0) {
                wa = 1;
                // cout << u << "." << v << endl;
            }
    // if(!f) {
    // cout << u << "->" << rg.l << " " << rg.r << '\n';
    // cout << v << "->" << tmp.l << " " << tmp.r << "\n";
    // }
            rg.l = max(rg.l, tmp.l);
            rg.r = min(rg.r, tmp.r);
            if(rg.l > rg.r) {
                wa = 1;
            }
        }
    }
    b[u] = rg;
    // if(!f)
    // cout << u << "->" << rg.l << " " << rg.r << '\n';
    return rg;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    memset(a, 0x3f, sizeof a);
    cin >> n;
    for(int i = 1, u, v; i < n; i++) {
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    cin >> m;
    for(int i = 0, v, p; i < m; i++) {
        cin >> v >> p;
        a[v] = p;
    }
    dfs(0, 1);
    f = 1;
    dfs(0, 1);
    if(wa) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
        for(int i = 1; i <= n; i++) {
            cout << a[i] << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;

int h,w;
char maze[51][51];
char ans[51][51];

int vx[]={1,0,-1,0,1,1,-1,-1};
int vy[]={0,1,0,-1,1,-1,1,-1};


bool inside(int y,int x){
  return y>=0 && x>=0 && y<h && x<w;
}
int main(){
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>maze[i][j];
    }
  }

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int cnt=0;

      rep(k,8){
        if(inside(i+vy[k],j+vx[k])){
            if(maze[i+vy[k]][j+vx[k]]=='#')cnt++;
        }
      }
      // cout<<"cnt"<<cnt<<endl;
      // ans[i][j]=(cnt+'0');
      ans[i][j]=cnt+'0';

      if(maze[i][j]=='#')ans[i][j]='#';
    }
  }
  rep(i,h){
    rep(j,w){
      cout<<ans[i][j];
    }
    cout<<endl;
  }


}


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

int main(){
  int N, M, ans;
  cin >> N >> M;

  vector<int>a(N);

  //各電球について
  for(int i=0; i<M; i++){
    int k;
    cin >> k;

    for(int j=0; j<k; j++){
      int s;
      cin >> s;
      s--;
      a[s] |= 1 << i;
    }
  }
  
  int p=0;
  for(int i=0; i<M; i++){
    int x;
    cin >> x;
    p |= x << i;
  }

  for(int s=0; s<(1<<N); s++){
    int t=0;
    for(int i=0; i<N; i++){
      if(s>>i & 1){
        t ^= a[i];
      }
    }
    if( t==p ){
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3640
use proconio::input;

fn main() {
    const M: i64 = 1_000_000_007;
    input! {
      n: i64,
      k: i64,
    }
    let mut res: i64 = 0;
    for i in k..=n + 1 {
        let min: i64 = (i - 1) * i / 2;
        let max: i64 = (n + n - i + 1) * i / 2;
        res += max - min + 1;
        res %= M;
    }
    println!("{}", res);
}


Measured memory_bytes: 2176
N,Y = map(int,input().split())
x = y = z = 0
while  Y >= 10000:
    x += 1
    N -= 1
    Y -= 10000
while Y >= 5000:
    y += 1
    N -= 1
    Y -= 5000
while Y >= 1000:
    z += 1
    N -= 1
    Y -= 1000
if Y != 0 or N < 0:
    x = y = z = -1
else:
    while N >= 9 and x > 0:
        x -= 1
        z += 10
        N -= 9
    while N >= 4 and y > 0:
        y -= 1
        z += 5
        N -= 4
    while N > 0 and x > 0:
        x -= 1
        y += 2
        N -= 1
    if N != 0:
        x = y = z = -1
print(x,y,z)

Measured memory_bytes: 9224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
int a[1005];
int main()
{
  int n,m;
  cin>>n>>m;
  int sum=0;
  for(int i=1;i<=n;i++) {
    cin>>a[i];
    sum+=a[i];
  }
  int ans=0;
  int tmp=(sum)/(4*m);
  if(sum%(4*m)) tmp++;
  for(int i=1;i<=n;i++) {
    if(a[i]>=tmp){
      ans++;
    }
  }
  if(ans>=m) printf("Yes");
  else printf("No");
  return 0;
}


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

int main(){
    char a;
    cin >> a;
  	char c = a+1;
    cout << c << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int a, b; cin >> a >> b;
    if (a <= 9 && b <= 9) cout << a * b << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
/*
https://www.hamayanhamayan.com/entry/2020/05/03/224417
勉強させていただいた記事
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int n;
    ll ans=0;
    cin>>n;
    map<ll,int> mp;
    REP(i,1,n+1){
        ll x;
        cin>>x;
        ans+=mp[i-x];
        mp[i+x]++;
    }
    cout<<ans<<endl;
    return 0;
}

//a=97,z=122

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

using namespace std;
#define sqr(x) (x)*(x)
#define cube(x) (x)*(x)*(x)
#define fixset(x) fixed << setprecision(x)
#define GCD(a,b) __gcd(a,b)
#define LCM(a,b) (a)*(b)/GCD(a,b)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define PBI pair<bool,int>
#define PIB pair<int,bool>
#define PLL pair<ll,ll>
#define SI set<int>
#define MS multiset
#define MSI multiset<int>
#define PB push_back
#define VI vector<int>
#define VLL vector<ll>
#define VB vector<bool>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1000000000;
const int MOD = 1000000007;
const int N = 200111;

int a[N], b[N], c[N];
void solve(){
    int n;
    cin >> n;

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

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

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

    for (int i = 1; i < n; i++){
        if (a[i]+1 == a[i+1]) sum += c[a[i]];
    }

    cout << sum;

}

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

    int T = 1;
    //cin >> T;

    while (T--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#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 pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
int x[10], y[10];
int S;
void solve()
{
    int s;
    int sq;
    sq = sqrt(S);
    if (sq * sq > S)
        sq--;
    s = sq + 1;
    if (s * s - S < 1e9) {
        x[0] = 0;
        y[0] = 0;
        x[1] = s;
        y[2] = s;
        x[2] = 1;
        y[1] = s * s - S;
    } else if (S != 1e18) {
        int s = sq;
        x[0] = 1;
        y[0] = 0;
        x[1] = 0;
        y[2] = s;
        x[2] = sq + 1;
        y[1] = S - s * s;
    } else {
        int s = sq;
        x[0] = 0;
        y[0] = 0;
        x[1] = 0;
        y[2] = 0;
        x[2] = s;
        y[1] = s;
    }
    FORR(i, 0, 2)
    {
        cout << x[i] << " " << y[i] << " ";
    }
    cout << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> S;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main() {
  int K,X;
  cin >> K >> X;
  vector <int> A(2*K-1);
  for(int i=0;i<2*K-1;i++){
    int a=A.at(i) = X-K+1+i;
    cout << a;
    cout <<endl;
  }
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut input_line = String::new();
    io::stdin().read_line(&mut input_line).unwrap();
    let inputs: Vec<&str> = input_line.trim().split(" ").collect();
    let n = inputs[0].parse::<f64>().unwrap();
    let m = inputs[1].parse::<f64>().unwrap();
    let d = inputs[2].parse::<f64>().unwrap();

    let ans = if d == 0.0 { (m-1.0) / n } else { (m-1.0) * 2.0*(n-d) / (n*n) };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
        d: [(usize, usize); n]
    }

    let mut ans = 0;
    let mut cnt = 0;

    for &(d1, d2) in d.iter() {
        if d1 != d2 {
            cnt = 0;
            continue;
        }

        cnt += 1;
        ans = std::cmp::max(cnt, ans);
    }

    if ans >= 3 {
        println!("Yes");
    } else {
        println!("No");
    }
    
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2164
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[3],b[3];
	int c[5]={0},y=0,o=0;
	for(int i=0;i<3;i++)
	{
		cin>>a[i]>>b[i];
		c[a[i]]++;
		c[b[i]]++;
	}
	for(int i=1;i<5;i++)
	{
		if(c[i]==2)
		y++;
		if(c[i]==1)
		o++;
	}
	if(y!=2||o!=2)
	{
		cout<<"NO";
		return 0;
	}
	cout<<"YES";
	return 0;
}

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

int main()
{
    int a,b,c,cnt=0,ma,storea,storeb,storec;
    cin >> a >> b >> c;
    while(1)
    {
        if(a!=b || a!=c || b!=c)
        {
            ma = max(a,max(b,c));
            storea = ma-a;
            storeb = ma-b;
            storec = ma-c;
            if(storea ==0 && storeb ==0 && ma-c >= 2)
            {
                c = c+2;
            }
            else if (storeb ==0 && storec ==0 && ma-a >= 2)
            {
                a = a+2;
            }
            else if(storea ==0 && storec ==0 && ma-b >= 2)
            {
                b =b+2;
            }
            else if(storea==0 && storeb!=0 && storec!=0)
            {
                c++;
                b++;
            }
            else if(storeb==0 && storec!=0 && storea!=0)
            {
                a++;
                c++;
            }
            else if(storec ==0 && storeb!=0 && storea!=0)
            {
                a++;
                b++;
            }

            else if(storea ==0 && storeb ==0 && ma-storec != 2)
            {
                a++;
                c++;
            }
            else if(storeb ==0 && storec ==0 && ma-storea != 2)
            {
                b++;
                a++;
            }
            else if(storea ==0 && storec ==0 && ma-storeb != 2)
            {
                b++;
                c++;
            }
           // cout << a << " " << b << " " << c << endl;
            cnt++;
        }
        else
        {
            break;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
if n == 0:
    if a[0] == 1:
        print(1)
    else:
        print(-1)
else:
    req = [0] * n
    req[-1] = a[-1]
    for i in range(2, n+1):
        req[-i] = req[-(i-1)] + a[-i]
    l = [0] * (n + 1)
    l[0] = 1
    for i in range(1, n+1):
        M = (l[i-1] - a[i-1]) * 2
        l[i] = min(M, req[i-1])
    if l[-1] < a[-1]:
        print(-1)
    else:
        print(sum(l))


Measured memory_bytes: 650680
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        if (d == 22) {
            System.out.println("Christmas Eve Eve Eve");
        } else if (d == 23) {
            System.out.println("Christmas Eve Eve");
        } else if (d == 24) {
            System.out.println("Christmas Eve");
        } else if (d == 25) {
            System.out.println("Christmas");
        }
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}


int main()
{
    int n;
    cin >> n;
    queue<int> q;
    q.push(n/2);
    string lefts,rights;
    cout << 0 << endl;
    cin >> lefts;
    if (lefts == "Vacant")
    {
        return 0;
    }
    cout << n-1 << endl;
    cin >> rights;
    if(rights=="Vacant"){
        return 0;
    }
    queue<int> hidari,migi;
    queue<string> hidas,migis;
    hidari.push(0);
    migi.push(n-1);
    hidas.push(lefts);
    migis.push(rights);
    while(!q.empty()){
        int left=hidari.front();
        int right=migi.front();
        hidari.pop();
        migi.pop();
        lefts=hidas.front();
        rights=migis.front();
        hidas.pop();migis.pop();
        cout << q.front() << endl;
        string s;
        cin >> s;
        if(s=="Vacant"){
            return 0;
        }
        else if(s=="Male"){
            if((q.front()-left)%2==(lefts=="Male")){
                q.push((q.front()+left)/2);
                migi.push(q.front());
                hidari.push(left);
                hidas.push(lefts);
                migis.push(s);
            }
            else if ((right-q.front()) % 2 == (rights == "Male"))
            {
                q.push((q.front()+right)/2);
                migi.push(right);
                hidari.push(q.front());
                hidas.push(s);
                migis.push(rights);
            }
        }
        else{
            if ((q.front() - left) % 2 == (lefts == "Female"))
            {
                q.push((q.front() + left) / 2);
                migi.push(q.front());
                hidari.push(left);
                hidas.push(lefts);
                migis.push(s);
            }
            else if ((right - q.front()) % 2 == (rights == "Female"))
            {
                q.push((q.front() + right) / 2);
                migi.push(right);
                hidari.push(q.front());
                hidas.push(s);
                migis.push(rights);
            }
        }
        q.pop();
    }
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
const int M = 1e9+7;

long long pwr( long long a , long long b , long long m = M ){
	
	long long ret = 1;
	a %= m , b %= m;

	while( b>0 ){
		if(b&1)	ret = ret*a % m;
		a = a*a % m;
		b >>= 1;
	}

	return ret;
}

int main(){

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

 	int n,k;
 	cin>>n>>k;

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

 	sort(a.begin(),a.end());
 	long long cur=1 , mx=0 , mn=0;

 	for(auto &i : a)
 		i = (i+M)%M;

 	for(int i=k-1 ; i<a.size() ; ++i){
 		mx = ( mx + cur*a[i] ) % M;
 		cur = cur * (i+1) % M;
 		cur = cur * pwr(i-k+2,M-2) % M;
 	}
 	// cout<<mx<<endl;

 	cur = 1;
 	for(int i=n-k ; i>=0 ; --i){
 		mn = ( mn + cur*a[i] ) % M;
 		cur = cur * (n-i) % M;
 		cur = cur * pwr(n-i-k+1,M-2) % M;
 	}

	// cout<<mn<<endl;
 	mx = ( mx - mn ) % M;
 	cout<< ( mx + M ) % M ;
 }





Measured memory_bytes: 640
N = int(input())
A = [0] + list(map(int,input().split())) + [0]
cuml = [0]
for a,b in zip(A,A[1:]):
    cuml.append(cuml[-1] + abs(a-b))
cumr = [cuml[-1]-c for c in cuml[::-1]][::-1]

ans = [cuml[i] + cumr[i+2] + abs(A[i] - A[i+2]) for i in range(N)]
print(*ans, sep='\n')

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

int main(){
	int k,a,b;

	cin >> k;
	cin >> a >> b;
	int i = 1;
	while(k * i <= b){
		if (k * i >=a && k * i <= b){
			cout << "OK" << endl;
			return 0;
		}
		i++;
	}
	cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3636
N=int(input())
if N<10:
    print(N)
elif 10<=N<100:
    print(9)
elif 100<=N<1000:
    print(N-99+9)
elif 1000<=N<10000:
    print(909)
elif 10000<=N<100000:
    print(N-9999+909)
else:
    print(90909)

Measured memory_bytes: 3060
//#include<bits/stdc++.h>
//難しい問題解いてるなぁ
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N;
	N = getint();
	int A[200000];
	ll B[200001], C;
	B[0] = 0;
	C = 0;

	vector<int> V;
	V.pb(0);
	rep(i, N) A[i] = getint();
	ll mae = A[0];
	rep(i, N) {
		ll a = A[i];
		B[i + 1] = B[i];
		if (mae >= a) {
			a *= 4;
			while (mae >= a) {
				V.pb(0);
				a *= 4;
			}
			V.back()++;
		}
		else {
			while (mae < a) {
				int kari = V.back();
				B[i + 1] += kari;
				if (V.size() > 1) {
					V.pop_back();
					V.back() += kari;
				}
				mae *= 4;
			}
			V.back()++;
		}
		mae = A[i];
	}
	V.clear();
	mae = A[N - 1];
	V.pb(0);
	ll kotae = 2 * B[N] + N;
	for (int i = N - 1; i >= 0; i--) {
		ll a = A[i];
		if (mae >= a) {
			a *= 4;
			while (mae >= a) {
				V.pb(0);
				a *= 4;
			}
			V.back()++;
		}
		else {
			while (mae < a) {
				int kari = V.back();
				C += kari;
				if (V.size() > 1) {
					V.pop_back();
					V.back() += kari;
				}
				mae *= 4;
			}
			V.back()++;
		}
		mae = A[i];
		kotae = min(kotae, B[i] + B[i] + C + C + i);
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include<algorithm>
#define pf printf
#define sf scanf
#define wh while
#define db double
#define LL long long
#define _USE_MATH_DEFINES
#define re(i,a,b) for(int i=a;i<b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

int main()
{
    db a,b,c,d,e,f,x,y;
    wh(sf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)==6){
        if((e*c-b*f)==0)x=0;
        else x=(e*c-b*f)/(a*e-b*d);
        y=(c-a*x)/b;
        pf("%.3lf %.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 1232
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var T = Console.ReadLine();
        var Sarr = new int[26];
        var Tarr = new int[26];
        for (int i = 0; i < S.Length; i++)
        {
            Sarr[S[i] - 'a']++;
            Tarr[T[i] - 'a']++;
        }
        var orderS = Sarr.OrderBy(i=>i).ToArray();
        var orderT = Tarr.OrderBy(i=>i).ToArray();
        for (int i = 0; i < 26; i++)
        {
            if (orderS[i] != orderT[i])
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}

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


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


int main() 
{
    
    map<int, int> mp;
    for (int i = 1; i <= 2;i++)
    {
        int a;
        cin >> a;
        mp[a] = 1;
    }
    for (int i = 1; i <= 3;i++)
    {
        if(mp[i]==0)
            cout << i << endl;
    }

        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 100010;
clock_t START, END;

int V;

struct HeapNode {
	int d, u;
	bool operator < (const HeapNode& rhs) const {
		return d > rhs.d;
	}
};

struct Edge {
	int from, to, dist;
	Edge(int u, int v, int d) :from(u), to(v), dist(d) {}
};

struct Dijkstra {
	int n, m;
	vector<Edge> edges;
	vector<int> G[NUM];
	
	int up[NUM], down_1[NUM], child[NUM], down_2[NUM];

	void init(int n) {
		this->n = n;
		for (int i = 0; i < n; i++)
			G[i].clear();
		edges.clear();
	}

	void AddEdge(int from, int to, int dist) {
		edges.push_back(Edge(from, to, dist));
		m = edges.size();
		G[from].push_back(m - 1);
	}

	void dfs1(int u, int fa) {
		down_1[u] = down_2[u] = 0;
		for (int i = 0; i < G[u].size(); i++) {
			int v = edges[G[u][i]].to;
			if (v != fa) {
				dfs1(v, u);
				if (down_1[v] + edges[G[u][i]].dist > down_1[u]) {
					down_2[u] = down_1[u];
					down_1[u] = down_1[v] + edges[G[u][i]].dist;
					child[u] = v;
				}
				else if (down_1[v] + edges[G[u][i]].dist > down_2[u])
					down_2[u] = down_1[v] + edges[G[u][i]].dist;
			}
		}
	}

	void dfs2(int u, int fa) {
		for (int i = 0; i < G[u].size(); i++) {
			int v = edges[G[u][i]].to;
			if (v == fa)
				continue;
			if (child[u] != v)
				up[v] = max(up[u] + edges[G[u][i]].dist, down_1[u] + edges[G[u][i]].dist);
			else
				up[v] = max(up[u] + edges[G[u][i]].dist, down_2[u] + edges[G[u][i]].dist);
			dfs2(v, u);
		}
	}
};

Dijkstra solve;

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int s, t, d;
	cin >> V;
	solve.init(V);
	for (int i = 0; i < V - 1; i++) {
		scanf("%d%d%d", &s, &t, &d);
		solve.AddEdge(s, t, d);
		solve.AddEdge(t, s, d);
	}
	solve.dfs1(0, -1);
	solve.dfs2(0, -1);
	for (int i = 0; i < V; i++)
		cout << max(solve.up[i], solve.down_1[i]) << endl;
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 6472
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


int a[3][3];
int n, b[15];

bool c[3][3], ans;

int main() {

	rep(i, 3) {
		rep(j, 3) {
			c[i][j] = false;
		}
	}

	rep(i, 3) {
		rep(j, 3) {
			cin >> a[i][j];
		}
	}

	cin >> n;
	rep(i, n)cin >> b[i];

	rep(i, n) {
		rep(j, 3) {
			rep(k, 3) {
				if (b[i] == a[j][k])c[j][k] = true;
			}
		}
	}

	if (c[0][0] == true && c[0][1] == true && c[0][2] == true)ans = true;
	else if (c[0][0] == true && c[1][0] == true && c[2][0] == true)ans = true;
	else if (c[0][2] == true && c[1][2] == true && c[2][2] == true)ans = true;
	else if (c[2][0] == true && c[2][1] == true && c[2][2] == true)ans = true;
	else if (c[0][0] == true && c[1][1] == true && c[2][2] == true)ans = true;
	else if (c[0][2] == true && c[1][1] == true && c[2][0] == true)ans = true;
	else if (c[1][0] == true && c[1][1] == true && c[1][2] == true)ans = true;
	else if (c[0][1] == true && c[1][1] == true && c[2][1] == true)ans = true;

	if (ans)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    for(int i=0;s[i];i++)
    {
        //s[i]=(s[i]+k%26);
        //if(s[i]-'A'>=26)
        s[i]=(s[i]-'A'+k)%26+'A';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [0, abs(h[1]-h[0])]
if n > 2:
    for i in range(2, n):
        dp.append(min(dp[-1]+abs(h[i]-h[i-1]), dp[-2]+abs(h[i]-h[i-2])))
print(dp[-1])

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

int main(){
    int n,a,ma=1,mi=1000000000;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        ma=max(ma,a);
        mi=min(mi,a);
    }
    cout<<ma-mi<<endl;
    return 0;
}

Measured memory_bytes: 256
fn main(){
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();

    let mut data: Vec<i32> = Vec::new();

    for x in vec {
        if x == "+"{
            let a: i32 = data.pop().unwrap();
            let b = data.pop().unwrap();
            let ans = a + b;
            data.push(ans);
        }else if x == "*"{
            let a: i32 = data.pop().unwrap();
            let b = data.pop().unwrap();
            let ans = a * b;
            data.push(ans);
        }else if x == "-"{
            let a: i32 = data.pop().unwrap();
            let b = data.pop().unwrap();
            let ans = b - a;
            data.push(ans);
        }else{
            let n: i32 = x.parse().unwrap();
            data.push(n);
        }
    }

    println!("{}",data.pop().unwrap());

}

Measured memory_bytes: 5048
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
    int N;
    cin >> N;
    pint A[N],B[N];
    rep(i,N){
        cin >> A[i].first;
        A[i].second=i;
    }
    rep(i,N) B[i].first=A[i].first,B[i].second=A[i].second;
    sort(A,A+N);
    int ans1=A[N/2].first,ans2=A[N/2-1].first;
    rep(i,N){
        if(B[i].first>ans2) cout << ans2 << endl;
        else cout << ans1 << endl;
    }
}

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n;
	cin >> n;
	vector<ll> ma(n),mb(n),mc(n-1);
	REP(i,n) cin >> ma[i];
	REP(i,n) cin >> mb[i];
	REP(i,n-1) cin >> mc[i];

	int ans = 0;
	int t = -1;
	REP(i,n) {
		if(t+1 == ma[i]) ans += mc[ma[i]-2];
		ans += mb[ma[i]-1];
		t = ma[i];

	}

  cout << ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
    int x;
    cin>>x;
    if(x>=30){
        cout<<"Yes";
    }
else
    cout<<"No";


    return 0;
}


Measured memory_bytes: 3580