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

Fixed submission:
a,b,c,k = map(int, input().split())
if k <= a: 
  print(k)
elif k <= a+b:
  print(a)
else:
  print(2*a+b-k)

Buggy submission (verdict: Runtime Error):
a,b,c,k = map(int, input().split())
A=[1]*a
B=[0]*b
C=[-1]*c
L=A+B+C
print(sum(L[:k]))
Problem p02701 (python)

Fixed submission:
n = int(input())
S=[]
for i in range(n):
  S.append(input())
T = set(S)
print(len(T))

Buggy submission (verdict: Runtime Error):
n = int(input())
S=[]
for i in range(n):
  S.append(int(input()))
T = set(S)
print(len(T))
Problem p02725 (python)

Fixed submission:
k, n = map(int, input().split())
A=list(map(int, input().split()))
B=[]
for i in range(n-1):
  B.append(A[i+1]-A[i])
B.append(k-A[n-1]+A[0])
print(k-max(B))

Buggy submission (verdict: Runtime Error):
k, n = map(int, input().split())
A=[]
for i in range(n):
  A.append(int(input()))
B=[]
for i in range(n-1):
  B.append(A[i+1]-A[i])
B.append(k-A[n-1]+A[0])
print(k-max(B))
Problem p02726 (python)

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

def f(l, k):
  if l+1 <= k:
    return 0
  else:
    return l-k+1

def g(l, k):
  if l < 2*k:
    return 0
  elif l==2*k:
    return l/2
  else:
    return l

def h(l, m, k):
  M = 0
  for i in range(1, k):
    if  i<=l and k-i >1:
      M += g(m,k-i)*2/m
    elif i<=l:
      M +=1 
  return M
    
A=[n]
for k in range(2, n):
  c=f(n+x-y,k)+g(y-x+1,k)+h(x-1,y-x+1,k)+h(n-y,y-x+1,k)
  A.append(int(c))

for i in range(n-1):
  print(A[i])

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

def f(l, k):
  if l+1 <= k:
    return 0
  else:
    return l-k+1

def g(l, k):
  if l < 2*k:
    return 0
  elif l==2*k:
    return l/2
  else:
    return l

def h(l, m, k):
  M = 0
  for i in range(1,k):
    if i<=l:
      M += g(m,k-i)*2/m
  return M

A=[n]
for i in range(2, n):
  c=f(n+x-y,k)+g(y-x+1,k)+h(x-1,y-x+1,k)+h(n-y,y-x+1,k)
  A.append(c)
for i in range(n-1):
  print(A[i])
Problem p02771 (python)

Fixed submission:
A = list(map(int, input().split()))
B = set(A)
if len(B) == 2:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split()))
B = set(map(int, input().split()))
if len(B) == 2:
  print('Yes')
else:
  print('No')
Problem p02773 (python)

Fixed submission:
import collections
N = int(input())
S = []
for i in range(N):
  S.append(str(input()))
A = collections.Counter(S)
m = max(A.values())
for s in sorted(set(S)):
  if A[s] == m:
    print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = []
for i in range(N):
  S.append(input())
m = max(S.count(S[i]), for i in range(N))
S_new = set(S)
for s in S_new:
  if m == S.count(s):
    print(s)
Problem p03345 (python)

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

if a-b>10**18:
  print("Unfair")
elif k%2==0:
  print(a-b)
else:
  print(b-a)

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

if abs(a-b)>10**18:
  print("Unfair")
elif k%2==0-:
  
  print(a-b)
else:
  print(b-a)
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
bc_list = [list(map(int, input().split())) for _ in range(m)]
a_list.sort()
bc_list.sort(key=lambda i: -i[1])

a_idx = 0
bc_idx = 0
while bc_idx < len(bc_list):
    b, c = bc_list[bc_idx]
    finish = False
    for _ in range(b):
        if a_idx >= len(a_list):
            finish = True
            break
        if c > a_list[a_idx]:
            a_list[a_idx] = c
            a_idx += 1
        else:
            finish = True
            break
    if finish:
        break
    bc_idx += 1

print(sum(a_list))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
bc_list = [list(map(int, input().split())) for _ in range(m)]
a_list.sort()
bc_list.sort(key=lambda i: -i[1])

a_idx = 0
bc_idx = 0
while bc_idx < len(bc_list):
    b, c = bc_list[bc_idx]
    finish = False
    for _ in range(b):
        if c > a_list[a_idx]:
            a_list[a_idx] = c
            a_idx += 1
        else:
            finish = True
            break
    if finish:
        break
    bc_idx += 1

print(sum(a_list))
Problem p03986 (python)

Fixed submission:
X = input()

count = 0
count_s = 0
i = 0
while i < len(X):
    if i < len(X) - 1 and X[i] == 'S' and X[i+1] == 'T':
        count += 1
        i += 1
    elif X[i] == 'S':
        count_s += 1
    elif X[i] == 'T' and count_s > 0:
        count_s -= 1
        count += 1
    else:
        count_s = 0
    i += 1

count = min(count, 10 ** 10000)
print(len(X) - count * 2)

Buggy submission (verdict: Runtime Error):
x = input()
ans = len(x)


def do(i, j):
    global ans
    if x[i] == 'S' and x[j] == 'T':
        ans -= 2
        if i > 0 and j < len(x) - 1:
            do(i-1, j+1)
    if j - i == 1 and j < len(x) - 1:
        do(i+1, j+1)


do(0, 1)
print(ans)
Problem p02693 (python)

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

result = False
for i in range(A, B + 1):
    if (i % K) == 0:
        result = True
print("OK" if result else "NG")

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

result = False
for i in range(A, B + 1):
    if (i % K) == 0:
        result = True
print("OK" if result else "NG")
Problem p02754 (python)

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

ans = (n // (a+b)) * a
ama = n % (a+b)

if a <= ama:
    print(ans + a)
else:
    print(ans + ama)

Buggy submission (verdict: Runtime Error):
n,a,b = [int(x) for x in input().split()]

s = "b" * a + "r" * b

ans = (n // (a+b)) * a
ama = n % (a+b)

if a <= ama:
    print(ans + s[:ama].count("b"))
else:
    print(ans + ama)

Buggy submission (verdict: Runtime Error):
n,a,b = [int(x) for x in input().split()]

s = "b" * a + "r" * b

ans = (n // (a+b)) * a
ama = n % (a+b)

print(ans + s[:ama].count("b"))
Problem p03041 (python)

Fixed submission:
n, k = [int(x) for x in input().split()]
s = list(input())

s[k-1] = s[k-1].lower()

print(*s ,sep="")

Buggy submission (verdict: Runtime Error):
n, k = [int(x) for x in input().split()]
s = input()

s[k-1] = s[k-1].lower()

print(s)
Problem p03705 (python)

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

if a > b:
    print(0)
elif n == 1:
    if a != b:
        print(0)
    else:
        print(1)
else:
    print((b-a)*(n-2)+1)

Buggy submission (verdict: Runtime Error):
import itertools
n,a,b = [int(x) for x in input().split()]

r = range(a,b+1)
tmp = []
ans = 0

if a == b:
    print(1)
elif n == 1:
    print(0)
else:
    for v in itertools.combinations_with_replacement(r, n-2):
        if not sum(v) in tmp:
            ans += 1
            tmp.append(sum(v))

    print(ans)
Problem p02685 (python)

Fixed submission:
def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

n, m, k = [int(i) for i in input().split()]

ret = 0
for i in range(k+1):
  ret += ((cmb(n-1, i, p) * m % p) * (power_func(m-1, n-1-i, p))) % p
print(ret % p)

Buggy submission (verdict: Runtime Error):
def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = 10 ** 6
fact = [1, 1] + [0] * (N-2)
factinv = [1, 1] + [0] * (N-2)
inv = [0, 1] + [0] * (N-2)

for i in range(2, N + 1):
    fact[i] = (fact[i-1] * i) % p
    inv[i] = (-inv[p % i] * (p // i)) % p
    factinv[i] = (factinv[i-1] * inv[i-1]) % p

n, m, k = [int(i) for i in input().split()]

ret = 0
for i in range(k+1):
  ret += ((cmb(n-1, i, p) * m % p) * (power_func(m-1, n-1-i, p))) % p
print(ret % p)

Buggy submission (verdict: Runtime Error):
def power_func(a,n,p):
  bi=str(format(n,"b"))#2進表現に
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = 10 ** 6
fact = [1, 1] + [0] * (N-2)
factinv = [1, 1] + [0] * (N-2)
inv = [0, 1] + [0] * (N-2)

for i in range(2, N + 1):
    fact[i] = (fact[-1] * i) % p
    inv[i] = (-inv[p % i] * (p // i)) % p
    factinv[i] = (factinv[-1] * inv[-1]) % p

n, m, k = [int(i) for i in input().split()]

ret = 0
for i in range(k+1):
  ret += ((cmb(n-1, i, p) * m % p) * (power_func(m-1, n-1-i, p))) % p
print(ret % p)
Problem p03013 (python)

Fixed submission:
n, m = [int(i) for i in input().split()]
a = [-1] + [int(input()) for _ in range(m)] + [n+1]

fib_l = [-1] * (n+3)

def make_fib(n):
    fib_l[0] = fib_l[1] = 1
    for i in range(2, n):
        fib_l[i] = fib_l[i-1] + fib_l[i-2]

make_fib(n+3)
ret = 1
for i in range(m+1):
    t = a[i+1] - a[i] - 2
    if t < 0:
        ret = 0
        break
    ret *= fib_l[t]
print(ret % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
a = [-1] + [int(input()) for _ in range(m)] + [n+1]

fib_l = [-1] * (n+2)

def fib(step):
    if step < 0:
        return 0
    if fib_l[step] != -1:
        return fib_l[step]
    if 0 <= step <= 1:
        return 1
    else:
        t = fib(step-1) + fib(step-2)
        fib_l[step] = t
        return t

ret = 1
for i in range(m+1):
    ret *= fib(a[i+1] - a[i] - 2)
print(ret % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
a = [-1] + [int(input()) for _ in range(m)] + [n+1]

fib_l = [-1] * (n+1)

def fib(step):
    if step < 0:
        return 0
    if fib_l[step] != -1:
        return fib_l[step]
    if 0 <= step <= 1:
        return 1
    else:
        t = fib(step-1) + fib(step-2)
        fib_l[step] = t
        return t

ret = 1
for i in range(m+1):
    ret *= fib(a[i+1] - a[i] - 2)
print(ret % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
a = [-1] + [int(input()) for _ in range(m)] + [n+1]

fib_l = [-1] * n

def fib(step):
    if step < 0:
        return 0
    if fib_l[step] != -1:
        return fib_l[step]
    if 0 <= step <= 1:
        return 1
    else:
        t = fib(step-1) + fib(step-2)
        fib_l[step] = t
        return t

ret = 1
for i in range(m+1):
    ret *= fib(a[i+1] - a[i] - 2)
print(ret % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
a = [-1] + [int(input()) for _ in range(m)] + [n+1]

fib_l = [-1] * n

def fib(step):
    if step < -1:
        return 0
    if fib_l[step] != -1:
        return fib_l[step]
    if 0 <= step <= 1:
        return 1
    else:
        t = fib(step-1) + fib(step-2)
        fib_l[step] = t
        return t

ret = 1
for i in range(m+1):
    ret *= fib(a[i+1] - a[i] - 2)
print(ret % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
a = [-1] + [int(input()) for _ in range(m)] + [n+1]

fib_l = [-1] * n

def fib(step):
    if fib_l[step] != -1:
        return fib_l[step]
    if 0 <= step <= 1:
        return 1
    else:
        t = fib(step-1) + fib(step-2)
        fib_l[step] = t
        return t

ret = 1
for i in range(m+1):
    ret *= fib(a[i+1] - a[i] - 2)
print(ret % 1000000007)
Problem p02711 (python)

Fixed submission:
from sys import stdin

A=input()
if A[0]=='7' or A[1]=='7' or A[2]=='7':
    print("Yes\n")
else:
    print("No\n")

Buggy submission (verdict: Runtime Error):
from sys import stdin
import numpy as np

k=int(input())
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            ans+=np.gcd(i,np.gcd(j,k))
print(str(ans)+"\n")
Problem p02754 (python)

Fixed submission:
from sys import stdin

n,a,b=map(int,input().split())
ans=0
ans+=(n//(a+b))*a
n%=a+b
if n<=a:
    ans+=n
else:
    ans+=a
print(str(ans)+"\n")

Buggy submission (verdict: Runtime Error):
from sys import stdin

n,a,b=map(int,input().split())
ans=0
ans+=(n//(a+b))*a
n%=a+b
if n<=a:
    ans+=n
else:
    ans+=a
print(str(ans)+"\n)
Problem p02754 (python)

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

ans =N//(A+B)*A
remain = N%(A+B)
ans += min(remain,A)
print(ans)

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

line =''

for i in range(10**100):
    line += 'b'*A
    line += 'r'*B
    if len(line)>=N:
        print(line[:N].count('b'))
        break
Problem p02835 (python)

Fixed submission:
A, B, C =map(int,input().split())
if A+B+C >=22:
  print('bust')
else:
  print('win')

Buggy submission (verdict: Runtime Error):
A, B, C =map(int,input().shape())
if A+B+C >=22:
  print('bust')
else:
  print('win')
Problem p02676 (python)

Fixed submission:
def main():
    K = int(input())
    S = input()
    if(len(S)<=K):
        print(S)
    else:
        print(S[0:K] + '...')
    
 
main()

Buggy submission (verdict: Runtime Error):
def main():
    k = input()
    s = input()
    if(len(s)<k):
        print(s)
    else:
        print(s[0:k] + '...')
    
 
main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    k = input()
    if(len(s)<=k):
        print(s)
    else:
        print(s[0:k] + '...')
    
 
main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    k = input()
    if(len(s)<k):
        print(s)
    else:
        print(s[0:k] + '...')
    
 
main()
Problem p02829 (python)

Fixed submission:
A = int(input())
B = int(input())

print(6-A-B)

Buggy submission (verdict: Runtime Error):
#from fractions import gcd
#A,B = map(int, input().split())
#print(A*B//gcd(A,B))
def gcd(a,b):
    if(a<b):
         b,a=a,b
    if(b==0):
        return a
    r = a%b
    if(r!=0) :
        a,b,r=b,r,b%r
        return gcd(b,r)
    else:
        return b

A,B = map(int, input().split())
print(A*B//gcd(A,B))
Problem p02676 (python)

Fixed submission:


if __name__ == '__main__':
    k = int(input());
    s = input();

    cnt=0
    for i in s:
        print(i, end='')
        cnt+=1
        if cnt>=k:
            break

    if k < len(s):
        print('...')

Buggy submission (verdict: Runtime Error):

import sys

def test(k,s):
    cnt=0

    length = len(s)
    if k<length:
        return s[:k]+'...'
    return s

if __name__ == '__main__':
    print(test(sys.argv[0],sys.argv[1]))
Problem p03012 (python)

Fixed submission:
T= int(input())
w = list(map(int, input().split()))

m = sum(w)
b = m
answer = T
for t in range(1, T):
    k = sum(w[0:t+1])
    diff= abs(2*k - m) 
    if diff < b:
        b = diff 
    else:
        break
print(b)

Buggy submission (verdict: Runtime Error):
now = 0
before = -9999
answer = 1

for a in a_n:
    if a - before == 1:
        answer = 0
        break    
    answer *= Fib( a - 1 - now + 2 )
    answer %= 1000000007
    now = a + 1
    before = a

if answer > 0:
    answer *= Fib( N - now + 2)
    answer %= 1000000007

print(answer )
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
a_n = [int(input()) for i in range(M)]
def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
now = 0
before = -9999
answer = 1

for a in a_n:
    if a - before == 1:
        answer = 0
        break

    answer *= Fib( a - 1 - now + 2 )
    answer %= 1000000007
    now = a + 1
    before = a

if answer > 0:
    answer *= Fib( N - now + 2)
    answer %= 1000000007

print(answer)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a_n = [int(input()) for i in range(M)]
def Fib(n):    
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return Fib(n-1)+Fib(n-2)
now = 0
before = -9999
answer = 1

for a in a_n:
    if a - before == 1:
        answer = 0
        break    
    answer *= Fib( a - 1 - now + 2 )
    answer %= 1000000007
    now = a + 1
    before = a

if answer > 0:
    answer *= Fib( N - now + 2)
    answer %= 1000000007

print(answer)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a_n = [int(input()) for i in range(M)]

def Fib(n):    
    if n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return Fib(n-1)+Fib(n-2)
      
now = 0
before = -9999
answer = 1

for a in a_n:
    if a - before == 1:
        answer = 0
        break    
    answer *= Fib( a - 1 - now + 2 )
    now = a + 1
    before = a

if answer > 0:
    answer *= Fib( N - now + 2)

print(answer % 1000000007)
Problem p02676 (python)

Fixed submission:
K=int(input())
S=input()

if len(S) > K:
  S = S[:K] + "..."
  
print(S)

Buggy submission (verdict: Runtime Error):
import sys

K = int(input())
S = input()
sentence = list(S)
sentencelong = len(sentence)

if K < sentencelong:
  print(sentence[:K] + '...')
elif K > sentencelong:
  print(S)
  
else:
  sys.exit()

Buggy submission (verdict: Runtime Error):
K = int(input())
S = input()
sentence = list(S)

for i in range(K):
  print(sentence[i], end="")

sentencelong = len(sentence)

if K < sentencelong:
  print("...")

Buggy submission (verdict: Runtime Error):
K = int(input())
S = input()
sentence = list(S)

for i in range(K):
  print(sentence[i], end="")
  
print("...")
Problem p02689 (python)

Fixed submission:
n,m = map(int,input().split())
h = list(map(int,input().split()))
p = [0 for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] >= h[b-1]:
        p[b-1] = -1
    if h[a-1] <= h[b-1]:
        p[a-1] = -1
print(p.count(0))

Buggy submission (verdict: Runtime Error):
n,m=input().split()
h_list = []
h_list = input().split(" ")
result =[True]*n
count = 0
for i in range(int(m)):
    temp1,temp2=input().split()
    if h_list[int(temp1)-1] < h_list[int(temp2)-1]:
        result[int(temp1)-1] = False
    elif h_list[int(temp1)-1] == h_list[int(temp2)-1]:
        result[int(temp1) - 1] = False
        result[int(temp2) - 1] = False
    else:
        result[int(temp2)-1] = False
for i in range(int(n)):
    if(result[i]==True):
        count += 1
print(count)
Problem p02831 (python)

Fixed submission:
A,B = (int(i) for i in input().split())
def gcd(a,b):
    if a % b == 0:
        return b
    else:
        r = a% b
        return gcd(b,r)
print(A*B//gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math
A,B = (int(i) for i in input().split())
g = math.gcd(A,B)
print(A*B//g)

Buggy submission (verdict: Runtime Error):
import math
A,B = (int(i) for i in input().split())
g = math.gcd(A,B)
print(A*B/g)
Problem p02835 (python)

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

if a + b + c <= 21:
    print("win")

else:
    print("bust")

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

if a + b + c <= 21:
    print("win")

else:
    print("bust")12
Problem p02912 (python)

Fixed submission:
import bisect
n,m = map(int,input().split())
a = list(map(int,input().split()))
while m != 0:
    a.sort()
    where = bisect.bisect_left(a,a[-1]//2)
    where = abs(where-(n+1))
    for i in range(1,min(where,m+1)):
        a[-i] = a[-i]//2
        m = m-1
print(sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
if n == 1:
	print(a[0]//(2**m))
else:
	for s in range(m):
		maxnum = 0
		flag = 0
		for t in range(s):
			if maxnum <= a[t]:
				maxnum = a[t]
				flag = t
		a[flag] = a[flag]//2
	print(sum(a))
Problem p03307 (python)

Fixed submission:
n = int(input())
if n % 2 == 0:
	print(n)
else:
	print(2 * n)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
print(2 * n // math.gcd(2 , n))
Problem p03315 (python)

Fixed submission:
s = list(input())
ans = 0
for c in s:
  if c == '+':
    ans += 1
  else:
    ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = list[input()]
ans = 0
for c in s:
  if c == '+':
    ans += 1
  else:
    ans -= 1
print(ans)
Problem p03346 (python)

Fixed submission:
N = int(input())
dp = [None for _ in range(N)]
for i in range(N):
  p = int(input())
  if dp[p - 2] == None or p == 1:
    dp[p - 1] = 1
  else:
    dp[p - 1] = dp[p - 2] + 1
print(N - max(dp))

Buggy submission (verdict: Runtime Error):
N = int(input())
dp = [None for _ in range(N)]
for i in range(N):
  p = int(input())
  if (p != 1) and (dp[p - 2] == None):
    dp[p - 1] = 1
  else:
    dp[p - 1] = dp[p - 2] + 1
print(N - max(dp))

Buggy submission (verdict: Runtime Error):
N = int(input())
dp = [None for _ in range(N)]
for i in range(N):
  p = int(input())
  if p != 1 and (dp[p - 2]) == None:
    dp[p - 1] = 1
  else:
    dp[p - 1] = dp[p - 2] + 1
print(N - max(dp))

Buggy submission (verdict: Runtime Error):
N = int(input())
dp = [None for _ in range(N)]
for i in range(N):
  p = int(input())
  if 0 <= p - 2 and dp[p - 2] == None:
    dp[p - 1] = 1
  else:
    dp[p - 1] = dp[p - 2] + 1
print(N - max(dp))
Problem p03135 (python)

Fixed submission:
T, X = map(int, input().split()) 
print(T / X)

Buggy submission (verdict: Runtime Error):
T, X = map(int, input.split()) 
print(T / X)
Problem p02695 (python)

Fixed submission:
N, M, Q = list(map(int, input().split()))
Qs = [list(map(int, input().split())) for i in range(Q)]

patterns = []
def dfs(a):
  if len(a) == N:
    patterns.append(a)
  else:
    for i in range(int(a[-1]), M+1):
   	  dfs(a+[i])

dfs(a=[1])
result = 0
for p in patterns:
  r = 0
  for q in Qs:
    if p[q[1]-1]-p[q[0]-1]==q[2]:
      r += q[3]
  #print(p, r)
  result = max([result, r])
print(result)

Buggy submission (verdict: Runtime Error):
N, M, Q = list(map(int, input().split()))
Qs = [list(map(int, input().split())) for i in range(Q)]

patterns = []
def dfs(a):
  if len(a) == N:
    patterns.append(a)
  else:
    for i in range(int(a[-1]), M+1):
   	  dfs(a+str(i))

dfs("1")
result = 0
for p in patterns:
  p = [int(i) for i in p]
  r = 0
  for q in Qs:
    if p[q[1]-1]-p[q[0]-1]==q[2]:
      r += q[3]
  #print(p, r)
  result = max([result, r])
print(result)
Problem p02754 (python)

Fixed submission:
N = list(map(int, input().split()))
print((N[0]//(N[1]+N[2]))*N[1] + min([N[0]%(N[1]+N[2]), N[1]]))

Buggy submission (verdict: Runtime Error):
N = list(map(int, input().split()))
print((N[0]//(N[1]+N[2])*N[1] + min([N[0]%(N[1]+N[2]), N[1]]))
Problem p02833 (python)

Fixed submission:
N = int(input())
if N % 2 == 1:
  print(0)
else:
  i = 10
  result = 0
  while N >= i:
    result += N//i
    i *= 5
  print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 1:
  print(0)
else:
  # i = 5 で始めると奇数が入る
  i = 10
  result = 0
  while N > i:
    result += N//i
    i *= 5
print(result)