def s(x):return len(x) input();a=[int(i)for i in input().split(' ')];c=[] for i in range(min(a),max(a)+1): if i in a:c.append([j for j in a if j==i]) c.sort(key=s);l=c[::-1];j=0 for i in c: while 2*i.count(i[0])>(len(i)+len(l[j])): i.append(l[j][-1]);l[j]=l[j][:-1] if len(l[j])==0:l.remove(l[j]) j-=1 j+=1 print(len(l))
1 2 3 4 5 6 7 8 9 10 11 12 | def s(x):return len(x) input();a=[int(i)for i in input().split(' ')];c=[] for i in range(min(a),max(a)+1): if i in a:c.append([j for j in a if j==i]) c.sort(key=s);l=c[::-1];j=0 for i in c: while 2*i.count(i[0])>(len(i)+len(l[j])): i.append(l[j][-1]);l[j]=l[j][:-1] if len(l[j])==0:l.remove(l[j]) j-=1 j+=1 print(len(l)) |