akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;
bool sr(ll a, ll b)
{
	return a > b;
}
bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(ll n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
template <class T>
void print(const T &value)
{
	std::cout << value << std::endl;
}

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n), b(n), dis(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	ll x = 0, y = 0; //x->a,y->b
	rep(i, n)
	{
		dis[i] = b[i] - a[i];
		if (dis[i] % 2 != 0)
		{
			if (dis[i] > 0)
			{
				dis[i]++;
				y++;
			}
			
		}
	//	cout << "d " << dis[i] << endl;
		if (dis[i] < 0)
		{
			y += -dis[i];
		}
		else
		{
			x += dis[i] / 2;
		}
	}
//	cout << x << " " << y << endl;
	if (x-y>=0 )
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define all(x) (x).begin(),(x).end()
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;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b; cin >> a >> b;
	if (a <= 8 && b <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math

ABHM = list(map(int, input().split()))
A = ABHM[0]; B = ABHM[1]; H = ABHM[2]; M = ABHM[3]

X = (A*math.cos(math.pi*M/30)-B*math.cos((math.pi/6)*(H+M/60)))**2
Y = (A*math.sin(math.pi*M/30)-B*math.sin((math.pi/6)*(H+M/60)))**2

print(math.sqrt(X+Y))


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

int main(void)
{
  char n;
  cin >> n;
  switch(n)
  {
    case 'a':
    case 'i':
    case 'u':
    case 'e':
    case 'o':
      cout << "vowel" << endl;
      break;
    default:
      cout << "consonant" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define vll vector<ll> 
#define vvl vector<vll>
#define pii pair<ll,ll>
#define F first
#define S second
#define endl "\n"
#define M 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}

ll po(ll x, ll y){
    if(y==0)
    return 1;
    if(y%2){
        return ((x)*(po(x,y/2)%M)*(po(x,y/2)%M))%M;
    }
   return ((po(x,y/2)%M)*(po(x,y/2)%M))%M;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
    //cin>>t;
    while(t--){
        ll n;
        cin>>n;
        string s;
        cin>>s;
        ll r=0;
        fo(i,n){
            if(s[i]=='R')
            r++;
        }
        string str="";
        fo(i,n){
            if(r>0)
            str+="R";
            else
            str+="W";
            r--;
        }
        ll c=0;
        fo(i,n){
            if(str[i]!=s[i])
            c++;
        }
        cout<<c/2<<endl;
    }
return 0;
}

Measured memory_bytes: 3844
import java.lang.Math

fun main(args: Array<String>)
{
    val n = readLine()!!.toInt()
    val l = readLine()!!.split(" ").map{ it.toInt() }.toIntArray().sortedArrayDescending()

    var cnt = 0
    for (i in 0 until n-2) {
        for (k in i+1 until n-1) {
            var ok = -1
            var ng = n
            while (Math.abs(ok - ng) > 1) {
                var mid = (ok + ng) / 2
                if (l[mid] > l[i] - l[k]) ok = mid
                else ng = mid
            }

            cnt += if (ok > k) ok - k else 0
        }
    }

    println(cnt)
}


Measured memory_bytes: 39572
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF=1e18;
#define PI 3.14159265358979323846
const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int pickUpNumbersFromStr(string S, int first, int second) {
    string strResult = S.substr(first-1, second - first + 1);
    return atoi(strResult.c_str());
}

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

    int K, S, L;
    cin >> K >> S >> L;
    for (int i=S; i<=L; i++) {
        if (i % K == 0) {
            cout << "OK" << '\n';
            return 0;
        }
    } 

    cout << "NG" << '\n';

    return 0;
}

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

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

function main(){
  var n = next();
  var m = next();
  var ans = m*1800 + n*100;
  return ans << m;
}

Measured memory_bytes: 29552
#include <iostream>
#include <vector>
#include <string>

#define reep(i,n,m) for(int i=(n);i<(m);i++)
#define rep(i,n) reep(i,0,n)

using namespace std;

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

void no(){
	cout << "No" << endl;
}

int main(){
	int N,A,B;
	cin >> N >> A >> B;
	string str;
	cin >> str;
	rep(i,str.size()){
		if(str[i]=='a'){
			if(A+B>0){
				yes();
				A--;
			}else{
				no();
			}
		}else if(str[i]=='b'){
			if(A+B>0 && B>0){
				yes();
				B--;
			}else{
				no();
			}
		}else{
			no();
		}
	}
}

Measured memory_bytes: 896
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
const int yuzu=1e5,mod=1e9+7;
typedef ll fuko[yuzu|10];
ll n,ans;
fuko a,c,wh,wq;
char str[yuzu|10];
 
ll kasumi(ll a,ll b){
if (b<0) return 0;
ll s=1;
for (;b;b>>=1,a=a*a%mod) if (b&1) s=s*a%mod;
return s;
}
 
int main(){
int i,j;
scanf("%s",str+1);
n=strlen(str+1);
for (i=1;i<=n;i++){
  a[i]=a[i-1]+(str[i]=='A');
  wq[i]=wq[i-1]+(str[i]=='?');
  }
for (i=n;i;i--){
  c[i]=c[i+1]+(str[i]=='C');
  wh[i]=wh[i+1]+(str[i]=='?');
  }
for (i=1;i<=n;i++){
  if (str[i]=='B'||str[i]=='?'){
    ans=(ans+(a[i-1]*kasumi(3,wq[i-1])%mod+kasumi(3,wq[i-1]-1)*wq[i-1]%mod)%mod*(c[i+1]*kasumi(3,wh[i+1])%mod+kasumi(3,wh[i+1]-1)*wh[i+1]%mod)%mod)%mod;
    }
  }
write(ans);
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#if ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) std::sort(all(x))
#define REV(x) std::reverse(all(x))
#define UNIQUE(x) x.erase(std::unique(all(x)), x.end());
#define MAX(x) *std::max_element(all(x))
#define MIN(x) *std::min_element(all(x))
#define LOWitr(x, n) std::lower_bound(all(x), n)
#define UPRitr(x, n) std::upper_bound(all(x), n)
#define cii(x) int x; std::cin >> x
#define cill(x) signed long long int x; std::cin >> x
#define cis(x) std::string x; std::cin >> x
#define co(x) std::cout << x << "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) if(DEBUG) std::cout<<#x<<" : "<<(x)<<"\n"
template<class T>using V = std::vector<T>;
template<class T>using VV = std::vector<std::vector<T>>;
template<class T>using Q = std::queue<T>;
template<class T>using PQ = std::priority_queue<T>;
template<class T,class U>using P = std::pair<T, U>;
template<class T,class U>using M = std::map<T, U>;
template<class T,class U>using UM = std::unordered_map<T, U>;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T>inline void vcin(T &v){for(auto&& i : v) std::cin >> i;}
template<class T>inline void dumpv(const T& v, std::ostream& os = std::cout){
    if(DEBUG){
        os<<"{";
        std::for_each(all(v),[&os](typename T::value_type p){os<<p<<',';});
        os<<"}\n";
    }
}
using std::cin;
using std::cout;
using std::string;
using std::next_permutation;
using LL = signed long long int;
const int INF = INT_MAX, MOD = 1e9 + 7;
const LL LLINF = LLONG_MAX;
const double PI = M_PI;

void Main(){
    cill(n);
    cill(m);
    V<V<int>> vv(n);
    V<int> di(n, -1);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        vv[a-1].pb(b-1);
        vv[b-1].pb(a-1);
    }
    Q<int> q;
    q.push(0);
    di[0]=0;
    while(!q.empty()){
        int room = q.front();
        q.pop();
        for(auto&& nr : vv[room]){
            if (di[nr]!= -1) continue;
            di[nr] = room;
            q.push(nr);
        }
    }

    if (std::find(all(di), -1) != di.end()){
        co("No");
    }else{
        co("Yes");
        rep(i, n-1){
            co(di[i+1]+1);
        }
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 10156
/*
 
 Author: @ygyash

*/

#include <bits/stdc++.h>
#define ll long long
#define ld long double

using namespace std;

ll minll(ll a, ll b)
{
    return a < b ? a : b;
}
ll maxll(ll a, ll b)
{
    return a > b ? a : b;
}

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll x, k, d;
    cin >> x >> k >> d;

    x = abs(x);
    ll y = x / d;
    ll val = x - y * d;
    ll ans = 0;
    if (y < k)
    {
        if ((k-y) & 1)
        {
            ans = abs(val - d);
        }
        else
        {
            ans = val;
        }
        cout<<ans<<endl;
    }
    else
    {
        cout << (x - k * d) << endl;
    }
}

Measured memory_bytes: 3632
function saiki(str,flag){
   while(true){
      if(/\[{2}\d.*?\]{2}/.test(str)){
         str=str.replace(/\[{2}\d.*?\]{2}/,function(s){
               var d =s.slice(2,-2).split("][").map(Number);
               d.sort((a,b)=> a-b);
               var sum=0;
               for(var i=0;i<Math.ceil(d.length/2);i++){
                  if(flag) sum+=Math.floor(d[i]/2)+1;
                  else sum+=Math.floor(d[i]);
               }
               return "("+sum+")";
            });
      }else break;
   }
   str=str.replace(/\(/g,"[");
   str=str.replace(/\)/g,"]");
   return str;
 }
  
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var n=arr.shift()-0;

arr.forEach(str=>{
   str=saiki(str,true);
   while(/\[\[/.test(str))str=saiki(str,false);
    console.log(str.replace(/\[|\]/g,""));
});


Measured memory_bytes: 19836
from functools import reduce, partial
n = int(input())
s = input()

def f(n, c):
  a = ord('A')
  x = a + (ord(c) - a + n) % 26
  return chr(x)

f = partial(f, n)

s = reduce(lambda x,y: x + y, map(f, s))
print(s)

Measured memory_bytes: 3572
a, b = map(int, input().split())
homes = input().split()
homes_number = [int(s) for s in homes]
long = []
for i in range(b-1):
    x = homes_number[i+1] - homes_number[i]
    long.append(x)
y = a - homes_number[b-1] + homes_number[0]
long.append(y)
print(a-max(long))

Measured memory_bytes: 27972
//
//  0121.cpp
//  
//
//  Created by Yoshida Satoshi on 2017/11/16.
//
//

#include <iostream>
#include <queue>
#include <stdlib.h>
#include <algorithm>
#include <map>

#define INF 100000


using namespace std;

int main(){
    int num[8];
    queue<vector<int> > que;
    vector<int> state;
    state.push_back(1);
    for(int i=0;i<8;i++) state.push_back(i);//?????????????´????0??????????????????????????????
    vector<int> tmp;
    vector<int> input;
    map<vector<int>, int> depth;
    int start;
    
    que.push(state);
    depth[state]=0;
    
    while(que.size()){
        tmp=que.front(); que.pop();

        if(tmp[0]>4){
            vector<int> next(tmp);
            next[0]=tmp[0]-4;
            swap(next[tmp[0]],next[tmp[0]-4]);
            if(depth.count(next)==0){
                depth[next]=depth[tmp]+1;
                que.push(next);
            }
        }
        if(tmp[0]<5){
            vector<int> next(tmp);
            next[0]=tmp[0]+4;
            swap(next[tmp[0]],next[tmp[0]+4]);
            if(depth.count(next)==0){
                depth[next]=depth[tmp]+1;
                que.push(next);
            }
        }
        if(tmp[0]!=4&&tmp[0]!=8){
            vector<int> next(tmp);
            next[0]=tmp[0]+1;
            swap(next[tmp[0]],next[tmp[0]+1]);
            if(depth.count(next)==0){
                depth[next]=depth[tmp]+1;
                que.push(next);
            }
        }
        if(tmp[0]!=1&&tmp[0]!=5){
            vector<int> next(tmp);
            next[0]=tmp[0]-1;
            swap(next[tmp[0]],next[tmp[0]-1]);
            if(depth.count(next)==0){
                depth[next]=depth[tmp]+1;
                que.push(next);
            }
        }
    }
    
    while(1){
        if(!(cin>>num[0]>>num[1]>>num[2]>>num[3]>>num[4]>>num[5]>>num[6]>>num[7])) break;
        vector<int> empty;
        swap(empty,input);
        for(int i=0;i<8;i++){
            if(num[i]==0) start=i;
        }
        input.push_back(start+1);
        for(int i=0;i<8;i++) input.push_back(num[i]);
        cout<<depth[input]<<endl;
    }
     
    
    
    return 0;
}

Measured memory_bytes: 5256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;

int main() {
  double l;
  cin >> l;

  cout << fixed;
  cout << setprecision(8) << pow(l/3, 3.0) << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0
for n in range(N):
  ans += B[A[n]-1]
  #print('{}: {}'.format(n,B[A[n]-1]))
  if n+1 < N and A[n]+1 == A[n+1]:
    ans += C[A[n]-1]
    #print('C {}: {}'.format(n,C[A[n]-1]))
print(ans)


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

using namespace std;

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

signed main () {
  cin.tie(0);
  cout << setprecision(10);
  int n;cin >> n;
  int t, a; cin >> t >> a;
  vector<int> h(n);
  REP(i, n) cin >> h[i];
  vector<pair<int, int>> b(n);
  REP(i, n) {
    b[i].first = abs(1000 * t - 1000 * a - 6 * h[i]);
    b[i].second = i;
  }
  sort(b.begin(), b.end());
  cout << b[0].second + 1 << endl;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    N = int(input())
    B = list(map(int, input().split()))
    
    S = 0
    
    for i in range(N):
        if i == 0:
            S += B[i]
        elif i == N-1:
            S += B[i-1]
        else:
            S += min(B[i], B[i-1])
        
    print(S)

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

#define INF 1e18
using namespace std;

long int a[405],dp[405][405],pre[405];
int main()
{
	int n;	
	scanf("%d",&n);
	pre[0] = 0;
	for(int i=0;i<n;++i)	
	{
		scanf("%ld",a+i);
		pre[i+1] = pre[i] + a[i];
	}
	for(int i=n-1;i>=0;--i)
	{
		for(int j=i;j<n;++j)
		{
			if(i == j)
			dp[i][j] = 0;
			else if(i == j+1)
			dp[i][j] = a[i] + a[j];
			else
			{
				dp[i][j] = INF;
				for(int m=i;m<j;++m)
				dp[i][j] = min(dp[i][j],dp[i][m]+dp[m+1][j] + pre[j+1]-pre[i]);
			}
		}
	}
	printf("%ld\n",dp[0][n-1]);
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
int main(){
    int n;cin>>n;
    int tmp,cnt=0;
    fo(i,n){
        cin >>tmp;
        if(tmp%2!=0){
            ++cnt;
        }
    }
    (cnt%2==0)?(cout<<"YES"):cout << "NO";
}


Measured memory_bytes: 3584
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	P := make([]int, N)
	Q := make([]int, N)
	var a, b int
	for i := range P {
		P[i] = nextInt()
	}
	for i := range Q {
		Q[i] = nextInt()
	}
	Pc := make([]int, N)
	copy(Pc, P)
	sort.Ints(Pc)
	for i := 0; NextPermutation(sort.IntSlice(Pc)); i++ {
		if reflect.DeepEqual(P, Pc) {
			a = i + 1
		}
		if reflect.DeepEqual(Q, Pc) {
			b = i + 1
		}
		if a != 0 && b != 0 {
			break
		}
	}
	fmt.Println(abs(a, b))
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func abs(a int, b int) int {
	if a > b {
		return a - b
	} else {
		return b - a
	}
}


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

int returnVal (char x)
{
    return (int) x - 97;
}

int main() {
    string S, T;
    cin >> S >> T;
    vector<vector<int>> repetitions(28, vector<int>(28));
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    for (int i = 0; i<repetitions.size();i++)
    {
        for (int j = 0;j<repetitions.size();j++)
        {
            repetitions[i][j] = 0;
        }
    }
    for (int i = 0; i < S.size(); i++)
    {
        repetitions[returnVal(T[i])][returnVal(S[i])]++;
    }

    int counter;
    for (int i = 0; i<repetitions.size();i++)
    {
        counter = 0;

        for (int j = 0;j<repetitions.size();j++)
        {
            if (repetitions[i][j] > 0)
            {
                counter++;
            }
            if (counter > 1)
            {
                cout << "No";
                return 0;
            }
        }
    }

    for (int i = 0; i<repetitions.size();i++)
    {
        counter = 0;

        for (int j = 0;j<repetitions.size();j++)
        {
            if (repetitions[j][i] > 0)
            {
                counter++;
            }
            if (counter > 1)
            {
                cout << "No";
                return 0;
            }
        }
    }

    cout << "Yes";

    return 0;
}

Measured memory_bytes: 776
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */

#include <iostream>
#include <fstream>

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<(n);++i)
typedef long long int ll;

class BTapDance {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s;
        in >> s;
        rep(i,s.size()){
            if(i%2==0){
                if(s[i]=='L'){
                    out << "No" << endl;
                    return ;
                }
            }else{
                if(s[i]=='R'){
                    out << "No" <<endl;
                    return ;
                }
            }
        }
        out << "Yes" << endl;
	}
};


int main() {
	BTapDance solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = 1000
for i in range(N):
    a = A[i]
    ans_i = 0
    while a % 2 == 0:
        a = a // 2
        ans_i += 1

    ans = min(ans, ans_i)

print(ans)

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


template <typename T>
void cout_vector(vector<T> A){
    for (T a : A) cout << a +1 << " ";
    cout << endl;
}





bool in(vector<int> A, int key){
    for (int a : A){
        if (a == key) return true;
    }
    return false;
}


int main(){
    int N,M;
    cin >> N >> M;
    if (M < N - 1){
        cout << 0 << endl;
        return 0;
    }
    vector<vector<int>> Graph(N);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        Graph[a].push_back(b);
        Graph[b].push_back(a);
    }
    vector<int> A(N - 1);
    rep(i,N - 1) A[i] = i + 1;
    int ans = 0;
    /*cout << "----------" << endl;
    for(int idx = 0; idx < N; idx++){
        cout_vector(Graph[idx]);
    }
    cout << "----------" << endl;*/
    do {
        bool flag = true;
        int start = A[0];
        if (!(in(Graph[0],start))) {      
            flag = false;
            continue;
        }
        for (int j = 1; j < N - 1; j++)  {
            int goal = A[j];        
            //cout << start << endl;    
            if (!(in(Graph[start],goal))){ 
                //cout << (start + 1) << " to " << (goal + 1) << " is not exits." << endl;
                flag = false;
                continue;
            } else {
                //cout << (start + 1) << " to " << (goal + 1) << " is exits." << endl;
            }
            start = goal;
        }
        //cout << "---" << endl;
        (flag) && (ans++);
    } while(next_permutation(A.begin(),A.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        int [][] a = new int[h][w];
        int [][] b = new int[h][w];
        for(int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                a[i][j] = scanner.nextInt();
            }
        }
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                b[i][j] = scanner.nextInt();
            }
        }
        boolean[][][] dp = new boolean[2][w][13000];
        dp[0][0][Math.abs(a[0][0] - b[0][0])] = true;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if (i == 0 && j == 0) {
                    continue;
                }
                int diff = Math.abs(a[i][j] - b[i][j]);
                for (int k = 0; k <= 12800; ++k) {
                    dp[i%2][j][k] = false;
                }
                for (int k = 0; k <= 12800; ++k) {
                    if (i > 0 && dp[(i + 1) % 2][j][k]) {
                        dp[i % 2][j][Math.abs(k + diff)] = true;
                        dp[i % 2][j][Math.abs(k - diff)] = true;
                    }
                    if (j > 0 && dp[i % 2][j - 1][k]) {
                        dp[i % 2][j][Math.abs(k + diff)] = true;
                        dp[i % 2][j][Math.abs(k - diff)] = true;
                    }
                }
            }
        }
        for (int k = 0; k <= 12800; ++k) {
            if (dp[(h - 1) % 2][w - 1][k]) {
                System.out.println(k);
                return;
            }
        }
    }
}


Measured memory_bytes: 39164
class DisjointSet:
    def __init__(self, size):
        self.parent = list(range(size))
        self.rank = [0]*size
    
    def find(self, x):
        stack = []
        parent = self.parent
        while parent[x] != x:
            stack.append(x)
            x = parent[x]
        for y in stack:
            parent[y] = x
        return x

    def union(self, x, y):
        xr, yr = self.find(x), self.find(y)
        
        if self.rank[xr] > self.rank[yr]:
            self.parent[yr] = xr
        elif self.rank[xr] < self.rank[yr]:
            self.parent[xr] = yr
        elif xr != yr:
            self.parent[yr] = xr
            self.rank[xr] += 1

from itertools import chain

N = int(input())
points = tuple(tuple(map(int,input().split())) for _ in range(N))
ds = DisjointSet(N)

x_i = sorted((x,i) for i,(x,y) in enumerate(points))
y_i = sorted((y,i) for i,(x,y) in enumerate(points))

xr = [x_i[0]]
yr = [y_i[0]]

for (x0,i0),(x1,i1) in zip(x_i,x_i[1:]):
    if x0 == x1:
        ds.union(i0,i1)
    else:
        xr.append((x1,i1))

for (y0,i0),(y1,i1) in zip(y_i,y_i[1:]):
    if y0 == y1:
        ds.union(i0,i1)
    else:
        yr.append((y1,i1))

deltas = sorted(
        chain(
            ((x1-x0,i0,i1) for (x0,i0), (x1,i1) in zip(xr,xr[1:])),
            ((y1-y0,i0,i1) for (y0,i0), (y1,i1) in zip(yr,yr[1:])),
        )
    )


def it():
    for d,i0,i1 in deltas:
        i0,i1 = ds.find(i0), ds.find(i1)
        if i0 != i1:
            ds.union(i0,i1)
            yield d
print(sum(it()))

Measured memory_bytes: 86156
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  ll n = X / 200;

  cout << 10 - n << "\n";
  
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 10000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,a,b;
vector<pair<int,int>>v;
vector<int>V;
int ans=1;
signed main(){
	cin>>n;
	rep(i,n){
		cin>>a;
		v.pb({a,1});
	}
	rep(i,n){
		cin>>b;
		v.pb({b,2});
	}
	sort(all(v));
	rep(i,2*n){
		if(V.empty()){
			V.pb(v[i].se);
		}
		else{
			if(V[0]==v[i].se){
				V.pb(v[i].se);
			}
			else{
				ans*=V.size();
				ans%=MOD;
				V.pop_back();
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if lc == 1
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

kk = inputs[0][1]
ss = inputs[1][0]

# body
if $debugFlag
  p kk
  p ss
end

if ss[0..0] == "0"
  state_is_zero = true
else
  state_is_zero = false
end

origlen = ss.length
# if ss[-1..-1] == "0"
#   ss += "1"
# else
#   ss += "0"
# end

queue = []
candidate = []
cur_cnt = 0
cand_val = 0
queue_cnt = 0
lastFlag = false ## ...
ss.length.times do |i|
  pd ss[i..i] 
  if state_is_zero == true
    if ss[i..i] == "0"
      cur_cnt += 1  
    else
      print "cur:" if $debugFlag
      pd cur_cnt
      queue << queue_cnt + cur_cnt
      queue_cnt = 0
      if kk > 1
        kk -= 1
      else
        lastFlag = true
      end
      cand_val += cur_cnt
      cur_cnt = 1
      state_is_zero = false
    end
  else
    if ss[i..i] == "0"
      print "cur:" if $debugFlag
      pd cur_cnt
      if lastFlag == true
        pd "cand update:#{cand_val + cur_cnt}"
        pd cand_val
        pd cur_cnt
        candidate << cand_val + cur_cnt        
        cand_val -= queue.shift
        lastFlag = false
      end
      cand_val += cur_cnt
      queue_cnt += cur_cnt      
      cur_cnt = 1
      state_is_zero = true      
    else
      cur_cnt += 1
    end    
  end
end

candidate << cand_val + cur_cnt

pd candidate
pd queue

if candidate.size == 0
  pd "all"
  puts origlen
else
  puts candidate.max
end


Measured memory_bytes: 2428
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;



int main(){
    INIT;
    int n, k; cin >> n >> k;
    if(k == 1) cout << 0; 
    else cout << n-k;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

const int U=0;
const int D=1;
const int R=2;
const int L=3;

int main()
{
	lint H,W,N;
	lint sr,sc;
	string S,T;
	
	cin >> H >> W >> N;
	cin >> sr >> sc;
	cin >> S >> T;

	//lint Ssum[200010][4]={};
	//lint Tsum[200010][4]={};
	lint Ssum[4]={};
	lint Tsum[4]={};
	bool ok=false;
	/*
	for(int i=0;i<S.size();i++)
	{
		if(S[i]=='U')Ssum[U]++;
		if(S[i]=='D')Ssum[D]++;
		if(S[i]=='R')Ssum[R]++;
		if(S[i]=='L')Ssum[L]++;

		if(sr-Ssum[U]+Tsum[D]<1 /*&& sr+Tsum[D]<=H)ok=true;
		if(sr+Ssum[D]-Tsum[U]>H /*&& sr-Tsum[U]>=1)ok=true;
		if(sc+Ssum[R]-Tsum[L]>W /*&& sc-Tsum[L]>=1)ok=true;
		if(sc-Ssum[L]+Tsum[R]<1 /*&& sc+Tsum[R]<=W)ok=true;

		if(ok)
			break;

		if(T[i]=='U')Tsum[U]++;
		if(T[i]=='D')Tsum[D]++;
		if(T[i]=='R')Tsum[R]++;
		if(T[i]=='L')Tsum[L]++;
	}
	*/
	int cr,cc;
	//U
	cr=sr;
	for(int i=0;i<S.size() && !ok;i++)
	{
		if(S[i]=='U')cr--;
		if(cr<1)ok=true;
		if(T[i]=='D')cr++;
		if(cr>H)cr=H;
	}
	//D
	cr=sr;
	for(int i=0;i<S.size() && !ok;i++)
	{
		if(S[i]=='D')cr++;
		if(cr>H)ok=true;
		if(T[i]=='U')cr--;
		if(cr<1)cr=1;
	}
	//L
	cc=sc;
	for(int i=0;i<S.size() && !ok;i++)
	{
		if(S[i]=='L')cc--;
		if(cc<1)ok=true;
		if(T[i]=='R')cc++;
		if(cc>W)cc=W;
	}
	//R
	cc=sc;
	for(int i=0;i<S.size() && !ok;i++)
	{
		if(S[i]=='R')cc++;
		if(cc>W)ok=true;
		if(T[i]=='L')cc--;
		if(cc<1)cc=1;
	}

	if(ok)
		cout << "NO";
	else 
		cout << "YES";
	cout << endl;
	return 0;
}



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

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


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

long long num[200005];

void debugout ( long long value ){
    cout << value  << endl;
}


int main(){

    string num;
    cin >> num;

    int last = num.size()-1;

    if( num[last] == '3' ){
        cout << "bon" << endl;
    } else if ( num[last] == '0' || num[last] == '1' || num[last] == '6' || num[last] == '8'){
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
    return 0;
}





Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

bool allN(const vector<int>& A, int N){
  rep(i,N){
    if(A[i]!=N) return false;
  }
  return true;
}

int main(){
  int N, K; cin >> N >> K;
  vector<int> A(N); rep(i,N) cin >> A[i];
  rep(i,K){
    if(allN(A,N)) break;
    vector<ll> imos(N+1,0);
    rep(j,N){
      imos[max(0, j-A[j])]++;
      imos[min(N, j+A[j]+1)]--;
    }
    vector<int> sums(N+1,0);
    rep(j,N) sums[j+1] = sums[j] + imos[j];
    rep(j,N) A[j]=sums[j+1];
  }
  rep(i,N){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 6432
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <chrono>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll n;
ll a[100000];
ll b[100000];
ll cnt;
ll ans;

int main()
{
	cin>>n;
	rep(i,n){
		cin>>a[i]>>b[i];
	}
	rrep(i,n){
		if((a[i]+cnt)%b[i]==0) continue;
		cnt+=b[i]-(a[i]+cnt)%b[i];
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

bool check(char a, char b) {
  return (a == '0' || (a == '1' && (b - '0' < 3))) && !(a == '0' && b == '0');
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  // cout << s[0]  << " " <<  s[1] << endl;
  // debug(char(s[0]));
  bool n1 = check(s[0], s[1]);
  bool n2 = check(s[2], s[3]);
  debug(n1, n2);
  if (n1 && n2) {
    cout << "AMBIGUOUS" << endl;
  } else if (n1) {
    cout << "MMYY" << endl;
  } else if (n2) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;


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

    a = a-c;
    cout<<a/(b+c)<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    p = LIR(n)
    p = [[p[i][0]-p[i][1],p[i][0]+p[i][1]] for i in range(n)]
    p.sort(key = lambda x:x[1])
    t = p[0][1]
    ans = 1
    for l, r in p[1:]:
        if t <= l:
            ans += 1
            t = r
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 71516
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    string s; cin >> s;
    int k; cin >> k;

    int len = s.length();
    int i = 0;
    while(i != len) {
        int x = ('z' - s[i] + 1) % 26;
        if(k < x) i++;
        else {
            k -= x;
            s[i] = 'a';
            i++;
        }
    }
    s[i-1] = (char)(((int)s[i-1] + k - 97) % 26 + 97);
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 640
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
#include <ctime>
using namespace std;
#define int long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


// -----------------------------------------------------------------------


// -----------------------------------------------------------------------

int fre[26];
void solve(){
	int n;
	cin>>n;
	string s;
	for(int i=0;i<n;++i)
	{cin>>s;
	fre[s[0]-'A']++;}
	int arr[5];
	arr[0]=fre['M'-'A'];
	arr[1]=fre['A'-'A'];
	arr[2]=fre['R'-'A'];
	arr[3]=fre['C'-'A'];
	arr[4]=fre['H'-'A'];
	int sum=0;
	for(int i=0;i<5;++i){
		for(int j=i+1;j<5;++j){
		int kp=1;
		for(int k=0;k<5;++k)
		if(k==i || k==j)
		continue;
		else
		kp*=arr[k];
		sum+=kp;
	}
	}
	cout<<sum;
}


// -----------------------------------------------------------------------


int32_t main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 	
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

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

    if (N == 1) {
        cout << "Hello World" << endl;
    } else if (N == 2) {
        int A, B;
        cin >> A >> B;
        cout << A+B << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int X, A;
	cin >> X >> A;

	if (X < A)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 10 << endl;
	}

	return 0;
}



Measured memory_bytes: 256
// 解けてない
#include <bits/stdc++.h>
using namespace std;

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

  int sum = (2 * L + N - 1) * N / 2;

  if (L >= 0) {
    sum -= L;
  }
  else if (L + N - 1 <= 0) {
    sum -= L + N - 1;
  }

  cout << sum << endl;
}


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

int main() {
    string s; cin >> s;
    if (s == "SUN") cout << 7 << endl;
    if (s == "MON") cout << 6 << endl;
    if (s == "TUE") cout << 5 << endl;
    if (s == "WED") cout << 4 << endl;
    if (s == "THU") cout << 3 << endl;
    if (s == "FRI") cout << 2 << endl;
    if (s == "SAT") cout << 1 << endl;
}


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

int main(void){
    int n, k, q; cin >> n >> k >> q;
    vector<ll>cnt(n,0);
    for(int i=0;i<q;i++){
        int a; cin >> a; a--;
        cnt[a]++;
    }
    for(int i=0;i<n;i++){
        if(0<k-(q-cnt[i])) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
int N,M;
cin>>N>>M;
int a[M],b[M];
int i;
for(i=0;i<M;i++){
cin>>a[i]>>b[i];
}
int backet[N+1]={0};
  for(i=0;i<M;i++){
  backet[a[i]]++;
  backet[b[i]]++;
  }
  for(i=0;i<N;i++){
  cout<<backet[i+1]<<endl;}
}


Measured memory_bytes: 256