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

Fixed submission:
X,K,D=map(int,input().split(' '))
if X>=0:
    time=X//D
    if time>K:
        print(X-K*D)
    elif (K-time)%2==0:
        print(X%D)
    else:
        print(abs((X%D)-D))
else:
    time=-(X//D)
    if time>K:
        print(abs(X+K*D))
    elif (K-time)%2==0:
        print(X%D)
    else:
        print(abs((X%D)-D))

Buggy submission (verdict: Runtime Error):
X,K,D=map(int,input().split(' '))
time=0
if X>=0:
    while X>0:
        X-=D
        time+=1
        if time==K:
            break
    if (K-time)%2==0:
    print(abs(X))
else:
    print(X+D)
else:
    while X<0:
        X+=D
        time+=1
        if time==K:
            break
    if (K-time)%2==0:
    print(abs(X))
else:
    print(X-D)
Problem p02683 (python)

Fixed submission:
import numpy as np
N,M,X=map(int,input().split())
allList=[]
for _ in range(N):
    allList.append(np.array(list(map(int,input().split()))))
minnum=10**7
for i in range(2**N):
    skill=[0]*(M+1)
    flag=True
    for row in range(N):
        if i&(2**row)>0:
            skill+=allList[row]
    for j in range(M):
        if skill[j+1]<X:
            flag=False
    if flag:
        minnum=min(minnum,skill[0])
if minnum==10**7:
    minnum=-1
print(minnum)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M,X=map(int,input().split())
allList=[]
for _ in range(N):
    allList.append(np.array(list(map(int,input().split()))))
minnum=10**7
for i in range(2**N):
    skill=[0]*(M+1)
    flag=True
    for row in range(N):
        if i&(2**row)>0:
            skill+=allList[row]
    for i in range(M):
        if skill[j+1]<X:
            flag=False
    if flag:
        minnum=min(minnum,skill[0])
if minnum==10**7:
    minnum=-1
print(minnum)
Problem p02690 (python)

Fixed submission:
X=int(input())
flagp=False
flagm=False
flage=True
for A in range(-10**3,10**3):
    B5=A**5-X
    for B in range(10**3):
        if B5==B**5:
            flagp=True
            flage=False
            break
        elif B5==-B**5:
            flagm=True
            flage=False
            break
    else:
        continue
    break
if flagp:
    print(A,B)
elif flage:
    raise Exception
else:
    print(A,-B)

Buggy submission (verdict: Runtime Error):
X=int(input())
flagp=False
flagm=False
for A in range(-10**3,10**3):
    B5=A**5-X
    for B in range(10**3):
        if B5==B**5:
            flagp=True
            break
        elif B5==-B**5:
            flagm=True
            break
        else:
            raise Exception
    else:
        continue
    break
if flagp:
    print(A,B)
else:
    print(A,-B)

Buggy submission (verdict: Runtime Error):
X=int(input())
for A in range(int(X**(1/5))+2):
    if X>=A**5:
        if int((X-A**5)**(1/5))==((X-A**5)**(1/5)):
            B=-int((X-A**5)**(1/5))
            break
    else:
        if int((A**5-X)**(1/5))==((A**5-X)**(1/5)):
            B=int((A**5-X)**(1/5))
            break
print(A,B)

Buggy submission (verdict: Runtime Error):
X=int(input())
for A in range(int(X**(1/5))+2):
    if int((X-A**5)**(1/5))==((X-A**5)**(1/5)):
        B=-int((X-A**5)**(1/5))
        break
print(A,B)
Problem p03162 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
N=int(input())
ABC=[]
for _ in range(N):
    ABC.append(list(map(int,input().split())))
from functools import lru_cache
@lru_cache(maxsize=None)
def dynam(n):
    if n>1:
        a=max(dynam(n-1)[1]+ABC[n-1][0],
              dynam(n-1)[2]+ABC[n-1][0])
        b=max(dynam(n-1)[0]+ABC[n-1][1],
              dynam(n-1)[2]+ABC[n-1][1])
        c=max(dynam(n-1)[0]+ABC[n-1][2],
              dynam(n-1)[1]+ABC[n-1][2])
        return (a,b,c)
    return tuple(ABC[0])
print(max(dynam(N)))

Buggy submission (verdict: Runtime Error):
N=int(input())
sys.setrecursionlimit(1000000000)

ABC=[]
for _ in range(N):
    ABC.append(list(map(int,input().split())))
from functools import lru_cache
@lru_cache(maxsize=None)
def dynam(n):
    if n>1:
        a=max(dynam(n-1)[1]+ABC[n-1][0],
              dynam(n-1)[2]+ABC[n-1][0])
        b=max(dynam(n-1)[0]+ABC[n-1][1],
              dynam(n-1)[2]+ABC[n-1][1])
        c=max(dynam(n-1)[0]+ABC[n-1][2],
              dynam(n-1)[1]+ABC[n-1][2])
        return (a,b,c)
    return tuple(ABC[0])
print(max(dynam(N)))

Buggy submission (verdict: Runtime Error):
N=int(input())
ABC=[]
for _ in range(N):
    ABC.append(list(map(int,input().split())))
from functools import lru_cache
@lru_cache(maxsize=None)
def dynam(n):
    if n>1:
        a=max(dynam(n-1)[1]+ABC[n-1][0],
              dynam(n-1)[2]+ABC[n-1][0])
        b=max(dynam(n-1)[0]+ABC[n-1][1],
              dynam(n-1)[2]+ABC[n-1][1])
        c=max(dynam(n-1)[0]+ABC[n-1][2],
              dynam(n-1)[1]+ABC[n-1][2])
        return (a,b,c)
    return tuple(ABC[0])
print(max(dynam(N)))

Buggy submission (verdict: Runtime Error):
N=int(input())
ABC=[]
for _ in range(N):
    ABC.append(list(map(int,input().split())))
MAXlist=[]

def dynam(n):
    if n>1:
        a=max(dynam(n-1)[1]+ABC[n-1][0],
              dynam(n-1)[2]+ABC[n-1][0])
        b=max(dynam(n-1)[0]+ABC[n-1][1],
              dynam(n-1)[2]+ABC[n-1][1])
        c=max(dynam(n-1)[0]+ABC[n-1][2],
              dynam(n-1)[1]+ABC[n-1][2])
        return (a,b,c)
    return tuple(ABC[0])
print(max(dynam(N)))

Buggy submission (verdict: Runtime Error):
N=int(input())
ABC=[]
for _ in range(N):
    ABC.append(list(map(int,input().split())))
MAXlist=[]
from functools import lru_cache
@lru_cache(maxsize=None)
def dynam(n):
    if n>1:
        a=max(dynam(n-1)[1]+ABC[n-1][0],
              dynam(n-1)[2]+ABC[n-1][0])
        b=max(dynam(n-1)[0]+ABC[n-1][1],
              dynam(n-1)[2]+ABC[n-1][1])
        c=max(dynam(n-1)[0]+ABC[n-1][2],
              dynam(n-1)[1]+ABC[n-1][2])
        return (a,b,c)
    return tuple(ABC[0])
print(max(dynam(N)))
Problem p02705 (python)

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

r = inp()
print(r*2*math.pi)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

n=inp()
a = inpl()
sorted_a = sorted(a,reverse=True)
place=defaultdict(lambda: [])
for i in range(n):
    place[a[i]].append(i+1)
ans = 0
dp=[[-INF]*(n+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    if i!=0 and sorted_a[i] == sorted_a[i - 1]:
        index += 1
    else:
        index = 0
    for j in range(n):
        _place = place[sorted_a[i]][index]
        #右
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + sorted_a[i] * abs(n - (i - j) - _place))
        #左
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + sorted_a[i] *  abs(_place - j - 1))

print(max(dp[n]))
Problem p02709 (python)

Fixed submission:
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

n=inp()
a = inpl()
sorted_a = sorted(a,reverse=True)
place=dict()
for i in range(n):
    if a[i] not in place:
        place[a[i]]=[i+1]
    else:
        place[a[i]].append(i+1)
ans = 0
dp=[[-INF]*(n+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    if i!=0 and sorted_a[i] == sorted_a[i - 1]:
        index += 1
    else:
        index = 0
    for j in range(n):
        _place = place[sorted_a[i]][index]
        #右
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + sorted_a[i] * abs(n - (i - j) - _place))
        #左
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + sorted_a[i] *  abs(_place - j - 1))

print(max(dp[n]))

Buggy submission (verdict: Runtime Error):
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

n=inp()
a = inpl()
sorted_a = sorted(a,reverse=True)
place=dict()
for i in range(n):
    if a[i] not in place:
        place[a[i]]=[i+1]
    else:
        place[a[i]].append(i+1)
ans = 0
dp=[[-INF]*(n+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    if i!=0 and sorted_a[i] == sorted_a[i - 1]:
        index += 1
    else:
        index = 0
    for j in range(n):
        _place = place[sorted_a[i]][index]
        #右
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + sorted_a[i] * abs(n - (i - j) - _place))
        #左
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + sorted_a[i] *  abs(_place - j - 1))

print(max(dp[n]))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())

n=inp()
a = inpl()
sorted_a = sorted(a,reverse=True)
place=defaultdict(lambda: [])
for i in range(n):
    place[a[i]].append(i+1)
ans = 0
dp=[[-INF]*(n+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    if i!=0 and sorted_a[i] == sorted_a[i - 1]:
        index += 1
    else:
        index = 0
    for j in range(n):
        _place = place[sorted_a[i]][index]
        #右
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + sorted_a[i] * abs(n - (i - j) - _place))
        #左
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + sorted_a[i] *  abs(_place - j - 1))

print(max(dp[n]))
Problem p02972 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1,-1,-1):
  if sum(ans[i::i+1])%2!=a[i]:
    ans[i]=1
ans=[i+1 for i in range(n) if ans[i]==1]
print(len(ans))
ans=list(map(str,ans))
ans=" ".join(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1,-1,-1):
  if sum(ans[i::i+1])%2!=a[i]:
    ans[i]=1
ans=[i+1 for i in range(n) if ans[i]==1]
print(len(ans))
ans=" ".join(ans)
print(ans)
Problem p02973 (python)

Fixed submission:
import bisect
n=int(input())
a=[int(input()) for i in range(n)]
inf=10**9+1
tmp=[inf]*n
ans=0
for i in range(n-1,-1,-1):
  j= bisect.bisect_right(tmp,a[i])
  tmp[j]=a[i]
for i in range(n):
  if tmp[i]!=inf:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n=int(input())
a=[int(input()) for i in range(n)]
inf=10**6
tmp=[inf]*n
ans=0
for i in range(n-1,-1,-1):
  j= bisect.bisect_right(tmp,a[i])
  tmp[j]=a[i]
for i in range(n):
  if tmp[i]!=inf:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n=int(input())
a=[int(input()) for i in range(n)]
inf=10**6
tmp=[inf]*(n+1)
ans=0
for i in range(n-1,-1,-1):
  j= bisect.bisect_right(tmp,a[i])
  tmp[j]=a[i]
for i in range(n):
  if tmp[i]!=inf:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n=int(input())
a=[int(input()) for i in range(n)]
inf=10**6
tmp=[inf]*(n+1)
ans=0
for i in range(n-1,-1,-1):
  j= bisect.bisect_right(tmp,a[i])
  tmp[j]=a[i]
for i in range(n):
  if tmp[i]!=inf:
    ans+=1
print(ans)
Problem p03014 (python)

Fixed submission:
h,w=map(int,input().split())
s=[list(input())for _ in range(h)]
score=[[0]*w for _ in range(h)]
ans=0
range_w=range(w)
range_h=range(h)
for i in range_h:
  tmp_1=0
  tmp_2=0
  for j in range_w:
    if s[i][j]=="#":
      tmp_1=0
    else:
      tmp_1+=1
    score[i][j]+=tmp_1
    
    if s[i][-j-1]=="#":
      tmp_2=0
    else:
      tmp_2+=1
    score[i][-j-1]+=tmp_2
    
for j in range_w:
  tmp_3=0
  tmp_4=0
  for i in range_h:
    if s[i][j]=="#":
      tmp_3=0
    else:
      tmp_3+=1
    score[i][j]+=tmp_3
    
    if s[-i-1][j]=="#":
      tmp_4=0
    else:
      tmp_4+=1
    score[-i-1][j]+=tmp_4-3
for i in range(h):
  for j in range(w):
    ans=max(ans,score[i][j])
print(ans)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
data=[list(input()) for i in range(h)]
map1=[[0]*w for i in range(h)]
map2=[[0]*w for i in range(h)]
for i in range(h):
  count=0
  for j in range(w):
    if data[i][j]=="#":
      count=0
    else:
      count+=1
      map1[i][j]=count
  count=0
  for j in range(w):
    if map1[i][-1-j]==0:
      count=0
    else:
      if count==0:count=map1[i][-1-j]
      map1[i][-1-j]=count
for i in range(w):
  count=0
  for j in range(h):
    if data[j][i]=="#":
      count=0
    else:
      count+=1
      map2[j][i]=count
  count=0
  for j in range(h):
    if map2[-j-1][i]==0:
      count=0
    else:
      count=max(map2[-j-1][i],count)
      map2[-j-1][i]=count
ans=0
import numpy
map1=numpy.ndarray(map1)
map2=numpy.ndarray(map2)
map3=map1+map2
print(int(max(map3)-1))
Problem p03061 (python)

Fixed submission:
def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y) #再帰定義
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
r=[0]*n
for i in range(1,n):
  if i==1:
    l[1]=a[0]
    r[-2]=a[-1]
  else:
    l[i]=gcd(l[i-1],a[i-1])
    r[-i-1]=gcd(r[-i],a[-i])
g=[0]*n
for i in range(n):
  if l[i]==0 or r[i]==0:
    g[i]=l[i]+r[i]
  else:
    g[i]=gcd(l[i],r[i])
print(max(g))

Buggy submission (verdict: Runtime Error):
# 区間[i,j]における最小値を返す
# 値の更新をする
import fractions
input = sys.stdin.readline
class segment_tree:
    '''
    init_val(int): 初期化値
    Input(array):  入力
    '''
    def __init__(self, init_val, Input):
        #self.num:n以上の最小の2のべき乗(一番下のNodeの数)
        n=len(Input)
        self.init_val = init_val
        self.num = 2 ** (n - 1).bit_length()
        self.seg = [init_val] * 2 * self.num
        for i in range(n):
            self.seg[i + self.num - 1] = Input[i]
        for i in range(self.num - 2, -1, -1):
            self.seg[i]=self._segfunc(self.seg[2*i+1],self.seg[2*i+2])
    def _segfunc(self, left, right):
        '''
        ここに求めたい関数を入れる
        ex)最小値問題→min, 
        left:左の子
        right:右の子
        '''
        res=fractions.gcd(left,right)
        return res
    def update(self, k, x):
        '''
        k番目の値をxに書き換える
        '''
        k += self.num - 1
        self.seg[k] = x
        while k > 0:
            k = (k - 1) // 2
            self.seg[k] = self._segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2])
    def query(self, p, q):
        '''
        区間[p,q)の目的の値を取り出す
        '''
        if q <= p:
            return self.init_val
        p += self.num - 1
        q += self.num - 2
        res = self.init_val
        while q - p > 1:
            if p % 2 == 0: #始点が偶数or終点が奇数だと端っこが余る
                res = self._segfunc(res, self.seg[p])
            if q % 2 == 1:
                res = self._segfunc(res, self.seg[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        res = self._segfunc(res, self.seg[p])
        res = self._segfunc(res, self.seg[q])
        return res
INF = 10 ** 10
n=int(input())
a=list(map(int,input().split()))

# a = [randint(0,N*2) for _ in range(N)]
dp = segment_tree(0, a)
ans=-1
for i in range(n):
  ans=max(ans,fractions.gcd(dp.query(0,i),dp.query(i+1,n)))
print(ans)
Problem p03068 (python)

Fixed submission:
n=int(input())
s=list(input())
k=int(input())
tmp=s[k-1]
for i in range(n):
  print(s[i],end="") if s[i]==tmp else print("*",end="")
print("")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
k=int(input())
tmp=s[k]
for i in range(n):
  print(s[i],end="") if s[i]==tmp else print("*",end="")
print("")
Problem p03069 (python)

Fixed submission:
n=int(input())
s_o=input()
s_dot=[len(x) for x in s_o.replace("#"," ").split()]
s_sharp=[len(x) for x in s_o.replace("."," ").split()]
if s_o[0]==".":
  s_dot=s_dot[1:]
if s_o[-1]=="#":
  s_sharp=s_sharp[:-1]
length=len(s_dot)+1
if len(s_dot)==0 or len(s_sharp)==0:
  print(0)
  exit()
sum_sharp=[0]*length
sum_dot=[0]*length
for i in range(length):
  if i==0:
    sum_sharp[i]=0
  else:
    sum_sharp[i]=sum_sharp[i-1]+s_sharp[i-1]

for i in reversed(range(length)):
  if i==length-1:
    sum_dot[i]=0
  else:
    sum_dot[i]=sum_dot[i+1]+s_dot[i]
ans=[1000000]*(length)
for i in range(length):
  ans[i]=sum_sharp[i]+sum_dot[i]
print(min(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
s_o=input()
s_dot=[len(x) for x in s_o.replace("#"," ").split()]
s_sharp=[len(x) for x in s_o.replace("."," ").split()]
if s_o[0]==".":
  s_dot=s_dot[1:]
if s_o[-1]=="#":
  s_sharp[:-1]
if len(s_dot)==0 or len(s_sharp)==0:
  print(0)
  exit()
sum_sharp=[0]*len(s_sharp)
sum_dot=[0]*len(s_dot)
for i in range(len(sum_sharp)):
  if i==0:
    sum_sharp[i]=s_sharp[i]
  else:
    sum_sharp[i]=sum_sharp[i-1]+s_sharp[i]

for i in reversed(range(len(sum_dot))):
  if i==len(sum_dot)-1:
    sum_dot[i]=s_dot[i]
  else:
    sum_dot[i]=sum_dot[i+1]+s_dot[i]
ans=[1000000]*len(sum_sharp)
for i in range(len(sum_sharp)):
  ans[i]=sum_sharp[i]+sum_dot[-i-1]
print(min(ans))
Problem p03079 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a==b and b==c:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=list(input())
stage=[1]*n
for i in range(q):
  v = input().split()
  for j in range(n):
    if s[j]==v[0]:
      if v[1]=="L":
        if j!=0:
          stage[j-1]+=stage[j]
        stage[j]=0
      else:
        if j!=n-1:
          stage[j+1]+=stage[j]
        stage[j]=0
print(sum(stage))
Problem p03089 (python)

Fixed submission:
n=int(input())
b=list(map(int,input().split()))
s_b=sorted(list(set(b)),reverse=True)
if 1 not in s_b:
  print(-1)
  exit()
ans=[]
for itr in range(n):
  for j in s_b:
    if len(b)>=j:
      if b[j-1]==j:
        b.pop(j-1)
        ans.append(j)
        break
    if j==1:
      print(-1)
      exit()
ans.reverse()
for i in range(n):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
b=list(map(int,input().split()))
s_b=sorted(list(set(b)),reverse=True)
ans=[]
for itr in range(n):
  for j in s_b:
    try:
      if len(b)>=j:
        if b[j-1]==j:
          b.pop(j-1)
          ans.append(j)
          break
    except:
      print("error")
    if j==1:
      print(-1)
      exit()
ans.reverse()
for i in range(n):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
b=list(map(int,input().split()))
s_b=sorted(list(set(b)),reverse=True)
ans=[]
for itr in range(n):
  for j in s_b:
    if len(b)>=j:
      if b[j-1]==j:
        b.pop(j-1)
        ans.append(j)
        break
    if j==1:
      print(-1)
      exit()
ans.reverse()
for i in range(n):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
b=list(map(int,input().split()))
s_b=sorted(list(set(b)),reverse=True)
ans=[]
for itr in range(n):
  for j in s_b:
    if len(b)>=j:
      if b[j-1]==j:
        b=b[:j-1]+b[j:]
        ans.append(j)
        break
    if j==1:
      print(-1)
      exit()
ans.reverse()
for i in range(n):
  print(ans[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
b=list(map(int,input().split()))
s_b=sorted(list(set(b)),reverse=True)
ans=[]
for itr in range(n):
  for j in s_b:
    if len(b)>=j:
      if b[j-1]==j:
        b=b[:j-1]+b[j:]
        ans.append(j)
        break
    if j==1:
      print(-1)
      exit()
for i in range(n):
  print(ans[i])
Problem p03145 (python)

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

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

def f(li):
  global ans
  
  #終了条件
  if li==[]:
    del li
    return
  
  #再帰
  min_num=min(li)
  if min(li)>0:
    count+=min(li)
    li=list(map(lambda x: x-min(li), li))
  li=[li[:li.index(0)],li[li.index(0)+1:]]
  f(li[0])
  f(li[1])

f(h)
print(count)
Problem p03147 (python)

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

def f(li):
  global ans
  
  #終了条件
  if li==[]:
    del li
    return
  
  #再帰
  min_num=min(li)
  if min(li)>0:
    ans+=min(li)
    li=list(map(lambda x: x-min(li), li))
  li=[li[:li.index(0)],li[li.index(0)+1:]]
  f(li[0])
  f(li[1])

f(h)
print(ans)

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

def f(li):
  global ans
  
  #終了条件
  if li==[]:
    del li
    return
  
  #再帰
  min_num=min(li)
  if min(li)>0:
    count+=min(li)
    li=list(map(lambda x: x-min(li), li))
  li=[li[:li.index(0)],li[li.index(0)+1:]]
  f(li[0])
  f(li[1])

f(h)
print(count)
Problem p03160 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
def f(k):
  if k==0:return 0
  if k<0: return 100000
  if dp[k]!=-1:return dp[k]
  f1=f(k-1)+abs(h[k]-h[k-1])
  f2=f(k-2)+abs(h[k]-h[k-2])
  dp[k]=min(f1,f2)
  return dp[k]
n=int(input())
h=list(map(int,input().split()))
dp=[-1]*n
print(f(n-1))

Buggy submission (verdict: Runtime Error):
def f(k):
  if k==0:return 0
  if k<0: return 100000
  if dp[k]!=-1:return dp[k]
  f1=f(k-1)+abs(h[k]-h[k-1])
  f2=f(k-2)+abs(h[k]-h[k-2])
  dp[k]=min(f1,f2)
  return dp[k]
n=int(input())
h=list(map(int,input().split()))
dp=[-1]*n
print(f(n-1))
Problem p03161 (python)

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
from functools import lru_cache
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp():
    '''
    一つの整数
    '''
    return int(input())
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))
def inpl_str():
    '''
    一行に複数の文字
    '''
    return list(input().split())


n,k = inpl()
h = inpl()
dp = [INF] * (n)
dp[0] = 0
for i in range(min(n,k)):
    dp[i] = abs(h[i] - h[0])
for i in range(n - k):
    option=[dp[i+j]+abs(h[i+k]-h[i+j]) for j in range(k)]
    dp[i + k] = min(option)
print(dp[n - 1])

Buggy submission (verdict: Runtime Error):
import sys
def f(j):
  if j==0:return 0
  if j<0: return 100000
  if dp[j]!=-1:return dp[j]
  f_k=[f(j-l-1)+abs(h[j]-h[j-l-1]) for l in range(k)]
  dp[j]=min(f_k)
  return dp[j]
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[-1]*n
sys.setrecursionlimit(1000000000)
print(f(n-1))

Buggy submission (verdict: Runtime Error):
import sys
def f(j):
  if j==0:return 0
  if j<0: return 100000
  if dp[j]!=-1:return dp[j]
  f_k=[f(j-l-1)+abs(h[j]-h[j-l-1]) for l in range(k)]
  dp[j]=min(f_k)
  return dp[j]
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[-1]*n
sys.setrecursionlimit((n+1)*(k+1))
print(f(n-1))

Buggy submission (verdict: Runtime Error):
import sys
def f(j):
  if j==0:return 0
  if j<0: return 100000
  if dp[j]!=-1:return dp[j]
  f_k=[f(j-l-1)+abs(h[j]-h[j-l-1]) for l in range(k)]
  dp[j]=min(f_k)
  return dp[j]
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[-1]*n
sys.setrecursionlimit(1000000000000)
print(f(n-1))

Buggy submission (verdict: Runtime Error):
import sys
def f(j):
  if j==0:return 0
  if j<0: return 100000
  if dp[j]!=-1:return dp[j]
  f_k=[f(j-l-1)+abs(h[j]-h[j-l-1]) for l in range(k)]
  dp[j]=min(f_k)
  return dp[j]
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[-1]*n
sys.setrecursionlimit(n*k+1)
print(f(n-1))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
def f(j):
  if j==0:return 0
  if j<0: return 100000
  if dp[j]!=-1:return dp[j]
  f_k=[f(j-l-1)+abs(h[j]-h[j-l-1]) for l in range(k)]
  dp[j]=min(f_k)
  return dp[j]
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[-1]*n
print(f(n-1))