akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 
int N;
string S;
string ans;
string what[4] = {"YYMM", "MMYY", "AMBIGUOUS", "NA"};

int main(){
    cin >> S;

    int y = stoi(S.substr(0, 2));
    int m = stoi(S.substr(2, 2));

    if(y>12){
        if(m==0 || m>12){
            ans = what[3];
        }else{
            ans = what[0];
        }
    }else if(m>12){
        if(y==0 || y>12){
            ans = what[3];
        }else{
            ans = what[1];
        }
    }else{
        if(y==0 && m==0){
            ans = what[3];
        }else if(y==0){
            ans = what[0];
        }else if(m==0){
            ans = what[1];
        }else{
            ans = what[2];
        }
    }

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




Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# abc132/abc132_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    n = i2n()
    p = i2nn()
    s = 0
    for i in range(1, n - 1):
        s += int(p[i - 1] < p[i]  < p[i + 1])
        s += int(p[i - 1] > p[i]  > p[i + 1])
    print(s)
    return

main()


Measured memory_bytes: 3064
N = int(input())
A = [list(map(lambda x: int(x) - 1, input().split())) + [-1] for i in range(N)]

ans = 0
matched = 0
marker = [0] * N
que = list(range(N))

while matched < N * (N - 1) // 2:
    already_matched = set()
    no_matched = True
    next_que = []

    while que:
        player = que.pop()
        partner = A[player][marker[player]]

        if A[partner][marker[partner]] == player:
            if not ((player not in already_matched) and (partner not in already_matched)):
                continue

            matched += 1

            marker[player] += 1
            marker[partner] += 1

            already_matched.add(player)
            already_matched.add(partner)

            next_que.append(player)
            next_que.append(partner)

            no_matched = False

    ans += 1
    que = next_que[:]
    if no_matched:
        print(-1)
        break

else:
    print(ans)


Measured memory_bytes: 55388
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
#include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)   (x).begin(),(x).end()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define mp       make_pair
#define eb       emplace_back
typedef pair<LL, LL> P;
typedef pair<P, P> PP;

LL n, a[101010], b[101010], c[101010];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	sort(a, a + n), sort(b, b + n), sort(c, c + n);
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		ans += distance(a, lower_bound(a, a + n, b[i]))*distance(upper_bound(c, c + n, b[i]), c + n);
	}
	cout << ans << endl;
}

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

int main() {
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(),v.end());
    cout << v[0]+v[1] << endl;
}

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k; cin>>n>>k;
    vector<int> a(n);
    int lowest = inf;
    int key;
    REP(i,n){
        cin>>a[i];
        lowest = min(lowest, a[i]);
        if(lowest>a[i]) key = i;
    }
    int ans = key/(k-1) + ((n-key-1)+k-2)/(k-1);
    print(ans);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPS 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 130
string ans = "Atcod3rIsGreat";
int dp[MN][MN];
int lcs(string x){
    memset(dp, 0, sizeof dp);
    FOR(i, 1, ans.size()) dp[i][0] = i;
    FOR(j, 1, x.size()) dp[0][j] = j;
    FOR(i, 1, ans.size()){
        FOR(j, 1, x.size()){
            dp[i][j] = INF;
            dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
            dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
            if(ans[i-1] == x[j-1]) dp[i][j] = min(dp[i][j], dp[i-1][j-1]);
            else dp[i][j] = min(dp[i][j], dp[i-1][j-1]+1);
        }
    }
    return dp[ans.size()][x.size()];
}
int l=128, q=850;
int k=62;
char alph[MN];
int cnt[MN];
int n;
int que(string t){
    cout << "? " << t << endl;
    cout.flush();
    int x;
    cin >> x;

    //int x = lcs(t);
    //cout << x << "\n";
    return x;
}
string get(int lb, int rb){
    //cout << "doing " << lb << " " << rb << "\n";
    if(lb == rb){
        string s = "";
        F0R(_, cnt[lb]) s += alph[lb];
        return s;
    }

    int mid = (lb+rb)/2;
    string lft = get(lb, mid);
    string rt = get(mid+1, rb);
    if(lft == "") return rt;
    if(rt == "") return lft;
    int j=0;
    string cur = lft;
    F0R(i, rt.size()){
        while(j <= cur.size()){
            string nw = cur;
            nw.insert(nw.begin()+j, rt[i]);
            int res = que(nw);
            if(res+nw.size() == n){
                //subsequence!
                cur = nw;
                ++j;
                break;
            } else{
                ++j;
            }
        }
    }
    //cout << lb << " " << rb << " " << cur << "\n";
    return cur;
}
int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);

    F0R(i, 26) alph[i] = 'a'+i;
    F0R(i, 26) alph[i+26] = 'A'+i;
    F0R(i, 10) alph[i+52] = '0'+i;
    F0R(i, k){
        string s = "";
        F0R(j, l) s += alph[i];
        cnt[i] = l-que(s);
        n += cnt[i];
    }
    /*F0R(i, k){
        F0R(j, cnt[i]) cout << alph[i];
    }
    cout << "\n";*/
    string res = get(0, k);
    cout << "! " << res << endl;
    cout.flush();
    return 0;
}


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

using namespace std;

int main(void)
{
    int pos[5];
    int minRemain = 999;
    int minIndex = -1;
    int total = 0;
    for(int i = 0; i < 5; i++){
        cin >> pos[i];
        int rem = pos[i] % 10;
        if( rem == 0 ){
            total += pos[i];
        }else{
            total += pos[i] / 10 * 10 + 10;
            if(rem < minRemain){
                minRemain = rem;
                minIndex = i;
            }
        }
    }
    if(minIndex != -1){
        total -= 10 - minRemain;
    }
    printf("%d\n", total);


    return 0;
}

Measured memory_bytes: 256
package main
import "fmt"

func main() {
	var a, b int
	fmt.Scanf("%d %d",&a,&b)

	add := a+b
	sub := a-b
	mul := a*b

	ans := add
	if add < sub {
		if sub < mul {
			ans = mul
		} else {
			ans = sub
		}
	} else {
		if add < mul {
			ans = mul
		}
	}
	
	fmt.Println(ans)
}
	

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

int n, W;

int w[111], v[111];

ll ans;

vector <ll> it[4], sum[4];

void calc(int id) {
    sum[id].resize(it[id].size() + 1);
    sum[id][0] = 0;
    for (int i = 1; i <= (int)it[id].size(); ++i) {
        sum[id][i] = sum[id][i - 1] + it[id][i - 1];
    }
}

void relax(int i1, int i2, int i3, int i4) {
    if (i1 > (int)it[0].size())
        return;
    if (i2 > (int)it[1].size())
        return;
    if (i3 > (int)it[2].size())
        return;
    if (i4 > (int)it[3].size())
        return;
    ll cur = sum[0][i1] + sum[1][i2] + sum[2][i3] + sum[3][i4];
    ll ww = w[0] * 1LL * i1 + ((w[0] + 1) * 1LL * i2) + ((w[0] + 2) * 1LL * i3) + ((w[0] + 3) * 1LL * i4);
    if (cur > ans && ww <= W)
        ans = cur;
}

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> W;
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
        it[w[i] - w[0]].push_back(v[i]);
    }
    for (int i = 0; i < 4; ++i) {
        sort(it[i].begin(), it[i].end());
        reverse(it[i].begin(), it[i].end());
        calc(i);
    }
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n - i; ++j) {
            for (int k = 0; k <= n - i - j; ++k) {
                for (int h = 0; h <= n - i - j - k; ++h) {
                    relax(i, j, k, h);
                }
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
template<typename T>void read(T &x){
	x=0;int f(1);char c(getchar());
	for(;!isdigit(c);c=getchar())if(c=='-')f=-f;
	for(; isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c-'0');
	x*=f;
}
template<typename T>void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)write(x/10),x%=10;
	putchar(x+'0');
}
long long so(long long a){
	long long tmp=a*a;
	return tmp*tmp*a;
}
int main(){
	long long x;read(x);
	for(long long a=-1000;a<=1000;++a)
		for(long long b=-1000;b<=a;++b)
			if(so(a)-so(b)==x){
				write(a),putchar(' ');
				write(b),putchar('\n');
				return 0;
			}
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
const int N = 200010;
int n,m,s[N][11];
PII c[N],que[N];
vector<int> v[N];
int x,y;
struct tri{
	int x,y,z;
	void Input(){scanf("%d%d%d",&x,&y,&z);}
}q[N];

int main(){
	scanf("%d%d",&n,&m);
	while(m--){
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int Q;
	scanf("%d",&Q);
	for(int i  =1;i<=Q;i++) q[i].Input();//scanf("%d%d",&q[i].X,&q[i].Y);
	for(int i=Q;i>=1;i--){
		int head = 0,tail = 0;
		int color = q[i].z;
		que[0] = mp(q[i].x,q[i].y);
		while(head<=tail){
			PII tmp = que[head++];
			if(i>c[tmp.X].X) c[tmp.X] = mp(i,color);
			//if(i>s[tmp.X][tmp.Y]) s[tmp.X][tmp.Y] = i; else continue;
			bool pd =true;
			for(int j = tmp.Y;j<=10;j++) if(s[tmp.X][j]>=i) {
				pd= false;
				break;
			}
			if(pd) s[tmp.X][tmp.Y] = i; else continue;
			if(tmp.Y==0) continue;
			for(int j = 0;j<v[tmp.X].size();j++){
				que[++tail] = mp(v[tmp.X][j],tmp.Y-1);
			}
		}
	}
	for(int i =1;i<=n;i++) printf("%d\n",c[i].Y);
	return 0;
}

Measured memory_bytes: 19704
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  int N, W; 
  cin >> N >> W;
  vector<int> v(N), w(N);
  rep(i, N) cin >> v[i] >> w[i];
  vector<vector<int>> dp(N+1, vector<int>(W+1));
  for(int i=1; i<=N; i++) {
    rep(j, W+1) {
      chmax(dp[i][j], dp[i-1][j]);
      if(j-w[i-1] >= 0)
        chmax(dp[i][j], dp[i][j-w[i-1]]+v[i-1]);
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 6828
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  vector<int> As(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[i] = make_pair(a, i+1);
    As[i] = a;
  }
  sort(A.begin(), A.end());
  
  for (int i = 1; i <= N; i++) {
    if (A[N-1].second == i) {
      cout << A[N-2].first << endl;
    }
    else {
      cout << A[N-1].first << endl;
    }
  }
}

  
  

Measured memory_bytes: 3968
#include <stdio.h>

int main() {
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=0;i<1000000;i++){
        if((a+a*i)%b==c){
            printf("YES\n");
            return 0;
        }else{
            continue;
        }
    }
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

const int N = 200005;

int n, q;
vector<int> g[N];
int load[N];
int val[N];
int dfs(int u, int par){
	val[u] += load[u];
	for(int v: g[u])
		if(v != par){
			load[v] += load[u];
			dfs(v, u);
		}
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> q;
	for(int i = 1 ; i < n ; i ++){
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	while(q--){
		int p, x;
		cin >> p >> x;
		load[p] += x; 
	}
	dfs(1, 0);
	for(int i = 1 ; i <= n ; i ++)
		cout << val[i] << " ";
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    int64_t ans = 0;
    for (int64_t i = 1; i < N; i++) {
        int64_t step = max(A[i - 1] - A[i], (int64_t)0);
        ans += step;
        A[i] += step;
    }

    cout << ans << endl;
}

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

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W, D;
  cin >> H >> W >> D;
  vector<vector<int>> A(H, vector<int>(W));
  vector<pair<int, int>> loc(H * W + 1);
  REP(i, H) REP(j, W) {
    cin >> A[i][j];
    loc[A[i][j]] = {i, j};
  }
  vector<i64> costs(H * W + 1, -1);
  for (int v = H * W; v > 0; --v) {
    if (costs[v] >= 0) continue;
    int p = v % D;
    i64 cost = 0;
    costs[p] = cost;
    pair<int, int> ploc = loc[p];
    while (p != v) {
      int x = p + D;
      pair<int, int> xloc = loc[x];
      cost += abs(xloc.first - ploc.first) + abs(xloc.second - ploc.second);
      costs[x] = cost;
      p = x;
      ploc = xloc;
    }
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int l, r;
    cin >> l >> r;
    cout << (costs[r] - costs[l]) << '\n';
  }
}

Measured memory_bytes: 4988
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int a, b;

	scanf("%d", &a);
	scanf("%d", &b);

	printf("%d %d %.5f", a / b, a % b, (double)a / (double)b);

	cout << endl;
	return 0;
}

Measured memory_bytes: 3296
#include <iostream>
#include <sstream>

int main() {
    int n, x, count;
    std::stringstream ss;
    while (std::cin >> n >> x) {
        if (n == 0 && x == 0) break;
        else {
            count = 0;
            for (int i=1;i<=n;++i)
                for (int j=i+1;j<=n;++j)
                    for (int k=j+1;k<=n;++k)
                        if (i + j + k == x)
                            ++count;
            ss << count << std::endl;
        }
    }
    std::cout << ss.str();
    return 0;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n );
  int gc;
  scanf("%d", &gc);
  for( int i = 1, x ; i < n ; ++i ) {
    scanf("%d", &x);
    gc = __gcd(gc, x );
  }
  printf("%d\n", gc );
  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  if (N==M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> iP;
typedef pair< LL, LL > LP;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 300005;

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );
            if( i * i != n ) ret.pb( n / i );

        }
    }
    sort( all( ret ) );
    return ret;
}

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

        int n;
        cin >> n;
        string s = "E869120";
        int res = 0;
        for( int i = 0; i < n; ++i ) {
                string t;
                cin >> t;
                if( t == s ) ++res;

        }
        cout << res << endl;

    return 0;
}


Measured memory_bytes: 3232
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int x=sc.nextInt();
    int y=sc.nextInt();
    int m=0;
    int flag=0;
    if(y<=x*2||y<=x*4)
    {
      for(int i=1;i<=x;i++)
      {
        int j=i*2;
        m=i*4;
        int h=y-j;
        int h1=y-m;
        if((h1%2==0&&h1/2==x-i)||(h%4==0&&h/4==x-i))
        {
          flag=1;
          break;
        }
      }
    }
    if(flag==1)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
} 


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

using namespace std;

#define N 200005
#define Mod 1000000007

int n, c[N], f[N], s[N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i)
        scanf("%d", c + i);
    s[0] = 1;
    for (int i = 1; i <= n; ++i)
        if (c[i] != c[i - 1]) (s[c[i]] += s[c[i - 1]]) %= Mod;
    cout << s[c[n]] << endl;
    return 0;
}


Measured memory_bytes: 1792
//O(N^2)
#include <stdio.h>
#include <x86intrin.h>
typedef unsigned int uint;
#pragma GCC optimize ("O3")
void read(uint *p){
    int flag = 0;
    uint num = 0;
    for(;;){
        int c = getchar_unlocked() - '0';
        if(0 <= c && c <= 9){
            num = num*10+c;
            flag = 1;
        }else if(flag){
            *p=num;
            return;
        }
    }
}
#define N 200000
uint a[N] __attribute__ ((aligned (16)));
uint b[N] __attribute__ ((aligned (16)));
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx")
int main(void){
    uint ss[4];
    uint s=0;
    uint n;
    read(&n);
    for(uint i=0; i<n; i++){
        read(a+i);
    }
    for(uint i=0; i<n; i++){
        read(b+i);
    }
    if(n&1){
        for(uint i=0; i<n; i++){
            s ^= a[i];
        }
        for(uint i=0; i<n; i++){
            s ^= b[i];
        }
    }
    __m128i s0 = _mm_setzero_si128();
    __m128i s1 = _mm_setzero_si128();
    __m128i s2 = _mm_setzero_si128();
    __m128i s3 = _mm_setzero_si128();
    uint j;
    for(j=0; j<N; j+=4){
        __m128i d = _mm_load_si128((__m128i*)(b+j));
        __m128i d0 = _mm_shuffle_epi32(d, 0x00);
        __m128i d1 = _mm_shuffle_epi32(d, 0x55);
        __m128i d2 = _mm_shuffle_epi32(d, 0xAA);
        __m128i d3 = _mm_shuffle_epi32(d, 0xFF);
        uint i;
        for(i=0; i<N; i+=16){
            __m128i c0 = _mm_load_si128((__m128i*)(a+i+0));
            __m128i c1 = _mm_load_si128((__m128i*)(a+i+4));
            __m128i c2 = _mm_load_si128((__m128i*)(a+i+8));
            __m128i c3 = _mm_load_si128((__m128i*)(a+i+12));
            __m128i t0 = _mm_add_epi32(c0, d0);
            __m128i t1 = _mm_add_epi32(c1, d0);
            __m128i t2 = _mm_add_epi32(c2, d0);
            __m128i t3 = _mm_add_epi32(c3, d0);
            s0 = _mm_xor_si128(s0, t0);
            s1 = _mm_xor_si128(s1, t1);
            s2 = _mm_xor_si128(s2, t2);
            s3 = _mm_xor_si128(s3, t3);
            t0 = _mm_add_epi32(c0, d1);
            t1 = _mm_add_epi32(c1, d1);
            t2 = _mm_add_epi32(c2, d1);
            t3 = _mm_add_epi32(c3, d1);
            s0 = _mm_xor_si128(s0, t0);
            s1 = _mm_xor_si128(s1, t1);
            s2 = _mm_xor_si128(s2, t2);
            s3 = _mm_xor_si128(s3, t3);
            t0 = _mm_add_epi32(c0, d2);
            t1 = _mm_add_epi32(c1, d2);
            t2 = _mm_add_epi32(c2, d2);
            t3 = _mm_add_epi32(c3, d2);
            s0 = _mm_xor_si128(s0, t0);
            s1 = _mm_xor_si128(s1, t1);
            s2 = _mm_xor_si128(s2, t2);
            s3 = _mm_xor_si128(s3, t3);
            t0 = _mm_add_epi32(c0, d3);
            t1 = _mm_add_epi32(c1, d3);
            t2 = _mm_add_epi32(c2, d3);
            t3 = _mm_add_epi32(c3, d3);
            s0 = _mm_xor_si128(s0, t0);
            s1 = _mm_xor_si128(s1, t1);
            s2 = _mm_xor_si128(s2, t2);
            s3 = _mm_xor_si128(s3, t3);
        }
    }
    s0 = _mm_xor_si128(s0, s2);
    s1 = _mm_xor_si128(s1, s3);
    s0 = _mm_xor_si128(s0, s1);
    _mm_storeu_si128((__m128i*)ss, s0);
    ss[0] ^= ss[2];
    ss[1] ^= ss[3];
    ss[0] ^= ss[1];
    printf("%u\n", ss[0]^s);
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


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

    vector<int> ans(N);
    REP(i, N) ans[A[i]-1] = i+1;
    
    REP(i, N) cout << ans[i] << " ";
    
    return 0;
}

Measured memory_bytes: 1536
#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 = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;
 
const int MAX_N = 100100;

//隣接リストでもつ
struct edge {
    int to; 
    edge(int to) : to(to) {};
}; 
vector<vector<edge> > G(MAX_N, vector<edge>());
void add_edge(int from, int to) {
    G[from].push_back(edge(to));
}

vector<bool> reach(MAX_N, false); //初期値:0
vector<int> ord; //トポソの逆順に並ぶ
void toposo(int u) {
    reach[u] = true;
    for(int i = 0; i < (int)G[u].size(); ++i) { //頂点vから出る各辺を走査
        int v = G[u][i].to;
        if (reach[v] == false) { 
            toposo(v);
        }
    }
    ord.push_back(u); //行ききった人から先に並ぶ（既に並んでる人にはもう指されない）
}

int main() {

    int n,m; cin >> n>>m; 
    for (int i = 0; i < m; ++i) {
        int a,b; cin>>a>>b;
        add_edge(--a, --b);
    }

    ord.clear();
    for (int i = 0; i < n; i++) {
        if(reach[i] == false) {
            toposo(i);
        }
    }

    vector<int> dp(n, 0);
    for (int i = 0; i < n; i++) {
        int v = ord[n-1-i];
        for (int j = 0; j < G[v].size(); j++) {
            int u = G[v][j].to;
            dp[u] = max(dp[u], dp[v]+1);
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, dp[i]);
    }

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

Measured memory_bytes: 8696
#include <stdio.h>
char s[500000], d;
int q, x, l, r, t;
int main() {
	scanf(" %s", s + 200000);
	l = 200000;
	r = 200000;
	while (s[r] != NULL)r++;
	r--;
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &t);
		if (t == 1)x = 1 - x;
		if (t == 2) {
			scanf("%d", &t);
			scanf(" %c", &d);
			if ((t + x) % 2) {
				l--;
				s[l] = d;
			}
			else {
				r++;
				s[r] = d;
			}
		}
	}
	if (x) {
		for (int i = r; i >= l; i--) {
			printf("%c", s[i]);
		}
	}
	else {
		for (int i = l; i <= r; i++) {
			printf("%c", s[i]);
		}
	}
	printf("\n");
}

Measured memory_bytes: 768
#include<stdio.h>

int main(void){
    long S;

    int X2,X3,Y2,Y3;

    X2=1000000000;
    Y2=1;

    scanf("%ld",&S);

    Y3=S/X2+1;
    X3=X2-S%X2;

    if(S==1000000000000000000){
        Y2=0;
        X3=0;
        Y3=1000000000;
    }

    printf("0 0 %d %d %d %d",X2,Y2,X3,Y3);

    return 0;
}

Measured memory_bytes: 128
# encoding: utf-8
N = int(input())
CSF = [list(map(int, input().split())) for i in range(N - 1)]

times = [0] * N
for i_start in range(N - 1):
    time = 0
    for Ci, Si, Fi in CSF[i_start:]:
        # wait opening celemony
        time = max(Si, time)
        # wait train arrival
        time += Fi - (time % Fi) if time % Fi > 0 else 0
        # on the train
        time += Ci
    # record
    times[i_start] = time

for time in times: print(time)

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

ll lcm(ll a,ll b){
  return b/__gcd(a,b)*a;
}

int main(){
  ll N,M,i;
  ll count;
  ll A[222222];
  bool check = true;
  cin >> N >> M;
  for(i=0;i<=N-1;i++){
    cin >> A[i];
    A[i] /= 2;
    }
  ll a = 0;
  while(A[0] % 2 == 0){
    a++;
    A[0] /= 2;
    }
  ll cm = A[0];
  for(i=1;i<=N-1;i++){
    count = 0;
    while(A[i] % 2 == 0){
      count++;
      A[i] /= 2;
    }
    cm = lcm(cm,A[i]);
    if(cm > M) check = false;
    if(count != a) check = false;
  }
  ll x = 1;
  x = x << a;
  x *= cm;
  ll y = 2*x;
  if(check) cout << M / x - M / y;  
  else cout << 0 << endl;
}

Measured memory_bytes: 4392
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        var A = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextint;
        }
        Array.Reverse(A);

        long cnt = 0;
        for (int i = 0; i < N; i++)
        {
            if (i == N - 1)
            {
                if (A[i] != 0)
                {
                    WriteLine(-1);
                    return;
                }
            }
            else
            {
                if (A[i] - A[i + 1] > 1)
                {
                    WriteLine(-1);
                    return;
                }
                if (A[i] - A[i + 1] == 1)
                {
                    cnt++;
                }
                else
                {
                    cnt += A[i];
                }
            }

        }

        WriteLine(cnt);

    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 17312
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    string s;
    if(a+b>c+d) s="Left";
    else if(a+b<c+d) s="Right";
    else s="Balanced";
    cout << s << endl;
}


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 P = pair<int,int>;

int main() {
  int a, b, c; cin >> a >> b >> c;
  cout << c << " " << a << " " << b;
  return 0;
}

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

typedef vector<int> vi;
#define all(c) ((c).begin()), ((c).end())

int main() {
    int N;
    cin>>N;
    vi L(2*N);
    for (auto&& e:L) {
        cin >> e;
    }
    sort(all(L));

    vi ans;
    for (int i = 0; i < L.size(); i+=2) {
        ans.push_back(L[i]);
    }

    cout<<(accumulate(all(ans), 0))<<endl;

    return 0;
}

Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var x = BigInt(next());
  var ans = 0;
  var q = 100n;
  while(1){
    ans++;
    q = q*101n/100n;
    if(q >= x)return ans;
  }
}

Measured memory_bytes: 29852
#include<bits/stdc++.h>
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

int P[100001];
int K[100001];

int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(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 = getint();

	vector<int> XY[100001];
	rep(i, N) {
		int x = getint(), y = getint();
		XY[x].pb(y);
	}

	rep1(i, 100000) P[i] = -1;

	rep1(i, 100000) {
		if (XY[i].size()) {
			int a = Find(XY[i][0]);
			for (int j = 1; j < (int)XY[i].size(); j++) {
				int b = Find(XY[i][j]);

				if (a == b) continue;
				if (P[a] > P[b]) swap(a, b);
				P[a] += P[b];
				P[b] = a;
				K[a] += K[b];
			}
			K[a]++;
		}
	}

	ll kotae = 0;
	rep1(i, 100000) {
		if (K[i] && P[i] < 0) {
			kotae -= 1ll * K[i] * P[i];
		}
	}
	co(kotae - N);

	Would you please return 0;
}

Measured memory_bytes: 5120
#include<stdio.h>


int main ()
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if     (x-r>=0&&y-r>=0&&x+r<=W&&y+r<=H) printf("Yes\n");
    else                                    printf("No\n");
    return 0;
}



Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
int main(){
  int n,x,m[101],s=0;
  std::cin>>n>>x;
  for(int i=0;i!=n;++i){std::cin>>m[i];s+=m[i];}
  std::cout<<n+(x-s)/(*std::min_element(m,m+n))<<"\n";
}

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

using namespace std;

#define ff first
#define ss second
#define pb push_back

using ll = long long;
using ii = pair<int, int>;

const int oo = 1e9;
const int N = 1e5 + 5;

int main(){
	char s[105];
	char s2[N];
	int k, n;
	scanf("%s", s);
	scanf("%d", &k);
	n = strlen(s);
	bool z = 0;
	int cnt0 = 0;
	int cnt = 1;
	ll ans = 0;
	for(int i = 1; i < n; i++){
		if(s[i] == s[i-1]){
			cnt++;
		}
		else{
			if(!z){
				cnt0 = cnt;
				ans += cnt / 2;
			}
			else
				ans += 1LL * cnt / 2 * k;
			cnt = 1;
			z = 1;
		}
	}
	if(z){
		ans += cnt / 2;
		if(k > 1){
			if(s[n-1] == s[0]){
				cnt += cnt0;
				ans += 1LL * cnt / 2 * (k - 1);
			}
			else{
				ans += 1LL * cnt0 / 2 * (k-1);
				ans += 1LL * cnt / 2 * (k-1);
			}
		}
	}
	else{
		ans = (1LL * cnt * k) / 2;
	}
	printf("%lld\n", ans);
	return 0;
}
// a1a2a3a


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

bool ACGT(char b)
{
	if (b == 'A' || b == 'C' || b == 'G' || b == 'T')
		return true;
	else return false;
}
int main() {
	string S;
	int S_len, ans = 0, i, ans_tmp;
	cin >> S;
	S_len = S.length();
	for (i = 0; i < S_len; i++)
	{
		ans_tmp = 0;
		while (1)
		{
			if (i + ans_tmp >= S_len)
				break;
			if (!ACGT(S[i + ans_tmp]))
				break;
			ans_tmp++;
		}
		ans = max(ans_tmp, ans);
	}


		cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N,ma=-1000001,mi=1000001,ma_idx=0,mi_idx=0;
    cin>>N;
    int a[N];
    for(int i=0;i<N;i++){
        cin>>a[i];
        if(ma<a[i])ma=a[i],ma_idx=i;
        if(mi>a[i])mi=a[i],mi_idx=i;
    }
    cout<<2*N-2<<endl;
    for(int i=0;i<N;i++){
        if(i==(abs(mi)<=abs(ma)?ma_idx:mi_idx))continue;
        cout<<(abs(mi)<=abs(ma)?ma_idx:mi_idx)+1<<" "<<i+1<<endl;
    }
    for(int i=1;i<N;i++)cout<<(abs(mi)<=abs(ma)?i:N-i+1)<<" "<<(abs(mi)<=abs(ma)?i+1:N-i)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
int n,m,low,high;
main()
{
    scanf("%d %d",&n,&m);
    if(m-n+1<-1000000) low=-1000000;
    else low=m-n+1;
    if(m+n-1>1000000) high=1000000;
    else high=m+n-1;
    for(int i=low;i<=high;i++)
        printf("%d ",i);
}


Measured memory_bytes: 256
n, k = map(int, input().split())
r, s, p = map(int, input().split())
tt = list(input())

selected  = []
get_points = []

def win_method(b):
  if b == 'r':
    return 'p'
  elif b == 's':
    return 'r'
  elif b == 'p':
    return 's'

for a, t in enumerate(tt):
  win_this = win_method(t)
  selectable = {'r': r, 's': s, 'p': p}
  # k回前に出した手以外を選択
  if len(selected) >= k:
    bf = selected[-k]
    del selectable[bf]
  else:
    bf = ''
  # k回後に得られる点数より低い場合は次回に譲るようにする
  if a + k < n:
    nx = win_method(tt[a + k])
    if win_this != nx and bf != nx:
      del selectable[nx]
  if win_this in selectable:
    selected.append(win_this)
    get_points.append(selectable[win_this])
  else:
    selected.append(next(iter(selectable)))
    get_points.append(0)
  # print(a)
  # print(selected)
  # print(get_points)
    
print(sum(get_points))

Measured memory_bytes: 5576
import heapq
X, Y, Z, K = map(int, input().split())
A_array = list(map(int, input().split()))
B_array = list(map(int, input().split()))
C_array = list(map(int, input().split()))

A_array.sort()
B_array.sort()
C_array.sort()

use_array = []
sum_array = []

candidate = []
heapq.heapify(candidate)

max_sum = A_array[-1] + B_array[-1] + C_array[-1]

heapq.heappush(candidate, (0, X - 1, Y - 1, Z - 1))
use_array.append((X - 1, Y - 1, Z - 1))

for i in range(K):
    s, x, y, z = heapq.heappop(candidate)

    sum_array.append(s)
    if x != 0 and (x - 1, y, z) not in use_array:
        use_array.append((x - 1, y, z))
        diff = A_array[x] - A_array[x - 1]
        heapq.heappush(candidate, (s + diff, x - 1, y, z))

    if y != 0 and (x, y - 1, z) not in use_array:
        use_array.append((x, y - 1, z))
        diff = B_array[y] - B_array[y - 1]
        heapq.heappush(candidate, (s + diff, x, y - 1, z))

    if z != 0 and (x, y, z - 1) not in use_array:
        use_array.append((x, y, z - 1))
        diff = C_array[z] - C_array[z - 1]
        heapq.heappush(candidate, (s + diff, x, y, z - 1))

for ans in sum_array:
    print(max_sum - ans)

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

int n , x[1010];

int main(){

cin>>n;
for(int i=0;i<n;i++)cin>>x[i];
sort(x,x+n);
cout<<x[n-1]-x[0]<<endl;

return 0;
}


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

int m(int h, int m) {
  return h*60+m;
}

int main() {
  int base[8][8] = {{0,0,0,0,0,0,0,0},
		    {0,0, 300,500,600,700,1350,1650},
		    {0,6, 0,  350,450,600,1150,1500},
		    {0,13,7,  0,  250,400,1000,1350},
		    {0,18,12, 5,  0,  250,850, 1300},
		    {0,23,17, 10, 5,  0,  600, 1150},
		    {0,43,37, 30, 25, 20, 0,   500},
		    {0,58,52, 45, 40, 35, 15,  0}};
  while(1) {
    int s,g;
    int sh, sm, gh, gm;
    cin >> s;
    if(s == 0) break;
    cin >> sh >> sm;
    cin >> g;
    cin >> gh >> gm;
    int temp;
    if(s > g) {
      temp = s;
      s = g;
      g = temp;
    }

    bool half = false;
    if(m(sh,sm) >= m(17,30) && m(sh,sm) <= m(19,30) && base[g][s] <= 40) {
      half = true;
    }
    else if(m(gh,gm) >= m(17,30) && m(gh,gm) <= m(19,30) && base[g][s] <= 40) {
      half = true;
    }
    if(half) {
      temp = (base[s][g] / 2 + 49) / 50 * 50;
      cout << temp << endl;
    } else {
      cout << base[s][g] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
N = int(input())
if N == 1:
  print("First")
  exit()
ab = [list(map(int, input().split())) for _ in range(N - 1)]

R = {}
for a, b in ab:
  if a - 1 in R:
    R[a - 1].append(b - 1)
  else:
    R[a - 1] = [b - 1]
  if b - 1 in R:
    R[b - 1].append(a - 1)
  else:
    R[b - 1] = [a - 1]

L = [0] * N
L[0] = 1
F = []
RL = {}
RL[1] = [0]
RL[2] = []
for i in R[0]:
  F.append(i)
  L[i] = 2
  RL[2].append(i)

k = 2
while F != []:
  k += 1
  Ft = []
  RL[k] = []
  for i in F:
    for j in R[i]:
      if L[j] == 0:
        L[j] = k
        Ft.append(j)
        RL[k].append(j)
  F = Ft

d = 0
D = [0] * N
for i in range(k - 1, 0, -1):
  for j in RL[i]:
    for k in R[j]:
      if L[k] == i - 1:
        if D[k] == 0:
          D[k] = D[j] + 1
          d = max(d, D[j] + 1)
        else:
          d = max(d, D[j] + D[k] + 1)
          D[k] = max(D[k], D[j] + 1)

if d % 3 == 1:
  print("Second")
else:
  print("First")


Measured memory_bytes: 128584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int N;
ll s[100010];
ll ans;

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s[i];
    }

    for(int C = 1; C < N; C++){
        ll score = 0;
        set<int> coor;
        for(int k = 1; k * C < N; k++){
            if(N - 1 - k * C < C) break;
            int y1 = N - 1 - k * C; 
            int y2 = k * C;
            if(coor.find(y1) != coor.end() || coor.find(y2) != coor.end() || y1 == y2) break;

            coor.insert(y1);
            coor.insert(y2);
            score += s[y1] + s[y2];
            ans = max(ans, score);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define mii map<int, int>
#define mci map<char, int>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << "debug: " << x << "\n";
}

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;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  int n;
  cin >> n;
  vi a(n);
  int c_2 = 0, c_4 = 0;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    if (tmp % 4 == 0)
      c_4++;
    else if (tmp % 2 == 0)
      c_2++;
  }
  Yes_No(2 * c_4 + 1 + max(c_2 - 1, 0) >= n);
}
int main(void) { solve(); }

Measured memory_bytes: 3756
#include <stdio.h>

int main(void){
    int k[5];
    int n;

    for(int i = 0; i < 5; i++){
        scanf("%d", &k[i]);
    }
    scanf("%d", &n);

    if(k[4] - k[0] > n){
        printf(":(");
    }
    else{
        printf("Yay!");
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

main(){
  int a,b,c,x,ans=0;
  cin>>a>>b>>c>>x;
  for(int i=0;i<=a;i++)
    for(int j=0;j<=b;j++)
      for(int k=0;k<=c;k++)
        if(500*i+100*j+50*k==x)ans++;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int arr[500001];
int ans = 0;

void marge_sort(int l,int r)
{
	if(r-l==1)return;
	int mid = (l+r)/2;
	marge_sort(l,mid);
	marge_sort(mid,r);
	vector<int> v;
	int i = l;
	int j = mid;
	while(1)
	{
		
		if(i==mid||j==r)break;
		ans++;
		if(arr[i]<arr[j])
		{
			
			v.push_back(arr[i]);
			i++;
		}
		else
	 	{
			 v.push_back(arr[j]);
			 j++;
		}
	}
	
	for(;i<mid;i++)v.push_back(arr[i]),ans++;
	for(;j<r;j++)v.push_back(arr[j]),ans++;
	for(int k = l;k<r;k++)
	{
		arr[k] = v[k-l];
	}
}

int main()
{
	int n;
	cin >> n;
	for(int i =0;i<n;i++)
	{
		cin >> arr[i];
	}
	marge_sort(0,n);
	for(int i = 0;i<n;i++)
	{
		if(i)cout<<' ';
		cout<<arr[i];
	}
	cout<<endl;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7816
#include <iostream>
#include <algorithm>

using namespace std;

int main( void )
{
	int n, m[31];
	fill(m, m+31, 0);
	m[0] = 1;
	for(int i=0; i < 30; ++i) {
		if(!m[i]) continue;
		for(int j=1; j <= 3; ++j) {
			int ii = i + j;
			if(ii <= 30) {
				m[ii] += m[i]; 
			}
		}
	}
	for(int i=0; i <= 30; ++i) m[i] /= 10;
	while(cin >> n, n) {
		cout << m[n] / 365 + ((m[n] == 0 || m[n]%365)? 1 : 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define N 1000000007
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    map <string, int> mapp;
    mapp["SUN"] = 7;
    mapp["MON"] = 6;
    mapp["TUE"] = 5;
    mapp["WED"] = 4;
    mapp["THU"] = 3;
    mapp["FRI"] = 2;
    mapp["SAT"] = 1;
    cout<<mapp[s];
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 100001
int MOD=1000000007;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

void solve()
{
    int n,m; cin>>n>>m;
    int x; int sum=0;
    for(int i=0;i<m;i++)
    cin>>x,sum+=x;
    if(sum>n)
    cout<<-1;
    else
    cout<<n-sum;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test;test=1;
    while(test--)
    {
        solve();
    }
    return 0;
}

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

int main() {
	int	N, Q;
	cin >> N >> Q;
	vector<vector<int>> vec(N);
	rep(i, Q)
	{
		int a, b;
		cin >> a >> b;
		if (a == 0)
		{
			int	c;
			cin >> c;
			vec.at(b).push_back(c);
		}
		else if (a == 1)
		{
			rep(j, vec.at(b).size())
			{
				if (j)
					cout << ' ';
				cout << vec.at(b).at(j);
			}
			cout << endl;
		}
		else if (a == 2)
			vec.at(b).clear();
	}
}



Measured memory_bytes: 5852