stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

#include<complex>

using namespace std;



#define FOR(i,a,b) for (int i = (a); i < (b); i++)

#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)

#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a,value) memset(a, value, sizeof(a))



#define SZ(a) (int)a.size()

#define ALL(a) a.begin(), a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 1000 * 1000 + 47;



int main()

{

	//freopen("in.txt", "r", stdin);

	//freopen("out.txt", "w", stdout);

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

	int x, y;

	cin >> x >> y;

	int res;

	if ((x >= 0 && y >= 0) || (x <= 0 && y <= 0))

	{

		res = abs(y - x);

		//cout << "!!" << res << endl;

		if (x > y)

		{

			res++;

			if (y != 0 && x != 0) res++;

		}



		cout << res << endl;

		return 0;

	}



	res = abs(x + y) + 1;



	cout << res << endl;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cmath>

using namespace std;

int main(){

	long long x,y,a=0,b=0;

	bool flag;

	scanf("%lld %lld",&x,&y);

	if(abs(x)>abs(y))

	a=abs(x)-abs(y),flag=false;

	else

	a=abs(y)-abs(x),flag=true;

	if(x>=0&&flag){

		if(y<0)

		++b;

		printf("%lld",a+b);

		return 0;

	}

	if(x<0&&flag){

		if(y>0)

		++b;

		else 

		b+=2;

		printf("%lld",a+b);

		return 0;

	}

	if(x>=0){

		if(y>0)

		b+=2;

		else

		++b;

		printf("%lld",a+b);

		return 0;

	}

	if(x<0){

		if(y>0)

		++b;

		printf("%lld",a+b);

		return 0;

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cmath>

using namespace std;

typedef long long LL;

LL a,b,ans;

int main(){

	cin>>a>>b;

	if(a==b) ans=0;

	else if(a==0){

		if(b>0) ans=b-a;

		else ans=-b+1;

	}

	else if(b==0){

		if(a<0) ans=b-a;

		else ans=a+1;

	}

	else if(a<0&&b<0){

		if(a<b) ans=b-a;

		else ans=a-b+2;

	}	

	else if(a>0&&b>0){

		if(a<b) ans=b-a;

		else ans=a-b+2;

	}

	else if(a>0&&b<0){

		ans=abs(a+b)+1;

	}

	else if(a<0&&b>0){

		ans=abs(a+b)+1;

	}

	cout<<ans<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cmath>

using namespace std;

int main(){

	long long x,y,a=0,b=0;

	bool flag;

	scanf("%lld %lld",&x,&y);

	if(abs(x)>abs(y))

	a=abs(x)-abs(y),flag=false;

	else

	a=abs(y)-abs(x),flag=true;

	if(x>=0&&flag){

		if(y<0)

		++b;

		printf("%lld",a+b);

		return 0;

	}

	if(x<0&&flag){

		if(y>0)

		++b;

		else 

		b+=2;

		printf("%lld",a+b);

		return 0;

	}

	if(x>=0){

		if(y>0)

		b+=2;

		else

		++b;

		printf("%lld",a+b);

		return 0;

	}

	if(x<0){

		if(y>0)

		++b;

		printf("%lld",a+b);

		return 0;

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cmath>

#include<string>

#include<cstdlib>

#include<algorithm>

#include<fstream>

using namespace std;

int main()

{

    int i,j,x,y,l;

//    while(777)

//    {

        scanf("%d%d",&x,&y);

    int ss=0;

    if(x<0&&y<0&&x>y)

    {

        x=fabs(x);

        y=fabs(y);

        x=y-x;

        x+=2;

        printf("%d\n",x);

           exit(0);

    }

   else if(x<y)

    {

        if(x>=0||y==0)printf("%d\n",y-x);

        else if(y<0)printf("%d\n",y-x);

        else if(x<0&&-x<y)printf("%d\n",y+x+1);

        else if(x<0&&-x>y)

        {

           printf("%d\n",-x-y+1);

        }

        else if(x<0&&-x==y)printf("%d\n",1);

        else printf("%d\n",y-x);

        exit(0);

    }

    else if(x>y)

    {

        if(y>0)

        {

            ss+=2;

            printf("%d\n",ss+x-y);

        }

        else

        {

            if(-y>x)

            {

                printf("%d\n",-x-y+1);

            }

            else

            {

                printf("%d\n",x+y+1);

            }

        }

         exit(0);

    }

//    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

int s(int x,int y)

{

    if(x<=y) return y-x;

        else return x-y+2;

}

int main()

{

    int x,y;

    scanf("%d %d",&x,&y);

    printf("%d\n",min(s(x,y),min(s(-x,y)+1,min(s(x,-y)+1,s(-x,-y)+2))));

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
//program luogu.AT22263

#include <iostream>

#include <cstdio>

#include <cmath>

using namespace std;

#define LL long long



LL a,b,ans;



int main() {

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

	if( a == b ) {

		printf("0\n");

		return 0;

	}

	if( a == 0 || b == 0 ) {

		if( a > b )

			ans = a - b + 1;

		else

			ans = b - a;

	}

	else if( ( a > 0 && b < 0 ) || ( a < 0 && b > 0 ) )

		ans = abs( abs( a ) - abs( b ) ) + 1;

	else {

		if( a < b )

			ans = b - a;

		else

			ans = a - b + 2;

	}

	printf("%lld\n",ans);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

using namespace std;

int s(int x,int y)

{

    if(x<=y) return y-x;

        else return x-y+2;

}

int main()

{

    int x,y;

    scanf("%d %d",&x,&y);

    printf("%d\n",min(s(x,y),min(s(-x,y)+1,min(s(x,-y)+1,s(-x,-y)+2))));

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<vector>

#include<algorithm>



#define	mp			make_pair

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



using namespace std;



typedef	vector<int>		vi;

typedef	pair<int,int>	pii;



class UnionFind{

	vi a;

	int root(int x){ return ~a[x]?a[x]=root(a[x]):x; }

public:

	UnionFind(int n):a(n,-1){}

	bool find(int x,int y){ return root(x)==root(y); }

	bool unite(int x,int y){ return find(x,y)?0:(a[root(y)]=root(x),1); }

};



int main(){

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

		pair<int,pii> packet[20000];

		rep(i,m)	scanf("%d%d%d",&packet[i].first,&packet[i].second.first,&packet[i].second.second);

		sort(packet,packet+m);



		int ans=1;

		UnionFind link(n+1);

		rep(i,m){

			int src=packet[i].second.first,dst=packet[i].second.second;

			if(link.find(1,src))	ans+=link.unite(src,dst);

		}

		printf("%d\n",ans);

	}



	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>



#define	mp			make_pair

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



using namespace std;



typedef	pair<int,int>	pii;



int main(){

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

		pair<int,pii> packet[20000];

		rep(i,m)	scanf("%d%d%d",&packet[i].first,&packet[i].second.first,&packet[i].second.second);

		sort(packet,packet+m);



		bool flg[20000]={};	flg[0]=true;

		rep(i,m){

			int src=packet[i].second.first-1,dst=packet[i].second.second-1;

			flg[dst]|=flg[src];

		}

		printf("%d\n",count(flg,flg+n,true));

	}



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<algorithm>

using namespace std;

typedef long long ll;

ll a[100022];

//ll b[100022];

int main()

{

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

    {

        cin>>a[i];

       // b[i]=a[i]*2;

    }

    int sum=1;

    sort(a,a+n);

    ll maxx=a[0];

    for(int i=1;i<n;i++)

    {

        if(maxx*2>=a[i])

        {

            sum++;

            maxx+=a[i];

        }

        else

        {

            sum=1;

            maxx+=a[i];

        }

    }

    cout<<sum<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main()

{

	int i,n,a[100005],temp=1;

	long long sum;

	scanf("%d",&n);

	for(i=0;i<n;i++)

	 scanf("%d",&a[i]);

	sort(a,a+n);

	sum=(long long)a[0];

	for(i=1;i<n;i++)

	{

		if(sum*2<(long long)a[i])

		{

		   temp=1;

		   sum+=(long long)a[i];

		}

		else

		{

			temp++;

			sum+=(long long)a[i];

		}	

	}

   printf("%d\n",temp);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <map>

#include <cmath>

#include <stack>

#include <queue>

#include <string>

#include <vector>

#include <cstdio>

#include <cstring>

#include <iostream>

#include <algorithm>

#define lld long long

#define llu unsigned long long



using namespace std;

long long n,i,s,c,a[100010];

int main()

{



	scanf("%lld",&n);

	for(i=0;i<n;i++)

		scanf("%lld",&a[i]);

	sort(a,a+n);

	for(c=1,s=i=0;i<n-1;i++)

	{

		s+=a[i];

		if(s*2>=a[i+1])			

			c++;

		else

			c=1;			

	}

	printf("%lld\n",c);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main()

{

	int i,n,a[100005],temp=1;

	long long sum;

	scanf("%d",&n);

	for(i=0;i<n;i++)

	 scanf("%d",&a[i]);

	sort(a,a+n);

	sum=(long long)a[0];

	for(i=1;i<n;i++)

	{

		if(sum*2<(long long)a[i])

		{

		   temp=1;

		   sum+=(long long)a[i];

		}

		else

		{

			temp++;

			sum+=(long long)a[i];

		}	

	}

   printf("%d\n",temp);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
//#include <bits/stdc++.h>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <iostream>

#include <vector>

#include <map>

#include <set>

#include <queue>

#include <string>

#include <stack>

#include <fstream>

#include <iomanip>

#include <algorithm>

#include <functional>

//#include <unordered_set>

#define INF 2147483647

#define MAXN  1000100

#define PII pair<int, int>

#define mp(a,b) make_pair(a,b)

typedef long long ll;

typedef unsigned long long ull;

using namespace std;

const int maxn = 35;

ll a[MAXN];



int main()

{

	//ios::sync_with_stdio(false);

	cin.tie(0);

#ifdef local_debug

	ifstream inputs("input.txt");

	cin.rdbuf(inputs.rdbuf());

	freopen("input.txt", "r", stdin);

#endif

	int n;

	while (cin >> n) {

		a[n] = 0;

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

		sort(a, a + n);

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

		int ans = 1;

		for (int i = 0; i < n; i++)

		{

			if (a[i]*2 >= (a[i + 1] - a[i]))

				ans++;

			else

				ans = 1;

		}

		cout << ans-1 << endl;

	}

	return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<algorithm>

using namespace std;

int main()

{

	int i,n,a[100005],temp=1;

	long long sum;

	scanf("%d",&n);

	for(i=0;i<n;i++)

	 scanf("%d",&a[i]);

	sort(a,a+n);

	sum=(long long)a[0];

	for(i=1;i<n;i++)

	{

		if(sum*2<(long long)a[i])

		{

		   temp=1;

		   sum+=(long long)a[i];

		}

		else

		{

			temp++;

			sum+=(long long)a[i];

		}	

	}

   printf("%d\n",temp);

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
# include <bits/stdc++.h>



# define pb push_back

# define fr first

# define sc second

# define mk make_pair



using namespace std;



const int inf = 1000000000 + 7;

const int N = 1e6 + 5;



typedef long long ll;



ll n, a[N], pref[N], ans;



inline void solve()

{

    cin >> n;



    for(int i = 1; i <= n; i ++)

        cin >> a[i];



    sort(a + 1, a + n + 1);



    for(int i = 1; i <= n; i ++)

        pref[i] = a[i] + pref[i - 1];

    for(int i = n; i >= 1; i --)

    {

        if(pref[i] * 2 >= a[i + 1])

            ans ++;

        else

            break;

    }



    cout << ans << endl;

}



int tests = 1;



int main()

{

//    scanf("%d", &tests);



    while(tests --)

        solve();

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

    for (int i=0;i<num;i++)

    {

        scanf("%d",&animal[i]);

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

    for (int i=1;i<num;i++)

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define fr first

#define sc second

#define mk make_pair

#define pb push_back

#define ll long long

#define OK puts("OK");

#define sz(s) (int)s.size()

#define all(s) s.begin(), s.end()



using namespace std;



const int N = 1e5 + 10;

const int inf = 1e9 + 7;





int a[N], ans, n;

ll s;



main()

{

    scanf("%d", &n);

    for(int i = 1; i <= n; i++)

        scanf("%d", a + i);

    sort(a + 1, a + n + 1);

    ans = n;

    for(int i = 1 ; i < n ; i ++)

    {

        s += a[i];

        if(s * 2 < a[i + 1])

            ans = n - i;

    }

    cout << ans << endl;





}








// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

    for (int i=0;i<num;i++)

    {

        scanf("%d",&animal[i]);

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

    for (int i=1;i<num;i++)

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define pb push_back

#define mk make_pair

#define sc second

#define fr first



using namespace std;



typedef long long ll;



const long long N = (long long) 1e6 + 5;

const long long mod = (long long) 1e9 + 7;



long long n,a[N],ans = 1,pr[N],dp[N];



int main(){

        cin >> n;



        for(long long i = 1; i <= n; i ++)

                cin >> a[i];



        sort(a + 1,a + n + 1);



        for(long long i = 1; i <= n; i ++)

                pr[i] = pr[i - 1] + a[i];



        dp[n] = 1;

        for(long long i = n - 1; i >= 1; i --){

                if(a[i + 1] <= pr[i] * 2 && dp[i + 1] == 1)

                        dp[i] = 1,ans ++;

        }

        cout << ans << endl;

        return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

    for (int i=0;i<num;i++)

    {

        scanf("%d",&animal[i]);

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

    for (int i=1;i<num;i++)

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define fr first

#define sc second

#define mk make_pair

#define pb push_back

#define pf push_front

#define pii pair <int ,int>

#define all(s) s.begin (), s.end ()

#define int long long



using namespace std;



const int N = 1e5 + 5;



int n, ar[N], pref[N];



main()

{

    cin >> n;

    for (int i = 1; i <= n; i++)

        scanf("%lld", &ar[i]);



    sort(ar + 1, ar + n + 1);



    for (int i = 1; i <= n; i++)

        pref[i] = ar[i] + pref[i - 1];



    for (int i = n - 1; i >= 0; i--)

    {

        if (pref[i] * 2 < ar[i + 1])

        {

            cout << n - i;

            return 0;

        }

    }



}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

    for (int i=0;i<num;i++)

    {

        scanf("%d",&animal[i]);

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

    for (int i=1;i<num;i++)

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define pb push_back

#define mk make_pair

#define fr first

#define sc second



using namespace std;



const int N = 1e5 + 11;



int n, c, l;

long long a[N], d[N], sm, flag[N];

int main () {



       cin >> n;

       for(int i = 1;i <= n;i ++)

           cin >> a[i];

       c = n;

       sort(a + 1, a + n + 1);



       for(int i = 1;i < n;i ++)

       {

           sm += a[i];

           if(sm * 2 < a[i + 1]) c -= (i - l), l = i;

       }

       cout << c << endl;

}




// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

    for (int i=0;i<num;i++)

    {

        scanf("%d",&animal[i]);

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

    for (int i=1;i<num;i++)

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <cstring>

#include <string>

#include <iostream>

#include <algorithm>

using namespace std;



typedef long long ll;

const int maxn=1e5+5;

int a[maxn];

ll b[maxn];



int main()

{

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

        scanf("%d",&a[i]);

    sort(a,a+n);

    b[0]=a[0];

    for(int i=1;i<n;i++)

    {

        b[i]=b[i-1]+a[i];

    }

    int cnt=1;

    for(int i=n-2;i>=0;i--)

    {

        if(b[i]*2>=a[i+1])

            cnt++;

        else

            break;

    }

    printf("%d\n",cnt);

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

    for (int i=0;i<num;i++)

    {

        scanf("%d",&animal[i]);

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

    for (int i=1;i<num;i++)

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#define ll long long

int line(const void*a,const void*b)

{

	return *(int *)a-*(ll *)b;

}

int main()

{

	ll s1[100010];

	ll judgesum[100010];

	ll a,n,sum;

	while(scanf("%lld",&n)!=EOF)

	{

		sum=0;

		for(a=1;a<=n;a++)

			scanf("%lld",&s1[a]);

		qsort(s1+1,n,sizeof(s1[1]),line);

		memset(judgesum,0,sizeof(judgesum));

		judgesum[1]=s1[1];

		for(a=2;a<=n;a++)

			judgesum[a]=judgesum[a-1]+s1[a];

		sum=1;

		for(a=n-1;a>=1;a--)

		{

			if(2*judgesum[a]>=s1[a+1])

				sum++;

            else break;

		}

		printf("%lld\n",sum);

	}

	return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

    for (int i=0;i<num;i++)

    {

        scanf("%d",&animal[i]);

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

    for (int i=1;i<num;i++)

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<string>

#include<vector>

#include<map>

#include<queue>

#include<stack>

using namespace std;

long long s[100005];

long long vis[100005];

int main(){

	int n;

	while(scanf("%d",&n)==1)

	{

		for(int i=0;i<n;i++)

		scanf("%lld",&s[i]);

		sort(s,s+n);

		vis[0]=s[0];

		for(int i=1;i<n;i++)

		vis[i]=vis[i-1]+s[i];

		int sum=0;

		for(int i=n-1;i>=0;i--)

		if(s[i]<=vis[i-1]*2)sum++;

		else break;

		printf("%d\n",sum+1);

	}

	return 0;

} 

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

    for (int i=0;i<num;i++)

    {

        scanf("%d",&animal[i]);

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

    for (int i=1;i<num;i++)

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<queue>

#include<stack>

#include<cmath>

#include<algorithm>

#define inf 99999999

using namespace std;

typedef long long ll;

const int MAX=100000+10;

int cmp(int a,int b){

    return a<b;

}

ll a[MAX],b[MAX];

int main(){

    #ifdef SIYU

    //freopen("in.txt","r",stdin);

    #endif // SIYU

    int n;

    cin>>n;

    for(int i=0;i<n;i++)

        scanf("%lld",&a[i]);

    sort(a,a+n,cmp);

    for(int i=0;i<n;i++){

        if(i==0)    b[i]=a[i];

        else    b[i]=b[i-1]+a[i];

    }

    int countt=0;

    for(int i=n-1;i>=0;i--){

        if(a[i]<=b[i-1]*2)

            countt++;

        else

            break;

    }

    cout<<countt+1<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

    for (int i=0;i<num;i++)

    {

        scanf("%d",&animal[i]);

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

    for (int i=1;i<num;i++)

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

using namespace std;

long long a[1000000],b[1000000];

int main()

{

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++)

    {

        scanf("%lld",&a[i]);

    }

    sort(a,a+n);

    b[0]=a[0];

    for(int i=0;i<n;i++)

    {

        b[i]=b[i-1]+a[i];

    }

    int cnt=0;

    for(int i=n-1;i>=0;i--)

    {

        if(a[i]<=2*b[i-1]) ++cnt;

        else

        {

            break;

        }

    }

    printf("%d\n",cnt+1);

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <algorithm>

using namespace std;

main()

{

    int num;

    scanf("%d",&num);

    int animal[num];

    for (int i=0;i<num;i++)

    {

        scanf("%d",&animal[i]);

    }

    sort(animal,animal+num);

    long long sum=animal[0];

    long long cnt=1;

    for (int i=1;i<num;i++)

    {

        if (sum*2>=animal[i])

        {

            cnt++;

        }

        else

        {

            cnt=1;

        }

        sum+=animal[i];

    }

    printf("%d",cnt);

}


// Fastest known solution for this problem: