Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x, a, b = map(int, input().split())

if a>=b:
  print("delicious")
else:
  if x=<b:
    print("safe")
  if a+x+1 <= b:
    print("dangerous")

Fixed submission:
x, a, b = map(int, input().split())

if a>=b:
  print("delicious")
else:
  if b-a<=x:
    print("safe")
  if a+x+1 <= b:
    print("dangerous")

Buggy python submission (verdict: Runtime Error):
x, a, b = map(int, input().split())

if a-b > 0:
  print("delicious")

if b > x
  print("safe")

if b > x+1:
  print("dangerous")

Fixed submission:
x, a, b = map(int, input().split())

if a>=b:
  print("delicious")
else:
  if b-a<=x:
    print("safe")
  if a+x+1 <= b:
    print("dangerous")
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
s = ""
for _ in range(N):
  a,b = map(int, input().split())
  s += (str(a)+" ")*b
print(sorted(s.split())[K-1])

Fixed submission:
N, K = map(int, input().split())
l = sorted([tuple(map(int, input().split()))for _ in range(N)], key=lambda x:x[0])
c = 0
for i in l:
  c += i[1]
  if c >= K:
    print(i[0])
    break
Buggy python submission (verdict: Runtime Error):
N = int(input())

for i in range(1,N):
  if N % i == 0:
    ans = max(len(str(i)), len(str(N//i)))
  if N//i and i > N//i:
    break
print(ans)

Fixed submission:
N = int(input())
ans = 1
for i in range(1,N):
  if N % i == 0:
    ans = max(len(str(i)), len(str(N//i)))
  if N//i and i > N//i:
    break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = 1
for i in range(1, n+1):
      a *= i
print(a%(10**9+7))

Fixed submission:
n = int(input())
p = 1
for i in range(1, n+1): 
  p = (p*i)%(10**9+7) #合同式より同じ数で割れば任意の数で乗算しても余りは等しい
print(p)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

#無向行列
path_matrix = [[False]*N for _ in range(M)]

for _ in range(M):
  line = map(int, input().split())
  paths = [x-1 for x in line]
  path_matrix[paths[0]][paths[1]] = True
  path_matrix[paths[1]][paths[0]] = True
  
visited = [False]*N

def dfs(now, depth):
  if visited[now]:
    return 0
  if depth == N-1:
    return 1
  
  visited[now] = True
  total_paths = 0
  for i in range(N):
    if path_matrix[now][i]:
      total_paths += dfs(i, depth+1)
  
  visited[now] = False
  
  return total_paths
print(dfs(0,0))

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

#無向行列
path_matrix = []

#無向行列の初期化
for _ in range(N):
    path_matrix.append([False] * N)

for _ in range(M):
  line = map(int, input().split())
  paths = [x-1 for x in line]
  path_matrix[paths[0]][paths[1]] = True
  path_matrix[paths[1]][paths[0]] = True
  
visited = [False]*N

def dfs(now, depth):
  if visited[now]:
    return 0
  if depth == N-1:
    return 1
  
  visited[now] = True
  total_paths = 0
  for i in range(N):
    if path_matrix[now][i]:
      total_paths += dfs(i, depth+1)
  
  visited[now] = False
  
  return total_paths
print(dfs(0,0))

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

#無向行列
path_matrix = [[False]*N for _ in range(M)]

for _ in range(M):
  line = map(int, input().split())
  paths = [x-1 for x in line]
  path_matrix[paths[0]][paths[1]] = True
  path_matrix[paths[1]][paths[0]] = True
  
visited = [False]*N

def dfs(now, depth):
  if visited[now]:
    return 0
  if depth == N-1:
    return 1
  
  visited[now] = True
  total_paths = 0
  for i in range(N):
    if path_matrix[now][i]:
      total_paths += dfs(i, depth+1)
  
  visited[now] = False
  
  return total_paths
print(dfs(0,0))

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

#無向行列
path_matrix = []

#無向行列の初期化
for _ in range(N):
    path_matrix.append([False] * N)

for _ in range(M):
  line = map(int, input().split())
  paths = [x-1 for x in line]
  path_matrix[paths[0]][paths[1]] = True
  path_matrix[paths[1]][paths[0]] = True
  
visited = [False]*N

def dfs(now, depth):
  if visited[now]:
    return 0
  if depth == N-1:
    return 1
  
  visited[now] = True
  total_paths = 0
  for i in range(N):
    if path_matrix[now][i]:
      total_paths += dfs(i, depth+1)
  
  visited[now] = False
  
  return total_paths
print(dfs(0,0))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
m = 0
for i in range(len(s)):
    for j in range(len(s)-1, -1, -1):
        if s[i] == "A" and s[j] == "Z":
            if m < j-i+1:
                m = j-i+1
print(m)

Fixed submission:
s = input()
min_A = len(s)
max_Z = 0
for i in range(len(s)):
    if s[i] == "A":
        if min_A>i:
            min_A = i
    if s[i] == "Z":
        if max_Z < i:
            max_Z = i
print(max_Z-min_A+1)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input(),split())
if str(b) == "+":
  print(a+b)
else:
  print(a-b)

Fixed submission:
i = input().split()
if i[1] == "+":
  print(int(i[0])+int(i[2]))
else:
  print(int(i[0])-int(i[2]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
Ts = list(map(int, input().split()))
M = int(input())
for i in range(M):
  p, x = map(int, input().split())
  print(sum(Ts)-T[p-1]+x)

Fixed submission:
import copy
N = int(input())
Ts = list(map(int, input().split()))
M = int(input())
for i in range(M):
  P, x = map(int, input().split())
  Ts_2 = copy.copy(Ts) #コピーを行う
  Ts_2[P-1] = x
  print(sum(Ts_2))
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
print(b//x - (a-1)//x)

Fixed submission:
a, b, c = map(str, input().split())
B = b[0]
print("A{}C".format(B))
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())
c = 0
for i in range(a, b+1):
  if i % x == 0:
    c += 1
print(c)

Fixed submission:
a, b, x = map(int, input().split())
print(b//x - (a-1)//x)
Buggy python submission (verdict: Runtime Error):
l = list(map(int, input().split()))
print(len(list(set(l)))

Fixed submission:
l = list(map(int, input().split()))
print(len(list(set(l))))
Buggy python submission (verdict: Runtime Error):
a, b = map(int,input().split())
num = (b-a)+1
if a > 0:
  print("Positive")
elif b < 0:
  if num%2 != 0:
    print("Positive")
  else:
  	print("Negative")
elif a < 0 and b > 0:
  if len(abs(a))%2 == 0:
  	print("Positive")
  else:
    print("Negative")
else:
  print("Zero")

Fixed submission:
a, b = map(int,input().split())
num = (b-a)+1
if a > 0:
  print("Positive")
elif b < 0 and num%2==0:
  print("Positive")
elif b < 0 and num%2!=0:
  print("Negative")
elif a <= 0 and b >= 0:
  print("Zero")

Buggy python submission (verdict: Runtime Error):
a, b = map(int,input().split())
num = (b-a)+1
if min(a,b) > 0 or:
  print("Positive")
elif max(a,b) < 0 and num%2!=0:
  print("Positive")
elif max(a,b) < 0 and num%2==0:
  print("Negative")
else:
  print("Zero")

Fixed submission:
a, b = map(int,input().split())
num = (b-a)+1
if a > 0:
  print("Positive")
elif b < 0 and num%2==0:
  print("Positive")
elif b < 0 and num%2!=0:
  print("Negative")
elif a <= 0 and b >= 0:
  print("Zero")

Buggy python submission (verdict: Runtime Error):
a, b = int(input())
if min(a,b) > 0:
  print("Positive")
elif max(a,b) < 0:
  print("Negative")
else:
  print("Zero")

Fixed submission:
a, b = map(int,input().split())
num = (b-a)+1
if a > 0:
  print("Positive")
elif b < 0 and num%2==0:
  print("Positive")
elif b < 0 and num%2!=0:
  print("Negative")
elif a <= 0 and b >= 0:
  print("Zero")

Buggy python submission (verdict: Runtime Error):
a, b = int(input())
if min(a,b) > 0:
  print("Positive")
elif max(a,b) < 0:
  print("Negative")
else:
  print("Zero")

Fixed submission:
a, b = map(int,input().split())
num = (b-a)+1
if a > 0:
  print("Positive")
elif b < 0 and num%2==0:
  print("Positive")
elif b < 0 and num%2!=0:
  print("Negative")
elif a <= 0 and b >= 0:
  print("Zero")
Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
s = []
for _ in range(n):
  s.append(input())
s = sorted(s)
print(*s, sep="")

Fixed submission:
A = list(map(int, input().split()))
c_7 = 0
c_5 = 0
for i in A:
  if i == 7:
    c_7 += 1
  if i == 5:
    c_5 += 1
if c_7 == 1 and c_5 == 2:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
n, l = map(int, input().split())
s = []
for _ in range(n):
  s.append(input())
s = sorted(s)
r = ""
for i in s:
  r += i
print(r)

Fixed submission:
A = list(map(int, input().split()))
c_7 = 0
c_5 = 0
for i in A:
  if i == 7:
    c_7 += 1
  if i == 5:
    c_5 += 1
if c_7 == 1 and c_5 == 2:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
N=int(input())

for i in range(0, N):
  val = input()
  if val:
    S.append(val)
AC=S.count('AC')
WA=S.count('WA')
TLE=S.count('TLE')
RE=S.count('RE')

print("AC x ", end='') 
print(AC)
print("WA x ", end='') 
print(WA)
print("TLE x ", end='') 
print(TLE)
print("RE x ", end='') 
print(RE)

Fixed submission:
N=int(input())
S=[]
for i in range(0, N):
    val = input()
    S.append(val)
ac=S.count('AC')
wa=S.count('WA')
tle=S.count('TLE')
re=S.count('RE')

print("AC x ", end='') 
print(ac)
print("WA x ", end='') 
print(wa)
print("TLE x ", end='') 
print(tle)
print("RE x ", end='') 
print(re)
Buggy python submission (verdict: Time Limit Exceeded):
import math

S=input()
T=input()


ans = 0
l=len(S)

if S ==T:
    print(0)
else:
    for a in range(l): 
          if S[a] != T[a]:
              S.replace(S[a], T[a])
              ans += 1
          
    print(ans)

Fixed submission:
S=input()
T=input()

ans = 0
l=len(S)

if S ==T:
    print(0)
else:
    for a in range(l): 
          if S[a] != T[a]:
              ans += 1
          
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
T=input()


ans = 0
l=len(S)


for a in range(l): 
      if S[a] != T[a]:
          S.replace(S[a], T[a])
          ans += 1
          
print(ans)

Fixed submission:
S=input()
T=input()

ans = 0
l=len(S)

if S ==T:
    print(0)
else:
    for a in range(l): 
          if S[a] != T[a]:
              ans += 1
          
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
def get_sum(count):
    return sum([key * count[key] for key in count.keys()])
n = int(input())
a = list(map(int, input().split()))
q = int(input())
count = Counter(a)
for i in range(q):
    b, c = list(map(int, input().split()))
    count[c] += count[b]
    count[b] = 0
    print(get_sum(count))

Fixed submission:
from collections import Counter
def get_sum(count):
    return sum([key * count[key] for key in count.keys()])
n = int(input())
a = list(map(int, input().split()))
q = int(input())
count = Counter(a)
s = sum(a)
for i in range(q):
    b, c = list(map(int, input().split()))
    count[c] += count[b]
    s -= count[b] * b
    s += count[b] * c
    count[b] = 0
    print(s)
Buggy python submission (verdict: Runtime Error):
x = int(input())
amax = int(x ** (1/ 5)) + 1
for a in range(amax + 1):
    b5 = a ** 5 - x
    if b5 < 0:
        c = (-b5) ** (1/5)
        if int(c) == c:
            ans = (a, -int(c))
            break
    else:
        c = (b5) ** (1/5)
        if int(c) == c:
            ans = (a, int(c))
            break

print(ans[0], ans[1])

Fixed submission:

def factorize(n):
    ## 素因数分解
    # arr = factorize(20)
    # arr == [[2, 2], [5, 1]]
    
    result = []
    tmp = n
    for k in range(2, int(n ** 0.5) + 1):
        cnt = 0
        while tmp % k == 0:
            cnt += 1
            tmp //= k
        if cnt > 0:
            result.append([k, cnt])
    if tmp != 1:
        result.append([tmp, 1])
    return result

def divisorize(n):
    ## 約数
    # arr = factorize(20)
    # arr == [2, 4, 5, 10, 20]
    f = factorize(n)
    divisors = [1]
    for k in range(len(f)):
        num_divisors = len(divisors)
        for i in range(1, f[k][1] + 1):
            for j in range(num_divisors):
                divisors.append(divisors[j] * f[k][0] ** i)
    return sorted(divisors)

x = int(input())
a = 0
d = divisorize(x)
flg = False
while True:
    for dd in d:
        b = a - dd
#         print(a, dd, b)
        try:
            if a ** 5 - b ** 5 == x:
                flg = True
                break
        except:
            pass
    if flg:
        break
    a += 1
print(a, b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

s = 0
for i in range(1, n):
    for k in range(0, n - i):
        if a[k] > i:
            continue
        else:
            if a[k] + a[k + i] == i:
                s += 1
print(s)

Fixed submission:
# %%time
n = int(input())
a = list(map(int, input().split()))

# n = 10000
# a = np.random.randint(1, 1000, n)

import numpy as np
from collections import Counter

a = np.array(a)
ap = a + np.arange(n)
am = a - np.arange(n)
am = -am

c = Counter(am)

s = 0
for k in range(n):
    s += c[ap[k]]
    c[am[k]] -= 1

print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

from collections import Counter
c = Counter(s)
c = list(c.values())
ans = c[0] * c[1] * c[2]
# print(ans)
for k in range(n):
    for a in range(1, n//2 + 1):
        if k + 2 * a >= n:
            continue
        if (s[k] != s[k+a]) and (s[k+a] != s[k + 2 * a]) and (s[k] != s[k + 2*a]):
            ans -= 1

print(ans)

Fixed submission:
# %%time
from collections import Counter, deque
n = int(input())
s = input()


# n = 4000
# np.random.seed(1)
# s = np.random.randint(0, 3, n)
# s = (s)

c = Counter(s)
c = list(c.values())
if len(c) == 3:
    ans = c[0] * c[1] * c[2]
else:
    ans = 0
# print(ans)
if ans > 0:
    for k in range(n):
        for a in range(1, (n - k)//2 + 1):
            if k + 2 * a >= n:
                continue
            x, y,  = s[k], s[k + a]
            
            if x != y:
                z = s[k + 2 * a]
                if y != z:
                    if z != x:
                        ans -= 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x, y, A, B, C = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a = sorted(a)[::-1]
b = sorted(b)[::-1]
c = sorted(c)

s = 0

a = a[:x]
b = b[:y]
s += sum(a)
s += sum(b)

a_nex = a.pop()
b_nex = b.pop()
c_nex = c.pop()

while True:
#     print(s)
    if a_nex > b_nex:
        if c_nex > b_nex:
            s = s - b_nex + c_nex
            if len(b) == 0:
                b_nex = int(2e9)
            else:
                b_nex = b.pop()
            if len(c) == 0:
                break
            c_nex = c.pop()

    if b_nex > a_nex:
        if c_nex > a_nex:
            s = s - a_nex + c_nex
            if len(a) == 0:
                a_nex = int(2e9)
            else:
                a_nex = a.pop()
            if len(c) == 0:
                break
            c_nex = c.pop()

    if c_nex <= a_nex and c_nex <= b_nex:
        break

print(s)

Fixed submission:
from collections import deque
x, y, A, B, C = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a = sorted(a)[::-1]
b = sorted(b)[::-1]
c = sorted(c)

s = 0

a = a[:x]
b = b[:y]
s += sum(a)
s += sum(b)

a = deque(a)
b = deque(b)
c = deque(c)

a_nex = a.pop()
b_nex = b.pop()
c_nex = c.pop()

while True:
#     print(s)
    if a_nex > b_nex:
        if c_nex > b_nex:
            s = s - b_nex + c_nex
            if len(b) == 0:
                b_nex = int(2e9)
            else:
                b_nex = b.pop()
            if len(c) == 0:
                break
            c_nex = c.pop()
    else:
        if c_nex > a_nex:
            s = s - a_nex + c_nex
            if len(a) == 0:
                a_nex = int(2e9)
            else:
                a_nex = a.pop()
            if len(c) == 0:
                break
            c_nex = c.pop()

    if c_nex <= a_nex and c_nex <= b_nex:
        break

print(s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

from collections import Counter

c = Counter(a)

from scipy.special import comb

s = set(c.values())

dic = {}
for ss in s:
    if ss not in dic.keys():
        dic[ss] = comb(ss, 2)
for ss in s:
    ss -= 1
    if ss not in dic.keys():
        dic[ss] = comb(ss, 2)

base = 0
for k in c.keys():
    base += dic[c[k]]

for k in range(len(a)):
    print(int(base - dic[c[a[k]]] + dic[c[a[k]] - 1]))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

from collections import Counter

c = Counter(a)

def comb(x):
    return x * (x - 1) // 2

base = 0
for aa in c.keys():
    x = c[aa]
    base += comb(x)

for aa in a:
    ans = base - comb(c[aa]) + comb(c[aa] - 1)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b, c = list(map(int, input().split()))
# xのn乗根を得る
def nroot(a, n, x=1.0, eps=1e-7):
    while abs(a - x**n) > eps:
#         print(abs(a - x**n))
        x = ( (n-1)*x + a/(x**(n-1)) ) / n
    return x
def sq(a):
    aa = np.sqrt(a)
    return nroot(a, 2, aa)
if (sq(a) + sq(b)) < sq(c):
    print("Yes")
else:
    print("No")

Fixed submission:
from decimal import *
getcontext().prec = 20      # デフォルト28桁のところを20桁にする
def sq(n):
    m = Decimal(n).sqrt()
    return m

import math
a, b, c = list(map(int, input().split()))
# def sq(a):
#     aa = math.sqrt(a)
#     return aa
if (sq(a) + sq(b)) < sq(c):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

mode = 0
for _ in range(q):
    query = input().split()
#     print(s, query, mode)
    if len(query) == 1:
        mode = 1 - mode
    else:
        if mode == 0:
            if query[1] == "1":
                s = query[2] + s
            else:
                s = s + query[2]
        else:
            if query[1] == "1":
                s = s + query[2]
            else:
                s = query[2] + s
if mode == 1:
    s = s[::-1]
print(s)

Fixed submission:
s = input()
q = int(input())

pres = []
posts = []
mode = 0
for _ in range(q):
    query = input().split()
#     print(s, query, mode, pres, posts)
    if len(query) == 1:
        mode = 1 - mode
    else:
        if mode == 0:
            if query[1] == "1":
                pres.append(query[2])
            else:
                posts.append(query[2])
        else:
            if query[1] == "1":
                posts.append(query[2])
            else:
                pres.append(query[2])
s = "".join(pres[::-1]) + s + "".join(posts)
if mode == 1:
    s = s[::-1]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for _ in range(q):
    query = input().split()
    if len(query) == 1:
        s = s[::-1]
    else:
        if query[1] == "1":
            s = query[2] + s
        else:
            s = s + query[2]
print(s)

Fixed submission:
s = input()
q = int(input())

pres = []
posts = []
mode = 0
for _ in range(q):
    query = input().split()
#     print(s, query, mode, pres, posts)
    if len(query) == 1:
        mode = 1 - mode
    else:
        if mode == 0:
            if query[1] == "1":
                pres.append(query[2])
            else:
                posts.append(query[2])
        else:
            if query[1] == "1":
                posts.append(query[2])
            else:
                pres.append(query[2])
s = "".join(pres[::-1]) + s + "".join(posts)
if mode == 1:
    s = s[::-1]
print(s)
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
f = {}
for _ in range(m):
    a, aa = map(int, input().split())
    try:
        f[a].append(aa)
    except:
        f[a] = [aa]
    try:
        f[aa].append(a)
    except:
        f[aa] = [a]
b = {}
for _ in range(k):
    a, aa = map(int, input().split())
    try:
        b[a].append(aa)
    except:
        b[a] = [aa]
    try:
        b[aa].append(a)
    except:
        b[aa] = [a]
    

g = []
done_g = []

for now in range(1, n+1):
    if now in done_g:
        continue
    done = []
    stack = [now]
    while len(stack) != 0:
        now = stack.pop()
        if now in done:
            continue
        done.append(now)
        stack += f[now]
    
    g.append(done)
    done_g += done

ans = {}
for gg in g:
    for x in gg:
        base = len(gg) - 1
        if x in f.keys():
            base -= len(set(gg).intersection(set(f[x])))
        if x in b.keys():
            base -= len(set(gg).intersection(set(b[x])))
        ans[x] = base

anss = []
for k in range(n):
    anss.append(str(ans[k+1]))
print(" ".join(anss))



Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parent = list(range(n+1))
        self.size = [1] * (n+1)
        
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, a, b):
        a = self.find(a)
        b = self.find(b)
        
        if self.parent[a] == self.parent[b]:
            return
        if self.size[a] >= self.size[b]:
            self.parent[b] = a
            self.size[a] += self.size[b]
        else:
            self.parent[a] = b
            self.size[b] += self.size[a]
        
    def count(self, x):        
        return self.size[self.find(x)]

n, m, k = map(int, input().split())

uf = UnionFind(n)
ans = [0] * (n + 1)

for _ in range(m):
    a, b = map(int, input().split())
    uf.union(a, b)
    ans[a] -= 1
    ans[b] -= 1
    
for _ in range(k):
    a, b = map(int, input().split())
    if uf.find(a) == uf.find(b):
        ans[a] -= 1
        ans[b] -= 1
        
for i in range(1, n+1):
    ans[i] += uf.count(i) - 1    
    
print(" ".join(map(str, ans[1:])))
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
ac_list = [0] * n
wa_list = [0] * n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        ac_list[p] = 1
    if s == "WA":
        if ac_list[p] == 0:
            wa_list[p] += 1
for k in range(m):
    if ac_list[k] == 0:
        wa_list[k] = 0
print(sum(ac_list), sum(wa_list))

Fixed submission:
n, m = list(map(int, input().split()))
ac_list = [0] * n
wa_list = [0] * n
for _ in range(m):
    p, s = input().split()
    p = int(p) - 1
    if s == "AC":
        ac_list[p] = 1
    if s == "WA":
        if ac_list[p] == 0:
            wa_list[p] += 1
for k in range(n):
    if ac_list[k] == 0:
        wa_list[k] = 0
print(sum(ac_list), sum(wa_list))