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

Fixed submission:
i = input()
i1 = list(map(int, i.split() ) )
i2 = i1[0] - i1[1]
i3 = i1[2] - i2
if i3 < 0:
 print("0")
else:
 print(i3)

Buggy submission (verdict: Runtime Error):
i = input()
6 4 3
i1 = list(map(int, i.split() ) )
i2 = i1[0] - i1[1]
i3 = i1[2] - i2
		if i3 < 0:
 				print(0)
		else:
 				print(i3)

Buggy submission (verdict: Runtime Error):
i = input()
i1 = list(map(int, i.split() ) )
i2 = i1[0] - i1[1]
i3 = i1[2] - i2
		if i3 < 0:
 				i3 = 0
		else:
 				i3 = i3

print(i3)
Problem p02959 (python)

Fixed submission:
N = int(input())

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

Y = list(map(int, input().split()))

sum_M = []
for i in range(0, N+1):
 if i == 0:
  p1 = max(0, Y[0] - M[0])
  sum_M.append(min(M[0], Y[0]) ) 
 elif i < N:
  sum_M.append(min(M[i], Y[i] + p1) )
  p1 = min(Y[i], max(0, Y[i] - M[i] + p1) )
 else:
  sum_M.append(min(M[i], p1) )
  p1 = max(0, p1 - M[i])  

print(sum(sum_M))

Buggy submission (verdict: Runtime Error):
N = int(input())

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

Y = list(map(int, input().split()))

sum_M = []
for i in range(0, N+1):
 if i == 0:
  p1 = max(0, Y[0] - M[0])
  sum_M.append(min(M[0], Y[0]) ) 
 elif i < N:
  sum_M.append(min(M[i], Y[i] + p1) )
  p0 = 
  p1 = min(Y[i], max(0, Y[i] - (M[i] + p1)) )
 else:
  sum_M.append(min(M[i], p1) )
  p1 = max(0, p1 - M[i])  

print(sum(sum_M))
Problem p02970 (python)

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

o1 = ((i1[0]) // (i1[1]*2 + 1))
o2 = ((i1[0]) % (i1[1]*2 + 1))
if o2 == 0:
    print(o1)
else:
    print(o1 + 1)

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

o1 = ((i1[0]) // (i1[1]*2 + 1))
o2 = ((i1[0]) % (i1[1]*2 + 1))
if o2 == 0:
    print(o1)
else:
    print(o1 + 1)
Problem p02990 (python)

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

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**4
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 )

for i in range(1, k+1):
    a1 = cmb(n-k+1, i, mod)*cmb(k-1, i-1, mod)
    print(a1%mod)

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

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**4
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 )

if k > n-1:
    r1 = n-1
else:
    r1 = k
for i in range(1, r1+1):
    a1 = cmb(n-k+1, i, mod)*cmb(k-1, i-1, mod)
    a2 = (a1 + a2)%mod
    print(a1)

Buggy submission (verdict: Runtime Error):
n,k = list(map(int, input().split()))
blue = k
red = n-k
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**4
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 )

for i in range(1, k+1):
    a1 = cmb(red+1, i, mod)*cmb(k-1, i-1, mod)
    a2 = (a1 + a2)%mod
    print(a1)

Buggy submission (verdict: Runtime Error):
n,k = list(map(int, input().split()))
blue = k
red = n-k
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**4
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 )

for i in range(1, k+1):
    a1 = cmb(red+1, i, mod)*cmb(k-1, i-1, mod)
    a2 = (a1 + a2)%mod
    print(a1)
Problem p03265 (python)

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

a,b = (n[2] - n[0]), (n[3] - n[1])

o1,o2 = (n[2] - b), (n[3] + a)
o3,o4 = (o1 - a),(o2 - b)

print(" ".join(list(map(str, [o1,o2,o3,o4]))))

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

a,b = (n[2] - n[0]), (n[3] - n[1])

o1,o2 = (n[2] - b), (n[3] + a)
o3,o4 = (o1 - a),(o2 - b)

print(" ".join([o1,o2,o3,o4]))
Problem p02793 (python)

Fixed submission:
import fractions
from functools import reduce

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(l):
    return reduce(lcm, l, 1)


ans = 0

dev = 10 ** 9 + 7

n = int(input())

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

z = lcm_list(a)



for i in a:
    ans += z // i
    #ans = ans % dev

print(ans%dev)

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(l):
    return reduce(lcm, l, 1)


ans = 0

dev = 10 ** 9 + 7

n = int(input())

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

z = lcm_list(a) * 


for i in a:
    ans += z // i
    #ans = ans % dev

print(ans%dev)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(l):
    return reduce(lcm, l, 1)


ans = 0

dev = 10 ** 9 + 7

n = int(input())

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

z = lcm_list(a)


for i in a:
    ans += z // i
    ans = ans % dev

print(ans)
Problem p03135 (python)

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

print(t/x)

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

line = map(int, input().split())

line.sort(reverse=True)

if line[0] < sum(line):
  print("Yes")
else:
  print("No")
Problem p02847 (python)

Fixed submission:
s = input()
target =  ["MON","TUE","WED","THU","FRI","SAT","SUN"]
print(7 if s=="SUN" else 7-(target.index(s)+1))

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
l = 1
r = 10**9
num = 0
b_num = 0
if 10**9*a + b*9 <= x:
  print(10**9)
elif a+b > x:
  print(0)
else:
  while 1:
    num = (l+r)//2
    if r - l == 1:
      c = [l*a+len(str(l))*b,r*a+len(str(r))*b]
      print(r if c[1]<=x else l)
      break
    cost = a*num+b*len(str(num))
    if cost < x:
      l = num
    else:
      r = num
    b_num = num
Problem p03013 (python)

Fixed submission:
N,M = map(int,input().split())
num = 1000000007

hole = [False]*(N+1)
a = [int(input()) for _ in range(M)]
for i in a:
  hole[i] = True
  
dp = [0]*(N+1)
dp[0] = 1


for i in range(1,N+1):
  if i == 1:
    if hole[i] == True:
      dp[i] = 0
    else:
      dp[i] = dp[0]
  else:
    if hole[i] == True:
      dp[i] = 0
    else:
      dp[i] = dp[i-1] + dp[i-2]
print(dp[-1]%num)

Buggy submission (verdict: Runtime Error):
import math
N,M = map(int,input().split())
a = []
flg = False

for i in range(M):
  a_ = int(input())
  a.append(a_)
  if a_ - a[i-1] == 1:
    flg = True

if flg == True:
  print(0)
else:
  before = 0
  ans = 1
  for i in a:
    step = i-before
    two = (step-1)//2
    p = 0
    if two < 1:
      p = 1
    else:
      for j in range(1,two+1):
        p += math.factorial(step-1-j)/math.factorial(j)/math.factorial(step-1-j-j)
      p += 1
      ans = ans * p
      ans = ans % 1000000007
      before = i
  step = N-before
  two = (step-1)//2
  p = 0
  if two < 1:
    p = 1
  else:
    for j in range(1,two+1):
      p += math.factorial(step-1-j)/math.factorial(j)/math.factorial(step-1-j-j)
    p += 1
  ans = ans * p
  ans = ans % 1000000007
  print(int(ans))
Problem p03209 (python)

Fixed submission:
n,x = map(int,input().split())
a,p = [1],[1]
for i in range(n):
  a.append(2*a[i]+3)
  p.append(2*p[i]+1)

def f(N,X):
  if N==0:
    return 0 if X<=0 else 1
  elif X <= 1+a[N-1]:
    return f(N-1,X-1)
  else:
    return p[N-1]+1+f(N-1,X-2-a[N-1])
print(f(n,x))

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
#@lru_cache(maxsize=3000)
@memoize
def burger(str_b,level):
  if(level == 0):
    return str_b + 'p'
  str_b += 'B'
  str_b = burger(str_b,level-1)
  str_b += 'p'
  str_b = burger(str_b,level-1)
  str_b += 'B'
  return str_b


str_b = ''
N,X = map(int,input().split())
str_b = burger(str_b,N)
b_list = list(str_b)
eat_list = b_list[::-1]
eat_list = b_list[0:X]
print(eat_list.count('p'))
Problem p02723 (python)

Fixed submission:
s=[]
s=list((input()))
if s[2]==s[3] and s[4]==s[5]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
k,n=map(int,input().split())
a=[]
a=list(map(int,input().split()))
dis=[]
dis.append(a[0]+(k-a[n-1]))
for i in range(n-1):
    dis.append(a[i+1]-a[i])
print(k-min(dis))

Buggy submission (verdict: Runtime Error):
s=[]
s=list(srt(input().split()))
if s[2]==s[3] and s[4]==s[5]:
    print('Yes')
else:
    print('No')
Problem p02726 (python)

Fixed submission:
n,x,y=map(int,input().split())
ans=[0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        a=min(j-i,abs(j-y)+1+abs(x-i),abs(y-i)+1+abs(x-j))-1
        ans[a]+=1
for i in range(len(ans)):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n,x,y=map(int,input().split())
ans=[0]*n
for i in range(1,n):
    for j in range(i+1,n+1):
        a=min(j-i,abs(j-y)+1+abs(x-i),abs(y-i)+1+abs(x-j))
        ans[a]+=1
for i in range(ans):
    print(ans[i])
Problem p03075 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if b-a<=k and c-a<=k and d-a<=k and e-a<=k and c-b<=k and d-b<=k and e-b<=k and d-c<=k and e-c<=k and e-d<=k:
  print('Yay!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
n=int(input())
math inport ceil
a=[]
for i in range(5):
  a.append(int(input()))
print(ceil(n/min(a))+4)
Problem p03107 (python)

Fixed submission:
s = str(input())
figure1 = s.count('0')
figure2 = s.count('1')
print(min(figure1, figure2)*2)

Buggy submission (verdict: Runtime Error):
s=str(input())
a=s.count('0')
print(min(ss,len(s)-ss)*2)
Problem p03207 (python)

Fixed submission:
n=int(input())
l=[]
for _ in range(n):
    l.append(int(input()))
print(sum(l)-int(max(l)/2))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=[]
for _ in range(n):
    l.append(int(input()))
l.sort()
a=0
for i in range(n-k+1):
    if i==0:
        a=l[i+k-1]-l[i]
    else:
        a=min(a,abs(l[i+k-1]-l[i]))
print(a)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=[]
for _ in range(n):
    l.append(int(input()))
l.sort()
a=0
for i in range(n-k+1):
    if i==0:
        a=l[i+k-1]-l[i]
    else:
        a=min(a,abs(l[i+k-1]-l[i]))
print(a)
n,k=map(int,input().split())
l=[]
for _ in range(n):
    l.append(int(input()))
l.sort()
a=0
for i in range(n-k+1):
    if i==0:
        a=l[i+k-1]-l[i]
    else:
        a=min(a,abs(l[i+k-1]-l[i]))
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[]
for _ in range(n):
    l.append(int(iｂnput()))
print(sum(l)-int(max(l)/2))
Problem p03272 (python)

Fixed submission:
n,i=map(int,input().split())
print(n-i+1)

Buggy submission (verdict: Runtime Error):
n,i=map(int、input().split())
print(n-i+1)
Problem p03834 (python)

Fixed submission:
print(input().replace(',',' '))

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

a = 0
for i in range(K + 1):
    r = S - i
    if i <= S and r <= K * 2:
        t = (r + 1) - max(0, r - K) * 2
        a += t

print(a)
Problem p03104 (python)

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

def f(x):
  amari = x % 4
  if amari == 0:
    return x
  elif amari == 1:
    return x ^ (x-1)
  elif amari == 2:
    return x ^ (x-1) ^ (x-2)
  elif amari == 3:
    return 0
    
    
A = f(a-1)
B = f(b)


print(A^B)

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

B_2 = str(bin(B)[2:])
B_2_len = len(B_2)
b_a = B-A


'''考え方
B,Aの差分が（２の倍数-1）なら、0も1も偶数個入り続ける。
Bの桁数分ループする
'''

oct = ''
for b in range(1,B_2_len+1,1):
  if b_a % (b ** 2 - 1) == 0:
    oct = '0' + oct
  else:
    oct = '1' + oct



# 2進数を１０進数に変換
out = int(oct, 2)
print(out)
Problem p03317 (python)

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

inf = 10 ** 18

for i in range(1,inf):
  N -= (K - 1)
  if N <= 1:
    print(i)
    break

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

inf = 10 ** 18

for i in range(1,inf):
  N -= (K - 1)a
  if N <= 1:
    print(i)
    break
Problem p02915 (python)

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

Buggy submission (verdict: Runtime Error):
n=int(input())
print(n**3))
Problem p03208 (python)

Fixed submission:
from statistics import mean, median,variance,stdev
import sys
import math

x = input().split()
#y = input().split()


#y = int(input())
#x = int(input())
a = []
b = int(x[0])
num = int(x[1])
for i in range(b):
    a.append(int(input()))
a = sorted(a)
min = a[num-1]-a[0]
for i in range(num,b):
    if min > a[i]-a[i-num+1]:
        min = a[i]-a[i-num+1]
if min > a[b-1]-a[b-num]:
    min = a[b-1]-a[b-num]
print(min)

Buggy submission (verdict: Runtime Error):
from statistics import mean, median,variance,stdev
import sys
import math

x = input().split()
#y = input().split()


#y = int(input())
#x = int(input())
a = []
n = int(x[0])
k = int(x[1])
for i in range(k):
    a.append(int(input()))
a = sorted(a)
p = []
for i in range(n-k-1):
    p.append(a[i+k-1]-a[i])
print(min(p))
Problem p02725 (python)

Fixed submission:
k,n=map(int,input().split())
a=list(map(int,input().split()))+[k]
d=abs(a[0]+(k-a[-2]))
for i in range(n):
  d=max(d,abs(a[i]-a[i+1]))
print(k-d)

Buggy submission (verdict: Runtime Error):
k,n=map(int,input().split())
a=list(map(int,input().split()))
d=abs(d[0]-d[-1])
for i in range(n-1):
  d=max(d,abs(a[i]-a[i+1]))
print(k-d)
Problem p02773 (python)

Fixed submission:
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
c=Counter(s)
t=[]
u=c.most_common()
v=u[0][1]
t.append(u[0][0])
for i in range(1,len(c)):
  a=u[i][1]
  if v>a:
    break
  else:
    t.append(u[i][0])
t.sort()
for i in t:
  print(i)

Buggy submission (verdict: Runtime Error):
import Counter
n=int(input())
s=[input() for i in range(n)]
c=Counter(s)
l=list(c)
l.sort(key=lambda x:x[1],reverse=True)
a=l[0][1]
i=0
while i<n and l[i][1]==a:
  print(l[i][0])
  i+=1

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
s=[input() for i in range(n)]
c=Counter(s)
t=[]
v=c.most_common()[0][1]
t.append(c.most_common()[0][0])
for i in range(1,n):
  a=c.most_common()[i][1]
  if v>a:
    break
  else:
    t.append(c.most_common()[i][0])
t.sort()
for i in t:
  print(i)
Problem p02829 (python)

Fixed submission:
print(6-int(input())-int(input()))

Buggy submission (verdict: Runtime Error):
print(6-int(input)-int(input))
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
a=set()
for i in range(m):
  a.add(int(input()))
mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
if 1 in a:
  dp[1]=0
else:
  dp[1]=1
if n==1:
  print(dp[1])
  exit()
if 2 in a:
  dp[2]=0
else:
  dp[2]=dp[1]+1
for i in range(3,n+1):
  if i in a:
    dp[i]=0
  else:
    dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=set()
for i in range(m):
  a.add(int(input()))
mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
if 1 in a:
  dp[1]=0
else:
  dp[1]=1
if 2 in a:
  dp[2]=0
else:
  dp[2]=dp[1]+1
for i in range(3,n+1):
  if i in a:
    dp[i]=0
  else:
    dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
if m==0:
  dp=[0]*(n+1)
  dp[1]=dp[2]=1
  for i in range(n+1):
    dp[i]=(dp[i-1]+dp[i-2])%mod
  print(dp[n])
  exit()
a=[int(input()) for i in range(m)]
mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
if n==1:
  print(1)
  exit()
if a[0]==1:
  dp[1]=0
else:
  dp[1]=1
a=set(a)
for i in range(2,n+1):
  if i in a:
    dp[i]=0
  else:
    dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
if n==1:
  print(1)
  exit()
if a[0]==1:
  dp[1]=0
else:
  dp[1]=1
a=set(a)
for i in range(2,n+1):
  if i in a:
    dp[i]=0
  else:
    dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
dp=[0]*(n+1)
dp[0]=1
if a[0]==1:
  dp[1]=0
else:
  dp[1]=1
a=set(a)
for i in range(2,n+1):
  if i in a:
    dp[i]=0
  else:
    dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input())-1 for i in range(m)]
a=set(a)
mod=10**9+7
dp=[0]*n
dp[0]=1
if a[0]==1:
  dp[1]=0
else:
  dp[1]=1
for i in range(2,n):
  if i in a:
    dp[i]=0
  else:
    dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[n-1])
Problem p03073 (python)

Fixed submission:
s=list(input())
cnt=0
for i in range(1,len(s)):
  if s[i]==s[i-1]=='1':
    cnt+=1
    s[i]='0'
  elif s[i]==s[i-1]=='0':
    cnt+=1
    s[i]='1'
print(cnt)

Buggy submission (verdict: Runtime Error):
s=list(input())
cnt=0
for i in range(1,n):
  if s[i]==s[i-1]=='1':
    cnt+=1
    s[i]='0'
  elif s[i]==s[i-1]=='0':
    cnt+=1
    s[i]='1'
print(cnt)
Problem p03208 (python)

Fixed submission:
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
ans=10**18
for i in range(k,n+1):
  ans=min(ans,h[i-1]-h[i-k])
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
ans=10**18
for i in range(k,n+1):
  ans=min(h[i-1]-h[i-k])
print(ans)
Problem p03252 (python)

Fixed submission:
from collections import Counter
s=input()
t=input()
cntS=list(Counter(s).values())
cntT=list(Counter(t).values())
cntS.sort()
cntT.sort()
print('Yes' if cntS==cntT else 'No')

Buggy submission (verdict: Runtime Error):
from collections import Counter
s=input()
t=input()
c1=Counter(s)
c2=Counter(t)
c1.sort()
c2.sort()
print('Yes' if c1==c2 else 'No')
Problem p03346 (python)

Fixed submission:
n=int(input())
p=[int(input()) for _ in range(n)]
dp=[0]*(n+10)
for i in p:
  dp[i]=dp[i-1]+1
print(n-max(dp))

Buggy submission (verdict: Runtime Error):
n=int(input())
p=[int(input()) for _ in range(n)]
dp=[0]*(n+10)
for i in p:
  dp[p]=dp[p-1]+1
print(n-max(dp))
Problem p03822 (python)

Fixed submission:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**7)
n=int(input())
t=[[] for i in range(n)]
for i in range(1,n):
  a=int(input())
  t[a-1].append(i)
def dfs(v):
  if not t[v]:
    return 0
  l=[dfs(i)+1 for i in t[v]]
  l.sort()
  for i in range(len(t[v])-1):
    l[i+1]=max(l[i+1],l[i]+1)
  return l[-1]
print(dfs(0))

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
n=int(input())
t=[[] for i in range(n)]
for i in range(1,n):
  a=int(input())
  t[a-1].append(i)
def dfs(v):
  if not t[v]:
    return 0
  l=[dfs(i)+1 for i in t[v]]
  l.sort()
  for i in range(len(t[v])-1):
    l[i+1]=max(l[i+1],l[i]+1)
  return l[-1]
print(dfs(0))
Problem p02831 (python)

Fixed submission:
import sys
from fractions import gcd

lines = sys.stdin.readlines()

a, b = map(int, lines[0].split())

x = gcd(a, b)

print(x * (a//x) * (b//x))

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

lines = sys.stdin.readlines()

a, b = map(int, lines[0].split())

x = gcd(a, b)

print(x * (a//x) * (b//x))

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

lines = sys.readlines()

a, b = map(int, lines[0].split())

x = gcd(a, b)

print(x * (a//x) * (b//x))
Problem p02754 (python)

Fixed submission:
N, blue, red = map(int, input().split())

ans = N // (blue + red) * blue
rem = N % (blue + red)
ans += min(rem, blue)
print(ans)

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


def count_blue(N, blue, red):
  
  if blue == 0:
    return 0
  elif N <= blue:
    return N
  elif N <= blue + red:
    return blue
  else:
    return (N // (blue + red) * blue) + count_blue(N // (blue + red), blue, red)
  
  
print(count_blue(N, blue, red))
Problem p02847 (python)

Fixed submission:
S = input()

if S == "SAT":
    res = "1"
elif S == "SUN":
    res = "7"
elif S == "MON":
    res = "6"
elif S == "TUE":
    res = "5"
elif S == "WED":
    res = "4"
elif S == "THU":
    res = "3"
elif S == "FRI":
    res = "2"
print(res)

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

if S == "SAT":
    res = "1"
elif S == "SUN":
    res = "7"
elif S == "MON":
    res = "6"
elif S == "TUE":
    res = "5"
elif S == "WED":
    res = "4"
elif S == "THU":
    res = "3"
elif S == "Fri":
    res = "2"
print(res)

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

if S == "SAT":
    res = "1"
elif S == "SUN":
    res = "7"
elif S == "MON":
    res = "6"
elif S == "TUE":
    res = "5"
elif S == "WED":
    res = "4"
elif S == "THU":
    res = "3"
elif S == "Fri":
    res = "2"
print(res)
Problem p02881 (python)

Fixed submission:
import math

n= int(input())
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

i, j = 10**12, 10**12
res  = 0
if is_prime(n):
    res = n - 1
else:
    for t in range(1, int(math.sqrt(n)) + 1):
        if n % t == 0:
            a, b = t, n//t
            if a + b < i + j:
                i, j = a, b
    res = i + j -2


print(res)

Buggy submission (verdict: Runtime Error):
import math

n= int(input())
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

res  = []
if is_prime(n):
    res = n - 1
else:
    for t in range(1, int(math.sqrt(n)) + 1):
        if n % t == 0:
                res.append(n//t + t - 2)


print(min(res))