ZhenlongDai/ACPR huggingface dataset:
Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
A.sort()

B=[A[0]]
for i in range(1,N):
  B.append(B[-1]+A[i])



left=0
for left in range(N-2,-1,-1):
  if B[left]*2>=A[left+1]:
    pass
  else:
    break

num=N-left-1

print(num)





Failing test case input:
5
1 1 2 1 1

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
A.sort()

B=[A[0]]
for i in range(1,N):
  B.append(B[-1]+A[i])



left=0
for left in range(N-2,-1,-1):
  if B[left]*2>=A[left+1]:
    pass
  else:
    break
else:
  left=-1

num=N-left-1

print(num)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=False)
ans = N
for i in range(N-1):
    if A[i]*2 < A[i+1]:
        A[i+1] += A[i]
        ans -= 1
print(ans)

Failing test case input:
6
36 2 23 1 0 38

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):

N = int(input())
A = list(map(int, input().split()))
A.sort()
tmp = 0
s = 0
for i in range(N-1):
    s += A[i]
    if 2*s < A[i+1]:
        tmp = i+1
print(N - tmp)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
a.sort()
tmp = 0
ans = 1
for i in range(n-1):
  tmp+= a[i]
  if a[i] *2 >=  a[i+1]:
    ans += 1
print(ans)

Failing test case input:
6
58 1 41 -1 0 2

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
a.sort()

tmp = 0
ans = 1
for i in range(n-1):
  tmp+= a[i]

  if tmp *2 >=  a[i+1]:
    ans += 1
  else:
    ans = 1
print(ans)

Problem: p03786
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n, *aa = map(int, open(0).read().split())

aa.sort()

count = 1
tmp = aa[0]
for i in range(1,n):
    if 2 * tmp >= aa[i]:
        tmp += aa[i]
        count += 1
    else:
        tmp += aa[i]
        count = 1
    print(count, tmp)

print(count)

Failing test case input:
6
58 1 41 -1 0 2

Expected output:
2


Actual output:
1 -1
1 0
1 2
1 43
2 101
2


Fixed submission (verdict: Accepted):
n, *aa = map(int, open(0).read().split())

aa.sort()

count = 1
tmp = aa[0]
for i in range(1,n):
    if 2 * tmp >= aa[i]:
        tmp += aa[i]
        count += 1
    else:
        tmp += aa[i]
        count = 1


print(count)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
A.sort()

S=[A[0]]
for i in range(1,N):
  S.append(S[i-1]+A[i])


T=[0]*(N-1)
for i in range(N-1):
  if S[i]*2>=S[i+1]:
    T[i]=1


ans=1
for t in T:
  if t==0:
    ans=1
  else:
    ans+=1
print(ans)

Failing test case input:
5
2 1 2 0 3

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
A.sort()

S=[A[0]]
for i in range(1,N):
  S.append(S[i-1]+A[i])


T=[0]*(N-1)
for i in range(N-1):
  if S[i]*2>=A[i+1]:
    T[i]=1


ans=1
for t in T:
  if t==0:
    ans=1
  else:
    ans+=1
print(ans)
Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import*
n,*a=map(int,open(0).read().split())
acc=list(accumulate(sorted(a)))[::-1]
c=1
i=0
while i<n-1:
  if acc[i]<=acc[i+1]*2:
    c+=1
    i+=1
  else:
    break
print(c)

Failing test case input:
6
40 2 21 1 9 20

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
from itertools import*
n,*a=map(int,open(0).read().split())
acc=list(accumulate(sorted(a)))[::-1]
c=1
i=0
while i<n-1:
  if acc[i]-acc[i+1]<=acc[i+1]*2:
    c+=1
    i+=1
  else:
    break
print(c)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
As = list(map(int, input().split()))
As.sort()
from itertools import accumulate
cum = accumulate(As)
cnt = 0
for n in range(N-1):
    if As[n]*2<As[n+1]:
        cnt += 1
print(N-cnt)
    



Failing test case input:
6
36 2 21 1 1 38

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
As = list(map(int, input().split()))
As.sort()
from itertools import accumulate
cum = list(accumulate(As))
cnt = 0
for n in range(N-1):
    if cum[n]*2>=As[n+1]:
        cnt += 1
    else:
        cnt = 0
cnt += 1
print(cnt)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
L = sorted(map(int, input().split()))
S = [0] * n
S[0] = L[0]
cnt = 0
for i in range(n-1):
    S[i+1] = S[i] + L[i+1]
    if L[i+1] <= 2 * S[i]:
        cnt += 1
    else:
        cnt = 1
print(cnt)


Failing test case input:
5
1 1 2 1 1

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
L = sorted(map(int, input().split()))
S = [0] * n
S[0] = L[0]
cnt = 1
for i in range(n-1):
    S[i+1] = S[i] + L[i+1]
    if L[i+1] <= 2 * S[i]:
        cnt += 1
    else:
        cnt = 1
print(cnt)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=sorted(list(map(int,input().split())))
ans,s=0,0
for u in l:
  if 2*s>=u:ans+=1
  s+=u
print(ans)

Failing test case input:
6
65 3 38 1 1 38

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n=int(input())
l=sorted(list(map(int,input().split())))
ans,s=1,0
for u in l:
  if 2*s>=u:ans+=1
  else:ans=1
  s+=u
print(ans)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
L = sorted(map(int, input().split()))
S = [0] * n
S[0] = L[0]
for i in range(n-1):
    S[i+1] = S[i] + L[i]
    if L[i+1] > 2 * S[i]:
        print(n - i - 1)
        break
else:
    print(n)


Failing test case input:
6
65 0 38 0 1 69

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
L = sorted(map(int, input().split()))
S = [0] * n
S[0] = L[0]
cnt = 1
for i in range(n-1):
    S[i+1] = S[i] + L[i+1]
    if L[i+1] <= 2 * S[i]:
        cnt += 1
    else:
        cnt = 1
print(cnt)
Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

N = int(input())
creatures = list(map(int, input().split()))

creatures.sort()
cumsum = [0]
tmp = 0
for c in creatures:
    tmp += c
    cumsum.append(tmp)

count = 0
for i,c in enumerate(creatures):
    index_new = 0
    index_old = i 
    t = cumsum[i+1]
    
    
    while True:
        index_new = bisect.bisect_right(creatures,t*2)
        if N == index_new:
            count += 1
            break
        if index_old+1 < index_new:
            t = cumsum[index_new]
            index_old = index_new
        else:
            break

print(count)


Failing test case input:
6
77 1 26 2 7 20

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
creatures = list(map(int, input().split()))

creatures.sort()
cumsum = [0]
tmp = 0
for c in creatures:
    tmp += c
    cumsum.append(tmp)

count = 0
for i,c in enumerate(creatures):
    index_new = 0
    index_old = i 
    t = cumsum[i+1]
    
    
    while True:
        index_new = bisect.bisect_right(creatures,t*2)
        if N == index_new:
            
            count += 1
            break
        if index_old+1 < index_new:
            t = cumsum[index_new]
            
            index_old = index_new-1
        else:
            break

print(count)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = input().split()
for i in range(0,N):
	a[i] = int(a[i])
a.sort()
t = 0
flag = 1
i = 0
sa = a[0]
while flag:
	if 2*sa <= a[i+1]:
		sa += a[i]
		t = i
		i += 1
		if i == N-1: 
			flag = 0
	else:
		flag = 0
		
print(N-t)
		

Failing test case input:
6
77 1 26 2 7 20

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
a = input().split()
for i in range(0,N):
	a[i] = int(a[i])
a.sort()
t = 0
flag = 1
sum_a = 0
for i in range(0,N-1):
	sum_a += a[i]
	if sum_a*2 < a[i+1]:
		t = i+1

			
print(N-t)

Problem: p03786
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from bisect import bisect_left

n = int(input())
a = list(map(int, input().split()))
a.sort()
total = [0] * n
total[0] = a[0]
for i in range(1, n):
    total[i] = a[i] + a[i - 1]


index = bisect_left(total, a[-1] / 2, 0, n)

print(n - index)

Failing test case input:
6
77 1 14 2 7 20

Expected output:
4


Actual output:
1


Fixed submission (verdict: Accepted):
from bisect import bisect_left

n = int(input())
a = list(map(int, input().split()))
a.sort()
total = [0] * n
total[0] = a[0]
for i in range(1, n):
    total[i] = a[i] + total[i - 1]
ans = 1
for i in range(n - 1, 0, -1):
    if a[i] <= total[i - 1] * 2:
        ans += 1
    else:
        break

print(ans)
Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
m = int(input())
n = list(map(int,input().split()))

n.sort()
SUM = 0
count = 0
for i in range(len(n)-1):
    SUM += n[i]
    if n[i+1] > SUM*2:
        count += 1
print(len(n)-count)
    



Failing test case input:
6
65 4 38 1 1 43

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
m = int(input())
n = list(map(int,input().split()))

n.sort()
SUM = 0
count = 0
for i in range(len(n)-1):
    SUM += n[i]
    if n[i+1] > SUM*2:
        count = i+1
print(len(n)-count)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, *A = map(int, open(0).read().split())
A.sort()
t, acc = 0, 0
for i in range(N - 1):
    acc += A[i]
    if acc < A[i + 1]:
        t = i + 1
print(N - t)

Failing test case input:
6
65 2 23 1 1 38

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N, *A = map(int, open(0).read().split())
A.sort()
t, acc = 0, 0
for i in range(N - 1):
    acc += A[i]
    if 2 * acc < A[i + 1]:
        t = i + 1
print(N - t)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=False)
ans = N
for i in range(N-1):
    if A[i]*2 < A[i+1]:
        ans -= 1
print(ans)

Failing test case input:
6
58 1 41 -1 0 2

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):

N = int(input())
A = list(map(int, input().split()))
A.sort()
tmp = 0
s = 0
for i in range(N-1):
    s += A[i]
    if 2*s < A[i+1]:
        tmp = i+1
print(N - tmp)

Problem: p03786
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

a.sort()
now = 0
ans = 1
for i in range(n-1):
  now += a[i]
  if 2*now >= a[i+1]:
    ans += 1

print(ans)

Failing test case input:
6
65 1 38 0 1 69

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
a.sort()
t = -1
sum_a = 0
for i in range(n-1):
    sum_a += a[i]
    if sum_a*2 < a[i+1]:
        t = i

print(n-t-1)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
i=list(map(int,input().split()))
i.sort()
temp=1
size=i[0]
for k in range(1,n):
  if i[k-1]*2>=i[k]:
    temp+=1
    size+=i[k]
  else:
    temp=1
print(temp)

Failing test case input:
6
40 1 26 2 7 20

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
i=list(map(int,input().split()))
i.sort()
temp=1
size=i[0]
for k in range(1,n):
  if size*2>=i[k]:
    temp+=1
    size+=i[k]
  else:
    temp=1
    size+=i[k]
print(temp)
Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=sorted(list(map(int,input().split())))
count=1
sum=n
now=l[0]
for i in range(1,n):
  if now*2<l[i]:
    sum-=count
    now=now+l[i]
    count=0
  else:
    count+=1
    now+=l[i]
print(sum)



Failing test case input:
6
65 1 38 0 1 69

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n=int(input())
l=sorted(list(map(int,input().split())))
count=1
sum=n
now=l[0]
for i in range(1,n):
  if now*2<l[i]:
    sum-=count
    now=now+l[i]
    count=1
  else:
    count+=1
    now+=l[i]
print(sum)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
creatures = list(map(int,input().split()))
creatures.sort()
ans = 1
p = creatures[0]
for i in range(1, n):
    if creatures[i] > p * 2:
        p = creatures[i]
    else:
        ans += 1
print(ans)

Failing test case input:
6
58 2 41 -1 0 2

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
creatures = list(map(int,input().split()))
creatures.sort()
ans = 0
p = creatures[0]
for i in range(1, n):
    if creatures[i] > p * 2:
        ans = 0
    else:
        ans += 1
    p += creatures[i]
ans += 1
print(ans)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
creatures = list(map(int,input().split()))
creatures.sort()
ans = n
p = creatures[0]
r = 1
for i in range(1, n):
    if creatures[i] > p * 2:
        p = creatures[i]
        ans -= r
        r = 0
    else:
        p += creatures[i]
        r += 1

print(ans)

Failing test case input:
6
58 1 41 1 0 2

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
creatures = list(map(int,input().split()))
creatures.sort()
ans = 0
p = creatures[0]
for i in range(1, n):
    if creatures[i] > p * 2:
        ans = 0
    else:
        ans += 1
    p += creatures[i]
ans += 1
print(ans)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(x) for x in input().split()]
A.sort()

print(A)
tmp = A[0]
ans = 1
for i in range(1,N) :
    if A[i] <= tmp*2 :
        tmp += A[i]
        ans += 1
    else :
        tmp += A[i]
        ans = 1

print(ans)


Failing test case input:
6
36 2 21 1 9 20

Expected output:
4


Actual output:
[1, 2, 9, 20, 21, 36]
4


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(x) for x in input().split()]
A.sort()

tmp = A[0]
ans = 1
for i in range(1,N) :
    if A[i] <= tmp*2 :
        ans += 1
    else :
        ans = 1
    tmp += A[i]

print(ans)
Problem: p03786
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = [0 for i in range(n + 1)]
    a.sort()
    ans = n
    for i in range(n):
        b[i + 1] = b[i] + a[i]
    for i in range(n - 1):
        if b[i + 2] - b[i + 1] > a[i] * 2:
            ans = n - i

    print(ans)

main()

Failing test case input:
6
58 1 63 0 2 2

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = [0 for i in range(n + 1)]
    a.sort()
    ans = n
    for i in range(n):
        b[i + 1] = b[i] + a[i]
    for i in range(1,n):
        if b[i + 1] - b[i] >  2 * b[i]:
            ans = n - i
    print(ans)

main()

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = input().split()
for i in range(0,N):
	a[i] = int(a[i])
a.sort()
t = 0
flag = 1
sum_a = 0
for i in range(0,N):
	sum_a += a[i]
	if sum_a*2 < a[i]:
		t = i+1

			
print(N-t)

Failing test case input:
6
65 3 38 -1 1 43

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
N = int(input())
a = input().split()
for i in range(0,N):
	a[i] = int(a[i])
a.sort()
t = 0
flag = 1
sum_a = 0
for i in range(0,N-1):
	sum_a += a[i]
	if sum_a*2 < a[i+1]:
		t = i+1

			
print(N-t)

Problem: p03786
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
al = list(map(int, input().split()))
al.sort()

c_sum = al[0]
cnt = 1
max_cnt = 1
for a in al[1:]:
    if c_sum*2 >= a:
        c_sum += a
        cnt += 1
    else:
        c_sum += a
        max_cnt = max(max_cnt,cnt)
        cnt = 1

ans = max(max_cnt,cnt)
print(ans)

Failing test case input:
6
58 1 95 0 1 1

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
al = list(map(int, input().split()))
al.sort()

c_sum = al[0]
cnt = 1
for a in al[1:]:
    if c_sum*2 >= a:
        c_sum += a
        cnt += 1
    else:
        c_sum += a
        cnt = 1

print(cnt)

Problem: p03786
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

N = int(input())
A = list(map(int, input().split()))
A.sort()
R = [sum(A[:i]) for i in range(N)]

A.sort(reverse=True)
R.sort(reverse=True)

cnt = 0
for i,j in zip(R[0:], A[:-1]):

  if i * 2 >= j:
    cnt += 1
print(cnt)


Failing test case input:
6
65 3 45 0 1 43

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):

N = int(input())
A = list(map(int, input().split()))
A.sort()
R = []
s = 0
for i in A:
  s += i
  R.append(s)
  


A.sort(reverse=True)
R.sort(reverse=True)



cnt = 1
for i,j in zip(R[1:], A[:-1]):

  if i * 2 >= j:
    cnt += 1
  else:
    break
print(cnt)
Problem: p03786
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import copy
n=int(input())
a=list(map(int,input().split()))
a.sort()
c=i=st=0

while i <n-1:
  if 2*(a[st]+c) >= a[i+1]:
    c+=a[i+1]
    i+=1
  else:
    st=i+1
    c=a[st]+c
    i+=1
print(n-st)

Failing test case input:
6
65 2 38 0 1 10

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
import copy
n=int(input())
a=list(map(int,input().split()))
a.sort()
c=i=st=0

while i <n-1:
  
  if 2*(a[st]+c) >= a[i+1]:
    c+=a[i+1]
    i+=1
    
  else:
    c=a[st]+c
    st=i+1
    i+=1
    
print(n-st)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
L = sorted(map(int, input().split()))
S = [0] * n
S[0] = L[0]
for i in range(n-1):
    S[i+1] = S[i] + L[i]
    if L[i+1] > 2 * S[i]:
        print(n - i)
        break
else:
    print(n)


Failing test case input:
5
1 2 0 0 2

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
L = sorted(map(int, input().split()))
S = [0] * n
S[0] = L[0]
cnt = 1
for i in range(n-1):
    S[i+1] = S[i] + L[i+1]
    if L[i+1] <= 2 * S[i]:
        cnt += 1
    else:
        cnt = 1
print(cnt)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
f = lambda: map(int,input().split())
n = int(input())
a = sorted(list(f()))
s = [a[0]]
for i in range(n-1):
    s.append(s[-1]+a[i+1])
for i in range(2,n):
    if s[-i]*2<a[-i+1]:
        break
print(i-1)


Failing test case input:
5
2 1 2 0 2

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
f = lambda: map(int,input().split())
n = int(input())
a = sorted(list(f()))
s = [a[0]]
for i in range(n-1):
    s.append(s[-1]+a[i+1])
ans = 1
for i in range(2,n+1):
    if s[-i]*2<a[-i+1]:
        break
    ans += 1
print(ans)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

n = int(readline())
a = sorted(tuple(map(int, readline().split())))
cnt = 1
cumsum = list(itertools.accumulate(a))

for i in range(1, n):
    if cumsum[i - 1] * 2 < a[i]:
        n -= cnt
        cnt = 0
    else:
        cnt += 1
print(n)


Failing test case input:
6
65 1 38 0 0 94

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

n = int(readline())
a = sorted(tuple(map(int, readline().split())))
cnt = 1
cumsum = list(itertools.accumulate(a))
for i in range(1, n):
    if cumsum[i - 1] * 2 < a[i]:
        n -= cnt
        cnt = 0
    cnt += 1
print(n)
Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gattai(ar,i):
    sm = sum(ar[:i+1])
    idx = i
    while True:
        if idx == len(ar)-1:
            return len(ar)
        elif ar[idx+1] <= sm:
            sm += ar[idx+1]
            idx += 1
            continue
        else: return i-idx-1

n = int(input())
ar = list(map(int, input().split()))
ar.sort()

ans = 0
idx = 0
while ans <= 0:
    hoge = gattai(ar, idx)
    ans += hoge
    idx = abs(ans) + 1

print(ans)


Failing test case input:
6
36 2 21 1 9 38

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
def gattai(ar,i):
    sm = sum(ar[:i+1])
    idx = i
    while True:
        if idx == len(ar)-1:
            return len(ar)
        elif ar[idx+1] <= sm*2:
            sm += ar[idx+1]
            idx += 1
            continue
        else: return i-idx-1

n = int(input())
ar = list(map(int, input().split()))
ar.sort()

ans = 0
idx = 0
while ans <= 0:
    hoge = gattai(ar, idx)
    ans += hoge
    idx = abs(ans)

print(ans)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))

a.sort()
count1=0
count2=0
for i in range(n-1):
    count1+=a[i]
    if 2*count1<a[i+1]:
        count2+=i+1
print(n-count2)

Failing test case input:
5
2 -1 2 0 0

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))

a.sort()
count1=0
count2=0
for i in range(n-1):
    count1+=a[i]
    if 2*count1<a[i+1]:
        count2=i+1
print(n-count2)

Problem: p03786
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = [0 for i in range(n + 1)]
    a.sort()
    ans = n
    for i in range(n):
        b[i + 1] = b[i] + a[i]
    for i in range(n - 1):
        if b[i + 2] - b[i + 1] > a[i] * 2:
            ans = n - i - 1

    print(ans)

main()

Failing test case input:
6
30 1 63 0 1 1

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = [0 for i in range(n + 1)]
    a.sort()
    ans = n
    for i in range(n):
        b[i + 1] = b[i] + a[i]
    for i in range(1,n):
        if b[i + 1] - b[i] >  2 * b[i]:
            ans = n - i
    print(ans)

main()

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [ int(x) for x in input().split() ]

a.sort()
t = 0
s = 0
for k, v in enumerate(a):
   s += v
   if k+1 < n and s*2 < a[k+1]:
       t = k+1
       break

print(n-t)



Failing test case input:
6
43 1 38 0 1 94

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
n = int(input())
a = [ int(x) for x in input().split() ]

a.sort()
t = 0
s = 0
for k, v in enumerate(a):
   s += v
   if k+1 < n and s*2 < a[k+1]:
       t = k+1

print(n-t)
Problem: p03786
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = [0 for i in range(n + 1)]
    a.sort()
    ans = n
    now = a[0]
    for i in range(n):
        b[i + 1] = b[i] + a[i]
    for i in range(n - 1):
        if b[i + 2] - b[i + 1] > now * 2:
            ans = n - i - 1
            break
        else:
            now = b[i + 1]

    print(ans)

main()

Failing test case input:
6
65 2 38 -1 1 43

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = [0 for i in range(n + 1)]
    a.sort()
    ans = n
    for i in range(n):
        b[i + 1] = b[i] + a[i]
    for i in range(1,n):
        if b[i + 1] - b[i] >  2 * b[i]:
            ans = n - i
    print(ans)

main()

Problem: p03786
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

wa = A[0]  
cnt = 1  
for i in range(1, N):
    if 2 * wa >= A[i]:
        cnt += 1
    else:
        cnt = 1
    wa += A[i]
    print(cnt)


Failing test case input:
5
1 2 0 -1 2

Expected output:
2


Actual output:
1
1
1
2


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

wa = A[0]  
cnt = 1  
for i in range(1, N):
    if 2 * wa >= A[i]:
        cnt += 1
    else:
        cnt = 1
    wa += A[i]
print(cnt)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=n
tmp=0
for i in range(n-1):
    tmp+=a[i]
    if not tmp*2>=a[i+1]:
        ans-=(i+1)
print(ans)

Failing test case input:
6
58 1 63 0 1 1

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
tmp=0
for i in range(n-1):
    tmp+=a[i]
    if not tmp*2>=a[i+1]:
        ans+=((i+1)-ans)
print(n-ans)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

cnt = 1
for i in range(n - 1):
    if a[i + 1] * 2 >= a[i]:
        cnt += 1
print(cnt)


Failing test case input:
6
58 1 41 -1 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
a = [0] + sorted(list(map(int, input().split())))

j = 0
now = 0
for i in range(n):
    now += a[i]
    if now * 2 < a[i + 1]:
        j = i
print(n - j)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
b[0]=a[0]
for i in range(1,n):
  b[i]=b[i-1]+a[i]
p=1
for i in range(n-1)[::-1]:
  if b[i]*2>=a[i+1]:
    p+=1
  else:
    break
print(p)

Failing test case input:
6
36 2 21 1 4 20

Expected output:
3


Actual output:
6


Fixed submission (verdict: Accepted):
n=int(input())
a=sorted(list(map(int,input().split())))
b=[0]*n
b[0]=a[0]
for i in range(1,n):
  b[i]=b[i-1]+a[i]
p=1
for i in range(n-1)[::-1]:
  if b[i]*2>=a[i+1]:
    p+=1
  else:
    break
print(p)
Problem: p03786
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
a=sorted(list(map(int,input().split())))
flag=0
ans=1
a_cumulative=[0]
for i in range(n):
  flag+=a[i]
  a_cumulative.append(flag)
a.reverse()
a_cumulative.reverse()
for j in range(n-1):
  if a[j]<= a_cumulative[j+1]*2:
    ans+=1
print(ans)


Failing test case input:
6
30 3 38 1 1 38

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
n=int(input())
a=sorted(list(map(int,input().split())))
flag=0
ans=1
a_cumulative=[0]
for i in range(n):
  flag+=a[i]
  a_cumulative.append(flag)
a.reverse()
a_cumulative.reverse()
for j in range(n-1):
  if a[j] <= a_cumulative[j+1]*2:
    ans+=1
  else:
    break
print(ans)

Problem: p03786
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = list(map(int,input().split()))
A = [(a,idx+1) for idx,a in enumerate(list(map(int,input().split())))]
A = sorted(A)

color_set = set()
prev_sum = 0
prev_num = 0
for a,color in A:
  if prev_num == a or prev_sum*2 <=a :
    color_set |= {color}
  elif a > prev_sum*2:
    color_set = {color}
  prev_sum += a
  prev_num = a
print(len(color_set))    

Failing test case input:
6
58 1 63 0 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
N = list(map(int,input().split()))
A = [(a,idx+1) for idx,a in enumerate(list(map(int,input().split())))]
A = sorted(A)

color_set = set()
prev_sum = 0
prev_num = 0
for a,color in A:
  if prev_num == a or prev_sum*2 >=a :
    color_set |= {color}
  else:
    color_set = {color}
  prev_sum += a
  prev_num = a
  
print(len(color_set))

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = [0]
for i in range(n-1):
    b.append(b[-1]+a[i])

print(b)
result = 1
for i in range(1, n+1):
    if b[-i]*2 < a[-i]:
        break
    result += 1
print(result)

Failing test case input:
6
65 3 23 1 2 38

Expected output:
3


Actual output:
[0, 1, 3, 6, 29, 67]
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
a.sort()
b = [0]
for i in range(n-1):
    b.append(b[-1]+a[i])
result = 1
for i in range(1, n+1):
    if b[-i]*2 < a[-i]:
        break
    result += 1
print(result)

Problem: p03786
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = [0 for i in range(n + 1)]
    a.sort()
    ans = n
    for i in range(n):
        b[i + 1] = b[i] + a[i]
    for i in range(n - 1):
        if b[i + 2] - b[i + 1] > a[i] * 2:
            ans = n - i - 1
            break

    print(ans)

main()

Failing test case input:
6
65 3 33 1 1 38

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = [0 for i in range(n + 1)]
    a.sort()
    ans = n
    for i in range(n):
        b[i + 1] = b[i] + a[i]
    for i in range(1,n):
        if b[i + 1] - b[i] >  2 * b[i]:
            ans = n - i
    print(ans)

main()
Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res
n = int(input())
data = list(map(int, input().split()))
cnt = count(data)
monsters = sorted(cnt.keys())
total = sum(data)
ans = n
idx = len(monsters)-2
while idx >= 0:
    prev = monsters[idx+1]
    total -= prev*cnt[prev]
    if total*2 < prev:
        break
    idx -= 1

ans -= max(0, idx+1) 
print(ans)

Failing test case input:
6
36 2 21 1 1 38

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res
n = int(input())
data = list(map(int, input().split()))
cnt = count(data)
monsters = sorted(cnt.keys())
total = sum(data)
ans = n
idx = len(monsters)-2
while idx >= 0:
    prev = monsters[idx+1]
    total -= prev*cnt[prev]
    if total*2 < prev:
        break
    idx -= 1
out = 0
while idx >= 0:
    m = monsters[idx]
    out += cnt[m]
    idx -= 1

ans -= out 
print(ans)

Problem: p03786
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))



import itertools as it

N=one_int()

A=many_int()

A=sorted(A)
sums_A=list(it.accumulate(A))

for i in range(N-1):
    if 2*sums_A[i] < A[i+1]: 
        break

if len(set(A))==1:
    print(N)
else:
    print(N-i-1)



Failing test case input:
6
65 1 38 0 1 94

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))



import itertools as it

N=one_int()

A=many_int()

A=sorted(A)
sums_A=list(it.accumulate(A))

for i in range(N-1, -1, -1):
    if 2*sums_A[i-1] < A[i]: 
        break

print(N-i)

Problem: p03786
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    A = sorted(A)

    now = N
    A_cumsum = [A[0]]
    for i in range(1,N):
        A_cumsum.append(A_cumsum[-1]+A[i])

    
    for i in range(N):
        if i==N-1:
            break
        if A_cumsum[i]*2>=A[i+1]:
            break
        else:
            pass
    print(N-i)


if __name__ == "__main__":
    main()



Failing test case input:
6
40 1 26 2 9 20

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    A = sorted(A)

    now = N
    A_cumsum = [A[0]]
    for i in range(1,N):
        A_cumsum.append(A_cumsum[-1]+A[i])
    ans = 0
    for i in range(1,N):
        if A_cumsum[i-1]*2>=A[i]:
            pass
        else:
            ans = i
    print(N-ans)

if __name__ == "__main__":
    main()
Problem: p03786
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = [0 for i in range(n + 1)]
    a.sort()
    ans = 1
    for i in range(n):
        b[i + 1] = b[i] + a[i]
    for i in range(n - 1):
        if b[i + 2] - b[i + 1] <= a[i] * 2:
            ans += 1

    print(ans)

main()

Failing test case input:
6
36 2 21 1 4 20

Expected output:
3


Actual output:
5


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    b = [0 for i in range(n + 1)]
    a.sort()
    ans = n
    for i in range(n):
        b[i + 1] = b[i] + a[i]
    for i in range(1,n):
        if b[i + 1] - b[i] >  2 * b[i]:
            ans = n - i
    print(ans)

main()

Problem: p03786
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

wa = A[0]
cnt = 0
for i in range(1, N):
    if wa >= A[i]:
        cnt += 1
    else:
        cnt = 1
    wa += A[i]
print(cnt + 1)


Failing test case input:
6
36 2 21 1 4 20

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

wa = A[0]  
cnt = 1  
for i in range(1, N):
    if 2 * wa >= A[i]:
        cnt += 1
    else:
        cnt = 1
    wa += A[i]
print(cnt)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
creatures = list(map(int,input().split()))
creatures.sort()
ans = n
for i in range(n-1):
    if creatures[i+1] > creatures[i] * 2:
        ans -= 1

print(ans)

Failing test case input:
6
58 1 41 0 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())
creatures = list(map(int,input().split()))
creatures.sort()
ans = 0
p = creatures[0]
for i in range(1, n):
    if creatures[i] > p * 2:
        ans = 0
    else:
        ans += 1
    p += creatures[i]
ans += 1
print(ans)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
A.sort()

B=[A[0]]
for i in range(1,N):
  B.append(B[-1]+A[i])



left=0
for left in range(N-2,-1,-1):
  if B[left]*2>=A[left+1]:
    pass
  else:
    break

num=N-left-1







Failing test case input:
6
36 2 42 1 9 38

Expected output:
3


Actual output:

Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
A.sort()

B=[A[0]]
for i in range(1,N):
  B.append(B[-1]+A[i])



left=0
for left in range(N-2,-1,-1):
  if B[left]*2>=A[left+1]:
    pass
  else:
    break
else:
  left=-1

num=N-left-1

print(num)
Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

a = list(map(int, input().split()))
a = sorted(a)

ans = n
size = a[0]
count = 1
for i in range(1, n - 1):
    if a[i + 1] > size * 2:
        ans -= count
        count = 1
        size = a[i + 1]
    else:
        count += 1
        size += a[i + 1]


print(ans)



Failing test case input:
6
65 3 38 1 1 43

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n = int(input())

a = list(map(int, input().split()))
a = sorted(a)

ans = n
size = a[0]
count = 1
for i in range(1, n):
    if a[i] > size * 2:
        count = 1
    else:
        count += 1
    size += a[i]

print(count)

Problem: p03786
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from itertools import*
n, *a = map(int, open(t := 0).read().split())
a.sort();*b, = accumulate(a)
for i in range(1, n):
  if 2 * b[i - 1] < a[i]:t = i;break
print(n - t)

Failing test case input:
6
58 1 63 0 1 1

Expected output:
2


Actual output:
5


Fixed submission (verdict: Accepted):
from itertools import*
n, *a = map(int, open(t := 0).read().split())
a.sort()
*b, = accumulate(a)
for i in range(1, n):
  if 2 * b[i - 1] < a[i]:t = i
print(n - t)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
a_t = a_t[1:]
ans = 0
canEat = []
mi = 0
for i in range(n):
    index = bisect.bisect_right(a, a[i] * 2) - 1
    canEat.append(index)
    if index == n - 1:
        if not mi:
            mi = i
for i in range(n):
    index = bisect.bisect_right(a, a_t[i] * 2) - 1
    if index >= mi:
        ans += 1
print(ans)

Failing test case input:
6
43 1 38 0 1 94

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
a_t = [0]
for i in range(n):
    a_t.append(a[i] + a_t[i])
a_t = a_t[1:]
ans = 0
mi = 0
for i in range(n):
    index = bisect.bisect_right(a, a[i] * 2) - 1
    if index == n - 1:
        if not mi:
            mi = i
for i in range(n - 1, -1, -1):
    index = bisect.bisect_right(a, a_t[i] * 2) - 1
    if index >= mi:
        mi = i
        ans += 1
print(ans)
Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))

def accmulate(arr):
    global cs
    N = len(arr)
    cs = [0]*(N+1)
    for i in range(N):
        cs[i+1] = cs[i] + arr[i]


def query(l,r):
    return cs[r] - cs[l]

A = sorted(A)
accmulate(A)

ans = N

for i in range(N-1):
    if not A[i+1] <= 2*query(0,i+1):
        ans -= (i+1)
        break

print(ans)

Failing test case input:
6
58 1 41 -1 0 2

Expected output:
2


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))

def accmulate(arr):
    global cs
    N = len(arr)
    cs = [0]*(N+1)
    for i in range(N):
        cs[i+1] = cs[i] + arr[i]


def query(l,r):
    return cs[r] - cs[l]

A = sorted(A)
accmulate(A)

ans = N

for i in range(N-1,0,-1):
    if not A[i] <= 2*query(0,i):
        ans -= i
        break

print(ans)

Problem: p03786
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))



import itertools as it

N=one_int()

A=many_int()

A=sorted(A)
sums_A=list(it.accumulate(A))





for i in range(N-1):
    if 2*sums_A[i] < A[i+1]: 
        break

print(N-i-1)

Failing test case input:
6
58 1 63 0 1 2

Expected output:
2


Actual output:
5


Fixed submission (verdict: Accepted):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))



import itertools as it

N=one_int()

A=many_int()

A=sorted(A)
sums_A=list(it.accumulate(A))

for i in range(N-1, -1, -1):
    if 2*sums_A[i-1] < A[i]: 
        break

print(N-i)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import accumulate
N = int(input())
a = list(map(int, input().split()))
a.sort()

b = list(accumulate(a))

ans = N
for i in range(N-1)[::-1]:
    if 2 * b[i] < a[i+1]:
        ans -= i+1
        
print(ans)

Failing test case input:
6
65 2 38 -1 1 43

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
from itertools import accumulate
N = int(input())
a = list(map(int, input().split()))
a.sort()

b = list(accumulate(a))

ans = N
for i in range(N-1)[::-1]:
    if 2 * b[i] < a[i+1]:
        ans -= i+1
        break
        
print(ans)

Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
A=list(map(int,input().split()))
saisho=10**15
cnt=0
for i in range(n):
    if  A[i]<saisho/2:
        saisho=A[i]
    else:
        cnt+=1
print(cnt)

Failing test case input:
5
2 0 2 0 0

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n=int(input())
A=list(map(int,input().split()))
A.sort()
cnt=1
cum=0
for i in range(n-1):
    cum+=A[i]
    if A[i+1]-2*cum<=0:
        cnt+=1
    else:
        cnt=1
print(cnt)
Problem: p03786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(x) for x in input().split(' ')]

a.sort()
s = [a[0]]
for i in range(1, n):
  s.append(a[i - 1] + a[i])

res = 1
for i in range(1, n):
  if s[-i] * 2 >= a[-i + 1]:
    res += 1
  else:
    break

print(res)


Failing test case input:
6
58 1 63 0 1 2

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(x) for x in input().split(' ')]

a.sort()
s = [a[0]]
for i in range(1, n):
  s.append(s[i - 1] + a[i])

res = 1
for i in reversed(range(0, n - 1)):
  if s[i] * 2 >= a[i + 1]:
    res += 1
  else:
    break

print(res)

Problem: p03786
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
creature_list = [ int(v) for v in input().split() ]

def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist
creature_list = sorted(creature_list)
creature_list_0 = list(reversed(creature_list))
creature_list = cumsum(creature_list)
creature_list = list(reversed(creature_list))


for i in range(1,n):
    if creature_list_0[i-1] > creature_list[i] * 2:
        print(i)
        break

Failing test case input:
5
1 2 1 1 2

Expected output:
5


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
creature_list = [ int(v) for v in input().split() ]

def cumsum(inlist):
    s = 0
    outlist = []
    for i in inlist:
        s += i
        outlist.append(s)
    return outlist
creature_list = sorted(creature_list)
creature_list_0 = list(reversed(creature_list))
creature_list = cumsum(creature_list)
creature_list = list(reversed(creature_list))

ans = None
for i in range(1,n):
    if creature_list_0[i-1] > creature_list[i] * 2:
        ans = i
        break
if ans == None:
    ans = n
print(ans)
Problem: p02815
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
mod=10**9+7
c=list(map(int,input().split()))
c.sort()
ans=0
for i in range(n):
    ans+=c[i]*(n-i+2)
    ans%=mod
print(ans*pow(4,n-1,mod)%mod)


Failing test case input:
5
2 67 30 25 55

Expected output:
142336


Actual output:
188160


Fixed submission (verdict: Accepted):
n=int(input())
mod=10**9+7
c=list(map(int,input().split()))
c.sort()
ans=0
for i in range(n):
    ans+=c[i]*(n-i+1)
    ans%=mod
print((ans*pow(4,n-1,mod))%mod)

Problem: p02815
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
mod=10**9+7
c=list(map(int,input().split()))
c.sort()
ans=0
for i in range(n):
    ans+=c[i]*(1+1+i)
    ans%=mod
print(n*ans*pow(4,n-1,mod)%mod)


Failing test case input:
5
2 116 2 5 2

Expected output:
70912


Actual output:
945920


Fixed submission (verdict: Accepted):
n=int(input())
mod=10**9+7
c=list(map(int,input().split()))
c.sort()
ans=0
for i in range(n):
    ans+=c[i]*(n-i+1)
    ans%=mod
print((ans*pow(4,n-1,mod))%mod)

Problem: p02815
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
mod=10**9+7
c=list(map(int,input().split()))
c.sort()
ans=0
for i in range(n):
    ans+=c[i]*(n-i)
    ans%=mod
print(ans*pow(4,n-1,mod)%mod)

Failing test case input:
5
3 124 11 37 1

Expected output:
108544


Actual output:
63488


Fixed submission (verdict: Accepted):
n=int(input())
mod=10**9+7
c=list(map(int,input().split()))
c.sort()
ans=0
for i in range(n):
    ans+=c[i]*(n-i+1)
    ans%=mod
print((ans*pow(4,n-1,mod))%mod)

Problem: p02815
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
mod=10**9+7
c=list(map(int,input().split()))
c.sort()
ans=0
for i in range(n):
    ans+=c[i]*(n-i)
    ans%=mod
print(2*ans*pow(4,n-1,mod)%mod)


Failing test case input:
5
2 124 30 25 1

Expected output:
116224


Actual output:
139264


Fixed submission (verdict: Accepted):
n=int(input())
mod=10**9+7
c=list(map(int,input().split()))
c.sort()
ans=0
for i in range(n):
    ans+=c[i]*(n-i+1)
    ans%=mod
print((ans*pow(4,n-1,mod))%mod)

Problem: p02815
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
mod=10**9+7
c=list(map(int,input().split()))
c.sort()
ans=0
for i in range(n):
    ans+=c[i]*(1+1+i)
    ans%=mod
print(ans*pow(4,n-1,mod)%mod)


Failing test case input:
5
2 116 8 5 1

Expected output:
74752


Actual output:
195584


Fixed submission (verdict: Accepted):
n=int(input())
mod=10**9+7
c=list(map(int,input().split()))
c.sort()
ans=0
for i in range(n):
    ans+=c[i]*(n-i+1)
    ans%=mod
print((ans*pow(4,n-1,mod))%mod)
Problem: p02815
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
c = list(map(int, input().split()))

mod = 10**9 + 7
c.sort()
ans = 0

for i in range(n):
    ans += c[i] * pow(2, i, mod) % mod * pow(2, n-i-1, mod) % mod * (n-i) % mod
    ans %= mod

print(ans)

Failing test case input:
5
2 124 30 25 32

Expected output:
153856


Actual output:
6208


Fixed submission (verdict: Accepted):
n = int(input())
c = list(map(int, input().split()))

mod = 10**9 + 7
c.sort()
ans = 0

for i in range(n):
    ans += c[i] * pow(2, i, mod) % mod * (pow(2, n-i-2+n, mod) * (n-i-1) + pow(2, n-i-1+n, mod)) % mod
    ans %= mod

print(ans)

Problem: p02815
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
c = list(map(int, input().split()))
p = 10**9+7
print(sum([(i+2) * c[i] for i in range(n)]) * pow(4, n-1, p) % p)

Failing test case input:
5
2 124 30 25 32

Expected output:
153856


Actual output:
208128


Fixed submission (verdict: Accepted):
n = int(input())
c = sorted(list(map(int, input().split())), reverse=True)
p = 10**9+7
print(sum([(i+2) * c[i] for i in range(n)]) * pow(4, n-1, p) % p)

Problem: p02815
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
c = list(map(int, input().split()))
c.sort(reverse = True)
mod = 10 ** 9 + 7
tmp = 2 ** (N - 1) % mod
d = tmp 
ans = 0
for ci in c:
    ans += ci * tmp % mod
    ans %= mod
    tmp += d
print(ans * 2 ** N % mod)


Failing test case input:
5
2 124 30 25 55

Expected output:
171520


Actual output:
222208


Fixed submission (verdict: Accepted):
N = int(input())
c = list(map(int, input().split()))
c.sort(reverse = True)
mod = 10 ** 9 + 7
tmp = (2 ** (N - 1)) % mod
d  = (2 ** (N - 2)) % mod
ans = 0
for ci in c:
    ans += (ci * tmp) % mod
    ans %= mod
    tmp = (tmp + d) % mod
print((ans * 2 ** N) % mod)

Problem: p02815
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
mod=10**9+7
c=list(map(int,input().split()))
c.sort()
ans=0
for i in range(n):
    ans+=c[i]*(1+i)
    ans%=mod
print(ans*pow(4,n-1,mod)%mod)


Failing test case input:
5
63 103 72 25 79

Expected output:
306176


Actual output:
306688


Fixed submission (verdict: Accepted):
n=int(input())
mod=10**9+7
c=list(map(int,input().split()))
c.sort()
ans=0
for i in range(n):
    ans+=c[i]*(n-i+1)
    ans%=mod
print((ans*pow(4,n-1,mod))%mod)

Problem: p02815
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
C = list(map(int,input().split()))
C.sort()
mod = 10**9 + 7
ans = 0
for i in range(N):
    ans += C[i]*(i+2) % mod
ans *= 4**(N-1)
ans % mod
print(ans)

Failing test case input:
5
2 67 30 25 55

Expected output:
142336


Actual output:
224256


Fixed submission (verdict: Accepted):
N = int(input())
C = list(map(int,input().split()))
for i in range(N):
    C[i] *= -1
C.sort()
for i in range(N):
    C[i] *= -1
mod = 10**9 + 7
ans = 0
for i in range(N):
    ans += C[i]*(i+2)
ans = ans*(4**(N-1))
ans = ans % mod
print(ans)
Problem: p02815
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
INF=1e9
mod=1e9+7
n=int(input())
lit=list(map(int,input().split()))
lit.sort()
ans=0
for i in range(n):
    ans=(ans+lit[i]*(n-i+1)%mod)%mod
for i in range(2*(n-1)):
    ans=ans*2%mod
print(ans)


Failing test case input:
5
3 181 30 2 1

Expected output:
122880


Actual output:
122880.0


Fixed submission (verdict: Accepted):
import sys
INF=1e9
mod=1e9+7
n=int(input())
lit=list(map(int,input().split()))
lit.sort()
ans=0
for i in range(n):
    ans=(ans+lit[i]*(n-i+1)%mod)%mod
for i in range(2*(n-1)):
    ans=ans*2%mod
ans=int(ans)
print(ans)

Problem: p02815
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
c = sorted(list(map(int, input().split())))
p = 10**9+7
print(sum([(i+2) * c[i] for i in range(n)]) * pow(4, n-1, p) % p)

Failing test case input:
5
0 139 1 0 4

Expected output:
75264


Actual output:
219648


Fixed submission (verdict: Accepted):
n = int(input())
c = sorted(list(map(int, input().split())), reverse=True)
p = 10**9+7
print(sum([(i+2) * c[i] for i in range(n)]) * pow(4, n-1, p) % p)