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

Fixed submission:
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  n, m = map(int, readline().split())
  A = list(int(readline()) for i in range(m))
  A.append(INF)
  dp = [0]*(n+1)
  dp[0] = 0
  j = 0
  if A[j] == 1:
    dp[1] = 0
    j += 1
  else:
    dp[1] = 1
  
  if n>=2:
    if A[j] == 2:
      dp[2] = 0
      j += 1
    else:
      dp[2] = dp[1] + 1
  
  if n>=3:
    for i in range(3, n+1):
      if A[j] == i:
        dp[i] = 0
        j += 1
      else:
        dp[i] = (dp[i-1]+dp[i-2])%MOD
  print(dp[n])
  
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  n, m = map(int, readline().split())
  A = list(int(readline()) for i in range(m))
  A.append(INF)
  dp = [0]*(n+1)
  dp[0] = 0
  j = 0
  if A[j] == 1:
    dp[1] = 0
    j += 1
  else:
    dp[1] = 1
  
  if A[j] == 2:
    dp[2] = 0
    j += 1
  else:
    dp[2] = dp[1] + 1
  
  for i in range(3, n+1):
    if A[j] == i:
      dp[i] = 0
      j += 1
    else:
      dp[i] = (dp[i-1]+dp[i-2])%MOD
  print(dp[n])
  
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
import math
import sys
input = sys.stdin.readline
#文字列のときはうまく行かないのでコメントアウトすること
sys.setrecursionlimit(2147483647)

def main():
  mod = 10**9 + 7
  n, m = map(int, input().split())
  dp = [0] * n
  memo = [1] * n
  for _ in range(m):
    i = int(input())
    memo[i-1] = 0
  if memo[0]:
    dp[0] = 1
  if memo[1]:
    dp[1] += dp[0] + 1
  for i in range(2,n):
    if memo[i]:
      dp[i] = dp[i-1]%mod + dp[i-2]%mod
  print(dp[n-1])
  

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

Fixed submission:
import sys
import math
from fractions import gcd
import numpy as np
readline = sys.stdin.readline
INF = 10**9


def main():
  N, M = map(int, readline().split())
  X = np.array(readline().split(), dtype=np.int64)
  X.sort()
  X = np.diff(X)
  X.sort()
  if M-N>=0:
    answer = X[:M-N].sum()
  else:
    answer = 0
  print(answer)
  
  
  
  
  
if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
import sys
import math
from fractions import gcd
import numpy as np
readline = sys.stdin.readline
INF = 10**9


def main():
  N, M = map(int, readline().split())
  X = np.array(readline().split(), dtype=np.int64)
  X.sort()
  X = np.diff(X)
  X.sort()
  if M-N>=0:
    answer = X[:M-N].sum()
  else:
    answe = 0
  print(answer)
  
  
  
  
  
if __name__ == "__main__":
  main()
Problem p02547 (python)

Fixed submission:
n = int(input())
c = 0
c1=0
for x in range(n):
  a,b = map(int,input().split())
  if a==b:
    c+=1
    if c==3:
        c1 = 1
        print('Yes')
        break
  else:
    c=0
if c1==0:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
c = 0
c1=0
for x in range(n):
  a,b = map(int,input().split())
  if a==b:
    c+=1
    if c==3:
        c1 = 1
      	print('Yes')
      	break
  else:
    c=0
if c1==0:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
c = 0
c1=0
for x in range(n):
  a,b = map(int,input().split())
  if a==b:
    c+=1
    if c==3:
        c1 = 1
      print('Yes')
      break
  else:
    c=0
if c1==0:
    print('No')
Problem p02659 (python)

Fixed submission:
from decimal import *
import math
A, B = input().split()
print(math.floor(Decimal(A) * Decimal(B)))

Buggy submission (verdict: Runtime Error):
import math
A, B = input().split()
print(math.floor(Decimal(A)*Decimal(B)))
Problem p02701 (python)

Fixed submission:
N = int(input())
l = []
c = 0
for i in range(N):
  s = input()
  l.append(s)

a = set(l)
print(len(a))

Buggy submission (verdict: Runtime Error):
N = int(input())
a={}
for i in range(N):
  a += input()
print(len(a))
Problem p02729 (python)

Fixed submission:
N, M = map(int, input().split())
gu = N * (N-1) //2
ki = M * (M-1) // 2
print(gu + ki)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
count = [0] * N
for i in range(N):
  count[A[i] - 1]  += 1
  
nanimo = 0 
for i in range(N):
  nanimo += count[i] * (count[i] - 1) // 2
for i in range(N):
  tekito = count[A[i] - 1]
  if tekito == 1:
    s = nanimo
  else:
    s = nanimo -  ((tekito * (tekito - 1) //2) - ((tekito - 1) * (tekito - 2) //2))
  print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
count = [0] * N
#answer = [-1] * N
#p = [0] * N
for i in range(N):
  count[i]  = A.count(i + 1)
  
nanimo = 0 
for i in range(N):
  nanimo += count[i] * (count[i] - 1) // 2
for i in range(N):
  tekito = count[A[i] - 1]
  if tekito == 2:
    s = nanimo - 1
  elif tekito == 1:
    s = nanimo
  else:
    s = nanimo -  ((tekito * (tekito - 1) //2) - ((tekito - 1) * (tekito - 2) //2))
  print(s)
Problem p02766 (python)

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

for i in range(1,50):
  if n < k ** i:
    print(i)
    break

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

for i in range(1,10):
  if n <= k ** i:
    print(i +1)
    sys.exit()
Problem p02777 (python)

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()

if s == u :
  a -= 1
else:
  b -= 1
print(a, b)

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

if s = u :
  a -= 1
else:
  b -= 1
print(a, b)
Problem p02829 (python)

Fixed submission:
l = [1,2,3]
for i in range (2):
  l.remove(int(input()))
print(l[0])

Buggy submission (verdict: Runtime Error):
l = [1,2,3]
for i range (2):
  l.remove(int(input()))
print(l[0])
Problem p02835 (python)

Fixed submission:
a, b, c = map(int, input().split())
 
if a + b + c <= 21:
  print('win')
else:
  print('bust')

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

if a + b + c <= 21:
  print('win')
else:
  print('bust')
Problem p02836 (python)

Fixed submission:
S = input()
 
cnt = 0
for i in range(len(S) // 2):
  if S[i] != S[len(S) - 1 - i]:
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
S = input()

cnt = 0
for i in range(S // 2):
  if S[i] != S[len(S) - 1 - i]:
    cnt +=0
print(cnt)
Problem p02915 (python)

Fixed submission:
print(int(input()) ** 3)

Buggy submission (verdict: Runtime Error):
N = int(input())
B = list(map(int,input().split()))
A = []
A.append(B[0])
A.append(B[0])
for i in range(1, N - 2):
  if B[i] < A[i]:
    A[i] = B[i]
  A.append(B[i])

if N > 2:
  A.append(B[-1])
print(sum(A))
Problem p03835 (python)

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

c = 0
for i in range(K+1):
  for j in range(K+1):
    z = S - i - j
    if 0 <= z and z <= K:
      c += 1
print(c)

Buggy submission (verdict: Runtime Error):
K, S = map(int,input()split())

c = 0
for i in range(K+1):
  for j in range(K+1):
    z = S - i - j
    if 0 <= z and z <= K:
      c += 1
print(c)
Problem p02659 (python)

Fixed submission:
def resolve():
    A, B = input().split()
    ans = int(A)*int(B[0])*100+int(A)*int(B[2:])
    print(str(ans)[:-2] if len(str(ans)) >= 3 else "0")
resolve()

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(A*(B*100//1)//100)

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
num = a*b
print(f'{num:.0f}')

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
num = a*b
print('{:.0f}'.format(num))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
ans = A*B
ant = math.floor(ans)
print(ant)

Buggy submission (verdict: Runtime Error):
import.math
A, B = map(int, input().split())
ans = A*B
ant = math.floor(ans)
print(ant)

Buggy submission (verdict: Runtime Error):
import.math
A, B = map(int, input().split())
ans = math.floor(A*B)
print(ans)

Buggy submission (verdict: Runtime Error):
import.math
A, B = map(int, input().split())
print(math.floor(A*B))

Buggy submission (verdict: Runtime Error):
import math
A, B = input().split()
print(math.floor(A*B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(math.floor(A*B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
float_var = A*B
print(math.floor(float_var))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(math.floor(A*B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
math.floor(A*B)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
format(A*B, '.0f')

Buggy submission (verdict: Runtime Error):
A, B = input().split()
ans = A * B
format(ans, '.0f')

Buggy submission (verdict: Runtime Error):
A, B = input().split()
ans = A * B
print(format(ans, '.0f'))

Buggy submission (verdict: Runtime Error):
A, B = input().split()
print(format((A*B), '.0f'))

Buggy submission (verdict: Runtime Error):
import math
A, B = input().split()
print(math.floor(A*B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
ans = math.floor(A*B)
print(ans)

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

Buggy submission (verdict: Runtime Error):
import.math
A, B = map(int, input().split())
ans = (A*B)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
ans = A * B
print(math.floor(ans))
Problem p02676 (python)

Fixed submission:
k = int(input())
s = str(input())
if len(s) <= k:
    print(s)
else:
    print((s[:k]) + "...")

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
if len(S)<=K:
  print(S)
else:
  print(S[:K]+"...")

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
print(S if len(S)<=K)

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
list = 0
a = ""
for i in raige(K):
  a = a+S[list]
  list = list + 1
print(S if len(S)<=K else a+"...")

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
s = len(S)
if s<=K:
  print(S)

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
count = len(S)
list = 0
a = ""
for i in raige(K):
  a = a+S[list]
  list = list + 1

if count <= K:
  print(S)
else:
  print(a+"...")

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
count = len(S)
list = 0
List = []
for i in range(K):
  print(S[list])
  list = list + 1
if count <= K:
  print(S)
else:
  print( *i +"...")

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
if (len(S) <= K):
  print(S)

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
s = len(S)
if (s <= K):
  print(S)

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
s = len(S)
if (s <= K):
  print(S)

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
if (len(S) <= K):
  print(S)
else:
  print(S[K]+"...")

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
list = 0
a = ""
for i in raige(K):
  a = "a+S[list]"
  list = list + 1

if (len(S) <= K):
  print(S)

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
count = len(S)
list = 0
a = ""
for i in raige(K):
  a = "a+S[list]"
  list = list + 1

if (count <= K):
  print(S)
else:
  print(a+"...")

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
count = len(S)
list = 0
a = ""
for i in raige(K):
  a = a+S[list]
  list = list + 1

if (count <= K):
  print(S)
else:
  print(a+"...")

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
count = len(S)
if (count <= K):
  print(S)
else:
  print('{:.Kg}.format(S)'+"...")

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
count = len(S)
list = 0
for i in range(K):
  i = S[list]
  list = list + 1
if (count <= K):
  print(S)
else:
  print(i+"...")

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
count = len(S)
list = 0
List = []
for i in range(K):
  print(S[list])
  list = list + 1
if (count <= K):
  print(S)
else:
  print( *i +"...")

Buggy submission (verdict: Runtime Error):
K = input()
S = input()
count = len(S)
list = 0
List = []
for i in range(K):
  a = S[list]
  a.attend(List)
  list = list + 1
if (count <= K):
  print(S)
else:
  print(List+"...")
Problem p02682 (python)

Fixed submission:
A, B, C, K = map(int, input().split())
if (A>=K):
  print(K)
if (A<K and A+B>=K):
  print(A)
if (A<K and A+B<K and A+B+C>=K):
  print(A-(K-A-B))

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())
if (A>=K):
  print(K)
else if (A+B>=K):
  print(A)
else:
  print(A-(K-A-B))
Problem p02688 (python)

Fixed submission:
def resolve():
    N, K = map(int, input().split())
    A = []
    for i in range(K):
        d = int(input())
        a = list(map(int, input().split()))
        A.extend(a)
    print(N - len(set(A)))
resolve()

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
for i in range(K):
  D = list(int(input()))
  A = list(map(int, input().split()))
print(N - len(set(A)))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
for i in range(K):
  D = list(int(input()))
  A = list(map(int, input().split()))
list = set(A)
print(len(A) - len(list))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
c = 0
n = 1
for i in range(K):
  List = list(map(int, input().split()))
for I in range(N):
  if n in List:
  else:
    c = c+1
  n = n+1
print(c)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
c = 0
n = 1
for i in range(K):
  Lists = list(int(input()))
  List = list(map(int, input().split()))
for I in range(N):
  if n in List:
    n = n+1
  else:
    c = c+1
    n = n+1
print(c)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
c = 0
n = 1
List = []
for i in range(1,K):
  d = int(input())
  m = int(input())
  List.append(m)
for I in range(1,N):
  if n in List:
    n = n+1
  else:
    c = c+1
    n = n+1
print(c)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
c = 0
n = 1
w = 1
z = 1
while w<=K
  d = int(input())
  List = list(map(int, input().split()))
  w = w+1
while w<=N
  if n in List:
    n = n+1
    z = z+1
  else:
    c = c+1
    n = n+1
    z = z+1
print(c)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
c = 0
n = 0
for i in range(K):
  d = int(input())
  List = list(map(int, input().split()))
for I in range(N):
  n = n+1
  if n in List:
  else:
    c = c+1
print(c)
Problem p02701 (python)

Fixed submission:
N = int(input())
list = [input() for i in range(N)]
print(len(set(list)))

Buggy submission (verdict: Runtime Error):
N = input()
list = [input() for i in range(N)]
print(len(set(list)))

Buggy submission (verdict: Runtime Error):
N = input()
list = [input() for i in range(N)]
print(len(set(list)))

Buggy submission (verdict: Runtime Error):
N = input()
list = list(input() for i in range(N))
print(len(set(list)))

Buggy submission (verdict: Runtime Error):
N = input()
for i in range(N):
  a = input()
print(len(set(i)))

Buggy submission (verdict: Runtime Error):
N = input()
for i in range(N):
  i = input()
print(len(set(i)))
Problem p02711 (python)

Fixed submission:
N = input()
print("Yes" if "7" in N else "No")

Buggy submission (verdict: Runtime Error):
N = int(input())
print("Yes" if "7" in N else "No")
Problem p02723 (python)

Fixed submission:
S = input()
print("Yes" if S[2] == S[3] and S[4] == S[5] else "No")

Buggy submission (verdict: Runtime Error):
S = input()
print("Yes" if S[3] == S[4] and S[5] == S[6] else "No")

Buggy submission (verdict: Runtime Error):
S = input()
if S[3] == S[4] and S[5] == S[6]:
  print("Yes")
else:
  print("No")
Problem p02754 (python)

Fixed submission:
N, A, B = map(int, input().split())
print(min((N//(A+B))*A + N - (N//(A+B))*(A+B), (N//(A+B))*A + A))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
print(min((N//(A+B))A + N-(N//(A+B), (N//(A+B))A + A))
Problem p02771 (python)

Fixed submission:
A = list(input().split())
print("Yes" if len(set(A)) == 2 else "No")

Buggy submission (verdict: Runtime Error):
A = list(input().split())
print("Yes" if len(set(A)) == 2 and (A[0].count(A) == 1 or A[0].count(A) == 2) else "No")

Buggy submission (verdict: Runtime Error):
A = list(input().split())
print("Yes" if len(set(A)) == 2 and A[0].count(A) == 1 or A[0].count(A) == 2 else"No")
Problem p02777 (python)

Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
U = input()
print(A-1, B) if S==U else print(A, B-1)

Buggy submission (verdict: Runtime Error):
S, T = input().split()
A, B = map(int, input().split())
U = input()
print(A-1, B if s==T else A, B-1)
Problem p02790 (python)

Fixed submission:
a, b = input().split()
print(a*int(b) if a<=b else b*int(a))

Buggy submission (verdict: Runtime Error):
A, B = input()
print(min(A*int(B), B*int(A)))
Problem p02831 (python)

Fixed submission:
def resolve():
    A, B = map(int, input().split())
    ans = []
    for i in range(1, min(A, B)+1):
        if A%i == 0 and B%i == 0:
            ans.append(i)
    print(A*B//ans[-1])
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    A, B = map(int, input().split())
    ans = []
    for i in range(1, min(A, B+1)):
        if A%i == 0 and B%i == 0:
            ans.append(i)
    print(A*B//ans[-1])
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    import math
    A, B = map(int, input().split())
    print(A*B//math.gcd(A, B))
resolve()
Problem p02847 (python)

Fixed submission:
S = input()
week = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
print(7-week.index(S))

Buggy submission (verdict: Runtime Error):
S = input()
week = ["SUN", "MAN", "TUE", "WED", "THU", "FRI", "SAT"]
print(7-week.index(S))
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r**2)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
print("Yes" if N%2 == 0 and S[:N/2] == S[N/2:N])
Problem p02860 (python)

Fixed submission:
N = int(input())
S = input()
print("Yes" if S[:N//2] == S[N//2:N] else "No")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
print("Yes" if N%2 == 0 and S[:N/2] == S[N/2:N] else "No")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
print("Yes" if N%2 == 0 and S[:(N/2)+1] == S[(N/2)+1:N+1])

Buggy submission (verdict: Runtime Error):
N = input()
S = input()
print("Yes" if N%2 == 0 and S[:(N/2)+1] == S[(N/2)+1:N+1])
Problem p02881 (python)

Fixed submission:
def resolve():
    import math
    N = int(input())
    ans = []
    for i in range(1, math.floor(math.sqrt(N))+1):
        if N%i == 0:
            ans.append(i+N//i-2)
    print(min(ans))
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    import math
    N = int(input())
    ans = []
    for i in range(1, math.floor(math.sqrt(N))):
        if N%i == 0:
            ans.append(i+N//i-2)
    print(min(ans))
resolve()
Problem p03207 (python)

Fixed submission:
N = int(input())
list = [int(input()) for i in range(N)]
print(sum(list)-(max(list)//2))

Buggy submission (verdict: Runtime Error):
N = int(input())
list = [int(input()) for i in range(N)]
print(sum(list)-(max(N)//2))

Buggy submission (verdict: Runtime Error):
N = int(input())
list = [int(input()) for i in range(N)]
print(sum(list)-(max(N)/2))
Problem p03834 (python)

Fixed submission:
a, b, c = input().split(",")
print(a, b, c)

Buggy submission (verdict: Runtime Error):
a, b, c = input.split(",")
print(a, b, c)
Problem p02598 (python)

Fixed submission:
from math import ceil
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K==0:print(max(A));exit()

left,right=0,10**9+1
while right>left+1:
    cnt=K
    mid=(left+right)//2
    for i in range(N):
        cnt -=ceil(A[i]/mid)-1
    if cnt>=0:right=mid
    elif cnt<0:left=mid

print(right)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K==0:print(max(A));exit()

left,right=0,10**9+1
while right>left+1:
    cnt=K
    mid=(left+right)//2
    for i in range(N):
        cnt -=A[i]//mid
    if cnt>=0:right=mid
    elif cnt<0:left=mid

cnt=K
for i in range(N):
    cnt -=A[i]//left
print(left if cnt==0 else right)
Problem p02735 (python)

Fixed submission:
inf=float("inf")
h,w=map(int,input().split())
D=[[inf]*w for _ in range(h)]
D[0][0]=0

S=[list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        for x,y in ((1,0),(0,1)):
            X,Y=i+x,j+y
            if 0<=X<h and 0<=Y<w:
                if S[i][j]=="." and S[X][Y]=="#":D[X][Y]=min(D[i][j]+1,D[X][Y])
                else:D[X][Y]=min(D[i][j],D[X][Y])

#import numpy as np
#print(np.array(D))
ans=D[h-1][w-1]
print(ans if S[0][0]!="#" else ans+1)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
D=[[0]*w for _ in range(h)]

S=[list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        for x,y in ((1,0),(0,1)):
            X,Y=i+x,j+y
            if 0<=X<=h and 0<=Y<=w:
                if S[i][j]=="." and S[X][Y]=="#":
                    D[X][Y]=D[i][j]+1

ans=D[h-1][w-1]
print(ans if S[0][0]!="#" else ans+1)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
D=[[0]*w for _ in range(h)]

S=[list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        for x,y in ((1,0),(0,1)):
            X,Y=i+x,j+y
            if 0<=X<=h and 0<=Y<=w:
                if S[i][j]=="." and S[X][Y]=="#":
                    D[X][Y]=D[i][j]+1
                    
ans=D[h-1][w-1]
print(ans if S[0][0]!="#" else ans+1)
Problem p02757 (python)

Fixed submission:
from collections import Counter
n,p=map(int,input().split())
s=input()
DP=[0]
ans=0

if p==2 or p==5:
    for i,j in enumerate(s):
        if int(j)%p==0:
            ans +=i+1
else:
    num,point=0,1
    for i in s[::-1]:
        num +=int(i)*point
        num %=p
        DP.append(num)
        point *=10
        point %=p

    DP=Counter(DP)
    for v,m in DP.items():
        if m>=2:ans +=m*(m-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n,p=map(int,input().split())
s=input()[::-1]
DP=[0]

if p==2 or p==5:
    if s[0]%p==0:print(n*(n+1)//2)
    else:print(0)
else:
    num,point=0,1
    for i in s:
        num +=int(i)*point
        num %=p
        DP.append(num)
        point *=10
        point %=p
    
    ans=0
    DP=Counter(DP)
    for v,m in DP.items():
        if m>=2:ans +=m*(m-1)//2
    print(ans)