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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
const int maxn=1e5+10;
vector<int> ans;
char a[maxn];
int n,m;

int main(){
	io;
	cin>>n>>m>>a;
	int now=n;
	while(now>0){
		// dbg(now);
		bool ok=false;
		for(int i=m;i>=1;i--){
			if(now-i<0)continue;
			if(a[now-i]=='0'){
				ok=true;
				now-=i;
				ans.pb(i);
				break;
			}
		}
		if(!ok){
			cout<<-1<<endl;
			return 0;
		}
	}
	for(int i=sz(ans)-1;i>=0;i--){
		if(i!=sz(ans)-1)cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;
	return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) {
        cnt++;
      }
    }
    if (cnt == 8 && i % 2 != 0) {
      ans++;
    }
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""One line explanation of c.py.

More explanations of c.py."""

import sys


def reader(fin):
    result = []
    for i in xrange(3):
        result.append([int(c) for c in fin.readline().strip().split(' ')])
    return result


def check_one_dir(m):
    for i in xrange(1, 3):
        d = m[i][0] - m[0][0]
        for j in xrange(1, 3):
            if m[i][j] - m[0][j] != d:
                return False
    return True

def trans(m):
    result = [[0, 0, 0] for i in xrange(3)]
    for i in xrange(3):
        for j in xrange(3):
            result[i][j] = m[j][i]
    return result

def checker(m):
    return check_one_dir(m) and check_one_dir(trans(m))

def main(argv):
    m = reader(sys.stdin)
    ans= 'No'
    if checker(m):
        ans = 'Yes'
    sys.stdout.write('%s\n' % ans)

if __name__ == '__main__':
    main(sys.argv)


Measured memory_bytes: 2696
n = gets.to_i

if n % 4 == 0 || n % 7 == 0 || n % 11 == 0
  puts 'Yes'
else
  (0..25).each do |x|
    (0..14).each do |y|
      if n == (4 * x) + (7 * y)
        puts 'Yes'
        exit
      end
    end
  end
  puts 'No'
end

Measured memory_bytes: 1788
MODE = "stdio"

line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = "\
  3 4
  5 6
  2 2
  0 0
  ".split("\n")
  tmp.each{|s|
    line << s.strip
  }
end

r=Array.new
r = line.map{|s|s.split(" ")}

r.each{|s| s.map!(&:to_i)}.each do |h,w|
  h.times do
    puts "#"*w
  end
  break if h==0 && w==0
  puts "\n"
end

Measured memory_bytes: 8764
from bisect import bisect_left

def sieve(n=10**5 + 9):
    # srn = int(n ** 0.5) + 1
    f = [False] * (n + 1)
    res = []
    for i in range(2, n+1):
        if f[i]:
            continue
        res.append(i)
        for j in range(2 * i, n + 1, i):
            f[j] = True
    return res

X = int(input())
pn = sieve()
idx = bisect_left(pn, X)
print(pn[idx])


Measured memory_bytes: 10144
A, B = map(int, input().split())
N = A + B
X = [i for i in range(N)]
Y = []
def chk(a, b):
    print("?", a, b)
    return 1 if input() == "Y" else 0
if A <= B:
    print("Impossible")
else:
    while X:
        if not Y:
            Y.append(X.pop())
        else:
            if chk(Y[-1], X[-1]):
                Y.append(X.pop())
            else:
                X.pop()
                Y.pop()
    print("!", "".join([str(chk(Y[-1], i)) for i in range(N)]))

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,a[10001],b[10001];
	cin>>n;
	long long cnt=0;
	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++){
		if (b[i]>a[i]) cnt+=(b[i]-a[i])/2;
		else cnt-=a[i]-b[i];
	}
	if (cnt<0) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    int x, y;
    scanf("%d %d", &x, &y);
    while (x != 0 || y != 0) {
        if (x > y) {
            printf("%d %d\n", y, x);
    } else {
            printf("%d %d\n", x, y);       
        } 
        scanf("%d %d", &x, &y);
    }
    return 0;
} 

Measured memory_bytes: 1028
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

const int MAX = 1001000;
const int MOD = 1000000007;

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

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

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	ll x,y;
	cin>>x>>y;
	ll p,q;
	if((2*y-x)%3!=0 || (2*x-y)%3!=0 || (2*y-x)/3<0 || (2*x-y)/3<0){
		cout << 0 << endl;
		return 0;
	}
	p = (2*y-x)/3;
	q = (2*x-y)/3;
	COMinit();
	cout << COM(p+q, p) << endl;

	return 0;
}


Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
#define int long
#define ti4 tuple<int,int,int,int>
signed main(){
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  vector<int> a(x),b(y),c(z);
  for(int i=0;i<x;++i)cin>>a[i];
  for(int i=0;i<y;++i)cin>>b[i];
  for(int i=0;i<z;++i)cin>>c[i];
  sort(a.begin(),a.end(),greater<>());
  sort(b.begin(),b.end(),greater<>());
  sort(c.begin(),c.end(),greater<>());
  auto comp = [](ti4 a,ti4 b){return (get<0>(a))<(get<0>(b));};
  priority_queue<ti4,vector<ti4>,decltype(comp)> que(comp);
  map<ti4,bool> hist;
  que.push(make_tuple(a[0]+b[0]+c[0],0,0,0));
  for(int i=0;i<k;++i){
    ti4 t=que.top();
    que.pop();
    cout<<(get<0>(t))<<endl;
    int xt=get<1>(t), yt=get<2>(t), zt=get<3>(t);
    ti4 at,bt,ct;
    if(xt+1<x){
      at=make_tuple(a[xt+1]+b[yt]+c[zt],xt+1,yt,zt);
      if(!hist[at]){
        que.push(at);
        hist[at]=true;
      }
    }
    if(yt+1<y){
      bt=make_tuple(a[xt]+b[yt+1]+c[zt],xt,yt+1,zt);
      if(!hist[bt]){
        que.push(bt);
        hist[bt]=true;
      }
    }
    if(zt+1<z){
      ct=make_tuple(a[xt]+b[yt]+c[zt+1],xt,yt,zt+1);
      if(!hist[ct]){
        que.push(ct);
        hist[ct]=true;
      }
    }
  }
  return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
int Group[int(2e5+5)];
int cnt[int(2e5+5)];
bool visited[int(2e5+5)];

int DFS(int now){
  if (visited[now]) return Group[now];

  visited[now] = true;
  int G = DFS(Group[now]);
  return Group[now] = G;
}


int main(){
  cin >> N >> M;
  for (int i = 1; i <= N; i++) Group[i] = i;

  for (int i = 0; i < M; i++){
    int A, B; cin >> A >> B;
    int GA = Group[A], GB = Group[B];
    while (GA != Group[GA]) GA = Group[GA];
    while (GB != Group[GB]) GB = Group[GB];
    Group[max(GA, GB)] = min(GA, GB);
    Group[A] = min(GA, GB);
    Group[B] = min(GA, GB);
  }

  for (int i = 1; i <= N; i++){
    DFS(i);
    cnt[Group[i]]++;
  }

  int ans = 0;
  for (int i = 1; i <= N; i++){
    ans = max(ans, cnt[i]);
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 5204
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.next());
    String A = sc.next();
    String B = sc.next();
    String C = sc.next();

    int ans = 0;

    for (int i = 0; i < N; i++) {
      char ai = A.charAt(i);
      char bi = B.charAt(i);
      char ci = C.charAt(i);

      if (ai != bi && bi != ci && ci != ai) {
        ans += 2;
      } else if (ai == bi && bi == ci && ci == ai) {
        ans += 0;
      } else {
        ans += 1;
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 22356
ma=input()
mb=input()
mc=input()
mdic={"a":ma,"b":mb,"c":mc}
m="a"
ndic={"a":0,"b":-1,"c":-1}
while ndic[m]<len(mdic[m]):
  m=mdic[m][ndic[m]]
  ndic[m]+=1
print(m.upper())

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

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    if (b-a<=0){
      cout << "delicious" << endl;
    }
    else if(x < b-a){
      cout << "dangerous" << endl;
    }
    else {
       cout << "safe" << endl;
    }
}

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


int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll>a(n+1);
    vector<ll>b(m+1);
    rep(i,n){
        int c;
        cin>>c;
        a[i+1]+=c;
        a[i+1]+=a[i];
    }
    rep(i,m){
        int d;
        cin>>d;
        b[i+1]+=d;
        b[i+1]+=b[i];
    }
    ll ans=0;
    for(ll i=0;i<n+1;i++){
        if(a[i]>k)break;
        ll temp=k-a[i];
        auto posi=upper_bound(b.begin(),b.end(),temp);
        ll index=posi-b.begin();
        index-=1;
        ans=max(ans,i+index);
        
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 6380
#include<bits/stdc++.h>
//clock_t t=clock();
namespace my_std{
    using namespace std;
    #define pii pair<int,int>
    #define fir first
    #define sec second
    #define MP make_pair
    #define rep(i,x,y) for (int i=(x);i<=(y);i++)
    #define drep(i,x,y) for (int i=(x);i>=(y);i--)
    #define go(x) for (int i=head[x];i;i=edge[i].nxt)
    #define templ template<typename T>
    #define sz 233
    typedef long long ll;
    typedef double db;
//    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//    templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
    templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
    templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
    templ inline void read(T& t)
    {
        t=0;char f=0,ch=getchar();double d=0.1;
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
        if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
        t=(f?-t:t);
    }
    template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
    char __sr[1<<21],__z[20];int __C=-1,__zz=0;
    inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
    inline void print(register int x)
    {
        if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
        while(__z[++__zz]=x%10+48,x/=10);
        while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
    }
//    void file()
//    {
//        #ifdef NTFOrz
//        freopen("a.in","r",stdin);
//        #endif
//    }
//    inline void chktime()
//    {
//        #ifndef ONLINE_JUDGE
//        cout<<(clock()-t)/1000.0<<'\n';
//        #endif
//    }
    #ifdef mod
    ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
    ll inv(ll x){return ksm(x,mod-2);}
    #else
    ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
    #endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
int cnt[sz];
#define END return puts("Impossible"),0

int main()
{
//    file();
	read(n);
	int mx=0,x;
	rep(i,1,n) read(x),chkmax(mx,x),++cnt[x];
	if (cnt[mx]<1) END;
	cnt[mx]-=2;
	rep(i,1,mx-1) --cnt[max(i,mx-i)];
	rep(i,1,mx) if (cnt[i]<0) END;
	rep(i,1,((mx+1)>>1)) if (cnt[i]) END;
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200000005];
char s[100][8];
int main()
{
    ll n,m,k,i,j,l,ans=0,K,x=1,y=1,r,d,z,flag=1;
    scanf("%lld",&n);
   for(x=1;x*x<=n;x++)
   {
      for(y=1;y*y<=n;y++)
      {
          for(z=1;z*z<=n;z++)
          {
              a[x*x+y*y+z*z+x*y+y*z+z*x]++;
               if(x*x+y*y+z*z+x*y+y*z+z*x>n)
               {
                   flag=0;
                   break;
               }
          }
         // if(flag==0)break;
      }
      //  if(flag==0)break;
   }
   for(x=1;x<=n;x++)
   printf("%lld\n",a[x]);



    return 0;

}


Measured memory_bytes: 3960
#include <iostream>
#include <algorithm>

using namespace std;

void insertion(int *A,int N);

int main() {
	int N,a[1000];
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}

	cout << a[0];
	for(int k = 1; k < N; k++) cout << " " << a[k];
	cout << endl;

	insertion(a,N);
	return 0;
}

void insertion(int *A,int N){
	for (int i = 1; i < N; i++){
		int v = A[i];
		int j = i - 1;
		
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
	A[j+1] = v;
	
	cout << A[0];
	for(int k = 1; k < N; k++) cout << " " << A[k];
	cout << endl;
	}
}

Measured memory_bytes: 1164
#include <stdio.h>

int main(){
    char a[10]={0};
    char*b = "YAKI";
    scanf("%s", a) ;
    int i;
    for(i =0; i<4; i++){
        if(a[i]!=b[i]){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

ll solve(ll N){
    ll ans = 0, ones;
    if(N%2 == 1){
        ones = (N+1)/2;
        if(ones % 2 == 0)ans = 0;
        else ans = 1;
    }
    else{
        ones = N/2;
        if(ones % 2 == 0)ans = N;
        else ans = N ^ 1;
    }
    return ans;
}

int main(){
    ll A,B;
    cin>>A>>B;
    if(A == 0)cout<<solve(B);
    else cout<<(solve(A-1)^solve(B));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;
using std::swap;

int main()
{
	int a[20], b;
	int t=0,n,x;
	cin >> n;
	for (int i = 0; i < n; ++i)cin >> a[i];
	for (int i = 0; i < n; ++i) {
		cin >> x;
		b = a[i] - x;
		if (b > 0)t += b;
	}
	cout << t << "\n";
}

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

int gcd(int s,int t){
  if(t == 0){
    return s;
  }
  return gcd(t, s%t);
}

int main(){
  long int a,b; cin >> a >> b;
  long int c = gcd(a, b);
  cout << a*b/c << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define MAXN ((int)3e2+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define TRACE(x) if(DEBUG) cerr << #x << " = " << x << endl;
#define TRACE2(x,y) if(DEBUG) cerr << #x << " = " << x << " | " << #y << " = " << y << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int N,M,L;
int t[MAXN][MAXN];
int d[MAXN][MAXN];

void setup()
{
	for (int k = 1; k <= N; ++k)
		for (int i = 1; i <= N; ++i)
			for (int j = 1; j <= N; ++j)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= N; ++j)
			if(d[i][j] != INF && d[i][j] <= L)
			{
				t[i][j] = 1;
				t[j][i] = 1;;
			}

	for (int k = 1; k <= N; ++k)
		for (int i = 1; i <= N; ++i)
			for (int j = 1; j <= N; ++j)
				t[i][j] = min(t[i][j], t[i][k] + t[k][j]);
}



void solve()
{
	int x,y;
	cin >> x >> y;
	cout << (t[x][y]==INF ? -1: t[x][y]-1) << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);	
	cin >> N >> M >> L;

	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= N; ++j)
		{
			d[i][j] = INF; 
			t[i][j] = INF;
		}

	for (int i = 0; i < M; ++i)
	{
		int a,b,c;
		cin >> a >> b >> c;
		d[a][b] = c;
		d[b][a] = c;
	}
	setup();

	int q;
	cin >> q;
	while(q--)
		solve();
}

Measured memory_bytes: 1280
n,m = map(int,input().split())
ll = [list(map(int,input().split())) for _ in [0]*m]
l=[]
r=[]
for i in range(m):
  l.append(ll[i][0])
  r.append(ll[i][1])
l = max(l)
r = min(r)

  
#for _ in range(m):
#  a,b = map(int,input().split())
#  l = max([a,l])
#  r = min([b,r])
print(max([0,r-l+1]))

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

int main(){
	std::vector<int> carsQueue;
	int switchingRailroadCarsNumber;
	while (std::cin >> switchingRailroadCarsNumber){
		if (switchingRailroadCarsNumber != 0){
			carsQueue.push_back(switchingRailroadCarsNumber);
		}
		else{
			std::cout << carsQueue.at(carsQueue.size() - 1) << std::endl;
			carsQueue.pop_back();
		}
	}
	return 0;
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
typedef long double ld;
ll f(ll x){
  switch(x%4){
    case 0 : return x;  break;
    case 1 : return 1;  break;
    case 2 : return x+1;  break;
    case 3 : return 0;  break;
  }
  return 0;
}
int main(){
  ll a,b; cin >> a >> b;
  ll ans = f(a-1)^f(b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
alphabets = 'abcdefghijkl'
norms = [['a']]
for i in range(1,n):
  rtn = []
  for norm in norms[-1]:
    n_ch = len(set(norm))
    for j in range(n_ch+1):
      rtn.append(norm+alphabets[j])
  norms.append(rtn)
  
for norm in norms[-1]:
  print(norm)

Measured memory_bytes: 14552
H,W = map(int, input().split())
m = [list(input()) for _ in range(H)]
for r in range(H):
  for c in range(W-1):
    if m[r][c] != '.' and m[r][c+1] != '.':
      m[r][c],m[r][c+1] = '*','*'
for c in range(W):
  for r in range(H-1):
    if m[r][c] != '.' and m[r+1][c] != '.':
      m[r][c],m[r+1][c] = '*','*'
c = sum([sum([1 if m[r][c] == r'#' else 0 for c in range(W)]) for r in range(H)])
print('No' if c else 'Yes')


Measured memory_bytes: 3064
import heapq

def dijkstra(s,g):
    color=[0]*n
    dis={}
    for i in xrange(n):
        dis[i]=float('inf')
    dis[s]=0
    heapq.heappush(pq,[0,s])
    while len(pq)!=0:
        t,u=heapq.heappop(pq)
        color[u]=2
        if dis[u]<t:
            continue
        for v,cost in g[u]:
            if color[v]!=2:
                if dis[u]+cost<dis[v]:
                    dis[v]=dis[u]+cost
                    color[v]=1
                    heapq.heappush(pq,[dis[v],v])
    return dis

n,m,c=map(int,raw_input().split())
g=[[] for _ in xrange(n)]
totalcost=0
for i in xrange(m):
    a,b,d=map(int,raw_input().split())
    g[a-1].append([b-1,d])
    g[b-1].append([a-1,d])
    totalcost+=d

pq=[]
dis=dijkstra(0,g)
dis=sorted(dis.items(), key=lambda x:x[1])

ans=float('inf')
visited=[0]*n
for u,x in dis:
    visited[u]=1
    for v,cost in g[u]:
        if visited[v]==1:
            totalcost-=cost
    ans=min(ans,totalcost+c*x)
print ans

Measured memory_bytes: 99792
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
signed main(signed argc, char* argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	map<string,int> s;
	cin>>n;
	rep(i,n){
	    string st;
	    cin>>st;
	    s[st]++;
	}
	cout<<s["E869120"]<<endl;
}



Measured memory_bytes: 3384
#include<iostream>
#include<cstring>
using namespace std;
char s[110000];
int len,a=0;
bool y[26];
int main(){
	for(int k=0;k<=26;k++){
	    y[k]=true;
    }
	cin>>s;
	len=strlen(s);
	for(int i='a';i<='z';i++){
		for(int j=0;j<=len;j++){
			if(s[j]==i){
				y[i-97]=false;
			}
		}
	}
	for(char u='a';u<='z';u++){
		if(y[u-97]==true){
			cout<<u<<endl;
			break;
		}
		else a++;
	}
    if(a==26){
    	cout<<"None"<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	var ans int64
	for i := k; i <= n+1; i++ {
		mx := mod(sum(int64(n+1-i), int64(n)))
		mn := mod(sum(int64(0), int64(i-1)))
		ans = mod(ans + mx - mn + 1)
	}
	fmt.Fprintln(writer, ans)
}

func sum(a, b int64) int64 {
	return (a + b) * (b - a + 1) / 2
}

func mod(k int64) int64 {
	m := int64(1e9 + 7)
	return (k%m + m) % m
}


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

int main(){
	int moment = 0;
	int L;
	int N;
	cin >> L >> N;
	cout << N << endl;
	for(int i = 0 ; i < N ; i++){
		int x,l;
		cin >> x >> l;
		cout << -x << " " << l << endl;
	}
}

Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>

using namespace std;

int n,m;
int main(){
    cin >> n >> m;
    if(n == m){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

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

A.sort(reverse=True)
cnt = 1
idx = 0
ans = 0
while cnt <= N-1:
    ans += A[idx]
    if cnt % 2 == 1:
        #ans += A[idx]
        idx += 1
    #else:
        #ans += A[idx]
    cnt += 1
print(ans)

Measured memory_bytes: 31636
s = gets.chomp
u = s.split("").uniq

# nCv = n*(n-1)/v

# 2つ選ぶ
choice = s.size * (s.size-1) / 2
# 同じ文字2つ選ぶ
dub = 0
u.each do |c|
  e = s.count(c)
  dub += e * (e-1) / 2
end

puts choice - dub + 1

Measured memory_bytes: 12796
n, a, b = map(int, input().split())
import math
def wa(x):
  keta = math.floor(math.log10(x))+1
  count = 0
  for i in range(keta):
    count += (x//(10**i))%10
  return count
s = 0
for i in range(a, n+1):
  if a<=wa(i) and wa(i)<=b:
    s += i
print(s)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	int a,b;
	int d,r;
	double f;
	scanf("%d %d", &a ,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %f\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
stdin = open(0).read().split('\n')
N, M = map(int,stdin[0].split())
if M ==0:
    num=['0']*N
    if N!=1:
        num[0]='1'
    ans = "".join(num)
    print(int(ans))
else:
    num=['a']*N
    flag = True
    for i in range(M):
        s, c = stdin[i+1].split()
        if N!=1 and s=='1' and c=='0':
            flag = False
            break            
        elif not num[int(s)-1].isdecimal():
            num[int(s)-1]=c
        elif num[int(s)-1]!=c:
            flag = False
            break
    if num[0]=='a':num[0]='1'
    ans = "".join(num).replace('a', '0')
    print(int(ans) if (ans[0]!='0' or N==1) and flag else -1)

Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var N int
	var a []int
	m := make(map[int]int)

	fmt.Scan(&N)
	a = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &a[i])
	}

	yesOrNo := true
	for j := 0; j < N; j++ {
		if _, found := m[a[j]]; found {
			m[a[j]]++
			yesOrNo = false
		} else {
			m[a[j]] = 1
		}
	}

	if yesOrNo {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 16012
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

int A, B, Q;
long long INF = pow(10, 15);
vector<long long> s(0);
vector<long long> t(0);

long long solve(long long x) {
	auto upper_it_s = lower_bound(s.begin(), s.end(), x);
	auto upper_it_t = lower_bound(t.begin(), t.end(), x);
	int idx_s = upper_it_s - s.begin();
	int idx_t = upper_it_t - t.begin();

	long long res = INF;
	FOR(S, idx_s - 1, idx_s) {
		FOR(T, idx_t - 1, idx_t) {
			long long d1 = abs(s[S] - x) + abs(t[T] - s[S]);
			long long d2 = abs(t[T] - x) + abs(s[S] - t[T]);
			res = min(res, d1);
			res = min(res, d2);
		}
	}
	return res;

}

int main() {
	cin >> A >> B >> Q;

	s.resize(A);
	t.resize(B);

	REP(i, A) {
		cin >> s[i];
	}
	REP(i, B) {
		cin >> t[i];
	}
	s.insert(s.begin(), -INF);
	t.insert(t.begin(), -INF);
	s.push_back(INF);
	t.push_back(INF);


	long long x;
	REP(q, Q) {
		cin >> x;
		ANS(solve(x));
	}



	return 0;
}


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

int main(){
  char b;
  cin >> b;
  if(b=='A'){
    cout << 'T' << endl;
  } else if(b=='T'){
    cout << 'A' << endl;
  } else if(b=='G'){
    cout << 'C' << endl;
  } else if(b=='C'){
    cout << 'G' << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b);
#define chmin(a, b) a = min(a, b);
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

struct SegTree {
	std::vector<int> d;
	int sz;
	int base;
	const int e = 0;
	int merge(const int& i, const int& j){return i+j;}
	SegTree(int size): sz(size) {
		int k = 1;
		while(sz > k) k <<= 1;
		d = std::vector<int>(2 * k - 1, e);
		base = k - 1;
	}
	void update_upper(int i) {
		while(i > 0) {
			i = (i-1)/2;
			d[i] = merge(d[i*2+1], d[i*2+2]);
		}
	}
	void add(int i, int x) {
		assert(0 <= i && i < sz);
		int t = base + i;
		d[t] += x;
		update_upper(t);
	}
	void assign(int i, int x) {
		assert(0 <= i && i < sz);
		int t = base + i;
		d[t] = x;
		update_upper(t);
	}
	int sum(int a, int b) {
		assert(0 <= a && a <= b && b <= sz);
		// sum up data in [a, b)
		return sum_sub(a, b, 0, 0, base+1);
	}
	int sum(int b) {return sum(0, b);}
	int sum_sub(int a, int b, int k, int l, int r) {
		if (b <= l || r <= a) return e;
		if (a <= l && r <= b) return d[k];
		int c = (l + r) / 2;
		return merge(
			sum_sub(a, b, 2*k+1, l, c),
			sum_sub(a, b, 2*k+2, c, r)
		);
	}
	int get(int i) {return d[base+i];}
};

int main() {
    int n, q;
    cin >> n >> q;
    VI c(n);
    rep(i, n) cin >> c[i];
    vector<tuple<int, int, int>> query;
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        query.emplace_back(l-1, r-1, i);
    }
    VI ans(q);
    sort(query.begin(), query.end(), [](tuple<int, int, int> x, tuple<int, int, int> y) {
        return get<1>(x) < get<1>(y);
    });
    int nxt = 0;
    VI last(n + 1, -1);
    SegTree st(n);
    rep(i, n) {
        int ci = c[i];
        st.assign(i, 1);
        if (last[ci] != -1) {
            int lci = last[ci];
            st.assign(lci, 0);
        }
        last[ci] = i;
        while(nxt < q && get<1>(query[nxt]) == i) {
            int l, r, qi;
            tie(l, r, qi) = query[nxt];
            ans[qi] = st.sum(l, r + 1);
            nxt++;
        }
    }
    rep(i, q) cout << ans[i] << endl;
}


Measured memory_bytes: 19536
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

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

    auto f = [&x](ll num) -> ll
    {
        if(num < 0) return 0;
        return num / x + 1;

    };

    cout << f(b) - f(a-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
const ll INF=1e18,MOD=1e9+7;
int main(){
    int a,x;
    cin>>x>>a;
    int ans=x<a?0:10;
    cout<<ans<<endl;
}   


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
  int N, tmp;
  int d[101];
  for (int i = 0; i < 101; i++) {
    d[i] = 0;
  }
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    d[tmp]++;
  }
  int answer = 0;
  for (int i = 0; i < 101; i++) {
    if (d[i] != 0) {
      answer++;
    }
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
#ifdef __GNUC__ 
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3") 
//#pragma GCC target ("avx")

#endif
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/dynamic_bitset.hpp>
using namespace std;
struct Calc {
	int h, w;
	boost::dynamic_bitset<> buf;
	vector<pair<int, int> > currentv, nextv;
	int maxdatacount;
	int datacount;
	Calc() {
		cin >> h >> w;
		
		string s;
		buf.resize(h*w);
		int line = 0, n = 0;
		maxdatacount = w * h;
		int linebase = 0;
		datacount = 0;
		for (int i = 0; i < h; ++i) {
			cin >> s;
			n = 0;
			for (auto c : s) {
				if (c == '#') {
					buf.set(linebase+n);
					nextv.emplace_back(linebase, n);
					++datacount;
				}
				++n;
			}
			linebase += w;
			++line;
		}
		
	}
	//template <typename Fn>
	void tryset(int base, int x) {
		if (!buf[base+x]) {
			buf.set(base + x);
			nextv.emplace_back(base, x);
			++datacount;
		}
	}
	int calcmain() {
		int n = 0;
		while (1) {
			if (datacount >= maxdatacount)return n;
			nextv.swap(currentv);
			nextv.clear();

			for (const auto &p : currentv) {
				if (p.first > 0)tryset(p.first - w, p.second);
				if (p.first + w < maxdatacount)tryset(p.first + w, p.second);
				if (p.second >0)tryset(p.first , p.second-1);
				if (p.second <w-1)tryset(p.first , p.second+1);
			}
			++n;
		}
	}
};

int main() {
	Calc calc;
	cout << calc.calcmain() << endl;
}


Measured memory_bytes: 13288
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N, M, an = 0;
	cin >> N >> M;
	vector<pair<ll, ll>> k(N);
	rep(i, N) {
		ll A, B;
		cin >> A >> B;
		k.at(i) = make_pair(A, B);
	}
	sort(k.begin(), k.end());
	ll i = 0;
	while (M > 0) {
		if (k.at(i).second > 0) {
			an += k.at(i).first;
			k.at(i).second--;
			M--;
		}
		else {
			i++;

		}
	}
	cout << an << endl;
}


Measured memory_bytes: 4812
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,k;
	cin>>a>>b>>k;
	long long c=min(a,k);
	a-=c,k-=c;
	long long d=min(b,k);
	b-=d,k-=d;
	cout<<a<<' '<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,ans;
    cin>>s;
    for(int i=0;i<s.size();i++){
        ans.push_back('x');
    }
    for(char e : ans){
        cout<<e;
    }
}    

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

int main(){
    int r; cin >> r;
    double pi = 3.141592648777698869248;
    cout << fixed << setprecision(5) << 2 * pi * r << endl;
    return 0;
}

Measured memory_bytes: 3772
//
//  main.cpp
//  ABC139A
//
#include <iostream>
//#include<string>
using namespace std;
int main(int argc, const char * argv[]) {
    string S,T;
    int count=0;
    cin >>S>>T;
    for (int i=0; i<3; i++) {
        if (S.at(i)==T.at(i)) {
            count++;
        }
    }
    cout << count<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
string names;

string karuta[100100];
int nn[400];
vector<pair<int, int>> workk;
long long summ;
int main() {
	int N = 0;
	int A1[105] = { 0 }, A2[105] = { 0 };
	int count1[105] = { 0 }, count2[105] = { 0 };
	int ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A1[i];
		if (i == 0) {
			count1[i] = A1[i];
		}
		else { count1[i] = count1[i - 1] + A1[i]; }
	}
	for (int i = 0; i < N; i++) {
		cin >> A2[i];
		if (i == 0) {
			count2[i] = A2[i];
		}
		else {
			count2[i] = count2[i - 1] + A2[i];
			//cout << count2[i];
		}
	}
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			
			ans=max(ans, count1[i] + count2[N -1] );
		}
		else {
			ans = max(ans, count1[i] + count2[N - 1] - count2[i - 1]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val M = sc.nextInt
    val X = sc.nextInt
    val Y = sc.nextInt
    val x = Array.fill(N)(sc.nextInt)
    val y = Array.fill(M)(sc.nextInt)

    if ((x :+ X).max < (y :+ Y).min) "No War" else "War"
  }
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

string s;
char lst = '0';
ll ans;

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

    cin >> s;

    for(int i=0; i<(int)s.size(); i++)
    {
        if (s[i] != lst)
        {
            lst=s[i];
            ans++;
        }
        else
        {
            if (i < (int)s.size()-1)
            {
                ans++ , i++;
                lst='0';
            }
            else break;
        }
    }

    cout << ans << '\n';

    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
	ll n;
	scanf("%lld", &n);

	ll inp[n];
	for(int i = 0; i < n; i++)
		scanf("%lld", &inp[i]);

	ll cnt[3] = {0};
	for(int i = 0; i < n; i++) {
		if(inp[i] % 4 == 0) 
			cnt[2]++;
		else if(inp[i] % 2 == 0)
			cnt[1]++;
	}
	
	bool ok = false;
	if(cnt[2] * 2 >= n)
		ok = true;
	else {
		n -= cnt[2] * 2;
		if(n == 1 && cnt[2] > 0)
			ok = true;
		if(n > 1 && cnt[1] >= n)
			ok = true;
	}

	printf("%s\n", ok ? "Yes" : "No");

	return 0;
}


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

int compare(const void *a,const void *b) {
	return *(long long int*)b-*(long long int*)a;
}

int main(void) {
	int n,cnt;
	long long int sum = 0LL;
	long long int *a;
	
	scanf("%d",&n);
	a = (long long int*)malloc(sizeof(long long int)*n);
	for (int i = 0;i < n;i++) {
		scanf("%lld",&a[i]);
		sum += a[i];
	}
	
	qsort(a,n,sizeof(long long int),compare);

	sum -= a[0];
	cnt = 1;
	for (int i = 1;i < n;i++) {
		if (a[i-1] > sum*2) {
			break;
		}
		cnt++;
		sum -= a[i];
	}
	printf("%d\n",cnt);

	return 0;
}


Measured memory_bytes: 1788
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int M = stdIn.nextInt();
		int Q = stdIn.nextInt();
		int[] a = new int[Q];
		int[] b = new int[Q];
		int[] c = new int[Q];
		int[] d = new int[Q];
		
		for(int i = 0; i < Q; i ++) {
			a[i] = stdIn.nextInt();
			b[i] = stdIn.nextInt();
			c[i] = stdIn.nextInt();
			d[i] = stdIn.nextInt();
		}
		
		ArrayList<Integer> A = new ArrayList<Integer>();
		A.add(1);
		
		System.out.println(dfs(A, a, b, c, d, N, M));
	}
	
	public static long dfs(ArrayList<Integer> A, int[] a, int[] b, int[] c, int[] d, int N, int M) {
		long ans = 0;
		if(A.size() == N + 1) {
			return calc(A, a, b, c, d, N);
		}else {
			int i = A.get(A.size() - 1);	
			while(i <= M) {
				A.add(i ++);
				ans = Math.max(ans, dfs(A, a, b, c, d, N, M));
				A.remove(A.size() - 1);
			}
			return ans;
		}
	}
	
	public static long calc(ArrayList<Integer> A, int[] a, int[] b, int[] c, int[] d, int N) {
		long score = 0;
		for(int i = 0; i < a.length; i ++) {
			if(A.get(b[i]) - A.get(a[i]) == c[i]) {
				score += d[i];
			}
		}
		return score;
	}

}

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

using namespace std;
using ll = long long;

const int N = 3e5;
int a[N], b[N];

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

	int n;
	cin >> n;

	for(int i=1; i<=n; i++)
		cin >> a[i];

	for(int i=1; i<=n; i++){
		int t = a[i];
		int q = b[t-1] + 1;
		b[t] = q;
	}

	int ans = 0;
	for(int i=1; i<=n; i++)
		ans = max(ans, b[i]);

	cout << n-ans << endl;

	return 0;
}

Measured memory_bytes: 1792
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

bool isPrime(int x) {
    for (int i=2; i*i <= x; i++) if (x % i == 0) return false;
    return x != 1;
}

void main() {

    int[10^^5+5] a;
    foreach (ii, v; a) {
        int i = ii.to!int;
        if (i & 1)
            a[i] = isPrime(i) & isPrime((i + 1) / 2);
    }
    foreach (i; 0..10^^5) a[i+1] += a[i];

    int q = readint();
    while (q--) {
        int l, r; readf("%d %d\n", &l, &r);
        writeln(a[r] - a[l-1]);
    }
}

Measured memory_bytes: 1020
n, m = [int(c) for c in input().split()]

k = [list(map(int, input().split())) for _ in range(n)]

food_count = [0] * m

for p in k:
    for i in range(1, len(p)):
        food_count[p[i]-1] += 1

count = 0
for f in food_count:
    if f == n:
        count += 1

print(count)

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

#define fix(x) cout<<fixed<<setprecision(x);

int main() {
    fix(8);
    int a, b;
    cin>>a>>b;
    cout<<a / b<<' '<<a % b<<' '<<(double)a / b<<endl;
    
    return 0;
}


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

int main() {
  int a[3][3];
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      cin >> a[i][j];
  bool c[3][3] = {};
  int n; cin >> n;
  while (n--) {
    int b; cin >> b;
    for (int i = 0; i < 3; ++i)
      for (int j = 0; j < 3; ++j)
        if (a[i][j] == b) c[i][j] = true;
  }
  
  if (c[0][0] && c[0][1] && c[0][2] ||
      c[1][0] && c[1][1] && c[1][2] ||
      c[2][0] && c[2][1] && c[2][2] ||
      c[0][0] && c[1][0] && c[2][0] ||
      c[0][1] && c[1][1] && c[2][1] ||
      c[0][2] && c[1][2] && c[2][2] ||
      c[0][0] && c[1][1] && c[2][2] ||
      c[0][2] && c[1][1] && c[2][0])
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    string s,t;
    cin >> n >> s >> t;
    for(int i = 0;i < n;i++)
    {
        cout << s[i] << t[i];
    }
    cout << "\n";

    return 0;
}

Measured memory_bytes: 256
n, x, y = map(int, input().split())

ans = [0]*n
for i in range(1, n+1):
  for j in range(i, n+1):
    m = min(j-i,  abs(x-i) + 1 + abs(j-y))
    ans[m] += 1
      
print(*ans[1:], sep = '\n')


Measured memory_bytes: 3444
while True:
    try:
        n = int(input())
        Num = 0
        for i in range(10):
            for j in range(10):
                for k in range(10):
                    for l in range(10):
                        if i + j + k + l == n:
                            Num += 1
        print(Num)
    except EOFError:
        break

Measured memory_bytes: 7492
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
template <class T> void ckmax(T &x,const T y){
	if (x<y)
		x=y;
}
template <class T> void ckmin(T &x,const T y){
	if (x>y)
		x=y;
}
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
const int N=200005;
int n;
LL a[N],b[N];
map <pii,int> v;
int main(){
	n=read();
	For(i,1,n){
		string s;
		cin>>s;
		int tp=0;
		b[i]=1;
		for (auto c : s){
			if (c=='.'){
				tp=1;
			}
			else {
				if (tp)
					b[i]*=10;
				a[i]=a[i]*10+c-48;
			}
		}
		int c2=0,c5=0;
		while (a[i]%2==0)
			a[i]/=2,c2++;
		while (a[i]%5==0)
			a[i]/=5,c5++;
		while (b[i]%2==0)
			b[i]/=2,c2--;
		while (b[i]%5==0)
			b[i]/=5,c5--;
		v[mp(c2,c5)]++;
	}
	LL ans=0;
	For(a,-50,50)
		For(b,-20,20)
			For(c,-50,50)
				For(d,-20,20)
					if (a+c>=0&&b+d>=0){
						ans+=(LL)v[mp(a,b)]*v[mp(c,d)];
						if (a==c&&b==d)
							ans-=v[mp(a,b)];
					}
	cout<<ans/2<<endl;
	return 0;
}

Measured memory_bytes: 7004
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n;
  string s;
  int ans=0;
  int sum=0;
  cin>>n;
  cin>>s;
  rep(i,n){
    if(s[i]=='I')sum++;
    else sum--;
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int r;
  cin >> r;
  cout << r*r << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
A = LI()

d = defaultdict(int)
for i in range(N):
    d[A[i]] += 1

s = 0
for k in d.keys():
    s += d[k]*(d[k]-1)//2

for i in range(N):
    print(s-(d[A[i]]-1))

Measured memory_bytes: 82912
#include <stdio.h>

int main(){
    int i,j,temp,a[10];
    
    for(i=0;i<10;i++){
        scanf("%d",&a[i]);
    }
    
    for(i=1;i<10;i++){
        temp=a[i];
        j=i-1;
        while(j>=0&&a[j]>temp){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=temp;
    }
    
    printf("%d\n%d\n%d\n",a[9],a[8],a[7]);
    
    return 0;
}

Measured memory_bytes: 600