Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    cnt = 0
    tmp = ""

    while tmp != s:
        tmp = s
        cnt += s.count("BW")
        s = s.replace("BW", "WB")

    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    s = input()
    length = len(s)-1
    count = s.count('B')
    init = sum([i for i in range(len(s)) if s[i] == "B"])
    processed = sum(range(length-count+1, length+1))

    print(processed-init)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    cnt = 0
    tmp = ""

    while tmp != s:
        tmp = s
        cnt += s.count("BW")
        s = s.replace("BW", "WB")
        if tmp == s:
            break

    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    s = input()
    length = len(s)-1
    count = s.count('B')
    init = sum([i for i in range(len(s)) if s[i] == "B"])
    processed = sum(range(length-count+1, length+1))

    print(processed-init)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    s = input()
    cnt = 0
    tmp = ""

    while tmp != s:
        tmp = s
        s = s.replace("BW", "WB", 1)
        if tmp == s:
            break
        cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    s = input()
    length = len(s)-1
    count = s.count('B')
    init = sum([i for i in range(len(s)) if s[i] == "B"])
    processed = sum(range(length-count+1, length+1))

    print(processed-init)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    s = input()
    ans = float('inf')
    for i in range(n):
        tmp = s[:i].count('W') + s[i:].count('E')
        if ans > tmp:
            ans = tmp

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    s = input()
    cnt = s.count('E')
    m = cnt
    for i in s:
        if i == 'E':
            cnt -= 1
        else:
            cnt += 1
        m = min(m, cnt)
    print(m)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import statistics
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
X = list(map(int, input().split()))
mid = N // 2 - 1

for i in range(N):
    print(statistics.median(X[:i]+X[i+1:]))


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
X = list(map(int, input().split()))
X_sorted = sorted(X)
L = X_sorted[N//2-1]
R = X_sorted[N//2]


for x in X:
    print(L if x >= R else R)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
X = list(map(int, input().split()))
mid = N // 2 - 1

for i in range(N):
    arr = X[:i]+X[i+1:]
    arr.sort()
    print(arr[mid])


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
X = list(map(int, input().split()))
X_sorted = sorted(X)
L = X_sorted[N//2-1]
R = X_sorted[N//2]


for x in X:
    print(L if x >= R else R)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

money = []
for i in range(len(a)):
    arr = [0]+a[:i]+a[i+1:]+[0]
    tmp = []
    for j in range(len(arr)-1):
        tmp.append(abs(arr[j]-arr[j+1]))
    money.append(sum(tmp))


print(*money, sep='\n')


Fixed submission:
n = int(input())
a = [0] + list(map(int, input().split())) + [0]


total = sum(abs(a[i+1]-a[i]) for i in range(n+1))
for i in range(1, n+1):
    print(total + abs(a[i-1]-a[i+1]) - abs(a[i-1]-a[i]) - abs(a[i]-a[i+1]))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def eratosthenes(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [i for i in range(1, n+1) if is_prime[i-1]]
    return table


def main():
    q = int(input())
    lr = [list(map(int, input().split())) for _ in range(q)]
    e = set(eratosthenes(10**5))

    for l, r in lr:
        cnt = 0
        for i in range(l, r+1, 2):
            if i in e and (i+1) // 2 in e:
                cnt += 1
        print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from itertools import accumulate
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


MAX = 10**5


def eratosthenes(n):
    is_prime = [1] * n
    is_prime[0] = 0

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = 0
                j += i
    return is_prime


def main():
    q = int(input())
    is_prime = eratosthenes(MAX)

    a = [0] * (MAX+1)
    for i in range(MAX+1):
        if is_prime[i-1] and is_prime[(i+1)//2-1]:
            a[i] = 1

    s = [0] + a
    s = list(accumulate(s))

    for _ in range(q):
        l, r = map(int, input().split())
        print(s[r+1] - s[l])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def eratosthenes(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [i for i in range(1, n+1) if is_prime[i-1]]
    return table


def main():
    q = int(input())
    lr = [list(map(int, input().split())) for _ in range(q)]
    e = eratosthenes(10**5)

    for l, r in lr:
        cnt = 0
        for i in range(l, r+1, 2):
            if i in e and (i+1) // 2 in e:
                cnt += 1
        print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from itertools import accumulate
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


MAX = 10**5


def eratosthenes(n):
    is_prime = [1] * n
    is_prime[0] = 0

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = 0
                j += i
    return is_prime


def main():
    q = int(input())
    is_prime = eratosthenes(MAX)

    a = [0] * (MAX+1)
    for i in range(MAX+1):
        if is_prime[i-1] and is_prime[(i+1)//2-1]:
            a[i] = 1

    s = [0] + a
    s = list(accumulate(s))

    for _ in range(q):
        l, r = map(int, input().split())
        print(s[r+1] - s[l])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from bisect import bisect_left, bisect, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    a = sorted(list(map(int, input().split())))
    b = sorted(list(map(int, input().split())))
    c = sorted(list(map(int, input().split())))

    cnt = 0
    for x in a:
        i = bisect(b, x)
        for y in b[i:]:
            j = bisect(c, y)
            cnt += len(c[j:])

    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    a = sorted(list(map(int, input().split())))
    b = sorted(list(map(int, input().split())))
    c = sorted(list(map(int, input().split())))

    cnt = 0
    for x in b:
        cnt += bisect_left(a, x)*(n-bisect_right(c, x))
    print(cnt)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
s=set()
for i in range(N):s^={input()}
print(len(s))

Fixed submission:
import collections

n = int(input())
a = [int(input()) for _ in range(n)]
b = collections.Counter(a)

cnt = 0
for v in b.values():
    if v % 2 == 1:
        cnt += 1

print(cnt)

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

for i in range(n):
    s ^= {input()}

print(len(s))


Fixed submission:
import collections

n = int(input())
a = [int(input()) for _ in range(n)]
b = collections.Counter(a)

cnt = 0
for v in b.values():
    if v % 2 == 1:
        cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]

b = [x for x in set(a) if a.count(x) % 2 != 0]
print(len(b))

Fixed submission:
import collections

n = int(input())
a = [int(input()) for _ in range(n)]
b = collections.Counter(a)

cnt = 0
for v in b.values():
    if v % 2 == 1:
        cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]

cnt = 0
for x in a:
    if a.count(x) % 2 != 0:
        cnt += 1

print(cnt)


Fixed submission:
import collections

n = int(input())
a = [int(input()) for _ in range(n)]
b = collections.Counter(a)

cnt = 0
for v in b.values():
    if v % 2 == 1:
        cnt += 1

print(cnt)

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

arr = []
for i in range(n):
    x = int(input())
    if x in arr:
        arr.remove(x)
    else:
        arr.append(x)


print(len(arr))


Fixed submission:
import collections

n = int(input())
a = [int(input()) for _ in range(n)]
b = collections.Counter(a)

cnt = 0
for v in b.values():
    if v % 2 == 1:
        cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]

arr = []
for x in a:
    if x in arr:
        arr.remove(x)
    else:
        arr.append(x)

print(len(arr))


Fixed submission:
import collections

n = int(input())
a = [int(input()) for _ in range(n)]
b = collections.Counter(a)

cnt = 0
for v in b.values():
    if v % 2 == 1:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = list(set([-x for x in A if A.count(x) >= 2]))

    if len(A) < 2:
        print(0)
        exit()

    heapq.heapify(A)

    print((-heapq.heappop(A)) * (-heapq.heappop(A)))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import heapq
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N = int(input())
    s = set()
    q = [0, 0]
    for a in map(int, input().split()):
        if a > q[0]:
            try:
                s.remove(a)
                heapq.heapreplace(q, a)
            except:
                s.add(a)
    print(q[0]*q[1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]


arr = []
for x in ab:
    if n in x:
        if x.index(n) == 0:
            arr.append(x[1])
        else:
            arr.append(x[0])

for a, b in ab:
    if a in arr:
        if b == 1:
            print('POSSIBLE')
            exit()
    if b in arr:
        if a == 1:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')


Fixed submission:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]


s = set()
for x in ab:
    if n in x:
        if x.index(n) == 0:
            s.add(x[1])
        else:
            s.add(x[0])

for a, b in ab:
    if a in s:
        if b == 1:
            print('POSSIBLE')
            exit()
    if b in s:
        if a == 1:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = [float('inf')] * n
    for i in range(1, n):
        ans[i] = abs(sum(a[:i])-sum(a[i:]))

    print(min(ans))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    s = sum(a)
    t = [0] * n
    for i in range(n-1):
        t[i+1] = t[i] + a[i]
    print(min(abs(s-2*t[i]) for i in range(1, n)))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = [float('inf')] * n
    for i in range(1, n):
        ans[i] = abs(sum(a[:i])-sum(a[i:]))

    print(min(ans))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    s = sum(a)
    t = [0] * n
    for i in range(n-1):
        t[i+1] = t[i] + a[i]
    print(min(abs(s-2*t[i]) for i in range(1, n)))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))

    s = set()
    for x in t:
        s |= set(range(x, x+T))
    print(len(s))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, T = map(int, input().split())
    t = list(map(int, input().split()))

    arr = [[]] * len(t)
    for i in range(len(t)):
        arr[i] = [t[i], t[i]+T]

    ans = arr[0][1]
    for i in range(len(t)-1):
        _, t1 = arr[i]
        f2, t2 = arr[i+1]

        if t1 <= f2:
            ans += t2 - f2
        else:
            ans += t2 - t1
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]


def check(a, t):
    ans = 0
    x = 0
    for i in a:
        x += i
        if t == True and x < 1:
            ans += 1 - x
            x = 1
        elif t == False and x > -1:
            ans += x + 1
            x = -1
        t = not t
    return ans


print(min(chk(a, True), chk(a, False)))


Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]


def check(a, t):
    ans = 0
    x = 0
    for i in a:
        x += i
        if t == True and x < 1:
            ans += 1 - x
            x = 1
        elif t == False and x > -1:
            ans += x + 1
            x = -1
        t = not t
    return ans


print(min(check(a, True), check(a, False)))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]


def check(a, t):
    ans = 0
    x = 0
    for i in a:
        x += i
        if t == True and x < 1:
            ans += 1 - x
            x = 1
        elif t == False and x > -1:
            ans += x + 1
            x = -1
        t = not t
    return ans


print(min(chk(a, True), chk(a, False)))


Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]


def check(a, t):
    ans = 0
    x = 0
    for i in a:
        x += i
        if t == True and x < 1:
            ans += 1 - x
            x = 1
        elif t == False and x > -1:
            ans += x + 1
            x = -1
        t = not t
    return ans


print(min(check(a, True), check(a, False)))
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

cnt = 0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                cnt += 1

print(cnt)


Fixed submission:
K, S = map(int, input().split())

cnt = 0
for x in range(K+1):
    for y in range(K+1):
        if (S-x-y) in range(K+1):
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
t = list(map(int, input().split()))
m = int(input())

for _ in range(m):
    new_t = t.copy()
    p, x = map(int, input().split())
    new_t[p-1] = x
    print(sum(new_t))


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

for _ in range(m):
    new_t = t.copy()
    p, x = map(int, input().split())
    new_t[p-1] = x
    print(sum(new_t))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    w, h, n = map(int, input().split())
    px = py = 0
    points = [[px, py], [w, h]]
    for _ in range(n):
        x, y, a = map(int, input().split())
        if a == 1:
            points[0][0] = max(px, x)
        elif a == 2:
            points[1][0] = min(w, x)
        elif a == 3:
            points[0][1] = max(py, y)
        elif a == 4:
            points[1][1] = min(h, y)

    print(max(0, points[1][0]-points[0][0])) * max(0, points[1][1]-points[0][1])


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    w, h, n = map(int, input().split())
    px = py = 0
    for _ in range(n):
        x, y, a = map(int, input().split())
        if a == 1:
            px = max(px, x)
        elif a == 2:
            w = min(w, x)
        elif a == 3:
            py = max(py, y)
        elif a == 4:
            h = min(h, y)

    print(max(0, w-px) * max(0, h-py))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
r=int(input()

print(2*r*3.141592)

Fixed submission:
r=int(input())

print(2*r*3.141592)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
s=0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      s += math.gcd(i,math.gcd(j,k))
print(s)


Fixed submission:
import math
  
def main():
  k=int(input())
  cur=0
  for a in range(1,k+1):
    for b in range(1,k+1):
      for c in range(1,k+1):
        cur+=math.gcd(math.gcd(a,b),c)
        
  return cur
print(main())

Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
s=0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      s += math.gcd(i,math.gcd(j,k))
print(s)

Fixed submission:
import math
  
def main():
  k=int(input())
  cur=0
  for a in range(1,k+1):
    for b in range(1,k+1):
      for c in range(1,k+1):
        cur+=math.gcd(math.gcd(a,b),c)
        
  return cur
print(main())
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
print(min(n%k,k-n%k)

Fixed submission:
n,k = map(int,input().split())
print(min(n%k,k-n%k))
Buggy python submission (verdict: Runtime Error):
s = list(input())

if s[3] == s[4] and s[5] == s[6]:
  print("Yes")
else:
  print("No")

Fixed submission:
s = list(input())

if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")

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

if s[3] == s[4] and s[5] == s[6]:
  print("Yes")
else:
  print("No")

Fixed submission:
s = list(input())

if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import math

a,b = map(int,input().split())

if math.floor(a*12.5) == math.floor(b*10):
  print(math.floor(b*10)
else:
  print("-1")

Fixed submission:
a,b=map(int,input().split())
c=[]

for i in range(1240):
  if int(i*0.08) == a and int(i*0.1) == b:
    c.append(i)
c.append(-1)

print(c[0])
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
ans=-1
arr = [list(map(int,input().split)) for i in range(b)]

for i in range(1001):
  j=str(i)
  if len(j)==a and all(j[s-1]==str(t) for s,t in arr):
    ans = i
    break
print(ans)

Fixed submission:
a,b=map(int,input().split())
ans=-1
arr = [list(map(int,input().split())) for i in range(b)]

for i in range(1001):
  j=str(i)
  if len(j)==a and all(j[s-1]==str(t) for s,t in arr):
    ans = i
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
ans="Yes"

if a=b=c or (a != b and b != c):
  ans = "No"
  
print(ans)

Fixed submission:
a,b,c = map(int,input().split())
ans="Yes"

if a==b and b==c or (a != b and b != c and c != a):
  ans = "No"
  
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=list(input() for _ in range(n)
dic={}

for i in range(n):
 if arr[i] not in dic:
  dic[arr[i]]=1
 else:
  dic[arr[i]]+=1
     
largest=max(dic.values())
ans=[]
for keys in dic.keys():
 if dic[keys]==largest:
  ans.append(keys)
ans=sorted(ans)

for words in ans:
 print(words)

Fixed submission:
n=int(input())
arr=list(input() for _ in range(n))
dic={}

for i in range(n):
  if arr[i] not in dic:
    dic[arr[i]]=1
  else:
    dic[arr[i]]+=1
     
largest=max(dic.values())
ans=[]
for keys in dic.keys():
  if dic[keys]==largest:
    ans.append(keys)
ans=sorted(ans)

for words in ans:
  print(words)
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split())

min=10000000000
ans=0
       
for i in p:
  if i <= min:
    ans+=1
    min=i
print(ans)


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

min=10000000000
ans=0
       
for i in p:
  if i <= min:
    ans+=1
    min=i
print(ans)

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

min=10000000000
ans=0
       
for i in p:
  if i <= min:
    ans+=1
    min=i
print(ans)

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

min=10000000000
ans=0
       
for i in p:
  if i <= min:
    ans+=1
    min=i
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n
rig=[0]*n

for i in range(m):
  if ps[i][1] == "AC":
    rig[int(ps[i][0])-1]=1
  else:
    if rig[int(ps[i][0]-1)] == 0:
      pen[int(ps[i][0]-1)]+=1

cnt1,cnt2=0,0
for i in range(n):
  if rig[i]==1:
    cnt1+=rig[i]
    cnt2+=pen[i]
    
print(str(cnt1)+" "+str(cnt2))


Fixed submission:
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n
rig=[0]*n

for i in range(m):
  if ps[i][1] == "AC":
    rig[int(ps[i][0])-1]=1
  else:
    if rig[int(ps[i][0])-1] == 0:
      pen[int(ps[i][0])-1]+=1

cnt1,cnt2=0,0
for i in range(n):
  if rig[i]==1:
    cnt1+=rig[i]
    cnt2+=pen[i]
    
print(str(cnt1)+" "+str(cnt2))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]
rig=[0]

for i in range(m):
  if ps[i][1] == "AC":
    rig[int(ps[i][0])-1]=1
  else:
    if rig[int(ps[i][0]-1)] == 0:
      pen[int(ps[i][0]-1)]+=1

cnt1,cnt2=0,0
for i in range(n):
  if rig[i]==1:
    cnt1+=rig[i]
    cnt2+=pen[i]
    
print(str(cnt1)+" "+str(cnt2))

Fixed submission:
n,m=map(int,input().split())
ps=[list(input().split()) for i in range(m)]
pen=[0]*n
rig=[0]*n

for i in range(m):
  if ps[i][1] == "AC":
    rig[int(ps[i][0])-1]=1
  else:
    if rig[int(ps[i][0])-1] == 0:
      pen[int(ps[i][0])-1]+=1

cnt1,cnt2=0,0
for i in range(n):
  if rig[i]==1:
    cnt1+=rig[i]
    cnt2+=pen[i]
    
print(str(cnt1)+" "+str(cnt2))