Problem:

Income Inequality

We often compute the average as the first step
in processing statistical data.
Yes, the average is a good tendency measure of data,
but it is not always the best.
In some cases, the average may hinder the understanding
of the data.

For example, consider the national income of a country.
As the term income inequality suggests,
a small number of people earn a good portion of the gross national income
in many countries.
In such cases, the average income computes much higher than the
income of the vast majority.
It is not appropriate to regard the average as the income of typical people.

Let us observe the above-mentioned phenomenon in some concrete data.
Incomes of n people, a1, ... ,
an, are given.
You are asked to write a program that reports the number of people
whose incomes are less than or equal to the average
(a1 + ... + an) / n.

Input

The input consists of multiple datasets, each in the following format.

n

a1 a2 ... an

A dataset consists of two lines.
In the first line, the number of people n is given.
n is an integer satisfying 2 &#8804; n &#8804; 10&#8239;000.
In the second line, incomes of n people are given.
ai (1 &#8804; i &#8804; n) is the income
of the i-th person.
This value is an integer greater than or equal to 1 and
less than or equal to 100&#8239;000.

The end of the input is indicated by a line containing a zero.
The sum of n's of all the datasets does not exceed 50&#8239;000.

Output

For each dataset, output the number of people whose incomes are
less than or equal to the average.

Sample Input

7
15 15 15 15 15 15 15
4
10 20 30 60
10
1 1 1 1 1 1 1 1 1 100
7
90 90 90 90 90 90 10
7
2 7 1 8 2 8 4
0

Output for the Sample Input

7
3
9
1
4



Sample input:
7
15 15 15 15 15 15 15
4
10 20 30 60
10
1 1 1 1 1 1 1 1 1 100
7
90 90 90 90 90 90 10
7
2 7 1 8 2 8 4
0


Sample output:
7
3
9
1
4

Submission status: Time Limit Exceeded

Solution code:
from statistics import mean
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=mean(ns):
      c+=1
    else:
      pass
  print(c)

Submission status: Time Limit Exceeded

Solution code:
from statistics import mean
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=mean(ns):
      c+=1
  print(c)

Submission status: Accepted

Solution code:
a = int(input())
su = 0
while a != 0:
    b = list(map(int,input().split()))
    c = sum(b)/len(b)
    for i in range(len(b)):
        if b[i] <= c:
            su += 1
    
    print(su)
    su = 0
    a = int(input())

Submission status: Accepted

Solution code:
# AOJ 1624 Income Inequality
# Python 2018.7.12 bal4u

while True:
	n = int(input())
	if n == 0: break
	a = list(map(int, input().split()))
	s = int(sum(a)//n)
	ans = 0
	for x in a:
		if x <= s: ans += 1
	print(ans)

Submission status: Accepted

Solution code:
while(1):
	n=int(input())
	if n==0:
		break	
	a=[int(i) for i in input().split()]

	total=0
	for i in a:
		total+=i
	
	hei=total/n
	count=0
	for i in a:
		if i <=hei:
			count+=1
	print(count)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break;
    a = list(map(int, input().split()))
    mean = sum(a)/n
    print(len(list(filter(lambda x:x<=mean, a))))

Submission status: Accepted

Solution code:
while True:
  n = int(input())
  if n == 0:break
  alst = list(map(int, input().split()))
  ave = sum(alst) / n
  print(sum(a <= ave for a in alst))

Submission status: Accepted

Solution code:
anslist = []

while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    ans = 0
    ave = sum(a) / n
    for i in range(n):
        if a[i] <= ave:
            ans += 1

    anslist.append(ans)

for i in anslist:
    print(i)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    m = sum(a) / n
    ans = 0
    for aa in a:
        if aa <= m:
            ans += 1
    print(ans)

Submission status: Accepted

Solution code:
while True:
  n=int(input())
  c=0
  if n==0:
    break
  ns=list(map(int, input().split()))
  for i in range(n):
    if ns[i]<=sum(ns)/n:
      c+=1
  print(c)

Submission status: Accepted

Solution code:

while True:
    a = 0
    num = int(input())

    if num == 0: break

    ls = list(map(int,input().split()))
    ave = sum(ls) / num
    

    for i in range(num):
        if ls[i] <= ave :
            a += 1
    print(a)

Submission status: Accepted

Solution code:
while True:
    n = int(input());
    if n == 0:
        break;
    a = list(map(int, input().split()));

    h = sum(a)/n;
    
    k = 0;
    for i in range(0,n):
        if a[i] <= h:
            k += 1;
    print(k);

Submission status: Accepted

Solution code:

while True:
    x=int(input())
    if x==0:
        break
    alst = list(map(int,input().split()))
    num = sum(alst) / x
    print(sum(a <= num for a in alst))

Submission status: Accepted

Solution code:
while True:
    t=[]
    n=int(input())
    if n==0:
        break
    else:
        m=input().strip().split()
        k=[int(i) for i in m]
        x=sum(k)/n
        for i in range(n):
            if k[i]<=x:
                t.append(k[i])
            else:
                pass
        print(len(t))

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))

    sum_a = sum(a)
    ans = 0
    for e in a:
        if e * n <= sum_a:
            ans += 1
    print(ans)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    m=list(map(int,input().split()))
    M=sum(m)//n
    A=0
    for i in range(n):
        S=m[i]-M
        if S<=0:
            A=A+1
    print(A)

Submission status: Accepted

Solution code:
while True:
   n = int(input())
   if n==0:
      break
   a = [int(x) for x in input().split()]
   ave = sum(a)/n
   c = 0
   for j in range(n):
      if a[j]<=ave:
         c += 1
   print(c)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    l=(input().split())
    for i in range(n):
        l[i]=int(l[i])
    m=sum(l)/n
    a=0
    for i in range(n):
        if l[i]<=m:
           a+=1
    print(a)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    a=list(map(int,input().split()))
    sum=0
    for i in range(n):
        sum+=a[i]
    ave=sum/n
    count=0
    for i in range(n):
        if a[i]<=ave:
            count+=1
    print(count)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    a=list(map(int,input().split()))
    
    c=0
    ave=0
    for i in range(n):
        ave=ave+a[i]
    ave=ave//n
    for i in range(n):
        if ave>=a[i]:
            c=c+1
    
    print(c)

Submission status: Accepted

Solution code:
ans = []
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    avg = sum(a) / n
    ans.append(sum(avg >= x for x in a))
print(*ans, sep="\n")

Submission status: Accepted

Solution code:
try:
    while True:
        n = int(input())
        if n == 0:
            break
        ika = 0
        a = list(map(int,input().split()))
        m = sum(a) / n
        for j in a:
            if j <= m:
                ika += 1 
        print(ika)
except EOFError:
    pass

Submission status: Accepted

Solution code:

while 1:
    n = int(input())
    if n==0: break
    a = list(map(int, input().split()))
    
    ave = sum(a)/n
    
    print(len([i for i in a if i <= ave]))
    #リスト内包表記、条件を満たす要素の数をlen()で表示

Submission status: Accepted

Solution code:
while True:
    M=0
    
    A=int(input())
    
    if A==0:
        break
    
    L=list(map(int,input().split()))
    
    B=sum(L)/len(L)
    
    for i in range(A):
        if L[i]<=B:
            M+=1
            
    print(M)

Submission status: Accepted

Solution code:
while True:
    a=int(input())
    if a==0:
        break
    else:
        b=list(map(int,input().split()))
        h=sum(b)/a
        c=0
        for i in range(a):
            if h>=b[i]:
                c+=1
            else:
                pass
        print(c)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    else:
        X=[int(i) for i in input().split()]
        a=sum(X)/n
        s=0
        for i in range(n):
            if X[i]<=a:
                s+=1
        print(s)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

while True:
   n = int(input()) # 国民の人数
   if n == 0: break
   
   income = list(map(int, input().split()))
   avg = sum(income) // n
   
   c = 0
   for i in range(n):
      if income[i] <= avg:
         c += 1
   print(c)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    a=list(map(int,input().split()))
    ans=0
    ave=sum(a)/n
    for i in range(n):
        if a[i]<=ave:
            ans+=1
    print(ans)

Submission status: Accepted

Solution code:
while True:
    try:
        n = int(input())
        a = list(map(int,input().split()))
        s = sum(a)
        ave = s/n
    
        i = 0
        x = []
        while i <= n-1:
            if a[i] <= ave:
                x.append(a[i])
            i += 1

        print(len(x))
    
    except:
        if n == 0:
            break

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    lst=list(map(int,input().split()))
    x=sum(lst)/n
    ans=0
    for i in lst:
        if x>=i:
            ans+=1
    print(ans)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    
    if n == 0:
        break
    
    a = list(map(int,input().split()))
    
    b = sum(a)/n
    
    
    ans = 0
    for i in a:
        if i <= b:
            ans += 1
        
    print(ans)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n==0:
        break
    a = [int(a) for a in input().split()]
    ave = sum(a)/n
    count = 0
    for i in range(n):
        if a[i]<=ave:
            count += 1
    print(count)

Submission status: Accepted

Solution code:
while True :
    n = int(input())
    if n == 0 :
        break
    
    lst = list(map(int, input().split()))
    ave_lst = sum(lst) / len(lst)
    Sum = 0
    for i in range(n) :
        if lst[i] <= ave_lst :
            Sum += 1
    print(Sum)

Submission status: Accepted

Solution code:
#無限ループと標準入力とカウンタ変数のリセット
while True:
    kai = 0
    num = int(input())
    
    #入力値が0だったら終わる
    if num == 0:break

    #標準入力をし、平均値を求める
    line = list(map(int,input().split()))
    heikin = sum(line) / num
    
    #平均値以下の個数を調べ個数を出力
    for i in range(num):
        if line[i] <= heikin:kai += 1
    print(kai)

Submission status: Accepted

Solution code:
while True :
    n = int(input())
    
    if n == 0 :
        break
    
    else :
        A = list(map(int, input().split()))
        cnt = 0
        
        ave = sum(A) / n
        # 平均 average
        
        for i in range(len(A)) :
            if A[i] <= ave :
                cnt += 1
                
        print(cnt)

Submission status: Accepted

Solution code:
while True:
    t=0
    n=int(input())
    if n==0:
        break
    else:
        y=list(map(int,input().split()))
        s=sum(y)/n
        for i in range(n):
            if y[i]<=s:
                t+=1
        print(t)

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break
    a = list(map(int,input().split()))
    cnt = 0
    ave = sum(a) / n
    for i in a:
        if ave >= i:
           cnt +=1
    print(cnt)

Submission status: Accepted

Solution code:
import statistics

def get_data():
    data = int(input())
    return data

def get_data_list():
    data_list = input().split()
    for i, v in enumerate(data_list):
        data_list[i] = int(v)
    return data_list

def count_num_under_average(list_num, reverse_sorted_num_list, average_num):
    count = list_num
    for v in reverse_sorted_income_list:
        if v > average_num:
            count -= 1
        else:
            break
    return count


if __name__ == "__main__":
    while True:
        population = get_data()
        if population == 0:
            break
        income_list = get_data_list()
        reverse_sorted_income_list = sorted(income_list, reverse=True)
        average_income = statistics.mean(reverse_sorted_income_list)
        count = count_num_under_average(population, reverse_sorted_income_list, average_income)
        print(count)

Submission status: Accepted

Solution code:
def solve():
  while(True):
    N = int(input())
    if N == 0:
      break
    l = list(map(int,input().split()))
    ave = sum(l)//len(l)
    ans = 0
    for a in l:
      if a <= ave:
        ans+=1
    print(ans)
if __name__ == '__main__':
  solve()

Submission status: Accepted

Solution code:
while True:
    c = int(input())
    if c == 0:
        break
    a = list(map(int,input().split()))
    az = sum(a)/c
    ans = 0
    for x in a:
        if x <= az:
            ans += 1
    print(ans)

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    m = sum(a)/n
    cnt = 0
    for i in a:
        if i <= m:
            cnt += 1
    print(cnt)

Submission status: Accepted

Solution code:
while True:
    num = int(input())
    if num == 0:
        break
    else:
        x = input().split()
        for i in range(num):
            x[i] = int(x[i])
        ave = sum(x)/num
        count = 0
        for i in range(num):
            if x[i]<=ave:
                count += 1
        print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/python3

import array
from fractions import Fraction
import functools
import itertools
import math
import os
import sys


def main():
    while True:
        N = read_int()
        if N == 0:
            break
        A = read_ints()
        print(solve(N, A))


def solve(N, A):
    avg = Fraction(sum(A), N)
    return len([a for a in A if a <= avg])


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
while True:
    num = int(input())
    if num == 0:
        break
    
    L = [int(x) for x in input().split()]
    
    ave = sum(L)/ len(L)
    
    c = 0
    for i in L:
        if i <= ave:
            c += 1
    print(c)

Submission status: Accepted

Solution code:
import os,re,sys,operator
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)
while 1:
    n=int(stdin.readline().rstrip())
    if n==0:
        break
    a=[int(i) for i in stdin.readline().rstrip().split()]
    mean=sum(a)/n
    cnt=0
    for i in a:
        if i<=mean:
            cnt+=1
    print(cnt)

Submission status: Accepted

Solution code:
# coding=utf-8

###
### for python program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    def pnum_check(self, n):
        if (n==1):
            return False
        elif (n==2):
            return True
        else:
            for x in range(2,n):
                if(n % x==0):
                    return False
            return True

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans
    
    ### intチェック
    def is_integer(self, n):
        try:
            float(n)
        except ValueError:
            return False
        else:
            return float(n).is_integer()

    ### 幾何学問題用
    def dist(self, A, B):
        d = 0
        for i in range(len(A)):
            d += (A[i]-B[i])**2            
        d = d**(1/2)
        return d

    ### 絶対値
    def abs(self, n):
        if n >= 0:
            return n
        else:
            return -n

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
# print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
# print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
# print(" {}".format(i), end="")

def printA(A):
    N = len(A)
    for i, n in enumerate(A):
        print(n, end='')
        if i != N-1:
            print(' ', end='')
    print()

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート
# N = N.sort()

# 10000個の素数リスト
# P = mymath.pnum_eratosthenes(105000)

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
        except EOFError:
            break
    return N

while True:
    N = int(input())
    if N==0:
        break
    A = [int(x) for x in input().split()]

    ave = sum(A)/N

    count = 0

    for i in A:
        if i <= ave:
            count += 1
    
    print(count)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    avg = sum(a)/n
    print(len([i for i in a if avg >= i]))

Submission status: Accepted

Solution code:
nl=[]
al=[]
while 1:
    n=input()
    if n=="0":
        break
    nl.append(int(n))

    a = list(map(lambda x: int(x), input().split()))
    al.append(a)

for i in range(len(nl)):
    ave = sum(al[i]) / nl[i]
    num = len(list(filter(lambda x: x <= ave, al[i])))
    print(num)

Submission status: Accepted

Solution code:
def main(n):
	if n == 0:
		return False
	a = list(map(int,input().split()))
	m = sum(a)/n
	ans = 0
	for i in a:
		if i<= m:
			ans += 1
	print(ans)
	return True

while main(int(input())): pass

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    A=list(map(int,input().split()))

    AVE=sum(A)/n
    print(len([a for a in A if a<=AVE]))

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    A = list(map(int, input().split()))
    assert len(A) == n

    ave = sum(A) // n
    print(sum(1 for a in A if a <= ave))

Submission status: Accepted

Solution code:
ans_list = []

while True:
    n = int(input())
    if n == 0:
        break
    A = list(map(int,input().split()))
    ave = sum(A) / len(A)
    cnt = 0
    for a in A:
        if a <= ave:
            cnt += 1
    ans_list.append(cnt)

for ans in ans_list:
    print(ans)

Submission status: Accepted

Solution code:
x=[]
a=[] #appendのために宣言が必要
while True:
    try:
        a.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。


#[[1, 2, 2, 3, 1], [4, 5, 3, 4, 1, 2, 3, 4], [2, 3, 5, 6, 0, 2]]
for i in range(len(a)//2):
    x.append(i)
    n=i*2
    m=i*2+1
    s=sum(a[m])/a[n][0]
    for t in range(len(a[m])):
      if s>=a[m][t]:
        x[i]=x[i]+1
    print(x[i]-i)

Submission status: Accepted

Solution code:
# import sys
# input = sys.stdin.readline

while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    m = sum(a)/n
    count = 0
    for i in a:
        if i <= m:
            count += 1
    print(count)

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0: break
    a = sorted(list(map(int, input().split())))
    mean = sum(a) / len(a)
    count = 0
    for item in a:
        if item <= mean: count += 1
        else: break
    print(count)

Submission status: Accepted

Solution code:
while(True):
    n = input()
    if n=="0":
        break
    elif (int)(n)>50000:
        continue
    hairetu = input()

    tarou = hairetu.split(" ")
    avg=0

    for i in range(0,(int)(n)):
        avg=avg+(int)(tarou[i])
    avg=avg/(int)(n)

    cdnt=0
    for j in range(0,(int)(n)):
        if (int)(tarou[j]) <= (int)(avg):
            cdnt=cdnt+1 
    print(cdnt)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0 :
        break
    lst = input().split()
    sum = 0

    for i in lst:
        sum = sum + int(i)

    mean = sum / len(lst)
    poor = 0

    for i in lst:
        if mean >= int(i):
            poor = poor +  1

    print(poor)

Submission status: Accepted

Solution code:
def solve(N, A):
    m = sum(A) / N
    ans = 0
    for i in range(N):
        if A[i] <= m:
            ans += 1
    print(ans)

while True:
    N = int(input())
    if N == 0:
        break
    A = list(map(int, input().split()))
    solve(N, A)

Submission status: Accepted

Solution code:
ans_list = []
while True:
    n = int(input())
    if n==0:
        break
    A = list(map(int,input().split()))
    ave = sum(A) // len(A)
    cnt = 0
    for a in A:
        if a <= ave:
            cnt += 1
    ans_list.append(cnt)

for ans in ans_list:
    print(ans)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n <= 0: break
    a = [int(i) for i in input().split()]
    ave = sum(a)/n

    print(len(list(filter(lambda x: x <= ave, a))))

Submission status: Accepted

Solution code:
import bisect
def main(n):
    a = list(map(int, input().split()))
    a.sort()
    print(bisect.bisect_right(a,sum(a)/n))

while 1:
    n = int(input())
    if n == 0:
        break
    main(n)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    datum = list(map(int, input().split()))
    ave = sum(datum) / n
    res = 0

    for data in datum:
        if data <= ave:
            res += 1

    print(res)

Submission status: Accepted

Solution code:
for v in range(10000):
  x = 0
  n = input()
  n = int(n)
  if n == 0:
    break
  else:
    a = input().split()
    b = [int(s) for s in a]
    for i in range(n):
      x += b[i]
      i += 1
    y = x/n
    z = 0
    for j in range(n):
      if y >= b[j]:
        z+=1
        j += 1
      else:
        j+=1
  print(z)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

while True:
    n = int(input())
    if n == 0: break

    a = list(map(int, input().split()))
    ave_num = sum(a) / n

    cnt = 0
    for item in a:
        if item <= ave_num:
            cnt += 1

    print(cnt)

Submission status: Accepted

Solution code:
def main():
    while True:
        n = int(input())
        if not n:
            return
        aa = list(map(int,input().split()))
        ave = sum(aa)/n
        print(len([x for x in aa if x <= ave]))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline().strip()
def LIST(): return list(map(int, input().split()))

def main():
    ans = []
    
    while 1:
        n = int(input())
        if n == 0:
            break
        else:
            a = LIST()
            heikin = sum(a) / n
            tmp = [x for x in a if x <= heikin]
            ans.append(len(tmp))
        
    for x in ans:
        print(x)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))

ans = []
while 1:
	n = INT()
	if n == 0:
		break

	a = LIST()
	ave = sum(a)/n
	count = 0
	for i in a:
		if i <= ave:
			count += 1
	ans.append(count)
for i in ans:
	print(i)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        exit()
    else:
        sample = list(map(int,input().split()))
        average = sum(sample)/n
        cnt = len([1 for i in range(n) if sample[i] <= average])
        print(cnt)

Submission status: Accepted

Solution code:
import sys


def solve(n):
    a = list(map(int, input().split()))
    ave = sum(a) / n
    count = 0
    for i in a:
        if i <= ave:
            count += 1

    print(count)


def main():
    while(True):
        n = int(input())
        if n == 0:
            sys.exit(0)
        else:
            solve(n)


main()

Submission status: Accepted

Solution code:
while(True):
    if(input()=="0"):
        exit()
    l = list(map(int,input().split()))
    print(len([i for i in l if i<=sum(l)/len(l)]))

Submission status: Accepted

Solution code:
while(True):
    n = int(input())
    if n==0:
        exit()
    l = list(map(int,input().split()))
    l.sort()
    s = sum(l)/n
    res = 0
    if l[-1]==l[0]:
        print(n)
        continue
    for i in range(n):
        if l[i]>s:
            print(i)
            break

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    hei = sum(a)/len(a)
    count = 0
    for i in a:
        if hei >= i:
            count += 1
    else:
        print(count)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if not n:
        break
    a = list(map(int, input().split()))
    ave = sum(a) / n
    print(len([x for x in a if x <= ave]))

Submission status: Accepted

Solution code:
while  True:
    N = int(input())
    if N == 0:
        break
    s = list(map(int,input().split()))
    avg = sum(s) / N
    ans = 0
    for c in s:
        if c <= avg:
            ans += 1
    print(ans)

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n == 0: break
    xs=list(map(int,input().split()))
    ave=sum(xs)/n
    print(sum(1 for x in xs if x <= ave))

Submission status: Accepted

Solution code:
from itertools import takewhile

while True:
    n = int(input())
    if n == 0:break
    num = sorted(list(map(int, input().split())))
    ave = int(sum(num))/int(len(num))
    print(len(list(takewhile (lambda x:x <= ave, num))))

Submission status: Accepted

Solution code:
while True:
  n = int(input())
  if n == 0:
    break
  a = list(map(int,input().split()))
  s = sum(a)/n
  a.sort()
  ans = 0
  for i in range(n):
    if a[i]>s:
      break
    ans += 1
  print(ans)

Submission status: Accepted

Solution code:
while True:
  n=int(input())
  if n == 0:
    break
  A = list(map(int,input().split()))
#  print(A)
  a =sum(A)
  bar = a/n
#  print(bar)
  count=0
  for i in A:
    if i<=bar:
      count+=1
  print(count)

Submission status: Accepted

Solution code:
while(True):
    N=int(input())
    if N==0:
        break
    a=[int(i) for i in input().split()]
    S=sum(a)
    ans=0
    for i in range(N):
        if a[i]*N<=S:
            ans+=1
    print(ans)

Submission status: Accepted

Solution code:
while True:
  n = int(input())
  if n==0:
    break
  a = list(map(int, input().split()))
  ave = int(sum(a) // n)
  cnt = 0
  for i in a:
    if i<=ave:
      cnt += 1
  print(cnt)

Submission status: Accepted

Solution code:
while True:
  #1行目nを読み込む
  cnt = 0
  n =int(input())
  #もしn==0ならbreak
  if n==0:
    break
  #n>0ならば
  if n>0:
    #配列a[i]を読み込む(1<=i<=n)
    a = list(map(int, input().split()))
 
  ans = sum(a) //n
  for i in range(n):
    if a[i] <= ans:
      cnt+=1
  print(cnt)

Submission status: Accepted

Solution code:
import bisect
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N=int(input())
    if N==0:
        exit()
    L=list(map(int,input().split()))
    ave = sum(L)//N
    L = sorted(L)
    low = bisect.bisect_right(L,ave)
    print(low)

while True:
    solve()

Submission status: Accepted

Solution code:
while True:
	n = int(input())
	if n == 0:
	    break
	a = list(map(int, input().split()))
	s = int(sum(a) // n)
	ans = 0
	for x in a:
	    if x <= s:
	        ans += 1
	print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    while 1:
        n = I()
        if n == 0:
            quit()
        a = LI()
        m = sum(a)/n
        c = 0
        for i in range(n):
            if a[i] <= m:
                c += 1
        print(c)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    A()

Submission status: Accepted

Solution code:
while True :
    n=int(input())
    if n==0 : break
    a=input().split()
    tot=0;ans=0
    for i in a : tot+=int(i)
    for i in a :
        if (tot/n)>=int(i) : ans+=1
    print(ans)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int,input().split()))
    ave = sum(a)/n
    ans = 0
    for i in range(n):
        if a[i] <= ave:
            ans += 1
    print(ans)

Submission status: Accepted

Solution code:
def income_inequality():
    n = int(input())
    low_income_num = []
    while n:
        incomes = [int(i) for i in input().split()]
        sum = 0.0
        for i in incomes:
            sum += i
        everage = sum / len(incomes)
        count = 0
        for i in incomes:
            if i <= everage:
                count += 1
        low_income_num.append(count)
        n = int(input())
    for i in low_income_num:
        print(i)

income_inequality()