Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
if len(set(s)) == 1:
  print(0)
  exit()
i = 0
while True:
    wi = s.index("W")
    ri = "".join(s).rindex("R")
    if wi < ri:
        s[wi], s[ri] = s[ri], s[wi]
        i += 1
    else: break
print(i)


Fixed submission:
n = int(input())
s = input()
w = []
r = []
for i in range(len(s)):
    if s[i] == "W": w.append(i+1)
    if s[len(s)-i-1] == "R": r.append(len(s)-i)
cnt = 0
# print(w,r)
for i in range(min(len(w), len(r))):
    if w[i] >  r[i]:
        break
    else:
        cnt += 1
print(cnt)

"""
i = 0
while True:
    wi = s.index("W")
    ri = str(s).rindex("R")
    if wi < ri:
        s[wi], s[ri] = s[ri], s[wi]
        i += 1
    else: break
print(cnt)
"""
Buggy python submission (verdict: Runtime Error):
print(360 // input())

Fixed submission:
i = 1
x = int(input())
while True:
  if (360 * i) % x == 0:
    print(360 * i // x)
    break
  i += 1
Buggy python submission (verdict: Runtime Error):
from math import floor
a, b = [i for i in input().split()]
p = int(b[0] + b[2] + b[3])
print(a * p // 100)


Fixed submission:
from math import floor
a, b = [i for i in input().split()]
p = int(b[0] + b[2] + b[3])
print(int(a) * p // 100)

Buggy python submission (verdict: Runtime Error):
from math import floor
a, b = [float(i) for i in input().split()]
b = b * 100
p = int(str(b)[0])
q = int(str(b)[1])
r = int(str(b)[2])
print(floor(a * p + (a * q) / 10 + (a * r)/100))

Fixed submission:
from math import floor
a, b = [i for i in input().split()]
p = int(b[0] + b[2] + b[3])
print(int(a) * p // 100)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
t = n
pf = []
i = 2
if n == 1:
    print(0)
    exit()

while i <= n or i ** 2 <= t:
    j = 0
    while n % i == 0:
        n = n // i
        j += 1
    if j > 0:
        pf.append(j)
    i += 1
if len(pf) == 0: pf.append(1)

ans = 0
for i in pf:
    tmp = i
    j = 1
    while j <= tmp:
        tmp -= j
        ans += 1
        j += 1
print(ans)

Fixed submission:
from math import ceil
n = int(input())
pf = []
t = n
if n == 1:
    print(0)
    exit()
for i in range(2, ceil(n ** 0.5) + 1):
    c = 0
    while t % i == 0:
        c += 1
        t //= i
    if c > 0: pf.append(c)
if t != 1: pf.append(1)

ans = 0
for i in pf:
    tmp = i
    j = 1
    while j <= tmp:
        tmp -= j
        ans += 1
        j += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
pf = []
i = 2
while n > 1:
    j = 0
    while n % i == 0:
        n = n // i
        j += 1
    if j > 0:
        pf.append(j)
    i += 1

ans = 0
for i in pf:
    tmp = i
    j = 1
    while j <= tmp:
        tmp -= j
        ans += 1
        j += 1
print(ans)

Fixed submission:
from math import ceil
n = int(input())
pf = []
t = n
if n == 1:
    print(0)
    exit()
for i in range(2, ceil(n ** 0.5) + 1):
    c = 0
    while t % i == 0:
        c += 1
        t //= i
    if c > 0: pf.append(c)
if t != 1: pf.append(1)

ans = 0
for i in pf:
    tmp = i
    j = 1
    while j <= tmp:
        tmp -= j
        ans += 1
        j += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n, m = [int(i) for i in input().split()]
rutes = [[]] * n
visited = [0] + [-1] * (n-1)
q = deque([0])

for i in range(n):
    a, b = [int(i) for i in input().split()]
    rutes[a-1].append(b)
    rutes[b-1].append(a)

cnt = 0
def visit(x):
    for i in rutes[x-1]:
        if visited[i] == -1:
            q.append(i)
            visited[i-1] = visited[x-1] + 1

while len(q) > 0:
    tmp = q.pop()
    visit(tmp)

for i in range(2,n+1):
    print(visited[i-1])

Fixed submission:
from collections import deque
n, m = [int(i) for i in input().split()]
rooms = [[] for i in range(n)]
dist = [-1] * n
for i in range(m):
    a, b = [int(i) for i in input().split()]
    rooms[a-1].append(b)
    rooms[b-1].append(a)

que = deque()
que.append(1)
dist[0] = 0
ans = [0] * n
while(len(que) != 0):
    v = que.popleft()
    for i in rooms[v-1]:
        if dist[i-1] == -1:
            dist[i-1] = dist[v-1] + 1
            que.append(i)
            ans[i-1] = v
print("Yes")
for i in ans[1:]:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
l_i = [a[i] + i + 1 for i in range(len(a))]
l_j = [i - a[i] + 1 for i in range(len(a))]

ans = 0
for i in range(n):
    for j in range(i+1, n):
        if l_i[i] == l_j[j]:
            ans += 1
print(ans)

Fixed submission:
from collections import defaultdict
n = int(input())
a = [int(i) for i in input().split()]
l_i = [a[i] + i + 1 for i in range(len(a))]
r_j = [i - a[i] + 1 for i in range(len(a))]
dl = defaultdict(int)
dr = defaultdict(int)
for i in range(n):
    dl[l_i[i]] += 1
    dr[r_j[i]] += 1

ans = 0
for i in dl.keys():
    ans += dl[i] * dr[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
l_i = [a[i] + i + 1 for i in range(len(a))]
l_j = [i - a[i] + 1 for i in range(len(a))]

ans = 0
for i in range(n):
    for j in range(i+1, n):
        if l_i[i] == l_j[j]:
            ans += 1
print(ans)

Fixed submission:
from collections import defaultdict
n = int(input())
a = [int(i) for i in input().split()]
l_i = [a[i] + i + 1 for i in range(len(a))]
r_j = [i - a[i] + 1 for i in range(len(a))]
dl = defaultdict(int)
dr = defaultdict(int)
for i in range(n):
    dl[l_i[i]] += 1
    dr[r_j[i]] += 1

ans = 0
for i in dl.keys():
    ans += dl[i] * dr[i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
cnt = 0
for i in range(n):
    for j in range(2, n-i):
        if a[i] + a[i+j] == j:
            cnt += 1
print(cnt)

Fixed submission:
from collections import defaultdict
n = int(input())
a = [int(i) for i in input().split()]
l_i = [a[i] + i + 1 for i in range(len(a))]
r_j = [i - a[i] + 1 for i in range(len(a))]
dl = defaultdict(int)
dr = defaultdict(int)
for i in range(n):
    dl[l_i[i]] += 1
    dr[r_j[i]] += 1

ans = 0
for i in dl.keys():
    ans += dl[i] * dr[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
s_cu = ["0"] * (n+1)
counter = [0] * 2019

counter[0] += 1
for i in range(1, n+1):
    s_cu[i] = s[n-i] + (s_cu[i-1] if i != 1 else "")
    counter[int(s_cu[i]) % 2019] += 1

ans = 0
for i in counter:
    ans += (i * (i - 1)) // 2

print(ans)

Fixed submission:
s = input()
n = len(s)
s_cu = [0] * (n+1)
counter = [0] * 2019
counter[0] += 1
for i in range(n):
    s_cu[i+1] = (int(s[n-i-1]) * pow(10,i,2019) + s_cu[i]) % 2019
    counter[s_cu[i+1]] += 1

ans = 0
for i in counter:
    ans += (i * (i - 1)) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
counter = [0] * 2019

counter[0] += 1
for i in range(1, n+1):
    counter[int(s[n-i:]) % 2019] += 1

ans = 0
for i in counter:
    ans += (i * (i - 1)) // 2

print(ans)

Fixed submission:
s = input()
n = len(s)
s_cu = [0] * (n+1)
counter = [0] * 2019
counter[0] += 1
for i in range(n):
    s_cu[i+1] = (int(s[n-i-1]) * pow(10,i,2019) + s_cu[i]) % 2019
    counter[s_cu[i+1]] += 1

ans = 0
for i in counter:
    ans += (i * (i - 1)) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
s_cu = [0] * n
counter = [0] * 2019

counter[0] += 1
for i in range(1, n):
    s_cu[i] = int(s[n-i:])
    counter[int(s[n-i-1:]) % 2019] += 1

ans = 0
for i in counter:
    ans += (i * (i - 1)) // 2

print(ans)

Fixed submission:
s = input()
n = len(s)
s_cu = [0] * (n+1)
counter = [0] * 2019
counter[0] += 1
for i in range(n):
    s_cu[i+1] = (int(s[n-i-1]) * pow(10,i,2019) + s_cu[i]) % 2019
    counter[s_cu[i+1]] += 1

ans = 0
for i in counter:
    ans += (i * (i - 1)) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
s_cu = [0] * n
counter = [0] * 2019

counter[0] += 1
for i in range(1, n):
    s_cu[i] = int(s[n-i:])
    counter[int(s[n-i-1:]) % 2019] += 1

ans = 0
for i in counter:
    ans += (i * (i - 1)) // 2

print(ans)

Fixed submission:
s = input()
n = len(s)
s_cu = [0] * (n+1)
counter = [0] * 2019
counter[0] += 1
for i in range(n):
    s_cu[i+1] = (int(s[n-i-1]) * pow(10,i,2019) + s_cu[i]) % 2019
    counter[s_cu[i+1]] += 1

ans = 0
for i in counter:
    ans += (i * (i - 1)) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
c = 0
for i in range(4,len(s)+1):
    for j in range(len(s)-i+1):
        if int(s[j:j+i]) % 2019 == 0:
            c += 1
print(c)


Fixed submission:
s = input()
n = len(s)
s_cu = [0] * (n+1)
counter = [0] * 2019
counter[0] += 1
for i in range(n):
    s_cu[i+1] = (int(s[n-i-1]) * pow(10,i,2019) + s_cu[i]) % 2019
    counter[s_cu[i+1]] += 1

ans = 0
for i in counter:
    ans += (i * (i - 1)) // 2

print(ans)
Buggy python submission (verdict: Runtime Error):
k

Fixed submission:
from math import pi
r = int(input())
print(2 * pi * r)
Buggy python submission (verdict: Time Limit Exceeded):
import math

d = dict()
k = int(input())
sm = 0

def g(x, y, z):
    t = sorted([x,y,z])
    d.setdefault(str(t), 0)
    if d[str(t)] == 0:
        s = math.gcd(math.gcd(a, b), c)
        d[str(t)] = s
        return s
    else:
        return d[str(t)]

for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            sm += g(a,b,c)

print(sm)


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

Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
sum = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            sum += math.gcd(math.gcd(a, b), c)
print(sum)


Fixed submission:
import math
k = int(input())
sum = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            sum += math.gcd(math.gcd(a, b), c)
print(sum)
Buggy python submission (verdict: Runtime Error):
n, m = [for i in input().split()]
a = [int(i) for i in input().split()]

ok_count = 0
for i in a:
    if i > 1 / (4 * sum(a)): ok_count += 1

print("Yes" if m >= ok_count else "No")

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

ok_count = 0
for i in a:
    if i >= sum(a) / (4 * m): ok_count += 1

print("Yes" if m <= ok_count else "No")
Buggy python submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]

if n > k:
    tmp = k 
    while not (n - tmp) % k == 0:
        tmp -= 1
    n = tmp
    
while tmp >= n:
    tmp = n
    n = abs(n - k)
    if tmp < n:
        break
print(tmp)

Fixed submission:
n, k = [int(i) for i in input().split()]
print(min(n % k, k - n % k))

Buggy python submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]

if n > k:
    tmp = k 
    while not (n - tmp) % k == 0:
        tmp -= 1
    n = tmp
    
while tmp >= n:
    tmp = n
    n = abs(n - k)
    if tmp < n:
        break
print(tmp)

Fixed submission:
n, k = [int(i) for i in input().split()]
print(min(n % k, k - n % k))

Buggy python submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]

if n > k:
    tmp = k 
    while not (n - tmp) % k == 0:
        tmp -= 1
    n = tmp
    
while tmp >= n:
    tmp = n
    n = abs(n - k)
    if tmp < n:
        break
print(tmp)

Fixed submission:
n, k = [int(i) for i in input().split()]
print(min(n % k, k - n % k))

Buggy python submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]

if n > k:
    tmp = k 
    while not (n - tmp) % k == 0: tmp -= 1
    n = tmp
    
while tmp >= n:
    tmp = n
    n = abs(n - k)
    if tmp < n:
        break
print(tmp)

Fixed submission:
n, k = [int(i) for i in input().split()]
print(min(n % k, k - n % k))

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

def a(x):
    return abs(x - k)

if n > k:
    tmp = k 
    while not (n - tmp) % k == 0:
        tmp -= 1
    n = tmp

while True:
    tmp = n
    n = a(n)
    if tmp < n:
        print(tmp)
        break


Fixed submission:
n, k = [int(i) for i in input().split()]
print(min(n % k, k - n % k))

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

def a(x):
    return abs(x - k)

if n > k:
    tmp = k
    while not (n - tmp) % k == 0:
        tmp -= 1
    n = tmp

while True:
    tmp = n
    n = a(n)
    if tmp < n:
        print(tmp)
        break


Fixed submission:
n, k = [int(i) for i in input().split()]
print(min(n % k, k - n % k))

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

def a(x):
    return abs(x - k)

while True:
    tmp = n
    n = a(n)
    if tmp < n:
        print(tmp)
        break


Fixed submission:
n, k = [int(i) for i in input().split()]
print(min(n % k, k - n % k))
Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = [int(i) for i in input().split()]
x, y = [x - 1, y - 1]

def shortest_dist(a, b):
    return min(min(abs(a - b), abs(a - x) + 1 + abs(b - y)), abs(a - x) + 2 + abs(b - x))

distance = [0] * n
for i in range(n):
    for j in range(i+1, n):
        distance[shortest_dist(i, j)] += 1

for i in range(1,n):
    print(distance[i])


# abs(a - b)
# abs(a - x) + 1 + abs(b - y)
# abs(a - x) + 2 + abs(b - x) 
# ↑のうち最小

Fixed submission:
n, x, y = [int(i) for i in input().split()]
x, y = [x - 1, y - 1]

def shortest_dist(a, b):
    return min(min(abs(a - b), abs(a - x) + 1 + abs(b - y)), abs(a - x) + 2 + abs(b - x))

distance = [0] * n
for i in range(n):
    for j in range(i+1, n):
        distance[shortest_dist(i, j)] += 1

for i in range(1,n):
    print(distance[i])


# abs(a - b)
# abs(a - x) + 1 + abs(b - y)
# abs(a - x) + 2 + abs(b - x) 
# ↑のうち最小
Buggy python submission (verdict: Runtime Error):
print(int(input() + 1) // 2)

Fixed submission:
print((int(input()) + 1) // 2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s_list = [input() for i in range(n)]
s_set = set(s_list)
max = 0
max_elements = []
for i in s_set:
    c = s_list.count(i)
    if c > max:
        max = c
        max_elements = [i]
    if c == max and i not in max_elements:
        max_elements.append(i)

for i in sorted(max_elements):
    print(i)


Fixed submission:
a, b, c = input().split()
count = 0
if(a == b): count += 1
if(b == c): count += 1
if(c == a): count += 1

print("Yes" if(count == 1) else "No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s_list = [input() for i in range(n)]
s_set = set(s)
max = 0
max_elements = []
for i in s_set:
    c = s_list.count(i)
    if c > max:
        max = c
        max_elements = [i]
    if c == max and i not in max_elements:
        max_elements.append(i)

for i in sorted(max_elements):
    print(i)


Fixed submission:
a, b, c = input().split()
count = 0
if(a == b): count += 1
if(b == c): count += 1
if(c == a): count += 1

print("Yes" if(count == 1) else "No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split() if i % 2 == 0]
for i in a:
    if i % 3 != 0 and i % 5 != 0:
            print("DENIED")
            exit()
print("APPROVED")

Fixed submission:
a, b, c = input().split()
count = 0
if(a == b): count += 1
if(b == c): count += 1
if(c == a): count += 1

print("Yes" if(count == 1) else "No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split() if i % 2 == 0]
for i in a:
    if a % 3 != 0 and a % 5 != 0:
            print("DENIED")
            exit()
print("APPROVED")

Fixed submission:
n = int(input())
a = [int(i) for i in input().split() if int(i) % 2 == 0]
for i in a:
    if i % 3 != 0 and i % 5 != 0:
            print("DENIED")
            exit()
print("APPROVED")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = [input() for i in range(n)]
s_set = set(s_list)
max = 0
max_elements = []
for i in s_set:
    c = s_list.count(i)
    if c > max:
        max = c
        max_elements = [i]
    if c == max and i not in max_elements:
        max_elements.append(i)

for i in sorted(max_elements):
    print(i)


Fixed submission:
n = int(input())
a = dict()

for i in range(n):
    s = input()
    a.setdefault(s, 0)
    a[s] += 1

ans = []
mx = 0
for key, value in a.items():
    if mx < value:
        mx = value
        ans = [key]
    elif mx == value: ans.append(key)

ans.sort()
for i in ans: print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = [input() for i in range(n)]
s_set = set(s_list)
max = 0
max_elements = []
for i in s_set:
    c = s_list.count(i)
    if c > max:
        max = c
        max_elements = [i]
    if c == max and i not in max_elements:
        max_elements.append(i)

for i in sorted(max_elements):
    print(i)


Fixed submission:
n = int(input())
a = dict()

for i in range(n):
    s = input()
    a.setdefault(s, 0)
    a[s] += 1

ans = []
mx = 0
for key, value in a.items():
    if mx < value:
        mx = value
        ans = [key]
    elif mx == value: ans.append(key)

ans.sort()
for i in ans: print(i)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for i in range(n)]
s_set = set(s)
max = 0
max_elements = []
for i in s_set:
    c = s.count(i)
    if c > max:
        max = c
        max_elements = [i]
    if c == max and i not in max_elements:
        max_elements.append(i)

for i in sorted(max_elements):
    print(i)


Fixed submission:
n = int(input())
a = dict()

for i in range(n):
    s = input()
    a.setdefault(s, 0)
    a[s] += 1

ans = []
mx = 0
for key, value in a.items():
    if mx < value:
        mx = value
        ans = [key]
    elif mx == value: ans.append(key)

ans.sort()
for i in ans: print(i)
Buggy python submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
q = [0] * (n + 1)
for i in range(n):
    q[i+1] = q[i] + p[i]
mx = 0
mx_num = 0
for i in range(n-2):
    if mx < q[i+3] - q[i]:
        mx_num = i

ans = 0
for i in range(3):
    t = p[mx_num + i]
    ans += (t + 1) / 2

print(ans)
    


Fixed submission:
from itertools import accumulate

n, k = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
c = [0] + list(accumulate(p))
mx = 0
mx_n = 0
for i in range(len(c)-k):
    if mx < c[i+k] - c[i]:
        mx = c[i+k] - c[i]
        mx_n = i
ans = 0
for i in range(k):
    ans += (p[mx_n + i] + 1) / 2

print(ans)
Buggy python submission (verdict: Runtime Error):
def a(x):
    if x == 1: return 1
    if x > 1: return a((a(x // 2)) * 2 + 1

print(a(int(input())))


Fixed submission:
def a(x):
    if x == 1: return 1
    if x > 1: return a(x // 2) * 2 + 1

print(a(int(input())))

Buggy python submission (verdict: Runtime Error):
def a(x):
    if x == 1: return 1
    if x > 1: return a((x + 1) // 2)) * 2 + 1

print(a(int(input())))


Fixed submission:
def a(x):
    if x == 1: return 1
    if x > 1: return a(x // 2) * 2 + 1

print(a(int(input())))

Buggy python submission (verdict: Runtime Error):
def a(x):
    if x == 1: return 1
    if x > 1: return a(x/2) * 2 + 1

print(a(int(input())))


Fixed submission:
def a(x):
    if x == 1: return 1
    if x > 1: return a(x // 2) * 2 + 1

print(a(int(input())))

Buggy python submission (verdict: Runtime Error):
print(a([int(input())]))

def a(x):
    if x == 1: return 1
    if x > 1: return a(x/2) * 2 + 1

Fixed submission:
def a(x):
    if x == 1: return 1
    if x > 1: return a(x // 2) * 2 + 1

print(a(int(input())))

Buggy python submission (verdict: Time Limit Exceeded):
h = [int(input())]
counter = 0
while True:
    if(h == []):
        print(counter)
        break
    t = h[0]
    h = ([t / 2, t / 2] if t / 2 >= 1 else []) + h[1:]
    counter += 1


Fixed submission:
def a(x):
    if x == 1: return 1
    if x > 1: return a(x // 2) * 2 + 1

print(a(int(input())))
Buggy python submission (verdict: Runtime Error):
a, b = [i for i in input().split()]
print(max(int(a * int(b)), int(b * int(a)))

Fixed submission:
a, b = [i for i in input().split()]
print(max(int(a * int(b)), int(b * int(a))))
Buggy python submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
ac = [0] * n
wa = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p)
    if ac[p-1] == 0:
        if s == "AC":
            ac[p-1] = 1
        elif s == "WA":
            wa[p-1] += 1

wa_sum = 0
for i in range(n):
    if ac[i] >= 1: wa_sum += wa[i]

print(sum(ac), sum_wa)

Fixed submission:
n, m = [int(i) for i in input().split()]
ac = [0] * n
wa = [0] * n

for i in range(m):
    p, s = input().split()
    p = int(p)
    if ac[p-1] == 0:
        if s == "AC":
            ac[p-1] = 1
        elif s == "WA":
            wa[p-1] += 1

wa_sum = 0
for i in range(n):
    if ac[i] >= 1: wa_sum += wa[i]

print(sum(ac), wa_sum)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = [int(i) for i in input().split()]
for i in range(k):
    if a >= 1: a -= 1
    elif b >= 1: b -= 1
print(a, b)

Fixed submission:
a, b, k = [int(i) for i in input().split()]
if a >= k:
    a = a - k
elif b >= k - a:
    b = b - k + a
    a = 0
else:
    a = 0
    b = 0
print(a,b)
Buggy python submission (verdict: Time Limit Exceeded):
def isPrime(x):
    if x <= 1: return False
    i = 2
    while i ** 2 <= x:
        if x % i == 0: return False
        i += 1

a = int(input())
while True:
    a += 1
    if isPrime(a):
        print(a)
        break

Fixed submission:
def isPrime(x):
    if x <= 1: return False
    i = 2
    while i ** 2 <= x:
        if x % i == 0: return False
        i += 1
    return True

a = int(input())
while True:
    if isPrime(a):
        print(a)
        break
    a += 1

Buggy python submission (verdict: Time Limit Exceeded):
def isPrime(x):
    if x <= 1: return False
    i = 2
    while i ** 2 <= x:
        if x % i == 0: return False
        i += 1

a = int(input())
while True:
    a += 1
    if isPrime(a): print(a)

Fixed submission:
def isPrime(x):
    if x <= 1: return False
    i = 2
    while i ** 2 <= x:
        if x % i == 0: return False
        i += 1
    return True

a = int(input())
while True:
    if isPrime(a):
        print(a)
        break
    a += 1
Buggy python submission (verdict: Runtime Error):
n = int(input())
s, t = [int(input()) for i in range(2)]
out = ""
for i in range(n):
    out += s[i] + t[i]
print(out)


Fixed submission:
n = int(input())
s, t = input().split()
out = ""
for i in range(n):
    out += s[i] + t[i]
print(out)
Buggy python submission (verdict: Runtime Error):
week = ['SUN','MON','TUE','WED','THU','FRI','SAT']
print(7 - index(input()))

Fixed submission:
week = ['SUN','MON','TUE','WED','THU','FRI','SAT']
print(7 - week.index(input()))