akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
using namespace std;
int test[213456];
signed main() {
	int n, a, ans = 0; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> a; test[a] = test[a - 1] + 1;
	}
	for (int h = 0; h <= n; h++) {
		ans = max(ans, test[h]);
	}
	cout << n - ans << endl;
}

Measured memory_bytes: 1920
#include<cstdio>
#include<algorithm>
using namespace std;
int D[1 << 15];
int n, E[15], Mod = 1000000007, C[1 << 15], res = 1;
int main() {
	int i, j, m, a, b;
	scanf("%d%d", &n,&m);
	for (i = 0; i < m; i++) {
		scanf("%d%d", &a, &b);
		a--, b--;
		E[a] |= (1 << b);
		res = res * 2 % Mod;
	}
	for (i = 0; i < n; i++)for (j = 0; j < (1 << n); j++)if ((j >> i) & 1)C[j]++;
	D[0] = 1;
	for (i = 0; i < (1 << n); i++) {
		int bb = (1 << n) - 1 - i;
		if (!D[i])continue;
		for (int mask = bb; mask; mask = (mask - 1)&bb) {
			int rem = (1 << n) - 1 - i - mask;
			if ((mask & 3) && (mask & 3) != 3)continue;
			int r = D[i];
			for (j = 0; j < n; j++) {
				if (!((i | mask)&(1 << j))) {
					r = (long long)r * ((1 << C[E[j] & mask]) - 1) % Mod;
					continue;
				}
				if ((mask >> j) & 1) {
					r = ((long long)r << C[rem & E[j]]) % Mod;
				}
			}
			D[i | mask] = (D[i | mask] + r) % Mod;
		}
	}
	printf("%d\n", (res + Mod - D[(1 << n) - 1]) % Mod);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//--<for debugging>
#define whatis(x) cout << #x << " is " << x<<" ";
#define whatisl(x) cout << #x << " is " << x<<"\n";
#define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
#define lline cout<<"\n";
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
    
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a <<" , ";
    err(++it, args...);
}
//--</for debugging> 
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define testcase ll tt; cin >> tt; while(tt--)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
#define vll vector<ll>
#define pll pair<ll,ll>
#define sll set<ll>
#define pint pair<int,int>
const ll INF=1e9+7;
const ll MOD=1e9+7;
int main()
{
    boost vars
    long double dvar;
    cin>>dvar;
    cout<< fixed << setprecision(12)<<2*acos(-1)*dvar;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL INF=1e9;
int main(){
    LL N,M;
    cin>>N>>M;
    if(N>M)swap(N,M);
    if(N==1&&M==1){
        cout<<1<<endl;
    }else if(N>=3){
        cout<<(N-2LL)*(M-2LL)<<endl;
    }else if(N==2){
        cout<<0<<endl;
    }else if(N==1){
        cout<<max(M-2LL,0LL)<<endl;
    }
    return 0;
}


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

#define POS(i,j) (((i)&1)*n+(j))

const int mod=1000000007;

void run(void){
  int n;
  scanf("%d",&n);
  char *s=(char *)calloc(n,sizeof(char));
  scanf("%s",s);
  int *dp=(int *)calloc(2*n,sizeof(int));
  int i,j;
  for(i=0;i<n;i++) dp[POS(0,i)]=1;
  for(i=1;i<n;i++){
    for(j=0;j<n;j++) dp[POS(i,j)]=0;
    if(s[i-1]=='<'){
      for(j=0;j<n-i;j++){
	dp[POS(i,j)]+=dp[POS(i-1,j)];
	dp[POS(i,j)]%=mod;
      }
    } else {
      for(j=1;j<n+1-i;j++){
	dp[POS(i,0)]+=dp[POS(i-1,j)];
	dp[POS(i,0)]%=mod;
	dp[POS(i,j)]+=mod-dp[POS(i-1,j)];
	dp[POS(i,j)]%=mod;
      }
    }
    for(j=1;j<n-i;j++){
      dp[POS(i,j)]+=dp[POS(i,j-1)];
      dp[POS(i,j)]%=mod;
    }
  }
  printf("%d\n",dp[POS(n-1,0)]);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define F first
#define S second
#define pi acos(-1)
using ll = long long;
using namespace std;
using namespace __gnu_pbds;
using vl = vector<ll>;
using pll =  pair<ll,ll>;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


ll power(ll x,ll y){
    ll res = 1;
    while(y){
        if(y&1)
            res = (res*x)%md;
        x = (x*x)%md;
        y = y/2;
    }
    return res;
}

void solve(){
    int l,r,d;
    cin>>l>>r>>d;
    cout<<(r/d) - ((l-1)/d);
}
 
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  //  int n; cin>>n; for (int i = 0; i < n; ++i)
    solve();
    return 0;
}


Measured memory_bytes: 3644
S = input().strip()
D = {}

for s in S:
    if s in D.keys():
        D[s] += 1
    else:
        D[s] = 1

if len(D) != 2:
    print("No")
else:
    for k, v in D.items():
        if v != 2:
            print("No")
            break
    else:
        print("Yes")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t r,l;
  cin >> l>>r;
  int64_t ans=2020;
  if(r-l>2020){
    cout << 0;
    return 0;
  }
  int64_t i,j=l;
  for(int64_t i=l;i<r;i++){
    for( j=i+1;j<=r;j++){
      int64_t mini=(i*j)%2019;
      ans=min(ans,mini);
      
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eps 1e-8
#define all(v) (v.begin(),v.end())
#define db double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const double pi=acos(-1.0);
const double inf = 1e100;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
int main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0),cout.tie(0);
  	int n;
  	cin>>n;
  	int cnt=(n%1000?n/1000+1:n/1000);
  	cout<<cnt*1000-n<<endl;
    return 0;
}



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

#define INF 100000000


int main() {
    long long n; cin >> n;
    long long ans = 1e18L;
    for(long long i = 1; i*i <= n; i++) {
        if(n % i == 0) {
            long long v = n / i;
            ans = min(ans, v + i - 2);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;

vector<int>p;
void init() {
  for(int i=2; i<maxn; i++) {
    bool sign=0;
    for(int j=2; j<i; j++)
      if(i%j==0) {
        sign=1;
        break;
      }
    if(!sign)p.push_back(i);
  }
}

int main() {
 // freopen("in.cpp","r",stdin);
  int n;
  cin>>n;
  init();
  unordered_map<int,int>umap;
  for(int i=2; i<=n; i++) {
    int tt = i;
    for(int j=0; j<p.size(); j++) {
      int cnt=0;
      while(tt%p[j]==0) {
        tt/=p[j];
        cnt++;
      }
      if(umap.find(p[j])==umap.end()) {
        umap[p[j]]=cnt;
      } else umap[p[j]]+=cnt;
    }
  }
  ll ret=1;
  for(auto kv:umap){
    ret=ret*(kv.second+1)%mod;
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 384
N, A, B, C= map(int, input().split())
L = [int(input()) for _ in range(N)]

K = 4

minmp = 1e8
for x in range(pow(4, N)):
    v = x
    c = [0] * K
    s = [0] * K
    i = 0
    while v > 0:
        m = v % K
        c[m] += 1
        s[m] += L[i]
        i += 1
        v //= K

    if c[1] > 0 and c[2] > 0 and c[3] > 0:
        minmp = min(minmp, (c[1] + c[2] + c[3] - 3) * 10 + abs(s[1] - A) + abs(s[2] - B) + abs(s[3] - C))

print(minmp)


Measured memory_bytes: 3064
a=:+
puts [6484,a,0,1,3,:<,2,3,3]+[0,1].map{|x|[a,x,3,x]+(0..29).map{|t|v=x+4;u=x*60+9+t;[a,v,v,v,a,v,3,6,*[a,6,6,6]*(29-t),:<,6,x,u,a,v,u,v]}}+(0..59).map{|t|[a,2,2,2]+(0...t).map{[a,8+t-_1,69+_1,5,:<,3,5,6,a,2,6,2]}}

Measured memory_bytes: 14792
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <string>

using namespace std;

// stringをintに
// string a = "123";
// stoi(a)
//
// intをstringに
// int a = 123;
// to_string(a)
//
// charをintに
// char a = '1';
// (int)a - 48 // asciiコードを値にする

// stringのソート
// string str = "abccba";
// sort(str.begin(), str.end());
//
// ハッシュテーブル
// unordered_map<string, int> mp;
// mp["aabbcc"] = 0;

// 配列Aにcinする
//int main() {
//  int N;
//  cin >> N;
//  vector<int> A(N);
//  for (int i = 0; i < N; i++) {
//    cin >> A.at(i);
//  }
//  return 0;
//}

// 標準入出力
//int main() {
//	int a, b;
//	cin >> a >> b;
//  if (a * b % 2 == 0) {
//	  cout << "Even" << endl;
//  } else {
//	  cout << "Odd" << endl;
//  }
//  return 0;
//}

// 文字列を1文字ずつループ
//int main() {
//  string str;
//  cin >> str;
//  int sum = 0;
//  for(int i = 0; i < (int)str.size(); ++i){
//    char ch = str[i];
//
//    if (ch == '1') {
//      sum++;
//    }
//  }
//  cout << sum << endl;
//  return 0;
//}



// 標準入出力
int main() {
	int A, B;
	cin >> A >> B;
  int n = 1;
  int counter = 0;
  while (n < B) {
    n += A - 1;
    counter++;
  }
  cout << counter << endl;
  return 0;
}


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

signed main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  long long s = 0;
  for (int i = 0; i < n; ++i) cin >> a[i], s += a[i];
  s -= a[0];
  long long x = a[0], ans = abs(s - a[0]);
  for (int i = 1; i + 1 < n; ++i) {
    x += a[i];
    s -= a[i];
    ans = min(ans, abs(x - s));
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

template< typename T >
class CumulativeSum
{
public:
    CumulativeSum() {}
    CumulativeSum(int sz) : m_Data(sz, T(0)) {};

    void Init(int sz) { m_Data.assign(sz, T(0)); }

    // k に x を加える O(1)
    void Add(int k, T x) {
        assert(static_cast<int>(m_Data.size()) >= k);
        if(static_cast<int>(m_Data.size()) <= k) { m_Data.push_back(x); }
        else { m_Data[k] = (m_Data[k] + x); }
    }

    // 累積和の構築 O(m_Data.size())
    void Build() {
        for(int i = 1; i < static_cast<int>(m_Data.size()); i++) {
            m_Data[i] = (m_Data[i] + m_Data[i - 1]);
        }
    }

    // 区間 [0, k] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int k) {
        if(k < 0) { return T(0); }
        return (m_Data[min(k, static_cast<int>(m_Data.size()) - 1)]);
    }

    // 区間 [l, h] の和を返す O(1)
    // 閉区間なので k が含まれることに注意
    T Query(int l, int h) {
        return (this->Query(h) - this->Query(l-1));
    }
private:
    vector< T > m_Data;
};

ll N, Q;
string S;
vector<ll> L, R;

signed main()
{
    cin >> N >> Q >> S;
    L.resize(Q);
    R.resize(Q);
    REP(i, Q) {
        cin >> L[i] >> R[i];
        L[i]--;
        R[i]--;
    }

    CumulativeSum<ll> cs(N);
    for(int i = 1; i < N; ++i) {
        if(S[i] == 'C' && S[i-1] == 'A') {
            cs.Add(i, 1);
        }
    }
    cs.Build();
    REP(i, Q) {
        ll ans = cs.Query(L[i], R[i]);
        ans -= cs.Query(L[i], L[i]);
        printf("%lld\n", ans);
    }
    return 0;
}


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

int main() {
	int a, b, flag = 0;
	scanf("%d %d",&a, &b);
	int begin = a / .08;
	int end = (b + 1) / .1;
	for (long i = begin; i < end; ++i) {
		if ((int)(i * .08) == a && (int)(i * .1) == b) {
			printf("%ld", i);
			flag = 1;
			break;
		}
	}
	if (flag == 0) {
		printf("-1");
	}
		
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void){
    int n,k,x;
    cin >>n>>k;
    
    int ans=0;
    for(int i=0;i<n;i++){
        cin >>x;
        if(x<=k/2){
            ans+=x*2;
        }
        else{
            ans+=(k-x)*2;
        }
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import copy

def maze_maker():
    h,w = map(int,input().split())
    maze = []
    for i in range(h):
        maze.append(list(input()))
    return maze,h,w

def search():
    v = 0
    now = [[i1,j1,0]]
    meiro[i1][j1] = 0
    go = True
    while go:
        for i in now[:]:
            #上
            if i[0] == 0:
                pass
            else:
                if meiro[i[0]-1][i[1]] == ".":
                    now.append([i[0]-1,i[1],i[2]+1])
                    meiro[i[0]-1][i[1]] = i[2]+1
            #下
            if i[0] == h-1:
                pass
            else:
                if meiro[i[0]+1][i[1]] == ".":
                    now.append([i[0]+1,i[1],i[2]+1])
                    meiro[i[0]+1][i[1]] = i[2]+1
            #左
            if i[1] == 0:
                pass
            else:
                if meiro[i[0]][i[1]-1] == ".":
                    now.append([i[0],i[1]-1,i[2]+1])
                    meiro[i[0]][i[1]-1] = i[2]+1
            #右
            if i[1] == w-1:
                pass
            else:
                if meiro[i[0]][i[1]+1] == ".":
                    now.append([i[0],i[1]+1,i[2]+1])
                    meiro[i[0]][i[1]+1] = i[2]+1
            v = max(v,i[2])
            now.remove(i)
            if now == []:
                return v


saitankeiro = 0
maze,h,w = maze_maker()
for i1 in range(h):
    for j1 in range(w):
        if maze[i1][j1] != "#":
            meiro = copy.deepcopy(maze)
            saitankeiro = max(saitankeiro,search())
print(saitankeiro)

Measured memory_bytes: 3444
import numpy as np
N = int(input())
A = list(map(int, input().split()))
R = np.zeros(N + 1, dtype="int64")
P = np.ones(N + 1, dtype="int64")
mod = 10 ** 9 + 7

def rev(a):
    return pow(a, mod - 2, mod)
    
for n in range(N + 1):
    r = rev(n)
    R[n] = (R[n - 1] + r) % mod
    if n != 0:
        P[n] = (P[n - 1] * n) % mod

C = [(R[j] + R[N - j + 1] - 1) % mod for j in range(1, N + 1)]

res = 0
for i in range(N):
    res = (res + (A[i] * C[i]) % mod) % mod

print(res * P[N] % mod)
#print((sum([a * c % mod for a, c in zip(C, A)]) * P[N]) % mod)


Measured memory_bytes: 24340
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main(){
      
      ios
      int a,b,c,d;
      cin >> a >> b >> c >> d;
      int i=1;
      while(i){
            
            if(i%2!=0){
                  c = c-b;
                  if(c<=0){
                        cout << "Yes" <<"\n";
                        break;
                  }      
            }
            else{
                  a=a-d;
                  if(a<=0){
                        cout << "No" <<"\n";
                        break;
                  }      
            }
            i++;
      }

      return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  string n;
  cin>>n;
  if(n[0] == '7' ||n[1] =='7' || n[2] == '7'){
    cout <<"Yes" <<endl;
  }else {
    cout <<"No"<<endl;
  }
return 0;
}

Measured memory_bytes: 3624
#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 <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
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 (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 3608
D, G = map(int, input().split())
List = [list(map(int, input().split())) for _ in range(D)]

for i in range(D):
    b = [[List[i][0], List[i][0]*(i+1)*100+List[i][1]] for i in range(D)]
    
m = 10**9
for j in range(2**D):
    cnt = 0
    score = 0
    flg = 0
    for k in range(D):
        if ((j>>k)&1):
            cnt+=b[k][0]
            score+=b[k][1]
            flg+=1
            used = k
        else:
            unused = k
    if G<=score:
        if flg==1:
            cnt = min(-(-G//((used+1)*100)), cnt)
            if cnt<m:
                m = cnt
        else:
            if cnt<m:
                m = cnt
                
    else: 
        diff = G-score
        offset = -(-diff//((unused+1)*100))
        cnt += offset
        if offset<List[unused][0]:
            if cnt<m:
                m = cnt
print(m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<int,int>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define ceili(x,y) (x+y-1)/y  
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
  lli A,B,C,D,E,L,R,X,Y,W,H,N,M,K,sum=0,num=0,flag=0;string S,T;
  cin >> X >> Y;
  while(X<=Y){
    X*=2;
    sum++;
  }
  Out(sum);
}

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> data[i][j];
    }
  }
  vector<int> h(H);
  int x = -1;
  vector<int> w(W);
  int y = -1;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(data[i][j] == '#'){
        x++;
        h[x] = i;
        break;
      }
    }
  }
  for(int i = 0; i < W; i++){
    for(int j = 0; j < H; j++){
      if(data[j][i] == '#'){
        y++;
        w[y] = i;
        break;
      }
    }
  }
  vector<vector<char>> z(x+1, vector<char>(y+1));
  for(int i = 0; i <= x; i++){
    for(int j = 0; j <= y; j++){
      z[i][j] = data[h[i]][w[j]];
    }
  }
  for(int i = 0; i <= x; i++){
    for(int j = 0; j <= y; j++){
      cout << z[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    long long   n, b, c, tmp, sum=0;
    scanf("%lld", &n);

    int num[100000+1]={0};
    for(int i=0; i<n; i++){
        scanf("%lld", &tmp);
        num[tmp]++;
        sum += tmp;
    }

    long long q;
    scanf("%lld", &q);
    for(int i=0; i<q; i++){
        scanf("%lld %lld", &b, &c);

        //和
//      sum = sum - num[b]*b;
//      sum = sum + num[b]*c;
        sum += ((c-b)*num[b]);
        printf("%lld\n", sum);

        //各要素の値変化
        num[c] += num[b];
        num[b]  = 0;

    }
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC153D()
{
	ll H;
	cin >> H;

	ll ans = 0;
	ll n = 1;
	while (H > 0)
	{
		H /= 2;
		ans += n;
		n *= 2;
	}
	cout << ans << endl;
}

int main()
{
	ABC153D();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int x,i;
    scanf("%d",&x);
    if(x==1||x==8||x==15||x==22||x==29)printf("fri\n");
    if(x==2||x==9||x==16||x==23||x==30)printf("sat\n");
    if(x==3||x==10||x==17||x==24)printf("sun\n");
    if(x==4||x==11||x==18||x==25)printf("mon\n");
    if(x==5||x==12||x==19||x==26)printf("tue\n");
    if(x==6||x==13||x==20||x==27)printf("wed\n");
    if(x==7||x==14||x==21||x==28)printf("thu\n");
    return 0;
}



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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  // ll ans = -INF;

  ll N, X, T;
  scanf("%lld %lld %lld", &N, &X, &T);

  // ans = 0;
  ll t = 0;
  ll n = 0;
  for (;;) {
    t += T;
    n += X;
    if (n >= N) {
      break;
    }
  }

  //

  cout << t << endl;
}


Measured memory_bytes: 3760
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<cctype>
#include<utility>
#include<algorithm>
#include<cctype>
using namespace std;

string shuffle(string s,int n){
	string ret;
	ret = s.substr(n) + s.substr(0,n);
	return ret;
}

int main()
{
	string s;int n,h;
	while(cin >> s && s!="-"){
		cin >> n;
		for(int i=0;i<n;i++){
			cin >> h;
			s = shuffle(s,h);
		}
		cout << s << endl;
	}

    return 0;
}

Measured memory_bytes: 1216
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		long x = 0;
		long y = 0;
		int count = 0;
		double distance = 0;

		for (int i = 0; i < N; i++ ) {
			x = sc.nextLong();
			y = sc.nextLong();
			distance = Math.hypot(x, y);
			if (distance <= D) count++;
		}

		sc.close();

		System.out.println(count);
	}
}

Measured memory_bytes: 59200
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct data{
	int l,x;
	data(){}
	data(int ll,int xx){
		l=ll;
		x=xx;
	}
};
int n,m;
ll dp[2][301][301];
data d[301];
vector<data> G[301];

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int l,r,x;
		scanf("%d%d%d",&l,&r,&x);
		l--;
		G[r].push_back(data(l,x));
	}
	dp[0][0][0]=3;
	int prev=0,now=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				bool flag=true;
				for(int ls=0;ls<G[i].size();ls++){
					int cnt=1;
					if(G[i][ls].l<j)cnt++;
					if(G[i][ls].l<k)cnt++;
					if(cnt!=G[i][ls].x)flag=false;
				}
				if(!flag)dp[prev][j][k]=0;
				dp[now][j][k]+=dp[prev][j][k];
				dp[now][j][k]%=MOD;
				dp[now][i][j]+=dp[prev][j][k];
				dp[now][i][j]%=MOD;
				dp[now][i][k]+=dp[prev][j][k];
				dp[now][i][k]%=MOD;
			}
		}
		swap(now,prev);
		memset(dp[now],0,sizeof(dp[now]));
	}
	ll res=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			bool flag=true;
			for(int k=0;k<G[n].size();k++){
				int cnt=1;
				if(G[n][k].l<i)cnt++;
				if(G[n][k].l<j)cnt++;
				if(cnt!=G[n][k].x)flag=false;
			}
			if(flag)res=(res+dp[prev][i][j])%MOD;
		}
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
using namespace std;
int main(){
    int n,x,y,z;
    cin>>n;
    int a[n+1][n+1];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            a[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(y!=0){
            for(int j=0;j<y;j++){
                cin>>z;
                a[x][z]=1;
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            cout<<a[i][j]<<" ";
        }
        cout<<a[i][n]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3092
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, D = NMI()
    P = [NLI() for _ in range(N)]
    ans = 0
    for x, y in P:
        if x**2 + y**2 <= D**2:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 45788
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> a;
    for(int i=0;i<n-1;i++){
        int x;
        cin >> x;
        a.push_back(x);
    }

    vector<int> ans(n);

    for(int i=0;i<n-1;i++){
        ans[a[i]-1]++;
    }

    for(auto i : ans){
        cout << i << endl;
    }
    return 0;
}


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

map<int, vector<int>> adj;

int main() {
	using ll = long long;
	int n;
	cin >> n;

	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	vector<int> color(n+1, -1);
	color[1] = 0; color[n] = 1;
	int cnt[2] = {0};
	queue<int> q;
	q.push(1); q.push(n);
	while(!q.empty()) {
		auto w = q.front(); q.pop();
		cnt[color[w]]++;
		for (auto v : adj[w]) {
			if (color[v] != -1) continue;
			color[v] = color[w];
			q.push(v);
		}
	}

	cout << (cnt[0] > cnt[1] ? "Fennec\n" : "Snuke\n");
	return 0;
}

Measured memory_bytes: 11520
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1;
    for (size_t i = 0; i < size; ++i) {
        vec1.push_back(cin2var<T>());
    }
    return vec1;
}

int main()
{
    const vec1<int> Xs(cin2vec<int>(2));
    cout << abs(Xs[0] - Xs[1]) << endl;
    return 0;
}


Measured memory_bytes: 3152
require 'date'
def calcTime(x)
    x1=DateTime.new(2020,1,1,x[0],x[1],x[2])
    x2=DateTime.new(2020,1,1,x[3],x[4],x[5])
    diff = (x2.to_time-x1.to_time).to_i
    hour = diff / (60*60)
    minute = (diff-hour*60*60)/60
    second = (diff-hour*60*60-minute*60)
    puts "#{hour} #{minute} #{second}"
end
calcTime(gets.split.map(&:to_i))
calcTime(gets.split.map(&:to_i))
calcTime(gets.split.map(&:to_i))


Measured memory_bytes: 7000
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        string s;
        cin >> s;

        int tot = 0;
        for (auto &&x : s)
            tot += (x - '0');

        cout << (tot % 9 ? "No" : "Yes") << '\n';
        
    }
    
    return 0;
}



Measured memory_bytes: 3760
N = int(input())
A = list(map(int, input().split()))

Alice = 0
Bob = 0
A.sort(reverse=True)
for i in range(len(A)):
    if i%2 == 0:
        Alice += A[0]
    else:
        Bob += A[0]
    A.pop(0)
    
print(Alice-Bob)

Measured memory_bytes: 3060
n, m = gets.split.map(&:to_i)
abs = n.times.map do
  gets.split.map(&:to_i)
end

sum = 0
count = 0
abs.sort_by{|a, b| a }.each do |a, b|
  count += b
  if count > m
    sum += a * (b + m - count)
  else
    sum += a * b
  end
  break if count > m
end

puts sum


Measured memory_bytes: 12664
#include<iostream>
using namespace std;
int main(){
  int n,kazu,dammy,i,j,a;
  char moji;  
  cin >> n;
  bool cards[4][13];
   
 

  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      cards[i][j]=false;
      
    }}
  for(int k=0;k<n;k++){ 
    cin >> moji >> kazu;
     a=kazu-1;
    if(moji=='S'){
      dammy=0;
      
    } 
    else if(moji=='H'){
      dammy=1;
      
    }
    else if(moji=='C'){
      dammy=2;
      
    }
    else if(moji=='D'){
      dammy=3;
      
    }
    cards[dammy][a]=true;
    
  }
  for(int l=0;l<4;l++){
    for(int m=0;m<13;m++){
      if(!cards[l][m]){
	if(l==0){
	  cout << "S " ;}
	else if(l==1){cout << "H " ;}
	else if(l==2){cout << "C " ;}
	else if(l==3){cout << "D " ;}


	cout << m+1 << endl;


    }
 
  }
  }}

Measured memory_bytes: 1160
import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    S, T = input().split()

    ans = ""
    for s, t in zip(S, T):
        ans += s + t

    return ans


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int[] c = new int[n - 1];
		int[] s = new int[n - 1];
		int[] f = new int[n - 1];
		int[] ans = new int[n];

		for (int i = 0; i < n - 1; i++) {
			c[i] = sc.nextInt();
			s[i] = sc.nextInt();
			f[i] = sc.nextInt();
		}
		
		for (int i = 0; i < n - 1; i++) {
			ans[i] = s[i];
			for (int j = i + 1; j < n; j++) {
				ans[i] += c[j - 1];
				if (j == (n - 1)) {
					break;
				}
				int x = s[j];
				while (ans[i] > x) {
					x += f[j];
				}
				if (ans[i] != x) {
					ans[i] += (x - ans[i]);
				}
			}
		}

		for (int i = 0; i < n; i++) {
			System.out.println(ans[i]);
		}

		sc.close();
	}
}


Measured memory_bytes: 26172
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int s[n];
	for(int i=0;i<n;i++)cin>>s[i];
	for(int i=0;i+1<n;i++){
		int index=i,l=s[i];
		for(int j=i+1;j<n;j++){
			if(s[j]<l){
				l=s[j];
				index=j;
			}
		}
		if(index>i){
			s[i]+=s[index];
			s[index]=s[i]-s[index];
			s[i]-=s[index];
		}
	}
	double total=s[0];
	for(int i=1;i<n;i++)total=(total+s[i])/2;
	cout<<total<<endl;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list()
    max_value = 0
    second_max_value = 0
    max_index = -1
    for i in range(N):
        a = int(input())
        A.append(a)
        if a > max_value:
            second_max_value = max_value
            max_value = a
            max_index = i
        elif a > second_max_value:
            second_max_value = a
    for i, a in enumerate(A):
        if i == max_index:
            print(second_max_value)
        else:
            print(max_value)


if __name__ == '__main__':
    main()

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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec.at(i);
    }
    // for(int i=0;i<N;i++){
    //     cout << vec.at(i) <<endl;
    // }
    long count = 1;
    int tmp = vec.at(0);
    // cout << tmp << endl;
    for(int i=1;i<N;i++){
        if(vec.at(i)<tmp){
            count++;
            tmp = vec.at(i);
        }
        // cout << tmp << endl;
    }
    cout << count << endl;

}

Measured memory_bytes: 1024
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    vl v;
    v.pb(0);
    for(int i=1;i<=n;i++)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    ll dp[n+1][5];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
    {
        ll add=v[i]%2;
        if(v[i]==0)
            add=2;
        dp[i][0]=dp[i-1][0]+v[i];
        dp[i][1]=min(dp[i-1][0],dp[i-1][1])+add;
        dp[i][2]=min3(dp[i-1][0],dp[i-1][1],dp[i-1][2])+1-v[i]%2;
        dp[i][3]=min(min(dp[i-1][0],dp[i-1][1]),min(dp[i-1][2],dp[i-1][3]))+add;
        dp[i][4]=min(min(min(dp[i-1][0],dp[i-1][1]),min(dp[i-1][2],dp[i-1][3])),dp[i-1][4])+v[i];
    }
    ll ans=1e18;
    for(int i=0;i<=4;i++)
        ans=min(ans,dp[n][i]);
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

int main() {
    int a, b, c, d, e, f, x, y, m, s, max_mizu = 0, max_sato = 0;
    float noudo, max_noudo = 0;
    vector<float> mizu, sato;
    cin >> a >> b >> c >> d >> e >> f;
    for(int i = 0; i <= f/(a*100)+1; ++i) {
        for(int j = 0; j <= f/(b*100)+1; ++j) {
            m = 100*a*i + 100*b*j;
            if(m <= f && m != 0) {
                mizu.push_back(m);
            }
        }
    }
    for(int i = 0; i <= f/c+1; ++i) {
        for(int j = 0; j <= f/d+1; ++j) {
            s = c*i + d*j;
            if(s <= f) {
                sato.push_back(s);
            }
        }
    }
    max_mizu = mizu[0];
    for(int i = 0; i < mizu.size(); ++i) {
        for(int j = 0; j < sato.size(); ++j) {
            if(sato[j]*100/mizu[i] <= e && (mizu[i] + sato[j]) <= f) {
                noudo = (float)(100*sato[j]/(mizu[i]+sato[j]));
                if(noudo > max_noudo) {
                        max_mizu = mizu[i];
                        max_sato = sato[j];
                        max_noudo = noudo;
                }
            }
        }
    }
    cout << max_mizu + max_sato << " " << max_sato << '\n';
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vl a(n),b(n);cin>>a>>b;
    vl p(n); iota(all(p),1);
    ll x,y,c=0;
    do{
        if(a==p)x=c;
        if(b==p)y=c;
        c++;
    }while(next_permutation(all(p)));
    puta(abs(x-y));
    return 0;
}

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

int main(void){
    int n, r, g, b, x;
    string color;
    cin >> n;
    cin >> color;
    r = g = b = x = 0;
    
    for(int i=0; i<n; i++){
        if(color[i] == 'R') r++;
        else if(color[i] == 'G') g++;
        else b++;
        for(int j=i+1, k=i+2; k<n; j++, k+=2)
            if(color[i]!=color[j] && color[j]!=color[k] && color[k]!=color[i]) x++;
    }
    cout << (int64_t)r*g*b - x << '\n';
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
int main() {
        fast;
        string s;
        cin >> s;
        if(s.size() == 6 and s[2] == s[3] and s[4]==s[5])cout << "Yes";
        else cout << "No";
        cout << endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n")
	const [n, m, k] = [...(input[0].split(" ").map( x => parseInt(x, 10)))]
	const a = (input[1].split(" ")).map( x => parseInt(x, 10) )
	const b = (input[2].split(" ")).map( x => parseInt(x, 10) )
	let sum_a = [0]
	let sum_b = [0]
	let temp = 0
	for( let i = 0; i < n; i++ ){
		temp += a[i]
		sum_a.push(temp)
	}
	temp = 0
	for( let i = 0; i < m; i++ ){
		temp += b[i]
		sum_b.push(temp)
	}
	let ap = 0
	for( let i = n; i >= 0; i-- ){
		if( sum_a[i] <= k ){
			ap = i
			break
		}
	}
	let bp = 0
	let ans = 0
	for( ; ap >= 0; ap-- ){
		while( bp+1 <= m && sum_a[ap] + sum_b[bp+1] <= k ) ++bp
		ans = ( ap+bp > ans ? ap+bp : ans )
	}
	console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 83476
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  ll x,y;
  int res=0;
  cin >> x>>y;

  while(x<=y){
    res++;
    x*=2;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
s = {}
for i in range(n):
    #print("i = ",i,"の時a[",i,"] = ",a[i],"で,s[",a[i],"] = ",i+1)
    s[a[i]] = i+1
for i in range(n):
    print(s[i+1])

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

int a,b,k;
int main() {
  cin >> a >> b >> k;
  set<int> s;
  for(int i=a;i<a+k;i++){
    s.insert(i);
  }
  for(int i=b-k+1;i<b+1;i++){
    s.insert(i);
  }
  for(int x:s ){
    if(x>=a&&x<=b){
    cout << x << endl;
    }
  }
}

Measured memory_bytes: 256
while 1:
	n,m,k = map(int,raw_input().split(" "))
	if n == m == k == 0: break
	dice = [[0 for _ in range(m * n)] for _ in range(n)]
	for i in range(m):
		dice[0][i] = 1
	for i in range(n-1):
		for j in range(m * n):
			if dice[i][j] == 0: continue
			for l in range(1,m+1):
				dice[i+1][j+l] += dice[i][j]
	print sum([(i+1-k if i+1-k > 1 else 1) * dice[n-1][i] for i in range((1*n-1),m*n)])/(m**n*1.)

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

using namespace std;

int f(int n){
  int ans=0;
  while (n!=0){
    ans+=n%10;
    n/=10;
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  if (n%f(n)==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
def fa(): #final answer
    global ans
    print(ans)
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

N, K = getNM()

if N%K == 0:
    ans = 0
else:
    ans = 1

fa()

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<queue>
#define ll long long
#define PI 2*acos(0.0)
using namespace std;

int main()
{

   // int i,j,k,m,n,val,t=0,test;
    ll a,x,y,ans1,ans2;
    cin>>x>>y>>a;
    if(x==0){
        ans1=0;
        ans2=(y/a)+1;
    }
    else ans1=(x-1)/a,ans2=y/a;;


    cout<<ans2-ans1<<endl;

    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    string w;
    cin >> w;
    vector<int> a(26, 0);
    rep(i, 0, w.size()){
        int x = w.at(i) - 'a';
        a.at(x)++;
    }
    rep(i, 0, 26){
        if (a.at(i) % 2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define PB push_back
#define E end()
#define PB push_back
typedef vector<ll> vctr;
#define REP(i,a,b) for (long long i = a; i < b; i++)
#define RREP(i,a,b) for (long long i = a; i > b; i--)
#define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');


/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
void solve() {
	int n;
	cin >> n;
	int count = 0;
	while (n--) {
		int x, y;
		cin >> x >> y;
		if (x == y) {
			count++;
		}
		else {
			count = 0;
		}
		if (count == 3) {
			cout << "Yes";
			return;
		}

	}
	if (count >= 3) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}




int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	long long test;
	test = 1;
	// cin >> test;
	while (test--) {
		solve();
		// cout << "\n";
	}


}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

vector<ll> explode(string const & s, char delim) {
    vector<ll> result;
    string token;
    for (istringstream iss(s); getline(iss, token, delim);) result.push_back(stoll(token));
    return result;
}

void solve() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if (a == 0 and b == 0) {
        ans = 0;
    } else if (a == 0) {
        if (b > 0) ans = b;
        else ans = abs(b) + 1;
    } else if (b == 0) {
        if (a > 0) ans = a + 1;
        else ans = abs(a);
    } else if (a > 0 and b > 0) {
        if (a < b) ans = b - a;
        else if (a > b) ans = a - b + 2;
    } else if (a > 0 and b < 0) {
        ans = abs(abs(b) - abs(a)) + 1;
    } else if (a < 0 and b > 0) {
        ans = abs(abs(a) - abs(b)) + 1;
    } else {
        if (a < b) ans = abs(abs(b) - abs(a));
        else if (a > b) ans = abs(abs(a) - abs(b)) + 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
int T; i64 A, B, C, D, g; i64 gcd(i64 a, i64 b) { return b?gcd(b, a%b):a; }
int main()
{
    for(scanf("%d", &T); T--; )
    {
        scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
        if(A < B||D < B) puts("No");
        else if(B <= C+1) puts("Yes");
        else g = gcd(B, D), puts((A-B)/g == (A-C-1)/g?"Yes":"No");
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

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

	char s;
	for(int i = 0; i < a; i++){
		cin >> s;
		if(!isdigit(s)){
			cout << "No" << endl;
			return 0;
		}
	}

	cin >> s;
	if(s != '-'){
		cout << "No" << endl;
		return 0;
	}

	for(int i = 0; i < b; i++){
		cin >> s;
		if(!isdigit(s)){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256