akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repb(i, n) for (int i = (n-1); i >= 0; i--)
#define rea(i, a, b) for (int i = (a); i < (b); i++)
#define reab(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(),(a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
inline ll divceil(ll a, ll b){return (a+b-1) / b;}
const int MOD = 1000000007;
/* END OF TEMPLATE */

int main(){
    ll r, d, x;
    cin >> r >> d >> x;
    rep(i, 10){
        x = r * x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll left,right;
    cin>>left>>right;
    if(right-left>=2019)
    {
        cout<<"0";
        exit(0);
    }
    if(left%2019>right%2019)
    {
        cout<<"0";
        exit(0);
    }
    ll ans=INF,store;
    for(ll i=left;i<=right;i++)
    {
        for(ll j=i+1;j<=right;j++)
        {
            store=(i*j)%2019;
            ans=min(ans,store);
        }
    }
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  l=[I() for _ in range(5)]

  mn=inf
  for c in itertools.permutations(l,5):
    t=0
    for x in c:
      if t%10==0:
        t+=x
      else:
        t+=10-(t%10)
        t+=x

    mn=min(mn,t)

  return mn

# main()
print(main())


Measured memory_bytes: 6476
#include<stdio.h>

int main(){
	int N,K,i,j,tmp,ans;
	scanf("%d %d",&N,&K);
	int p[N];
	for(i = 0; i < N; i++){
		scanf("%d",&p[i]);
	}
	for(i = 0; i < N; i++){
		for(j = i + 1; j < N; j++){
			if(p[i] > p[j]){
				tmp = p[i];
				p[i] = p[j];
				p[j] = tmp;
			}
		}
	}
	ans = 0;
	for(i = 0; i < K; i++){
		ans += p[i];
	}
	printf("%d",ans);

	return 0;
}


Measured memory_bytes: 1700
#include<iostream>
using namespace std;
 
int main(){
int N;
int T[101];
int sum=0;
cin>>N;
for(int i=1;i<=N;i++){
cin>>T[i];
sum+=T[i];
}
int M;
cin>>M;
for(int i=0;i<M;i++){
int p,x;
cin>>p>>x;
cout<<sum-T[p]+x<<endl;
}
return 0;
}

Measured memory_bytes: 256
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;


int n;
ll ret,facto[1001];
const ll mod = 1000000007;

void factor( int n ){
    if (n == 1) return;
    FOR(i,2,n+1){
        if (n%i == 0){
            facto[i]++;
            return factor(n/i);
        }
    }
}

int main(){
    I(n);
    REP(i,n+1) facto[i] = 1;
    REP(i,n+1) factor(i);
    ll ret = 1;
    REP(i,n+1) {
        ret *= facto[i];
        ret %= mod;
    }
    cout << ret << endl;
}


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

using namespace std;

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

    int n, a, b, ta, tb;
    cin >> n >> a >> b;
    while (--n)
    {
        cin >> ta >> tb;

        if (ta <= a || tb <= b)
        {
            int mx = max((a - 1) / ta + 1, (b - 1) / tb + 1);
            a = ta * mx, b = tb * mx;
        }
        else
            a = ta, b = tb;
    }
    cout << a + b << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  // input
  int s; cin >> s;
 
  // compute
  vector<int> a(10000000);
  vector<int> c(10000000);
  int ans = 0;
 
  a[1] = s;
  c[s] = 1;
  
  for(int i = 2;i < 10000000; i++){
    if(a[i-1] % 2 == 0){
        a[i] = a[i-1] / 2 ;
        if(c[a[i]] == 1){
            ans = i;
            break;
        }else{
            c[a[i]] = 1;
        }
    }else{
        a[i] = (a[i-1] * 3) + 1;
        if(c[a[i]] == 1){
            ans = i;
            break;
        }else{
            c[a[i]] = 1;
        }
    }
  }
  
  // output  
  cout << ans << endl;
  
}

Measured memory_bytes: 81368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int N = 100000;
const int W = 100;
bool vis[N][W];

struct edge{ int to,cost; };
vector<edge> G[N];

const int INF = 19191919;

int main(){
    int n,m,w;
    scanf(" %d %d %d", &n, &m, &w);

    rep(i,m){
        int s,t,c;
        scanf(" %d %d %d", &s, &t, &c);
        G[s].pb({t,c});
    }

    queue<pi> que;
    rep(i,n) que.push({i,0});
    while(!que.empty()){
        pi now = que.front();
        que.pop();

        int v = now.fi, c = now.se;
        for(const auto &e:G[v]){
            int nv = e.to;
            int nc = c+e.cost;
            if(nc<W && !vis[nv][nc]){
                vis[nv][nc] = true;
                que.push({nv,nc});
            }
        }
    }

    int ans = -INF;
    rep(i,n){
        rep(j,-w)if(vis[i][j]) ans = max(ans, j+w);
    }
    if(ans == -INF) printf("NA\n");
    else printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 39732
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int n;
    cin >> n;
    cout << 180 * (n - 2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<random>
#include <cassert>

using namespace std;

typedef long long ll;
const ll INF = 1<<30;

int main()
{

    int N;
    cin >> N;
    ll *a = new ll[N + 1];
    for (int i = 1; i <= N; i++){
        cin >> a[i];
    }

    // process exception first
    if (N == 1){
        cout << a[1] << endl;
        cout << 0 << endl;
    }
    assert (N > 1);

    bool *used = new bool[N + 1];
    fill(used, used+N+1, false);

    int rp = -1;
    ll rs = -INF;
    for (int p = 1; p <= 2; p++){
        // find maximum index (mi) first
        int mi = p;
        for (int i = p; i <= N; i += 2){
            if (a[i] > a[mi]){
                mi = i;
            }
        }

        ll sum = 0;
        if (a[mi] <= 0){ // if maximum element is negative, select only maximum element
            sum += a[mi];
            used[mi] = true;
        } else {
            for (int i = p; i <= N; i += 2){
                if (a[i] > 0){
                    sum += a[i];
                    used[i] = true;
                }
            }
        }

        //update if necessary
        if (sum > rs){
            rs = sum;
            rp = p;
        }
    }
    assert (rp != -1);

    vector<int> ret;
    int cnt;
    for (int i = rp + ((N - rp)/2) * 2 ; i > 0; i -= 2){
        if (used[i]){
            cnt++;
        } else {
            ret.push_back(i);
        }
    }

    if (rp != 1 || !used[1]){
        ret.push_back(1);
    }

    if ((N - rp) % 2 == 0 && used[N]){
        cnt--;
    }

    for (int i = 0; i < cnt; i++){
        ret.push_back(2);
    }

    cout << rs << endl;
    cout << ret.size() << endl;
    for (int i : ret){
        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf p
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n;
	cin>>n;
	int cur = 1;
	for(int i=1;i<=20;i++){
		if( cur == n ){
			cout<<"No"<<endl;
			return 0;
		}
		cur *= 2;
	}
	vector< pair<int,int> > ed;
	ed.pb( mp(1,2) );
	ed.pb( mp(2,3) );
	ed.pb( mp(3,n+1) );
	ed.pb( mp(n+1,n+2) );
	ed.pb( mp(n+2,n+3) );
	for(int i=4;i<=n-1;i+=2){
		ed.pb(mp(i,1));
		ed.pb(mp(i+1,i));
		ed.pb(mp(1,i+1+n));
		ed.pb(mp(i+1+n,i+n));
	}
	if( n % 2 == 0 ){
		for(int i=4;i<=n-1;i++){
			if( (n^1^i) >= 4 && (n^1^i) != i && (n^1^i)<=n-1 ){
				int a = i;
				int b = n^i^1;
				if( a%2 ) a+=n;
				if( b%2 ) b+=n;
				ed.pb(mp(a,n));
				ed.pb(mp(b,n+n));
				goto endd;
			}
		}
		for(int i=4;i<=n-1;i++){
			if( (i^3) == n ){
				int a = i;
				if( a%2 ) a+=n;
				ed.pb( mp( a, n ) );
				ed.pb( mp( 2, n+n ) );
				goto endd;
			}
		}
		endd: n = n + 0;
	}
	cout<<"Yes"<<endl;
	for(int i=0;i<ed.size();i++){
		cout<<ed[i].first<<" "<<ed[i].second<<endl;
	}		
	return 0;
}

Measured memory_bytes: 6384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double answer = 0;
		for(int i=0; i<N; i++) {
			double A = sc.nextDouble();
			answer += 1.0/A;
		}
		answer = 1.0/answer;
		System.out.println(answer);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(ll a,ll b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int year(ll n) {
	return mod(n, 3650);
}

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

  int n;
	ll memo[50];
	memo[0] = 1;
	memo[1] = 1;
	memo[2] = 2;
	for(int i = 3; i <= 30; i++) {
		memo[i] = memo[i - 1] + memo[i - 2] + memo[i - 3];
	}
	while(1) {
		cin >> n;
		if(!n) break;
		cout << year(memo[n]) << endl;
	}
  return 0;
}



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

long long combi(long long n) {
    return n*(n - 1) /2;
}

int main(){
  map<int,int> mball;
  map<int,long long> reball;
  int N,a;
  long long sum=0,bcombi,acombi;
  vector<int> vball;
  cin >> N;
  for(int i = 0;i < N;i++){
  	cin >> a;
    vball.push_back(a);
    mball[a] += 1;
  }
  for(auto itr = mball.begin(); itr != mball.end(); ++itr) {
        if(itr->second ==  1){
        }else{
          	reball[itr->second] = combi(itr->second);
        	sum += reball[itr->second];
        }
    }
  for(int i = 0;i < N;i++){
    bcombi=0,acombi=0;
	auto itr = mball.find(vball.at(i));
    if( itr != mball.end()) {
        bcombi = reball[itr->second];
      	acombi = combi((itr->second - 1));
      }
    cout << sum + acombi - bcombi<< endl;
  }
  
}


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

#define REP(i,n) for (long long i=0;i<(n);i++)
#define REPT(i,t,n) for (long long i=t;i<(n);i++)

int Result_int;
long Result_lng;
string Result_str = "";
//int A,B,C;
long long N,left,t;
//char S,target;
string S;

int main() {
    long r_white = 0,r_black = 0,n;
    long ignore_white = 0,ignore_black= 0;
    long left_b=0,right_w;
    char white = '.';
    char black = '#';
    cin >> N;
    cin >> S;
    REP(i,N) {
        if (S[i] == white) {
            r_white++;
        }
    }
    long Result_min = r_white;

    REP(i,N) {
        if (S[i] == white) {
            r_white--;
        } else {
            left_b++;
        }
        Result_min = min(Result_min, left_b + r_white);
    }

    cout << Result_min << endl;
}





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

int main()
{
    int n;
    cin>>n;
    if(n==1)
    {
        cout<<"Hello World"<<endl;
    }
    else
    {
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
//int n,m,c;
string s;
int main()
{
	cin>>s;
	if(s[s.size()-1]=='s') cout<<s<<"es"<<endl;
	else cout<<s<<"s"<<endl; 
//	scanf("%s%d%d",&n,&m,&c);
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
from itertools import combinations

def readlines(n):
    for _ in range(n):
        yield list(map(int,input().split()))

def bene(me, f, p):
    a = sum(1 if f[m] == 1 else 0 for m in me)
    return p[a]

def main():
    n = int(input())
    F = list(readlines(n))
    P = list(readlines(n))

    for i in range(1, 11):
        for comb in combinations(range(10), i):
            yield sum(bene(comb, f, p) for f, p in zip(F,P))

    
print(max(main()))

Measured memory_bytes: 3064
def solve(a, b, k):
    d = min(a, k)
    a -= d
    k -= d
    d = min(b, k)
    b -= d
    return "%d %d" % (a, b)

assert solve(2, 3, 3) == "0 2"
assert solve(500000000000, 500000000000, 1000000000000) == "0 0"

a, b, k = map(int, input().split())
print(solve(a, b, k))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
int main(){
char a,b;
cin >>a>>b;
if (a=='H'){
    if (b=='H')
        cout<<"H"<<endl;
    else if(b=='D')
        cout<<"D"<<endl;
      
}else if (a=='D'){
    if (b=='D')
        cout<<"H"<<endl;
    else if(b=='H')
        cout<<"D"<<endl;
}

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<limits.h>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<set>
#include<vector>
#include<queue>
#include<set>
#include<stdlib.h>
#include<time.h>
using namespace std;
typedef long long ll;
#define inf	1000000
typedef pair<int,int>	P;
int road[10][10];
int n;
int used[10];
void init(){
	memset(used,false,sizeof(used));
	fill_n(&road[0][0],10*10,1000);
	for(int i=0;i<10;i++){
		road[i][i]=0;
	}
}

void floyd(){
	for(int k=0;k<10;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				if(used[k]&&used[i]&&used[j]){
					if(road[i][k]+road[k][j]<road[i][j]){
						road[j][i]=road[i][j]=road[i][k]+road[k][j];
					}
				}
			}
		}
	}
}

void solve(int &city,int &cost){
	floyd();
	for(int i=0;i<10;i++){
		if(used[i]){
			int sum=0;
			for(int j=0;j<10;j++){
				if(used[j]){
					sum+=road[i][j];
				}
			}
			if(sum<cost){
				cost=sum;
				city=i;
			}else if(sum==cost){
				city=min(city,i);
			}
		}
	}
}

int main() {
	
	int a,b,c;
	while(scanf("%d",&n)!=EOF){
		if(n==0){
			break;
		}
		init();
		while(n--){
			scanf("%d%d%d",&a,&b,&c);
			road[a][b]=road[b][a]=c;
			used[a]=used[b]=true;
		}
		int city=10,cost=INT_MAX;
		solve(city,cost);
		printf("%d %d\n",city,cost);
	}
	return 0;
}


Measured memory_bytes: 3204
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int W,H,x,y;
int L[104];
int ans=0;
signed main(){
    scanf("%lld %lld %lld %lld",&W,&H,&x,&y);
    float menseki=0;
    if(x==W||x==0||y==H||y==0||x*2!=W||y*2!=H){
        ans=0;
    }else{
        ans=1;
    }
    printf("%lf %lld\n",(double)W*H/2,ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
const int maxn = 100000 + 10;

template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int Gcd, N, K, Max = 0;
int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif
    
    cin >> N >> K >> Gcd;

    Max = Gcd;
    for(int i = 1; i < N; ++i) {
        int x;
        cin >> x;
        Max = max(Max, x);
        Gcd = __gcd(Gcd, x);
    }
    puts((K % Gcd || K > Max) ? "IMPOSSIBLE":"POSSIBLE");
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <unordered_map>

using namespace std;


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

  long long n, c, k;
  cin >> n;
  vector<long long> s;
  for (long long i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    s.push_back(x);
  }
  sort(s.begin(), s.end());
  long long s1 = 0;
  long long ind = 0;
  for (long long i = 0; i < n - 1; ++i) {
    s1 += 2 * s[i];
    if (s1 < s[i + 1]) {
      ind = i + 1;
    }
  }
  cout << n - ind << endl;
  return 0;
}


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

using namespace std;

int main(){

  while(1){
    int N,M;
    cin>>N;
    cin>>M;

    if(N == 0 && M == 0){
      break;
    }

    vector<pair<int,int>> Q;
    for(int i = 0;i < N;++i){
      int d,v;
      cin>>d;
      cin>>v;

      Q.push_back(make_pair(d,v));
    }

    sort(Q.begin(),Q.end());
    reverse(Q.begin(),Q.end());

    int fi = 0;
    int ans = 0;
    for(pair<int,int> e : Q){
      int e2;
      if(fi == 0){
        e2 = e.first;
        ans += e.second;
        fi = 1;
      }
      else{ 
        if(e2 != e.first){
          ans += e.second;
          e2 = e.first;
        }
      }
    }
    cout<<ans<<endl;
  }

  return 0;

}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll n; cin>>n;
  string s; cin>>s;
  vi r(n,0),w(n,0);
  rep(i,n){
    if(s[i]=='R'){
      if(i==0) r[i]=1;
      else{
        r[i]=r[i-1]+1;
        w[i]=w[i-1];
      }
    }
    else{
      if(i==0) w[i]=1;
      else{
        w[i]=w[i-1]+1;
        r[i]=r[i-1];
      }
    }
  }
  ll ans=min(r[n-1],w[n-1]);
  rep(i,n-1){
    chmin(ans,max(w[i],r[n-1]-r[i]));
  }
  out(ans);
}

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


Measured memory_bytes: 6772
#include <stdio.h>

int main(){
    int h;
    int n;
    int a;
    int i;

    scanf("%d %d", &h, &n);
    for(i=0;i<n;i++){
        scanf("%d", &a);
        h -= a;
    }
    
    if(h <= 0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;


int main()
{
    const int INF = 1e9;
	cin.tie(0);
	ios::sync_with_stdio(0);

    int H, N;
    cin >> H >> N;

    vector<int> dp(H+1, INF);
    dp[0] = 0;

    rep(i, N) {
        int A, B;
        cin >> A >> B;
        for (int h = 1; h <= min(A,H); ++h) {
            dp[h] = min(B, dp[h]);
        }
        for (int h = A+1; h <= H; ++h) {
            dp[h] = min(B+dp[h-A], dp[h]);
        }
    }

    cout << dp[H] << endl;

    return 0;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

int main() {
    int N,A,B;
    cin >> N >> A >> B;

    int N1=0,N2=0,N3=0;
    REP(i,N){
        int p;
        cin >> p;

        if(p <= A) N1++;
        else if(p <= B) N2++;
        else N3++;
    }

    pl(min(N1,min(N2,N3)))

    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    float d, t ,s;
    cin >> d >> t >> s;
    if(d/s <= t) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3716
N,M=map(int,input().split())
d={i:[] for i in range(1,N+1)}
for _ in range(M):
  a,b=map(int,input().split())
  d[a].append(b)

s=d[1]
f=True
for i in s:
  if N in d[i]:
    print("POSSIBLE")
    f=False
    break
if f:print("IMPOSSIBLE")

Measured memory_bytes: 46148
n, a, b = map(int, input().split())
s = list(input())
x, y = 0, 0
for i in s:
    if i == "a":
        if x + y < a + b:
            x += 1
            print("Yes")
        else:
            print("No")
    elif i == "b":
        if x + y < a + b and y < b:
            y += 1
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 10000
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    if(n<1000) cout << "ABC";
    else cout << "ABD";
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define mod 1000000007
using namespace std;

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



    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
/*Jai Bhole Nath */
#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
#define int long long int
#define f(i,a,n)    for(int i = a; i < (n); ++i)
#define fe(i, a, n)  for(int i = a; i <= (n); ++i)
#define fr(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define input(arr,n) for(int i=0;i<n;i++) cin>>arr[i];
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

void solve()
{
    int x;
    cin >> x;
    if(x == 0)
    {
        cout << 1 << endl;
    }
    else if(x == 1)
    {
        cout << 0 << endl;
    }


}

signed main()
{
    FIO;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
   // cin >> t;
    while(t--)
        solve();
    return 0;
}



Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  ll sum=0;
  int n;
  cin >> n;
  int i;
  for(i=1;i<=n;i++){
    if(n%i==0){
      sum+=n/i-1;
    }
    else{
      sum+=n/i;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int a[100000],b[100000],c[100000];
int dp[100001][3];
int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> a[i] >> b[i] >> c[i];
  dp[0][0]=0;dp[1][0]=a[0];dp[1][1]=b[0];dp[1][2]=c[0];
  for(int i=1;i<n;i++){
    dp[i+1][0]=max(dp[i][1]+a[i],dp[i][2]+a[i]);
    dp[i+1][1]=max(dp[i][0]+b[i],dp[i][2]+b[i]);
    dp[i+1][2]=max(dp[i][0]+c[i],dp[i][1]+c[i]);
  }
  cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << "\n";
  
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[16];
bool B[16];
int X[16][16],Y[16][16];
int M=0;

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
		REP(j,A[i]){
			cin>>X[i][j]>>Y[i][j];
		}
	}
	REP(Bit,1<<N){
		REP(i,N){
			if(Bit&(1<<i)){
				B[i]=1;
			}
			else{
				B[i]=0;
			}
		}
		bool flag=true;
		REP(i,N){
			REP(j,A[i]){
				if(B[i]==1){
					if(B[X[i][j]-1]!=Y[i][j]){
						flag=false;
					}
				}
			}
		}
		int ans=0;
		if(flag==true){
			REP(i,N){
				if(B[i]==1)ans++;
			}
			M=max(M,ans);
		}
	}
	cout<<M<<endl;
	return 0;
}


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

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

	int n, m;
	cin >> n >> m;
	vector<int> s(m), c(m);
	for(int i=0; i<m; i++) cin >> s[i] >> c[i];

	for(int i=0; i<1000; i++) {
		string x = to_string(i);
		if(x.size() == n) {
			bool valid=1;
			for(int j=0; j<m; j++) {
				if(x[s[j]-1] != ('0' + c[j])) valid=0;	
			}
			if(valid) {
				cout << i;
				return 0;
			}
		}
	}
	cout << -1;
    return 0;
}


Measured memory_bytes: 256
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

# 移動量が最大2から最大Kになっただけ
# でもちょっとめんどい
# K回比較, を適当に関数にしとくことでforで回せるようになるらしい

dp=[float("inf")]*N
dp[0]=0
for i in range(1,N):
    for j in range(K):
        if i>j:
            dp[i] = min(dp[i], dp[i-j-1] + abs(H[i] - H[i-j-1]))
        # print(dp[i])
    # print(dp)
print(dp[N-1])

Measured memory_bytes: 85060
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>


// boost
#define USE_BOOST_IN_CODE
#ifdef USE_BOOST_IN_CODE
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/strided.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/format.hpp>
#endif


using ll = long long;

//vector
template <class T>
using vec = std::vector<T>;

//namespace std
//{
//    template<>
//    class hash<Key>
//    {
//    public:
//        size_t operator() (const Key& key) const
//        {
//            size_t seed = 0;
//            auto i_hash = hash<int>()(key.i_th);
//            auto w_hash = hash<int>()(key.W);
//
//            seed ^= i_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
//            seed ^= w_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
//
//            return seed;
//        }
//    };
//}

void solve()
{
    using namespace std;

    int count {};
    int n;
    while (cin >> n)
    {
        if (n == 0)
            break;

        vec<int> v(n);
        for (auto& x : v)
            cin >> x;

        boost::sort(v);

        cout << accumulate(v.cbegin() + 1, v.cend() - 1, 0) / (n - 2) << endl;
        ++count;
    }

}

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


Measured memory_bytes: 2992
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> num(3);
  for (int i=0; i<3; i++){
    cin >> num[i];
  }
  int cnt = 0;
  for (int i=0; i<3; i++){
    for (int j=0; j<3; j++){
      if(num[i]==num[j]){
        cnt++;
      }
    }
  }
  if(cnt-3 == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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


void solve(ll X, ll Y, ll Z)
{
    cout<<Z<<" "<<X<<" "<<Y<<endl;
}


int main()
{
    ll X;
    cin >> X;
    ll Y;
    cin >> Y;
    ll Z;
    cin >> Z;
    solve(X, Y, Z);
    return 0;
}


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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] AB = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            bool res = false;
            if(AB[0]%3==0){
                res = true;
            }else if(AB[1]%3==0){
                res = true;
            }else if((AB[0]+AB[1])%3==0){
                res = true;
            }
            Console.WriteLine(res?"Possible":"Impossible");
        }
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vec vector
#define psb push_back
#define ppb pop_back
#define mkp make_pair
#define fst first
#define scd second
#define ins insert
#define psf push_front
#define ppf pop_front
using namespace std;
ll modExp(ll a, ll b, ll c) {
	a %= c;
	ll ans = 1;
	for(; b; b >>= 1) {
		if(b & 1){
			ans *= a;
			ans %= c;
		}
		a *= a;
		a %= c;
	}
	return ans;
}
int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n,a,b;
	cin>>n>>a>>b;
	if(a>b)
		swap(a,b);
	ll ans;
	if((b-a)%2==0)
		cout << ((b-a)>>1);
	else if(a-1<n-b)
		cout << ((b-1-a)>>1) + a;
	else
		cout << (n-b)+1+((b-1-a)>>1);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

	class Trie {
		int[][] next;
		int states;

		public Trie() {
			next = new int[2][(int) 2e5];
			states = 1;
			for (int[] i : next) {
				Arrays.fill(i, -1);
			}
		}

		void add(String s) {
			int cur = 0;
			for (char c : s.toCharArray()) {
				c -= '0';
				if (next[c][cur] == -1) {
					next[c][cur] = states++;
				}
				cur = next[c][cur];
			}
		}

		long get(long len) {
			return get(0, len);
		}

		long get(int cur, long len) {
			if (len < 0) {
				return 0;
			}
			if (cur == -1) {
				len++;
				return 1L << (Long.numberOfTrailingZeros(len));
			}

			return get(next[0][cur], len - 1) ^ get(next[1][cur], len - 1);
		}
	}

	void solve() {
		int n = in.nextInt();
		long l = in.nextLong();
		Trie t = new Trie();
		int[] grundy = new int[100];
		grundy[0] = 1;
//		for (int i = 1; i < grundy.length; i++) {
//			Set<Integer> set = new HashSet<>();
//			set.add(0);
//			for (int d = i - 1; d >= 0; d--) {
//				int cur = 0;
//				for (int j = d; j <= i + 1; j++) {
//					cur ^= grundy[j];
//				}
//				set.add(cur);
//			}
//			while (set.contains(grundy[i])) {
//				grundy[i]++;
//			}
//			System.err.println(i + " " + grundy[i]);
//		}

		for (int i = 0; i < n; i++) {
			t.add(in.nextToken());
		}
		out.println(t.get(l) == 0 ? "Bob" : "Alice");
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

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


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

int limit;
int dfs( int n )
{
	if ( n == limit ) return 1;
	if ( n > limit ) return 0;
	int count = 0;
	for ( int i = 1; i <= 3; i++ )
	{
		count += dfs( n+i );
	}
	return count;
}

int calc( int n )
{
	limit = n;
	int count = dfs( 0 );
	return count / 10;
}

int calc2( int n )
{
	vector <int> dp(n+4,0);
	dp[1] = dp[2] = dp[3] = 1;
	for ( int i = 1; i <= n; i++ )
	{
		for ( int j = 1; j <= 3; j++ ) dp[i+j] += dp[i];
	}
	return dp[n] / 10;
}

int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		int days = calc2( n );
		cout << days/365+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = 0
for i in range(min(N, K) + 1):
    for j in range(i+1):
        Juel = V[:j] + V[N-i+j:]
        Juel.sort()
        sum_v = 0
        for k in range(min(K-i, i)):
            Juel[k] = max(Juel[k], 0)
        ans = max(ans, sum(Juel))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
main(){
 char c;
 cin >> c;
 if (c == 'a' || c == 'i' || c == 'u' || c == 'e' ||c == 'o'){
 cout << "vowel" << endl; 
}
else
{
 cout << "consonant" << endl; 
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
vector<ll> Dijkstra_list(int n, int s, vector<vector<pair<ll, ll>>> &Edge) {
    vector<bool> visited(n, false); //確定済み
    vector<ll> d(n, __LONG_LONG_MAX__ / 3);
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
        que; //頂点とsからの距離
    d[s] = 0;
    que.push(make_pair(0, s));
    while(!que.empty()) {
        auto now = que.top();
        que.pop();
        visited[now.second] = true;
        for(auto e : Edge[now.second]) {
            if(visited[e.second])
                continue;
            if(d[e.second] > d[now.second] + e.first) {
                d[e.second] = d[now.second] + e.first;
                que.push(make_pair(d[e.second], e.second));
            }
        }
    }
    return d;
}
int main() {
    int l, n;
    cin >> l >> n;
    vector<vector<pair<ll, ll>>> edge(l);
    for(int i = 0; i < n; i++) {
        ll l, r, c;
        cin >> l >> r >> c;
        l--, r--;
        edge[l].push_back(make_pair(c, r));
    }
    for(int i = 0; i < l - 1; i++) {
        edge[i + 1].push_back(make_pair(0LL, i));
    }
    auto ans = Dijkstra_list(l, 0, edge);
    if(ans[l - 1] == LLONG_MAX / 3) {
        cout << -1 << endl;
    } else {
        cout << ans[l - 1] << endl;
    }
}


Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N, i=0;
  cin >> N;
  
  int sum=0, num=N;
  
  while(num != 0){
    int dig;
    dig = num%10;
    sum += dig;
    num /= 10;
    i++;
  }
  
  if(N%sum == 0){cout << "Yes" << endl;}
  else{cout << "No" << endl;} 
}

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

yen = {}

for i in range(len(s)):
    if s[i] in yen:
        yen[s[i]] += 1
    else:
        yen[s[i]] = 1

for name in yen.keys():
    for i in t:
        if i == name:
            yen[name] -= 1

if max(yen.values()) < 0:
    print(0)
else:
    print(max(yen.values()))

Measured memory_bytes: 3064
n = int(input())
x = int(input(),2)
pc = 0
d = []
c = x
for i in range(n):
    d.append(c&1)
    if c&1 == 1:
        pc += 1
    c=c>>1
mp = x%(pc+1)
if pc == 1:
    mm = -1
else:
    mm = x%(pc-1)
for i in range(n):
    if d[-i-1]==0:
        temp = (mp+pow(2,n-i-1,pc+1)) % (pc+1)
        ans = 1
    else:
        if mm == -1:
            temp = 0
            ans = 0
        else:    
            temp = (mm-pow(2,n-i-1,pc-1)) % (pc-1)
            ans = 1
    while temp:
        c = temp
        temppc = 0
        while c:
            if c&1 == 1:
                temppc += 1
            c=c>>1
        if temppc == 0:
            break
        temp = temp % temppc
        ans += 1
    print(ans)

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

int get(set<pair<int,int>> s, int a, int b) {
    int ans = 0;
    while (!s.empty()) {
        auto p = *s.begin();
        s.erase(s.begin());
        ans++;
        while (s.count({p.first-a,p.second-b})) {
            s.erase({p.first-a,p.second-b});
            p = {p.first-a,p.second-b};
        }
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    set<pair<int,int>> s;
    vector<pair<int,int>> v;
    for (int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        s.insert({x,y});
        v.push_back({x,y});
    }
    int ans = n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int a = v[i].first-v[j].first;
            int b = v[i].second-v[j].second;
            if (a != 0 || b != 0) ans = min(ans,get(s,a,b));
        }
    }
    cout << ans << '\n';
}



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

using namespace std;

int main()
{
    int n,i,j,flag=0;
    char str[30];
    cin>>str;
    n=strlen(str);
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(str[i]==str[j])
            {
                flag=1;
                break;
            }
        }
        if(flag)
            break;
    }
    if(!flag)
        cout<<"yes";
    else
        cout<<"no";

}


Measured memory_bytes: 3640