akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#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 all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

ll N;
vector<ll> A;

void solve() {
  vector<int> p(N - 1);
  rep(i, N - 1) { p.at(i) = A.at(i + 1) - A.at(i); }

  ll c = 1000;  // cash
  ll s = 0;     // stock count
  for (int i = 0; i < N - 1; i++) {
    if (p.at(i) > 0) {  // buy
      ll cnt = floor(c / A.at(i));
      c -= A.at(i) * cnt;
      s += cnt;
    } else if (p.at(i) < 0) {  // sell
      c += A.at(i) * s;
      s = 0;
    }
  }
  c += s * A.at(N - 1);

  cout << c << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  scanf("%lld", &N);
  A.resize(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve();
  return 0;
}


Measured memory_bytes: 3724
from itertools import combinations_with_replacement

n = int(input())
res = [0] * n
for x, y, z in combinations_with_replacement(range(1, int(n**0.5)), 3):
    val = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if val > n:
        continue
    if (l := len(set([x, y, z]))) == 1:
        res[val-1] += 1
    elif l == 2:
        res[val-1] += 3
    else:
        res[val-1] += 6
print('\n'.join(map(str, res)))


Measured memory_bytes: 9724
#include <stdio.h>

int main(void)
{
  char *w[256] = {};
  w['S'] = "Cloudy";
  w['C'] = "Rainy";
  w['R'] = "Sunny";
  char s[256];
  fgets(s, 256, stdin);
  puts(w[s[0]]);
}


Measured memory_bytes: 128
import sys

n = int(input())
A = list(map(int, sys.stdin.readlines()))

index = 0
past_index = list()
found = False

for i in range(len(A)):
    if index == 1:
        print(i)
        found = True
        break
    index = A[index]-1

if not found:
    print(-1)

Measured memory_bytes: 20072
#include <stdio.h>

int
main(void)
{
	int a;
	int b;
	int c;
	
	scanf("%d %d %d", &a, &b, &c);

	if (a < b && b < c) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	
	return 0;
}



Measured memory_bytes: 2092
//By Krishna Yadav
#pragma GCC optimize("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio                        \
    ios_base::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 testcase(t) \
    int t;          \
    cin >> t;       \
    while (t--)
#define forstl(i, v) for (auto &i : v)
#define forn(i, e) for (int i = 0; i < e; i++)
#define ln "\n"

#define dbg(x) cout << #x << " = " << x << ln
#define dbg2(x, y) cout << #x << " = " << x << " & " << #y << " = " << y << ln
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef map<int, int> m32;
const int LIM = 2e5 + 5, MOD = 1e9 + 7;
int t, n, m, k, x, y;

int findMex(map<int, int> mp)
{
    int i = 0;
    while (mp[i])
        i++;
    return i;
}

int main()
{
    int n;
    cin >> n;
    int ac = 0, wa = 0, tle = 0, re = 0;
    string s;
    forn(i, n)
    {
        cin >> s;
        if (s == "AC")
            ac++;
        else if (s == "WA")
            wa++;
        else if (s == "TLE")
            tle++;
        else if (s == "RE")
            re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}


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


#define loop(i,n) for(int lc=i;lc<=n;lc++)
#define tloop(tn) for(int tlc=1;tlc<=tn;tlc++)
#define loop2(i2,n2) for(int lc2=i2;lc2<=n2;lc2++)
#define bloop(n,bn) for(int blc=n;blc>=bn;blc--)
#define il() while(true)
#define pi acos(-1)
#define rad_to_deg(angl) ((180*angl)/pi)
#define ll long long
#define caseno printf("Case %d: ",tlc);

#define sfi(def_var) scanf("%d",&def_var)
#define sfii(def_var,def_var2) scanf("%d %d",&def_var,&def_var2)
#define sfll(def_var,def_var2) scanf("%lld %lld",&def_var,&def_var2)

#define sfl(def_var) scanf("%lld",&def_var)
#define sfd(def_var) scanf("%lf",&def_var)
#define sfs(def_var) scanf("%s",&def_var)

#define pfie(def_var) printf("%d\n",def_var)
#define pfi(def_var) printf("%d",def_var)
#define pfl(def_var) printf("%lld",def_var)
#define pfd(def_var) printf("%lf",def_var)
#define nl printf("\n");

string grid[1001];
int h,w;
int dp[1001][1001];

ll mod=1000000000+7;
int find_ans(int i=0,int j=0)
{
    if(i==h || j==w) return 0;
    if(i==h-1 && j==w-1) return 1;
    if(dp[i][j]>-1) return dp[i][j];
    ll p1=0,p2=0;
    if(grid[i+1][j]=='.') p1= find_ans(i+1,j);
    if(grid[i][j+1]=='.') p2=find_ans(i,j+1);

    p1+=p2;
    p1%=mod;
    dp[i][j]=p1;
    return dp[i][j];
}

int main()
{
    cin >> h >> w;
    loop(0,h-1)
    {
        cin >> grid[lc];
    }
    memset(dp,-1,sizeof(dp));

    cout << find_ans();

}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define N 1000005
#define sc scanf
#define pb push_back

int main() {

    int n;
    sc("%d", &n);

    int a;

    if(n >= 400 && n <= 599) {
        a = 8;
    }
    if(n >= 600 && n <= 799) {
        a = 7;
    }
    if(n >= 800 && n <= 999) {
        a = 6;
    }
    if(n >= 1000 && n <= 1199) {
        a = 5;
    }
    if(n >= 1200 && n <= 1399) {
        a = 4;
    }
    if(n >= 1400 && n <= 1599) {
        a = 3;
    }
    if(n >= 1600 && n <= 1799) {
        a = 2;
    }
    if(n >= 1800 && n <= 1999) {
        a = 1;
    }

    printf("%d\n", a);
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=5000,INF=1e18;
ll N,A,B,memo[MAX_N+1][MAX_N*2+1],q[MAX_N];
ll dfs(ll n,ll x){
	if(n==N){
		return 0;
	}
	if(memo[n][x]!=-1){
		return memo[n][x];
	}
	ll ret=INF,x2;
	if(q[n]*2+1>x){
		x2=(x+1)/2*2;
		ret=dfs(n+1,x2)+B;
		ret=min(ret,dfs(n+1,q[n]*2+1));
	}
	ret=min(ret,A+dfs(n+1,max(q[n]*2+2,(x+1)/2*2)));
	return memo[n][x]=ret;
}
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>A>>B;
	REP(i,N){
		ll p;
		cin>>p;
		p--;
		q[p]=i;
	}
	memset(memo,-1,sizeof(memo));
	cout<<dfs(0,0)<<endl;
}

Measured memory_bytes: 391296
#include <iostream>
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;

    int res = A + B;
    if (res < A - B)
        res = A - B;
    if (res < A * B)
        res = A * B;
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int k(int a) {
  int k = 0;
  while(a) {
    a /= 10;
    k ++;
  }
  return k;
}
int main () {
  long long N;
  cin >> N;
  int bi[10];
  bi[0] = 1;
  
  for (int i = 0; i < 9; i ++) bi[i + 1] = bi[i] * 2;
  int ju = k(N);
  long long ans = 0;
  for (int i_ = 0; i_ < bi[ju - 1]; i_ ++) {
    int i = i_;
    long long a = N;
    long long b = 10;
    for (int j = 0; j < ju - 1; j ++) {
      if (i % 2) {
        ans += a % b;
        a /= b;
        b = 1ll;
      }
      i /= 2;
      b *= 10;
    }
    ans += a;
  }
  cout << ans << endl;
}
  



Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin >> n;

    ll ret = 1145141919810364364;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret = min(ret, i + n / i - 2);
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

// 入力文字を以下の法則に従って書き換え
// print a b : str の a 文字目から b 文字目までを出力する。
// reverse a b : str の a 文字目から b 文字目までを逆順にする。
// replace a b p : str の a 文字目から b 文字目までを p に置き換える。
int main()
{
	char achInputText[1000];
	int iQuestionNum;
	char achQuestion[10];
	char achReplaceText[1000];
	int iInputA, iInputB;
	int iCnt, iCnt2;
	char chSwapTmp;

	scanf("%s", achInputText);
	scanf("%d", &iQuestionNum);

	for (iCnt = 0; iCnt < iQuestionNum; iCnt++)
	{
		scanf("%s", achQuestion);

		// 置き換えなら
		if (strcmp("replace", achQuestion) == 0)
		{
			scanf("%d %d %s", &iInputA, &iInputB, achReplaceText);
			for (iCnt2 = 0; iCnt2 < iInputB - iInputA + 1; iCnt2++)
			{
				achInputText[iInputA + iCnt2] = achReplaceText[iCnt2];
			}
		}
		else if (strcmp("reverse", achQuestion) == 0)
		{
			scanf("%d %d", &iInputA, &iInputB);
			// 指定された文字の頭からと後ろからで入れ替え
			for (iCnt2 = 0; iCnt2 < (iInputB - iInputA) / 2 + 1; iCnt2++)
			{
				chSwapTmp = achInputText[iInputA + iCnt2];
				achInputText[iInputA + iCnt2] = achInputText[iInputB - iCnt2];
				achInputText[iInputB - iCnt2] = chSwapTmp;
			}
		}
		else
		{
			scanf("%d %d", &iInputA, &iInputB);
			// 指定範囲で出力
			for (iCnt2 = iInputA; iCnt2 < iInputB + 1; iCnt2++)
			{
				printf("%c", achInputText[iCnt2]);
			}
			printf("\n");
		}
	}

	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

int main() {
    int n, q, t;
    string name;

    queue<pair<string, int> > Q; // queue of processes

    cin >> n >> q;

    // Add all processes to queue in order
    for (int i = 0; i < n; i++) {
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }

    pair<string, int> u;
    int elaps = 0, a;

    while ( !Q.empty() ) {
        u = Q.front(); Q.pop();
        a = min(u.second, q);
        u.second -= a;
        elaps += a;
        if (u.second > 0) {
            Q.push(u);
        } else {
            cout << u.first << " " << elaps << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 6312
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define INF (ll)1e16

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    int MAX_JUMP = (n % 2 == 0) ? 2 : 3;
    vector<ll> dp[MAX_JUMP];
    rep(i,MAX_JUMP) dp[i] = vector<ll>(n, -INF);
    rep(i,MAX_JUMP) dp[i][i] = a[i];
    rep(i,n){
        rep(k,MAX_JUMP){
            if (i < k) continue;
            rep(j,MAX_JUMP){
                if (k+j <= MAX_JUMP-1 && i+j+2 < n){
                    dp[k+j][i+j+2] = max(dp[k+j][i+j+2], dp[k][i] + a[i+j+2]);
                }
            }
        }
    }
    if (n % 2 == 0){
        cout << max({dp[1][n-1], dp[0][n-2]}) << endl;
    } else {
        cout << max({dp[2][n-1], dp[1][n-2], dp[0][n-3]}) << endl;
    }

    return 0;
}


Measured memory_bytes: 9548
#include<stdio.h>
int gcd(int a,int b);

int main()
{
  int n;
  scanf("%d",&n);
  int a[n],d[n],d0=0,i,j;
  int saki[n],ato[n];
  for(i=0;i<n;i++)
    {
      ato[i]=0;
    }
  for(i=0;i<n;i++)
    {
      scanf("%d",&a[i]);
    }

  saki[0]=a[0]; 
  for(i=1;i<n;i++)
    {
      saki[i]=gcd(saki[i-1],a[i]);
    }

  ato[n-1]=a[n-1];
  for(i=n-2;i>0;i--)
    {
      ato[i]=gcd(ato[i+1],a[i]);
    }
  d[0]=ato[1];
  if(n>=2) d[n-1]=saki[n-2];
  for(i=1;i<n-1;i++)
    d[i]=gcd(saki[i-1],ato[i+1]);
  
  
  int max=0;
  for(i=0;i<n;i++)
    {
      if(max<d[i])max=d[i];
    }

  printf("%d",max);
  
}


int gcd(int a,int b)
{
  if(a<b)return gcd(b,a);
  else if(b==0)return a;
  //  printf("%d\n",a);
  return gcd(b, a%b);
}


Measured memory_bytes: 1664
import sys
import math
import collections
import bisect
import itertools
import decimal
import copy
import heapq

# import numpy as np

# sys.setrecursionlimit(10 ** 6)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
flush = lambda: sys.stdout.flush()


# ===CODE===
def main():
    n = ni()
    cnt = 0
    for _ in range(n):
        a, b = ns()
        if a == b:
            cnt += 1
        else:
            cnt = 0

        if cnt == 3:
            print("Yes")
            exit()

    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 9928
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
sum = np.sum(A)
cumsum = np.cumsum(A)
diff = float("inf")
for n in range(N):
    left = cumsum[n]
    right = sum-left
    if abs(left-right) < diff:
        diff = abs(left-right)
print(diff)


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

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<ll> A;
int main() {
  cin >> N;
  A.resize(N);
  for (auto &val : A) {
    cin >> val;
  }
  sort(A.rbegin(), A.rend());
  ll a = A[0];
  ll b = 0;
  for (int i = N - 1; i >= 1; i--) {
    ll c = min(A[0] - A[i], A[i]);
    if (b <= c) {
      b = A[i];
    }
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 1024
//
// Created by 江口慎悟 on 2019-04-06.
//
#include <vector>
#include <iostream>
#include <limits>
#include <algorithm>

using namespace std;
void a(){

    vector<int> antena(5);
    for(int i = 0; i < 5; i++){
        cin >> antena[i];
    }
    int k; cin >> k;

    bool ok =(antena[4] - antena[0] <= k);

    if (ok)
        cout << "Yay!";
    else
        cout << ":(";

}

void b(){


    int time_sum = 0;
    int max_loss = 0;
    int loss_sum = 0;
    for(int i = 0; i < 5; i++){
        int time; cin >> time;
        time_sum += time;
        int loss = (10 - time%10)%10;
        max_loss = (max_loss > loss)? max_loss:loss;
        loss_sum += loss;
    }

    int ans = time_sum + loss_sum - max_loss;

    cout << ans;
}

void c(){

    long long N; cin >> N;
    long long min_capa = numeric_limits<long long>::max();
    for(int i = 0; i < 5; i++){
        long long capa; cin >> capa;
        min_capa = min(min_capa, capa);
    }

    long long ans = ((N - 1)/min_capa) + 5;

    cout << ans;

}
int main(){

    c();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int n, a, l, m, s, t; cin >> n >> a >> l >> m >> s >> t;
    if (n == 0) break;
    V<> vs{s, t};
    while (l--) {
      int v; cin >> v;
      vs.push_back(v);
    }
    VV<> g(n, V<>(n, 1e9));
    for (int i = 0; i < n; ++i) g[i][i] = 0;
    while (m--) {
      int u, v, w; cin >> u >> v >> w;
      g[u][v] = g[v][u] = w;
    }
    for (int k = 0; k < n; ++k) for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
      g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
    }
    n = vs.size();
    VV<> h(n, V<>(n, 1e9));
    for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) if (g[vs[i]][vs[j]] <= a) {
      h[i][j] = g[vs[i]][vs[j]];
    }
    for (int k = 0; k < n; ++k) for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
      h[i][j] = min(h[i][j], h[i][k] + h[k][j]);
    }
    int res = h[find(begin(vs), end(vs), s) - begin(vs)][find(begin(vs), end(vs), t) - begin(vs)];
    if (res == 1e9) {
      cout << "Help!" << '\n';
    } else {
      res += max(res - a, 0);
      cout << res << '\n';
    }
  }
}


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

use std::cmp::*;
use std::collections::HashMap;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
macro_rules! chmax {
    ($x:expr, $e:expr) => {
        $x = max($x, $e);
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        $x = min($x, $e);
    };
}

const INF: i64 = 1 << 60;

fn main() {
    input!{
        N: usize,
        S: [String; N],
    }
    let mut dict = HashMap::new();
    for s in S {
        match dict.get(&s) {
            Some(_) => {
                *dict.get_mut(&s).unwrap() += 1;
            },
            None => {
                dict.insert(s, 1);
            },
        }
    }
    let mut ans: Vec<(&String, &usize)> = dict
        .iter()
        .collect();
    ans.sort_by(|a, b| (a.0).cmp(b.0));
    ans.sort_by(|a, b| (b.1).cmp(a.1));
    //println!("{:?}", ans);
    let &max = ans[0].1;
    for (k, &v) in ans {
        if v != max {
            break;
        }
        println!("{}", k);
    }
}


Measured memory_bytes: 30476
/* author   : mpily :-()
title : Competing.cpp
time :Sun Jun 14 13:11:23 2020

*/
#include<random>
#include<cassert>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<utility>
#include<cstdint>
#include<queue>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdio>
using namespace std;

void solve(int cnum){
	int mask,n;
	cin >> n;
	mask = 0;
	vector<int>arr(n);
	for(int i = 0; i < n; ++i){
		int tm;
		cin >> tm;
		mask^=tm;
		arr[i] = tm;
	}
	for(int i = 0; i < n; ++i){
		cout << (mask^arr[i]) <<" ";
	}
	cout << "\n";
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	//cout.tie(nullptr);
	int t;
	int count = 1;
	for(t = 1;t--; solve(count));
	return 0;
}

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

string s[3];
int p[3];
int len[3];
int k = 0;

int main() {
	for (int i = 0; i < 3; ++i) cin >> s[i], len[i] = s[i].size();
	while (1) {
		if (p[k] == len[k]) {
			printf("%c\n", k + 'A');
			break;
		}
		k = s[k][p[k]++] - 'a';
	}
	return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};


long long int n, a, b, ta[300010];

int main(){
	cin >> n >> a >> b;
	if(a+b>n+1||n>a*b){
		cout << -1 << endl;
		return 0;
	}
	int k=2;
	ta[1] = a;
	for(int i=1;i<=n-a;i++){
		ta[k]++;
		k++;
		if(k==b+1){
			k=2;
		}
	}
	k=1;
	for(int i=1;i<=b;i++){
		n -= ta[i] - 1;
		for(int j=n;j<n+ta[i];j++){
			cout << j << " ";
		}
		n--;
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3456
#include<iostream>

using namespace std;

int main()
{
	int n, c=0, mx=0;
	cin>>n;
	int a, b;
	cin>>a; n--;
	b=a;
	//cout<<n<<endl;
	while(n--)
	{
		//cout<<n<<endl;
		cin>>a;
		if(a<=b) c++;
		else
		{
			if(c>mx)
				mx=c;
			c=0;
		}
		if(c>mx)
				mx=c;
		//cout<<c<<" "<<mx<<" "<<b<<" "<<a<<endl;
		b=a;
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x=[0 for i in range(n)]
a=[0 for j in range(m)]
ans=0
for i in range(n):
    x[i]=list(map(int,input().split()))
    for j in range(1,x[i][0]+1):
         a[x[i][j]-1]+=1

for s in range(m):
    if n==a[s]:
        ans+=1
print(ans)

Measured memory_bytes: 8996
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define ll long long
#define endl "\n"
#define lu unsigned long long
#define mod 1000000007
#define ld long double
#define f(i, n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define v vector<ll>
#define vv vector<vector<ll> >
#define vs vector<string>
#define vpr vector<pair<ll,ll>>
#define fi first
#define se second
#define all(x)  x.begin(),x.end()
#define bg(x)  x.begin()
#define sz(x)  x.size()
#define in(x,n) f(i,n) cin>>x[i]
#define out(x,n) f(i,n) cout<<x[i]<<" "
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define mem(x,val) memset(x,val,sizeof(x))
#define tc    ll t;cin>>t;while(t--)
#define pi pair<int,int>
#define prfloat(val,precise) cout<<fixed<<setprecision(precise)<<val<<endl;
const ld PI = 2 * acos(0.0);
void yes(){ cout<<"YES\n";}
void no(){cout<<"NO\n";}
ll m(ll a){ return (a+mod)%mod;}
ll cel(ll x1,ll y1){ ;if((x1%y1)==0)return x1/y1;return x1/y1+1;}
ll power(ll a,ll b){ if(b==0)return 1;ll d=power(a,b/2);d=m(d*d);
if(b&1)d=m(d*a);return d;}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;cin>>n>>k;
	v arr(n);in(arr,n);
	int dp[2][k+1];
	int mn=mnt(arr);
	for(int i=0;i<mn;i++){
		dp[0][i]=0;dp[1][i]=0;
	}
	for(int i=mn;i<=k;i++)
		{
			int flg=0;
			for(int j=0;j<n;j++)
			{
				if(arr[j]<=i)
				if(dp[1][i-arr[j]]==0)
				{
					flg=1;
					break;
				}
			}
			dp[0][i]=flg;
			flg=0;
			for(int j=0;j<n;j++)
			{
				if(arr[j]<=i)
				if(dp[0][i-arr[j]]==0)
				{
					flg=1;
					break;
				}
			}
			dp[1][i]=flg;

		}
		if(dp[0][k]==0)cout<<"Second\n";
		else cout<<"First\n";


	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define INF INT_MAX
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef unsigned long long ull;


int main()
{
    #define int long long
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef cbaaabc
    freopen("debug.inp","r",stdin);
    freopen("debug.out","w",stdout);
    #endif
    int k,a,b;
    cin >> k >> a >> b;
    int chia = b/k;
    if (chia*k>=a)
    {
        cout << "OK";
    } else
    {
        cout << "NG";
    }
    return 0;
}



















Measured memory_bytes: 3656
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

double N;

double ans = 0;

void solve(){
	ans = N*2*3.14159265358979323846;
}
 
int main(){
    cin >> N;
 
    solve();

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 3256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
using ll = long long;

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

int N;
int A[100002];
// B[i]: A[i]とA[i-1]の距離
int B[100002];
// C[i]: A[i]を消すことでどれだけ距離が減るか
int C[100002] = {0};

int main() {
  ll sum = 0;

  scanf("%d", &N);
  A[0] = 0;
  FOR(i,1,N+1) {
    scanf("%d", &A[i]);
    B[i] = abs(A[i] - A[i-1]);
    sum += B[i];
  }
  A[N+1] = 0;
  B[N+1] = abs(A[N+1] - A[N]);
  sum += B[N+1];

  FOR(i,1,N+1) {
    printf("%d\n", sum - (B[i] + B[i+1]) + abs(A[i+1] - A[i-1]));
  }

  return 0;
}

Measured memory_bytes: 2048
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define v_in(v) for(auto&& i : v) cin >> i
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;


int main(void){
    FAST_IO
    
    ll a,b,c,x;
    cin >> a >> b >> c >> x;

    ll count = 0;
    rep(a_i,a+1){
        rep(b_i,b+1){
            rep(c_i,c+1){
                if(a_i * 500 + b_i * 100 + c_i * 50 == x) count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3156
#include <stdio.h>

int lcm(int, int); //Least_Common_Multiple
int gcm(int, int); //Greatest_Common_Measure
int pnCheck(int x);

int main() {
	int i;
	int num;
	int data[10];


	scanf("%d", &num);
	for (i = 0; i < num; i++) scanf("%d", &data[i]);

	int ans = data[0];
	for (i = 1; i < num; i++) {
		ans = lcm(data[i], ans);
	}
	printf("%d\n", ans);
	

	return 0;
}
int lcm(int x, int y){
	return x*y / gcm(x, y);
}

int gcm(int x, int y){
	if (x > y) {
		int t = x;
		x = y;
		y = t;
	}
	if (x == 1)return 1;
	int ans = 1;
	for (int i = 2; i <= x; i += 2) {
		if ((x % i == 0) && (y % i == 0) && pnCheck(i)) {
			while ((x % i == 0) && (y % i == 0)) {
				x /= i;	y /= i;
				ans *= i;
			}
		}
		if (i == 2)i--;
	}

	return ans;
	
}
int pnCheck(int x) {
	if ((x != 2) && (x % 2 == 0))return 0;
	int i;
	int fl = 0;

	for (i = 3; i*i <= x; i += 2) {
		if (pnCheck(i)) {
			if (fl = (x % i == 0)) break;
		}

	}

	return !fl;
}

Measured memory_bytes: 2756
n, m = gets.chomp.split(' ').map(&:to_i)
graph = Array.new(n) { [] }
 
m.times do
  a, b = gets.split(' ').map(&:to_i)
  graph[a - 1] << b - 1
  graph[b - 1] << a - 1
end

queue = [0]
answer = [0]

until queue.empty?
  current = queue.shift

  graph[current].each do |to|
    next if answer[to]
    answer[to] = current + 1
    queue << to
  end
end

puts 'Yes'
puts answer[1...n]


Measured memory_bytes: 33180
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int a,b;
	cin >> a >> b;
	cout << a*b << " " << 2*a + 2*b << "\n";
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		int[][] res=new int[h][w];
		//long n=sc.nextLong(),y=sc.nextLong();
		String buff="";
		for(int i=0;i<h;i++) {
			buff=sc.next();
			for(int j=0;j<w;j++) {
				if(buff.substring(j,j+1).equals(".")) {
					res[i][j]=0;
				}else {
					res[i][j]=-1;
				}
			}
		}
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				if(res[i][j]==-1) {
					if(j-1>=0 &&res[i][j-1]!=-1) {
						res[i][j-1]++;
					}
					if(j+1<=w-1&&res[i][j+1]!=-1) {
						res[i][j+1]++;
					}
					if(i-1>=0&&res[i-1][j]!=-1) {
						res[i-1][j]++;
					}
					if(i+1<=h-1&&res[i+1][j]!=-1) {
						res[i+1][j]++;
					}
					if(i+1<=h-1) {
						if(j-1>=0&&res[i+1][j-1]!=-1) {
							res[i+1][j-1]++;
						}
						if(j+1<=w-1&&res[i+1][j+1]!=-1) {
							res[i+1][j+1]++;
						}
					}
					if(i-1>=0) {
						if(j-1>=0&&res[i-1][j-1]!=-1) {
							res[i-1][j-1]++;
						}
						if(j+1<=w-1&&res[i-1][j+1]!=-1) {
							res[i-1][j+1]++;
						}
					}
				}
			}
		}
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				if(res[i][j]==-1) {
					System.out.print("#");
				}else {
					System.out.print(res[i][j]);
				}
			}
			System.out.println();
		}

	}

}


Measured memory_bytes: 22356
#include<bits/stdc++.h>
#define N 500100
using namespace std;
int n,d[N],l[N],f[N];
int main(){
	scanf("%d%d",&n,&l[0]);
	for(int i=1;i<=n;i++){
		scanf("%d",&d[i]);
		l[i]=min(l[i-1],abs(l[i-1]-d[i]));
	}
	f[n+1]=1;
	for(int i=n;i;i--){
		f[i]=f[i+1];
		if(d[i]<2*f[i]) f[i]+=d[i];
	}
	scanf("%d",&n);
	for(int i=0,a;i<n;i++){
		scanf("%d",&a);
		if(l[a-1]>=f[a+1]) puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 7808
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 200010
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,d,a[N],fa[N],t;
ll ans;
struct data
{
	int x,y;ll z;
	bool operator <(const data&a) const
	{
		return z<a.z;
	}
}e[N<<5];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
ll calcl(int i)
{
	return a[i]-1ll*i*d;
}
ll calcr(int i)
{
	return a[i]+1ll*i*d;
}
void solve(int l,int r)
{
	if (l==r) return;
	int mid=l+r>>1;
	solve(l,mid);
	solve(mid+1,r);
	int L=l;
	for (int i=l;i<=mid;i++) if (calcl(i)<calcl(L)) L=i;
	int R=r;
	for (int i=mid+1;i<=r;i++) if (calcr(i)<calcr(R)) R=i;
	for (int i=l;i<=mid;i++) e[++t]=(data){i,R,calcl(i)+calcr(R)};
	for (int i=mid+1;i<=r;i++) e[++t]=(data){L,i,calcl(L)+calcr(i)};
}
signed main()
{
	n=read(),d=read();
	for (int i=1;i<=n;i++) a[i]=read();
	solve(1,n);
	for (int i=1;i<=n;i++) fa[i]=i;
	sort(e+1,e+t+1);
	for (int i=1;i<=t;i++)
	if (find(e[i].x)!=find(e[i].y))
	{
		fa[find(e[i].x)]=find(e[i].y);
		ans+=e[i].z;
	}
	cout<<ans;
	return 0;
	//NOTICE LONG LONG!!!!!
}

Measured memory_bytes: 59264
#include <bits/stdc++.h>
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 = -1;
	for(;isdigit(c);c = getchar()) x = x*10+c-'0';
	x *= f;
}
int main(){
	string s;
	cin >> s;
	if(s == "ABC")	puts("ARC");
	else	puts("ABC");
	return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;

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

const int kMaxN = 100000;

string s;
int n;
int lr[kMaxN][2];
string ans = "";

int num_from_s[kMaxN];
int dif_s[kMaxN+1];
int sum[kMaxN+1];

class DisjointSet {
 public:
  vector<int> rank, p;

  DisjointSet();
  DisjointSet(int size) {
    rank.resize(size, 0);
    p.resize(size, 0);
    REP(i, size) { MakeSet(i); }
  }
  void MakeSet(int x) {
    p[x] = x;
    rank[x] = 0;
  }

  bool Same(int x, int y) { return FindSet(x) == FindSet(y); }
  void Unite(int x, int y) { Link(FindSet(x), FindSet(y)); }
  void Link(int x, int y) {
    if (rank[x] > rank[y]) {
      p[y] = x;
    } else if (rank[x] < rank[y]) {
      p[x] = y;
    } else {
      p[x] = y;
      ++rank[y];
    }
  }
  int FindSet(int x) {
    if (x != p[x]) { p[x] = FindSet(p[x]); }
    return p[x];
  }
};

int main() {
  cin >> s;
  cin >> n;
  REP(i, n) { cin >> lr[i][0] >> lr[i][1]; }

  REP(i, s.length()) { num_from_s[i] = s[i] - 97; }
  REP(i, s.length()+1) {
    if (i == 0) {
      dif_s[i] = num_from_s[i];
    } else if (i == s.length()) {
      dif_s[i] = (0 - num_from_s[i-1] + 26) % 26;
    } else {
      dif_s[i] = (num_from_s[i] - num_from_s[i-1] + 26) % 26;
    }
  }

  DisjointSet ds(s.length()+1);
  REP(i, s.length()+1) {
    if (i < s.length()-i) {
      ds.Unite(i, s.length()-i);
    } else {
      break;
    }
  }
  REP(i, n) { ds.Unite(lr[i][0]-1, lr[i][1]); }

  fill(sum, sum+s.length()+1, 0);
  REP(i, s.length()+1) { sum[ds.FindSet(i)] += dif_s[i]; }
  ans = "YES";
  REP(i, s.length()+1) {
    if (sum[i]%26 != 0) {
      ans = "NO";
      break;
    }
  }

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


Measured memory_bytes: 3200
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    to = [[None]*n for _ in range(60)]
    to[0] = a[:]
    for i in range(1, 60):
        for j in range(n):
            to[i][j] = to[i-1][to[i-1][j]-1]
    p = 1
    for i in range(59, -1, -1):
        num = 1 << i
        if k >= num:
            k -= num
            p = to[i][p-1]
    print(p)

if __name__ == "__main__":
    main()

Measured memory_bytes: 175212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fastio() ios::sync_with_stdio(0),cin.tie(0);

int main()
{
	fastio();
	int n, x[101],y[101],h[101],H=0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i] >> h[i];
		if (h[i]>h[H])H = i;
	}
	
	for(int i=0;i<=100;i++)
		for (int j = 0; j <= 100; j++)
		{
			bool possible = true;
			int hh = h[H] + abs(x[H] - i) + abs(y[H] - j);
			for (int k = 0; k < n&&possible; k++)
			{
				if (h[k] != max(hh - abs(x[k] - i) - abs(y[k] - j), 0))possible = false;
			}
			if (possible)
			{
				cout << i << " " << j << " " << hh;
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 256
main = do
  [n, k] <- map read . words <$> getLine
  as <- map read . words <$> getLine
  print $ solve k n as

solve k n as = solve' k l m
  where
    l = length $ takeWhile (/= 0) as
    m = n - l - 1

solve' k l m
  | l + m <= k - 1 = 1
  | l >= k = 1 + solve' k (l - k + 1) m
  | m >= k = 1 + solve' k l (m - k + 1)
  | otherwise = 2


Measured memory_bytes: 18812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int o = 0, e = 0;
    rep(i, n) { int a; cin >> a; a % 2 == 0 ? e++ : o++; }
    
    // out(e << " " << o);
    
    e += o / 2;
    o -= o / 2 * 2;
    
    if (o) { out("NO"); return 0; }
    
    out("YES");
}


Measured memory_bytes: 256
if !ENV['RUBY_THREAD_VM_STACK_SIZE']
    require 'rubygems'
    RUBY=Gem.ruby
    exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},RUBY,$0)
end

N, M = gets.split.map(&:to_i)
G = Hash.new { |h, k| h[k] = Hash.new(false) }
A = Hash.new { |h, k| h[k] = Hash.new(false) }
ANS = Hash.new { |h, k| h[k] = Hash.new(false) }

M.times do
  a, b = gets.split.map(&:to_i)

  G[a][b] = true
  G[b][a] = true
end

if M.odd?
  puts -1
  exit
end

def dfs(v, visited = Hash.new(false))
  visited[v] = true

  G[v].each_key do |u|
    next if visited[u]

    A[v][u] = true
    dfs(u, visited)
  end
end

dfs(1)

def dfs2(v, parent = -1, visited = Hash.new(false), fixed = Hash.new(false))
  A[v].each_key do |u|
    dfs2(u, v, visited, fixed)
  end

  cnt = 0

  G[v].each_key do |u|
    if ANS[v][u]
      cnt += 1
    end
    next if fixed[u]

    cnt += 1
    ANS[v][u] = true
  end

  if cnt.odd? && parent != -1
    ANS[parent][v] = true
    ANS[v][parent] = false
  end

  fixed[v] = true
end

dfs2(1)

1.upto(N) do |v|
  ANS[v].each do |u, connected|
    next if !connected

    puts "#{v} #{u}"
  end
end


Measured memory_bytes: 390204
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;
 
typedef long long LL;
typedef pair < int, int > pa;
 
inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while( ch < '0' || ch > '9' ) { if( ch == '-' ) f = -1; ch = getchar(); }
	while( ch >= '0' && ch <= '9' ) sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}
 
const int MAXN = 200020;
 
int q[MAXN], p[MAXN], n, T[MAXN], f[MAXN];
 
int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	n = read();
	for( int i = 1 ; i <= n ; i++ ) q[ p[ i ] = read() ] = i;
	for( int i = n - 1 ; i ; i-- )
	{
		if( !T[ i + 1 ] )
		{
			if( q[ i ] > q[ i + 1 ] ) T[ i ] = 1, f[ i ] = i + 1;
			else T[ i ] = 0;
		}
		else
		{
			int cnt = 0;
			cnt += q[ f[ i + 1 ] ] < q[ i ];
			cnt += q[ i ] < q[ i + 1 ];
			cnt += q[ i + 1 ] < q[ f[ i + 1 ] ];
			if( cnt == 2 ) T[ i ] = T[ i + 1 ], f[ i ] = f[ i + 1 ];
			else T[ i ] = T[ i + 1 ] + 1, f[ i ] = i + 1;
		}
	}
	return printf( "%d\n", T[ 1 ] ), 0;
}


Measured memory_bytes: 6756
from collections import Counter
n,m = map(int,input().split())
many  =[]
for i in range(n):
    a = list(map(int,input().split()))
    for j in range(1,a[0]+1):
        many.append(a[j])

ans = Counter(many).most_common()
count = 0
for i in range(len(ans)):
    if ans[i][1] == n:
        count += 1

print(count)

Measured memory_bytes: 38512
#include<stdio.h>
int main()
{
	int X,day;
	scanf("%d",&X);
	day=X%7;
	if(day==0)
	puts("thu");
	else if(day==1)
	puts("fri");
	else if(day==2)
	puts("sat");
	else if(day==3)
	puts("sun");
	else if(day==4)
	puts("mon");
	else if(day==5)
	puts("tue");
	else if(day==6)
	puts("wed");
	return 0;
}


Measured memory_bytes: 2112
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a!=b&&b!=c&&c!=a)||(a==b&&b==c)) puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 128
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };
    let T: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let N = S.len();
    let M = T.len();
    let i = if N >= M {
        (0..(N - M + 1)).rev().find(|&j| {
            (0..M).all(|k| S[j + k] == T[k] || S[j + k] == '?')
        })
    } else {
        None
    };
    let ans = if let Some(j) = i {
        (0..N).map(|k| {
            if j <= k && k < j + M {
                T[k - j]
            } else if S[k] == '?' {
                'a'
            } else {
                S[k]
            }
        }).collect::<String>()
    } else {
        "UNRESTORABLE".to_string()
    };

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;

int main(){
    //std::stack<int> stack;
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    long long ans = 0;
    ans = (h2-h1)*60 + (m2-m1) - k;
    cout << ans << endl;
     return 0;
}





Measured memory_bytes: 3636
fun main(array: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val arr = Array(n+1){0}
    repeat(m) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt() }
        arr[a] += 1
        arr[b] += 1
    }
    for(i in 1..n) {
        println(arr[i])
    }
}

Measured memory_bytes: 37564
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		if(X >= 10000){
			System.out.println(1);
		}else{
			boolean can[] = new boolean[X + 1];
			can[0] = true;
			for(int rep = 0 ; rep < 100 ; ++rep){
				for(int i = 0 ; i < can.length ; ++i){
					if(can[i]){
						for(int j = 0 ; j <= 5 ; ++j){
							if(i + j + 100 < can.length){
								can[i + j + 100] = true;							
							}
						}
					}
				}				
			}
			if(can[X]){
				System.out.println(1);
			}else{
				System.out.println(0);				
			}
				
		}
	}
}


Measured memory_bytes: 23636
N,Q=map(int,input().split())
if N>1:
    def find_par(x):
        u=x%N-1
        if u<=0:
            u+=N
        return (x-u-1)//N+1
    def path(x):
        s_node=x
        d=[s_node]
        while s_node!=1:
            s_node=find_par(s_node)
            d.append(s_node)
        return d
    for _ in range(Q):
        v,w=map(int,input().split())
        data1=set(path(v))
        data2=set(path(w))
        print(max(data1 & data2))
else:
    for _ in range(Q):
        v,w=map(int,input().split())
        print(min(v,w))

Measured memory_bytes: 57176
#include <stdio.h>

int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b && b!=c) printf("Yes\n");
	else if(a!=b && b==c) printf("Yes\n");
	else if(a!=b && c==a) printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 1640
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[25];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int sum=1;
	for(int i=1;i<n;i++){
		int f=1;
		for(int j=0;j<i;j++){
			if(a[j]>a[i]){
				f=0;
				break;
			}
		}
		if(f==1) sum++;
	}
	cout<<sum<<endl;
}

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

typedef long long ll;

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    ll t, a;
    if (A > K) {
        t = A - K;
        a = B;
    } else if (A + B > K) {
        t = 0;
        a = A + B - K;
    } else {
        t = 0;
        a = 0;
    }
    cout << t << " " << a << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

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

	private static void print() throws IOException {
		int allSecond = 0;
		int hour = 0;
		int minute = 0;
		int second = 0;

		int tempHH = 1;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		allSecond = Integer.valueOf(str);

		hour = allSecond / 3600;
		tempHH =allSecond % 3600;
		minute = tempHH / 60;
		second = tempHH % 60;




		System.out.println(hour + ":" + minute + ":" + second);

	}


}

Measured memory_bytes: 24372
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(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()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";

int main(){
    int N,X,ans=0,range=0;cin >> N >> X;
    vint L(N); REP(i,N) cin >> L.at(i);

    if(X > 0){
        ans++;
    }

    REP(i,N){
        range += L.at(i);
        if(range <= X){
            ans++;
        }else{
            break;
        }


    }
    cout << ans << endl;

}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
L = [list(map(int, input().split())) for _ in range(Q)]

tmp = [0 for _ in range(N)]

for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        tmp[i+1] = tmp[i] + 1
    else:
        tmp[i+1] = tmp[i]
        
for l in L:
    print(tmp[l[1]-1] - tmp[l[0]-1])

Measured memory_bytes: 30716
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <decimal/decimal>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    ll n; cin>>n;
    if(n%2==0) cout<<n/2-1<<endl;
    else cout<<(n-1)/2<<endl;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    char arr[h][w];

    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> arr[i][j];
        }
    }

    long dp[h][w];
    memset(dp, 0, sizeof(dp));

    if (arr[0][1] != '#') dp[0][1] = 1;

    if (arr[1][0] != '#') dp[1][0] = 1;


    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (i-1 >= 0 && (arr[i-1][j] != '#')) dp[i][j] = (dp[i][j] + dp[i-1][j]) % mod;
            if (j-1 >= 0 && (arr[i][j-1] != '#')) dp[i][j] = (dp[i][j] + dp[i][j-1]) % mod;
        }
    }

    cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 9088
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll N, ans{}, d{}, e{}, f{};
  cin >> N;
  vector<ll> A(N), B(N), C(N), D(N);
  for (auto &a : A) cin >> a;
  for (auto &b : B) cin >> b;
  for (auto &c : C) cin >> c;
  sort(begin(A), end(A));
  sort(begin(B), end(B));
  sort(begin(C), end(C));
  for (int i = 0; i != N; ++i) {
    while (d != N && A[d] < B[i]) ++d;
    D[i] = d;
  }
  for (int i = 0; i != N; ++i) {
    while (e != N && B[e] < C[i]) {
      ++e;
      f += D[e-1];
    }
    ans += f;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6424