akhauriyash/Code-Regression huggingface dataset:
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif



ll f(ll b, ll n) {
    if (n < b) return n;
    else return f(b, n / b) + n % b;
}

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

    ll N, S; cin >> N >> S;

    for(ll b=2; b*b<=N; b++) {
        if (f(b, N) == S) {
            cout << b << endl;
            return 0;
        }
    }

    if (N==S) {
        cout << N + 1 << endl;
        return 0;
    }

    ll ans = -1;
    for(ll p=sqrt(N); p >= 1; p--) {
        if ((N-S)%p == 0) {
            ll b = (N - S) / p  + 1;
            if (b>=2 && f(b, N) == S) {
                ans = b;
                break;
            }
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
using namespace::std;
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define rrep(i,n) for(lint i=lint(n-1);i>=0;--i)
#define all(n) (n).begin(),(n).end()
#define endl '\n'
#define INF (1LL<<60)

typedef lint T;
typedef lint E;
T node[1<<23];
E lazy[1<<23];
int n=1<<21;
T et=0;
E ee=0;
T f(T,T);
void g(E&,E);
void h(T&,E,int);
void eval(int i){
    g(lazy[2*i],lazy[i]);
    g(lazy[2*i+1],lazy[i]);
    h(node[i],lazy[i],n>>int(log2(i)));
    lazy[i]=ee;
}
auto eval(int l,int r){
    int lm=(l/(l&-l))/2,rm=(r/(r&-r))/2;
    vector<int>v;
    while(l<r){
        if(r<=rm)v.push_back(r);
        if(l<=lm)v.push_back(l);
        l/=2,r/=2;
    }
    while(l)v.push_back(l),l/=2;
    reverse(all(v));
    for(auto i:v)eval(i);
    reverse(all(v));
    return v;
}
void add(int l,int r,E x){
    l+=n,r+=n;
    auto v=eval(l,r);
    while(l<r){
        if(l&1)g(lazy[l++],x);
        if(r&1)g(lazy[--r],x);
        l/=2,r/=2;
    }
    for(auto i:v){
        eval(i*2);eval(i*2+1);
        node[i]=f(node[i*2],node[i*2+1]);
    }
}

T get(int l,int r){
    l+=n,r+=n;
    eval(l,r);
    T s=et;
    while(l<r){
        if(l&1)eval(l),s=f(s,node[l++]);
        if(r&1)eval(--r),s=f(s,node[r]);
        l/=2,r/=2;
    }
    return s;
}
T f(T s,T t){
    return s+t;
}
void g(E& s,E t){
    s+=t;
}
void h(T& s,E t,int len){
    s+=t*len;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n,q;
    cin>>n>>q;
    rep(i,q){
        int x;
        cin>>x;
        if(x){
            lint s,t;
            cin>>s>>t;
            cout<<get(s-1,t)<<endl;
        }else{
            lint s,t,x;
            cin>>s>>t>>x;
            add(s-1,t,x);
        }
    }
}


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

class Program
{
    void Run()
    {
        var sc = new Scanner();
        string s = sc.NextString();
        for (int i = 0; i < s.Length; i++)
            Console.Write('x');
        Console.WriteLine();
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)

    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }

    static long Lcm(long a, long b)
    {
        long d = Gcd(a, b);
        return a / d * b;
    }

    static long RepeatedSquare(long n, long p, long m)
    {
        if (p == 0) return 1;
        if (p % 2 != 0) return n * RepeatedSquare(n, p - 1, m);
        long t = RepeatedSquare(n, p / 2, m);
        return (t * t) % m;
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11092
from itertools import permutations
import numpy as np
N, M = map(int, input().split(" "))#N頂点M辺
edges = []
for _ in range(M):
    edges += [list(map(int, input().split(" ")))]

count = 0
for line in permutations(np.arange(N - 1) + 2):
    vtxs = [1] + list(line)
    for i in range(N - 1):
        edge = sorted([vtxs[i], vtxs[i + 1]])
        if edge not in edges:
            break
    else:
        count += 1
print(count)

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


int main() {
    string s,t;
    int ans=0;
    cin >>s>>t;
    rep(i,3)if(s[i]==t[i])ans++;
    cout << ans <<endl;
}

Measured memory_bytes: 256
/*input
4
2 5 2 5
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define YY cout<<"YES\n"
#define NN cout<<"NO\n"
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int a[maxn];
int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	ll tt=0;
	REP(i,n) tt+=a[i];
	REP(i,n) a[i]*=n;
	REP(i,n) a[i]=abs(a[i]-tt);
	cout<<min_element(a,a+n)-a<<'\n';
	return 0;
}


Measured memory_bytes: 256
def inp():exec('global inppp\ninpmoto,inppp=input().split(),[]\nfor i in inpmoto:\n try:inppp.append(int(i))if float(i).is_integer()else inppp.append(float(i));\n except:\n  try:inppp.append(str(i))\n  except:print("error in inp")');return inppp[0]if len(inppp)==1else list(inppp)
a, b, h, m = inp()
"""
時間は a cm
分は   b cm
"""
import math
kakudo_a = (60*h+m) / (12 * 60) * 360
kakudo_b = ((60*h+m) / 60 * 360) % 360
kakudo = (abs(kakudo_a - kakudo_b)/180) * math.pi
c = a ** 2 + b ** 2 - 2*a*b*math.cos(kakudo)
print(math.sqrt(c))

Measured memory_bytes: 9468
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD*MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int a,b;

int main(){
while(cin>>a>>b){
swap(a,b);
cout<<a+b<<endl;
}
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
int INF = numeric_limits<int>::max() / 2;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    char people[n];
    int e,w;
    w = 0;
    for(int i = 0; i < n; i++){
        cin >> people[i];
        if(people[i] == 'E') e++;
    }
    if(people[0] == 'E') e--;
    int ans = e;
    for(int i = 1; i < n; i++){
        if(people[i-1] == 'W') w++;
        if(people[i] == 'E') e--;
        ans = min(ans, w+e);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <stdint.h>
#include <algorithm>

using namespace std;

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

  uint64_t ans = 0;

  for (int a=1; a<=K; ++a) {
    for (int b=1; b<=K; ++b) {
      for (int c=1; c<=K; ++c) {
	ans += __gcd(a,__gcd(b,c));
      }
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3636
from collections import deque

def new_color(s, i, color):
  return s[:i] + color * 2 + s[i + 2:]

def solve(s):
  length = len(s)
  monos = ["r" * length, "g" * length, "b" * length]
  if s in monos:
    print(0)
    return
  rgb = "rgb"
  another = {("r", "g"):"b", ("g", "r"):"b", 
             ("r", "b"):"g", ("b", "r"):"g",
             ("g", "b"):"r", ("b", "g"):"r"}
  dic = {s:0}
  que = deque()
  app = que.append
  pop = que.popleft
  que.append((s, 0))

  while que:
    colors, score = pop()
    score += 1
    temp = colors[0]

    for i in range(1, length):
      ci = colors[i]
      if ci != temp:
        new = new_color(colors, i - 1, another[(ci, temp)])

        if new in monos:
          print(score)
          return

        if new not in dic:
          dic[new] = score
          app((new, score))

      temp = ci

  print("NA")

def main():
  while True:
    s = input()
    if s == "0":
      break
    solve(s)

main()


Measured memory_bytes: 7816
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, ans, sum, d[2010][2];
bool f;
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
string str;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
void DIUX(LL s,LL u,bool f) {
	for (int i = 1; i < 2010; i++)
		d[i][f] = INF;
	d[0][f] = 0;
	d[s][f] = 0;
	priority_queue<Pll, vector<Pll>, greater<Pll>> pq;
	pq.push(make_pair(d[s][f], s)); // (cost,頂点番号) 
	while (!pq.empty()) {
		Pll pp;
		pp = pq.top();
		LL cos = pp.first, vv = pp.second;
		pq.pop();
		if (d[vv][f] < pp.first)continue;
		for (int i = 0; i < vec[vv].size(); i++) {
			if(vv!=s||vec[vv][i].to!=u)
			if (vec[vv][i].cost + d[vv][f] < d[vec[vv][i].to][f]) {
				d[vec[vv][i].to][f] = vec[vv][i].cost + d[vv][f];
				if (d[vec[vv][i].to][f] <= k / 2) {
					d[0][0]++;
					pq.push(make_pair(d[vec[vv][i].to][f], vec[vv][i].to));
				}
			}
		}
	}
}

int main() {
	cin >> n >> k;
	rep(i, n - 1) {
		LL x, y;
		cin >> x >> y;
		vec[x].push_back(Edge{ y,1 });
		vec[y].push_back(Edge{ x,1 });
	}
	rep(i, n) {
		if (k % 2 == 0) {
			DIUX(i + 1, 0, 0);
			ans = max(ans, d[0][0]+1);
		}
		else {
			rep(j, vec[i + 1].size()) {
				DIUX(i + 1, vec[i + 1][j].to, 0);
				DIUX(vec[i + 1][j].to, i + 1, 1);
				ans = max(ans, d[0][0] + 2);
			}
		}
	}
	cout << n - ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void Quick(int bottom, int top, int* sort){
  if(bottom >= top) return;
  int lower;
  int upper;
  int target = sort[bottom];
  int tmp;
  //------------------  
  for(lower=bottom, upper=top; lower<upper;){
    while(lower <= upper && sort[lower] >= target){
      lower++;
    } 
    while(lower <= upper && sort[upper] < target){
      upper--;
    }  
    if(lower < upper){
      tmp = sort[upper];
      sort[upper] = sort[lower];
      sort[lower] = tmp;
    }  
  }
  tmp = sort[upper];
  sort[upper] = sort[bottom];
  sort[bottom] = tmp;
  
  Quick(bottom, upper-1, sort);
  Quick(upper+1, top, sort);  
}  

//-------------------------------------------------------------------
int main(int argc, char** argv){
  int num;
  char str[400];
  int* data;

  int i;
  char* p;
  //------------
  // 総数の取得
  scanf("%d", &num);
  getchar();                           //改行コード除去
  //------------
  // 個別データの取得
  fgets(str, sizeof(str), stdin);
  if((p=strchr(str, '\n'))!=NULL){    //改行コード除去
    *p='\0';
  }
  //------------
  // 数値変換
  data = malloc(sizeof(int) * num);
  data[0] = atoi(strtok(str, " ")); 
  for(i=1; i<num; i++){
    data[i] = atoi(strtok(NULL, " "));
  }  
  //------------
  // ソート
  Quick(0, num-1, data);
  //------------
  // 差
  int alice = 0;
  int bob = 0;
  for(i=0; i<num;){
  	alice = alice + data[i++];
    bob = bob + data[i++];
  }
  printf("%d\n", alice - bob);
  return 0;
}  

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main(){
  int n;cin>>n;
  int a[n];rep(i,n)cin>>a[i];
  int ctr=0;
  rep(i,n){
    if(a[i]%2)ctr++;
  }
  if(ctr%2){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
int main(){
	ll N;
	cin >> N;
	vl H(N);
	REP(i, N){
		cin >> H[i];
	}
	bool flag = true;
	for(ll j = 1; j <= N - 2; j++){
		if(flag){
			if(H[j] - 1 <= H[j+1] && H[j-1] <= H[j] - 1){
				H[j] = H[j] - 1;
			}else if(H[j] <= H[j+1] && H[j-1] <= H[j]){
			}else {
				cout << "No" << endl;
				flag = false;
			}
		}
	}
	if(flag){
		cout << "Yes" << endl;
	}
}


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

int main()
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if (a < b) printf("a < b\n");
	else if(a > b) printf("a > b\n");
	else printf("a == b\n");
	
	return (0);
}

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

#define pb push_back
#define ll long long
#define MOD 1000000007

class grafo {
	int n;
	vector<vector<pair<int, int>>> adj;

public:

    vector<ll> dp_preto, dp_branco;

	grafo(int n) {
		this->n = n;
		adj = vector<vector<pair<int, int>>>(n);
        dp_preto = vector<ll>(n, 1);
        dp_branco = vector<ll>(n, 1);
	}

	void aresta(int u, int v, int w) {
		adj[u].pb({v, w});
		adj[v].pb({u, w});
	}

    void dfs(int u, int pai = -1) {
        for (auto &v : adj[u]) {
            if (v.first == pai) continue;
            dfs(v.first, u);
            dp_branco[u] *= (dp_preto[v.first] + dp_branco[v.first]);
            dp_preto[u] *= dp_branco[v.first];
            dp_branco[u] %= MOD;
            dp_preto[u] %= MOD;
        }
	}

};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, x, y;
    cin >> n;
    grafo g(n);
    for (int i = 0; i < n-1; i++) {
        cin >> x >> y;
        g.aresta(x-1, y-1, 1);
    }
    g.dfs(0);
    cout << (g.dp_preto[0] + g.dp_branco[0]) % MOD;
}

Measured memory_bytes: 17160
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  ll h,w,n;
  int x,y;
  map<pair<int,int>,int> m;
  cin>>h>>w>>n;
  rep(i,n){
    cin>>y>>x;
    x--;y--;
    m[mp(x,y)]++;
    rep(i,8)if(1<=x+ddx[i]&&x+ddx[i]<w-1&&1<=y+ddy[i]&&y+ddy[i]<h-1)m[mp(x+ddx[i],y+ddy[i])]++;
  }
  map<int,ll> ans;
  for(auto itr : m){
    if(itr.first.first!=0&&itr.first.first!=w-1&&itr.first.second!=0&&itr.first.second!=h-1)ans[itr.second]++;
  }
  ll sum=0;
  REP(i,1,10){
    sum+=ans[i];
  }
  ans[0]=(h-2)*(w-2)-sum;
  rep(i,10){
    cout<<ans[i]<<endl;
  }
  return 0;
}


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

#define __m int mid=(l+r)>>1
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

template<class T>
inline bool rd(T &num) {
    char in;
    bool IsN = false;
    while(in = getchar(), in != '-' && (in < '0' || in > '9'))if(in == EOF)return false;
    in == '-' ? (IsN = true, num = 0) : num = in - '0';
    while(in = getchar(), in >= '0' && in <= '9')num = num * 10 + in - '0';
    return IsN ? num = -num : num, true;
}

#define rep(i,a,b) for(register int i = (a); i< (b); i++)
#define per(i,a,b) for(register int i = (a); i> (b); i--)
#define clr(a) memset(a,0,sizeof(a));
#define inf(a) memset(a,0x3f,sizeof(a));
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rd2(a,b) rd(a)&&rd(b)
#define rd3(a,b,c) rd(a)&&rd(b)&&rd(c)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))

string nico;
#ifdef LOCAL
#define bug(x) cout<<#x<<" : "<<x<<endl
#define infile(x) freopen(x,"r",stdin)
#define outfile(x) freopen(x,"w",stdout)
#else
#define bug(x)
#define infile(x)
#define outfile(x)
#endif

const int maxn = 1e5 + 7;
const int inf  = 0x3f3f3f3f;
const LL linf  = (LL)inf << 32 | inf;
const int mod  = 1e9 + 7;

int main() {
    IO;
    string a;
    cin>>a;
    int ans =0;
    rep(i,0,a.size())
        if(a[i]=='+')
            ans++;
        else ans--;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct help{
 ll weight,value;
};
ll dp[101][100001]={0};
ll knapsack2(help arr[],ll n,ll mv,ll dp[][100001]){
  if(mv<=0){
    return 0;
  }
  if(n==0){
    return INT_MAX;
  }
  if(dp[n][mv]!=0){
    return dp[n][mv];
  }
  ll op1=INT_MAX,op2=INT_MAX,ans=0;
  if(mv-arr[n].value>=0){
    op1 = arr[n].weight+knapsack2(arr,n-1,mv-arr[n].value,dp);
  }
  op2 = knapsack2(arr,n-1,mv,dp);

return dp[n][mv] = min(op1,op2);
}
int main(){
 ll n,w,mv=0;
 cin>>n>>w;
 help arr[n+1];
 for(ll i=1;i<=n;i++){
    cin>>arr[i].weight>>arr[i].value;
    mv+=arr[i].value;
 }

 for(ll i=mv;i>=0;i--){
  ll ans = knapsack2(arr,n,i,dp);
 if(ans<=w){
    cout<<i;
    break;
  }
 }
}


Measured memory_bytes: 78336
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[10],i,j,k;
    for(i=0; i<5; i++)
        scanf("%d",&a[i]);
    scanf("%d",&k);
    for(i=0; i<4; i++)
        for(j=i+1; j<5; j++)
            if(a[j]-a[i]>k)
            {
                printf(":(\n");
                goto loop;
            }
    printf("Yay!\n");
loop:
    ;
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




int main()
{
    ll A,B,C,K;
    cin >> A >> B >> C >> K;

    ll ans = 0;
    if(K <= A) ans = K;
    else if(K <= A+B) ans = A;
    else if(K > A+B) ans = A - (K -(A+B));

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int N;
  string res;
  cin >> N;
  cout << 0 << endl;
  cin >> res;
  string even;
  if (res == "Vacant")
    return 0;
  else
    even = res;
  int64 high = N;
  int64 low = -1;
  while (high - low > 1) {
    int mid = (high + low) / 2;
    cout << mid << endl;
    cin >> res;
    if (res == "Vacant") return 0;
    if ((mid % 2 == 0 && res != even) || (mid % 2 == 1 && res == even))
      high = mid;
    else
      low = mid;
  }
  return 0;
}

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

int n, p = 0;
int dp[120][100];

bool is_prime(int n)
{
	for (int i = 2; i * i <= n; i++)
		if (n % i == 0)
			return false;
	return true;
}

int main()
{
	cin >> n;
	dp[0][1] = 1;
	for (int i = 2; i <= n; i++)
	{
		if (is_prime(i) == false)
			continue;
		int cnt = 0;
		for (int j = 1; j <= n; j++)
		{
			int a = j;
			while (a % i == 0)
				cnt++, a /= i;
		}
		for (int j = 0; j <= cnt; j++)
		{
			for (int k = 1; k * (j + 1) <= 75; k++)
			{
				dp[i][k * (j + 1)] += dp[p][k];
			}
		}
		p = i;
	}
	cout << dp[p][75] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll N,X,T;
    cin >> N >> X >> T;
    if(N%X>0){
        cout<<(N/X)*T+T<<endl;
    }else{
        cout<<(N/X)*T<<endl;

    }
    return 0;  
}


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

int main(){
     int n,k;
    cin>>n>>k;
    vector<double>p(n);
    vector<double>sum(n+1);
    for(int i=0; i<n; i++){
        cin>>p.at(i);
        double bu=(1+p.at(i))/2;
        sum.at(i+1)=sum.at(i)+bu;
    }
    double mak=0;
    for(int i=k; i<n+1; i++){
        mak=max(mak,sum.at(i)-sum.at(i-k));
    }
    cout << fixed << setprecision(4);
    cout<<mak<<endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
  int n, d;
  int x[20][20];
  cin >> n >> d;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= d; j++) {
      cin >> x[i][j];
    }
  }

  int cnt = 0;
  for (int i = 1; i <= n-1; i++) {
    for (int j = i+1; j <= n; j++) {
      int dist = 0;
      for (int k = 1; k <= d; k++) {
        dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      for (int l = 1; l < 200; l++) {
        if (l*l == dist) {
          cnt++;
        }
      }
    }
  }

  cout << cnt << endl;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n;
	cin >> n;
	vi a(n);
	vi count(1010101, 0);
	f(i, 0, n - 1) {
		cin >> a[i];
		count[a[i]]++;
	}
	ll ans = 0;
	f(i, 0, n - 1) {
		if (count[a[i]] >= 2)continue;
		bool flag = true;
		for (ll j = 1; j * j <= a[i]; j++) {
			if (a[i] % j == 0) {
				ll fact1 = j;
				ll fact2 = a[i] / j;
				ll c = count[fact1];
				if (fact1 == a[i])c--;
				if (c > 0) {
					flag = false; break;
				}
				c = count[fact2];
				if (fact2 == a[i])c--;
				if (c > 0) {
					flag = false; break;
				}
			}
		}
		if (flag) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}































Measured memory_bytes: 12692
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;	string S[200001];
	set<string> st;
int main(){
	int N;

	scan(N);
	rep(i,N){
		scan(S[i]);
		st.insert(S[i]);
	}
	prin(st.size());
	return 0;
}


Measured memory_bytes: 25428
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long res = 0;
        int[] l = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                int nibutan = Algo.nibutan(l[i] + l[j], l);
                // l[i]+l[j]>=l[nibutan]なる最小のindex
                res += (nibutan - j - 1);
            }
        }

        System.out.println(res);
        sc.close();
    }
}

class io {
    public static void br() {
        System.out.println("");
    }

    public static void YesNo(boolean f) {
        System.out.println(f ? "Yes" : "No");
    }

    public static void YESNO(boolean f) {
        System.out.println(f ? "YES" : "NO");
    }

}

class Algo {
    public static int nibutan(int target, int[] ar) {
        // ar[i] >= target なる最小のiを探す
        int res;
        int high = ar.length;
        int low = 0;
        while (high > low) {
            res = (high + low) / 2;
            if (ar[res] < target) {
                // too low
                low = res + 1;
            } else {
                // 上界
                high = res;
            }
        }
        return low;
    }

    public static boolean isOdd(int n) {
        return n % 2 == 1;
    }

    public static boolean isEven(int n) {
        return n % 2 == 0;
    }


}



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

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

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>;

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
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__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 55;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    CIN(N);
    vector<ll> A(N);VCIN(A);

    ll ans=0;
    rep(i,60){
        ll cnt1=0,cnt0=0;
        rep(j,N){
            if(A[j]>>i&1)cnt1++;
            else cnt0++;
        }
        ll tmp=((1LL<<i)%MOD)*(cnt0*cnt1%MOD)%MOD;
        ans=(ans+tmp)%MOD;
    }
    COUT(ans);

    return 0;
}

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

using namespace std;
typedef long long int ll;

int N;
int M;
int A[200005];
int B[200005];
int C[200005];

int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[i + 1] = a;
    B[a]++;
    C[a - B[a] + 1]++;
  }
  int count = 0;
  for (int i = 1; i <= N; i++) {
    if (C[i] == 0) count++;
  }


  for (int i = 0; i < M; i++) {
    int X, Y;
    cin >> X >> Y;

    C[max(A[X] - B[A[X]] + 1,0)]--;
    if (C[max(A[X] - B[A[X]] + 1,0)] == 0 && A[X] - B[A[X]] + 1 > 0) count++;
    //    assert(C[A[X] - B[A[X]] + 1] >= 0);
    B[A[X]]--;
    //    assert(B[A[X]]>=0);

    A[X] = Y;
    B[A[X]]++;
    C[max(A[X] - B[A[X]] + 1,0)]++;
    if (C[max(A[X] - B[A[X]] + 1,0)] == 1 && A[X] - B[A[X]] + 1 > 0) count--;

    cout << count << endl;
  }

  return 0;
}


Measured memory_bytes: 3712
S=input()
flag = 1
while flag:
    if S[len(S)-5:len(S)] == "dream":S=S[0:len(S)-5]
    elif S[len(S)-5:len(S)] == "erase":S=S[0:len(S)-5]
    elif S[len(S)-6:len(S)] == "eraser":S=S[0:len(S)-6]
    elif S[len(S)-7:len(S)] == "dreamer":S=S[0:len(S)-7]
    else: flag = 0
if(len(S)):print("NO")
else:print("YES")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    int A[n];
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    sort(A,A+n);
    int sum=0;
    for(int i=0;i<k;i++){
        sum += A[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pd(x) cerr<<"//"<<(x)<<endl;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[500005];
char s[200005],t[200005];
ll dp[1005][1005];
ll sx,sy;
bool flag,dame;

void look(ll a,ll b){
	x[a]=b; //aまでの距離はb
	for(int i=0;i<G[a].size();i++){
		if(x[G[a][i]]>=0)continue;
		look(G[a][i],b+1);
	}
}

void looko(ll a,ll b){
	y[a]=b; //aまでの距離はb
	for(int i=0;i<G[a].size();i++){
		if(y[G[a][i]]>=0)continue;
		looko(G[a][i],b+1);
	}
}



int main(){
	cin >> n;
	for(i=0;i<n-1;i++){
		cin >> a >> b;
		G[a].pb(b);
		G[b].pb(a);
	}
	for(i=0;i<=n;i++){
		x[i]=-1;
		y[i]=-1;
	}
	look(1,0);
	for(i=1;i<=n;i++){
		if(num<x[i]){
			num=x[i];
			a=i;
		}
	}
	looko(a,0);
	num=0;
	for(i=1;i<=n;i++){
		if(num<y[i])num=y[i];
	}
	if(num % 3 == 1){
		p("Second");
	}else{
		p("First");
	}
	return 0;
}


Measured memory_bytes: 49024
#include <bits/stdc++.h>
#define ll long long
int main()
{
    ll n;
    std::vector<ll> a;
    std::cin >> n;
    const ll pack = 1000000007;
    for (int i = 0; i < n; ++i) {
        ll temp = 0;
        std::cin >> temp;
        a.push_back(temp);
    }
    ll ans = 0;
    ll temp_sum = 0;
    for (int i = 0; i < n; ++i) {
        temp_sum += a[i];
        temp_sum %= pack;
    }
    ans += (temp_sum % pack) * (temp_sum % pack);
    ans %= pack;
    for (int i = 0; i < n; ++i) {
        ans -= (a[i] % pack) * (a[i] % pack);
        ans %= pack;
    }
    while (ans < 0) {
        ans += pack;
    }
    if (ans % 2 != 0) {
        ans += pack;
    }
    ans /= 2;
    ans %= pack;
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 5288
import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt(), arr[] = new int[n], xor = 0;
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			xor ^= arr[i];
		}
		
		for(int i = 0; i < n; i++) {
			out.print((arr[i] ^ xor) + " ");
		}
		
		out.close();
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}

Measured memory_bytes: 60092
/*input
5
0.42 0.01 0.42 0.99 0.42

*/
/*

  ####   #    #    ##    #####    ####           #    #
 #       #    #   #  #   #    #  #    #          #    #
  ####   ######  #    #  #    #  #    #          #    #
      #  #    #  ######  #    #  #    #          # ## #
 #    #  #    #  #    #  #    #  #    #          ##  ##
  ####   #    #  #    #  #####    ####  #######  #    #

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
using namespace std;
#define N  3005
long double dp[N][N];
long double a[N];
lld n;
void init()
{
	rep(i,0,N)
	{
		rep(j,0,N)
		{
			dp[i][j]=-1;
		}
	}
}
long double func(lld pos,lld cnt)
{
	if(pos==n && cnt >= (n+1)/2)
	{
		return 1.00;
	}
	if(pos==n)
	{
		return 0.00;
	}
	if(dp[pos][cnt]!=-1)
	{
		return dp[pos][cnt];
	}
	long double ans=0;
	ans=(a[pos]*func(pos+1,cnt+1)*1.0000 + 1.000*(1.00-a[pos])*func(pos+1,cnt));
	dp[pos][cnt]=ans;
	return ans;
}
inline void solve()
{
	cin >> n;
	rep(i,0,n)
	{
		cin >> a[i];
	}
	init();
	std::cout << std::fixed;
  	std::cout << std::setprecision(15) << func(0,0) << endl;  
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 141696
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes(){
  cout << "Possible" << endl;
}

void no(){
  cout << "Impossible" << endl;
  exit(0);
}

int main(){
  ll N; cin >> N;
  vector<ll> a(N);
  REP(i, N) cin >> a[i];

  //座標圧縮
  vector<ll> vals;
  REP(i, N) vals.push_back(a[i]);
  sort(ALL(vals));
  vals.erase(unique(ALL(vals)), vals.end());
 
  ll cnt = 0;
  REP(i, N){
    ll id = lower_bound(ALL(vals), a[i]) - vals.begin() + 1;
    if((id+i+1)%2!=0) cnt++;
  }
  cout << cnt/2 << endl;
}



Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second


void solve(){
    ll w,N;cin>>N;
    rep(i,1,3510)rep(j,1,3510){
        if((4*i*j-N*i-N*j)==0)continue;
        w=(N*i*j)/(4*i*j-N*i-N*j);
        if(w<=0)continue;
        if(4*i*j*w==N*(i*j+w*j+w*i)){cout<<i<<" "<<j<<" "<<w<<endl;return;}
    }
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

using namespace std;

int main() {
    int q, c[100], a[100], n[100];
    cin >> q;
    for(int i = 0 ;i < q; i++){
        int team = 0;
        cin >> c[i] >> a[i] >> n[i];
        while(1){
            if(c[i] > 0 && a[i] > 0 && n[i] > 0){
                c[i]--;
                a[i]--;
                n[i]--;
                team++;
            }
            else if(c[i] > 1 && a[i] > 0 && n[i] == 0){
                c[i] -= 2;
                a[i]--;
                team++;
            }
            else if(c[i] > 2 && a[i] == 0 && n[i] >= 0){
                c[i] -= 3;
                team++;
            }
            else {
                break;
            }
        }
        cout << team << endl;
    }
    return 0;
}

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

bool isPrime(int x) {
  if (x < 2) return false;
  if (x == 2) return true;
  if (x % 2 == 0) return false;
  double sqrt_num = sqrt(x);
  for (int j=3; j <= sqrt_num; j+=2) {
    if (x % j==0) return false;
  }
  return true;
}

int main(){
  int n; cin >> n;
  int c=0;
  rep(i,n) {
    int x; cin >> x;
    bool b = isPrime(x);
    if (b) c++;
  }
  cout << c << endl;
}



Measured memory_bytes: 3104
from sys import stdin
input = stdin.readline

def preorder(idx, nodelist):
    nodelist.append(idx)
    left, right = leftlist[idx], rightlist[idx]
    if left != -1:
        preorder(left, nodelist)
    if right != -1:
        preorder(right, nodelist)
    return nodelist

def inorder(idx, nodelist):
    left, right = leftlist[idx], rightlist[idx]
    if left != -1:
        inorder(left, nodelist)
    if right != -1:
        nodelist.append(idx)
        inorder(right, nodelist)
    else:
        nodelist.append(idx)
    return nodelist
    
def postorder(idx, nodelist):
    left, right = leftlist[idx], rightlist[idx]
    if left != -1:
        postorder(left, nodelist)
    if right != -1:
        postorder(right, nodelist)
        nodelist.append(idx)
    else:
        nodelist.append(idx)
    return nodelist

n = int(input())
parentlist = [-1]*n
leftlist = [-1]*n
rightlist = [-1]*n
for i in range(n):
    idx, left, right = map(int, input().split())
    leftlist[idx], rightlist[idx] = left, right
    if left != -1:
        parentlist[left] = idx
    if right != -1:
        parentlist[right] = idx
root = parentlist.index(-1)

print('Preorder\n', *preorder(root, []))
print('Inorder\n', *inorder(root, []))
print('Postorder\n', *postorder(root, []))


Measured memory_bytes: 5620