Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a=list(S)
n=0
while n<len(a):
    oldn=n
    if a[n] == "e":
        if n+4<len(a) and a[n+1]=="r" and a[n+2]=="a" and a[n+3]=="s" and a[n+4]=="e":
            if n+5<len(a) and a[n+5]=="r":
                n=n+6
            else:
                n=n+5
    else:
        if a[n] == "d":
            if n+4<len(a) and a[n+1]=="r" and a[n+2]=="e" and a[n+3]=="a" and a[n+4]=="m":
                if n+6<len(a) and a[n+5]=="e" and a[n+6] == "r":
                    if n+7<len(a) and a[n+7]=="a":
                        n=n+5
                    else:
                        n=n+7
                else:
                    n=n+5
    if oldn == n:
        print("NO")
        break
else:
    print("OK")

Fixed submission:
a=list(input())
n=0
while n<len(a):
    oldn=n
    if a[n] == "e":
        if n+4<len(a) and a[n+1]=="r" and a[n+2]=="a" and a[n+3]=="s" and a[n+4]=="e":
            if n+5<len(a) and a[n+5]=="r":
                n=n+6
            else:
                n=n+5
    else:
        if a[n] == "d":
            if n+4<len(a) and a[n+1]=="r" and a[n+2]=="e" and a[n+3]=="a" and a[n+4]=="m":
                if n+6<len(a) and a[n+5]=="e" and a[n+6] == "r":
                    if n+7<len(a) and a[n+7]=="a":
                        n=n+5
                    else:
                        n=n+7
                else:
                    n=n+5
    if oldn == n:
        print("NO")
        break
else:
    print("YES")

Buggy python submission (verdict: Runtime Error):
a=list(S)
n=0
while n<len(a):
    oldn=n
    if a[n] == "e":
        if n+4<len(a) and a[n+1]=="r" and a[n+2]=="a" and a[n+3]=="s" and a[n+4]=="e":
            if n+5<len(a) and a[n+5]=="r":
                n=n+6
            else:
                n=n+5
    else:
        if a[n] == "d":
            if n+4<len(a) and a[n+1]=="r" and a[n+2]=="e" and a[n+3]=="a" and a[n+4]=="m":
                if n+6<len(a) and a[n+5]=="e" and a[n+6] == "r":
                    if n+7<len(a) and a[n+7]=="a":
                        n=n+5
                    else:
                        n=n+7
                else:
                    n=n+5
    if oldn == n:
        print("NO")
        break
else:
    print("OK")

Fixed submission:
a=list(input())
n=0
while n<len(a):
    oldn=n
    if a[n] == "e":
        if n+4<len(a) and a[n+1]=="r" and a[n+2]=="a" and a[n+3]=="s" and a[n+4]=="e":
            if n+5<len(a) and a[n+5]=="r":
                n=n+6
            else:
                n=n+5
    else:
        if a[n] == "d":
            if n+4<len(a) and a[n+1]=="r" and a[n+2]=="e" and a[n+3]=="a" and a[n+4]=="m":
                if n+6<len(a) and a[n+5]=="e" and a[n+6] == "r":
                    if n+7<len(a) and a[n+7]=="a":
                        n=n+5
                    else:
                        n=n+7
                else:
                    n=n+5
    if oldn == n:
        print("NO")
        break
else:
    print("YES")
Buggy python submission (verdict: Runtime Error):
if inputs[0] <= inputs[2] and inputs[2] <= inputs[1]:
    print("Yes")
elif inputs[0] >= inputs[2] and inputs[2] >= inputs[1]:
    print("Yes")
else:
    print("No")

Fixed submission:
inputs = list(map(int,input().split()))
if inputs[0] < inputs[2] < inputs[1] or inputs[0] > inputs[2] > inputs[1]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
s=input()
if s='SUN':
    print(7)
elif s='MON':
    print(6)
elif s='TUE':
    print(5)
elif s='WED':
    print(4)
elif s='THU':
    print(3)
elif s='FRI':
    print(2)
elif s='SAT':
    print(1)

Fixed submission:
s=input()
if s=='SUN':
    print(7)
elif s=='MON':
    print(6)
elif s=='TUE':
    print(5)
elif s=='WED':
    print(4)
elif s=='THU':
    print(3)
elif s=='FRI':
    print(2)
elif s=='SAT':
    print(1)

Buggy python submission (verdict: Runtime Error):
s=(input())
if s='SUN':
    print(7)
elif s='MON':
    print(6)
elif s='TUE':
    print(5)
elif s='WED':
    print(4)
elif s='THU':
    print(3)
elif s='FRI':
    print(2)
elif s='SAT':
    print(1)

Fixed submission:
s=input()
if s=='SUN':
    print(7)
elif s=='MON':
    print(6)
elif s=='TUE':
    print(5)
elif s=='WED':
    print(4)
elif s=='THU':
    print(3)
elif s=='FRI':
    print(2)
elif s=='SAT':
    print(1)

Buggy python submission (verdict: Runtime Error):
s=int(input())
if s='SUN':
    print(7)
elif s='MON':
    print(6)
elif s='TUE':
    print(5)
elif s='WED':
    print(4)
elif s='THU':
    print(3)
elif s='FRI':
    print(2)
elif s='SAT':
    print(1)

Fixed submission:
s=input()
if s=='SUN':
    print(7)
elif s=='MON':
    print(6)
elif s=='TUE':
    print(5)
elif s=='WED':
    print(4)
elif s=='THU':
    print(3)
elif s=='FRI':
    print(2)
elif s=='SAT':
    print(1)
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())
 
if 1 >=(A,B)<=9:
    print(A*B)
elif:
    print(-1)

Fixed submission:
A,B = map(int, input().split())
 
if A<=9 and B<=9:
    print(A*B)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())
 
if 1 >=A<=9 and 1>=B<=9:
    print(A*B)
elif:
    print(-1)

Fixed submission:
A,B = map(int, input().split())
 
if A<=9 and B<=9:
    print(A*B)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())

if 1 <=A,B >= 9:
    print(A*B)
else:
    print(-1)
    

Fixed submission:
A,B = map(int, input().split())
 
if A<=9 and B<=9:
    print(A*B)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
a,b,n = map(int, input().split())
n=a*b
if a<=9 and b<=9:
    print('YES')
else:
    print('NO')

Fixed submission:
n=int(input())
for i in range(1,10):
  for j in range(1,10):
    if n==(i*j):
      print('Yes')
      exit()
print('No')
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())

A, B, C = map(int, input().split())
if A < C < B:
    print('Yes')
else:
   print('No')

Fixed submission:
A, B, C = map(int, input().split())
if A < C < B:
    print('Yes')
elif B < C < A:
    print('Yes')
else:
   print('No')

Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A > C:
    print('No')
elif:
   B < C:
    print('No')
else:
   print('Yes')

Fixed submission:
A, B, C = map(int, input().split())
if A < C < B:
    print('Yes')
elif B < C < A:
    print('Yes')
else:
   print('No')
Buggy python submission (verdict: Runtime Error):
b = input()

if b==A:
    print('T')
elif b==G:
    print('C')
elif b==T:
    print('A')
else:
    print('G')
    
    

Fixed submission:
b = input()

if b=='A':
    print('T')
elif b=='G':
    print('C')
elif b=='T':
    print('A')
else:
    print('G')
Buggy python submission (verdict: Runtime Error):
D = int(input())

if D==25:
    print('Christmas')
elif D==24:
    print('Christmas Eve')
elif D==23:
    print('Christmas Eve Eve')
ellif D==22:
    print('Christmas Eve Eve Eve')


Fixed submission:
D = int(input())

if D==25:
    print('Christmas')
elif D==24:
    print('Christmas Eve')
elif D==23:
    print('Christmas Eve Eve')
elif D==22:
    print('Christmas Eve Eve Eve')

Buggy python submission (verdict: Runtime Error):
D = int(input())

if D==25:
    print('Christmas')
elif D==24:
    print('Christmas Eve')
elif D==23:
    print('Christmas Eve Eve')
ellif D==22:
    print('Christmas Eve Eve Eve')

Fixed submission:
D = int(input())

if D==25:
    print('Christmas')
elif D==24:
    print('Christmas Eve')
elif D==23:
    print('Christmas Eve Eve')
elif D==22:
    print('Christmas Eve Eve Eve')

Buggy python submission (verdict: Runtime Error):
if D==25:
    print('Christmas')
elif D==24:
    print('Christmas Eve')
elif D==23:
    print('Christmas Eve Eve')
else:
    print('Christmas Eve Eve Eve')
    

Fixed submission:
D = int(input())

if D==25:
    print('Christmas')
elif D==24:
    print('Christmas Eve')
elif D==23:
    print('Christmas Eve Eve')
elif D==22:
    print('Christmas Eve Eve Eve')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def count_pair(k):
    cnt = 0
    for i in range(1, N+1):
        visited = [-1]*(N+1)
        visited[i] = 0
        s = 0
        q = deque([[i]])
        while s != k:
            p = []
            A = q.popleft()
            for a in A:
                if a == X and visited[Y] == -1:
                    p.append(Y)
                    visited[Y] = 0
                if a == Y and visited[X] == -1:
                    p.append(X)
                    visited[X] = 0
                if a+1 <=N and visited[a+1] == -1:
                    p.append(a+1)
                    visited[a+1] = 0
                if a-1 >= 1 and visited[a-1] == -1:
                    p.append(a-1)
                    visited[a-1] = 0
            q.append(p)
            s += 1
        r = q[0]
        t = 0
        for j in range(len(r)):
            if r[j] > i:
                t += 1
        cnt += t
    return cnt

N, X, Y = map(int, input().split())
for k in range(1, N):
    print (count_pair(k))

Fixed submission:
N, X, Y = map(int, input().split())
t = [0]*N
for i in range(1, N):
    for j in range(i+1, N+1):
        t[min(j-i, abs(X-i)+1+abs(j-Y))] += 1
for k in range(1, N):
    print (t[k])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def count_pair(k):
    cnt = 0
    for i in range(1, N+1):
        visited = [-1]*(N+1)
        visited[i] = 0
        s = 0
        q = deque([[i]])
        while s != k:
            p = []
            A = q.popleft()
            for a in A:
                if a == X and visited[Y] == -1:
                    p.append(Y)
                    visited[Y] = 0
                if a == Y and visited[X] == -1:
                    p.append(X)
                    visited[X] = 0
                if a+1 <=N and visited[a+1] == -1:
                    p.append(a+1)
                    visited[a+1] = 0
                if a-1 >= 1 and visited[a-1] == -1:
                    p.append(a-1)
                    visited[a-1] = 0
            q.append(p)
            s += 1
        r = q[0]
        t = 0
        for j in range(len(r)):
            if r[j] > i:
                t += 1
        cnt += t
    return cnt

N, X, Y = map(int, input().split())
for k in range(1, N):
    print (count_pair(k))

Fixed submission:
N, X, Y = map(int, input().split())
t = [0]*N
for i in range(1, N):
    for j in range(i+1, N+1):
        t[min(j-i, abs(X-i)+1+abs(j-Y))] += 1
for k in range(1, N):
    print (t[k])
Buggy python submission (verdict: Time Limit Exceeded):
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
dp = [[0 for _ in range(S+1)] for _ in range(N)]

for i in range(0, S+1):
    if i == A[0]:
        dp[0][i] = 1

for i in range(1, N):
    for j in range(0, S+1):
        if j > A[i]:
            dp[i][j] = (dp[i-1][j]+dp[i-1][j-A[i]])%mod
        elif j == A[i]:
            dp[i][j] = (dp[i-1][j]+(i+1))%mod
        else:
            dp[i][j] = dp[i-1][j]
            
ans = 0
for i in range(0, N):
    ans = (ans+dp[i][S])%mod

print (ans)

Fixed submission:
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
dp = [[0 for _ in range(S+1)] for _ in range(N)]

for j in range(0, S+1):
    if j == A[0]:
        dp[0][j] = 1
        break

for i in range(1, N):
    for j in range(0, S+1):
        if j > A[i]:
            dp[i][j] = (dp[i-1][j]+dp[i-1][j-A[i]])%mod
        elif j == A[i]:
            dp[i][j] = (dp[i-1][j]+(i+1))%mod
        else:
            dp[i][j] = dp[i-1][j]
            
ans = 0
for i in range(0, N):
    ans = (ans+dp[i][S])%mod
    
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
dp = [[0 for _ in range(S+1)] for _ in range(N)]

for i in range(0, S+1):
    if i == A[0]:
        dp[0][i] = 1

for i in range(0, N):
    for j in range(0, S+1):
        if j > A[i]:
            dp[i][j] = (dp[i-1][j]+dp[i-1][j-A[i]])%mod
        elif j == A[i]:
            dp[i][j] = (dp[i-1][j]+(i+1))%mod
        else:
            dp[i][j] = dp[i-1][j]
            
ans = 0
for i in range(0, N):
    ans = (ans+dp[i][S])%mod

print (ans)

Fixed submission:
N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
dp = [[0 for _ in range(S+1)] for _ in range(N)]

for j in range(0, S+1):
    if j == A[0]:
        dp[0][j] = 1
        break

for i in range(1, N):
    for j in range(0, S+1):
        if j > A[i]:
            dp[i][j] = (dp[i-1][j]+dp[i-1][j-A[i]])%mod
        elif j == A[i]:
            dp[i][j] = (dp[i-1][j]+(i+1))%mod
        else:
            dp[i][j] = dp[i-1][j]
            
ans = 0
for i in range(0, N):
    ans = (ans+dp[i][S])%mod
    
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
a = [0]*Q
for i in range(0, Q):
    a[i] = list(input().split())
    if a[i][0] == "1":
        S = S[::-1]
    elif a[i][1] == "1":
        S = a[i][2]+S
    else:
        S = S+a[i][2]
print (S)

Fixed submission:
import collections

S = collections.deque(list(input()))
Q = int(input())
rev = 0
for i in range(0, Q):
    query = list(input().split())
    if query[0] == "1":
        rev = rev+1
    else:
        if query[1] == "1":
            if rev%2 == 0:
                S.appendleft(query[2])
            else:
                S.append(query[2])
        else:
            if rev%2 == 0:
                S.append(query[2])
            else:
                S.appendleft(query[2])
if rev%2 == 0:
    for i in S:
        print (i, end = "")
else:
    for i in reversed(S):
        print (i, end = "")

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
a = [0]*Q
for i in range(0, Q):
    a[i] = list(input().split())
    if a[i] == ["1"]:
        S = S[::-1]
    else:
        if a[i][1] == "1":
            S = a[i][2]+S
        else:
            S = S+a[i][2]
print (S)

Fixed submission:
import collections

S = collections.deque(list(input()))
Q = int(input())
rev = 0
for i in range(0, Q):
    query = list(input().split())
    if query[0] == "1":
        rev = rev+1
    else:
        if query[1] == "1":
            if rev%2 == 0:
                S.appendleft(query[2])
            else:
                S.append(query[2])
        else:
            if rev%2 == 0:
                S.append(query[2])
            else:
                S.appendleft(query[2])
if rev%2 == 0:
    for i in S:
        print (i, end = "")
else:
    for i in reversed(S):
        print (i, end = "")

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
a = [0]*Q
for i in range(0, Q):
    a[i] = list(input().split())
    if a[i] == ["1"]:
        S = S[::-1]
    else:
        if a[i][1] == "1":
            S = a[i][2]+S
        else:
            S = S+a[i][2]
print (S)

Fixed submission:
import collections

S = collections.deque(list(input()))
Q = int(input())
rev = 0
for i in range(0, Q):
    query = list(input().split())
    if query[0] == "1":
        rev = rev+1
    else:
        if query[1] == "1":
            if rev%2 == 0:
                S.appendleft(query[2])
            else:
                S.append(query[2])
        else:
            if rev%2 == 0:
                S.append(query[2])
            else:
                S.appendleft(query[2])
if rev%2 == 0:
    for i in S:
        print (i, end = "")
else:
    for i in reversed(S):
        print (i, end = "")
Buggy python submission (verdict: Runtime Error):
N, P = map(int, input().split())
S = input()
U = [0]*P
ans = 0
if P == 2 or P == 5:
    for i in range(0, N):
        if int(S[i])%P == 0:
            ans += i+1
    print (ans)
else:
    for _ in range(0, N):
        U[int(S)%P] += 1
        S = S.lstrip(S[0])
    for u in U:
        ans += u*(u-1)//2
    ans += U[0]
    print (ans)

Fixed submission:
N, P = map(int, input().split())
S = input()
U = [0]*P
ans = 0
if P == 2 or P == 5:
    for i in range(0, N):
        if int(S[i])%P == 0:
            ans += i+1
    print (ans)
else:
    t, s = 0, 1
    for i in range(N-1, -1, -1):
        t = (int(S[i])*s+t)%P
        U[t] += 1
        s = s*10%P
    for u in U:
        ans += u*(u-1)//2
    ans += U[0]
    print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, P = map(int, input().split())
S = input()
U = [0]*P
ans = 0
if P == 2 or P == 5:
    for i in range(0, N):
        if int(S[i])%P == 0:
            ans += i+1
    print (ans)
else:
    for i in range(0, N):
        U[int(S[i:N])%P] += 1
    for u in U:
        ans += u*(u-1)//2
    ans += U[0]
    print (ans)

Fixed submission:
N, P = map(int, input().split())
S = input()
U = [0]*P
ans = 0
if P == 2 or P == 5:
    for i in range(0, N):
        if int(S[i])%P == 0:
            ans += i+1
    print (ans)
else:
    t, s = 0, 1
    for i in range(N-1, -1, -1):
        t = (int(S[i])*s+t)%P
        U[t] += 1
        s = s*10%P
    for u in U:
        ans += u*(u-1)//2
    ans += U[0]
    print (ans)
Buggy python submission (verdict: Runtime Error):
A = [0]*3
b = [0]*N
for i in range(0, 3):
    A[i] = list(map(int, input().split()))
N = int(input())
for i in range(0, N):
    b[i] = int(input())
for i in range(0, 3):
    for j in range(0, 3):
        for k in range(0, N):
            if A[i][j] == b[k]:
                A[i][j] = 0
if A[0] == [0, 0, 0] or A[1] == [0, 0, 0] or A[2] == [0, 0, 0]:
    print ("Yes")
elif A[0][0] == A[1][0] == A[2][0] == 0:
    print ("Yes")
elif A[0][1] == A[1][1] == A[2][1] == 0:
    print ("Yes")
elif A[0][2] == A[1][2] == A[2][2] == 0:
    print ("Yes")
elif A[0][0] == A[1][1] == A[2][2] == 0:
    print ("Yes")
elif A[0][2] == A[1][1] == A[2][0] == 0:
    print ("Yes")
else:
    print ("No")

Fixed submission:
A = [0]*3
for i in range(0, 3):
    A[i] = list(map(int, input().split()))
N = int(input())
b = [0]*N
for i in range(0, N):
    b[i] = int(input())
for i in range(0, 3):
    for j in range(0, 3):
        for k in range(0, N):
            if A[i][j] == b[k]:
                A[i][j] = 0
if A[0] == [0, 0, 0] or A[1] == [0, 0, 0] or A[2] == [0, 0, 0]:
    print ("Yes")
elif A[0][0] == A[1][0] == A[2][0] == 0:
    print ("Yes")
elif A[0][1] == A[1][1] == A[2][1] == 0:
    print ("Yes")
elif A[0][2] == A[1][2] == A[2][2] == 0:
    print ("Yes")
elif A[0][0] == A[1][1] == A[2][2] == 0:
    print ("Yes")
elif A[0][2] == A[1][1] == A[2][0] == 0:
    print ("Yes")
else:
    print ("No")

Buggy python submission (verdict: Runtime Error):
A = [0]*3
b = [0]*N
for i in range(0, 3):
    A[i] = list(map(int, input().split()))
N = int(input())
for i in range(0, N):
    b[i] = int(input())
for i in range(0, 3):
    for j in range(0, 3):
        for k in range(0, N):
            if A[i][j] == b[k]:
                A[i][j] = 0
if A[0] == [0, 0, 0] or A[1] == [0, 0, 0] or A[2] == [0, 0, 0]:
    print ("Yes")
elif A[0][0] == A[1][0] == A[2][0] == 0:
    print ("Yes")
elif A[0][1] == A[1][1] == A[2][1] == 0:
    print ("Yes")
elif A[0][2] == A[1][2] == A[2][2] == 0 :
    print ("Yes")
elif A[0][0] == A[1][1] == A[2][2] == 0:
    print ("Yes")
elif A[0][2] == A[1][1] == A[2][0] == 0:
    print ("Yes")
else:
    print ("No")

Fixed submission:
A = [0]*3
for i in range(0, 3):
    A[i] = list(map(int, input().split()))
N = int(input())
b = [0]*N
for i in range(0, N):
    b[i] = int(input())
for i in range(0, 3):
    for j in range(0, 3):
        for k in range(0, N):
            if A[i][j] == b[k]:
                A[i][j] = 0
if A[0] == [0, 0, 0] or A[1] == [0, 0, 0] or A[2] == [0, 0, 0]:
    print ("Yes")
elif A[0][0] == A[1][0] == A[2][0] == 0:
    print ("Yes")
elif A[0][1] == A[1][1] == A[2][1] == 0:
    print ("Yes")
elif A[0][2] == A[1][2] == A[2][2] == 0:
    print ("Yes")
elif A[0][0] == A[1][1] == A[2][2] == 0:
    print ("Yes")
elif A[0][2] == A[1][1] == A[2][0] == 0:
    print ("Yes")
else:
    print ("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for _ in range(0, N)]
t = {}
for i in range(0, N):
    if S[i] in t:
        t[S[i]] += 1
    else:
        t[S[i]] = 1
max_k_list = [kv[0] for kv in t.items() if kv[1] == max(t.values())]
max_k_list.sort()
ans = "\n".join(max_k_list)
print(ans)

Fixed submission:
N = int(input())
S = [input() for _ in range(0, N)]
t = {}
for i in range(0, N):
    if S[i] in t:
        t[S[i]] += 1
    else:
        t[S[i]] = 1
vmax = max(t.values())
ans = []
for key in t.keys():
    if t[key] == vmax:
        ans.append(key)
ans.sort()
for i in ans:
    print (i)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))
s = 0
for i in range(0,N-K+1):
    t = K
    for j in range(0,K):
        t = t+p[i+j]
    t = t/2
    if s < t:
        s = t
print (s)

Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
s = 0
for i in range(0,K):
    s = s+p[i]
u = s
for i in range(0,N-K):
    t = s+p[i+K]-p[i]
    if u < t:
        u = t
    s = t
print ((u+K)/2)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
p_S = []
for i in range(0,M):
    a, b = input().split()
    a = int(a)
    p_S.append([a,b])
s, t = 0, 0
res = []
for i in range(0,N):
    res.append([i,0])
for i in range(0,M):
    if p_S[i][1] == "WA":
        res[p_S[i][0]][1] = res[p_S[i][0]][1]+1
    elif res[p_S[i][0]][1] >= 0:
        s, t = s+1, t+res[p_S[i][0]][1]
        res[p_S[i][0]][1] = -1
print(s, t)

Fixed submission:
N, M = map(int, input().split())
p, S = [0]*M, [0]*M
for i in range(0,M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])
s, t = 0, 0
res = []
for i in range(0,N):
    res.append([i,0])
for i in range(0,M):
    if S[i] == "WA":
        res[p[i]-1][1] = res[p[i]-1][1]+1
    elif res[p[i]-1][0] != -1:
        s, t = s+1, t+res[p[i]-1][1]
        res[p[i]-1][0] = -1
print(s, t)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [input().split() for _ in range(H)]

from collections import deque

def bfs(sy, sx):
    q = deque([[sy, sx]])
    visited = [[-1]*W for _ in range(H)]
    visited[sy][sx] = 0
    while q:
        y, x = q.popleft()
        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+i, x+j
            if not 0 <= new_y < H or not 0 <= new_x < W:
                continue
            if S[new_y][new_x] ==  "." and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x]+1
                q.append([new_y, new_x])
    return max(max(l) for l in visited)

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            ans = max(ans, bfs(i, j))
print (ans)

Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]

from collections import deque

def bfs(sy, sx):
    q = deque([[sy, sx]])
    visited = [[-1]*W for _ in range(H)]
    visited[sy][sx] = 0
    while q:
        y, x = q.popleft()
        for i, j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+i, x+j
            if not 0 <= new_y < H or not 0 <= new_x < W:
                continue
            if S[new_y][new_x] ==  "." and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x]+1
                q.append([new_y, new_x])
    return max(max(l) for l in visited)

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            ans = max(ans, bfs(i, j))
print (ans)