Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split())
d_list = [0] * (n-1)
for i in range(1, int(n)):
    for j in range(i+1, int(n)+1):
        d = min(abs(i-j), abs(i-x)+abs(j-y)+1, abs(i-y)+abs(j-x)+1)
        d_list[d-1] += 1
print("\n".join(str(d) for d in d_list))

Fixed submission:
import collections

def distances(n,x,y):
    for i in range(1, int(n)):
        for j in range(i+1, int(n)+1):
            yield min(abs(i-j), abs(i-x)+abs(j-y)+1, abs(i-y)+abs(j-x)+1)

n, x, y = map(int, input().split())

c = collections.Counter(distances(n,x,y))

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

Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = input().split()
ans_list = []
for i in range(1, int(n)):
    for j in range(i+1, int(n)+1):
        ans_list.append(min(abs(i-j), abs(i-int(x))+1+abs(j-int(y)), abs(i-int(y))+1+abs(j-int(x))))
for i in range(1, int(n)):
    print(ans_list.count(i))

Fixed submission:
import collections

def distances(n,x,y):
    for i in range(1, int(n)):
        for j in range(i+1, int(n)+1):
            yield min(abs(i-j), abs(i-x)+abs(j-y)+1, abs(i-y)+abs(j-x)+1)

n, x, y = map(int, input().split())

c = collections.Counter(distances(n,x,y))

for i in range(1,n):
    print(c[i])
Buggy python submission (verdict: Runtime Error):
import math
def combinations(n ,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
n, m = map(int, input().split())
print(combinations(n, 2) + combinations(m , 2))

Fixed submission:
n, m = map(int, input().split())
print(n*(n-1)//2 + m*(m-1)//2)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

n, m = map(int, input().split())
print(comb(n, 2, exact=True) + comb(m , 2, exact=True))

Fixed submission:
n, m = map(int, input().split())
print(n*(n-1)//2 + m*(m-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
a_list = list(map(int, input().split()))
c = collections.Counter(a_list)
for k in range(n):
    c[a_list[k]] -= 1
    ans = 0
    for i in c.values():
        ans += i*(i-1)//2
    print(ans)
    c[a_list[k]] += 1

Fixed submission:
import collections

n = int(input())
a_list = list(map(int, input().split()))
c = collections.Counter(a_list)
ans = 0
for i in c.values():
    ans += i*(i-1)//2
for i in range(n):
    print(ans - (c[a_list[i]]-1))

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

n = int(input())
a_list = list(map(int, input().split()))
for k in range(n):
    a_list_k = a_list.copy()
    del a_list_k[k]
    c = collections.Counter(a_list_k)
    ans = 0
    for i in c.values():
        ans += i*(i-1)//2
    print(ans)

Fixed submission:
import collections

n = int(input())
a_list = list(map(int, input().split()))
c = collections.Counter(a_list)
ans = 0
for i in c.values():
    ans += i*(i-1)//2
for i in range(n):
    print(ans - (c[a_list[i]]-1))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
for i in range(1, 10**5):
    if (i*8) // 100 == a and i // 10 == b:
        print(n)
        exit()
print(-1)

Fixed submission:
a, b = map(int, input().split())
for i in range(1, 10**5):
    if (i*8) // 100 == a and i // 10 == b:
        print(i)
        exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
query_list = [list(input().split()) for _ in range(q)]
for query in query_list:
    if query[0] == '1':
        #s = ''.join(list(reversed(s)))
        s = s[::-1]
    elif query[0] == '2':
        if query[1] == '1':
            s = query[2] + s
        elif query[1] == '2':
            s = s + query[2]
print(s)

Fixed submission:
s = input()
q = int(input())
query_list = [list(input().split()) for _ in range(q)]
reverse_flag = False
concat = ''
initial = 0
for query in query_list:
    if query[0] == '1':
        reverse_flag = not reverse_flag
    elif query[0] == '2':
        if (query[1] == '1' and not reverse_flag) or (query[1] == '2' and reverse_flag):
            concat = query[2] + concat
            initial += 1
        elif (query[1] == '2' and not reverse_flag) or (query[1] == '1' and reverse_flag):
            concat = concat + query[2]
ans = ''
if reverse_flag:
    s = s[::-1]
    concat = concat[::-1]
    ans = concat[:-initial]+s+concat[-initial:]
else:
    ans = concat[:initial]+s+concat[initial:]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
query_list = [list(input().split()) for _ in range(q)]
for query in query_list:
    if query[0] == '1':
        s = ''.join(list(reversed(s)))
    elif query[0] == '2':
        if query[1] == '1':
            s = query[2]+s
        elif query[1] == '2':
            s = s + query[2]
print(s)

Fixed submission:
s = input()
q = int(input())
query_list = [list(input().split()) for _ in range(q)]
reverse_flag = False
concat = ''
initial = 0
for query in query_list:
    if query[0] == '1':
        reverse_flag = not reverse_flag
    elif query[0] == '2':
        if (query[1] == '1' and not reverse_flag) or (query[1] == '2' and reverse_flag):
            concat = query[2] + concat
            initial += 1
        elif (query[1] == '2' and not reverse_flag) or (query[1] == '1' and reverse_flag):
            concat = concat + query[2]
ans = ''
if reverse_flag:
    s = s[::-1]
    concat = concat[::-1]
    ans = concat[:-initial]+s+concat[-initial:]
else:
    ans = concat[:initial]+s+concat[initial:]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
N, A, B = map(int, input().split())
MOD = 10 ** 9 + 7

def calc(n):
    ret = 1
    for i in range(n):
        ret *= (N - i) % MOD
    return ret * pow(factorial(n), MOD - 2, MOD) % MOD

print(max(0, (pow(2, N, MOD) - ((calc(A) + calc(B)) % MOD) - 1) % MOD))

Fixed submission:
mod = 10 ** 9 + 7

def calc(n,r):
    x = 1
    y = 1
    for i in range(r):
        x *= n - i
        x %= mod
        y *= i + 1
        y %= mod
    return x * pow(y, mod - 2, mod) % mod

n, a, b = map(int, input().split())
res = pow(2, n, mod) - 1
 
for i in [a, b]:
    res -= calc(n, i)
print(res % mod)

Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9+7

def calculate_combination(n,k):
    x, y = 1, 1
    for i in range(k):
        x *= (n - i) % mod
        y *= (k - i) % mod
    return x * pow(y, mod-2, mod) % mod

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

ans = pow(2, n, mod) - 1 - calculate_combination(n,a) - calculate_combination(n,b)
while ans < 0:
    ans += mod
print(ans)

Fixed submission:
mod = 10 ** 9 + 7

def calc(n,r):
    x = 1
    y = 1
    for i in range(r):
        x *= n - i
        x %= mod
        y *= i + 1
        y %= mod
    return x * pow(y, mod - 2, mod) % mod

n, a, b = map(int, input().split())
res = pow(2, n, mod) - 1
 
for i in [a, b]:
    res -= calc(n, i)
print(res % mod)

Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9+7

def calculate_combination(n,k):
    x, y = 1, 1
    for i in range(k):
        x *= (n - i) % mod
        y *= (k - i) % mod
    return x * pow(y, mod-2, mod) % mod

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

ans = pow(2, n, mod) - 1 - calculate_combination(n,a) - calculate_combination(n,b)
while ans < 0:
    ans += mod
print(ans)

Fixed submission:
mod = 10 ** 9 + 7

def calc(n,r):
    x = 1
    y = 1
    for i in range(r):
        x *= n - i
        x %= mod
        y *= i + 1
        y %= mod
    return x * pow(y, mod - 2, mod) % mod

n, a, b = map(int, input().split())
res = pow(2, n, mod) - 1
 
for i in [a, b]:
    res -= calc(n, i)
print(res % mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_dic = {}
for i in range(n):
    s = input()
    if s not in s_dic:
        s_dic[s] = 1
    else:
        s_dic[s] += 1
max_s_list = [s[0] for s in s_dic.items() if s[1] == max(s_dic.values())]
max_s_list.sort()
for s in max_s_list:
    print(s)


Fixed submission:
from collections import Counter

n = int(input())
s_list = []

for i in range(n):
    s_list.append(input())

s_list.sort()
c = Counter(s_list)
l = c.most_common()    
count = l[0][1]
l.sort()
for i in l:
    if count == i[1]:
        print(i[0])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split()) 
p_list = list(map(int, input().split()))
pe_list = [(p + 1) / 2 for p in p_list]

ans = -1
for i in range(n):
    if i + k > n: break
    ans = max(ans, sum(pe_list[i:i+k]))
print(ans)

Fixed submission:
n, k = map(int, input().split()) 
p_list = list(map(int, input().split()))
e_list = [(p + 1) / 2 for p in p_list]

s = sum(e_list[:k])
ans = s
for i, e in enumerate(e_list[k:]):
    s = s - e_list[i] + e
    ans = max(ans, s)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split()) 
p_list = list(map(int, input().split()))
pe_list = [(p + 1) / 2 for p in p_list]

ans = -1
for i in range(n):
    ans = max(ans, sum(pe_list[i:i+k]))
print(ans)

Fixed submission:
n, k = map(int, input().split()) 
p_list = list(map(int, input().split()))
e_list = [(p + 1) / 2 for p in p_list]

s = sum(e_list[:k])
ans = s
for i, e in enumerate(e_list[k:]):
    s = s - e_list[i] + e
    ans = max(ans, s)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p_list = list(map(int, input().split()))

ans = 0
for i, p in enumerate(p_list):
    if p == min(p_list[:i+1]): ans += 1
print(ans)

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

ans = 0
m = 10**10

for p in p_list:
    if p <= m:
        ans += 1
        m = p
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

mod = 10**9+7
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += (A[i] ^ A[j])
print(ans % mod)

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

mod = 10**9+7
ans = 0
for j in range(60):
    one_num = 0
    for i in A:
        if (i >> j) & 1:
            one_num += 1
    ans += one_num * (N - one_num) * 2**j
    ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

N = int(input())
L = list(map(int, input().split()))

c = combinations(L, 3)
ans = 0
for v in c:
    a, b, c = v
    if (a < b + c) and (b < a + c) and (c < a + b): ans += 1
print(ans)

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-1, 1, -1):
    for j in range(i-1, 0, -1):
        a, b = L[i], L[j]
        c = a - b + 1
        if c > b: continue
        ans += (j - bisect.bisect_left(L, c))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

for i in range(N):
    if K - (Q - A.count(i+1)) > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
from collections import Counter

N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]

c = Counter(A)
for i in range(N):
    if K - (Q - c[i+1]) > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()

ans = N - 1
initial = 0
for i in range(N-1):
    if S[i] == S[i+1]: initial += 1
ans = min(ans, initial + 2 * K)
print(ans)v

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

ans = N - 1
initial = 0
for i in range(N-1):
    if S[i] == S[i+1]: initial += 1
ans = min(ans, initial + 2 * K)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = input().split()

a = int(a)
b = int(b *100)
c = int(a*b)
print(c//100)


Fixed submission:
from decimal import *

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

print(int(a*b))
Buggy python submission (verdict: Runtime Error):

aaa = [0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N = int(input())
l = factorization(N) 

ans = 0

for arr in l:
  if arr[0] != 1:
    a = arr[1]
    b = aaa[a]
    ans += b
  
print(ans)

Fixed submission:

aaa = [0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
N = int(input())
l = factorization(N) 

ans = 0

for arr in l:
  if arr[0] != 1:
    a = arr[1]
    b = aaa[a]
    ans += b
  
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

A,B,H,M = map(int, input().split())
##Aは短針の長さ、Bは長針の長さ
##ARは短針の進んだ針の角度、BRは長針の進んだ針の角度
AR = 360*H/12+30*M/60
BR = 360*M/60

if abs(AR-BR)<180:
  X = abs(AR-BR)
elif abs(AR-BR)>180:
  X = 360-abs(AR-BR)
else :
  X = 0

C = math.sqrt(　A**2+B**2-abs(2*A*B*math.cos(math.radians(X)))　)

if X ==0:
  print(A+B)
else:
  print(C)


Fixed submission:
import math

A,B,H,M = map(int,input().split())

a = 360 * (H/12 + 1/12*M/60)
b = 360 * M/60

c = abs(a-b)
c = min(c,360-c)
cos = math.cos(math.radians(c))

hypotenuse = math.sqrt(math.pow(A, 2) + math.pow(B, 2) - 2 *A*B*cos)

print(hypotenuse)
Buggy python submission (verdict: Runtime Error):
# cook your dish here
def dijkstra_back(s,t,n,w,cost):
    #sからtへの最短経路の経路復元
    prev = [s] * n #最短経路の直前の頂点
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
        
        for i in range(n):
            if d[i] > d[v] + cost[v][i]: 
                d[i] = d[v] + cost[v][i]
                prev[i] = v
        
    path = [t]
    while prev[t] != s:
        path.append(prev[t])
        prev[t] = prev[prev[t]]
    path.append(s)
    path = path[::-1]
    return path


from scipy.sparse.csgraph import csgraph_from_dense,dijkstra

N,M = map(int,input().split())
edge = [[10**9 for j in range(N+1)] for i in range(N+1)]

for i in range(M):
  a,b = list(map(int,input().split()))
  edge[a][b] = 1
  edge[b][a] = 1

G = csgraph_from_dense(edge, null_value=10**9)
d = dijkstra(G,indices = 1)
ck = 0
for i in range(2,len(d)):
  if d[i] == float('inf'):
    ck = 1
if ck == 1:
  print("No")
else:
  print("Yes")
  for i in range(2,len(d)):
    d = dijkstra_back(1,i,N,M,edge)
    print(d[-2])

Fixed submission:
from collections import deque

N,M = map(int,input().split())

List = [ list(map(int,input().split())) for i in range(M)]

dict = { i:[] for i in range(1,N+1)}

for i in range(M):
  a = List[i][0]
  b = List[i][1]
  
  dict[a].append(b)
  dict[b].append(a)


kouho = deque([1])
sumi = [-1 for i in range(N+1)]

while len(kouho) > 0:
  a = kouho.popleft()
  sumi.append(a)

  for t in dict[a]:
    if sumi[t] != -1:
      continue
    else:
      kouho.append(t)
      sumi[t] = a
          
ck = 0

for i in range(2,N+1):
  if sumi[i] == -1:
    ck=1
    
if ck == 1:
  print("No")
else:
  print("Yes")
  
  for i in range(2,N+1):
    print(sumi[i])
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
List=list(map(int,input().split()))

arr = [1]
cnt = 1

ans = [0 for i in range(N+1)]
ans[0] = 1

for i in range(N):
  if i == 0:
    s = List[i]
    arr.append(s)
    ans[s] += 1
  else:
    if ans[s-1] == 1:
      b = arr.index(List[s-1])
      break
    else:
      s = List[s-1]
      arr.append(s)
      ans[s] += 1
      
l = len(arr)
c = int( (K-b) % (l-b) )

if K-b > 0:
  print(arr[b+c])
else:
  print(arr[K-1])

Fixed submission:
N,K=map(int,input().split())
List=list(map(int,input().split()))

arr = [1]
cnt = 1
b = 10 ** 7
ans = [0 for i in range(N+1)]

for i in range(N):
  if i == 0:
    ans[1] += 1
    s = List[i]
    arr.append(s)    
  else:
    if ans[s] == 1:
      b = arr.index(List[s-1])
      break
    else:
      ans[s] += 1
      s = List[s-1]
      arr.append(s)
            
l = len(arr)
c = int( (K-b) % (l-b) )

if K-b > 0:
  print(arr[b+c])
elif K-b == 0:
  print(arr[b])
else:
  print(arr[K])
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())

d = int(input())
ans = [0 for i in range(N)]

for i in range(d):
  List=list(map(int,input().split()))
  for j in List:
    ans[j-1] += 1
    
print(ans.count(0))

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

ans = [0 for i in range(N)]

for i in range(K):
  d = int(input())
  List=list(map(int,input().split()))
  for j in List:
    ans[j-1] += 1
    
cnt = 0

for i in ans:
  if i == 0:
    cnt += 1
    
print(cnt)
Buggy python submission (verdict: Runtime Error):
A,B,N=map(int,input().split())

print(int(N/abs(A-B)))

Fixed submission:
A,B,N=map(int,input().split())
import math

if N >= B-1:
  print(math.floor(A*(B-1)/B))
else:
  print(math.floor(A*N/B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = []


for i in range(N):
  S = input()
  if S in arr:
    a = 0
  else:
    arr.append(S)
    
print(int(len(arr)))

Fixed submission:
N = int(input())
arr = []

for i in range(N):
  S = input()
  arr.append(S)
    
arr.sort()
cnt = 1
for i in range(N-1):
  a = arr[i]
  b = arr[i+1]
  if a != b:
    cnt += 1

print(int(cnt))
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
  
K = int(input())
a = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      a += int(gcd_list([i,j,k]))
      
print(int(a))

Fixed submission:
import math

K = int(input())
arr = []
a = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    arr.append(math.gcd(i, j))      
for j in range(len(arr)):
  for k in range(1,K+1):
    a += math.gcd(arr[j],k)
print(int(a))
Buggy python submission (verdict: Runtime Error):
import bisect
X,Y,A,B,C=map(int,input().split())

AList=list(map(int,input().split()))
BList=list(map(int,input().split()))
CList=list(map(int,input().split()))

AList.sort(reverse=True)
BList.sort(reverse=True)
CList.sort(reverse=True)

alist = AList[0:X] + BList[0:Y] + CList
alist.sort(reverse=True)

print(int(sum(alist[:X+Y])))


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

ans = [0 for i in range(N+1)]

for i in range(1,N+1):
  for j in range(i+1,N+1):
    if i < X :
      if j < X:
        a = j - i
        ans[a] += 1
      elif j >= X and j < Y:
        a = j - i
        b = (X-i) + 1 + (Y-j)
        c = min(a,b)
        ans[c] += 1
      else:
        a =  (X-i)+ 1 + (j - Y)
        ans[a] += 1
        
    elif i >= X and i < Y:
      if j < Y:
        a = j - i
        b = (i-X) + 1 + (Y-j)
        c = min(a,b)
        ans[c] += 1
      else:
        a = j -i
        b =  (i-X) + 1 + (j - Y)
        c = min(a,b)
        ans[c] += 1
        
    else:
      a = j - i
      ans[a] += 1
        
for i in range(1,N):
  print(int(ans[i]))

Buggy python submission (verdict: Time Limit Exceeded):
from scipy.sparse.csgraph import csgraph_from_dense,floyd_warshall

N,X,Y=map(int,input().split())

edge = [[10**9 for j in range(N)] for i in range(N)]

for i in range(N-1):
  edge[i][i+1] = 1
  edge[i+1][i] = 1

edge[X-1][Y-1] = 1
edge[Y-1][X-1] = 1

G = csgraph_from_dense(edge, null_value=10**9)
d = floyd_warshall(G)
ans = []
for i in d:
  for j in i:
    ans.append(j)

for i in range(1,N):
  print(int(ans.count(i)/2))

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

ans = [0 for i in range(N+1)]

for i in range(1,N+1):
  for j in range(i+1,N+1):
    if i < X :
      if j < X:
        a = j - i
        ans[a] += 1
      elif j >= X and j < Y:
        a = j - i
        b = (X-i) + 1 + (Y-j)
        c = min(a,b)
        ans[c] += 1
      else:
        a =  (X-i)+ 1 + (j - Y)
        ans[a] += 1
        
    elif i >= X and i < Y:
      if j < Y:
        a = j - i
        b = (i-X) + 1 + (Y-j)
        c = min(a,b)
        ans[c] += 1
      else:
        a = j -i
        b =  (i-X) + 1 + (j - Y)
        c = min(a,b)
        ans[c] += 1
        
    else:
      a = j - i
      ans[a] += 1
        
for i in range(1,N):
  print(int(ans[i]))
Buggy python submission (verdict: Runtime Error):
N = int(input())

List = list(map,input().split())

m = 1
cnt = 0

for i in range(N):
  a = List[i]
  if a <= m :
    cnt += 1
    m = a
    
print(int(cnt))

Fixed submission:
N = int(input())

List = list(map(int,input().split()))

m = 10 ** 10
cnt = 0

for i in range(N):
  a = List[i]
  if a <= m :
    cnt += 1
    m = a
    
print(int(cnt))
Buggy python submission (verdict: Runtime Error):
N.M = map(int,input().split())

List = []
ans = [0  for i in range(N+1)]
WA = [0  for i in range(N+1)]

for i in range(M):
  p,S = map,input().split()
  
  if ans[p] != 0:
    if S == "AC":
      ans[p] = 1
    else:
      WA[p] += 1
      
A = sum(ans)
W = sum(WA)

print(A,W)

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

List = []
ans = [0  for i in range(N+1)]
WA = [0  for i in range(N+1)]

for i in range(M):
  p,S = input().split()
  p = int(p)
  
  if ans[p] == 0:
    if S == "AC":
      ans[p] = 1
    else:
      WA[p] += 1
      
A = sum(ans)

W= 0

for i in range(N+1):
  W += ans[i] * WA[i]

print(A,W)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
List=[list(input().split()) for i in range(M)]
AC = set([])
WA = []
accnt = 0
wacnt = 0

for i in range(M):
  num = List[i][0]
  res = List[i][1]
  
  if num in AC:
    aa = 9
  else:
    if res == "AC":
      accnt = accnt + 1
      AC.add(num)
      wacnt = wacnt + WA.count(num)
    if res == "WA":
      WA.append(num)
  
ans = [int(accnt),int(wacnt)]
print(*ans)


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

List = []
ans = [0  for i in range(N+1)]
WA = [0  for i in range(N+1)]

for i in range(M):
  p,S = input().split()
  p = int(p)
  
  if ans[p] == 0:
    if S == "AC":
      ans[p] = 1
    else:
      WA[p] += 1
      
A = sum(ans)

W= 0

for i in range(N+1):
  W += ans[i] * WA[i]

print(A,W)