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

Fixed submission:
s = input().strip()
K = int(input())

indices = [0]*5
substrings = [sorted(list(set([s[i:i+l] for i in range(len(s)-l+1)])))[:5]+['zzzzz'] for l in range(1,6)]
for k in range(K):
    s = min(substrings[l][i] for l, i in enumerate(indices))
    # print([substrings[l][i] for l, i in enumerate(indices)])
    indices[len(s)-1] += 1
    if k == K-1:
        print(s)

Buggy submission (verdict: Runtime Error):
s = input().strip()
K = int(input())


def min_substring(s, l, num):
    substrings = list(set([s[i:i+l] for i in range(len(s)-l+1)]))
    substrings.sort()

    return substrings[num]




rank = 0
top = min_substring(s, 1, rank)
res = top
k = 1
l = 2

while k < K:
    substrings = list(set([s[i:i+l] for i in range(len(s)-l+1) if s[i:i+l-1] == res]))
    substrings.sort()

    if len(substrings) == 0:
        rank += 1
        top = min_substring(s, 1, rank)
        res = top
        k += 1
        continue
    else:
        for string in substrings:
            k += 1
            res = string
            break

        l += 1

print(res)
Problem p02641 (python)

Fixed submission:
x,n = map(int,input().split())
a = list(map(int,input().split()))
if n == 0:
    print(x)
    exit()
ans = min(a)-1
for i in range(1,102):
    if i in a:
        continue
    if abs(x-i) < abs(x-ans):
        ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
a = list(map(int,input().split()))
ans = min(a)-1
for i in range(1,102):
    if i in a:
        continue
    if abs(x-i) < abs(x-ans):
        ans = i
print(ans)
Problem p02642 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if n == 1:
    print(1)
    exit()
flag = [True for i in range(10**6+1)]
a.sort()
for i in range(n):
    if flag[a[i]] == False:
        continue
    if i >= 1:
        if a[i] == a[i-1]:
            continue
    for j in range(2,(10**6)//a[i]+1):
        flag[a[i]*j] = False
ans = 0
for i in range(n):
    if flag[a[i]]:
        if i >= 1:
            if a[i] == a[i-1]:
                continue
        if i < n-1:
            if a[i] == a[i+1]:
                continue
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if n == 1:
    print(1)
    exit()
flag = [True for i in range(10**6+1)]
a.sort()
for i in range(n):
    if flag[a[i]] == False:
        continue
    if i >= 1:
        if a[i] == a[i-1]:
            continue
    for j in range(2,(10**6)//a[i]+1):
        flag[a[i]*j] = False
ans = 0
for i in range(n):
    if flag[a[i]]:
        if i >= 1:
            if a[i] == a[i-1]:
                continue
        if i <= n-1:
            if a[i] == a[i+1]:
                continue
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
flag = [True for i in range(10**6)]
a.sort()
for i in range(n):
    if flag[a[i]-1] == False:
        continue
    if i >= 1:
        if a[i] == a[i-1]:
            continue
    for j in range(2,(10**6)//a[i]+1):
        flag[a[i]*j-1] = False
ans = 0
for i in range(n):
    if flag[a[i]-1]:
        if i >= 1:
            if a[i] == a[i-1]:
                continue
        if i == 0:
            if a[i] == a[i+1]:
                continue
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
flag = [True for i in range(2*10**5)]
a.sort()
for i in range(n):
    if flag[a[i]-1] == False:
        continue
    if i >= 1:
        if a[i] == a[i-1]:
            continue
    for j in range(2,(2*10**5)//a[i]):
        flag[a[i]*j-1] = False
ans = 0
for i in range(n):
    if flag[a[i]-1]:
        if i >= 1:
            if a[i] == a[i-1]:
                continue
        if i == 0:
            if a[i] == a[i+1]:
                continue
        ans+=1
print(ans)
Problem p02705 (python)

Fixed submission:
import math
a = int(input())
print(2*a*math.pi)

Buggy submission (verdict: Runtime Error):
import math
a = int(input()
print(2*a*math.pi)

Buggy submission (verdict: Runtime Error):
import math
a = int(input()
print(2*a*math.pi)
Problem p02706 (python)

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
sum = n
for i in a:
  sum -= i
if sum < 0:
  print(-1)
else:
  print(sum)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = list(map(int,input().split()))
sum = -314
for i in a:
  sum += a
if sum < 0:
  print(-1)
else:
  print(sum)
Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
t = [0 for i in range(n)]
e = [True for i in range(n)]
b = ""
a = False
for i in range(m):
    s,c = map(int,input().split())
    if e[s-1]:
        if s == 1 and c == 0:
            a = True
            if n == 1:
                print(0)
                exit()
        else:
            t[s-1] = c
            e[s-1] = False
    else:
        if t[s-1] != c:
            a = True
for i in range(n):
    b += str(t[i])
if a:
    print(-1)
elif n > 1 and b[0] == '0':
    print(str(1)+b[1:3])
else:
    print(b)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
t = [0 for i in range(n)]
b = ""
a = True
for i in range(m):
    s,c = map(int,input().split())
    if t[s-1] != 0 and c == 0:
        a=False
    elif t[s-1] == 0 or t[s-1] == c:
        t[s-1] = c
    else:
        a=False
for i in range(n):
    b += str(t[i])
if n > 1 and b[0] == '0':
    b[0]=1
    print(b)
elif b[0] == '0':
    print(0)
elif a:
    print(b)
else:
    print(-1)
Problem p03240 (python)

Fixed submission:
n = int(input())
t = [list(map(int,input().split())) for i in range(n)]
for x,y,h in t:
    if h > 0:
        a = [x,y,h]            # hが0でない1つの組(地面以外の部分)

for cx in range(101):
    for cy in range(101):
        flag = True
        ch = abs(a[0]-cx) + abs(a[1] - cy) + a[2]     # 高さ
        for x,y,h in t:
            if h != max(ch - abs(x - cx) - abs(y - cy),0):    # 高さが条件に合うか 
                flag = False
                break
        if flag:
            print(cx,cy,ch)
            exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
t = [list(map(int,input().split())) for i in range(n)]
for x,y,h in t:
    if h > 0:
        a = [x,y,h]            # hが0でない1つの組(地面以外の部分)

for cx in range(101):
    for cy in range(101):
        flag = True
        ch = abs(a[0]-cx) + abs(a[1] - cy) + a[2]     # 高さ
        for x,y,h in t:
            if h != max(ch - abs(x - cx) - abs(y - cy),0):　　　# 高さが条件に合うか 
                flag = False
                break
        if flag:
            print(cx,cy,ch)
            exit()
Problem p03263 (python)

Fixed submission:
h,w = map(int,input().split())
a = []
for i in range(h):
    ai = list(map(int,input().split()))
    a.append(ai)
ans = []
for i in range(h):
    for j in range(w-1):
        if a[i][j] % 2 == 1:
            ans.append([i+1,j+1,i+1,j+2])
            a[i][j+1] += 1
for i in range(h-1):
    if a[i][-1] % 2 == 1:
        ans.append([i+1,w,i+2,w])
        a[i+1][-1] += 1
print(len(ans))
for i,j,k,l in ans:
    print(i,j,k,l)

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
a = []
for i in range(h):
    ai = list(map(int,input().split()))
    a.append(ai)
ans = []
for i in range(h):
    for j in range(w-1):
        if a[i][j] % 2 == 1:
            ans.append([i+1,j+1,i+1,j+2])
            a[i][j+1] += 1
for i in range(h-1):
    if a[-1][i] % 2 == 1:
        ans.append([i+1,w,i+2,w])
        a[-1][i+1] += 1
print(len(ans))
for i,j,k,l in ans:
    print(i,j,k,l)
Problem p03380 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 10**18
for i in range(n-1):
    if abs(a[i] - a[-1]/2) < abs(ans - a[-1]/2):
        ans = a[i]
print(a[-1],ans)

Buggy submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**5+1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = 0
tmp = 0
for i in range(n):
    if a[i] == a[-1]:
        break
    if cmb(a[-1],a[i],mod) > ans:
        ans = cmb(a[-1],a[i],mod)
        tmp = a[i]
print(a[-1],tmp)
Problem p03436 (python)

Fixed submission:
from collections import deque
h,w = map(int,input().split())
d = [input() for i in range(h)]
count = 0
for i in range(h):
    for j in range(w):
        if d[i][j] == '#':
            count+=1
visited = [[0 for i in range(w)] for i in range(h)]
def bfs(sy,sx,gy,gx):
    que = deque()
    que.append((sy,sx))
    visited[sy][sx] = 0
    while que:
        y,x = que.popleft()
        if y == gy and x == gx:
            return visited[y][x]
        for dy,dx in [(-1,0),(1,0),(0,-1),(0,1)]:
            ny,nx = y+dy, x+dx
            if ny < 0 or nx < 0 or ny >= h or nx >= w:
                continue
            elif d[ny][nx] == '#':
                continue
            elif visited[ny][nx] != 0:
                continue
            else:
                visited[ny][nx] = visited[y][x] + 1
                que.append((ny,nx))
    return visited[gy][gx]
ans = bfs(0,0,h-1,w-1)
if ans == 0:
    print(-1)
    exit()
print(h*w - ans - count - 1)

Buggy submission (verdict: Runtime Error):
from collections import deque
h,w = map(int,input().split())
d = [input() for i in range(h)]
count = 0
for i in range(h):
    for j in range(w):
        if d[i][j] == '#':
            count+=1
visited = [[0 for i in range(w)] for i in range(h)]
def bfs(sy,sx,gy,gx):
    que = deque()
    que.append((sy,sx))
    visited[sy][sx] = 0
    while que:
        y,x = que.popleft()
        if y == gy and x == gx:
            return visited[y][x]
        for dy,dx in [(-1,0),(1,0),(0,-1),(0,1)]:
            ny,nx = y+dy, x+dx
            if ny < 0 or nx < 0 or ny >= h or nx >= w:
                continue
            elif d[ny][nx] == '#':
                continue
            elif visited[ny][nx] != 0:
                continue
            else:
                visited[ny][nx] = visited[y][x] + 1
                que.append((ny,nx))
    return visited[gy][gx]
ans = bfs(0,0,h-1,w-1)
if ans = 0:
    print(-1)
    exit()
print(h*w - ans - count - 1)
Problem p03587 (python)

Fixed submission:
S = input()
count =  0
for i in S:
  if i == '1':
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
S = input()
count =  0
for i in S:
  if i == '1':
    count++
print(count)
Problem p03633 (python)

Fixed submission:
def gcd(a,b):
    return gcd(b,a % b) if b else abs(a)
def lcm(a,b):
    return (a*b) // gcd(a,b)
n = int(input())
t = []
for i in range(n):
    a = int(input())
    t.append(a)
b = t[0]
for i in range(1,n):
    b = lcm(b,t[i])
print(b)

Buggy submission (verdict: Runtime Error):
import math
def lcm(a,b):
    return (a*b) // math.gcd(a,b)
n = int(input())
t = []
for i in range(n):
    a = int(input())
    t.append(a)
b = t[0]
for i in range(1,n):
    b = lcm(b,t[i])
print(b)
Problem p03695 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
w = [0 for i in range(8)]
count = 0
sup = 0
for i in a:
    if i < 3200 and w[i//400]==0:
        count+=1
        w[i//400] += 1
    elif i >= 3200:
        sup += 1
if count == 0:
    print(1,sup)
elif sup == 0:
    print(count,count)
else:
    b= count+sup
    print(count,b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
w = [0 for i in range(9)]
count = 0
for i in a:
    if i < 3200 and w[i//400]==0:
        count+=1
    w[i//400]+=1
if count == 0:
    print(1,w[8])
elif w[8] == 0:
    print(count,count)
else:
    b= count+w[8]
    print(count,b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
w = [0 for i in range(9)]
count = 0
for i in a:
    if i < 3200 and w[i//400]==0:
        count+=1
    w[i//400]+=1
if count == 0:
    print(1,w[8])
elif w[8] == 0:
    print(count,count)
else:
    print(count,count+w[8])

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = list(map(int,input().split()))
w = np.zeros(9,dtype=int)
count = 0
for i in a:
    if i < 3200 and w[i//400]==0:
        count+=1
    w[i//400]+=1
if count == 0:
    print(1,w[8])
elif w[8] == 0:
    print(count,count)
else:
    print(count,count+w[8])

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = list(map(int,input().split()))
w = np.zeros(9,dtype=int)
count = 0
for i in range(n):
    if a[i] < 3200 and w[a[i]//400]==0:
        count+=1
    w[a[i]//400]+=1
if count == 0:
    print(1,w[8])
elif w[7] == 0:
    print(count,count)
else:
    print(count,count+w[8])

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = list(map(int,input().split()))
w = np.zeros(9,dtype=int)
count = 0
for i in range(n):
    if a[i] < 3200 and w[a[i]//400]==0:
        count+=1
    w[a[i]//400]+=1
if count == 0:
    print(1,w[8])
elif w[7] == 0:
    print(count,count)
else:
    print(count,count+w[8])
print(w[8])

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = list(map(int,input().split()))
w = np.zeros(9,dtype=int)
count = 0
for i in range(n):
    if a[i] < 3200 and w[a[i]//400]==0:
        count+=1
    w[a[i]//400]+=1
if count == 0 and w[8] <=8:
    print(1,w[8])
elif count == 0:
    print(1,8)
elif w[7] == 0:
    print(count,count)
elif count + w[8] <= 8:
    print(count,count+w[8])
else:
    print(count,count)
Problem p03846 (python)

Fixed submission:
n = int(input())
MOD = 10**9+7
a = list(map(int,input().split()))
if n == 1 and a[0] == 0:
    print(1)
    exit()
elif n == 1:
    print(0)
    exit()
if n == 2 and a[0] == 1 and a[1] == 1:
    print(1)
    exit()
elif n == 2:
    print(0)
    exit()
a.sort()
if n % 2 == 0:
    if a[0] != 1 or a[1] != 1 or a[2] == 1:
        print(0)
        exit()
    j = 3
    for i in range(2,n,2):
        if a[i] != j:
            print(0)
            exit()
        j += 2
    j = 3
    for i in range(3,n,2):
        if a[i] != j:
            print(0)
            exit()
        j+=2
if n % 2 != 0:
    if a[0] != 0 or a[1] == 0:
        print(0)
        exit()
    j = 2
    for i in range(1,n,2):
        if a[i] != j:
            print(0)
            exit()
        j += 2
    j = 2
    for i in range(2,n,2):
        if a[i] != j:
            print(0)
            exit()
        j+=2
print(pow(2,(n//2),MOD))

Buggy submission (verdict: Runtime Error):
n = int(input())
MOD = 10**9+7
a = list(map(int,input().split()))
a.sort()
if n % 2 == 0:
    if a[0] != 1 or a[1] != 1 or a[2] == 1:
        print(0)
        exit()
    j = 3
    for i in range(2,n,2):
        if a[i] != j:
            print(0)
            exit()
        j += 2
    j = 3
    for i in range(3,n,2):
        if a[i] != j:
            print(0)
            exit()
        j+=2
if n % 2 != 0:
    if a[0] != 0 or a[1] == 0:
        print(0)
        exit()
    j = 2
    for i in range(1,n,2):
        if a[i] != j:
            print(0)
            exit()
        j += 2
    j = 2
    for i in range(2,n,2):
        if a[i] != j:
            print(0)
            exit()
        j+=2
print(pow(2,(n//2),MOD))
Problem p02683 (python)

Fixed submission:
n, m, x = map(int, input().split())
#n,m,x,i,j,l,money,k,o
books = []
for i in range(n):
    books.append(list(map(int, input().split())))
books = sorted(books, reverse=False)
#print(books)#

ans = 10 ** 10000
import itertools
for i in range(n+1):
    for j in itertools.combinations(books, i):#j:組み合わせ
#        print(j)#
        l = [0] * m #理解度
        money = 0
        for k in j:#k:組み合わせの中の１冊
#            print(k)#
            money += k[0]  #費用
#            print(money)#
            for o in range(1, m + 1):
                l[o-1] += k[o]  #lが理解度、kが本
#        print(money,l)#
        if all(a >=x for a in l):
            if money < ans:
                ans = money

if ans == 10 ** 10000:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
#n,m,x,i,j,l,money,k,o
books = []
for i in range(n):
    books.append(list(map(int, input().split())))
books = sorted(books, reverse=False)
print(books)#

ans = 10 ** 6
import itertools
for i in range(n+1):
    for j in itertools.combinations(books, i):#j:組み合わせ
#        print(j)#
        l = [0] * n #理解度
        money = 0
        for k in j:#k:組み合わせの中の１冊
#            print(k)#
            money += k[0]  #費用
#            print(money)#
            for o in range(1, m + 1):
                l[o-1] += k[o]  #lが理解度、kが本
#        print(money,l)
        if all(a >=x for a in l):
            if money < ans:
                ans = money

if ans == 10 ** 6:
    print(-1)
else:
    print(ans)
Problem p02684 (python)

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

mrk = [0] * n
plc = a[0] - 1
rp = 0 #ループに入った場所
rpc = -1#ループに入ってから
prc = 0#ループに入る前
for i in range(1, k + 1):
#    logging.debug(i)
    if rpc >= 0:
        rpc += 1
        if plc == rp:
#            logging.debug("prc{},rpc{}".format(prc,rpc))
            k = (k - prc) % rpc
#            logging.debug("k{},plc{}".format(k,plc))
            for i in range(k):
                plc = a[plc] - 1
#                logging.debug(plc)
            print(plc + 1)
            exit()
    if rpc == -1:
        prc += 1
    if mrk[plc] == 1 and rpc == -1:
        rp = plc
        rpc = 0
    mrk[plc] += 1
    if i < k:
        plc = a[plc] - 1
#    logging.debug("{},next{},{},roop{}".format(mrk,plc,prc,rpc))

print(plc + 1)

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

B = [0] * N
C = 0
D = 0
E = []
for i in range(K):
    if i == 0:
        B[i] += 1
        C = A[0]
        D += 1
        E.append(C)
        #print(i, C)
        #print(B)
    else:
        if B[C - 1] == 0:
            B[C - 1] += 1
            C = A[C - 1]
            D += 1
            #E.append(C)
            #print(i, C)
            #print(B)
        else:
            #print("２回目")
            #print(D, K % D)
            #print(E)
            print(E[K % D])
            exit()

print(C)
Problem p02713 (python)

Fixed submission:
K = int(input())  #スペース抜きの複数行,１文字ずつ
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

A = []
for i in range(1, K + 1):
    for j in range(i, K+1):
        for k in range(j, K + 1):
            if i == j and j == k and k == i:
                #print(i,j,k)
                A.append(gcd_list([i, j, k]))
            elif i != j and j != k and k != i:
                A.append(gcd_list([i, j, k])*6)
            else:
                #print(i,j,k)
                A.append(gcd_list([i, j, k])*3)           

print(sum(A))

Buggy submission (verdict: Runtime Error):
from math import gcd

def main():
    K=int(input())
    ans=0
    for a in range(1,K+1):
        for b in range(1,K+1):
            p=gcd(a,b)
            if p==1:
                ans+=p*K
            else:
                for c in range(1,K+1):
                    ans+=gcd(p,c)

print(ans)
Problem p02755 (python)

Fixed submission:
A, B = map(int, input().split())  #数字

import math
x = math.ceil(A / 0.08)
#print(x)

y = math.ceil(B / 0.1)
#print(y)

if x == y:
    print(int(x))
    exit()

if y < x:
#    print("y < x")
    while y < x:
        y += 1
        z = y * 0.1
    if z >= B + 1:
        print(-1)
        exit()
    else:
        print(int(x))
        exit()

if y > x:
#    print("y > x")
    while y > x:
        x += 1
        z = x * 0.08
    if z >= A + 1:
        print(-1)
        exit()
    else:
        print(int(y))
        exit()

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

P = A / 0.08
PX = (A+1) / 0.08

PP = B / 0.1
PPX = (B+1) /0.1 

if PP <= P and P < PPX: round(print(P))
elif P <= PP and PP < PX: round(print(PP))
elif 
else:print(-1)
Problem p03000 (python)

Fixed submission:
N,X = list(map(int, input().split()))
L = list(map(int, input().split()))
L.insert(0,0)
cou = 0
BP = 0
for i in range(N + 1):
    BP += L[i]
    if BP <= X:
        cou += 1
    else:
        print(cou)
        exit()
print(cou)

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


cou = 0
BP = 0
for i in range(0, N + 1):
    if BP <= X:
        cou += 1
        BP += L[i]
    else:
        print(cou)
        exit()
print(cou)
Problem p04044 (python)

Fixed submission:
N,L = map(int, input().split())
S = list(input() for i in range(N))
S = sorted(S)
print(''.join(S))

Buggy submission (verdict: Runtime Error):
N,L = map(int, input().split())
S = list((input() for i in range(N))
S = sorted(S)
print(''.join(S))
Problem p02922 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	A,B = inputMap()

	if B == 1:
		print(0)
		sys.exit()

	ans = 0
	to = 0
	flg = False
	while True:
		ans += 1
		if flg == False:
			to += A
			flg = True
		else:
			to = (to-1) + A

		if to >= B:
			break

	print(ans)

if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	A,B = inputMap()

	ans = 0
	to = 0
	flg = False
	while True:
		ans += 1
		if flg == False:
			to += A
			flg = True
		else:
			to = (tp-1) + A
		if to >= B:
			break

	print(ans)

if __name__ == "__main__":
	main()
Problem p03386 (python)

Fixed submission:
a,b,k=map(int,input().split())
r=range(a,b+1)
for i in sorted(set(r[:k])|set(r[-k:])):print(i)

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

r = list(range(A, B+1))
for i in sorted(set(r[:K]) | set(r[-K:])):
    print(i)

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

r = list(range(A, B+1))
for i in sorted(set(r[:K] + r[-K:])):
    print(i)