Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
IN=lambda:map(int,input().split())
N,W=IN()
INF=float("inf")
dp=[INF]*(100*N)
dp.insert(0,0)
c=0
ans=0
for i in range(N):
    w,v=IN()
    for j in range((100*N+1),-1,-1):
        if dp[j-v]!=INF:
            dp[j]=min(dp[j],dp[j-v]+w)
for i in dp:
    c+=1
    if i<=W:
        ans=c-1
print(ans)   

Fixed submission:
IN=lambda:map(int,input().split())
N,W=IN()
INF=float("inf")
dp=[INF]*(1000*N)
dp.insert(0,0)
c=0
ans=0
for i in range(N):
    w,v=IN()
    for j in range((1000*N+1),-1,-1):
        if dp[j-v]!=INF:
            dp[j]=min(dp[j],dp[j-v]+w)
for i in range(1000*N+1):
    if dp[i]<=W:
        ans=i
print(ans)

Buggy python submission (verdict: Runtime Error):
N,W=map(int,input().split())
w=0
v=0
w_list=[]
v_list=[]
dp=[0]*(W+1)
for i in range (N):
    w,v=map(int,input().split())
    w_list.append(w)
    v_list.append(v)
for i in range (N):
    for j in range(W,-1,-1):
        if j>=w_list[i]:
            dp[j]=max(dp[j],dp[j-w_list[i]]+v_list[i])
print(dp[-1])

Fixed submission:
IN=lambda:map(int,input().split())
N,W=IN()
INF=float("inf")
dp=[INF]*(1000*N)
dp.insert(0,0)
c=0
ans=0
for i in range(N):
    w,v=IN()
    for j in range((1000*N+1),-1,-1):
        if dp[j-v]!=INF:
            dp[j]=min(dp[j],dp[j-v]+w)
for i in range(1000*N+1):
    if dp[i]<=W:
        ans=i
print(ans)

Buggy python submission (verdict: Runtime Error):
N,W=map(int,input().split())
w=0
v=0
w_list=[]
v_list=[]
dp=[0]*(W+1)
for i in range (N):
    w,v=map(int,input().split())
    w_list.append(w)
    v_list.append(v)
for i in range (N):
    for j in range(0,W+1,-1):
        if j>=w_list[i]:
            dp[j]=max(dp[j],dp[j-w_list[i]]+v_list[i])
print(dp[-1])

Fixed submission:
IN=lambda:map(int,input().split())
N,W=IN()
INF=float("inf")
dp=[INF]*(1000*N)
dp.insert(0,0)
c=0
ans=0
for i in range(N):
    w,v=IN()
    for j in range((1000*N+1),-1,-1):
        if dp[j-v]!=INF:
            dp[j]=min(dp[j],dp[j-v]+w)
for i in range(1000*N+1):
    if dp[i]<=W:
        ans=i
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
alise=0
bob=0
a_list=list(map(int,input().split()))
a_sort=sorted(a_list)[::-1]
for i in range(N//2+N%2):
    alise+=a_sort.pop(0)
    bob+=a_sort.pop(0)
print(alise-bob)

Fixed submission:
N=int(input())
alise=0
bob=0
a_list=list(map(int,input().split()))
a_sort=sorted(a_list)
for i in range(N,0,-2):
    alise+=a_sort[i-1]
for i in range(N-1,0,-2):
    bob+=a_sort[i-1]
print(alise-bob)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=int(input())
B=int(input())
Answer=[]
for i in range(10):
    for j in range(10):
        for k in range(10):
            for l in range(10):
                if i*10**3+j*10**2+k*10+l<=N and A<=i+j+k+l<=B:
                    Answer.append(i*10**3+j*10**2+k*10+l)
print(sum(Answer))


Fixed submission:
N,A,B=map(int,input().split())
ans=0 

for i in range(1,N+1):
    D=0
    for j in str(i):
        D+=int(j)
    if A<=D<=B:
        ans+=i
print(ans)
Buggy python submission (verdict: Runtime Error):
def is_kaibunn(str): return 1 if str == str[::-1] else 0
word_front = input()
flag = 0
num = len(word)
word_back = word_front
while num > 1:
    if is_kaibunn(word_front) and is_kaibunn(word_back):
        flag = 1
    else:
        flag = 0
        break;
    
    if num%2 == 1:
        num_flag = 1
    else:
        num_flag = 0
    num = int(num/2)
    if num_flag == 1:
        word_front = word_front[0:num]
        word_back = word_back[num+1:]
    else:
        word_front = word_front[0:num]
        word_back = word_back[num:]       
if flag:
    print('Yes')
else:
    print('No')


Fixed submission:

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

even,odd = map(int,input().split())
if even != 1 or odd != 1:
    numa = cmb(even,2)
    numb = cmb(odd,2)
    if even == 1 or even == 0:
        numa = 0
    if odd == 1 or odd == 0:
        numb = 0
    print(numa+numb)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
#X匹Y本の組み合わせが存在するか判定。鶴の数を基準に連立方程式を解いて、鶴の数が正の整数であればYES
X,Y = map(int,input().split())
a = (4 * X - Y) / 2
if a.is_integer() and 0 <= a:
  print("Yes")
else:
  print("No")


Fixed submission:
nums = list(map(int, input().split()))
print(nums.index(0)+1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = [int(i) for i in input().split()]
ans = 1

if 0 in p:
  print(0)
  exit()
  
for i in range(n):
  ans*=p[i]
  
if ans > 10 ** 18:
  print(-1)
  exit()
  
print(ans)

Fixed submission:
A,B = map(int,input().split())
print(A*B)
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = [int(i) for i in input().split()]
ans = 1

if 0 in p:
  print(0)
  exit()
  
for i in range(N):
  ans*=p[i]
  if ans > 10 ** 18:
  print(-1)
  exit()
  
print(ans)

Fixed submission:
N = int(input())
p = [int(i) for i in input().split()]
ans = 1

if 0 in p:
  print(0)
  exit()
  
for i in range(N):
  ans*=p[i]
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = [int(i) for i in input().split()]
ans = 1

if 0 in p:
  print(0)
  exit()

for i in range(N):
  ans*=p[i]
  
if ans > 10 ** 18:
  print(-1)
  exit()
  
print(ans)

Fixed submission:
N = int(input())
p = [int(i) for i in input().split()]
ans = 1

if 0 in p:
  print(0)
  exit()
  
for i in range(N):
  ans*=p[i]
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
p = [int(i) for i in input().split()]
ans = 1

if 0 in p:
  print(0)
  exit()
  
for i in range(n):
  ans*=p[i]
  
if ans > 10 ** 18:
  print(-1)
  exit()
  
print(ans)

Fixed submission:
N = int(input())
p = [int(i) for i in input().split()]
ans = 1

if 0 in p:
  print(0)
  exit()
  
for i in range(N):
  ans*=p[i]
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = [int(i) for i in input().split()]
ans = 1

if 0 in p:
  print(0)
  exit()
  
for i in p:
  ans = ans * i
  
if ans > 10 ** 18:
  print(-1)
else:
  print(ans)

Fixed submission:
N = int(input())
p = [int(i) for i in input().split()]
ans = 1

if 0 in p:
  print(0)
  exit()
  
for i in range(N):
  ans*=p[i]
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = [int(i) for i in input().split()]

ans = 1
for i in p:
  ans = ans * i
  
if ans > 10 ** 18:
  print(-1)
else:
  print(ans)

Fixed submission:
N = int(input())
p = [int(i) for i in input().split()]
ans = 1

if 0 in p:
  print(0)
  exit()
  
for i in range(N):
  ans*=p[i]
  if ans > 10 ** 18:
    print(-1)
    exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

if S == T[0:-1]:
  print('Yes')
else:
  print('No')

Fixed submission:
N = int(input())
if N%10 in [2,4,5,7,9]:
  print('hon')
elif N%10 in [0,1,6,8]:
  print('pon')
else:
  print('bon')
Buggy python submission (verdict: Runtime Error):
if K < A:
  print(A)
elif A <= K and B >= (K-A):
  print(A)
else:
  print(A - (K-A-B))

Fixed submission:
A,B,C,K =list(map(int,input().split()))
if K < A:
  print(K)
elif A <= K and B >= (K-A):
  print(A)
else:
  print(A - (K-A-B))
Buggy python submission (verdict: Time Limit Exceeded):
input()
a = map(int, input().split())
ans = 1
from functools import reduce
from operator import mul
ans = reduce(mul, a)
if(ans > 10 ** 18):
    ans = -1
print(ans)

Fixed submission:
input()
a = map(int, input().split())
a = list(a)
ans = 1
c = 10 ** 18
if 0 in a:
    print(0)
    exit(0)
for b in a:
    ans *= b
    if(ans > c ):
        print(-1)
        exit(0)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
input()
a = map(int, input().split())
a = list(a)
ans = 1
for b in a:
    ans *= b
if(ans > 10 ** 18):
    ans = -1
print(ans)

Fixed submission:
input()
a = map(int, input().split())
a = list(a)
ans = 1
c = 10 ** 18
if 0 in a:
    print(0)
    exit(0)
for b in a:
    ans *= b
    if(ans > c ):
        print(-1)
        exit(0)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
input()
a = map(int, input().split())
a = list(a)
ans = 1
for b in a:
    ans *= b
if(ans > 10 ** 18):
    ans = -1
print(ans)

Fixed submission:
input()
a = map(int, input().split())
a = list(a)
ans = 1
c = 10 ** 18
if 0 in a:
    print(0)
    exit(0)
for b in a:
    ans *= b
    if(ans > c ):
        print(-1)
        exit(0)
print(ans)
Buggy python submission (verdict: Runtime Error):
HW = [int(i) for i in input().split()]
hw = [int(i) for i in input().split()]

print((HW[0] - hw[0])(HW[1] - hw[1]))

Fixed submission:
HW = [int(i) for i in input().split()]
hw = [int(i) for i in input().split()]

print((HW[0] - hw[0])*(HW[1] - hw[1]))
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,K = map(int,input().split())

t = 1
while t<=K:
    a = B+C
    b = A+C
    C = a+b-2*C
    A = a
    B = b
    t+=1

ans = A - B

if ans<=10^18:
    print(ans)
else:
    print('Unfair')

Fixed submission:
A,B,C,K = map(int,input().split())

if K % 2 == 0:
    m = A-B
else:
    m = B-A

print(m)
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
print(a*b)

Fixed submission:
a,b=[int(i) for i in input().split()]
print(a*b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
arr = [int(x) for x in input().split()]
for each in arr:
    ans *= each
if (ans > 1e18):
    print(-1)
else:
    print(ans)


Fixed submission:
n = int(input())
ans = 1
arr = [int(x) for x in input().split()]
arr.sort()
for each in arr:
    ans *= each
    if (ans > 1e18):
        print(-1)
        exit(0)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
import math
read = sys.stdin.readline

X = int(input())


for a in range(1,10000):
    for b in range(0,10000):
        a4 = a ** 4
        b4 = b ** 4
        a3 = a ** 3
        b3 = b ** 3
        a2 = a ** 2
        b2 = b ** 2
        if ( (a-b)*( a4 + (a3*b) + (a2 * b2) + (b3 * a) + b4) ) == X:
            print(a,b)
            sys.exit()

        b = -1 * b
        b3 = -1 * b3
        if ( (a-b)*( a4 + (a3*b) + (a2 * b2) + (b3 * a) + b4) ) == X:
            print(a,b)
            flag = 1
            sys.exit()
        


Fixed submission:
import numpy as np
import sys
import math
read = sys.stdin.readline

X = int(input())


for a in range(1,1000):
    for b in range(0,1000):
        a4 = a ** 4
        b4 = b ** 4
        a3 = a ** 3
        b3 = b ** 3
        a2 = a ** 2
        b2 = b ** 2
        if ( (a-b)*( a4 + (a3*b) + (a2 * b2) + (b3 * a) + b4) ) == X:
            print(a,b)
            sys.exit()

        b = -1 * b
        b3 = -1 * b3
        if ( (a-b)*( a4 + (a3*b) + (a2 * b2) + (b3 * a) + b4) ) == X:
            print(a,b)
            flag = 1
            sys.exit()
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
import math
read = sys.stdin.readline

N = int(read().rstrip())
A = list(map(int,read().rstrip().split()))
da = []
for i , a in enumerate(A):
    da.append([i,a])

sumN = [0] * N
for i , a in enumerate(A):
    sumN[i] = i + a + 1

sumN = sorted(sumN)

newA = sorted(da , key = lambda x:(x[1]))
ans = 0

for s in sumN :
    if s > 200000:
        break

    for a in newA :
        if s + a[1] > 200000:
            break

        if s  + a[1]  == a[0] + 1:
            ans += 1

print(ans)


Fixed submission:
import numpy as np
import sys
import math
read = sys.stdin.readline

N = int(read().rstrip())
A = list(map(int,read().rstrip().split()))
da = []
for i , a in enumerate(A):
    da.append([i,a])

dR = {}
dL = {}

ans = 0
for d in reversed(da):
    r = d[0] + d[1] + 1
    l = d[0] - d[1] + 1 
    if r in dR:
        dR[r] += 1
    else:
        dR[r] = 1

    if r in dL:
        ans += dL[r]

    if l in dL :
        dL[l] += 1
    else:
        dL[l] = 1  

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
import math
read = sys.stdin.readline

N = int(read().rstrip())
A = list(map(int,read().rstrip().split()))
da = []
for i , a in enumerate(A):
    da.append([i,a])

sumN = [0] * N
for i , a in enumerate(A):
    sumN[i] = i + a + 1


newA = sorted(da , key = lambda x:(x[1]))
ans = 0
for s in sumN :
    if s > 200000:
        continue

    for a in newA :
        if s + a[1] > 200000:
            break

        if s  + a[1]  == a[0] + 1:
            ans += 1

print(ans)


Fixed submission:
import numpy as np
import sys
import math
read = sys.stdin.readline

N = int(read().rstrip())
A = list(map(int,read().rstrip().split()))
da = []
for i , a in enumerate(A):
    da.append([i,a])

dR = {}
dL = {}

ans = 0
for d in reversed(da):
    r = d[0] + d[1] + 1
    l = d[0] - d[1] + 1 
    if r in dR:
        dR[r] += 1
    else:
        dR[r] = 1

    if r in dL:
        ans += dL[r]

    if l in dL :
        dL[l] += 1
    else:
        dL[l] = 1  

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
import math
read = sys.stdin.readline

N = int(read().rstrip())
A = list(map(int,read().rstrip().split()))
da = []
for i , a in enumerate(A):
    da.append([i,a])

sumN = [0] * N
for i , a in enumerate(A):
    sumN[i] = i + a + 1


newA = sorted(da , key = lambda x:(x[1]))
ans = 0
for s in sumN :
    for a in newA :
        if s + a[1] > 200000:
            break

        if s  + a[1]  == a[0] + 1:
            ans += 1

print(ans)  


Fixed submission:
import numpy as np
import sys
import math
read = sys.stdin.readline

N = int(read().rstrip())
A = list(map(int,read().rstrip().split()))
da = []
for i , a in enumerate(A):
    da.append([i,a])

dR = {}
dL = {}

ans = 0
for d in reversed(da):
    r = d[0] + d[1] + 1
    l = d[0] - d[1] + 1 
    if r in dR:
        dR[r] += 1
    else:
        dR[r] = 1

    if r in dL:
        ans += dL[r]

    if l in dL :
        dL[l] += 1
    else:
        dL[l] = 1  

print(ans)
Buggy python submission (verdict: Runtime Error):
# import module
import sys
import math
import numpy as np

S = input()

if S.find(A) != -1 and S.find("B") != 0:
    print("Yes")
else:
    print("No")

Fixed submission:
# import module
import sys
import math
import numpy as np

S = input()

if S.find("A") != -1 and S.find("B") != -1:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# import module
import sys
import math
import numpy as np

N , A , B = map(int,input().split())

x = int(N / (A+B)) 
y = N % (A+B)

if y > A:
    print(x*A+ A)
else
    print(x*A + y )



Fixed submission:
# import module
import sys
import math
import numpy as np

N , A , B = map(int,input().split())

x = int(N / (A+B)) 
y = N % (A+B)

if y > A:
    print(x*A+ A)
else:
    print(x*A + y )
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math

def add_h(s,c):
    return c+s

def add_t(s,c):
    return s+c

s = input()
Q = int(input())
query = []
[query.append(input().split()) for _ in range(Q)]

inversion = -1

for i in range(Q):
    if query[i][0] == "1":
        inversion *= -1
        continue

    c = str(query[i][2])
    if query[i][1] == "1" and inversion == -1:
        s = c + s
    elif query[i][1] == "1" and inversion == 1:
        s = s + c
    elif query[i][1] == "2" and inversion == -1:
        s = s+ c
    else:
        s = c + s


if inversion == -1:
    print(s)
else:
    print(s[::-1])

        

Fixed submission:
import sys
import math

s = input()
Q = int(input())
query = []
[query.append(input().split()) for _ in range(Q)]

inversion = -1

if len(s) >= 3:
    head = s[0]
    tail = s[-1]
    body = s[1:-1]
    for i in range(Q):
        if query[i][0] == "1":
            inversion *= -1
            continue

        c = str(query[i][2])
        if query[i][1] == "1" and inversion == -1:
            head = c + head
        elif query[i][1] == "1" and inversion == 1:
            tail = tail + c
        elif query[i][1] == "2" and inversion == -1:
            tail = tail + c
        else:
            head = c + head
        
    if inversion == -1:
        print(head + body + tail)
    else:
        print(tail[::-1] + body[::-1] + head[::-1])

else:
        for i in range(Q):
            if query[i][0] == "1":
                inversion *= -1
                continue

            c = str(query[i][2])
            if query[i][1] == "1" and inversion == -1:
                s = c + s
            elif query[i][1] == "1" and inversion == 1:
                s = s + c
            elif query[i][1] == "2" and inversion == -1:
                s = s + c
            else:
                s = c + s
        
        if inversion == -1 :
            print(s)
        else:
            print(s[::-1])
Buggy python submission (verdict: Runtime Error):
import sys

n , m = map(int,input().split())
if m == 0:
    m += 1
a = []

for i in range(m):
    a.append(list(map(int,input().split())))

ans = [-1] * n

for j in a:
    if ans[j[0]-1] == -1:
        if j[0] > n:
            print(-1)
            sys.exit()
        else:
            ans[j[0]-1] = j[1]
    elif ans[j[0]-1] == j[1]:
        continue
    else:
        print(-1)
        sys.exit()

if n == 3 and ans[0] == -1 and ans[1] == 0:
    ans[0] = 1

for index,l in enumerate(ans):
    if l == -1 :
        ans[index] = 0
    elif index == 0 and n != 1:
        if ans[index] == 0:
            print(-1)
            sys.exit()

for index , x in enumerate(ans):
    ans[index] = str(ans[index])

b = "".join(ans)

if b == "000" or b == "00" or b == "0":
    print(0)
else:
    print(int(b))

Fixed submission:
import sys

n , m = map(int,input().split())
#if m == 0:
#    m += 1
a = []

for i in range(m):
    a.append(list(map(int,input().split())))

ans = [-1] * n

for j in a:
    if ans[j[0]-1] == -1:
        if j[0] > n:
            print(-1)
            sys.exit()
        else:
            ans[j[0]-1] = j[1]
    elif ans[j[0]-1] == j[1]:
        continue
    else:
        print(-1)
        sys.exit()

if n == 3 and ans[0] == -1:
    ans[0] = 1

if n == 2 and ans[0] == -1:
    ans[0] = 1

for index,l in enumerate(ans):
    if l == -1 :
        ans[index] = 0
    elif index == 0 and n != 1:
        if ans[index] == 0:
            print(-1)
            sys.exit()

for index , x in enumerate(ans):
    ans[index] = str(ans[index])

b = "".join(ans)

if b == "000" or b == "00" or b == "0":
    print(0)
else:
    if len(b) == n:
        print(int(b))
    else:
        print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
    S.append(input())

#S.sort()

dic = list((set(S)))
times = [0] * len(dic)

for s in S :
    for i in range(len(dic)):
        if dic[i] == s:
            times[i] += 1

ans = [0] * len(dic)
ma = max(times)

s_ans = []

for a in range(len(dic)):
    if times[a] == ma:
        s_ans.append(dic[a])

s_ans.sort()

for j in range(len(s_ans)):
    print(s_ans[j])



Fixed submission:
N = int(input())
S = []
for i in range(N):
    S.append(input())

S.sort()

dic = list((set(S)))
dic.sort()
times = [0] * len(dic)
aa=0

for s in S :
    if dic[aa] == s:
        times[aa] += 1
    else:
        aa += 1
        times[aa] += 1

ans = [0] * len(dic)
ma = max(times)

s_ans = []

for a in range(len(dic)):
    if times[a] == ma:
        s_ans.append(dic[a])

s_ans.sort()

for j in range(len(s_ans)):
    print(s_ans[j])
Buggy python submission (verdict: Runtime Error):
N , M = map(int , input().split(" "))
#N = 100000
#M = 100000
solve_problem = [0] * N 
wa = [0] * N
ans = 0

for i in range(0,M):
    ps = input().split(" ")
    if ps[1] == "AC":
        if solve_problem[ int(ps[0]) -1] == 0:
            solve_problem[int(ps[0]) -1] = 1
            ans += 1
    elif ps[1] == "WA":
        if solve_problem[ int(ps[0])-1] == 0:
            wa[int(ps[0]) -1 ] += 1

print(ans,sum(wa[i] for i in range(0,N) if solve_problem[1] == 1))



Fixed submission:
N , M = map(int , input().split(" "))

solve_problem = [0] * N 
wa = [0] * N
ans = 0

for i in range(0,M):
    ps = input().split(" ")
    if ps[1] == "AC":
        if solve_problem[ int(ps[0]) -1] == 0:
            solve_problem[int(ps[0]) -1] = 1
            ans += 1
    elif ps[1] == "WA":
        if solve_problem[ int(ps[0])-1] == 0:
            wa[int(ps[0]) -1 ] += 1

print(ans,sum(wa[i] for i in range(0,N) if solve_problem[i] == 1))

Buggy python submission (verdict: Runtime Error):
N , M = map(int , input().split(" "))
#N = 100000
#M = 100000
solve_problem = [0] * N 
wa = [0] * N
ans = 0

for i in range(0,M):
    ps = input().split(" ")
    if ps[1] == "AC":
        if solve_problem[ int(ps[0]) -1] == 0:
            solve_problem[int(ps[0]) -1] = 1
            ans += 1
    elif ps[1] == "WA":
        if solve_problem[ int(ps[0])-1] == 0:
            wa[int(ps[0]) -1 ] += 1



print(ans,sum(wa[i] for i in range(0,N) if solve_problem[1] == 1))



Fixed submission:
N , M = map(int , input().split(" "))

solve_problem = [0] * N 
wa = [0] * N
ans = 0

for i in range(0,M):
    ps = input().split(" ")
    if ps[1] == "AC":
        if solve_problem[ int(ps[0]) -1] == 0:
            solve_problem[int(ps[0]) -1] = 1
            ans += 1
    elif ps[1] == "WA":
        if solve_problem[ int(ps[0])-1] == 0:
            wa[int(ps[0]) -1 ] += 1

print(ans,sum(wa[i] for i in range(0,N) if solve_problem[i] == 1))
Buggy python submission (verdict: Runtime Error):
import sys

nm = list(input().split(" "))
N = int(nm[0])
M = int(nm[1])
A = list(input().split(" "))
A.sort()
A.reverse()

ans = 0

start ,counter  = 0 , 0
flag1 = 0
flag2 = 0 # repete
flag3 = 0 # next step
for i in range(0,M):
    if flag1 == 0:
        ans += int(A[start]) + int(A[counter])
        counter += 1
        flag1 = 1
    elif flag2 == 0:
        ans += int(A[start]) + int(A[counter])
        flag2 = 1
    else:
        ans += int(A[start]) + int(A[counter])
        flag2 = 0
        if flag3 == 0:
            counter += 1
            if counter == N-1:
                flag3 = 1
        else:
            flag1 = 0
            flag3 = 0
            start += 1
            counter = start

print(ans)

    
    
    


Fixed submission:
import sys

nk = list(input().split(" "))
n = int(nk[0])
k = int(nk[1])
rsp = list(input().split(" "))
r = int(rsp[0])
s = int(rsp[1])
p = int(rsp[2])
T = str(input())

my_choice = [""] * n
ans = 0

for i in range(0,k):
    if T[i] == "r":
        my_choice[i] = "p"
        ans += p
    elif T[i] == "s":
        my_choice[i] = "r"
        ans += r
    else:
        my_choice[i] = "s"
        ans += s

if k == n:
    print(ans)
    sys.exit()

for i in range(k,n):
    if T[i] == "r" and my_choice[i - k] != "p":
        my_choice[i] = "p"
        ans += p
    elif T[i] == "s" and my_choice[i - k] != "r":
        my_choice[i] = "r"
        ans += r
    elif T[i] == "p" and my_choice[i - k] != "s":
        my_choice[i] = "s"
        ans += s


print(ans)
Buggy python submission (verdict: Runtime Error):
f = input().split(" ")
print(6 - int(f[0]) - int(f[1]) )

Fixed submission:
a = int(input())
b = int(input())
print(6 - a -b )