Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=int)

for i in range(N):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[:-w]+v)
print(dp[-1])

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
wv = np.array(wv)
V = max(wv[:, 1])
dp = np.array([float('inf')]*(N*V+1))

dp[0] = 0
for i in range(N):
    w, v = wv[i]
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
print(max(np.where(dp<=W)[0]))

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=int)

for i in range(N):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[:-w]+v)
print(dp[-1])

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
wv = np.array(wv)
V = max(wv[:, 1])
dp = np.array([float('inf')]*(N*V+1))

dp[0] = 0
for i in range(N):
    w, v = wv[i]
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
print(max(np.where(dp<=W)[0]))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

s = input().split()[0]
t = input().split()[0]

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]
for i in range(len(s)):
    for j in range((len(t))):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i][j]+1, dp[i+1][j], dp[i][j+1])
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

i = len(s)
j = len(t)
ans = ''
while i>0 and j>0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        i -= 1
        j -= 1
        ans = s[i] + ans
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

s = input().split()[0]
t = input().split()[0]

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]
for i in range(len(s)):
    for j in range((len(t))):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i][j]+1, dp[i+1][j], dp[i][j+1])
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

i = len(s)
j = len(t)
ans = ''
while i>0 and j>0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        i -= 1
        j -= 1
        ans = s[i] + ans
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
counted = 0

def make_divisors(n):
    count = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            count += 1
            if i != n // i:
                count += 1
    return count

for i in range(1,n):
  counted +=  make_divisors(i)

print(counted)

Fixed submission:
n = int(input())
counted = 0

for i in range(1,n):
  counted +=  (n-1)//i

print(counted)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nlist = list(map(int, input().split(" ")))

count = 0
for i, m in enumerate(nlist):
  count += max(nlist[:i+1])-m
  
print(count)


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

count = 0
for i in range(n-1):
  if nlist[i]>nlist[i+1]:
    count += nlist[i]-nlist[i+1]
    nlist[i+1] = nlist[i]
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
alist = list(map(int, input().split(" ")))

if 0 in alist:
  print("0")
else:
  result = 1
  m = 0
  while result <= 10**18:
    result *= alist[m]
    m += 1
  if m < n or result > 10**18:
    print("-1")
  else:
    print(result)

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

if 0 in alist:
  print("0")
else:
  result = 1
  m = 0
  while result <= 10**18 and m < n:
    result *= alist[m]
    m += 1
  if m < n or result > 10**18:
    print("-1")
  else:
    print(result)

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

result = 1
m = 0
while result <= 10**18:
  result *= alist[m]
  m += 1

if m < n or result > 10**18:
  print("-1")
else:
  print(result)

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

if 0 in alist:
  print("0")
else:
  result = 1
  m = 0
  while result <= 10**18 and m < n:
    result *= alist[m]
    m += 1
  if m < n or result > 10**18:
    print("-1")
  else:
    print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
alist = list(map(int, input().split(" ")))

result = 1
for i in alist:
  result *= i

if result > 10**18:
  print("-1")
else:
  print(result)

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

if 0 in alist:
  print("0")
else:
  result = 1
  m = 0
  while result <= 10**18 and m < n:
    result *= alist[m]
    m += 1
  if m < n or result > 10**18:
    print("-1")
  else:
    print(result)
Buggy python submission (verdict: Runtime Error):
a,b,n = map(int, input().split(" "))

def floor(x):
    return x//1

dp=[0]*(n+1)

for x in range(1,n+1):
    dp[x] = max(dp[x-1],floor(a*x/b)-a*floor(x/b))

print(int(dp[n]))

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

def floor(x):
    return ((a*x/b)//1) - a*((x/b)//1)

ans = floor(min(b-1,n))

print(int(ans))

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

def floor(x):
    return x//1

dp=[0]*(n+1)

for x in range(1,n+1):
    dp[x] = max(dp[x-1],floor(a*x/b)-a*floor(x/b))

print(int(dp[n]))

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

def floor(x):
    return ((a*x/b)//1) - a*((x/b)//1)

ans = floor(min(b-1,n))

print(int(ans))

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

dp=[0]*(n+1)

for x in range(n):
    dp[x+1] = max(dp[x],((a*(x+1)/b)//1)-a*(((x+1)/b)//1))

print(int(dp[n]))

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

def floor(x):
    return ((a*x/b)//1) - a*((x/b)//1)

ans = floor(min(b-1,n))

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

result = 0
for i in range(k,n+2):
  numbers = range(0,n+1)
  mins = sum(numbers[0:i])
  maxs = sum(numbers[-i:])
  result += maxs - mins +1


print(result)

Fixed submission:
import math
r = int(input())

l=float(math.pi*2*r)

print(round(l,3))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
alist = list(map(int, input().split()))

for i in range(1,n+1):
  print(alist.count(i))

Fixed submission:
n = int(input())
alist = list(map(int, input().split(" ")))
dp = [0]*n

for i in alist:
  dp[i-1]+=1

for i in dp:
  print(int(i))

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

for i in range(1,n+1):
  ilist = [s for s in alist if s==i]
  print(len(ilist))

Fixed submission:
n = int(input())
alist = list(map(int, input().split(" ")))
dp = [0]*n

for i in alist:
  dp[i-1]+=1

for i in dp:
  print(int(i))

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

for i in range(1,n+1):
  ilist = [s for s in alist if int(s)==i]
  print(len(ilist))

Fixed submission:
n = int(input())
alist = list(map(int, input().split(" ")))
dp = [0]*n

for i in alist:
  dp[i-1]+=1

for i in dp:
  print(int(i))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=list(map(int,input().split()))

result = 0
for i in range(k,n+2):
  numbers = range(0,n+1)
  mins = sum(numbers[0:i])
  maxs = sum(numbers[-i:])
  result += maxs - mins +1


print(result)

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

result = 0
for i in range(k,n+2):
  result += n*i-i*i+i+1


print(result%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())

def gcd(x,y):
    while y:
        x ,y = y ,x%y
    return x



total = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            total += gcd(a , gcd(b,c))

print(total)

Fixed submission:
k = int(input())

def gcd(x,y):
    while y:
        x ,y = y ,x%y
    return x

total = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        subg = gcd(a,b)
        subtotal = 0
        for c in range(1,k+1):
            subtotal += gcd(subg, c)
        total += subtotal

print(total)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())

count = 0
for i in range(0, n-2):
    for j in range(i+1,n-1):
        if s[i] == s[j]:
            count += 0
        elif 2*j-i<=n-1 and s[2*j-i] != s[i] and s[2*j-i] != s[j]:
            l = [s[k] for k in range(j+1,n) if s[k] != s[i] and s[k] != s[j]]
            count += len(l) -1
        else:
            l = [s[k] for k in range(j + 1, n) if s[k] != s[i] and s[k] != s[j]]
            count += len(l)

print(count)


Fixed submission:
import math
n =  int(input())
s = list(input())

upper = s.count("R")*s.count("G")*s.count("B")

def counting(x):
  count = 0
  for i in range(1, math.ceil(x/2)):
    if s[x-1]!=s[x-1-i] and s[x-1-i]!=s[x-1-2*i] and s[x-1-2*i]!=s[x-1]:
      count += 1
    else:
      count += 0
  return count

if n>=3:
  minus = [0]*(n+1)
  if s[0]!=s[1] and s[1]!=s[2] and s[2]!=s[0]:
    minus [3] = 1
  else:
    minus [3] = 0
  for i in range(3,n):
    minus[i+1] = minus[i]+counting(i+1)
  print(int(upper-minus[n]))
else:
  print(int(0))

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

count = 0
for i in range(0, n-2):
    for j in range(i+1,n-1):
        if s[i] == s[j]:
            count += 0
        else:
            for k in range(j+1,n):
                if s[i] == s[k] or s[j] == s[k]:
                    count +=0
                elif j-i == k-j:
                    count +=0
                else:
                    count +=1

print(count)

Fixed submission:
import math
n =  int(input())
s = list(input())

upper = s.count("R")*s.count("G")*s.count("B")

def counting(x):
  count = 0
  for i in range(1, math.ceil(x/2)):
    if s[x-1]!=s[x-1-i] and s[x-1-i]!=s[x-1-2*i] and s[x-1-2*i]!=s[x-1]:
      count += 1
    else:
      count += 0
  return count

if n>=3:
  minus = [0]*(n+1)
  if s[0]!=s[1] and s[1]!=s[2] and s[2]!=s[0]:
    minus [3] = 1
  else:
    minus [3] = 0
  for i in range(3,n):
    minus[i+1] = minus[i]+counting(i+1)
  print(int(upper-minus[n]))
else:
  print(int(0))
Buggy python submission (verdict: Runtime Error):
k,n = map(int,input().split(" "))
alist = list(map(int, input().split(" ")))
glist = []
for i in range(n-1):
  glist.append(alist[i+1]-alist[i])
glist.append(k+a[0]-a[n-1])

print(k-max(glist))


Fixed submission:
k,n = map(int,input().split(" "))
alist = list(map(int, input().split(" ")))
glist = []
for i in range(n-1):
  glist.append(alist[i+1]-alist[i])
glist.append(k+alist[0]-alist[n-1])

print(k-max(glist))

Buggy python submission (verdict: Runtime Error):
k ,n  = map(int, input().split(" "))
alist = list(map(int, input().split(" "))
glist =  []
for i in range(n-1):
    glist.append(alist[i+1]-alist[i])
glist.append(k+alist[0]-alist[n-1])

print(int(k-max(glist)))
    
   

Fixed submission:
k,n = map(int,input().split(" "))
alist = list(map(int, input().split(" ")))
glist = []
for i in range(n-1):
  glist.append(alist[i+1]-alist[i])
glist.append(k+alist[0]-alist[n-1])

print(k-max(glist))
Buggy python submission (verdict: Time Limit Exceeded):
x,y,a,b,c = map(int, input().split(" "))
plist= sorted(list(map(int, input().split(" "))),reverse=True)[0:x]
qlist= sorted(list(map(int, input().split(" "))),reverse=True)[0:y]
rlist= list(map(int, input().split(" ")))

plist.extend(qlist)
plist.sort()

rlist.sort(reverse=True)

n = min(len(plist),len(rlist))
results = [sum(plist)]

for i in range(n):
  plist[i]=rlist[i]
  results.append(sum(plist))
  
print(max(results))

Fixed submission:
x,y,a,b,c = map(int, input().split(" "))
plist= sorted(list(map(int, input().split(" "))),reverse=True)[0:x]
qlist= sorted(list(map(int, input().split(" "))),reverse=True)[0:y]
rlist= sorted(list(map(int, input().split(" "))),reverse=True)

plist.extend(qlist)
plist.sort()
n = min(x+y,len(rlist))
i = 0

while i < n and rlist[i]>plist[i]:
  i += 1
if i == 0:
  print(sum(plist))
else:
  print(sum(plist[i:x+y])+sum(rlist[0:i]))

Buggy python submission (verdict: Runtime Error):
x,y,a,b,c = map(int, input().split(" "))
plist= list(map(int, input().split(" ")))
qlist= list(map(int, input().split(" ")))
rlist= list(map(int, input().split(" ")))

plist.extend(qlist)
plist.sort()

rlist.sort(reverse=True)

n = min(len(plist),len(rlist))
slist = plist[0:x+y-1]
ulist = plist[0:x+y-1]
slist[0] = rlist[0]
i = 1

while i < n and sum(slist)>sum(ulist):
  slist[i]=rlist[i]
  ulist[i-1]=rlist[i-1]
  i += 1

print(sum(slist))
  

Fixed submission:
x,y,a,b,c = map(int, input().split(" "))
plist= sorted(list(map(int, input().split(" "))),reverse=True)[0:x]
qlist= sorted(list(map(int, input().split(" "))),reverse=True)[0:y]
rlist= sorted(list(map(int, input().split(" "))),reverse=True)

plist.extend(qlist)
plist.sort()
n = min(x+y,len(rlist))
i = 0

while i < n and rlist[i]>plist[i]:
  i += 1
if i == 0:
  print(sum(plist))
else:
  print(sum(plist[i:x+y])+sum(rlist[0:i]))
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split(" "))
p = []
q = []

for i in range(((a/8)*100)//1, (((a+1)/8)*100)//1+1):
  if i >= (a/8)*100 and i < ((a+1)/8)*100:
    p.append(i)
    
for i in range((a*10), (a+1)*10):
    q.append(i)

pq = list(set(p) & set(q))
if pq == []:
  print("-1")
else:
  print(min(pq))

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

for i in range(int(((a/8)*100)//1), int((((a+1)/8)*100)//1+1)):
  if i >= (a/8)*100 and i < ((a+1)/8)*100:
    p.append(i)
    
for i in range((b*10), (b+1)*10):
    q.append(i)

pq = list(set(p) & set(q))
if pq == []:
  print("-1")
else:
  print(min(pq))
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
q = int(input())
actions = []

for i in range(q):
  actions.append(input().split(" "))

for action in actions:
  if action[0] == "1":
    s = s[::-1]
  else:
    if action[1] == "1":
      s = action[2]+s
    else:
      s = s+action[2]
    
print(s)

Fixed submission:
s = input()
q = int(input())
results_forward = str("")
results_back = str("")
qlist = []
for i in range(q):
  qlist.extend(input().split(" "))

amount = 0
for i in range(len(qlist)):
  if qlist[i] == "1" or qlist[i] == "2":
    amount += int(qlist[i])
  elif amount%2 == 1:
    results_forward = qlist[i] + results_forward
    amount -= int(qlist[i-1])
  elif amount%2 == 0:
    results_back = results_back + qlist[i]
    amount -= int(qlist[i-1])

if q%2 == (len(results_forward)+len(results_back))%2:
  print(results_forward+s+results_back)
else:
  print((results_forward+s+results_back)[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ar = list(map(int,input().split()))
ans=1
for i in ar:
    ans*=i
if ans>1e18:
    print(-1)
else:
    print(ans)

Fixed submission:
n = int(input())
ar = list(map(int,input().split()))
if 0 in ar:
    print(0)
else:
    ans=1
    for i in ar:
        ans*=i
        if ans>1e18:
            break
    if ans>1e18:
        print(-1)
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def Replacing():
    N = int(input())
    A = np.array(list(map(int,input().split())))
    Q = int(input())
    for i in range(Q):
        b, c = map(int,input().split())
        A = np.where(A == b, c, A)
        print(A.sum())
        
Replacing()

Fixed submission:
def Replacing():
    N = int(input())
    A = list(map(int,input().split()))
    lis = [0 for i in range(10 ** 5)]
    res = 0
    for i in A:
        lis[i-1] += 1
        res += i
    
    Q = int(input())
    for i in range(Q):
        b, c = map(int,input().split())
        num = lis[b-1]
        res += (c - b) * num
        lis[b-1] = 0
        lis[c-1] += num
        print(res)
        
Replacing()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def Replacing():
    N = int(input())
    A = np.array(list(map(int,input().split())))
    Q = int(input())
    bc = [tuple(map(int,input().split())) for i in range(Q)]
    for i,j in bc:
        res = 0
        A = np.where(A == i, j, A)
        print(A.sum())
        
Replacing()
        

Fixed submission:
def Replacing():
    N = int(input())
    A = list(map(int,input().split()))
    lis = [0 for i in range(10 ** 5)]
    res = 0
    for i in A:
        lis[i-1] += 1
        res += i
    
    Q = int(input())
    for i in range(Q):
        b, c = map(int,input().split())
        num = lis[b-1]
        res += (c - b) * num
        lis[b-1] = 0
        lis[c-1] += num
        print(res)
        
Replacing()

Buggy python submission (verdict: Time Limit Exceeded):
def Replacing():
    N = int(input())
    A = list(map(int,input().split()))
    Q = int(input())
    bc = [tuple(map(int,input().split())) for i in range(Q)]
    for i,j in bc:
        res = 0
        for k in range(len(A)):
            if A[k] == i:
                A[k] = j
            res += A[k]
        print(res)
        
Replacing()
        

Fixed submission:
def Replacing():
    N = int(input())
    A = list(map(int,input().split()))
    lis = [0 for i in range(10 ** 5)]
    res = 0
    for i in A:
        lis[i-1] += 1
        res += i
    
    Q = int(input())
    for i in range(Q):
        b, c = map(int,input().split())
        num = lis[b-1]
        res += (c - b) * num
        lis[b-1] = 0
        lis[c-1] += num
        print(res)
        
Replacing()
Buggy python submission (verdict: Runtime Error):
lis = "abcdefghijklmnopqrstuvwxyz"

z = input()

for a in range(len(lis)-1):
  if z = lis[a]:
    print(lis[a+1])
    exit()

Fixed submission:
lis = "abcdefghijklmnopqrstuvwxyz"
 
z = input()
 
for a in range(len(lis)-1):
  if z == lis[a]:
    print(lis[a+1])
    exit()

Buggy python submission (verdict: Runtime Error):
lis = "abcdefghijklmnopqrstuvwxyz"
dic = {}

z = imput()

for a in range(len(lis)-1):
  if z = lis[a]:
    print(lis[a+1])
    exit()


Fixed submission:
lis = "abcdefghijklmnopqrstuvwxyz"
 
z = input()
 
for a in range(len(lis)-1):
  if z == lis[a]:
    print(lis[a+1])
    exit()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int,input().split())
res = 0
for i in range(n):
  for j in range(i+1,n):
    res += a[i]*a[j]
print(res)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
res = 0
for i in range(n):
  for j in range(i+1,n):
    res += a[i]*a[j]
print(res)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int,input().split())
res = 0
for i in range(n):
  if a[i] == 0:
    continue
  for j in range(i+1,n):
    res += a[i]*a[j]
print(res)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
res = 0
for i in range(n):
  for j in range(i+1,n):
    res += a[i]*a[j]
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def get_prime_factors(x):
    out = []
    if x < 1:
        return out
    while not x%2:
        out.append(2)
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            out.append(i)
            x //= i
        else:
            i += 2
    if x != 1:
        out.append(x)
    return out



def main():
    n = int(input())
    ans = 0
    
    for i in range(1, n):
        primes = get_prime_factors(i)
        num = 1
        for k, v in Counter(primes).items():
            num *= v+1
        ans += num
    print(ans)
        

if __name__ == "__main__":
    main()

Fixed submission:
from collections import Counter

def get_prime_factors(x):
    out = []
    if x < 1:
        return out
    while not x%2:
        out.append(2)
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            out.append(i)
            x //= i
        else:
            i += 2
    if x != 1:
        out.append(x)
    return out



def main():
    n = int(input())
    ans = 0
    
    for i in range(1, n):
        primes = get_prime_factors(i)
        num = 1
        for k, v in Counter(primes).items():
            num *= v+1
        ans += num
    print(ans)
        

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from numba import njit


class UnionFind:
    __slots__ = ["data"]
    
    def __init__(self, n=0):
        self.data = [-1]*(n+1)
    
    def root(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.data[x] < self.data[y]:
                self.data[x] += self.data[y]
                self.data[y] = x
            else:
                self.data[y] += self.data[x]
                self.data[x] = y
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def size(self, x):
        return -self.data[self.root(x)]

@njit
def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    for i in range(m):
        a, b = map(int, input().split())
        uf.unite(a, b)
        
    ans = 0
    
    for i in range(1, n+1):
        ans = max(ans, uf.size(i))
        
    print(ans)
        


main()


Fixed submission:
class UnionFind:
    __slots__ = ["data"]
    
    def __init__(self, n=0):
        self.data = [-1]*(n+1)
    
    def root(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.data[x] < self.data[y]:
                self.data[x] += self.data[y]
                self.data[y] = x
            else:
                self.data[y] += self.data[x]
                self.data[x] = y
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def size(self, x):
        return -self.data[self.root(x)]


def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    for i in range(m):
        a, b = map(int, input().split())
        uf.unite(a, b)
        
    ans = 0
    
    for i in range(1, n+1):
        ans = max(ans, uf.size(i))
    
    print(ans)
        

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n, d = map(int, input().split())
    is_shorter = lambda dis, x, y : dis**2 <= (x**2 + y**2)
    ans = sum([is_shorter(d, map(int, input().split())) for _ in range(n)])
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, d = map(int, input().split())
    dis = d**2
    ans = 0
    for _ in range(n):
        x, y = map(int, input().split())
        if x**2 + y**2 <= dis:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    MAX = 10**18
    ans = a[0]
    for ai in a[1:]:
        ans *= ai
    if ans > MAX:
        print(-1)
    else:
        print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    MAX = 10**18
    if 0 in set(a):
        print(0)
    else:
        ans = a[0]
        for ai in a[1:]:
            ans *= ai
            if ans > MAX:
                print(-1)
                return
        print(ans)

if __name__ == "__main__":
    main()