Help me in solving SNAKEEAT problem

My issue

Error
Traceback (most recent call last):
File “/mnt/sol.py”, line 3, in
for _ in range(int(input())):
^^^^^^^
EOFError: EOF when reading a line

My code

# cook your dish here
from bisect import bisect_left
for _ in range(int(input())):
    n,q=list(map(int,input().split()))
    l=list(map(int,input().split()))
    k=[]
    l.sort()
    for i in q:
        k=int(input())
        pos=bisect_left(l,k)
        start=0
        stop=pos
        while(start<stop):
            mid=(start+stop)//2
            for j in range(mid,pos):
                s=s+(k-a[j])
            if(s<=mid):
                stop=mid-1
            else:
                start=mid+1
        print(k-pos-1+mid)
            

Learning course: Binary Search
Problem Link: Snake Eating Practice Problem in Binary Search - CodeChef