Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

colors = ['R', 'G', 'B']
thirds = {'RG': 'B', 'GR': 'B', 'BR': 'G', 'RB': 'G', 'BG': 'R', 'GB': 'R'}
accs = {color: [] for color in colors}
nums = {color: 0 for color in colors}
sums = {color: len([s for s in S if s == color]) for color in colors}
for i in range(N):
    nums[S[i]] += 1
    for color in colors:
        accs[color].append(sums[color] - nums[color])
        
res = 0
for i in range(N-2):
    first = S[i]
    for j in range(i+1, N-1):
        second = S[j]
        if first == second:
            continue
        third = thirds[first+second]
        res += accs[third][j]
        if 2 *j - i < N and S[2*j - i] == third:
            res -= 1
                
print(res)

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

colors = ['R', 'G', 'B']
thirds = {'RG': 'B', 'GR': 'B', 'BR': 'G', 'RB': 'G', 'BG': 'R', 'GB': 'R'}
accs = {color: [] for color in colors}
nums = {color: 0 for color in colors}
sums = {color: len([s for s in S if s == color]) for color in colors}
for i in range(N):
    nums[S[i]] += 1
    for color in colors:
        accs[color].append(sums[color] - nums[color])
        
res = 0
for i in range(N-2):
    first = S[i]
    for j in range(i+1, N-1):
        second = S[j]
        if first == second:
            continue
        third = thirds[first+second]
        res += accs[third][j]
        if 2 *j - i < N and S[2*j - i] == third:
            res -= 1
                
print(res)

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


colors = ['R', 'G', 'B']
accs = {color: [] for color in colors}
nums = {color: 0 for color in colors}
sums = {color: len([s for s in S if s == color]) for color in colors}
for i in range(N):
    nums[S[i]] += 1
    for color in colors:
        accs[color].append(sums[color] - nums[color])
        
res = 0
for i in range(N):
    first = S[i]
    for j in range(i+1, N):
        second = S[j]
        if first == second:
            continue
        third = [color for color in colors if color not in [first, second]][0]
        res += accs[third][j]
        if j + (j - i) < N:
            if S[j + (j - i)] == third:
                res -= 1
                
print(res)

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

colors = ['R', 'G', 'B']
thirds = {'RG': 'B', 'GR': 'B', 'BR': 'G', 'RB': 'G', 'BG': 'R', 'GB': 'R'}
accs = {color: [] for color in colors}
nums = {color: 0 for color in colors}
sums = {color: len([s for s in S if s == color]) for color in colors}
for i in range(N):
    nums[S[i]] += 1
    for color in colors:
        accs[color].append(sums[color] - nums[color])
        
res = 0
for i in range(N-2):
    first = S[i]
    for j in range(i+1, N-1):
        second = S[j]
        if first == second:
            continue
        third = thirds[first+second]
        res += accs[third][j]
        if 2 *j - i < N and S[2*j - i] == third:
            res -= 1
                
print(res)
Buggy python submission (verdict: Runtime Error):
def pow_mod(a, n, m): # (a^n) % m
    res = 1
    while n > 0:
        if n % 2 == 1:
            res = (res * a) % m
        a = (a * a) % m
        n = n // 2
    return res

def combi_mod(p, q, m):
    numerator, denominator = 1, 1
    for i in range(1, q+1):
        numerator *= (p - i + 1)
        numerator %= m
        denominator *= i
        denominator %= m
    return numerator * pow_mod(denominator, m-2, m) % m

n, a, b = list(map(int, input().split()))
res = pow_mod(2, n, M) - 1
res -=combi_mod(n, a, M)
if res < 0:
    res += M
res -= combi_mod(n, b, M)
if res < 0:
    res += M
print(res)

Fixed submission:
M = pow(10, 9) + 7

def pow_mod(a, n, m): # (a^n) % m
    res = 1
    while n > 0:
        if n % 2 == 1:
            res = (res * a) % m
        a = (a * a) % m
        n = n // 2
    return res

def combi_mod(p, q, m):
    numerator, denominator = 1, 1
    for i in range(1, q+1):
        numerator *= (p - i + 1)
        numerator %= m
        denominator *= i
        denominator %= m
    return numerator * pow_mod(denominator, m-2, m) % m

n, a, b = list(map(int, input().split()))
res = pow_mod(2, n, M) - 1
res -=combi_mod(n, a, M)
if res < 0:
    res += M
res -= combi_mod(n, b, M)
if res < 0:
    res += M
print(res)
Buggy python submission (verdict: Runtime Error):
import math

A, B, C, D = list(map(int, input().split()))
lcm = int(C * D /math.gcd(C, D))

num_lesser_than_A_non_dividable_by_C = (A - 1) - (A - 1) // C
num_lesser_than_A_non_dividable_by_D = (A - 1) - (A - 1) // D
num_lesser_than_A_non_dividable_by_C_or_D = (A - 1) - (A - 1) // lcm
num_lesser_than_A_dividable_by_C_nor_D = num_lesser_than_A_non_dividable_by_C + num_lesser_than_A_non_dividable_by_D - num_lesser_than_A_non_dividable_by_C_or_D
num_not_larger_than_than_B_non_dividable_by_C = B - B // C
num_not_larger_than_than_B_non_dividable_by_D = B - B // D
num_not_larger_than_than_B_non_dividable_by_C_or_D = B - B // lcm
num_not_larger_than_than_B_dividable_by_C_nor_D = num_not_larger_than_than_B_non_dividable_by_C + num_not_larger_than_than_B_non_dividable_by_D - num_not_larger_than_than_B_non_dividable_by_C_or_D
print(num_not_larger_than_than_B_dividable_by_C_nor_D - num_lesser_than_A_dividable_by_C_nor_D)

Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

A, B, C, D = list(map(int, input().split()))
lcm = int(C * D / gcd(C, D))

num_lesser_than_A_non_dividable_by_C = (A - 1) - (A - 1) // C
num_lesser_than_A_non_dividable_by_D = (A - 1) - (A - 1) // D
num_lesser_than_A_non_dividable_by_C_or_D = (A - 1) - (A - 1) // lcm
num_lesser_than_A_dividable_by_C_nor_D = num_lesser_than_A_non_dividable_by_C + num_lesser_than_A_non_dividable_by_D - num_lesser_than_A_non_dividable_by_C_or_D
num_not_larger_than_than_B_non_dividable_by_C = B - B // C
num_not_larger_than_than_B_non_dividable_by_D = B - B // D
num_not_larger_than_than_B_non_dividable_by_C_or_D = B - B // lcm
num_not_larger_than_than_B_dividable_by_C_nor_D = num_not_larger_than_than_B_non_dividable_by_C + num_not_larger_than_than_B_non_dividable_by_D - num_not_larger_than_than_B_non_dividable_by_C_or_D
print(num_not_larger_than_than_B_dividable_by_C_nor_D - num_lesser_than_A_dividable_by_C_nor_D)
Buggy python submission (verdict: Runtime Error):
dp = [0] * N

dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min([
        dp[i-1] + abs(H[i] - H[i-1]),
        dp[i-2] + abs(H[i] - H[i-2]),
    ])
    
print(dp[-1])

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

dp = [0] * N

dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min([
        dp[i-1] + abs(H[i] - H[i-1]),
        dp[i-2] + abs(H[i] - H[i-2]),
    ])
    
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())

for p in prospects:
    if p < n:
        continue
    if p >= n:
        print(p)
        break

Fixed submission:
n = int(input())
prospects = [111*i for i in range(1, 10)]

for p in prospects:
    if p < n:
        continue
    if p >= n:
        print(p)
        break
Buggy python submission (verdict: Runtime Error):

def gcd(a, b):
    if a < 0:
        a = -a
    if b < 0:
        b = -b
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
 

def reduce(function, iterable, initializer=None):
    it = iter(iterable)
    if initializer is None:
        value = next(it)
    else:
        value = initializer
    for element in it:
        value = function(value, element)
    return value

def gcd_list(ls):
    return reduce(gcd, ls)

N, X = list(map(int, input().split()))
xs = list(map(int, input().split()))
ys = [x - X for x in xs]

print(gcd_list(ys))

Fixed submission:
A, B = list(map(int, input().split()))
m = A * B

if m % 2 == 1:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import math
def main():
    i = int(input())
    j = list(map(int, input().split()))
    res = 1
    for jj in j:
        res *= jj

    if math.pow(10, 18) < res:
        print(-1)
    else:
        print(res)


if __name__ == "__main__":
    main()

Fixed submission:
import math
def main():
    i = int(input())
    j = list(map(int, input().split()))
    res = 1

    if 0 in j:
        print(0)
        return

    for jj in j:
        res *= jj
        if math.pow(10, 18) < res:
            print(-1)
            return

    print(res)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    n, k = map(int, input().split())
    nlis = list(map(int, input().split()))

    tmp = 1
    tl = []
    tl_a = tl.append

    if k < n:
        for i in range(k):
            tmp = nlis[tmp - 1]
        print(tmp)
    else:
        for i in range(n):
            if not nlis[tmp - 1] in tl:
                tl_a(nlis[tmp - 1])
                tmp = nlis[tmp - 1]
            else:
                tl = tl[tl.index(nlis[tmp - 1]):]
                print(tl[((k - i) % len(tl)) - 1])
                break

if __name__ == "__main__":
    main()

Fixed submission:
s= input()
t = input()
flag = True

for i in range(len(s)):
  if s[i] != t[i]:
    flag = False
    
print(['No', 'Yes'][flag])

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

def main():
    n, k = map(int, input().split())
    nlis = list(map(int, input().split()))

    tmp = 1
    tl = []
    tl_a = tl.append

    if k < n:
        for i in range(k):
            tmp = nlis[tmp - 1]
        print(tmp)
    else:
        for i in range(n):
            if not nlis[tmp - 1] in tl:
                tl_a(nlis[tmp - 1])
                tmp = nlis[tmp - 1]
            else:
                tl = tl[tl.index(nlis[tmp - 1]):]
                print(tl[((k - i) % len(tl)) - 1])
                break

if __name__ == "__main__":
    main()

Fixed submission:
s= input()
t = input()
flag = True

for i in range(len(s)):
  if s[i] != t[i]:
    flag = False
    
print(['No', 'Yes'][flag])
Buggy python submission (verdict: Runtime Error):
import math
X = int(input())
res = False
for A in range(1,1000):
    for B in range(-1000, A):
        if math.pow(A, 5) - math.pow(B, 5) == X:
            res = Trueå
            break

    if res:
        break

print(A, B)

Fixed submission:
import math
X = int(input())
res = False
for A in range(1,1000):
    for B in range(-1000, A):
        if math.pow(A, 5) - math.pow(B, 5) == X:
            res = True
            break

    if res:
        break

print(A, B)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
import sys
input = sys.stdin.readline

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

def main():
    _, m = map(int, input().split())
    a = list(map(int, input().split()))

    mlcm = lcm(a)

    for i in a:
        if (int(mlcm / i) % 2 == 0):
            print(0)
            return

    print(int((int(m * 2 / mlcm) + 1) / 2))

if __name__ == '__main__':
    main()

Fixed submission:
from fractions import gcd
import sys
input = sys.stdin.readline

def main():
    _, m = map(int, input().split())
    a = list(map(int, input().split()))

    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
        if i == 1:
            if (int(x / a[0]) % 2 == 0) or (int(x / a[i]) % 2 == 0):
                print(0)
                return
        else:
            if (int(x / a[i]) % 2 == 0):
                print(0)
                return

    print(int((int(m * 2 / x) + 1) / 2))

if __name__ == '__main__':
    main()

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

mlcm = 1
for i in a:
    mlcm = lcm(mlcm, i)

for i in a:
    if (int(mlcm / i) % 2 == 0):
        print(0)
        exit(0)

print(int((int(m * 2 / mlcm) + 1) / 2))

Fixed submission:
from fractions import gcd
import sys
input = sys.stdin.readline

def main():
    _, m = map(int, input().split())
    a = list(map(int, input().split()))

    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
        if i == 1:
            if (int(x / a[0]) % 2 == 0) or (int(x / a[i]) % 2 == 0):
                print(0)
                return
        else:
            if (int(x / a[i]) % 2 == 0):
                print(0)
                return

    print(int((int(m * 2 / x) + 1) / 2))

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

s = input()
s = s.replace('BC', 'D')
s = re.split('[BC]', s)
res = 0

for kk in s:
  if not kk:
    continue
  while 'AD' in kk:
    res += kk.count('AD')
    kk = kk.replace('AD', 'DA')
    
print(res)

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

s = input()
s = s.replace('BC', 'D')
s = re.split('[BC]', s)
res = 0

for kk in s:
  if not kk:
    continue
  d = 0
  for a in kk[::-1]:
    if a == 'D':
      d += 1
    else:
      res += d
    
print(res)

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

s = input()
s = s.replace('BC', 'D')
s = re.split('[BC]', s)
re = 0

for kk in s:
  if not kk:
    continue
  while 'AD' in kk:
    re += kk.count('AD')
    kk = kk.replace('AD', 'DA')
    
print(re)

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

s = input()
s = s.replace('BC', 'D')
s = re.split('[BC]', s)
res = 0

for kk in s:
  if not kk:
    continue
  d = 0
  for a in kk[::-1]:
    if a == 'D':
      d += 1
    else:
      res += d
    
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
res = s.count('ABC')

for i in range(len(s)):
  s = s.replace('ABC', 'BCA')
  res += s.count('ABC')
  if not 'ABC' in s:
    break
  
  
print(res)

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

s = input()
s = s.replace('BC', 'D')
s = re.split('[BC]', s)
res = 0

for kk in s:
  if not kk:
    continue
  d = 0
  for a in kk[::-1]:
    if a == 'D':
      d += 1
    else:
      res += d
    
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
res = s.count('ABC')

for i in range(len(s)):
  s = s.replace('ABC', 'BCA')
  res += s.count('ABC')
  
  
print(res)

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

s = input()
s = s.replace('BC', 'D')
s = re.split('[BC]', s)
res = 0

for kk in s:
  if not kk:
    continue
  d = 0
  for a in kk[::-1]:
    if a == 'D':
      d += 1
    else:
      res += d
    
print(res)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a =< 5:
  print(0)
elif a <= 12:
  print(int(b / 2))
else:
  print(b)

Fixed submission:
a, b = map(int, input().split())
 
if a <= 5:
  print(0)
elif a <= 12:
  print(int(b / 2))
else:
  print(b)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
lis = [1]*(n+2)
lis[0] = 0
lis[-1] = 0

for k in range(m):
  i, j = map(int, input().split())
  lis[:i] = [0]*(i)
  lis[j+1:] = [0]*(n - j + 2)
  
print(sum(lis))

Fixed submission:
n, m = map(int, input().split())
i = 0
j = n + 1

for k in range(m):
  ti, tj = map(int, input().split())
  if ti > i:
    i = ti
  if tj < j:
    j = tj

if j == 0 and i == 0:
  print(0)
else:
  print(max(j - i + 1, 0))
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
n = int(input())
li = list(map(int, input().split()))
lil = [0]*n
lir = [0]*n
for k in range(n):
  if k == 0:
    lil[k] = li[0]
    lir[k] = li[-1]
  else:
    lil[k] = gcd(lil[k-1], li[k])
    lir[k] = gcd(lir[k-1], li[-k-1])
    
lir = lir[::-1]
tmp = max(gcd(lil[j-1], lir[j+1]) for j in range(1, n-1))
print(max(tmp, lir[1], lil[-2]))

Fixed submission:
A, B, T = map(int, input().split())
print(int(T / A) * B)
Buggy python submission (verdict: Runtime Error):
import numpy as np
 
n, m, c = map(int, input().split())
 
mp = np.zeros((w, h))
b = list(map(int, input().split()))
num = 0
 
for i in range(n):
  A = list(map(int, input().split()))
  npb = np.array(b)
  npA = np.array(A)
  if np.dot(npA.T, npb) + c > 0:
    num += 1
    
print(num)

Fixed submission:
import numpy as np
 
n, m, c = map(int, input().split())
 
b = list(map(int, input().split()))
num = 0
 
for i in range(n):
  A = list(map(int, input().split()))
  npb = np.array(b)
  npA = np.array(A)
  if np.dot(npA.T, npb) + c > 0:
    num += 1
    
print(num)

Buggy python submission (verdict: Runtime Error):
import numpy as np

n, m, c = map(int, input().split())

mp = np.zeros((w, h))
b = list(map(int, input().split()))
num = 0

for i in range(n):
  A = list(map(int, input().split()))
  npb = np.array(b)
  npA = np.array(A)
  if np.dot(npA.T, npb) + c > 0:
    num++
    
print(num)

Fixed submission:
import numpy as np
 
n, m, c = map(int, input().split())
 
b = list(map(int, input().split()))
num = 0
 
for i in range(n):
  A = list(map(int, input().split()))
  npb = np.array(b)
  npA = np.array(A)
  if np.dot(npA.T, npb) + c > 0:
    num += 1
    
print(num)
Buggy python submission (verdict: Runtime Error):
N = int(input())
res = 0
for i in range(N):
  x, y = input().split()
  if y == 'JPY':
    res += int(x)
  else:
    res += int(x) * 380000
    
print(res)

Fixed submission:
N = int(input())
res = 0
for i in range(N):
  x, y = input().split()
  if y == 'JPY':
    res += int(x)
  else:
    res += float(x) * 380000
    
print(res)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

print(['No', 'Yes'][(b % 500) <= a]

Fixed submission:
a = int(input())
b = int(input())
print(['No', 'Yes'][(a % 500) <= b])
Buggy python submission (verdict: Runtime Error):
def ZZ(): return list(map(int, input().split()))
def Z(): return int(input())

A, B, C, K = ZZ()
S = [1] * A + [0] * B + [-1] * C
print(sum(S[:K]))

Fixed submission:
def ZZ(): return list(map(int, input().split()))
def Z(): return int(input())

A, B, C, K = ZZ()
ans = 1 * min(A, K)
K -= min(A, K)
ans += 0 * min(B, K)
K -= min(B, K)
ans += -1 * min(C, K)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
A = np.array(input().split(), np.int64)

ans = 0
for k in range(60):
  x = int(sum(A >> k & 1))
  ans += x * (N - x) * 2**k

print(ans % (10**9+7))


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

ans = 0

for k in range(60):
  cnt = [0] * 2
  for i in range(N):
    ans += cnt[(A[i] >> k & 1) ^ 1] << k
    cnt[A[i] >> k & 1] += 1

print(ans % (10 ** 9 + 7))

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

ans = 0

for k in range(60):
  cnt = [0] * 2
  for i in range(N):
    ans += cnt[(A[i] >> k & 1) ^ 1] << k
    cnt[A[i] >> k & 1] += 1

print(ans % (10 ** 9 + 7))



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

ans = 0

for k in range(60):
  cnt = [0] * 2
  for i in range(N):
    ans += cnt[(A[i] >> k & 1) ^ 1] << k
    cnt[A[i] >> k & 1] += 1

print(ans % (10 ** 9 + 7))
Buggy python submission (verdict: Runtime Error):
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))
C = [0] * 100000
C[0] = 3
答 = 1
for x in A:
  答 *= C[x]
  答 %= MOD
  C[x] -= 1
  C[x+1] += 1
print(答)


Fixed submission:
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))
C = [0] * 100001
C[0] = 3
答 = 1
for x in A:
  答 *= C[x]
  答 %= MOD
  C[x] -= 1
  C[x+1] += 1
print(答)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
edges = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
edges += [[i, i] for i in range(n)]

q = int(input())
color = [0] * q
dp = [[0 for j in range(n)] for i in range(11)]
for i in range(q):
    v, d, color[i] = map(int, input().split())
    dp[d][v - 1] = i
 
for i in reversed(range(1, 11)):
    for u, v in edges:
        dp[i - 1][u] = max(dp[i - 1][u], dp[i][v])
        dp[i - 1][v] = max(dp[i - 1][v], dp[i][u])
 
print(*[color[dp[0][i]] for i in range(n)], sep = '\n')

Fixed submission:
n = int(input())
a = list(reversed(sorted(
    map(int, input().split())
)))

print(sum(a[i * 2 + 1] for i in range(n)))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
edges = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
edges += [[i, i] for i in range(n)]

q = int(input())
color = [0] * q
dp = [[0 for j in range(n)] for i in range(11)]
for i in range(q):
    v, d, color[i] = map(int, input().split())
    dp[d][v - 1] = i
 
for i in reversed(range(1, 11)):
    for u, v in edges:
        dp[i - 1][u] = max(dp[i - 1][u], dp[i][v])
        dp[i - 1][v] = max(dp[i - 1][v], dp[i][u])
 
print(*[color[dp[0][i]] for i in range(n)], sep = '\n')

Fixed submission:

n, m = map(int, input().split())
edges = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

q = int(input())
vv = [None] * q
dd = [None] * q
cc = [None] * q
dp = [[-1 for j in range(11)] for i in range(n)]
for i in range(q):
    vv[i], dd[i], cc[i] = map(int, input().split())
    dp[vv[i] - 1][dd[i]] = i

for i in reversed(range(1, 11)):
    for j in range(n):
        dp[j][i - 1] = max(dp[j][i - 1], dp[j][i])
    for u, v in edges:
        dp[u][i - 1] = max(dp[u][i - 1], dp[v][i])
        dp[v][i - 1] = max(dp[v][i - 1], dp[u][i])

for i in range(n):
    if dp[i][0] == -1:
        print('0')
    else:
        print(cc[dp[i][0]])

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

n, m = map(int, input().split())
edges = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]
 
q = int(input())
vv = [None] * q
dd = [None] * q
cc = [None] * q
dp = np.array([[-1 for j in range(11)] for i in range(n)])
for i in range(q):
    vv[i], dd[i], cc[i] = map(int, input().split())
    dp[vv[i] - 1][dd[i]] = i
 
for i in reversed(range(1, 11)):
    for j in range(n):
        dp[j][i - 1] = max(dp[j][i - 1], dp[j][i])
    for u, v in edges:
        dp[u][i - 1] = max(dp[u][i - 1], dp[v][i])
        dp[v][i - 1] = max(dp[v][i - 1], dp[u][i])
 
for i in range(n):
    if dp[i][0] == -1:
        print('0')
    else:
        print(cc[dp[i][0]])

Fixed submission:

n, m = map(int, input().split())
edges = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

q = int(input())
vv = [None] * q
dd = [None] * q
cc = [None] * q
dp = [[-1 for j in range(11)] for i in range(n)]
for i in range(q):
    vv[i], dd[i], cc[i] = map(int, input().split())
    dp[vv[i] - 1][dd[i]] = i

for i in reversed(range(1, 11)):
    for j in range(n):
        dp[j][i - 1] = max(dp[j][i - 1], dp[j][i])
    for u, v in edges:
        dp[u][i - 1] = max(dp[u][i - 1], dp[v][i])
        dp[v][i - 1] = max(dp[v][i - 1], dp[u][i])

for i in range(n):
    if dp[i][0] == -1:
        print('0')
    else:
        print(cc[dp[i][0]])
Buggy python submission (verdict: Runtime Error):
import math
a, b, n = map(int, input().split())
if n < b:
    print(math.floor((a * n) / b))
else:
    print(math.floor((a * n) / (b - 1)))

Fixed submission:
import math
a, b, n = map(int, input().split())
if n < b:
    print(math.floor((a * n) / b))
else:
    print(math.floor(a * (b - 1) / b) - a * math.floor((b - 1) / b))
Buggy python submission (verdict: Runtime Error):
x, y, z = map(int, input().split())
print(c, a, b)

Fixed submission:
x, y, z = map(int, input().split())
print(z, x, y)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x_list = list(map(int, input().split()))
ans_list = [sum([(x - p) ** 2 for x in x_list]) for p in range(min(x_list), max(x_list)) + 1]
print(sorted(ans_list)[0])

Fixed submission:
n = int(input())
x_list = list(map(int, input().split()))
ans_list = [sum([(x - p) ** 2 for x in x_list]) for p in range(min(x_list), max(x_list) + 1)]
print(sorted(ans_list)[0])
Buggy python submission (verdict: Runtime Error):
h = int(input())
while 2 ** i <= h:
    i += 1
print(2 ** i - 1)

Fixed submission:
i = 0
h = int(input())
while 2 ** i <= h:
    i += 1
print(2 ** i - 1)