when i add count variable it works properly but when i dont add like how it is right now, it wont work
My code
# cook your dish here
for _ in range(int(input())):
n,k=map(int,input().split())
l = list(map(int,input().split()))
s = 0
dic = {}
for i in l:
dic[i]=dic.get(i,0)+1
for x,y in dic.items():
if y==k:
s = s+x
if s==0:
print(-1)
else:
print(s)
Problem Link: CREP Problem - CodeChef