Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
trainlist = {}
for i in range(m):
    a, b = map(str, input().split())
    k = "".join([a.zfill(2), "-", b.zfill(2)])
    if k in trainlist:
        trainlist[k] = trainlist[k] + 1
    else:
        trainlist[k] = 1
        
for i in range(x):
    s, t = map(int, input().split())
    ans = 0
    for w in trainlist:
        if s <= int(w[0])*10+int(w[1]) and int(w[3])*10+int(w[4]) <= t:
            ans += trainlist[w]
    print(ans)

Fixed submission:
n, m, q = map(int, input().split())
ans = [[0]*n for _ in range(n)]
for i in range(m):
  l, r = map(int, input().split())
  ans[l-1][r-1] += 1

for i in range(n-1, -1, -1):
  for j in range(i+1, n):
    ans[i][j] += ans[i][j-1]
for i in range(n-1, -1, -1):
  for j in range(i+1, n):
    ans [i][j] += ans[i+1][j]

for _ in range(q):
  p, q = map(int, input().split())
  print(ans[p-1][q-1])

Buggy python submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
trainlist = {}
for i in range(m):
    a, b = map(str, input().split())
    k = "".join([a.zfill(2), "-", b.zfill(2)])
    if k in trainlist:
        trainlist[k] = trainlist[k] + 1
    else:
        trainlist[k] = 1
        
for i in range(x):
    s, t = map(int, input().split())
    ans = 0
    for w in trainlist:
        if s <= int(w[0])*10+int(w[1]) and int(w[3])*10+int(w[4]) <= t:
            ans += trainlist[w]
    print(ans)

Fixed submission:
n, m, q = map(int, input().split())
ans = [[0]*n for _ in range(n)]
for i in range(m):
  l, r = map(int, input().split())
  ans[l-1][r-1] += 1

for i in range(n-1, -1, -1):
  for j in range(i+1, n):
    ans[i][j] += ans[i][j-1]
for i in range(n-1, -1, -1):
  for j in range(i+1, n):
    ans [i][j] += ans[i+1][j]

for _ in range(q):
  p, q = map(int, input().split())
  print(ans[p-1][q-1])
Buggy python submission (verdict: Runtime Error):
from collections import deque
n = int(input())
ans = deque([])
while n > 0:
    if n % 2 == 0:
        ans.appendleft(0)
    else:
        ans.appendleft(1)
    n = n // 2
print("".join(ans))

Fixed submission:
n = int(input())
key = []
if n%2:
  key.append("1")
  n -= 1
else:
  key.append("0")

bef_p, bef_q = 0, 0
n //= 2
while n:
  k_p, k_q = (n//2)%2, n%2
  if k_p == 0:
    if k_q == 0:
      key.append("0")
      key.append("0")
      bef_p, bef_q = 0, 0
    else:       
      key.append("1")
      key.append("1")
      bef_p, bef_q = 0, 0      
  else:
    if k_q == 0:
      key.append("0")
      key.append("1")
      bef_p, bef_q = 0, 0
    else:
      key.append("1")
      key.append("0")
      bef_p, bef_q = 1, 1
  n //= 4
  n = n + bef_p*2-bef_q
key.reverse()
print(int("".join(key)))
Buggy python submission (verdict: Runtime Error):
import sys
from heapq import *
input = sys.stdin.readline

def main():
  n, m, s, t = map(int, input().split())
  
  tree = [[] for _ in range(n)]
  cost_yen = [[0]*n for _ in range(n)]
  cost_snuke = [[0]*n for _ in range(n)]
  for i in range(m):
    u, v, a, b = map(int, input().split())
    tree[u-1].append(v-1)
    tree[v-1].append(u-1)
    cost_yen[u-1][v-1] = a
    cost_yen[v-1][u-1] = a
    cost_snuke[u-1][v-1] = b
    cost_snuke[v-1][u-1] = b
  
  ans_yen = [0]*n
  ans_snuke = [0]*n
  
  for cost, start, ans in zip([cost_yen, cost_snuke], [s-1, t-1], [ans_yen, ans_snuke]):
    already = [False]*n
    not_yet = [(0, start)]
    
    while len(not_yet) > 0:
      c, p = heappop(not_yet)
      if already[p]:
        continue
      ans[p] = c
      already[p] = True
      
      for value in tree[p]:
        if already[value]:
          continue
        heappush(not_yet, (ans[p]+cost[p][value], value))
  
  ans = [0]*n
  sub = 10**15
  for i in range(n-1, -1, -1):
    sub = min(sub, ans_yen[i]+ans_snuke[i])
    ans[i] = sub
  
  sub = 10**15
  for a in ans:
    print(sub-a)
      
  
  
  
if __name__ == "__main__":
  main()

Fixed submission:
import sys
from heapq import *
input = sys.stdin.readline

def main():
  n, m, s, t = map(int, input().split())
  
  inf = pow(10, 15)
  
  tree = [[] for _ in range(n)]
  for i in range(m):
    u, v, a, b = map(int, input().split())
    tree[u-1].append((v-1, a, b))
    tree[v-1].append((u-1, a, b))
  
  ans_yen = [0]*n
  ans_snuke = [0]*n
  
  for start, ans in zip([s-1, t-1], [ans_yen, ans_snuke]):
    already = [False]*n
    not_yet = [(0, start)]
    
    while len(not_yet) > 0:
      c, p = heappop(not_yet)
      if already[p]:
        continue
      ans[p] = c
      already[p] = True
      
      for (value, a, b) in tree[p]:
        if already[value]:
          continue
        if start == s-1:
          cost = a
        else:
          cost = b
        heappush(not_yet, (c+cost, value))
  
  ans = [0]*n
  sub = inf
  for i in range(n-1, -1, -1):
    sub = min(sub, ans_yen[i]+ans_snuke[i])
    ans[i] = sub
  
  sub = inf
  for a in ans:
    print(sub-a)
      
  
  
  
if __name__ == "__main__":
  main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  import numpy as np
  n = int(input())
  a = np.array([int(x) for x in input().split()])
  a = a-np.array([int(i) for i in range(1, n+1)])
  a.sort()

  sum_0 = np.sum(np.abs(a-a[0]))
  sum_n = np.sum(np.abs(a-a[-1]))

  l, r = n//3, n*2//3

  while r-l > 1:
    sum_l = np.sum(np.abs(a-a[l]))
    sum_r = np.sum(np.abs(a-a[r]))
    if sum_l < sum_r:
      if sum_r > sum_0:
        r = l
        l = l//2
        sum_n = sum_r
      else:
        l = (r+l)//2
        sum_0 = sum_l
    else:
      if sum_l > sum_n:
        l = r
        r = (r+n)//2
        sum_0 = sum_l
      else:
        r = (r+l)//2
        sum_n = sum_r

  print(min([np.sum(np.abs(a-a[l])), np.sum(np.abs(a-a[r]))]))

if __name__ == "__main__":
   main()

Fixed submission:
import numpy as np
n = int(input())
a = np.array([int(x)-i-1 for x, i in zip(input().split(), range(n))])
ans = np.sum(np.abs(a-int(np.median(a))))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = np.array([int(x) for x in input().split()])
for i in range(n):
  a[i] -= i+1
a.sort()

sum_0 = np.sum(np.abs(a-a[0]))
sum_n = np.sum(np.abs(a-a[-1]))

l, r = n//3, n*2//3

while r-l > 1:
  sum_l = np.sum(np.abs(a-a[l]))
  sum_r = np.sum(np.abs(a-a[r]))
  if sum_l < sum_r:
    if sum_r > sum_0:
      r = l
      l = l//2
    else:
      l = (r+l)//2
      sum_0 = sum_l
  else:
    if sum_l > sum_n:
      l = r
      r = (r+n)//2
    else:
      r = (r+l)//2
      sum_n = sum_r

print(min([np.sum(np.abs(a-a[l])), np.sum(np.abs(a-a[r]))]))

Fixed submission:
import numpy as np
n = int(input())
a = np.array([int(x)-i-1 for x, i in zip(input().split(), range(n))])
ans = np.sum(np.abs(a-int(np.median(a))))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    s = [0]*(n+1)

    for i in range(n):
        s[i+1] += s[i] + a[i]
    
    ans = int(1e15)
    for i in range(n):
        sub = []
        for l, r, ll, rr in zip([0, i], [i, n], [0, i], [i, n]):
            while r-l > 1:
                k = (r+l) // 2
                if s[k] - s[ll] < s[rr] - s[k]:
                    l = k
                else:
                    r = k

            if abs(s[ll] + s[rr] - s[l]*2) > abs(s[ll] + s[rr] - s[r]*2):
                k = r
            else:
                k = l
            sub.append(s[k] - s[ll])
            sub.append(s[rr] - s[k])
        judge = max(sub) - min(sub)
        ans = min(ans, judge)
    
    print(ans)


    
if __name__ == "__main__":
    main()



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

def main():
    n = int(input())
    a = list(map(int, input().split()))
    s = [0]*(n+1)

    for i in range(n):
        s[i+1] += s[i] + a[i]
    
    ans = int(1e15)
    for i in range(n):
        sub = []
        for l, r, ll, rr in zip([0, i], [i, n], [0, i], [i, n]):
            while r-l > 1:
                k = (r+l) // 2
                if s[k] - s[ll] < s[rr] - s[k]:
                    l = k
                else:
                    r = k

            if abs(s[ll] + s[rr] - s[l]*2) > abs(s[ll] + s[rr] - s[r]*2):
                k = r
            else:
                k = l
            sub.append(s[k] - s[ll])
            sub.append(s[rr] - s[k])
        judge = max(sub) - min(sub)
        ans = min(ans, judge)
    
    print(ans)


    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
print((b-a)*(b-a-1)//2-a)

Fixed submission:
a, b = map(int, input().split())
print((b-a)*(b-a-1)//2-a)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(max[a*b, a-b, a+b])

Fixed submission:
a, b = map(int, input().split())
print(max([a*b, a-b, a+b]))
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = [int(x) for x in input().split()]

bit = int(math.log2(max(a+[1])))+1
key = [0]*bit
ans = 0
ans_bef = 0
for i in range(n):
  value = a[i]
  max_len = ans_bef
  for j in range(bit):
    if value%2 == 1:
      if max_len > key[j]:
        max_len = key[j]
      key[j] = 0
    else:
      key[j] += 1
    value //= 2
  ans_bef = max_len+1
  ans += max_len
      
ans += n
print(ans)

Fixed submission:
import math
n = int(input())
a = [int(x) for x in input().split()]

bit = int(math.log2(max(a+[1])))+1
key = [0]*bit
ans = 0
ans_bef = 0
for i in range(n):
  value = a[i]
  max_len = ans_bef
  for j in range(bit):
    if value%2 == 1:
      if max_len > key[j]:
        max_len = key[j]
      key[j] = 0
    else:
      key[j] += 1
    value //= 2
  ans_bef = max_len+1
  ans += max_len
      
ans += n
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import exit
n = int(input())
powlist = set()
k = 2
chance = True
while chance:
    for i in range(1, n):
        key = i**k
        if key <= n:
            powlist.add(key)
        else:
            k += 1
            judge = i
            break
    if judge == 2:
        chance = False
print(max(powlist))

Fixed submission:
from sys import exit
n = int(input())
powlist = set()
k = 2
chance = True
if n == 1:
    print(1)
    exit()
while chance:
    for i in range(1, n):
        key = i**k
        if key <= n:
            powlist.add(key)
        else:
            k += 1
            judge = i
            break
    if judge == 2:
        chance = False
print(max(powlist))
Buggy python submission (verdict: Runtime Error):
def change(n, word):
    for i in range(len(ans)-1, n, -1):
        ans[i] = ans[i-1]
    ans[n] = word

s = input()
k = int(input())
p = min(len(s), k)
key = s[:p]

for i in range(1, len(s)+1-p):
  if key > s[i:i+k]:
    key = s[i:i+k]

ans = [0]*k
for i in range(k):
  if i < p:
    ans[i] = key[:i+1]
  else:
    ans[i] = "zzzzzz"
for i in range(len(s)-p, len(s)):
    for j in range(i+1, len(s)+1):
        print(s[i:j])
        for t in range(k):
            if s[i:j] < ans[t] and s[i:j] not in ans:
                change(t, s[i:j])
print(ans[k])

Fixed submission:
def change(n, word):
    for i in range(len(ans)-1, n, -1):
        ans[i] = ans[i-1]
    ans[n] = word

s = input()
k = int(input())
p = min(len(s), k)
key = s[:p]

for i in range(1, len(s)+1-p):
  if key > s[i:i+k]:
    key = s[i:i+k]

ans = [0]*k
for i in range(k):
  if i < p:
    ans[i] = key[:i+1]
  else:
    ans[i] = "zzzzzz"
for i in range(len(s)-p, len(s)):
    for j in range(i+1, len(s)+1):
        for t in range(k):
            if s[i:j] < ans[t] and s[i:j] not in ans:
                change(t, s[i:j])
print(ans[k-1])
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
m = [0]*n
for i in range(n):
  	m[i] = int(input())
m.sort()
ans = 0
flag = False
while x > 0:
    for i in range(n):
        if x >= m[i]:
        	x -= m[i]
            ans += 1
        else:
            flag = True
            break
    if flag:
        break
    key = m[0]
    while x > 0:
        if x >= key:
            x -= key
            ans += 1
        else:
            flag = True
            break
    if flag:
        break
print(ans)

Fixed submission:
n, x = map(int, input().split())
m = [0]*n
for i in range(n):
  	m[i] = int(input())
m.sort()
ans = 0
flag = False
while x > 0:
    for i in range(n):
        if x >= m[i]:
            x -= m[i]
            ans += 1
        else:
            flag = True
            break
    if flag:
        break
    key = m[0]
    while x > 0:
        if x >= key:
            x -= key
            ans += 1
        else:
            flag = True
            break
    if flag:
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = map(int, input().split())
x2 = sorted(x)
ans1, ans2 = x2[n//2-1], x2[n//2]
for i in range(n):
    if x[i] <= ans1:
        print(ans2)
    else:
        print(ans1)

Fixed submission:
n = int(input())
x = [int(x) for x in input().split()]
x2 = sorted(x)
ans1, ans2 = x2[n//2-1], x2[n//2]
for i in range(n):
    if x[i] <= ans1:
        print(ans2)
    else:
        print(ans1)
Buggy python submission (verdict: Runtime Error):
def nCr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1: 
            result *= numerator[k]
    return result

n = int(input())
a = list(int(x) for x in input().split())
a.sort()
key = []
key1 = a[0]
key2 = 1000000007
for i in range(1, n):
    key3 = a[i] - a[i-1]
    if key3 < key1 and key3 < key2:
        key2 = key3
        key.append([a[i], a[i-1]])
key.append([a[1], a[0]])
ans = 0
answer = 0
for value in key:
    i, j = value[0], value[1]
    k = nCr(i, j)
    if ans:
        if k < ans:
            ans = k
            answer = [i, j]
    else:
        ans = k
        answer = [i, j]
for i in range(2):
    print(answer[i], end=" ")

Fixed submission:
n = int(input())
a = list(int(x) for x in input().split())
a.sort()

a_i = a[-1]

key_small, key_large = 0, n-1
border = a_i//2
while key_small < key_large-1:
    key = (key_small+key_large)//2
    if a[key] <= border:
        key_small = key
    else:
        key_large = key

p, q = a[key_small], a[key_large]

judge = a_i / 2
if abs(p-judge) < abs(q-judge):
    a_j = p
else:
    a_j = q
if a_i == a_j:
    a_j = 0
print(a_i, a_j)

Buggy python submission (verdict: Runtime Error):
def nCr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1: 
            result *= numerator[k]
    return result

n = int(input())
a = list(int(x) for x in input().split())
a.sort()
ans = 0
for i in range(1, n):
    value = a[i]
    key = min([value-a[0], value-a[i-1]])
    judge = nCr(value, key)
    if ans:
        if judge < ans:
            ans = judge
    else:
        ans = judge
print(ans)

Fixed submission:
n = int(input())
a = list(int(x) for x in input().split())
a.sort()

a_i = a[-1]

key_small, key_large = 0, n-1
border = a_i//2
while key_small < key_large-1:
    key = (key_small+key_large)//2
    if a[key] <= border:
        key_small = key
    else:
        key_large = key

p, q = a[key_small], a[key_large]

judge = a_i / 2
if abs(p-judge) < abs(q-judge):
    a_j = p
else:
    a_j = q
if a_i == a_j:
    a_j = 0
print(a_i, a_j)
Buggy python submission (verdict: Runtime Error):
n = int(input())
d, x = map(int, input().split())
ans = x
for i in range(n):
    a = int(input())
	ans += (d-1)//a+1
    
print(ans)

Fixed submission:
n = int(input())
d, x = map(int, input().split())
ans = x
for i in range(n):
    a = int(input())
    ans = ans+(d-1)//a+1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().solit()]
ans = a[0]+sum(b)
sub = ans
for i in range(1, n):
  sub += a[i]
  sub -= b[i-1]
  if ans < sub:
    ans = sub
print(ans)

Fixed submission:
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]
    ans = a[0]+sum(b)
    sub = ans
    for i in range(1, n):
        sub += a[i]
        sub -= b[i-1]
        if ans < sub:
            ans = sub
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().solit()]
ans = a[0]+sub(b)
sub = ans
for i in range(1, n):
  sub += a[i]
  sub -= b[i-1]
  if ans < sub:
    ans = sub
print(ans)

Fixed submission:
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]
    ans = a[0]+sum(b)
    sub = ans
    for i in range(1, n):
        sub += a[i]
        sub -= b[i-1]
        if ans < sub:
            ans = sub
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a, b =(int, input().split())
if (a*b)%2:
  print("Odd")
else:
  print("Even")

Fixed submission:
a, b = map(int, input().split())
print("Odd" if a*b%2 else "Even")
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
letters_s = []
letters_t = []
for i in range(len(s)):
  letters_s.append(s[i])
letters_s.sort()
for i in range(len(t)):
  letters_t.append(len(t))
letters_t.sort(reverse=True)
ss = "".join(letters_s)
tt = "".join(letters_t)
if ss < tt:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
t = input()
letters_s = []
letters_t = []
for i in range(len(s)):
  letters_s.append(s[i])
letters_s.sort()
for i in range(len(t)):
  letters_t.append(t[i])
letters_t.sort(reverse=True)
ss = "".join(letters_s)
tt = "".join(letters_t)
if ss < tt:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
ans = 1
for i in range(n):
  ans = min([ans*2, ans+k])
print(ans)

Fixed submission:
n = int(input())
k = int(input())
ans = 1
for i in range(n):
  ans = min([ans*2, ans+k])
print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int(input()))
ans = 1
for i in range(n):
  ans = min([ans*2, ans+k])
print(ans)

Fixed submission:
n = int(input())
k = int(input())
ans = 1
for i in range(n):
  ans = min([ans*2, ans+k])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for h in range(1, 3501):
  for n in range(1, 3501):
    if 4*n*h-N*n-N*h == 0:
      continue
    w = N*h*n/(4*n*h-N*n-N*h)
    if w > 0 and w.is_integer():
      ans = [n, h, int(w)]
print(*ans)

Fixed submission:
N = int(input())

for h in range(1, 3501):
  for n in range(1, 3501):
    if 4*n*h-N*n-N*h == 0:
      continue
    w = N*h*n/(4*n*h-N*n-N*h)
    if w > 0 and w.is_integer():
      ans = [n, h, int(w)]
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
road = [0]*n
for i in range(n):
  road[i] = [int(x) for x in input().split()]

road_judge = [[True]*n for i in range(n)]
for k in range(n):
  for i in range(n):
    for j in range(n):
      if road[i][j] > road[i][k]+road[k][j]:
        print(-1)
        sys.exit()
      if road[i][j] == road[i][k]+road[k][j] and i != k and j != k:
        road_judge[i][j] = False
ans = 0
for i in range(n):
  for j in range(n):
    if road_judge[i][j]:
      ans += road[i][j]
print(ans//2)

Fixed submission:
import sys
n = int(input())
road = [0]*n
for i in range(n):
  road[i] = [int(x) for x in input().split()]

road_judge = [[True]*n for i in range(n)]
for k in range(n):
  for i in range(n):
    for j in range(n):
      if road[i][j] > road[i][k]+road[k][j]:
        print(-1)
        sys.exit()
      if road[i][j] == road[i][k]+road[k][j] and i != k and j != k:
        road_judge[i][j] = False
ans = 0
for i in range(n):
  for j in range(n):
    if road_judge[i][j]:
      ans += road[i][j]
print(ans//2)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n, m, r = map(int, input().split())
R = [int(x) for x in input().split()]
inf = pow(10, 9)+7

roads = [[inf]*n for _ in range(n)]
for i in range(m):
  a, b, c = map(int, input().split())
  roads[a-1][b-1] = c
  roads[b-1][a-1] = c

for k in range(n):
  for i in range(n):
    for j in range(n):
      if roads[i][j] > roads[i][k]+roads[k][j]:
        roads[i][j] = roads[i][k]+roads[k][j]

ans = inf
for value in itertools.permutations(R):
  sub = 0
  for k in range(r-1):
    sub += roads[value[k]-1][value[k+1]-1]
  if ans > sub:
    ans = sub

print(ans)

Fixed submission:
import itertools
n, m, r = map(int, input().split())
R = [int(x) for x in input().split()]
inf = pow(10, 9)+7

roads = [[inf]*n for _ in range(n)]
for i in range(m):
  a, b, c = map(int, input().split())
  roads[a-1][b-1] = c
  roads[b-1][a-1] = c

for k in range(n):
  for i in range(n):
    for j in range(n):
      if roads[i][j] > roads[i][k]+roads[k][j]:
        roads[i][j] = roads[i][k]+roads[k][j]

ans = inf
for value in itertools.permutations(R):
  sub = 0
  for k in range(r-1):
    sub += roads[value[k]-1][value[k+1]-1]
  if ans > sub:
    ans = sub

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
print("".join([str(s[2*i+1]) for i in range((len(s)+1)//2)]))

Fixed submission:
s = input()
ans = ""
for i in range(len(s)):
  if i%2 == 0:
    ans = ans + s[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
ans = 0
for i in range(n):
  if i == n-1 and a[i] == n:
    ans += 1
  if a[i] == i+1:
    ans += 1
    a[i], a[i+1] = a[i+1], a[i]
print(ans)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
ans = 0
for i in range(n):
  if i == n-1 and a[i] == n:
    ans += 1
  elif a[i] == i+1:
    ans += 1
    a[i], a[i+1] = a[i+1], a[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
def gcd(p, q):
    if p < q:
        p, q = q, p
    while q > 0:
        p, q = q, p%q
    return p

n = int(input())
ans = 1
for i in range(n):
  t = int(input())
  ans = a*t//gcd(a, t)
print(ans)

Fixed submission:
def gcd(p, q):
    if p < q:
        p, q = q, p
    while q > 0:
        p, q = q, p%q
    return p

n = int(input())
ans = 1
for i in range(n):
  t = int(input())
  ans = ans*t//gcd(ans, t)
print(ans)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd
n = int(input())
ans = 1
for i in range(n):
  t = int(input())
  ans = a*t//gcd(a, t)
print(ans)

Fixed submission:
def gcd(p, q):
    if p < q:
        p, q = q, p
    while q > 0:
        p, q = q, p%q
    return p

n = int(input())
ans = 1
for i in range(n):
  t = int(input())
  ans = ans*t//gcd(ans, t)
print(ans)
Buggy python submission (verdict: Runtime Error):
from fructions import gcd

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

if c%gcd(a, b):
  print("NO")
else:
  print("YES")

Fixed submission:
from fractions import gcd

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

if c%gcd(a, b):
  print("NO")
else:
  print("YES")
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
n = len(s)
for i in range(n):
  if i%2:
    print(t[i], end="")
  else:
    print(s[i], end="")
print()

Fixed submission:
s = input()
t = input()
n = len(t)
for i in range(n):
  print(s[i], end="")
  print(t[i], end="")
if len(s) != len(t):
  print(s[-1], end="")
print()

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
n = len(s)
for i in range(n):
  if i%2:
    print(s[i], end="")
  else:
    print(t[i], end="")
print()

Fixed submission:
s = input()
t = input()
n = len(t)
for i in range(n):
  print(s[i], end="")
  print(t[i], end="")
if len(s) != len(t):
  print(s[-1], end="")
print()