Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03324 (python)

Fixed submission:
d,n = map(int,input().split())
 
if d == 0:
  if n == 100:
    print(101)
  else:
    print(n)
elif d == 1:
  if n == 100:
    print(10100)
  else:
    print(100*n)
elif d == 2:
  if n == 100:
    print(1010000)
  else:
    print(10000*n)

Buggy submission (verdict: Runtime Error):
d,n = map(int,input()split())
 
if d == 0:
  if n == 100:
    print(101)
  else:
    print(n)
elif d == 1:
  if n == 100:
    print(10001)
  else:
    print(100*n)
elif d == 2:
  if n == 100:
    print(1000001)
  else:
    print(10000*n)

Buggy submission (verdict: Runtime Error):
d,n = map(int,input())

if d == 0:
  print(n)
elif d == 1:
  print(100*n)
elif d == 2:
  print(10000*n)
Problem p03338 (python)

Fixed submission:
n = int(input())
s = input()
c = 0
tmp = 0

for i in range(1,n):
  s1 = list(set(s[:i]))
  s2 = list(set(s[i:]))
  for j in s1:
    if j in s2:
      tmp += 1
  if tmp > c:
    c = tmp
  tmp = 0
  
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
c = 0

for i in range(1,n):
  s1 = set(s[:i])
  s2 = set(s[i:])
  w = lin(s1&s2)
  if w > c:
    c = w
    
print(c)
Problem p03351 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
if abs(a-c) <= d:
  print("Yes")
elif abs(a-b) <= d and abs(b-c) <= d:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input()
K = int(input())
k = []

for i in range(len(s)):
  if s[i] not in k:
    k.append(s[i])
  
if len(s) >= 2:
  for i in range(len(s)-1):
    if s[i] + s[i+1] not in k:
      k.append(s[i] + s[i+1])
    
if len(s) >= 3:
  for i in range(len(s)-2):
    if s[i] + s[i+1] + s[i+2] not in k:
      k.append(s[i] + s[i+1] + s[i+2])
    
if len(s) >= 4:
  for i in range(len(s)-3):
    if s[i] + s[i+1] + s[i+2] + s[i+3] not in k:
      k.append(s[i] + s[i+1] + s[i+2] + s[i+3])
    
if len(s) >= 5:
  for i in range(len(s)-4):
    if s[i] + s[i+1] + s[i+2] +s[i+3] + s[i+4] not in k:
      k.append(s[i] + s[i+1] + s[i+2] +s[i+3] + s[i+4])
    
new = sorted(k)

print(new[K-1])
Problem p03359 (python)

Fixed submission:
a,b = map(int,input().split())
if a > b:
  print(a-1)
elif a == b:
  print(a)
else:
  print(a)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())
if a >= b:
  print(a)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())
if a == b or a > b:
  print(a)
else:
  print(b)
Problem p03361 (python)

Fixed submission:
h,w = map(int,input().split())
s = [["."]+list(input())+["."] for i in range(h)]

for i in range(h):
  for j in range(1,w+1):
    if i == 0:
      if s[i][j]=="#" and s[i][j+1]=="." and s[i][j-1]=="." and s[i+1][j]==".":
        print("No")
        exit()
    elif i == h-1:
      if s[i][j]=="#" and s[i][j+1]=="." and s[i][j-1]=="." and s[i-1][j]==".":
        print("No")
        exit()
    else:
      if s[i][j]=="#" and s[i][j+1]=="." and s[i][j-1]=="." and s[i+1][j]=="." and s[i-1][j]==".":
        print("No")
        exit()
        
print("Yes")

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
s = [["."]+list(input())+["."] for i in range(h)]

for i in range(h):
  for j in range(1,w+1):
    if i == 0:
      if s[i][j]=="#" and s[i][j+1]=="." and s[i][j-1]=="." and s[i+1][j]==".":
        print("No")
        exit()
    elif i == h-1:
      if s[i][j]=="#" and s[i][j+1]=="." and s[i][j-1]=="." and s[i+1][j]==".":
        print("No")
        exit()
    else:
      if s[i][j]=="#" and s[i][j+1]=="." and s[i][j-1]=="." and s[i+1][j]=="." and s[i-1][j]==".":
        print("No")
        exit()
        
print("Yes")
Problem p03369 (python)

Fixed submission:
a = input().count("o")
print(700 + int(a)*100)

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
m = sorted([int(input()) for i in range(n)])
newx = x - sum(m)
c = n

for j in range(100):
  for i in m:
    newx -= i
    c +=1
    if newx < x - sum(m):
      break
if newx < x - sum(m):
  break
    
print(c-1)
Problem p03370 (python)

Fixed submission:
n,x = map(int,input().split())
m = sorted([int(input()) for i in range(n)])
newx = x - sum(m)
c = n
 
for i in range(114514):
  newx -= m[0]
  c += 1
  if newx < 0 :
    break

print(c-1)

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
m = sorted([int(input()) for i in range(n)])
newx = x - sum(m)
c = n
 
for j in range(100):
  for i in m:
    newx -= i
    c +=1
    if newx < x - sum(m):
      break
if newx < x - sum(m):
  break
    
print(c-1)
Problem p03377 (python)

Fixed submission:
A,B,X = map(int,input().split())
if A <= X <= A+B :
  print("YES")
else :
  print("NO")

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

a.append(x)
a = sorted(a)

if len(a[:a.index(x)]) >= len(a[-(a.index(x)+1):]):
  print(len(a[-(a.index(x)+1):]))
else:
  print(len(a[:a.index(x)]))
Problem p03378 (python)

Fixed submission:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
c = 0
d = m

for i in range(m):
  if a[i] < x:
    c += 1
    d -= 1

if c >= d:
  print(d)
else:
  print(c)

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

a.append(x).sort()

if len(a[:a.index(x)]) >= len(a[-(a.index(x)+1):]):
  print(len(a[-(a.index(x)+1):]))
else:
  print(len(a[:a.index(x)]))
Problem p03385 (python)

Fixed submission:
print("Yes" if len(set(input())) == 3 else "No")

Buggy submission (verdict: Runtime Error):
print("Yes" if len(set(input())) == 3 "No" else)

Buggy submission (verdict: Runtime Error):
if input() = "abc" or "acb" or "cba" or "bac" or "bca" or "cab":
  print(Yes)
else:
  print(No)
Problem p03386 (python)

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

if (b-a)//2 + 1 <= k:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a,a+k):
    print(i)
  for j in range(b-k+1,b+1):
    print(j)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
l = list(range(a,b+1))
newl = sorted(list(set(l[:k] + l[-k:])))

for i in newl:
  print(i)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
l = list(range(a,b+1))
newl = list(set(l[:k] + l[-k:]))

for i in newl:
  print(i)
Problem p03387 (python)

Fixed submission:
a = list(map(int,input().split()))
a.sort()
count= 0

if a[2] != a[1] and a[1] != a[0] and a[2] != a[0]:
  sum = a[2]-a[1]
  for i in range(a[2]-a[1]):
    a[1] += 1
    a[0] += 1  
  for i in range(10**12):
    a[0] += 2
    count += 1
    if a[0] >= a[1]:
      break
      
  if a[0] == a[1]:
    print(sum + count)
  elif a[0] > a[1]:
    print(sum + count + 1)

elif a[2] == a[1] and a[1] != a[0]:
  for i in range(10**4):
    a[0] += 2
    count += 1
    if a[0] >= a[1]:
      break
  
  if a[0] == a[1]:
    print(count)
  elif a[0] > a[1]:
    print(count + 1)
    
elif a[0] == a[1] and a[1] != a[2]:
  print(a[2]-a[1])
  
elif a[1] == a[2] and a[2] == a[0]:
  print(0)

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
a.sort()
count= 0

if a[2] != a[1] and a[1] != a[0] and a[2] != a[0]:
  sum = a[2]-a[1]
  for i in range(a[2]-a[1]):
    a[1] += 1
    a[0] += 1  
  for i in range(10**12):
    a[0] += 2
    count += 1
    if a[0] >= a[1]:
      break
      
  if a[0] == a[1]:
    print(sum + count)
  elif a[0] > a[1]:
    print(sum + count + 1)

elif a[2] == a[1] and a[1] != a[0]:
  for i in range(10**4):
    a[0] += 2
    count += 1
    if a[0] >= a[1]:
      break
  
  if a[0] == a[1]:
    print(count)
  elif a[0] > a[1]:
    print(count + 1)
    
elif a[0] == a[1] amd a[1] != a[2]:
  print(a[2]-a[1])
  
elif a[1] == a[2] and a[2] == a[0]:
  print(0)
Problem p03434 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
suma = 0
sumb = 0
a.sort(reverse = True)
 
for i in range(len(a)):
  if i%2 == 0:
    suma += a[i]
  else:
    sumb += a[i]
    
print(suma-sumb)

Buggy submission (verdict: Runtime Error):

n = int(input())
a = list(map(int,input().split()))
suma = 0
sumb = 0
a.sort(reverse == True)
 
for i in range(len(a)):
  if a[i]%2 == 0:
    suma += a[i]
  else:
    sumb += a[i]
    
print(suma-sumb)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
suma = 0
sumb = 0
a.sort(reverse == True)

for i in range(len(a)):
  if a[i]%2 == 0:
    suma += a[i]
  else:
    sumb += a[i]
    
print(suma-sumb)
Problem p03474 (python)

Fixed submission:
a,b = map(int,input().split())
n = list(input())
 
if n[a] == '-' and '-' not in n[:a] and '-' not in n[a+1:]:
  print('Yes')
else:
  print('No')

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

if n[a] == '-' and '-' not in n[:a] and '-' not in n[a+1:]
  print('Yes')
else:
  print('No')
Problem p03478 (python)

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

sum1 = 0

for i in range(1,n+1):
  sum = 0
  N = list(str(i))
  for j in N:
    sum += int(j)
  
  if a<=sum <= b:
    sum1 += i
    
print(sum1)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
sum = 0
sum1 = 0

for i in range(1,n+1):
  N = list(str(i))
   for i in N:
      sum += int(i)
  if a<=sum <= b:
    sum1 += sum
    
print(sum1)
Problem p03486 (python)

Fixed submission:
s = list(input())
t = list(input())


for i in range(101):
  if min(s) > max(t):
    print('No')
    exit()
    
  elif min(s) == max(t):
    s.remove(min(s))
    t.remove(max(t))
    if s == [] and t != []:
      print('Yes')
      exit()
    elif s == [] and t == []:
      print('No')
      exit()
    elif s != [] and t == []:
      print('No')
      exit()
  if min(s) < max(t):
    print('Yes')
    exit()

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())


for i in range(101):
  if min(s) > max(t):
    print('No')
    exit()
    
  elif min(s) == max(t):
    s.remove(min(s))
    t.remove(max(t))
    if s == [] and t != []:
      print('Yes')
      exit()
    elif s == [] and t == []:
      print('No')
      exit()
    
  if min(s) < max(t):
    print('Yes')
    exit()
Problem p03494 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
count = 0

for i in range(10**10):
  for j in range(n):
    if a[j]%2 != 0:
      print(count)
      exit()
    else:
      a[j] = a[j]//2
  count += 1

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

for i in range(10**10):
  for j in range(n):
    if a[j]%2 != 0:
      print(count)
      exit()
    else:
      a[j] = a//2
  count += 1
Problem p03502 (python)

Fixed submission:
n = input()
N = list(n)
sum = 0
for i in N:
  sum += int(i)
  
if int(n)%sum == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = list(input())
sum = 0
for i in n:
  sum += int(i)
  
if sum%int(n) == 0:
  print('Yes')
else:
  print('No')
Problem p03547 (python)

Fixed submission:
x,y = map(str,input().split())
if x > y:
  print('>')
elif x < y:
  print('<')
else:
  print('=')

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
if x > y:
  print('>')
elif x < y:
  print('<')
else:
  print('==')
Problem p03555 (python)

Fixed submission:
c1 = input()
c2 = input()

if c1[2] + c1[1] + c1[0] == c2:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
c1 = input()
c2 = input()

if ''.join(list(c1).reverse()) == c2:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
c1 = input()
c2 = input()

if c1.reverse() == c2:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
c1 = input()
c2 = input()

if c1.reverse() == c2:
  print('YES')
else:
  print('NO)
Problem p03611 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
dict = {}
ans = 0

for i in range(n):
  if a[i] not in dict:
    dict[a[i]] = 1
  else:
    dict[a[i]] += 1

l = sorted(dict.items())
l += [(-1,0),(-2,0)]

for j in range(len(l)-2):
  if l[j][0]+1 == l[j+1][0] and l[j][0]+2 == l[j+2][0]:
     ans = max(ans,l[j][1]+l[j+1][1]+l[j+2][1])
  elif l[j][0]+1 == l[j+1][0] and l[j][0]+2 != l[j+2][0]:
     ans = max(ans,l[j][1]+l[j+1][1])
  elif l[j][0]+1 != l[j+1][0] and l[j][0]+2 != l[j+2][0]:
     ans = max(ans,l[j][1])
   
  
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
dict = {}
ans = 0

for i in range(n):
  if a[i] not in dict:
    dict[a[i]] = 1
  else:
    dict[a[i]] += 1

l = sorted(dict.items())
l += [(-1,0),(-2,0)]

for j in range(len(l)-2):
  if l[i][0]+1 == l[i+1][0] and l[i][0]+2 == l[i+2][0]:
     ans = max(ans,l[j][1]+l[j+1][1]+l[j+2][1])
  elif l[i][0]+1 == l[i+1][0] and l[i][0]+2 != l[i+2][0]:
     ans = max(ans,l[j][1]+l[j+1][1])
  elif l[i][0]+1 != l[i+1][0] and l[i][0]+2 != l[i+2][0]:
     ans = max(ans,l[j][1])
   
  
print(ans)
Problem p03624 (python)

Fixed submission:
s = input()
alpha = 'abcdefghijklmnopqrstuvwxyz'
 
for i in list(alpha):
  if i not in s:
    print(i)
    exit()
    
print('None')

Buggy submission (verdict: Runtime Error):
s = input()
alpha = abcdefghijklmnopqrstuvwxyz

for i in list(alpha):
  if i not in s:
    print(i)
    exit()
    
print('None')
Problem p03693 (python)

Fixed submission:
n = ''.join(list(map(str,input().split())))
if int(n)%4 == 0:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
n = ''.join(list(map(int,input().split())))
if int(n)%4 == 0:
  print('YES')
else:
  print('NO')
Problem p03815 (python)

Fixed submission:
x = int(input())
x11 = x/11
num = [1,2,3,4,5,6]
num2= [7,8,9,10]

if x in num:
  print(1)
  exit()
elif x in num2:
  print(2)
  exit()

elif int(x11) == x11:
  print(int(x11)*2)
  exit()
elif x > int(x11)*11 + 6:
  print(int(x11)*2 +2)
  exit()
else:
  print(1+int(x11)*2)
  exit()

Buggy submission (verdict: Runtime Error):
x = int(input())
x11 = x/11
num = [1,2,3,4,5,6]
num2= [7,8,9,10]

if x in num:
  print(1)
elif x in num2:
  print(2)

elif int(x11) == x11:
  print(int(x11)*2)
elif x+5 >int(x11)*2 + 6 >= x
  print(1+int(x11)*2)
else:
  print(2+int(x11)*2)
Problem p03854 (python)

Fixed submission:
from collections import deque

s = input()
q = deque(list(s))

while q:
  if len(q) >= 5:
    subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft()
    if subs != 'erase' and subs != 'dream':
      print('NO')
      exit()
    if subs == 'erase' and len(q) != 0 and q[0] == 'r':
      q.popleft()
    if subs == 'dream' and len(q) == 2 and q[0]+q[1] == 'er':
      q.popleft()
      q.popleft()
    if subs == 'dream' and len(q) >= 3 and q[0]+q[1] == 'er' and q[2] != 'a':
      q.popleft()
      q.popleft()
  else:
   
    print('NO')
    exit()
    
print('YES')

Buggy submission (verdict: Runtime Error):
from collections import deque

s = input()
q = deque(list(s))

while q:
  if len(q) >= 5:
    subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft()
    if subs != 'erase' and subs != 'dream':
      print('NO')
      exit()
    if subs == 'erase' and len(q) != 0 and q[0] == 'r':
      q.popleft()
    if subs == 'dream' and len(q) == 2 and q[0]+q[1] == 'er':
      q.popleft()
      q.popleft()
    if subs == 'dream' and len(q) >= 3 and q[0]+q[1] == 'er' and q[2] != e:
      q.popleft()
      q.popleft()
  else:
    print('NO')
    exit()
    
print('YES')
Problem p02607 (python)

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

ans = 0
for i in range(0, N, 2):
    if A[i] % 2 == 1:
        ans += 1
print(ans)

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

ans = 0
for i in range(0, N+1, 2):
    if A[i] % 2 == 1:
        ans += 1
print(ans)
Problem p02691 (python)

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

D = defaultdict(int)

ans = 0

for i, a in enumerate(A):
    ans += D[i-a]
    D[i+a] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import numpy as np
N = int(input())
A = list(map(int, input().split()))

D = defaultdict(int)

ans = 0

for i, a in enumerate(A):
    ans += D[i-a]
    D[i+a] += 1

print(ans)
Problem p02755 (python)

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

ans = -1
i = 1
while i < 2000:

    a = int(i * 1.08) - i
    b = int(i * 1.1) - i
    if A == a and B == b:
        ans = i
        break
    i += 1
print(ans)

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

S = input().strip()
Q = int(input())

reverse = False

before = ""
after = ""

for _ in range(Q):
    s = input().strip()
    if s[0] == "1":
        reverse = not reverse
    else:
        _, f, c = s.split()
        if f == "1":
            if reverse:
                after = after + c
            else:
                before = c + before
        else:
            if reverse:
                before = c + before
            else:
                after = after + c

if reverse:
    print(after[::-1] + S[::-1] + before[::-1])
else:
    print(before + S + after)
Problem p02803 (python)

Fixed submission:
from collections import deque
import sys
input = sys.stdin.readline

H, W = list(map(int, input().split()))
S = ["#" * (W+2)] + ["#" + input().strip() +
                     "#" for _ in range(H)] + ["#" * (W+2)]

ans = 0

for j in range(1, H+1):
    for i in range(1, W+1):
        if S[j][i] != ".":
            continue
        m = [[-1] * (W+2) for _ in range(H+2)]

        q = deque()
        q.append((j, i, 0))
        m[j][i] = 0

        while q:
            y, x, v = q.popleft()
            if ans < v:
                ans = v
            for dj, di in ((y, x+1), (y, x-1), (y+1, x), (y-1, x)):
                if S[dj][di] == "#" or m[dj][di] != -1:
                    continue
                q.append((dj, di, v+1))
                m[dj][di] = v+1
print(ans)

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

H, W = list(map(int, input().split()))
S = []
for _ in range(H):
    S.append(input())

ans = 0

d = ([0, 1], [0, -1], [1, 0], [-1, 0])


def bfs(x, y):
    m = np.full((H, W), dtype=np.int)

    q = deque()
    q.append([y, x, 0])
    maximus = 0

    while q:
        j, i, v = q.popleft()
        m[j][i] = v
        for dd in d:
            dj = j + dd[0]
            di = i + dd[1]
            if 0 <= dj < H and 0 <= di < W and m[dj][di] == -1 and S[dj][di] == ".":
                q.append([dj, di, v+1])
                if maximus < v+1:
                    maximus = v+1

    return maximus


for j in range(H):
    for i in range(W):
        if S[j][i] != ".":
            continue
        ans = max(ans, bfs(i, j))
print(ans)
Problem p02804 (python)

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

mod = 10 ** 9 + 7

f = [i for i in range(N+1)]
for i in range(2, N+1):
    f[i] *= f[i-1]
    f[i] %= mod
f[0] = 1

q = K - 1
fk = pow(f[q], mod - 2, mod)

total = 0

for i in range(N - K + 1):
    p = N - i - 1

    c = (f[p] * fk * pow(f[p-q], mod-2, mod)) % mod
    total += c * (A[-1 - i] - A[i])
    total %= mod

print(total)

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

MOD = 10 ** 9 + 7

A.sort()

ans = A[K-1] - A[-K]

tmp2 = 1
tmp3 = K

a = 1

for k in range(K, N):
    a = a * tmp3 / tmp2
    ans += a * (A[k] - A[N-k-1])
    if ans > MOD:
        ans %= MOD
    tmp2 += 1
    tmp3 += 1

print(int(ans))
Problem p02889 (python)

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

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

T = []
T1 = []
for _ in range(N):
    T.append([float("inf")] * N)
    T1.append([float("inf")] * N)
for n in range(N):
    T[n][n] = 0
    T1[n][n] = 0

for _ in range(M):
    A, B, C = list(map(int, input().split()))
    A -= 1
    B -= 1
    T[A][B] = C
    T[B][A] = C

for k in range(N):
    for i in range(N):
        for j in range(N):
            if T[i][j] > T[i][k] + T[k][j]:
                T[i][j] = T[i][k] + T[k][j]

for j in range(N):
    for i in range(N):
        if i == j:
            continue
        if T[j][i] <= L:
            T1[j][i] = 1
            T1[i][j] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            if T1[i][j] > T1[i][k] + T1[k][j]:
                T1[i][j] = T1[i][k] + T1[k][j]

Q = int(input())
for _ in range(Q):
    S, G = list(map(int, input().split()))
    if math.isinf(T1[S-1][G-1]):
        print(-1)
    else:
        print(T1[S-1][G-1]-1)

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

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

T = []
T1 = []
for _ in range(N):
    T.append([float("inf")] * N)
    T1.append([float("inf")] * N)
for n in range(N):
    T[n][n] = 0
    T1[n][n] = 0

for _ in range(M):
    A, B, C = list(map(int, input().split()))
    A -= 1
    B -= 1
    T[A][B] = C
    T[B][A] = C

for k in range(N):
    for i in range(N):
        for j in range(N):
            if T[i][j] > T[i][k] + T[k][j]:
                T[i][j] = T[i][k] + T[k][j]

for j in range(N):
    for i in range(N):
        if i == j:
            continue
        if T[j][i] <= L:
            T1[j][i] = 1
            T1[i][j] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            if T1[i][j] > T1[i][k] + T1[k][j]:
                T1[i][j] = T1[i][k] + Tq[k][j]

Q = int(input())
for _ in range(Q):
    S, G = list(map(int, input().split()))
    if math.isinf(T1[S-1][G-1]):
        print(-1)
    else:
        print(T1[S-1][G-1]-1)
Problem p02918 (python)

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

ans = 0
count = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        ans += 1
    if S[i] != S[i+1]:
        count += 1

while count > 0 and K > 0:
    if count == 1:
        count -= 1
        ans += 1
        K -= 1
    else:
        K -= 1
        count -= 2
        ans += 2

print(ans)

Buggy submission (verdict: Runtime Error):
foo
Problem p02971 (python)

Fixed submission:
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

L = [1]
for n in range(N-1):
    L.append(max(L[-1], A[n]))

R = [1]
A.reverse()
for n in range(N-1):
    R.append(max(R[-1], A[n]))
R.reverse()

for i in range(N):
    print(max(L[i], R[i]))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

L = []
R = []

for a in A:
    if len(L) == 0:
        L.append(a)
    L.append(max(L[-1]), a)

A.reverse()
for a in A:
    if len(R) == 0:
        R.append(a)
    R.append(max(R[-1]), a)

R.reverse()

print(R[0])
for i in range(1, N-1):
    print(max(L[i-1], R[i+1]))
print(L[len(L)-2])
Problem p03059 (python)

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

ans = 0
for i in range(1, T+1):
    if i % A == 0:
        ans += B
print(ans)

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


if N == 2:
    print(max(A[0], A[1]))
else:
    m = min(A)

    ans = -1
    for i in range(m+1, 1, -1):
        count = 0
        for n in range(N):
            if count > 1:
                break
            if A[n] % i != 0:
                count += 1
        if count <= 1:
            ans = i
            break

    print(ans)

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


if N == 2:
    print(max(A[0], A[1]))
else:
    m = min(A)

    ans = -1
    for i in range(1, m+1):
        count = 0
        for n in range(N):
            if count > 1:
                break
            if A[n] % i != 0:
                count += 1
        if count <= 1 and i > ans:
            ans = i

    print(ans)
Problem p03071 (python)

Fixed submission:
a, b = list(map(int, input().split()))
 
if a == b:
    print(a+b)
else:
    print(max(a, b)*2-1)

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

if a == b:
    print(a+b)
else:
    print(max(a, b)*2-1