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

Fixed submission:
import math

def InvMod(i, pow, mod): #階乗のmodを計算
    if pow == 1:
        return i % mod
    else:
        if pow % 2 == 0:
            return InvMod((i**2) % mod, pow//2, mod) % mod
        else:
            return InvMod((i**2) % mod, pow//2, mod) * i % mod

def Prime(i): #素数であればTrueを返す
    root = math.sqrt(i)
    j, div = 2, True
    while j <= root:
        if i % j == 0:
            div = False
            break
        j += 1
    return div

N, M = map(int, input().split())
max = int(math.sqrt(M))
mod = 7 + 10**9

Pinv = [0]
Pfact = 1
for i in range(1, 31): #(階乗)^-1の計算, 2^31 > 10^9なので階乗は高々30乗まで
    Pfact *= i
    Pfact %= mod
    Pinv.append(InvMod(Pfact, mod-2, mod))

P = []
for i in range(2, max+1): #素因数の列挙
    if M % i == 0:
        if Prime(i):
            P.append(i)
        if Prime(M//i) and i**2 != M:
            P.append(M//i)

ans = 1
for p in P:
    C, pow = M, 0
    while C % p == 0: 
        pow += 1
        C //= p
    comb = Pinv[pow]  #(N-1)!/pow!(N-1)!
    for i in range(pow): #comb * (N-1+1)(N-1+2)…(N-1+pow)
        comb *= (N+i)
        comb %= mod
    ans *= comb
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())
max = int(math.sqrt(M))
mod = 7 + 10**9
F = []
for i in range(1, max+1):
    if M%i == 0:
        F.append(i)
        F.append(M//i)

def DP(i, n, memo = {}): 
    if i == 1 or n==1:
        return 1
    try:
        return memo[(i, n)]
    except KeyError:
        ans = 0
        for j in F:
            if n//j >= 1 and n%j == 0:
                ans += DP(i-1, n//j, memo)
                ans %= mod
        memo[(i, n)] = ans
        return ans

memo = {}
print(DP(N, M, memo))
Problem p03291 (python)

Fixed submission:
S = input()
mod = 10 ** 9 + 7
count = 0
leftA = (1 if S[0] == "A" else 0)
leftQ = (1 if S[0] == "?" else 0)
rightC = S[1:].count("C")
rightQ = S[1:].count("?")

def mult(a, b, mod):
    if b == 0:
        return a
    else:
        return ((3*a + b) * pow(3, b-1, mod))

for i in range(1,len(S)-1):
    if S[i] == "B" or S[i] == "?":
        rightQ -= (1 if S[i] == "?" else 0)
        count += mult(leftA, leftQ, mod) * mult(rightC, rightQ, mod)
        count %= mod
        leftQ += (1 if S[i] == "?" else 0)
    elif S[i] == "A":
        leftA += 1 
    else:
        rightC -= 1
print(count)

Buggy submission (verdict: Runtime Error):
S = input()
mod = 10 ** 9 + 7
def DP(i, j, S, mod):
    if i == len(S) and j == 3:
        return 1
    elif i == len(S) and j < 3:
        return 0
    elif i < len(S) and j == 3:
        if S[i] == "?":
            return 3 * DP(i+1, 3, S, mod) % mod
        else:
            return DP(i+1, 3, S, mod) % mod
    elif i < len(S) and j < 3:
        ABC = "ABC"
        if S[i] == "?":
            return (3 * DP(i+1, j, S, mod) + DP(i+1, j+1, S, mod)) % mod
        elif S[i] == ABC[j]:
            return (DP(i+1, j, S, mod) + DP(i+1, j+1, S, mod)) % mod
        else:
            return DP(i+1, j, S, mod) % mod

print(DP(0, 0, S, mod))

Buggy submission (verdict: Runtime Error):
S = input()
mod = 10 ** 9 + 7
def DP(i, j, S):
    if i == len(S) and j == 3:
        return 1
    elif i == len(S) and j < 3:
        return 0
    elif i < len(S) and j == 3:
        if S[i] == "?":
            return 3 * DP(i+1, 3, S) 
        else:
            return DP(i+1, 3, S)
    elif i < len(S) and j < 3:
        ABC = "ABC"
        if S[i] == "?":
            return 3 * DP(i+1, j, S) + DP(i+1, j+1, S)
        elif S[i] == ABC[j]:
            return DP(i+1, j, S) + DP(i+1, j+1, S)
        else:
            return DP(i+1, j, S)

print(DP(0, 0, S)%mod)
Problem p03805 (python)

Fixed submission:
N, M = map(int, input().split())
Edge = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    Edge[a].append(b)
    Edge[b].append(a)

Visited = [False for i in range(N)]
Visited[0] = True
ans = 0
def DFS(i):
    allvisited = True
    for j in range(N):
        if Visited[j] == False:
            allvisited = False
    if allvisited:
        return 1
    else:
        ret = 0
        for node in Edge[i]:
            if Visited[node] == False:
                Visited[node] = True
                ret += DFS(node)
                Visited[node] = False
        return ret

print(DFS(0))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
Edge = [[] for i in range(M)]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    Edge[a].append(b)
    Edge[b].append(a)

Visited = [False for i in range(N)]
Visited[0] = True
ans = 0
def DFS(i):
    allvisited = True
    for j in range(N):
        if Visited[j] == False:
            allvisited = False
    if allvisited:
        return 1
    else:
        ret = 0
        for node in Edge[i]:
            if Visited[node] == False:
                Visited[node] = True
                ret += DFS(node)
                Visited[node] = False
        return ret

print(DFS(0))
Problem p03839 (python)

Fixed submission:
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

Plus, Whole = [0], [0]
for i in range(N):
    Plus.append(Plus[-1] + max(A[i], 0))
    Whole.append(Whole[-1] + A[i])

Score = max(max(0, Whole[K] - Whole[0]) + Plus[N] - Plus[K], Plus[N-K] - Plus[0] + max(0, Whole[N] - Whole[N-K]))
for i in range(1, N-K):
    temp = Plus[i] + max(0, Whole[i+K] - Whole[i]) + Plus[N] - Plus[i+K]
    Score = max(Score, temp)

print(Score)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

Plus, Whole = [0], [0]
for i in range(N):
    Plus.append(Plus[-1] + max(A[i], 0))
    Whole.append(Whole[-1] + A[i])

Full = Plus[N-K] - Plus[0] + Whole[N] - Whole[N-K]
MaxScore = max(Full, Plus[N-K] - Plus[0])
for i in range(1, K):
    temp = Plus[N-K] - Plus[0] + Whole[N]-Whole[N-K+i] - (Plus[N-K] - Plus[N+1 -2*K])
    MaxScore = max(MaxScore, temp)

Fullb = Plus[N] - Plus[K] + Whole[K] - Whole[0]
MS2 = max(Fullb, Plus[N] - Plus[N-K])
for i in range(1, K):
    temp = Plus[N] - Plus[K] + Whole[K] - Whole[K-i] - (Plus[2*K-i] - Plus[K])
    MS2 = max(MS2, temp)

print(max(MaxScore, MS2))
Problem p02598 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
 
def isfeasible(L):
  k = 0
  for a in A:
    if a < L:
      break
    if a%L == 0:
      dk = a//L - 1
    else:
      dk = a//L
    k += dk
    if k > K:
      return False
  return True
 
l = 0
r = A[0]

while r-l>1:
  L = (r+l)//2
  if isfeasible(L):
    r = L
  else:
    l = L
print(r)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
 
def isfeasible(L):
  k = 0
  for a in A:
    if a < L:
      break
    if a%L == 0:
      dk = a//L - 1
    else:
      dk = a//L
    k += dk
    if k > K:
      return False
  return True
 
l = 0
r = A[0]

while r-l>0:
  L = (r+l)//2
  if isfeasible(L):
    r = L
  else:
    l = L+1
print(r)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
 
def isfeasible(L):
  k = 0
  for i in range(N):
    a = A[i]
    if a < L:
      break
    if a%L == 0:
      dk = a//L - 1
    else:
      dk = a//L
    k += dk
    if k > K:
      return False
  return True
 
l = 0
r = A[0]

while r-l>0:
  L = (r+l)//2
  if isfeasible(L):
    r = L
  else:
    l = L+1
print(r)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
 
def isfeasible(L):
  k = 0
  for i in range(N):
    a = A[i]
    if a < L:
      break
    if a%L == 0:
      dk = a//L - 1
    else:
      dk = a//L
    k += dk
    if k > K:
      return False
  return True
 
l = 0
r = A[0]
if K == 0:
  print(A[0])
else:
  while r-l>0:
    L = (r+l)//2
    if isfeasible(L):
      r = L
    else:
      l = L+1
  print(r)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
 
def isfeasible(L):
  k = 0
  sub = []
  for i in range(N):
    a = A[i]
    if a < L:
      sub.append([a, "small"])
      break
    if a%L == 0:
      dk = a//L - 1
      sub.append([a, dk, "just"])
    else:
      dk = a//L
      sub.append([a, dk, "over"])
    k += dk
    if k > K:
      #print("out")
      return False
  #print("ok")
  return True
 
l = 0
r = A[0]
if K == 0:
  print(A[0])
else:
  while r-l>0:
    L = (r+l)//2
    #print("[", l, ",", r,"]checking ", L)
    if isfeasible(L):
      r = L
    else:
      l = L+1
  print(r)
Problem p02629 (python)

Fixed submission:
N = int(input())
a = 26
counter = 1
while a<N:
  N -= a
  counter += 1
  a *= 26
ans = []
N -= 1
while N>=26:
  ans.append(N%26)
  N = N //26
ans.append(N)
dic = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
ans = [dic[i] for i in ans[::-1]]
n = len(ans)
print("a"*(counter-n) + "".join(ans))

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

#B = [0]*N                                 # 記録用のリスト

for k in range(K):                        # 以降の操作をK回繰り返す
  B = [0 for _ in range(N)] 
  for i in range(N):                      # 各電球によって照らされる範囲を考える
    start = max(0, i-A[i])                # 始点のインデックスは0かi-A[i]
    end = min(N, i+A[i]+1)                # 終点のインデックスはNかi+A[i]+1
    B[start] += 1                         # 始点に+1を記録する
    if end <= N - 1:
      B[end] -= 1                         # 終点に電球が存在する場合は-1を記録する
  amin = B[0]
  A[0] = B[0] 
  for i in range(1, N):                   # 累積和の計算
    A[i] = B[i-1] + B[i]
    amin = min(A[i], amin)                                   # AをBで更新してつぎのループへ 
  if amin == N:                        # すべての電球がN個の電球に照らされるタイミングでbreakする
    break

print(*A)                                 # リストAの中身を順に表示

Buggy submission (verdict: Runtime Error):
N = int(input())
a = 26
counter = 1
while a<N:
  N -= a
  counter += 1
  a *= 26
ans = []
N -= 1
while N>26:
  ans.append(N%26)
  N = N //26
ans.append(N)
#print(ans)
dic = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
ans = [dic[i] for i in ans[::-1]]
n = len(ans)
print("a"*(counter-n) + "".join(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = 26
counter = 1
while a<N:
  N -= a
  counter += 1
  a *= 26
ans = []
N -= 1
while N>26:
  ans.append(N%26)
  N = N //26
ans.append(N)
#print(ans)
dic = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
ans = [dic[i] for i in ans[::-1]]
n = len(ans)
print("a"*(counter-n) + "".join(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = 26
counter = 1
while a<N:
  N -= a
  counter += 1
  a *= 26
ans = []
N=-1
while N>26
  ans.append(N%26)
  N = N //26
ans.append(N)
dic = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
ans = [dic[i] for i in ans[::-1]]
n = len(ans)
print("a"*(conter-n) + "".join(ans))
Problem p02688 (python)

Fixed submission:
N, K = map(int,input().split())
state = [1 for i in range(N)]
for i in range(K):
  d = int(input())
  #print(1,i,d)
  x = list(map(int, input().split()))
  for k in x:
    state[k-1] = 0
print(sum(state))

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
state = [1 for i in range(N)]
for i in range(K):
  d = int(input())
  for j in range(d):
    x = list(map(int,input().split()))
    for k in x:
      state[k-1] = 0
print(sum(state))

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
state = [1 for i in range(N)]
for i in range(K):
  d = int(input())
  for j in range(d):
    x = list(map(int,input().split()))
    for k in x:
      state[x-1] = 0
print(sum(state))
Problem p02707 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
res = [0 for i in range(N)]
for i in range(N-1):
  res[A[i]-1] += 1
for i in res:
  print(i)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
res = rep(0,N)
for i in range(N-1):
  res[A[i]-1] += 1
for i in res:
  print(i)
Problem p02711 (python)

Fixed submission:
data = input()
#print(data)
res = "No"
for i in range(len(data)):
  if data[i]=="7":
    res = "Yes"
    break
print(res)

Buggy submission (verdict: Runtime Error):
data = input().split("")
res = "No"
for i in data:
  if i=="7":
    res = "Yes"
    break
print(res)
Problem p02989 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
l = A[N//2-1]
h = A[N//2]
print(h-l)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(int, input().split())
A.sort()
l = A[N//2-1]
h = A[N//2]
print(h-l)
Problem p03723 (python)

Fixed submission:
A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 1 == 1:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
print(con)

Buggy submission (verdict: Runtime Error):
A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 1 == 1:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
  
print(con)
A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 1 == 0:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
  
print(con)

Buggy submission (verdict: Runtime Error):
A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 1 == 1:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
  
print(con)
A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 1 == 0:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
  
print(con)
提出情報

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

if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    break
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
  
print(con)
Problem p02623 (python)

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

a,b = [0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j = 0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)

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

# print(list_B)

list_A_num = -1
list_B_num = -1

total_time = 0
count = 0

while total_time < time:
    if len(list_A) > 0:
        if list_A[list_A_num] <= list_B[list_B_num]: # Aの値の方が小さければ
            total_time += list_A[list_A_num]
            list_A.pop()
        else:
            total_time += list_B[list_B_num]
            list_B.pop()
    else:
        total_time += list_B[list_B_num]
        list_B.pop()
    if total_time <= time:
        count += 1

print(count)
Problem p02990 (python)

Fixed submission:
import math
from math import gcd,pi,sqrt,factorial
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,k = i_map()

    p = n - k + 1
    b = k - 1

    def comb(n, r):
      if n-r>=0:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
      else:
        return 0

    for i in range(1,k+1):
        pci = comb(p,i)
        bci1 = comb(b,i-1)
        print((pci*bci1)%MOD)

if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
from math import gcd,pi,sqrt,factorial
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,k = i_map()

    p = n - k + 1
    b = k - 1

    for i in range(1,k+1):
        pci = factorial(p)//factorial(p-i)//factorial(i)
        bci1 = factorial(b)//factorial(b-(i-1))//factorial(i-1)
        print(pci*bci1%MOD)



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

Fixed submission:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():

    s = list(input().rstrip())
    zero = 0
    one = 0
    for i in s:
        if i == "0":
            zero += 1
        else:
            one += 1
    print(2*min(zero,one))

if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():

    def de(l,i):
        if len(l) == 0:
            return
        if len(l) == 2:
            if l[0] != l[1]:
                l = []
            return
        if l[i] != l[i-1]:
            l.pop(i)
            l.pop(i-1)
            de(l,i-1)
        elif len(l) >= i+1:
            if l[i] != l[i+1]:
                l.pop(i+1)
                l.pop(i)
                de(l,i)
        else:
            pass

    s = list(input().rstrip())
    l = len(s)
    for i in range(1,len(s)):
        de(s,i)
    print(l - len(s))

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

Fixed submission:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,m = map(int, input().split())
    l = list(map(int, input().split()))
    l.sort()

    ans = 0
    if n<m:
        L = []
        for i in range(m-1):
            L.append(l[i+1] - l[i])
        L.sort()
        for i in range(m-n):
            ans += L[i]
    print(ans)

if __name__=="__main__":
    main(
    )

Buggy submission (verdict: Runtime Error):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,m = map(int, input().split())
    l = list(map(int, input().split()))
    l.sort()

    ans = 0
    if n<m:
        L = []
        for i in range(m-1):
            l.append(l[i+1] - l[i])
        L.sort()
        for i in range(m-n):
            ans += L[i]
    print(ans)


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

Fixed submission:
d, t, s = map(int, input().split())

if d/s <= t:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
# import numpy as np
# import itertools as it

n = int(input())
a = list(map(int, input().split()))

res = 0
for i in range(n):
    res += a[i] * a[i]

ans = sum(a) * sum(a)
print(((ans - res)//2) % (10 ** 9 + 7))


# sum = 0
# for i in range(n):
#     sum += 1 / a[i]
#print(sum)

# ans = int(sum * np.prod(a))
# print(ans % (10 ** 9 + 7))
Problem p02571 (python)

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

cnt = []
for i in range(len(s) - len(t) + 1):
    cnt1 = 0
    for k in range(len(t)):
        if t[k] == s[i: i + len(t)][k]:
            cnt1 += 1
            cnt.append(cnt1)
            #print(t[i:k], s[i:], k-i)
    else:
        cnt.append(0)
            #print(t[i:k], k - i)
#print(cnt)
print(len(t) - max(cnt))

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

cnt1 = 0
if len(s) == len(t):
    for i in range(len(t)):
        if s[i] != t[i]:
            cnt1 += 1
print(cnt1)
else:
    cnt = []
    for i in range(len(t)):
        for k in range(i + 1, len(t) + 1):
            if t[i:k] in s[i:]:
                cnt.append(k - i)
                print(t[i:k], s[i:], k-i)
            else:
                cnt.append(0)
                #print(t[i:k], k - i)
#print(cnt)
print(len(t) - max(cnt))

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

cnt = []
for i in range(len(t)):
    for k in range(i + 1, len(t) + 1):
        if t[i:k] in s[i:]:
            cnt.append(k - i)
            print(t[i:k], k - i)
#print(cnt)
print(len(t) - max(cnt))

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

cnt = []
for i in range(len(t)):
    for k in range(i + 1, len(t)):
        if t[i:k] in s[i:]:
            cnt.append(k - i)
            #print(t[i:k])
#print(cnt)
print(len(t) - max(cnt))
Problem p02557 (python)

Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

count = [0] * (N+1)
for a, b in zip(A, B):
    count[a] += 1
    count[b] += 1

for i in range(N+1):
    if count[i] > N:
        print('No')
        quit()

diff = 0
checked = set()
ida = 0
for i, b in enumerate(B):
    if b in checked:
        continue
    checked.add(b)
    while ida < N and A[ida] <= b:
        ida += 1
    diff = max(diff, ida - i)


idx = (np.arange(N) - diff) % N
print('Yes')
print(*np.array(B)[idx])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0] + list(map(int, input().split())) + [N+1]
B = list(map(int, input().split()))
B_store = B.copy()


def do(A, B):
    ans = []
    ida = 1
    res = True
    while ida < N+1:
        a = A[ida]
        c = 1
        while ida+c < N+2 and A[ida+c] == a:
            c += 1
        
        ida += c
        temp = []
        while c:
            if len(B) == 0:
                res = False
                break
            b = B.pop()
            if b != a:
                ans.append(b)
                c -= 1
            else:
                temp.append(b)
        
        B += temp
        if not res:
            break

    if res:
        return ans
    else:
        return False

ans = do(A, B)
if ans:
    print('Yes')
    print(*ans)

ans = do(A[::-1], B_store[::-1])[::-1]
if ans:
    print('Yes')
    print(*ans)

else:
    print('No')