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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int N; cin >> N;
    int odd=0;
    rep(i, N){
        ll a; cin >> a;
        if(a%2) odd++;
    }
    if(odd > 0) cout << "first" << endl;
    else cout << "second" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <array>
#include <iomanip>
#include <unordered_set>
#define ll long long
#define ar array
#define AC ios_base::sync_with_stdio(0);
using namespace std;
const int K = 1e5;
int nums[105];
int dp[K+5];
int n, k;

int MEX(unordered_set<int>& S){
    int m = 0;
    while(S.find(m)!=S.end())
        m++;
    return m;
} 

void grundy(int k){
    unordered_set<int> S;
    for(int i=0; i<n; i++){
        if(k-nums[i]>=0)
            S.insert(dp[k-nums[i]]);
    }
    dp[k] = MEX(S);
}

int main(){
    AC
    cin>>n>>k;
    int min_num = 1e6;
    for(int i=0; i<n; i++){
        cin>>nums[i];
        min_num = min(min_num, nums[i]);
    }

    dp[0] = 0;
    for(int i=min_num; i<=k; i++){
        grundy(i);
    }

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

Measured memory_bytes: 3536
n = int(input())
S = list(input())
left = []
right = []
l = 0
r = 0
wa = []
for i in range(n):
  if i == 0:
    l += 0
    r += 0
    left.append(l)
    right.append(r)
  else:
    if S[i-1] == "W":
      l += 1
    left.append(l)
    if S[n-i] == "E":
      r += 1
    right.append(r)
for j in range(n):
  wa.append(left[j] + right[n-1-j])
print(min(wa))


Measured memory_bytes: 37616
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define MAX 1e9+10
using namespace std;

bool check(int n,string *signal){
  for(int i=1;i<n;i++){
    if(signal[i-1]=="x" && signal[i]=="x")return false;
    if(signal[i-1]=="x" || signal[i]=="x")continue;
    int prev=atoi(signal[i-1].c_str());
    int pre=atoi(signal[i].c_str());
    if(i%2){
      if(prev>pre)
	return false;
    }else{
      if(prev<pre)
	return false;
    }
  }
  return true;
}

void renge(int n,string *signal){
  int mx=MAX,mm=-(MAX);
  if(signal[0]=="x")
    mx=atoi(signal[1].c_str());
  if(signal[n-1]=="x"){
    if(n%2) mx=atoi(signal[n-2].c_str());
    else mm=atoi(signal[n-2].c_str());
  }
  for(int i=1;i<n-1;i++){
    if(signal[i]!="x")continue;
    int prev=atoi(signal[i-1].c_str());
    int next=atoi(signal[i+1].c_str());
    if(i%2)
      mm=max(mm,max(prev,next));
    else
      mx=min(mx,min(prev,next));
  }
  //cout << "mx:" << mx << " mm:" << mm << endl;
  int border=mx-mm;
  //cout << "border:" << border << endl;
  if(border>2){
    cout << "ambiguous" << endl;
  }else if(border==2){
    cout << mx-1 << endl;
  }else{
    cout << "none" << endl;
  }
}

int main(){
  int n;
  while(cin>>n,n){
    string signal[1001];
    for(int i=0;i<n;i++)cin>>signal[i];
    if(!check(n,signal)){
      cout << "none" << endl;
      continue;
    }
    renge(n,signal);
  }
  return 0;
}

Measured memory_bytes: 1324
H, W, D = [int(_) for _ in input().split()]
l1 = [0] * H
for i in range(0, H):
    l1[i] = [int(_) for _ in input().split()]
Q = int(input())
l2 = [0] * Q
for i in range(0, Q):
    l2[i] = [int(_) for _ in input().split()]


HWdict = {}
for j in range(0, H):
    for k in range(0,W):
        HWdict[l1[j][k]] = [j, k]


mylist = []
for i in range(0,D):
    mylist.append({})

for i in range(0, D):
    j = 1
    mylist[i][i+1] = 0
    while ((i+1) + j*D) <= H*W:
        mylist[i][(i+1) + j*D] = mylist[i][(i+1)+ (j-1)*D] + abs(HWdict[(i+1) + j*D][0]- HWdict[(i+1) + (j-1)* D][0]) + abs(HWdict[(i+1) + j*D][1] - HWdict[(i+1) + (j-1)* D][1])
        j += 1

L = 0
R = 0
ans = 0
for i in range(0, Q):
    L = l2[i][0]
    R = l2[i][1]
    print(mylist[R%D-1][R] - mylist[R%D-1][L])
    


Measured memory_bytes: 71112
/* ex 5_4
series2 */
#include <stdio.h>
#include <string.h>

int main(void){
    char str[11];
    char count=0;
    char max=0;
    scanf("%s",str);
    for(int i=0;i<strlen(str);i++){
        if(str[i]=='A'||str[i]=='C'||str[i]=='G'||str[i]=='T'){
            count++;
        }else{
            if(count>max){
                max=count;
            }
            count=0;
        }
    }
    if(count>max){
        max=count;
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

int gcd(int a, int b) {
	return (a % b == 0 ? b : gcd(b, a % b));
}

signed main() {
  INIT;

	VAR(int, n, x);
	vector< int > d(n);
	REP(i, n) {
		VAR(int, a);
		d[i] = abs(a - x);
	}

	int g = d.back();
	REP(i, n - 1) {
		g = gcd(g, d[i]);
	}

	cout << g << endl;

	
  
  return 0;
}


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

typedef long long ll;
typedef vector < int > vi;
typedef pair <int , int > pi;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fr(i,a,b) for(int i=a;i<b;i++)




int isprime(ll n)
{
    int flag=0;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            flag=1;;
            break;
        }
    }
    return flag;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    ll sum=0;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=0;i<k;i++)
    {
        sum+=arr[i];
    }
    cout<<sum;
  
  
    return 0;
}


Measured memory_bytes: 3704
#include<iostream>
using namespace std;
int main ()
{
	long long n,a,b,c,d;
	cin>>n>>a>>b;
	c=n/(a+b);
	d=n-(c*(a+b));
	if(d<=a)
		cout<<c*a+d;
	else
		cout<<(c+1)*a;
	return 0;
} 

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

using ll = long long int;
const int mx = 1e5 + 10;
ll n, x, ar[mx], ans, sm, dif;

int main() {
    #ifdef LU_SERIOUS
        freopen( "in.txt", "r", stdin );
    #endif // LU_SERIOUS
    while( cin >> n >> x ) {
        for( int i=1; i<=n; i++ ) cin >> ar[i];
        ar[0] = 0;
        ar[n+1] = 0;
        ans = 0;
        for( int i=2; i<=n; i++ ) {
            sm = ar[i] + ar[i-1];
            if( sm > x ) {
                dif = sm - x;
                ans += dif;
                if( dif <= ar[i] ) ar[i] -= dif;
                else ar[i] = 0;
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
main()
{
	int H,W,a,b,c,d;
	char i[101][101];
	d=1;
	scanf("%d %d",&H,&W);
	getchar();
       for(a=1;a<=H;a++)
	{	
	       scanf("%s",&i[a]);
	       
	       
	}
	for(b=1;b<=H+2;b++)
	{
		for(c=1;c<=W+2;c++)
		{
			if(b==1||b==H+2)
		{
				printf("#");
		}
	        else
	        {
	        	if(c==1||c==W+2)
	        	{
	        		printf("#");
	        	}
	        else if(c==2)
	        {
	        		printf("%s",i[d]);
	        		d++;
	        }
	        }
		}
	        printf("\n");
	        
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
#include<utility>
using namespace std;
int a,b,c;
int main(){
  scanf("%d%d%d",&a,&b,&c);
  if(a>b){
    swap(a,b);
  }
  printf("%s",(a<c && c<b)?"Yes":"No" );
  
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
  using namespace std;
  #define ll  long long int
  #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);




  int main()
  {


  
 
   
    fastio; 
   ll  n,m,targets;
   cin>>n>>m>>targets;
   map<ll,ll> mp_row,mp_col;
   map<pair<ll,ll>,ll> mp_exist;
   while(targets--)
   {
    ll h,w;
    cin>>h>>w;
    mp_row[h]++;
    mp_col[w]++;
    mp_exist[{h,w}]=1;


   }
   ll maxi_row=INT_MIN,maxi_col=INT_MIN;
   ll row_no,col_no;

   for(auto it:mp_row)
   {

     if(it.second>maxi_row)
     {
      maxi_row=it.second;
      row_no=it.first;
     }
   }

   for(auto it:mp_col)
   {

     if(it.second>maxi_col)
     {
      maxi_col=it.second;
      col_no=it.first;
     }


   }

   if(maxi_row>maxi_col)
   {


   
    ll ans=INT_MIN;
    for(ll i=1;i<=m;i++)
    {
      if(mp_exist[{row_no,i}]==1)
      {
        ans=max(ans,maxi_row+mp_col[i]-1);
      }
      else
        ans=max(ans,maxi_row+mp_col[i]);
    }

    cout<<ans;

   }
   else
   {
    
    ll ans=INT_MIN;
    for(ll i=1;i<=n;i++)
    {
      
        if(mp_exist[{i,col_no}]==1)
      {
        ans=max(ans,mp_row[i]+maxi_col-1);
      }
      else
        ans=max(ans,mp_row[i]+maxi_col);
    }

    cout<<ans;
 
   }
   
  

  return 0;   
  }


Measured memory_bytes: 78636
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF+7;
const LL LLINF = 1e18;

int main(void) {
    string s; cin >> s;
    int n = 0, m=0;
    FORE(c, s) {
        if (c == 'C') n++;
        if (n &&( c == 'F')) m++;
    }
    if (n && m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N; cin >> N;
  int h[100001];
  for(int i=0; i<N; i++) cin >> h[i+1];
  
  int dp[100001];
  dp[N] = 0;
  dp[N-1] = max(h[N] - h[N-1], h[N-1] - h[N]);
  
  for(int i=N-2; i>0; i--) dp[i] = min(dp[i+1] + max(h[i] - h[i+1], h[i+1] - h[i]), dp[i+2] + max(h[i] - h[i+2], h[i+2] - h[i]));
  
  cout << dp[1] << endl;
  
}

Measured memory_bytes: 1024
# encoding:utf-8
import copy
import numpy as np
import random
import queue

n = int(input())

withdraws = [1]
price = 1
while True:
    price *= 6
    if price <= 10**5 and price <= n:
        withdraws.append(price)
    else:
        break

price = 1
while True:
    price *= 9
    if price <= 10**5 and price <= n:
        withdraws.append(price)
    else:
        break


withdraws.sort()
# print(withdraws)
money = 0
count = 0


# 幅優先探索
'''
que = queue.Queue()

que.put((0,0))
memory = []
while not(que.empty()):
    money,count = que.get()
    print(money,count)
    if money > n:
        pass
    else:
        for withdraw in withdraws:
            if money+withdraw == n:
                print(count+1)
                exit()

            elif money+withdraw in memory:
                pass
            else:
                memory.append(money+withdraw)
                next = (money+withdraw,count+1)
                que.put(next)
'''
'''
# 分割

ans = 10**10
if n < 6:
    ans = n
for i in range(n+1):
    t = i
    count = 0
    while t>0:
        count += t%6
        t = t//6
    t = n - i
    while t>0:
        count += t%9
        t = t//9
    # print(ans)
    ans =min(ans,count)

print(ans)

'''

max_num = 10**5
dp = [99999999]*(n+1)
dp[0] = 0
for i in range(1,n+1):
    # print(dp)
    dp[i] = dp[i-1]+1
    k = 6
    while i>=k:
        dp[i] = min(dp[i],dp[i-k]+1)
        k *= 6
    k = 9
    while i>=k:
        dp[i] = min(dp[i],dp[i-k]+1)
        k *= 9



print(dp[n])


Measured memory_bytes: 14452
import kotlin.math.abs
import kotlin.math.min

fun main() {
  val n = readLine()!!.toInt()
  val h = readLine()!!.split(' ').map { it.toInt() }
  val dp = IntArray(n+1){1000000001}
  dp[0] = 0
  dp[1] = abs(h[0]-h[1])

  for(i in 2 until n){
    dp[i] = min(dp[i], min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2]+ abs(h[i]-h[i-2])))
  }
  println(dp[n-1])
}

Measured memory_bytes: 50008
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int out = 0;
    if (s.equals("SUN")) {
      out = 7;
    } else if (s.equals("MON")) {
      out = 6;
    } else if (s.equals("TUE")) {
      out = 5;
    } else if (s.equals("WED")) {
      out = 4;
    } else if (s.equals("THU")) {
      out = 3;
    } else if (s.equals("FRI")) {
      out = 2;
    } else if (s.equals("SAT")) {
      out = 1;
    }
    System.out.println(out);
  }
}

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

int main(void) {
	int N, A, B, C;
	int l[16];
	int i;
	int search, max;
	int yosinagasayuri = 999999999;
	if (scanf("%d%d%d%d", &N, &A, &B, &C) != 4) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &l[i]) != 1) return 1;
	}
	max = (1 << (2 * N));
	for (search = 0; search < max; search++) {
		int nagasa[4] = {0};
		int cost[4] = {-10, -10, -10, -10};
		int yakusimaruhiroko;
		for (i = 0; i < N; i++) {
			int idx = (search >> (2 * i)) & 3;
			nagasa[idx] += l[i];
			cost[idx] += 10;
		}
		if (cost[0] < 0 || cost[1] < 0 || cost[2] < 0) continue;
		cost[0] += abs(A - nagasa[0]);
		cost[1] += abs(B - nagasa[1]);
		cost[2] += abs(C - nagasa[2]);
		yakusimaruhiroko = cost[0] + cost[1] + cost[2];
		if (yakusimaruhiroko < yosinagasayuri) yosinagasayuri = yakusimaruhiroko;
	}
	printf("%d\n", yosinagasayuri);
	return 0;
}


Measured memory_bytes: 128
N = list(map(int, input().split()))
S = input()
result = 0
maxnum = len(set(S))
for i in range(len(S)):
    X = set(S[:i])
    Y = set(S[i:])
    Z = X & Y
    if result < len(Z):
        result = len(Z)
    if result == maxnum:
        break

print(result)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
//#define int long long
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

signed main()
{
	ios::sync_with_stdio(false);
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(n/x+(n%x!=0))*t<<endl;	
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
#define INF MOD
typedef long long ll;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
//#define int long long 


/* UnionFind部分 */
int UF[114514];

void UFinit(int n){
    for(int i=0;i<=n;i++){
        UF[i]=i;
    }
}

int UFroot(int k){
    if(UF[k]==k){
        return k;
    }else{
        UF[k]=UFroot(UF[k]);
        return UF[k];
    }
}

int UFsame(int P,int Q){
    if(UFroot(P)==UFroot(Q)){
        return true;
    }else{
        return false;
    }
}

void UFunite(int P,int Q){
    int p=UFroot(P);
    int q=UFroot(Q);
    if(p==q)return;
    if(p>q)swap(p,q);
    UF[q]=p;
}

/*UnionFind部分 おわり*/

/*Kruskal部分*/

struct edge{
    int from;
    int to;
    ll cost;
};

bool comp_kruskal(edge F,edge G){
    return F.cost<G.cost;
}

edge es[214514];
int V,E;

int kruskal(void){
    sort(es,es+E,comp_kruskal);
    UFinit(V);
    int res=0;
    for(int i=0;i<E;i++){
        edge e = es[i];
        if(!UFsame(e.from,e.to)){
            UFunite(e.from,e.to);
            res += e.cost;
        }
    }
    return res;
}

/*kruskal部分　おわり*/

/*Build?部分*/
struct machi{
  int x,y,num;  
};

bool compx(machi F,machi G){
    if(F.x!=G.x){
        return F.x<G.x;
    }else{
        return F.y<G.y;
    }
}
bool compy(machi F,machi G){
    if(F.y!=G.y){
        return F.y<G.y;
    }else{
        return F.x<G.x;
    }
}

machi city[114514];

/*Build?部分　おわり*/


signed main(){
    int N,x,y;
    cin >> N;
    V=N;
    E = 2*(N-1);
    REP(i,N){
        cin >> x >> y;
        city[i].x = x;
        city[i].y = y;
        city[i].num = i;
    }
    sort(city,city+N,compx);
    REP(i,N-1){
        es[i]={city[i].num,city[i+1].num,min(abs(city[i].x-city[i+1].x),abs(city[i].y-city[i+1].y))};
    }
    sort(city,city+N,compy);
    REP(i,N-1){
        es[i+N-1]={city[i].num,city[i+1].num,min(abs(city[i].x-city[i+1].x),abs(city[i].y-city[i+1].y))};
    }
    int Ans= kruskal();
    
    cout << Ans << endl;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{   
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    cout << a[0]*10+a[1]+a[2] << endl;

    return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int sLen = s.length();
    int minDif = Integer.MAX_VALUE;
    
    for (int i=0;i<=sLen-3;i++) {
      int num = new Integer(s.substring(i,i+3));
      int dif = Math.abs(753 - num);
      minDif = minDif>dif?dif:minDif;
    }
    System.out.println(minDif);
  }
}

Measured memory_bytes: 20692
def main():
    n = int(input())
    pairs = []
    for i in range(n):
        s, p0 = input().split()
        pairs.append((i + 1, s, int(p0)))
    pairs.sort(key=lambda q: (q[1], -q[2]))
    for i, _, _ in pairs:
        print(i)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long n, k, dp[200000], a[200000];
int main()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i ++) cin >> a[i];
	for (int i = 1; i <= k; i ++)
	{
		for (int j = 1; j <= n; j ++)
		{
			if (i - a[j] >= 0 && dp[i-a[j]] == 0) {
				dp[i] = 1;
				break;
			}
		}
	}
	if (dp[k] == 1)
		cout << "First";
			else
		cout << "Second";	
}

Measured memory_bytes: 1152
def solve(x, y):
    a = max(x, y)
    b = min(x, y)
    if b == 0:
        return 0
    res = 2*a
    r = solve(b-a % b, a % b)
    if r == 0:
        res -= b
    res += r
    return res


s = raw_input().split()
n = int(s[0])
x = int(s[1])

ans = n + solve(x, n-x)
print(ans)


Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

// const int dx[4] = { 1, 0, -1, 0 };
// const int dy[4] = { 0, 1, 0, -1 };

const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  string s,t;cin>>s>>t;
  int ans = INF;
  rep(i,s.size()-t.size()+1){
    int tmp = 0;
    rep(j,t.size()){
      if(s[i+j] != t[j])tmp++;
    }
    chmin(ans,tmp);
  }
  print(ans);
  return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, temp;
	cin >> n;
	vector<int> v2(n + 1, 0);
	for (int i = 0; i < n - 1; i++)
	{
		cin >> temp;
		v2[temp]++;
	}
	for (int i = 1; i < n + 1; i++)
	{
		cout << v2[i] << "\n";
	}
}

Measured memory_bytes: 3984
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    std::ifstream in(string(argv[0]) + ".txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n;
    cin >> n;

    map<string, int> poll;

    rep(i, n) {
        string s;
        cin >> s;
        poll[s]++;
    }

    int m = 0;
    for (auto i = poll.begin(); i != poll.end(); i++) {
        m = max(m, i->second);
    }
    for (auto i = poll.begin(); i != poll.end(); i++) {
        if (m == i->second) cout << i->first << endl;
    }

    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll  long long
#define INF (ll)1e18 + 50
#define MAXN (int)1e5 + 50
#define fi first
#define se second
#define MOD 1000000007
#define all(v)((v).begin()), ((v).end())
#define A 911382323
#define B 972663749


int main() {
    int n; string a, b;
    cin >> n >> a >> b;
    
    for(int i = 0; i < n; i++)
    	cout << a[i] << b[i];
    return 0;
}

Measured memory_bytes: 256
import bisect
N = int(input())
A= list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
  a = bisect.bisect_left(A,b)
  c = bisect.bisect_right(C,b)
  ans += a * (len(C)-c)
print(ans)

Measured memory_bytes: 29504
import sys
from collections import deque
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

deq=deque(["1", "2", "3", "4", "5", "6", "7", "8", "9"])

K=II()
for i in range(K-1):
    v = deq.popleft()
    last = int(v[-1])
    if last == 0:
        deq.append(v + "0")
        deq.append(v + "1")
    elif last == 9:
        deq.append(v + "8")
        deq.append(v + "9")
    else:
        deq.append("{}{}".format(v, last-1))
        deq.append("{}{}".format(v, last))
        deq.append("{}{}".format(v, last+1))

print(deq.popleft())


Measured memory_bytes: 17004
//https://atcoder.jp/contests/dp/tasks/dp_r
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

typedef LL D;
#define REP4(i,n) for(int i=0;i<n;i+=4)

constexpr int S = 64;
struct M{
    D v[S][S];
    D& operator()(int i,int j){
        return v[i][j];
    }
}mat[64];
constexpr int mod = 1e9+7;
void mat_mul(M &a,M& b,M &c){
    for(int i:range(S))for(int j:range(S))c(i,j)=0;
    D sum[4],tmp;
    for(int k:range(S)){
        REP4(i,S){
            sum[0]=a(i,k);
            sum[1]=a(i+1,k);
            sum[2]=a(i+2,k);
            sum[3]=a(i+3,k);
            for(int j:range(S)){
                tmp=b(k,j);
                c(i,j)+=sum[0]*tmp%mod;
                c(i+1,j)+=sum[1]*tmp%mod;
                c(i+2,j)+=sum[2]*tmp%mod;
                c(i+3,j)+=sum[3]*tmp%mod;
            }
        }
    }
    for(int i:range(S)){
        for(int j:range(S))c(i,j)%=mod;
    }
}

int main(){
    int N;
    cin>>N;
    LL K;
    cin>>K;
    for(int i:range(N)){
        for(int j:range(N)){
            cin>>mat[0](i,j);
        }
    }
    for(int i:range(62))mat_mul(mat[i],mat[i],mat[i+1]);
    vector<LL> dp(N,1);
    for(int i:range(62)){
        if(K&1){
            vector<LL> nxt(N,0);
            for(int a:range(N))for(int b:range(N)){
                nxt[b]+=dp[a]*mat[i](a,b)%mod;
            }
            for(int a:range(N))nxt[a]%=mod;
            swap(dp,nxt);
        }
        K>>=1;
    }
    LL ret=0;
    for(int i:range(N))ret+=dp[i];
    cout<<ret%mod<<endl;
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,c0=0,c1=0,c2=0,c3=0;
	string s;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(s=="AC")  c0++;
		else if(s=="WA")  c1++;
		else if(s=="TLE")  c2++;
		else c3++;
	}
	cout<<"AC x "<<c0<<endl
	    <<"WA x "<<c1<<endl
	    <<"TLE x "<<c2<<endl
	    <<"RE x "<<c3<<endl;
	return 0;
}

Measured memory_bytes: 3616
import math
N=int(input())
def g(N):#桁数を返す
  i=0#桁数
  while N>=1:
    N=N/10
    i+=1
  return i

def f(N):
  j=g(N)
  S=0
  while j!=0:
    d=math.floor(N/(10**(j-1)))
    S+=d
    N-=d*(10**(j-1))
    j-=1
  return S
  
if N%f(N)==0:
  print("Yes")
else: print("No")

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

int main(){
    int N, K, cnt;

    cin >> N >> K;
    
    int h[N];

    cnt = 0;
    for(int i = 0; i < N; ++i) {
    	cin >> h[i];
      	if(h[i]>=K) cnt++;
    }

    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <map>
#include <unordered_map>
#include <ctime>
#include <cassert>
#include <cstring>
#include <sys/time.h>
#include <stdlib.h>
using namespace std;

int main(int argc, char *argv[]){
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s==u){
    a--;
  }
  if(t==u){
    b--;
  }
  cout << a << " " << b;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N;
        N=sc.nextInt();
        int [] X = new int [N];
        ArrayList<Integer>list = new ArrayList<>();
        for(int a=0;a<N;a++){
            X[a]=sc.nextInt();
            list.add(X[a]);
        }
        Collections.sort(list);
        for(int a=0;a<N;a++){
            if(list.get((N+1)/2)>X[a]) System.out.println(list.get((N+1)/2));
            else System.out.println(list.get((N-1)/2));
        }
   }
}

Measured memory_bytes: 96964
#include <iostream>
#include <cmath>

using namespace std;
typedef long long ll;

int main(void){
long double a,b,c;
cin >> a >> b >> c;

 long double eps = 1.0E-14;

 if(sqrt(a) + sqrt(b) + eps < sqrt(c)){
 cout << "Yes" << endl;
 } else {
 cout << "No" << endl;
 }

 return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N,M;
    cin>>N>>M;
    vector<tuple<int, int, int>> City;
    deque<string> ans(M,"");
    REP(i,M){
        int a,b;
        cin>>a>>b;
        City.emplace_back(a,b,i);
    }
    sort(City.begin(),City.end());
    int cn=0;
    int cnt=1;
    for(auto i : City){
        if(cn==get<0>(i)){
            cnt++;
        } else {
            cnt=1;
            cn = get<0>(i);
        }
        ostringstream sout;
        ostringstream soud;
        sout<<setfill('0')<<setw(6)<<cn;
        sout<<setfill('0')<<setw(6)<<cnt;
        ans[get<2>(i)] = sout.str()+soud.str();
    }
    std::for_each(ans.begin(), ans.end(), [](const std::string& x) {
        std::cout << x << std::endl;
    });
}

Measured memory_bytes: 8180
import java.util.*;
class Main {
  public static void main(String args[]){
  //input
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    //output
        System.out.println(gcd(a,b));
  }
  //判定
  static int gcd(int x, int y){
    int tmp;

    if(x<y){
      tmp = x;
      x = y;
      y = tmp;
    }
    while(y>0){
      tmp = x%y;
      x = y;
      y = tmp;
    }
    return x;
  }
}


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

//Compiler version g++ 6.3.0

int main()
{
    int n ;
    cin >>n;
    int arr[n];
    vector <int> v;
    for(int i = 0 ; i< n ; i++)
    {
       cin >> arr[i];
       v.push_back(arr[i]);
    }
    sort(v.begin(),v.end());
    for(int i = 0 ; i< n ; i++)
    {
       if(arr[i]==v[n-1])
       {
         cout << v[n-2]<< "\n";
       }
       else
       {
         cout << v[n-1] << "\n";
       }
    }
}

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007

ll ans = 0;

ll h, w;
string s[50];

int movex[4] = {1, 0, -1, 0};
int movey[4] = {0, 1, 0, -1};

int main(){
   cin >> h >> w;
   string wall = "";
   rep(i, w+2)wall += '#';
   s[0] = s[h+1] = wall;

   vector<pair<ll, ll>> p;
   rep(i, h){
       cin >> s[i+1];
       s[i+1] += '#';
       s[i+1].insert(s[i+1].begin(), '#');
   }

   rep(i, h+2)rep(j,w+2)if(s[i][j] == '.'){
       p.push_back(make_pair(i, j));
   }

   ll ans = 0;
   bool used[50][50] = {};
   ll dist[50][50];
   rep(i, p.size()){
       ll sx =p[i].first, sy= p[i].second;
       for(ll j = i+1; j < p.size(); ++j){
           ll gx = p[j].first, gy = p[j].second;
            rep(k, 50)rep(l, 50)dist[k][l] = 1000000000, used[k][l] = false;
           queue<pair<ll, ll>> que;
           que.push(make_pair(sx, sy));
           dist[sx][sy] = 0;
           used[sx][sy] = true;

           while(!que.empty()){
               pair<ll, ll> pos = que.front();
               que.pop();
               if(pos.first==gx && pos.second==gy)break;
               rep(move, 4){
                   int dx = pos.first+movey[move];
                   int dy = pos.second+movex[move];
                   if(s[dx][dy] == '.' && !used[dx][dy]){
                       used[dx][dy] = true;
                       que.push(make_pair(dx, dy));
                       dist[dx][dy] = dist[pos.first][pos.second]+1;
                   }
               }
           }
        //    cout << sx <<  ", " << sy << " to" << gx << ", " << gy << "=" << dist[gx][gy] << endl;
           ans = max(ans, dist[gx][gy]);
       } 
   }

   cout << ans << endl;
   
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE



// OO#**
//OO###**

//##
//##

//####
//OOOO

//#OOOOX
//###XXX

//#XXX
//###X

Int calc(Int x){return (x / 2) * 2;}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int I, O, J, L;
  {
    Int x;
    cin>>I>>O>>x>>J>>L>>x>>x;
  }


  Int a = 0;
  if(I && J && L) a = 3 + calc(I - 1) + calc(J - 1) + calc(L - 1) + O;
  Int b = calc(I) + calc(J) + calc(L) + O;
  Int ans = max(a, b);
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, m;
string str;

int main(){
	cin >> str;
	ll c = 0;
	for(ll i = 0; i < str.size(); i++){
		if(str[i] == 'x'){c++;}
	}
	if(c >= 8){cout << "NO" << endl;}
	else{cout << "YES" << endl;}
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn divisors(n: usize) -> Vec<usize> {
    let mut m = 1;
    let mut divs = vec![];
    while m * m <= n {
        if n % m == 0 {
            divs.push(m);
            if n != m * m {
                divs.push(n / m);
            }
        }
        m += 1;
    }
    divs.sort();
    divs
}

fn main() {
    input! {
        n: usize, m: usize,
    }
    let mut divs = divisors(m);
    divs.reverse();
    for div in divs {
        if div * n <= m {
            return println!("{}", div);
        }
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	int N; cin >> N;
	vector<int> A(N), B(N); rep(i, 0, N) { cin >> A[i] >> B[i]; }
	int add = 0;
	rrep(i, 0, N) {
		if ((A[i] + add) % B[i]) {
			add += B[i] - (A[i] + add) % B[i];
		}
	}
	cout << add << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <bitset>
#include <stack>
#include <queue>
#include <map>
#include <functional>
using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpii;

vector<int> L;
int N;

bool isOK(){
    int ma = L[0];
    int sum = 0;
    for(int i = 1; i < N; i++){
        sum += L[i];
    }
    //printf("%d\n", ma);
    return ma < sum;
}

int main(void){
    cin >> N;
    for(int i = 0; i < N; i++){
        int t;
        cin >> t;
        L.push_back(t);
    }
    sort(L.begin(), L.end(), greater<int>());
    if(isOK()){
        printf("Yes\n");
    } else{
        printf("No\n");
    }

    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++)
#define Rrep(i,n) for(int i=((int)n-1); i>=0; i--)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e15
#define MOD 1000000007

typedef vector<int> vint;
typedef long long ll;



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

        int n;
        cin >> n;

        int cnt=0;

        rep(i,n){
                int d1,d2;
                cin>>d1>>d2;
                if(d1==d2){cnt++;}
                else{cnt=0;}
                if(cnt==3){cout<<"Yes"<<endl;return 0;}   
                
        }
        cout<<"No"<<endl;


        return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N)cin >> A[i];
    int a = 1;
    for(int i=0;i<N;i++){
        if(a == A[i]){
            a++;
            }
    }
    if(a > 1)cout <<N-a+1;
    else cout << -1;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll s = max(A, C);
    ll e = min(B, D);
    cout << max(0LL, e - s) << endl;
    return 0;
}


Measured memory_bytes: 3644