# Unable to find the bug in the code of problem Javeluin qualification- Starters 8

for i in range(int(input())):

``````n,m,x=map(int,input().split())

a=[int(x) for x in input().split()]

d={}

for  j in range(n):

d[a[j]]=j+1

a.sort(reverse=True)

s1=0

l=[]

while a[s1]>=m:

l.append(d[a[s1]])

if s1<n-1:

s1=s1+1

else:

break

if s1<x:

for k in range(s1,x):

l.append(d[a[k]])

l.sort()

print(len(l), end=' ')

for j in range(len(l)):

print(l[j],end=' ')

print()
``````

The main issue here is that you do not cater for two players throwing the same distance in the qualification rounds. Clearly this means you can’t have a dictionary that maps from score to player.

When you code this update, following the qualification rules, it means that any distance-tied players would be either included or excluded together.

Let me “Python up” your printing loop; you have:

``````    print(len(l), end=' ')
for j in range(len(l)):
print(l[j],end=' ')
print()
``````

so iterating the list elements rather than the index would be

``````    print(len(l), end=' ')
for e in l:
print(e,end=' ')
print()
``````

Unwrapping the list is less cluttered; this would be

``````    print(len(l), end=' ')
print(*l)
``````

(a space being the default separator)
and the length can just be another parameter before the unwrapped `l`

``````    print(len(l),*l)
``````