akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

int prime(int N) {
  if(N<2) return 0;
  if(N == 2) return 1;
  if(N%2 == 0) return 0;
  int sq = (int)(sqrt(N))+1;
  for(int i=3; i<sq; i+=2) {
    if(N%i == 0) return 0;
  }
  return 1;
}


signed main() {
  int N, M; cin >> N >> M;
  
  if(prime(M) == 1 && N >= 2) {
    cout << 1 << endl;
    return 0;
  }
  
  for(int i=N; i<=M; i++) {
    if(M%i == 0) {
      cout << M/i << endl;
      return 0;
    }
  }
    
  
}

Measured memory_bytes: 3680
N=int(input())
alphabets = [chr(ord('a') + x) for x in range(26)]
def dfs(n,s,maxc):
    if len(s)==N:
        print(''.join(s))
        return
    for i in range(maxc+1):
        dfs(n+1,s+[alphabets[i]],maxc+1 if i==maxc else maxc)
s=[]
dfs(0,s,0)

Measured memory_bytes: 4412
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int x[5];
	rep(i,5){
		scan(x[i]);
		if(x[i]==0){
			prin(i+1);
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3588
class Combination:
    '''MOD上の
    計算量：階乗・逆元テーブルの作成O(N)
    nCkを求めるO(1)'''

    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [pow(self.fact[i], MOD - 2, MOD) for i in range(n + 1)]
        self.MOD = MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD

    def combination2(self, k, r):
        """kCrを求める O(r)
        kが大きいときに使える
        """
        if k < r:
            return 0
        res = 1
        for l in range(r):
            res *= (k - l)
            res %= self.MOD
        return (res * self.inv_fact[r]) % self.MOD

n, a, b = list(map(int, input().split()))
MOD = 10 ** 9 + 7
comb = Combination(2 * 10 ** 5 + 10, MOD)

ptn_a = comb.combination2(n, a)
ptn_b = comb.combination2(n, b)
ptn_n = pow(2, n, MOD) - 1

print((ptn_n - ptn_a - ptn_b) % MOD)


Measured memory_bytes: 54260
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second

string s;

int main(){
	
	cin >> s;
	for ( int i = 1; i < 3; i++ ){
		if ( s[i] != s[i-1] ){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	if(n==1&&m==1){
		printf("1\n");
		return 0;
	}
	if(n==1||m==1){
		if(m==1) swap(n,m);
		printf("%d\n",m-2);
		return 0;
	}
	long long ans=n*(long long)m-n*2-m*2+4;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ii pair<ll,pair<int,int>>
#define ll long long
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define orta ((bas+son)>>1)
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define inf 2000000000
#define N 100005
#define MOD 1000000007
using namespace std;
 
int main() {
 
	int a,b;

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

	if((a+b)&1) printf("IMPOSSIBLE");
	else printf("%d",(a+b)>>1);
	
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if( n == 0 ) break;
			int m = sc.nextInt();
			String str = sc.next();
			int cnt = 0;
			int ioi = 0;
			for(int i=0;i<m;i++) {
				if( str.charAt(i) == 'I' ) {
					if( ioi%2 == 0 ) {
						ioi++;
						if( ioi/2 >= n  ) cnt++;
					}
					else ioi = 1;
				}
				else if( str.charAt(i) == 'O' ) {
					if( ioi%2 == 1 )
						ioi++;
					else ioi = 0;
				}
			}
			System.out.println(cnt);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 16000
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<30;
const int mod = 1e9+7;

int main() {
  int N; cin >> N;
  vector<int> a(N), b(N), c(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  for(int i = 0; i < N; i++) cin >> b[i];
  for(int i = 0; i < N; i++) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll ans = 0;
  for(int i = 0; i < N; i++) {
    ans += ll(lower_bound(a.begin(), a.end(), b[i])-a.begin()) * (c.end() - upper_bound(c.begin(), c.end(), b[i]));
  }
  cout << ans << endl;
  return 0;
}



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

int main(){
  double ans;
  double n,k;
  cin >> n >> k;
  rep(i,n){
    double x = log2((double)(k/(i+1)));
    double integral_part = 0;
    double fractional_part = modf(x, &integral_part);
    if(x<=0){
      ans += 1.0/n;
      continue;
    }
    if(fractional_part>0)integral_part+=1;
    ans += 1.0/n/pow(2,integral_part);
  }
  printf("%.13lf\n", ans);
  return 0;
}


Measured memory_bytes: 512
# include<iostream>
# include<algorithm>
# include<cstring>
# include<string>
# include<cmath>
# include<queue>
# include<stack>
# include<set>
# include<vector>
# include<cstdio>
# include<cstdlib>
# include<map>
# include<deque>

# define deb(x) printf("# x=%d\n",x)
# define deb_d(x) printf("# x=%lf\n",x)
# define ccout(x) printf("%d\n",x)

typedef long long ll;

using namespace std;

string s;

bool check(){
	int sum=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='9')
			sum++;
	}
	return sum==s.length();
}

int Sum(){
	int sum=0;
	for(int i=0;i<s.length();i++){
		sum+=s[i]-'0';
	}
	return sum;
}

int main(void){
	while(cin>>s){
		if(s.length()==1){
			printf("%c\n",s[0]);
			continue;
		}
		if(check()){
			printf("%d\n",s.length()*9);
			continue;
		}
		int ans=0;	
		ans=(s.length()-1)*9;
		ans+=s[0]-'0'-1;
		ans=max(Sum(),ans);
		printf("%d\n",ans);
	}
	return 0;
}

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

int main() {
    int p, q, r;
    cin >> p >> q >> r;
    int ans = 1000;
    if(p + q < ans) ans = p + q;
    if(r + q < ans) ans = r + q;
    if(p + r < ans) ans = p + r;
    if(q + r < ans) ans = q + r;
    if(r + p < ans) ans = r + p;
    if(q + p < ans) ans = q + p;

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


Measured memory_bytes: 3616
import sys

DBG_FLAG = 1

def pdbg(str):
    if(DBG_FLAG == 1):
        sys.stdout.flush()
        print str

def max_num(num):
    if(num % 2):
        return 0
    else:
        return 1 + max_num(num / 2)

# get num
N = int(raw_input())
array = map(int, raw_input().split())

#pdbg(N)
#pdbg(array)

min = 1
num = 0

ans = []

for item in array:
    ans.append(max_num(item))

ans.sort()

print ans[0]


Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	string N;
	cin >> N;
	bool ok = false;
	for (int i = 0; i < 3; i++) {
		if (N[i] - '0' == 7) ok = true;
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()		
#define debug system("pause")				//デバッグ用


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

	int n;
	cin >> n;

	string s;

	ll c = 0;
	ll begin_is_B_cnt = 0;
	ll end_is_A_cnt = 0;
	ll AandB = 0;

	for (int i = 0; i < n; i++)
	{
		cin >> s;
		for (int j = 0; j < (s.size() - 1); j++)
		{
			if (s[j] == 'A' && s[j + 1] == 'B')
			{
				c++;
			}
		}
		if (s[0] == 'B' && s[s.size() - 1] == 'A')
		{
			AandB++;
		}
		else if (s[s.size() - 1] == 'A')
		{
			end_is_A_cnt++;
		}
		else if (s[0] == 'B')
		{
			begin_is_B_cnt++;
		}
	}

	if (AandB >= 2)
	{
		c += AandB - 1;
		AandB = 1;
	}

	if (end_is_A_cnt == 0 && begin_is_B_cnt == 0)
	{
		cout << c << endl;
	}
	else
		cout << c + max(min(begin_is_B_cnt + AandB, end_is_A_cnt + AandB), min(end_is_A_cnt + AandB, begin_is_B_cnt)) << endl;




}

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

int main() {
    long long N;
    cin >> N;
    vector<pair<long long, long long>> T[N + 1];
    for (long long i = 1; i <= N - 1; i++) {
        long long u, v, w;
        cin >> u >> v >> w;
        T[u].push_back(make_pair(v, w));
        T[v].push_back(make_pair(u, w));
    }
    stack<pair<long long, long long>> S;
    vector<long long> ans(N + 1);
    vector<long long> col(N + 1, 0);
    S.push(make_pair(1, 0));
    col[1] = 1;
    while (!S.empty()) {
        auto u = S.top();
        S.pop();
        ans[u.first] = u.second % 2;
        for (auto v : T[u.first]) {
            if (col[v.first] == 0) {
                S.push(make_pair(v.first, u.second + v.second));
                col[v.first] = 1;
            }
        }
    }
    for (long long i = 1; i <= N; i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 12216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N + 1);
    rep(i, N + 1) cin >> A[i];
    vector<long long> sum(N + 1);
    sum[N] = A[N];
    for (int i = N - 1; i >= 0; --i) sum[i] = sum[i + 1] + A[i];
    long long x = 1, ans = 0;
    bool b = false;
    rep(i, N + 1) {
        if (b) {
            ans += sum[i];
        } else {
            if (x < A[i]) {
                cout << -1 << "\n";
                return 0;
            }
            ans += min(x, sum[i]);
            x = (x - A[i]) * 2;
            if (x > 1e16) b = true;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4844
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

int inf = 1000005;

int ok[1000010]={};
int dp[1000010]={};
int dp2[1000010]={};

int main(void){
	
	reg(i,1,1000){
		int no=(i*(i+1)*(i+2))/6;
		if(no>inf)break;
		ok[no]=1;
	}
	
	rep(i,inf)dp[i]=dp2[i]=inf;
	
	rep(i,inf){
		if(!ok[i])continue;
		//printf("ok! %d\n",i);
		dp[i]=1;
		rep(j,inf){
			int to=i+j;
			if(to>inf)continue;
			dp[to]=min(dp[to],dp[j]+1);
		}
	}
	
	rep(i,inf){
		if(!ok[i] || i%2==0)continue;
		//printf("ok! %d\n",i);
		dp2[i]=1;
		rep(j,inf){
			int to=i+j;
			if(to>inf)continue;
			dp2[to]=min(dp2[to],dp2[j]+1);
		}
	}
	
	
	for(;;){
		int p;
		scanf("%d",&p);
		if(!p)break;
		printf("%d %d\n",dp[p],dp2[p]);
	}
		
	return 0;
}

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

const int N = 1000;
int a[N];
long long sum[N + 1];

int main() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }

  long long res = 0;
  for (int pos = 39; pos >= 0; --pos) {
    long long mask = res | 1LL << pos;
    int cnt = 0;
    for (int i = 0; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        if (((sum[j] - sum[i]) & mask) == mask) {
          ++cnt;
        }
      }
    }
    if (cnt >= k) res = mask;
  }
  cout << res << endl;
}


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

int main()
{
	long long a, b, k;
	bool flag = true;
	scanf("%lld  %lld %lld", &a, &b, &k);
	while (k--)
	{
		if (flag)//a
		{
			flag = false;
			if (a & 1)//odd
			{
				a--;
				int t = a / 2;
				a -= t;
				b += t;
			}
			else
			{
				int t = a / 2;
				a -= t;
				b += t;
			}

		}

		else//b
		{
			flag = true;
			if (b & 1)//odd
			{
				b--;
				int t = b / 2;
				b -= t;
				a += t;
			}
			else
			{
				int t = b / 2;
				b -= t;
				a += t;
			}

		}

	}

	printf("%lld %lld\n", a, b);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005,mod=1000000000;
int n,b[N],c[N],s[100][100],xb[N],xc[N],a[N],ans;
signed main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string r;
		cin>>r;
		int k=0,zh=0;
		int fl=0;
		for(auto c:r)
		{
			if(c=='.')
			{
				fl=1;
				continue;
			}
			k=k*10+c-'0';
			zh+=fl;
		}
		while(zh<9)
		{
			zh++;
			k*=10;
		}
		int y;
		y=k;
		while(y%2==0)
		{
			xb[i]++;
			y/=2;
		}
		y=k;
		while(y%5==0)
		{
			xc[i]++;
			y/=5;
		}
		s[xb[i]][xc[i]]++;
		if(k%mod==0)
			ans--;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=max(18-xb[i],0LL);j<=70;j++)
			for(int k=max(18-xc[i],0LL);k<=70;k++)
				ans+=s[j][k];
	}
	cout<<ans/2<<endl;
	return 0;
}

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

#define PI 3.141592653589
#define ll long long int
#define ld long double
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vv vector
int MOD=1e9+7;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
ll min(ll a,ll b){return (a>b)?b:a;}
ll max(ll a,ll b){return (a>b)?a:b;}
bool prime[1000001];
vi primes;
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, true, sizeof(prime)); 
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for(int p=2;p<1000001;p++)
        if(prime[p])
            primes.pb(p);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

    int t=1;
	//cin>>t;
	//SieveOfEratosthenes(1000000);
    while(t--){
        int l,r,d;
        cin>>l>>r>>d;
        int cnt=0;
        for(int i=l;i<=r;i++){
            if(i%d==0)
                cnt++;
        }
        cout<<cnt;
    }
}

Measured memory_bytes: 3652
# https://atcoder.jp/contests/abc059/tasks/arc072_a
# 累積和を作っておいて、その累積和の符号が交互になるようにしていく

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


class cumsum1d:  # 一次元累積和クラス
    def __init__(self, ls: list):
        '''
        1次元リストを受け取る
        '''
        from itertools import accumulate
        self.ls_accum = [0] + list(accumulate(ls))

    def total(self, i, j):
        # もとの配列lsにおける[i,j)の中合計
        return self.ls_accum[j] - self.ls_accum[i]

    def __call__(self, i):
        # i番目までの合計
        return self.ls_accum[i + 1]


N = read_a_int()
A = read_ints()

A = cumsum1d(A)
# ただし第一項が0とか途中0になる場合がめんどくさい
# →二通りやって少ないほうでいいじゃん
ans1 = 0
bias = 0
pre_sign = 1  # 第一項が負と仮定
for i in range(N):
    now = A(i) + bias
    if (-1, 1)[pre_sign] * now < 0:  # 異符号
        pass
    elif (-1, 1)[pre_sign] * now >= 0:  # 同符号
        ans1 += abs(now) + 1
        bias += (1, -1)[pre_sign] * (abs(now) + 1)
    pre_sign = 1 - pre_sign

ans2 = 0
bias = 0
pre_sign = 0  # 第一項が正と仮定
for i in range(N):
    now = A(i) + bias
    if (-1, 1)[pre_sign] * now < 0:  # 異符号
        pass
    elif (-1, 1)[pre_sign] * now >= 0:  # 同符号
        ans2 += abs(now) + 1
        bias += (1, -1)[pre_sign] * (abs(now) + 1)
    pre_sign = 1 - pre_sign
print(min(ans1, ans2))


Measured memory_bytes: 60884
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=100000;
int a[maxn],b[maxn+10];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int ans=0;
    for(int i=1;i<n;i++)
        if(a[i]==i)
        {
           swap(a[i],a[i+1]);
           ans++;
        }
    if(a[n]==n)
        ans++;
    cout<<ans<<endl;

}


Measured memory_bytes: 640
//https://atcoder.jp/contests/agc040/tasks/agc040_b

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <stack>
#include <math.h>
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(ll i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(ll i=(s), i##_len=(n); i<i##_len; ++i)
#define ALL(v) (v).begin(),(v).end()
#define INF (ll(1e18))

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    if (a.second == b.second) {
        return a.first > b.first;
    }
    return a.second < b.second;
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

class SegmentTree {
public:
    int N, n;
    vector<ll> value;
    SegmentTree(int n) {
        this->n = n;
        this->N = 1;
        while (N < n) N *= 2;
        this->value = vector<ll>(2 * N - 1, INF);
    }
    
    void update(int i, ll x) {
        i += N - 1;
        value[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            value[i] = min(value[i * 2 + 1], value[i * 2 + 2]);
        }
    }
    
    ll query(int l, int r) {
        return _query(l, r, 0, 0, N);
    }
    
    ll _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b)
            return value[k];
        else {
            ll c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
            ll c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
            return min(c1, c2);
        }
    }
};

#define MOD (1000000007)

int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    REP(k, N-1) {
        ll ub = (N-k-1)*D - k*C;
        ll lb = (N-k-1)*C - k*D;
        if ((A+lb <= B && B <= A+ub)  ) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


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

using P = pair<int,int>;
const int di[] = {1,0,-1,0};
const int dj[] = {0,1,0,-1};


int main() {
    // 頂点数と辺数
    int H, W; cin >> H >> W;
    int start_h, start_w; cin >> start_h >> start_w;
    int goal_h, goal_w; cin >> goal_h >> goal_w;
    start_h--,start_w--,goal_h--,goal_w--;
    vector<string> S(H);

    // グラフ入力受取 (ここでは無向グラフを想定)

    for (int i = 0; i < H; i++){
        cin >> S[i];
    }

    // BFS のためのデータ構造
    vector<vector<int>> dist(H, vector<int>(W,-1)); // 全頂点を「未訪問」に初期化
    deque<P> dq;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[start_h][start_w] = 0;
    dq.emplace_front( P(start_h, start_w) );

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!dq.empty()) {
        int i = dq.front().first; // キューから先頭頂点を取り出す
        int j = dq.front().second;
        dq.pop_front();

        // v から辿れる頂点をすべて調べる
        for (int nv = 0; nv < 4; nv++) {
            int next_i = i + di[nv], next_j = j + dj[nv];
            if (next_i >= H || next_j >= W || next_i <0 || next_j <0) continue;
            if (S[next_i][next_j] == '#') continue;
            if (dist[next_i][next_j] != -1 && dist[next_i][next_j] <= dist[i][j]) continue; // すでに発見済みの頂点は探索しない

            dist[next_i][next_j] = dist[i][j];
            dq.emplace_front(P(next_i,next_j));
        }
        for (int mi = -2; mi <=2; mi++){
            for (int mj = -2; mj <=2; mj++){
                int next_i = i + mi, next_j = j + mj;
                if (next_i >= H || next_j >= W || next_i <0 || next_j <0) continue;
                if (S[next_i][next_j] == '#') continue;
                if (dist[next_i][next_j] != -1 && dist[next_i][next_j] <= dist[i][j]+1) continue; // すでに発見済みの頂点は探索しない

                dist[next_i][next_j] = dist[i][j]+1;
                dq.emplace_back(P(next_i,next_j));
            }
        }

    }
    int ans = dist[goal_h][goal_w];
    cout << ans << endl;

}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;ll h;
    cin>>n>>h;
    vector<ll> v;
    ll ma = 0;
    for(int i=0;i<n;++i){
        ll a,b;
        cin>>a>>b;
        ma = max(ma,a);
        v.emplace_back(b);
    }
    sort(v.rbegin(),v.rend());
    vector<ll> s(n+1);
    s[0] = v[0];
    for(int i=1;i<n;++i)s[i] += s[i-1] + v[i]; 
    ll ret = (h+ma-1)/ma;
    for(int i=0;i<n;++i){
        if(v[i] <= ma)break;
        ll tmp = 0;
        tmp += i+1;
        if(h-s[i] > 0)tmp += (h-s[i]+ma-1)/ma;
        ret = min(ret,tmp);
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 5028
n = int(input())
a_ls = list(map(int, input().split()))
b_ls = list(map(int, input().split()))
c_ls = list(map(int, input().split()))
a_ls.sort()
b_ls.sort()
c_ls.sort()

# 「-より大きい」
def isOK_1(ind, key, ls):
    if ls[ind] > key:
        return True
    else: # if ls[ind] <= key
        return False


def connect_b2c_minind(key, ls):
    ok = len(ls)
    ng = -1
    while ok - ng > 1:
        mid = ng + (ok-ng) // 2
        if isOK_1(mid, key, ls):
            ok = mid
        else:
            ng = mid
    return len(ls) - ok

def isOK_2(ind, key, ls):
    if ls[ind] < key:
        return True
    else: # if ls[ind] >= key
        return False

def connect_a2b_maxind(key, ls):
    ok = -1
    ng = len(ls)
    while ng - ok > 1:
        mid = ok + (ng - ok) // 2
        if isOK_2(mid, key, ls):
            ok = mid
        else:
            ng = mid
    return ok + 1

ans = 0
for i in range(n):
    ans += connect_a2b_maxind(b_ls[i], a_ls) * connect_b2c_minind(b_ls[i], c_ls)
print(ans)

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int n; cin >> n;
    int max = 0, loc;
    int p[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
        if(max<p[i]){
            max = p[i];
            loc = i;
        }
    }
    int sum = 0;
    for(int i=0; i<n; i++){
        if(i==loc){
            sum=sum+p[i]/2;
        }
        else sum+=p[i];
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
	cin >> s;

	bool aa = 0 , bb = 0;

	fo(i,0,3)
	{
		aa |= (s[i] == 'A' );
		bb |= ( s[i] == 'B' );
	}

	if( aa and bb ) cout << "Yes\n";
	else cout << "No\n";

}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

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

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class DCake123 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int X, Y, Z, K;
	    in >> X >> Y >> Z >> K;
	    vector<ll> A(X), B(Y), C(Z);
	    REP(i,0,X) in >> A[i];
	    REP(i,0,Y) in >> B[i];
	    REP(i,0,Z) in >> C[i];
	    sort(all(A), greater<ll>());
	    sort(all(B), greater<ll>());
	    sort(all(C), greater<ll>());

	    vector<ll> cakes;
	    REP(i,0,X) {
	        REP(j,0,Y) {
	            REP(k,0,Z) {
	                if (i*j*k > K) break;
	                cakes.emplace_back(A[i] + B[j] + C[k]);
	            }
	        }
	    }
	    sort(all(cakes), greater<ll>());
	    REP(i,0,K) out << cakes[i] << "\n";
	}
};


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


Measured memory_bytes: 35176
S = raw_input()

first = int(S[0:2])
second = int(S[2:])

if first > 0 and first < 13:
    vmf = True
else:
    vmf = False
    
if second > 0 and second < 13:
    vms = True
else:
    vms = False

if vmf and vms:
    print "AMBIGUOUS"
elif vmf and not vms:
    print "MMYY"
elif not vmf and vms:
    print "YYMM"
else:
    print "NA"

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

using namespace std;

#define REP(i, a, b) for(ll i=a;i<b;i++)
#define REPR(i, a, b) for(ll i=b-1;i>=a;i--)
#define forr(i, n) for(ll i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define w(t) int t;cin>>t;while(t--)
#define W(t) ll t;cin>>t;while(t--)
#define endl '\n'
#define space ' '
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl

typedef long long ll;

// const int N = 2e5 + 5;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll N, D;
	cin >> N >> D;
	ll X, Y, ans = 0;
	for (ll i = 1; i <= N; i++) {
		cin >> X >> Y;
		if (X * X + Y * Y <= D * D)
		{	++ans;}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
/*
NAME:
 ___   _      _   ___  
/ __| /_\    /_\ |   \ 
\__ \/ _ \  / _ \| |) |
|___/_/ \_\/_/ \_\___/ 
 
lang: 
  ___   _      _   
 / __)_| |_  _| |_ 
( (__(_   _)(_   _)
 \___) |_|    |_|  
 
*/
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
 
using namespace std;
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
 
typedef long long ll;
typedef long l;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<l> vl;
typedef vector<ll> vll;
 
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
 
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }
 
void solve(){
	int n,m;
	cin>>n>>m;
	string a,b;
	int temp1=m,temp2=n;
	while(temp2--){
		b+='0'+m;
	}
	while(temp1--){
		a+='0'+n;
	}
	if(a[0]<=b[0]) cout<<a;
	else cout<<b;
	
}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
 
	solve();
 
	return 0;
} 


Measured memory_bytes: 256
fun main() {
    var (a, b, h, m) = readLine()!!.split(" ").map(String::toInt)
    val rad = 2 * Math.PI * ((h / 12.0) + (m / 60.0) / 12.0 - (m / 60.0))
    println(Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(rad)))
}





Measured memory_bytes: 36584
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define N 200001
#define ll long long
#define pi pair<int , int>
#define pip pair<pi ,int>
#define mp make_pair 
#define f first
#define s second
#define int ll 
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
// this is triplet class , which will help us .
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
// this is for finding inversing multiplicative module of a number.
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
      lps[i] = j+1;
   i++;
   j++;
  }
  else{
        if(j != 0){
         j = lps[j-1];
        }
        else{
         lps[i] = 0;
         i++;
        }
  }
 }
 return lps[len-1];
}


int32_t main(){
   ios_base::sync_with_stdio(false);
      cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    if(n >= 30){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    

    
}

Measured memory_bytes: 3652
S = str(input())
a = S[0]
b = S[1]
c = S[2]
d = S[3]
if a == b and a != c and c == d:
    print("Yes")
elif a == c and a != b and b == d:
    print("Yes")
elif a == d and a != c and b ==c:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

string S;
ll K, A,B;

int Main() {
    cin >> K >> A >> B;
    for (ll i=A; i<=B; i++) {
        if (i%K==0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    
    cout << "NG" << endl;
    
    return 0;
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3688
c_list = ["light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy"]
w_list = [48, 51, 54, 57, 60, 64, 69, 75, 81, 91]
while True:
    try:
        w = float(input())
        for i in range(10):
            if w <= w_list[i]:
                print(c_list[i])
                break
        else:
            print("heavy")
    except:
        break



Measured memory_bytes: 5576
#include <bits/stdc++.h>
#include <atcoder/fenwicktree>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using namespace atcoder;



int main() {
    cin.tie(nullptr);
    int N, Q; cin >> N >> Q;
    fenwick_tree<ll> bit(N+1);
    for (int i=0; i<N; i++) {
        int a; cin >> a;
        bit.add(i+1, a);
    }
    for (int q=0; q<Q; q++) {
        int d, l, r; cin >> d >> l >> r;
        if (d == 0) {
            bit.add(l+1, r);
        } else {
            cout << bit.sum(l+1, r+1) << "\n";
        }
    }
}

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

void call(int n);

int main()
{
    int n;
    cin >> n;
    call(n);
    return 0;
}


void call(int n) {
    int i = 1;
    do {
        int x = i;
        if(x % 3 == 0){
            cout << " " << i;
            continue;
        }
        do {
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
            x /= 10;
        } while (x != 0);
    } while (++i <= n);
    cout << endl;
}


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

int D,G;

int main(){
    cin >> D >> G;
    
    vector<int> p(D+1),c(D+1);
    
    for(int i=1; i<=D; i++){
        cin >> p[i] >> c[i];
    }
    
    
    int ans=1'000'000;
    //最後まで解く問題
    for(int bit=0; bit < (1<<D); bit++){
        int c_ans=0, score=0, toi=0;
        for(int i=1; i<=D; i++){
            if( bit >> (i -1) & 1){
                c_ans += p[i];
                //cout << c_ans << endl;
                score += i*100*p[i] + c[i];
            }else{
                //解いてない最も点数が高い問題
                toi=i;
            }
        }
        
        //点数が不足しているとき
        if(score < G){
            //必要問題数
            int toi_score = toi * 100;
            int x = (G - score + toi_score - 1)/toi_score;
            if(x > p[toi]){
                continue;
            }else{
                c_ans += x;
                score += toi * 100 *p[toi];
            }
            //ans = min(ans, c_ans);
        }else{
            //ans = min(ans, c_ans);
        }
        ans = min(ans, c_ans);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const double PI  =3.141592653589793238463;
long long mod = 1000000007;
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}
ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}
bool prime[1000000];
void seive()
{  memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=1000000;i++)
    {
         if(prime[i]==true) {
        for(int j=2*i;j<=(1000000);j+=i)
           { prime[j]=false;}

    }
    }

}

int main()
{
    int n,i;
    cin>>n>>i;
    cout<<n-i+1<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#define H 20+1
#define W 20+1
using namespace std;

signed char di[4] = { 1,0,-1,0 }; // i+, j+, i-, j-
signed char dj[4] = { 0,1, 0,-1};

typedef struct {
  char s[H][W]; // ÕÊÌóÔ
  char n;         // Ú®ñ
  char d;         // ±ê©çÚ®·éûü
  char i,j;       // »Ýn
} P;

int main(){
  short h,w, b;
  P p, p2;
  queue<P> q;
  short gi,gj;

  while( cin>>w>>h && (w||h) ){
    while( q.size()>0 ) q.pop();

    for( int i=1;i<=h;i++ )
      for( int j=1;j<=w;j++ ){
	cin >> b;
	p.s[i][j] = b;
	if( b==2 ){ p.i = i; p.j=j; p.s[i][j]=0; }
	else if( b==3 ){ gi=i; gj=j; }
      }
    p.n=1;
    for( int i=0;i<4;i++ ){
      p.d = i;
      q.push( p );
    }

    signed char ans = -1;
    while( q.size()>0 ){
      p = q.front(); q.pop();

      int i=p.i, j=p.j;
      bool f=true;
      while( f ){
	int in=i+di[p.d], jn=j+dj[p.d];

	if( in<1 || in>h || jn<1 || jn>w )
	  break;

	switch( p.s[ in ][ jn ] ){
	case 0: // ½àÈ¢
	  i=in; j=jn;
	  break;
	case 1: // áQ¨
	  if( p.i==i && p.j==j ){
	    f=false; break;
	  }
	  if( p.n==10 ){
	    f=false; break;
	  }else if( p.n==9 ){
	    if( i-gi!=0 && j-gj!=0 ){
	      f=false; break;
	    }
	  }
	  p2 = p;
	  p2.i=i; p2.j=j; p2.n++;
	  p2.s[ in ][ jn ] = 0; 
	  for( int k=0;k<4;k++ ){
	    p2.d = k; q.push( p2 );
	  }
	  f=false;
	  break;
	case 3: // S[
	  ans = p.n; f=false;
	  break;
	}
      }
      if( ans>0 ) break;
    }
    cout << (int)ans << endl;
  }

  return 0;
}

Measured memory_bytes: 16000
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>
using namespace std;
int read()
{
	char ch=getchar();
	int num=0,flus=1;
	while(ch<'0'||ch>'9')
	{if(ch=='-') flus=-flus;ch=getchar();}
	while(ch>='0'&&ch<='9')
	{num=num*10+ch-'0';ch=getchar();}
	return num*flus;
}
int main(void)
{
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d\n",6-a-b);
	return 0;
}
//	freopen("working.in","r",stdin);
//	freopen("working.out","w",stdout);

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var f = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var W = f[0];
            var H = f[1];
            var x = f[2];
            var y = f[3];
            var r = f[4];
            if (x + r > W)
            {
                Console.WriteLine("No");
            }
            else
            {
                if (x < r)
                {
                    Console.WriteLine("No");
                }
                else
                {
                    if (y + r > H)
                    {
                        Console.WriteLine("No");
                    }
                    else
                    {
                        if (y < r)
                        {
                            Console.WriteLine("No");
                        }
                        else
                        {
                            Console.WriteLine("Yes");
                        }
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 9304
#C-Back and Forth
sx,sy,tx,ty=map(int,input().split( ))
x=tx-sx
y=ty-sy
r1="U"*y+"R"*x
r2="R"+"D"*2+"L"*(x-1)+"D"*(y-1)+"L"*2+"U"
r3="R"+"U"*(y-1)+"R"*(x-1)+"U"
r4="U"+"L"*(x+1)+"D"*(y+1)+"R"
print(r1+r2+r3+r4)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair <int, int> ii;

const int Maxn = 55;
const int Inf = 1000000000;

int n;
ll a[Maxn];
vector <ii> res;

void Add(int x, int y)
{
	res.push_back(ii(x, y));
	a[y] += a[x];
}

int main()
{
	cin >> n;
	int mn = 1, mx = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] < a[mn]) mn = i;
		if (a[i] > a[mx]) mx = i;
	}
	if (a[mn] == a[mx]) { printf("0\n"); return 0; }
	if (-a[mn] > a[mx]) {
		for (int i = 1; i <= n; i++) if (i != mn)
			Add(mn, i);
		for (int i = n - 1; i >= 1; i--)
			if (a[i] > a[i + 1]) Add(i + 1, i);
	} else {
		for (int i = 1; i <= n; i++) if (i != mx)
			Add(mx, i);
		for (int i = 2; i <= n; i++)
			if (a[i - 1] > a[i]) Add(i - 1, i);
	}
	printf("%d\n", res.size());
	for (int i = 0; i < res.size(); i++)
		printf("%d %d\n", res[i].first, res[i].second);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int ara[3];
string str[MAX];
int main()
{
    fastRead;
    
    int n ;
    cin>>n;
    cin>>ara[0]>>ara[1]>>ara[2];
    
    bool ok = 1;
    
    vector<char>vec;
    
    for(int i =0 ; i < n ; i++ ) cin>>str[i];
    
    for(int i =0 ;  i < n ; i++) {
        
        string s = str[i];
        
        if( ara[ s[0]-'A'] > ara[s[1]-'A']) {
            ara[ s[0]-'A']--;
            ara[ s[1]-'A']++;
            vec.push_back(s[1]);
        }
        else if( ara[ s[0]-'A'] < ara[s[1]-'A'] ) {
            ara[ s[0]-'A']++;
            ara[ s[1]-'A']--;            
            vec.push_back(s[0]);
        }
        else {
                
            if( i < n -1 && (str[i+1][0] == s[0] || str[i+1][1] == s[0] ) ) {
                ara[ s[0]-'A']++;
                ara[ s[1]-'A']--;            
                vec.push_back(s[0]);
            }
            else {
                ara[ s[0]-'A']--;
                ara[ s[1]-'A']++;
                vec.push_back(s[1]);                
            }
        }
        
        if(ara[0] < 0 || ara[1] < 0 || ara[2] < 0 ) ok = 0;
    }
    if(!ok) cout<<"No\n";
    else {
        cout<<"Yes\n";
        for(auto x : vec) cout<<x<<'\n';
    }
    return 0;
}

Measured memory_bytes: 35028
N,M = map(int,input().split())
L = list(list(map(int,input().split())) for i in range(M))

A = [1 for i in range(N+1)]

red = [0 for i in range(N+1)]
red[1] = 1

ans = 1
for i in range(M) :
    A[L[i][0]] -= 1
    A[L[i][1]] += 1
    if red[L[i][0]] == 1 :
        red[L[i][1]] = 1
    if A[L[i][0]] == 0 :
        red[L[i][0]] = 0
        
ans = sum(red)
print(ans)


Measured memory_bytes: 29044
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let mut s=read::<i32>();
    let mut i=2;
    while s>1{s=if s%2==0{s/2}else{s*3+1};i+=1}
    println!("{}",if i<4{4}else{i})
}

Measured memory_bytes: 4352
#include<cstdio>
#include<algorithm>
using namespace std;
using ull = unsigned long long;

int Digits(ull n){
	int res = 1;
	while(n /= 10){
		res++;
	}
	return res;
}

int main(){
	ull N;
	scanf("%llu", &N);
	int answer = Digits(N);
	for (ull i = 2; i*i <= N; ++i){
		if(!(N % i)) answer = min(answer, Digits(N/i));
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 128
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n)) #親ノード
        self.size = [1]*n #グループの要素数
 
    def root(self, x): #root(x): xの根ノードを返す．
        while self.parent[x] != x:
            x, self.parent[x] = self.parent[x], self.parent[self.parent[x]]
        return x 
 
    def merge(self, x, y): #merge(x,y): xのいる組とyのいる組をまとめる
        x, y = self.root(x), self.root(y)
        if x == y: return False
        if self.size[x] < self.size[y]: x,y=y,x #xの要素数が大きいように
        self.size[x] += self.size[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True
 
    def issame(self, x, y): #same(x,y): xとyが同じ組ならTrue
        return self.root(x) == self.root(y)
        
    def size(self,x): #size(x): xのいるグループの要素数を返す
        return self.size[self.root(x)]
#>>>>>>>>>>>>>>EhdCutHere>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

n,m = list(map(int,input().split()))
p = list(map(lambda x: int(x)-1,input().split()))

uf = UnionFind(n)
for i in range(m):
    x,y=list(map(int,input().split()))
    uf.merge(x-1,y-1)

ans = 0
for i in range(n):
    if uf.issame(i,p[i]):
        ans += 1

print(ans)
#print([uf.root(i) for i in range(n)])
#print([uf.parent[i] for i in range(n)])
#print([uf.size(i) for i in range(n)])



Measured memory_bytes: 14324