Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

l = collections.Counter(A)
for i in range(1, N+1):
  print(l[i])


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

l = Counter(A)
for i in range(1, N+1):
  print(l[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

for i in range(1, N):
  print(A.count(i))
print(0)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

l = Counter(A)
for i in range(1, N+1):
  print(l[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

counter = 0
for i in range(1, N):
  for j in range(N-1):
    if A[j] == i:
      counter += 1
  print(counter)
  counter = 0
print(0)


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

l = Counter(A)
for i in range(1, N+1):
  print(l[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

counter = 0
for i in range(1, N):
  for j in range(N-1):
    if A[j] == i:
      counter += 1
  print(counter)
  counter = 0
print(0)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

l = Counter(A)
for i in range(1, N+1):
  print(l[i])

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

counter = 0
for i in range(1, N):
  for j in range(N):
    if A[j] == i:
      counter += 1
  print(counter)
  counter = 0

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

l = Counter(A)
for i in range(1, N+1):
  print(l[i])
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
 
import math
 
ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      first = int(math.gcd(a, b))
      plus = int(math.gcd(first, c))
      ans += plus
      
print(ans)

Fixed submission:
K = int(input())
 
import math
 
ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      first = int(math.gcd(a, b))
      plus = int(math.gcd(first, c))
      ans += plus
      
print(ans)

Buggy python submission (verdict: Runtime Error):
K = int(input())

import math

ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      plus = int(math.gcd(a, b, c))
      ans += plus
      
print(ans)

Fixed submission:
K = int(input())
 
import math
 
ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      first = int(math.gcd(a, b))
      plus = int(math.gcd(first, c))
      ans += plus
      
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())
import itertools

l = list(S)
ans = 0
for a,b,c in itertools.combinations_with_replacement(range(N), 3):
  if (l[a]!=l[b]) and (l[b]!=l[c]) and (l[c]!=l[a]) and (b-a!=c-b):
    ans += 1
        
print(ans)


Fixed submission:
N = int(input())
S = str(input())

l = list(S)
ans = l.count('R')*l.count('G')*l.count('B')
for i in range(N-2):
  a = l[i]
  for j in range(1, (N+1-i)//2):
    b, c = l[i+j], l[i+2*j]
    if (a!=b) and (b!=c) and (c!=a):
      ans -= 1
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())

l = list(S)
ans = 0
for a in range(0, N-2):
  for b in range(a+1, N-1):
    for c in range(b+1, N):
      if (l[a]!=l[b]) and (l[b]!=l[c]) and (l[c]!=l[a]) and (b-a!=c-b):
        ans += 1
        
print(ans)

Fixed submission:
N = int(input())
S = str(input())

l = list(S)
ans = l.count('R')*l.count('G')*l.count('B')
for i in range(N-2):
  a = l[i]
  for j in range(1, (N+1-i)//2):
    b, c = l[i+j], l[i+2*j]
    if (a!=b) and (b!=c) and (c!=a):
      ans -= 1
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())
dis = []

for i in range(1, N+1):
  for j in range(i, N+1):
    dis.append(min(j-i, abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X)))
    
for i in range(1, N):
  ans = dis.count(i)
  print(ans)

Fixed submission:
N, X, Y = map(int, input().split())
dis = [0]*(N-1)

for i in range(1, N+1):
  for j in range(i+1, N+1):
    kyori = min(j-i, abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X))
    dis[kyori-1] += 1
    
for ans in dis:
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y = map(int, input().split())

for k in range(1, N):
  ans = 0
  for i in range(1, N+1):
    for j in range(i, N+1):
      dis = min(j-i, abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X))
      if dis == k:
        ans += 1
  print(ans)

Fixed submission:
N, X, Y = map(int, input().split())
dis = [0]*(N-1)

for i in range(1, N+1):
  for j in range(i+1, N+1):
    kyori = min(j-i, abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X))
    dis[kyori-1] += 1
    
for ans in dis:
  print(ans)
Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

red = sorted(p, reverse=True)[:X]
green = sorted(q, reverse=True)[:Y]
white = sorted(r, reverse=True)

original = sorted(red + green)
while original[0] < white[0]:
  original[0] = white[0]
  white.pop(0)
  original.sort()
  
print(sum(original))


Fixed submission:
from collections import deque
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r = sorted(r, reverse=True)

ans_p = deque(p[:X])
ans_q = deque(q[:Y])
ans_r = deque(r)

while (ans_p[-1]<ans_r[0]) or (ans_q[-1]<ans_r[0]):
  if ans_p[-1] <= ans_q[-1]:
    ans_p.pop()
    ans_p.appendleft(ans_r[0])
    ans_r.popleft()
  else:
    ans_q.pop()
    ans_q.appendleft(ans_r[0])
    ans_r.popleft()
  if not ans_r:
    break;
    
ans = sum(ans_p) + sum(ans_q)
print(ans)

Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

red = sorted(p, reverse=True)[:X-1]
green = sorted(q, reverse=True)[:Y-1]
white = sorted(r, reverse=True)

original = sorted(red + green)
while original[0] < white[0]:
  original[0] = white[0]
  white.pop(0)
  original.sort()
  
print(sum(original))

Fixed submission:
from collections import deque
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r = sorted(r, reverse=True)

ans_p = deque(p[:X])
ans_q = deque(q[:Y])
ans_r = deque(r)

while (ans_p[-1]<ans_r[0]) or (ans_q[-1]<ans_r[0]):
  if ans_p[-1] <= ans_q[-1]:
    ans_p.pop()
    ans_p.appendleft(ans_r[0])
    ans_r.popleft()
  else:
    ans_q.pop()
    ans_q.appendleft(ans_r[0])
    ans_r.popleft()
  if not ans_r:
    break;
    
ans = sum(ans_p) + sum(ans_q)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

if N != 0 and M != 0:
  answer = N(N-1)/2 + M(M-1)/2
  print(answer)
elif N == 0:
  answer = M(M-1)/2
  print(answer)
else:
  answer = N(N-1)/2
  print(answer)

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

if N != 0 and M != 0:
  answer = N*(N-1)/2 + M*(M-1)/2
  print(int(answer))
elif N == 0:
  answer = M*(M-1)/2
  print(int(answer))
else:
  answer = N*(N-1)/2
  print(int(answer))
Buggy python submission (verdict: Runtime Error):
S = input()

num = len(S)
S1 = S[:(num-1)/2]
S2 = S[(num+3)/2:]

if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1]:
  print('Yes')
else:
  print('No')

Fixed submission:
S = input()

num = len(S)
S1 = S[:(num-1)//2]
S2 = S[(num+1)//2:]

if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1]:
  print('Yes')
else:
  print('No')

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

num = len(S)
S1 = S[:(num-1)/2]
S2 = S[(num+3)/2:]

if S == S[::-1] and S1 == [::-1] and S2 == [::-1]:
  print('Yes')
else:
  print('No')

Fixed submission:
S = input()

num = len(S)
S1 = S[:(num-1)//2]
S2 = S[(num+1)//2:]

if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

down_a = A / 0.08
up_a = (A+1) / 0.08
down_b = B / 0.1
up_b = (B+1) / 0.1

a = [i for i in range(down_a, up_a)]
b = [j for j in range(down_b, up_b)]

ans = -1
for num in a:
  if num in b:
    ans = num
    break;
print(ans)

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

down_a = math.ceil(A / 0.08)
up_a = math.ceil((A+1) / 0.08)
down_b = int(B / 0.1)
up_b = int((B+1) / 0.1)

a = [i for i in range(down_a, up_a)]
b = [j for j in range(down_b, up_b)]

ans = -1
for num in a:
  if num in b:
    ans = num
    break;
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
s = str(input())
Q = int(input())
cnt = 0

for i in range(Q):
  q = list(input().split())
  if q[0] == '1':
    cnt = (cnt+1) % 2
  elif q[1] == '1':
    if cnt == 0:
      s = q[2] + s
    else:
      s += q[2]
  else:
    if cnt == 0:
      s += q[2]
    else:
      s = q[2] + s

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

Fixed submission:
from collections import deque
import sys
s = deque(list(input()))
Q = int(input())
cnt = 0

for i in range(Q):
  q = list(input().split())
  if q[0] == '1':
    cnt = (cnt+1) % 2
  elif q[1] == '1':
    if cnt == 0:
      s.appendleft(q[2])
    else:
      s.append(q[2])
  else:
    if cnt == 0:
      s.append(q[2])
    else:
      s.appendleft(q[2])

if cnt == 1:
  s.reverse()
print("".join(s))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
s = str(input())
Q = int(input())
q = sys.stdin.readlines()
cnt = 0

for i in q:
  if i[0] == '1':
    cnt = (cnt+1) % 2
  elif i[2] == '1':
    if cnt == 0:
      s = i[4] + s
    else:
      s += i[4]
  else:
    if cnt == 0:
      s += i[4]
    else:
      s = i[4] + s

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

Fixed submission:
from collections import deque
import sys
s = deque(list(input()))
Q = int(input())
cnt = 0

for i in range(Q):
  q = list(input().split())
  if q[0] == '1':
    cnt = (cnt+1) % 2
  elif q[1] == '1':
    if cnt == 0:
      s.appendleft(q[2])
    else:
      s.append(q[2])
  else:
    if cnt == 0:
      s.append(q[2])
    else:
      s.appendleft(q[2])

if cnt == 1:
  s.reverse()
print("".join(s))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
s = str(input())
Q = int(input())
q = sys.stdin.readlines()
for i in q:
  i = i.strip()
  if i[0] == '1':
    s = s[::-1]
  elif i[2] == '1':
    s = i[4] + s
  else:
    s += i[4]
print(s)

Fixed submission:
from collections import deque
import sys
s = deque(list(input()))
Q = int(input())
cnt = 0

for i in range(Q):
  q = list(input().split())
  if q[0] == '1':
    cnt = (cnt+1) % 2
  elif q[1] == '1':
    if cnt == 0:
      s.appendleft(q[2])
    else:
      s.append(q[2])
  else:
    if cnt == 0:
      s.append(q[2])
    else:
      s.appendleft(q[2])

if cnt == 1:
  s.reverse()
print("".join(s))

Buggy python submission (verdict: Runtime Error):
import sys
s = str(input())
Q = int(input())
q = sys.stdin.readlines()
for i in q:
  if i[0] == 1:
    s = alpha[::-1]
  elif i[1] == 1:
    s.appendleft(i[2])
  else:
    s.append(i[2])
print(s)

Fixed submission:
from collections import deque
import sys
s = deque(list(input()))
Q = int(input())
cnt = 0

for i in range(Q):
  q = list(input().split())
  if q[0] == '1':
    cnt = (cnt+1) % 2
  elif q[1] == '1':
    if cnt == 0:
      s.appendleft(q[2])
    else:
      s.append(q[2])
  else:
    if cnt == 0:
      s.append(q[2])
    else:
      s.appendleft(q[2])

if cnt == 1:
  s.reverse()
print("".join(s))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 != 0 and A[i] % 5 != 0:
      print('DENIED')
      break()
      
print('APPROVED')

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

for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 != 0 and A[i] % 5 != 0:
      print('DENIED')
      break
    elif i != N-1:
      continue
    else:
      print('APPROVED')
      break
  elif i != N-1:
    continue
  else:
    print('APPROVED')
    break
Buggy python submission (verdict: Runtime Error):
s, t = input().split()
a, b = int(input().split())
u = input()

if s == u:
  a = a - 1
else:
  b =  b - 1
  
print("{} {}".format(a, b))

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()
 
if s == u:
  a = a - 1
else:
  b =  b - 1
  
print("{} {}".format(a, b))
Buggy python submission (verdict: Runtime Error):
number = len(input())
print(x * number)

Fixed submission:
number = len(input())
print('x' * number)
Buggy python submission (verdict: Runtime Error):
H, K = map(int, input().split())
hp = list(int, map(input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))


Fixed submission:
H, K = map(int, input().split())
hp = list(map(int, input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))

Buggy python submission (verdict: Runtime Error):
H, K = map(int, input().split())
hp = list(map(input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))


Fixed submission:
H, K = map(int, input().split())
hp = list(map(int, input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))

Buggy python submission (verdict: Runtime Error):
H, K = map(int, input().split())
hp = list(map(input().split()))
hp_sorted = sorted(hp, reverse=True)
print(sum(hp_sorted[K:]))


Fixed submission:
H, K = map(int, input().split())
hp = list(map(int, input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))

Buggy python submission (verdict: Runtime Error):
H, K = map(int, input().split())
hp = list(map(input().split()))
hp_sorted = sorted(hp, reverse=True)
hp_new = list(hp_sorted[K:])
print(sum(hp_new))


Fixed submission:
H, K = map(int, input().split())
hp = list(map(int, input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))

Buggy python submission (verdict: Runtime Error):
H, K = map(int, input().split())
hp = list(map(input().split()))
hp_sorted = sorted(hp, reverse=True)
hp_new = hp_sorted[K:]
print(sum(hp_new))

Fixed submission:
H, K = map(int, input().split())
hp = list(map(int, input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))
Buggy python submission (verdict: Runtime Error):
H = input()

i = 0
while 2 ** i <= H:
  i += 1
print(2 ** i - 1)

Fixed submission:
H = input()

i = 0
while 2 ** i <= int(H):
  i += 1
print(2 ** i - 1)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
nums = [list(map(int, input().split())) for _ in range(N)]
for row in nums:
  row.append(row[0]+row[1])
  row.append(row[0]-row[1])

nums.sort(key=lambda x: x[2])
ans_1 = N
ans_2 = N

point_1 = nums[0][2]
point_2 = nums[1][2]
for j in range(N-1):
  if nums[j+1][3] < point_1:
    ans_1 -= 1
  else:
    point = nums[j][2]
for j in range(N-1):
  if nums[j+1][3] < point_2:
    ans_2 -= 1
  else:
    point = nums[j][2]
print(max(ans_1, ans_2))

Fixed submission:
N = int(input())
l = []
for i in range(N):
  X, L = map(int, input().split())
  l.append([X-L, X+L])
  
l.sort(key=lambda x: x[1])
pin = l[0][1]
ans = 1

for i in range(1, N):
  if pin <= l[i][0]:
    ans += 1
    pin = l[i][1]
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(str(input()))
d = [[float('inf') for i in range(V)] for j in range(V)]
  
  

Fixed submission:
import math
import sys
sys.setrecursionlimit(10000)
H, W = map(int, input().split())
S = []
for i in range(H):
  S.append(str(input()))
  
def main(l, d, cnt):
  tmp = []
  for n in l:
    i, j = n[0], n[1]
    if (0<i) and (S[i-1][j] == '.'):
      if d[i-1][j] > d[i][j]+1:
        d[i-1][j] = d[i][j]+1
        tmp.append([i-1, j])
    if (i<H-1) and (S[i+1][j] == '.'):
      if d[i+1][j] > d[i][j]+1:
        d[i+1][j] = d[i][j]+1
        tmp.append([i+1, j])
    if (0<j) and (S[i][j-1] == '.'):
      if d[i][j-1] > d[i][j]+1:
        d[i][j-1] = d[i][j]+1
        tmp.append([i, j-1])
    if (j<W-1) and (S[i][j+1] == '.'):
      if d[i][j+1] > d[i][j]+1:
        d[i][j+1] = d[i][j]+1
        tmp.append([i, j+1])
  if tmp == []:
    return cnt
  else:
    cnt += 1
    return main(tmp, d, cnt)
  
ans = 0
for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      d = [[float('inf') for i in range(W)] for j in range(H)]
      d[i][j] = 0
      cnt = main([[i, j]], d, 0)
      ans = max(ans, cnt)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
original = int(N // 1.08)

if (math.floor(original * 1.08)) = N:
  print(original)
elif (math.floor((original + 1) * 1.08)) = N:
  print(original + 1)
else:
  print(':(')


Fixed submission:
N = int(input())
original = int(N // 1.08)

if 0 <= (original * 1.08) - N < 1:
  print(original)
elif 0 <= ((original + 1) * 1.08) - N < 1:
  print(original + 1)
else:
  print(':(')

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
original = int(N // 1.08)

if math.floor(original * 1.08) = N:
  print(original)
elif math.floor((original + 1) * 1.08) = N:
  print(original + 1)
else:
  print(':(')

Fixed submission:
N = int(input())
original = int(N // 1.08)

if 0 <= (original * 1.08) - N < 1:
  print(original)
elif 0 <= ((original + 1) * 1.08) - N < 1:
  print(original + 1)
else:
  print(':(')
Buggy python submission (verdict: Runtime Error):
N = map(int, input())
answer = N // 2
print(answer)

Fixed submission:
N = int(input())
answer = (N - 1) // 2
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())
N = len(S) + 1
l = [-1] * N
if S[0] == '<':
  l[0] = 0
else:
  i = 0
  while i <= N-2:
    if S[i] == '>':
      i += 1
    else:
      break
  l[0] = i
  
if S[-1] == '>':
  l[-1] = 0
else:
  i = N-2
  cnt = 0
  while i >= 0:
    if S[i] == '<':
      i -= 1
      cnt += 1
    else:
      break
  l[-1] = cnt
  
for i in range(N-2):
  if (S[i]=='>') and (S[i+1]=='<'):
    l[i+1] = 0
  else:
    left = 0
    right = 0
    c1 = i
    c2 = i+1
    while c1 >= 0:
      if S[c1] == '<':
        left += 1
        c1 -= 1
      else:
        break
    while c2 <= N-2:
      if S[c2] == '>':
        right += 1
        c2 += 1
      else:
        break
    num = max(left, right)
    l[i+1] = num
ans = sum(l)
print(ans)

Fixed submission:
s = input()
num = len(s)
a = [0]*(num+1)

for i in range(num):
    if s[i] == '<':
        a[i+1] = max(a[i+1], a[i]+1)

for i in range(1, num+1):
    if s[-i] == '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
print(sum(a))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
 
length = 1
i = 0
while i < N-1:
  if S[i] == S[i+1]:
    i += 1
  else:
    lendth += 1
    i += 1
    
print(length)

Fixed submission:
N = int(input())
S = list(input())
 
length = 1
i = 0
while i < N-1:
  if S[i] == S[i+1]:
    i += 1
  else:
    length += 1
    i += 1
    
print(length)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
total = 0
for i in range(N):
  h = int(input())
  if h >= K:
    total += 1
    
print(total)

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

total = 0
for height in h:
  if height >= K:
    total += 1
    
print(total)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A_re = []

for i in range(N):
  num = A[i]
  A_re.append([num, i+1])
  
A_re.sort()

Ans = []
for j in range(N):
  ans = A_re[j][1]
  Ans.append(ans)
  
print(' '.join(Ans))

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

for i in range(N):
  num = A[i]
  A_re.append([num, i+1])
  
A_re.sort()

Ans = []
for j in range(N):
  ans = A_re[j][1]
  Ans.append(str(ans))
  
Ans = ' '.join(Ans)
print(Ans)
Buggy python submission (verdict: Runtime Error):
import collections
A, B = map(int, input().split())

a = collections.Counter(prime_factorize(A))
b = collections.Counter(prime_factorize(B))

l_a = list(a.keys())
l_b = list(b.keys())

ans = 1
for i in l_b:
  if i in l_a:
    ans += 1
    
print(ans)

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a = set(prime_factorize(A))
b = set(prime_factorize(B))

ans = 1
for i in b:
  if i in a:
    ans += 1
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

def discount(l):
  l[-1] = l[-1] // 2
  l.sort()

for i in range(M):
  discount(A)
  
print(sum(A))

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(lambda x:int(x)*(-1), input().split()))
heapq.heapify(A)

for i in range(M):
  max_value = heapq.heappop(A)*(-1)
  heapq.heappush(A, (max_value//2)*(-1))
  
print((-1)*sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
for i in range(M):
  A[-1] = A[-1] // 2
  A.sort()
  
print(sum(A))

Fixed submission:
import heapq

N, M = map(int, input().split())
A = list(map(lambda x:int(x)*(-1), input().split()))
heapq.heapify(A)

for i in range(M):
  max_value = heapq.heappop(A)*(-1)
  heapq.heappush(A, (max_value//2)*(-1))
  
print((-1)*sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
  a = int(input())
  A.append(a)
  
A2 = sorted(A)
mx1 = A2[-1]
mx2 = A2[-2]

for i in range(N):
  if i == A.index(mx1):
    print(mx2)
  else:
    print(mx1)


Fixed submission:
N = int(input())
A = []
for i in range(N):
  a = int(input())
  A.append(a)
  
A2 = sorted(A)
mx1 = A2[-1]
mx2 = A2[-2]
ind = A.index(mx1)

for i in range(N):
  if i != ind:
    print(mx1)
  else:
    print(mx2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = []
for i in range(N):
  a = int(input())
  A.append(a)
  
A2 = sorted(A)
mx1 = max(A)
mx2 = A2[-2]

for i in range(N):
  if i == A.index(mx1):
    print(mx2)
  else:
    print(mx1)

Fixed submission:
N = int(input())
A = []
for i in range(N):
  a = int(input())
  A.append(a)
  
A2 = sorted(A)
mx1 = A2[-1]
mx2 = A2[-2]
ind = A.index(mx1)

for i in range(N):
  if i != ind:
    print(mx1)
  else:
    print(mx2)