Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    N,K =LMIIS()
    A = LMIIS()
    A.sort()
    # print(A)
    MOD = 10**9+7
    ans = 0
    import itertools
    C = itertools.combinations(A,K)
    def f(L):
        return (L[-1] - L[0])%MOD
    for i in map(f,C):
        ans += i
        ans %= MOD
    print(ans)






if __name__ == '__main__':
    main()

Fixed submission:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True
class Combination:
    def __init__(self,N,P=10**9+7):
        if N > 10**7:
            self.fact = lambda x: x * self.fact(x-1) % P if x > 2 else 2
            self.perm = lambda x, r: x * self.perm(x-1,r-1) % P if r > 0 else 1
            self.cmb = lambda n,r: (self.perm(n,min(n-r,r)) * pow(self.fact(min(n-r,r)) ,P-2 ,P) % P) if r > 0 else 1
        else:
            self.__fact = [1] * (N+1)
            self.__inv = [1] * (N+1)
            self.__inv_fact = [1] * (N+1)
            for i in range(2,N+1):
                self.__fact[i] = self.__fact[i-1] * i % P
                self.__inv[i] = - self.__inv[P%i] * (P//i) % P
                self.__inv_fact[i] = self.__inv_fact[i-1] * self.__inv[i] % P
            self.fact = lambda n: self.__fact[n]
            self.perm = lambda n,r: self.__fact[n] * self.__inv_fact[n-r] % P
            self.cmb = lambda n,r: (self.__fact[n] * self.__inv_fact[n-r] * self.__inv_fact[r] % P) if n >= r > 0 else 0 if r > n else 1
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    N,K =LMIIS()
    A = LMIIS()
    A.sort()
    cmb = Combination(N)
    ans = 0
    P = 10**9+7
    for i,a in enumerate(A):
        ans = (ans + cmb.cmb(i,K-1)*a - cmb.cmb(N-i-1,K-1)*a)%P
    print(ans)


    






if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N,K = LMIIS()
    R,S,P = LMIIS()
    T = input()
    A = ''
    ans = 0
    for i in range(K):
        if T[i] == 'r':
            A += 'p'
            ans += P
        elif T[i] == 's':
            A += 'r'
            ans += R
        else:
            A += 's'
            ans += S
    for i in range(K,N):
        if T[i] == 'r':
            if A[i-K] != 'p':
                A += 'p'
                ans += P
            else:
                A += '-'
        elif T[i] == 's':
            if A[i-K] != 'r':
                A += 'r'
                ans += R
            else:
                A += '-'
        else:
            if A[i-K] != 's':
                A += 's'
                ans += S
            else:
                A += '-'
    print(ans)




if __name__ == '__main__':
    main()

Fixed submission:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N,K = LMIIS()
    R,S,P = LMIIS()
    T = input()
    A = [False]*N
    ans = 0
    # hand = {
    #     'r':
    # }
    score = {
        'r':P,
        's':R,
        'p':S
    }
    for i in range(K):
        # print(T[i],score[T[i]])
        ans += score[T[i]]
        A[i] = True
    for i in range(K,N):
        if T[i] != T[i-K]:
            # print(T[i],score[T[i]])
            ans += score[T[i]]
            A[i] = True
        else:
            if A[i-K] != True:
                ans += score[T[i]]
                A[i] = True
            # print(T[i],0)
    print(ans)
    # for i in range(K):
    #     if T[i] == 'r':
    #         A += 'p'
    #         ans += P
    #     elif T[i] == 's':
    #         A += 'r'
    #         ans += R
    #     else:
    #         A += 's'
    #         ans += S
    # for i in range(K,N):
    #     if T[i] == 'r':
    #         if A[i-K] != 'p':
    #             A += 'p'
    #             ans += P
    #         else:
    #             A += '-'
    #     elif T[i] == 's':
    #         if A[i-K] != 'r':
    #             A += 'r'
    #             ans += R
    #         else:
    #             A += '-'
    #     else:
    #         if A[i-K] != 's':
    #             A += 's'
    #             ans += S
    #         else:
    #             A += '-'





if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    X = II()
    S = input()
    l = len(S)
    memo = {}
    for i in range(l):
        for j in range(i+1,l):
            for k in range(j+1,l):
                memo[S[i]+S[j]+S[k]] = True
    print(len(memo.keys()))



if __name__ == '__main__':
    main()

Fixed submission:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    X = II()
    S = input()
    l = len(S)
    from collections import defaultdict
    memo = {}
    usedAs1 = defaultdict(lambda : False)
    for i in range(l):
        if usedAs1[S[i]]:
            continue
        usedAs1[S[i]] = True
        usedAs2 = defaultdict(lambda : False)
        for j in range(i+1,l):
            if usedAs2[S[j]]:
                continue
            usedAs2[S[j]] = True
            for k in range(j+1,l):
                memo[S[i]+S[j]+S[k]] = True
    print(len(memo.keys()))



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = int(input())
    xy = XLMIIS(N)
    

    def distance(x1,y1,x2,y2):
        return ((x1-x2)**2 + (y1-y2) ** 2) ** 0.5

    def f(n):
        ans = n
        if n <= 0:
            return 1
        for i in range(1,n):
            ans *= i
        return ans
    

    sumdis = 0
    for i in range(N):
        for j in range(i+1,N):
            sumdis += distance(*xy[i],*xy[j])
    summ = sumdis  / N * 2
    print(summ)


if __name__ == '__main__':
    main()

Fixed submission:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = int(input())
    xy = XLMIIS(N)
    

    def distance(x1,y1,x2,y2):
        return ((x1-x2)**2 + (y1-y2) ** 2) ** 0.5

    def f(n):
        ans = n
        if n <= 0:
            return 1
        for i in range(1,n):
            ans *= i
        return ans
    

    sumdis = 0
    for i in range(N):
        for j in range(i+1,N):
            sumdis += distance(xy[i][0],xy[i][1],xy[j][0],xy[j][1])
    summ = sumdis  / N * 2
    print(summ)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import sys
import bisect
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = II()
    L = LMIIS()
    L.sort()
    count = 0
    for i in range(N):
        a = L[i]
        for j in range(i+1,N):
            b = L[j]
            k = j+1
            while k < N and a+b > L[k]:
                k += 1
                count += 1
    print(count)



if __name__ == '__main__':
    main()

Fixed submission:
#coding:utf-8
import sys
import bisect
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = II()
    L = LMIIS()
    L.sort()
    count = 0
    for i in range(N):
        for j in range(i+1,N):
            a = L[i]
            b = L[j]
            l = bisect.bisect_right(L,a-b,lo=j+1)
            r = bisect.bisect_left(L,a+b,lo=j+1)
            count += max(r - l ,0)
    print(count)



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = II()
    A = LMIIS()
    for i in range(N):
        A[i] = [A[i],i]
    A.sort()

    ans = ''
    for i in range(N):
        ans += str(A[i][1]+1) + ' '
    print(ans.rstrip())
        

if __name__ == '__main__':
    main()

Fixed submission:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = II()
    A = LMIIS()
    for i in range(N):
        A[i] = [A[i],i]
    A.sort()


    for i in range(N):
        print(A[i][1]+1)

        

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
print('Yes) if int(input()) >= 3200 else print(input())


Fixed submission:
print('red') if int(input()) < 3200 else print(input())
Buggy python submission (verdict: Runtime Error):
r = input()
print(r**2*3)

Fixed submission:
r =int(input())
print(3*r**2)
Buggy python submission (verdict: Runtime Error):
S = input()
C = [0] * 26
for s in S:
    C[ord(s)-ord('A')] += 1
v = 0
for  c in C:
    if c != 0 and c!= 2:
        print('No')
        import sys
        sys.exit(1)

print('Yes')




Fixed submission:
S = input()
C = [0] * 26
for s in S:
    C[ord(s)-ord('A')] += 1
v = 0
for  c in C:
    if c == 2:
        v += 1
    elif c != 0:
        print('No')
        break
if v == 2:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
#dp[i]:i段目に登るまでの組み合わせ総数
#dp[i] = dp[i-1] + dp[i-2] if dp[i] != B[i] else 0
N,M = list(map(int,input().split()))
B = [True] * N
try:
    for _ in range(M):
        B[int(input())-1] = False
except:
    print(0)
    import sys
    sys.exit(1)
dp = [0] * N
if B[0]:
    dp[0] = 1
dp[1] = dp[0] + 1 if B[1] else 0
mod = 10**9 + 7
for i in range(2,N):
    if B[i] :
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])



Fixed submission:
#coding:utf-8
#dp[i]:i段目に登るまでの組み合わせ総数
#dp[i] = dp[i-1] + dp[i-2] if dp[i] != B[i] else 0
N,M = list(map(int,input().split()))
B = [True] * N

for _ in range(M):
    B[int(input())-1] = False
dp = [0] * N
if B[0]:
    dp[0] = 1
if N >= 2 and B[1]:
    dp[1] = dp[0] + 1 
mod = 10**9 + 7
for i in range(2,N):
    if B[i] :
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
#dp[i]:i段目に登るまでの組み合わせ総数
#dp[i] = dp[i-1] + dp[i-2] if dp[i] != B[i] else 0
N,M = list(map(int,input().split()))
B = [True] * N
for _ in range(M):
    B[int(input())-1] = False
dp = [0] * N
dp[0] = 1 if B[0] else 0
dp[1] = dp[0] + 1 if B[1] else 0
mod = 10**9 + 7
for i in range(2,N):
    if B[i] :
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])



Fixed submission:
#coding:utf-8
#dp[i]:i段目に登るまでの組み合わせ総数
#dp[i] = dp[i-1] + dp[i-2] if dp[i] != B[i] else 0
N,M = list(map(int,input().split()))
B = [True] * N

for _ in range(M):
    B[int(input())-1] = False
dp = [0] * N
if B[0]:
    dp[0] = 1
if N >= 2 and B[1]:
    dp[1] = dp[0] + 1 
mod = 10**9 + 7
for i in range(2,N):
    if B[i] :
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
#coding:utf-8
#dp[i]:i段目に登るまでの組み合わせ総数
#dp[i] = dp[i-1] + dp[i-2] if dp[i] != B[i] else 0
N,M = list(map(int,input().split()))
B = [True] * N
for _ in range(M):
    B[int(input())-1] = False
dp = [0] * N
dp[0] = 1 if B[0] else 0
dp[1] = dp[0] + 1 if B[1] else 0
mod = 10**9 + 7
for i in range(2,N):
    if B[i] :
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])



Fixed submission:
#coding:utf-8
#dp[i]:i段目に登るまでの組み合わせ総数
#dp[i] = dp[i-1] + dp[i-2] if dp[i] != B[i] else 0
N,M = list(map(int,input().split()))
B = [True] * N

for _ in range(M):
    B[int(input())-1] = False
dp = [0] * N
if B[0]:
    dp[0] = 1
if N >= 2 and B[1]:
    dp[1] = dp[0] + 1 
mod = 10**9 + 7
for i in range(2,N):
    if B[i] :
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
write = lambda x: sys.stdout.write(str(x))
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = False

def main():

    N = II()
    t = [-1] * N


    E = [  [] for _ in range(N)]
 
    reached = [False] * N
    for _ in range(N-1):
        u,v,w = LMIIS()
        u -=1
        v -=1
        E[u].append((v,w))
        E[v].append((u,w))
    dbg(E)
    t[E[0][0][0]] = 0

     
    def search(u):
        for v,w in E[u]:
            if t[v] == -1:
                t[v] = t[u] if w % 2 == 0 else t[u]^1
                search(v)
                

    search(E[0][0][0])

    for i in t:
        write(i)
        write(' ')






    pass
if __name__ == '__main__':
    main()

Fixed submission:
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = lambda x: sys.stdout.write(str(x))
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = False

def main():

    N = II()
    t = [-1] * N


    E = [  [] for _ in range(N)]
 
    reached = [False] * N
    for _ in range(N-1):
        u,v,w = LMIIS()
        u -=1
        v -=1
        E[u].append((v,w))
        E[v].append((u,w))
    dbg(E)
    t[E[0][0][0]] = 0

     
    def search(u):
        for v,w in E[u]:
            if t[v] == -1:
                t[v] = t[u] if w % 2 == 0 else t[u]^1
                search(v)
                

    search(E[0][0][0])

    for i in t:
        write(i)
        write(' ')






    pass
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    
    H,W = LMIIS()
    A = []
    for _ in range(H):
        A.append(input())
    from copy import deepcopy
    blacks = []
    max_d = 0
    for w in range(W):
        for h in range(H):
            if A[h][w] == '#':
                blacks.append((h,w))
    for w in range(W):
        for h in range(H):
            if A[h][w] == '.':
                d = 10**7
                for i,j in blacks:
                    d = min(d,abs(i-h)+abs(j-w))
                max_d = max(max_d,d)
    print(max_d)


if __name__ == '__main__':
    main()

Fixed submission:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    
    H,W = LMIIS()
    A = []
    for _ in range(H):
        A.append(input())
    from copy import deepcopy
    blacks = deque()
    visited = [[False]*W for _ in range(H)]
    for w in range(W):
        for h in range(H):
            if A[h][w] == '#':
                blacks.append((h,w))
                visited[h][w] = True

    count = -1
    
    while len(blacks) > 0:
        count += 1
        next_blacks = deque()
        while len(blacks) > 0:
            i,j = blacks.pop()
            if 0 <= i-1 and not visited[i-1][j]:
                next_blacks.append((i-1,j))
                visited[i-1][j] = True
            if 0 <= j-1 and not visited[i][j-1]:
                next_blacks.append((i,j-1))
                visited[i][j-1] = True
            if i+1 < H and not visited[i+1][j]:
                next_blacks.append((i+1,j))
                visited[i+1][j] = True
            if j+1 < W and not visited[i][j+1]:
                next_blacks.append((i,j+1))
                visited[i][j+1] = True
        blacks = next_blacks
    print(count)



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():
    X,Y,Z,K = LMIIS()
    A = LMIIS()
    B = LMIIS()
    C = LMIIS()
    
    # A.sort(reverse=True)
    # B.sort(reverse=True)
    # C.sort(reverse=True)
    
    h = []
    from heapq import heappush,heappop
    for a in A:
        for b in B:
            for c in C:
                heappush(h,-(a+b+c))
    for _ in range(K):
        print(-heappop(h))
    # A.append(0)
    # B.append(0)
    # C.append(0)

    # # ai = bi = ci = 0

    # # for i in range(min(3000,X*Y*Z)):
    # #     print(A[ai],B[bi],C[ci])
    # #     print(A[ai]+B[bi]+C[ci])
    # #     nextai = ai + 1 if ai < X else ai
    # #     nextbi = bi + 1 if bi < Y else bi
    # #     nextci = ci + 1 if ci < Z else ci

    # #     #aiを更新する場合
    # #     if  A[nextai] >= B[nextbi]:
    # #         if A[nextai] >= C[nextci]:
    # #             ai = nextai
    # #         else:
    # #             ci = nextci
    # #     else:
    # #         if B[nextbi] >= C[nextci]:
    # #             bi = nextbi
    # #         else:
    # #             ci = nextci






    pass
if __name__ == '__main__':
    main()

Fixed submission:
#coding:utf-8
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():
    X,Y,Z,K = LMIIS()
    A = LMIIS()
    B = LMIIS()
    C = LMIIS()
    

    AB = []
    for a in A:
        for b in B:
            AB.append(a+b)
    
    AB.sort(reverse=True)

    ABC = []
    for ab in AB[:K]:
        for c in C:
            ABC.append(ab+c)
    ABC.sort(reverse=True)
    for i in range(K):
        print(ABC[i])

    pass
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from math import gcd, ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    N,M,C = LMIIS()
    B = LMIIS()
    A = [LMIIS() for _ in range(N)]

    ans = 0
    for i in range(N):
        dot = C
        for a,b in zip(A[i],B):
            dot += a*b
        if dot > 0:
            ans += 1
    print(ans)

    

if __name__ == '__main__':
    main()

Fixed submission:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7
    
    N,M,C = LMIIS()
    B = LMIIS()
    A = [LMIIS() for _ in range(N)]

    ans = 0
    for i in range(N):
        dot = C
        for a,b in zip(A[i],B):
            dot += a*b
        if dot > 0:
            ans += 1
    print(ans)

    

if __name__ == '__main__':
    main()