Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=[]
for i in range(n):
  s,p=map(int,input().split())
  l.append([i+1,s,p])
l.sort(key=lambda x:x[2],reverse=True)
l.sort(key=lambda x:x[1])
for ll in l:
  print(ll[0])

Fixed submission:
n=int(input())
lists=[]
for x in range(n):
  a,b=input().split()
  lists.append([a,int(b),x+1])
lists.sort(key=lambda t:t[1],reverse=True)
lists.sort(key=lambda t:t[0])
for x in range(n):
  print(lists[x][2])

Buggy python submission (verdict: Runtime Error):
n=int(input())
for x in range(n):
  a,b=input().split()
  lists.append([a,int(b),x+1])
lists.sort(key=lambda t:t[1],reverse=True)
lists.sort(key=lambda t:t[0])
for x in range(n):
  print(lists[x][2])

Fixed submission:
n=int(input())
lists=[]
for x in range(n):
  a,b=input().split()
  lists.append([a,int(b),x+1])
lists.sort(key=lambda t:t[1],reverse=True)
lists.sort(key=lambda t:t[0])
for x in range(n):
  print(lists[x][2])

Buggy python submission (verdict: Runtime Error):
n=int(input())
lists=[list(input().split()) for x in range(n)]
for x in range(n):
  a,b=input().split()
  lists.append([a,int(b),x+1])
lists.sort(key=lambda t:t[1],reverse=True)
lists.sort(key=lambda t:t[0])
for x in range(n):
  print(lists[x][2])

Fixed submission:
n=int(input())
lists=[]
for x in range(n):
  a,b=input().split()
  lists.append([a,int(b),x+1])
lists.sort(key=lambda t:t[1],reverse=True)
lists.sort(key=lambda t:t[0])
for x in range(n):
  print(lists[x][2])

Buggy python submission (verdict: Runtime Error):
n=int(input())
lists=[list(input().split()) for x in range(n)]
for y in range(n):
  lists[y].append(y+1)
lists.sort(key=lambda t:t[1] reverse=True)
lists.sort(key=lambda t:t[0])
for z in range(n):
  print(lists[z][2])

Fixed submission:
n=int(input())
lists=[]
for x in range(n):
  a,b=input().split()
  lists.append([a,int(b),x+1])
lists.sort(key=lambda t:t[1],reverse=True)
lists.sort(key=lambda t:t[0])
for x in range(n):
  print(lists[x][2])

Buggy python submission (verdict: Runtime Error):
n=int(input())
lists=[list(input().split()) for x in range(n)]
for x in range(n):
  lists[x].append(x+1)
lists.sort(key=lambda t:t[1] reverse=True)
lists.sort(key=lambda t:t[0])
for x in range(n):
  print(lists[x][2])

Fixed submission:
n=int(input())
lists=[]
for x in range(n):
  a,b=input().split()
  lists.append([a,int(b),x+1])
lists.sort(key=lambda t:t[1],reverse=True)
lists.sort(key=lambda t:t[0])
for x in range(n):
  print(lists[x][2])

Buggy python submission (verdict: Runtime Error):
n=int(input())
lists=[list(input().split()) for x in range(n)]
for x in range(n):
  lists[x].append(x+1)
lists.sort(key=lambda x:x[1] reverse=True)
lists.sort(key=lambda x:x[0])
for x in range(n):
  print(lists[x][2])
           

Fixed submission:
n=int(input())
lists=[]
for x in range(n):
  a,b=input().split()
  lists.append([a,int(b),x+1])
lists.sort(key=lambda t:t[1],reverse=True)
lists.sort(key=lambda t:t[0])
for x in range(n):
  print(lists[x][2])
Buggy python submission (verdict: Runtime Error):
import itertools
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
sss=0
for c in itertools.product([0,1],n):
  for i in range(m):
    cnt=0
    for j in range(l[i][0]):
      if c[l[i][j+1]-1]==1:
        cnt+=1
    if cnt%2==p[i]:
      ans+=1
  if ans==m:
    sss+=1
print(sss)

Fixed submission:
import itertools
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
sss=0
for c in itertools.product([0,1],repeat=n):
  ans=0
  for i in range(m):
    cnt=0
    for j in range(l[i][0]):
      if c[l[i][j+1]-1]==1:
        cnt+=1
    if cnt%2==p[i]:
      ans+=1
  if ans==m:
    sss+=1
print(sss)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lr=[list(map(int,input().split())) for i in range(m)]
a=set(range(lr[0][0],lr[0][1]+1))
for j in range(1,m):
  a=a&set(range(lr[j][0],lr[j][1]+1))
print(len(a))

Fixed submission:
n,m=map(int,input().split())
l,r=map(int,input().split())
for i in range(m-1):
  x,y=map(int,input().split())
  l=max(l,x)
  r=min(r,y)
print(r-l+1 if l<=r else(0))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lr=[list(map(int,input().split())) for i in range(m)]
lis=[0]*n
for l,r in lr:
  for t in range(l,r+1):
    lis[t-1]+=1
ans=0
for ll in lis:
  if ll==m:
    ans+=1
print(ans)

Fixed submission:
n,m=map(int,input().split())
l,r=map(int,input().split())
for i in range(m-1):
  x,y=map(int,input().split())
  l=max(l,x)
  r=min(r,y)
print(r-l+1 if l<=r else(0))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
lr=[list(map(int,input().split())) for i in range(m)]
l=[0]*n
for l,r in lr:
  for t in range(l,r+1):
    l[t-1]+=1
ans=0
for ll in l:
  if ll==m:
    ans+==1
print(ans)

Fixed submission:
n,m=map(int,input().split())
l,r=map(int,input().split())
for i in range(m-1):
  x,y=map(int,input().split())
  l=max(l,x)
  r=min(r,y)
print(r-l+1 if l<=r else(0))
Buggy python submission (verdict: Runtime Error):
a,b,c,d=input()
x=int(a+b)
y=int(c+d)
if 0<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 1<=x<=12 and 0<=y=12:
  print('AMBIGUOUS')
elif 0<=x<=99 and 1<=y<=12:
  print('YYMM')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
else:
  print('NA')

Fixed submission:
a,b,c,d=input()
x=int(a+b)
y=int(c+d)
if 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 0<=x<=99 and 1<=y<=12:
  print('YYMM')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
else:
  print('NA')

Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
x=int(a+b)
y=int(c+d)
if 0<=x<=12 and 0<=b<=12:
  if x==y==0:
    print('NA')
  else:
    print('AMBIGUOUS')
elif 0<=x<=99 and 1<=y<=12:
  print('YYMM')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
else:
  print('NA')

Fixed submission:
a,b,c,d=input()
x=int(a+b)
y=int(c+d)
if 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 1<=x<=12 and 1<=y<=12:
  print('AMBIGUOUS')
elif 0<=x<=99 and 1<=y<=12:
  print('YYMM')
elif 1<=x<=12 and 0<=y<=99:
  print('MMYY')
else:
  print('NA')
Buggy python submission (verdict: Runtime Error):
n=int(input())
listh=(list(map(int,input().split()))
count=1
for i in range(2,n+1):
  max=max(list[:i-1])
  if listh[i-1]>=max:
    count+=1
print(count)


Fixed submission:
n=int(input())
h=list(map(int,input().split()))
cnt=1
for i in range(1,n):
  if h[i]>=max(h[:i]):
    cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
n=int(input())
listh=(list(map(int,input().split()))
count=0
for i in range(2,n+1):
  if listh[i-1]>=max(listh[:i-1]):
    count+=1
print(count+1)


Fixed submission:
n=int(input())
h=list(map(int,input().split()))
cnt=1
for i in range(1,n):
  if h[i]>=max(h[:i]):
    cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
n=int(input())
listh=(list(map(int,input().split()))
count=1
for i in range(2,n+1):
  if listh[i-1]>=max(listh[:i-1]):
    count+=1
print(count)


Fixed submission:
n=int(input())
h=list(map(int,input().split()))
cnt=1
for i in range(1,n):
  if h[i]>=max(h[:i]):
    cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
n=int(input())
listh=(list(map(int,input().split()))
count=1
for i in range(2,n+1):
  if listh[i]>=max(listh[:i-1]):
    count+=1
print(count)
     

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
cnt=1
for i in range(1,n):
  if h[i]>=max(h[:i]):
    cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
l=[int(input()) for i in range(5)]
t=[]
for ll in l:
  t.append(math.ceil(t//10))
lis=[]
for i in range(5):
  lis.append(t[i]*10-l[i])
m=max(lis)
sum=0
for i in range(5):
  sum+=t[i]*10
print(sum-m)
  


Fixed submission:
import math
list=[int(input()) for x in range(5)]
list.sort(key=lambda x:x%10)
count=0
for l in list:
  if l%10==0:
    count+=1
if count==5:
  print(sum(list))
else:
  a=list[count]
  del list[count]
  ans=[]
  for t in list:
    ans.append(math.ceil(t/10)*10)
  print(sum(ans)+a)

Buggy python submission (verdict: Runtime Error):
import math
list=[int(input()) for x in range(5)]
list.sort(key=lambda x:x%10)
count=0
for l in list:
  if l%10==0:
    count+=1
if count==0:
  print(sum(list))
else:
  a=list[count]
  del list[count]
  ans=[]
  for t in list:
    ans.append(math.ceil(t/10)*10)
  print(sum(ans)+a)

Fixed submission:
import math
list=[int(input()) for x in range(5)]
list.sort(key=lambda x:x%10)
count=0
for l in list:
  if l%10==0:
    count+=1
if count==5:
  print(sum(list))
else:
  a=list[count]
  del list[count]
  ans=[]
  for t in list:
    ans.append(math.ceil(t/10)*10)
  print(sum(ans)+a)

Buggy python submission (verdict: Runtime Error):
import math
list=[int(input()) for x in range(5)]
list.sort(key=lambda x:x%10)
count=0
for l in list:
  if l%10==0:
    count+=1
a=list[count]
del list[count]
ans=[]
for t in list:
  ans.append(math.ceil(t/10)*10)
print(sum(ans)+a)

Fixed submission:
import math
list=[int(input()) for x in range(5)]
list.sort(key=lambda x:x%10)
count=0
for l in list:
  if l%10==0:
    count+=1
if count==5:
  print(sum(list))
else:
  a=list[count]
  del list[count]
  ans=[]
  for t in list:
    ans.append(math.ceil(t/10)*10)
  print(sum(ans)+a)
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
list=['A','C','G','T']
ans=[]
for i in range(n):
  k=0
  while i+k<=n-1:
    if all(a in list for a in s[i:i+k+1]):
      ans.append(k+1)
    k+=1
print(max(ans))

Fixed submission:
s=input()
n=len(s)
list=['A','C','G','T']
ans=[]
for i in range(n):
  k=0
  while i+k<=n-1:
    if all(a in list for a in s[i:i+k+1]):
      ans.append(k+1)
    k+=1
if len(ans)==0:
  print(0)
else:
  print(max(ans))
Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
list=[0]
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    list.append(list[i]+1)
  else:
    list.append(list[i])
for j in range(q):
  l,r=map(int,input().split())
  print(list[r]-list[l-1])

Fixed submission:
n,q=map(int,input().split())
s=input()
list=[0]
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    list.append(list[i]+1)
  else:
    list.append(list[i])
for j in range(q):
  l,r=map(int,input().split())
  print(list[r-1]-list[l-1])

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
list=[0]
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    list.append(list[i]+1)
  else:
    list.append(list[i])
for j in range(q):
  l,r=map(int,input().split())
  print(list[r]-list[l-1])

Fixed submission:
n,q=map(int,input().split())
s=input()
list=[0]
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    list.append(list[i]+1)
  else:
    list.append(list[i])
for j in range(q):
  l,r=map(int,input().split())
  print(list[r-1]-list[l-1])

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
list=[0]
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    list.append(list[i]+1)
  else:
    list.append(list[i])
for j in range(q):
  l,r=map(int,input().split())
  print(list[r]-list[l-1])

Fixed submission:
n,q=map(int,input().split())
s=input()
list=[0]
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    list.append(list[i]+1)
  else:
    list.append(list[i])
for j in range(q):
  l,r=map(int,input().split())
  print(list[r-1]-list[l-1])

Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
list=[0]
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    list.append(s[i]+1)
  else:
    list.append(s[i])
for j in range(q):
  l,r=map(int,input().split())
  print(list[r]-list[l-1])

Fixed submission:
n,q=map(int,input().split())
s=input()
list=[0]
for i in range(n-1):
  if s[i]=='A' and s[i+1]=='C':
    list.append(list[i]+1)
  else:
    list.append(list[i])
for j in range(q):
  l,r=map(int,input().split())
  print(list[r-1]-list[l-1])
Buggy python submission (verdict: Runtime Error):
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
lista=[list(map(int,input().split())) for x in range(n)]
ans=0
for i in range(1,n+1):
  sum=0
  for j in range(1,m+1):
    sum+=lista[j-1][j-1]*b[j-1]
  if sum+c>0:
    ans+=1
print(ans)


Fixed submission:
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
lista=[list(map(int,input().split())) for x in range(n)]
ans=0
for i in range(1,n+1):
  sum=0
  for j in range(1,m+1):
    sum+=lista[i-1][j-1]*b[j-1]
  if sum+c>0:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
n,a,b,c=map(int,input().split())
l=[int(input()) for i in range(n)]
ans=100000
for p in itertools.product(['A','B','C','Z'],repeat=n):
  if list(p).count('A')>=1 and list(p).count('B')>=1 and list(p).count('C')>=1:
    for i in range(n):
      la=0
      lb=0
      lc=0
      if p[i]=='A':
        la+=p[i]
      elif p[i]=='B':
        lb+=p[i]
      elif p[i]=='C':
        lc+=p[i]
      ans=min(ans,abs(la-a)+abs(lb-b)+abs(lc-c))
print(ans)

Fixed submission:
import itertools
n,A,B,C=map(int,input().split())
l=[int(input()) for i in range(n)]
ll=[]
for p in itertools.product(['A','B','C','Z'],repeat=n):
  ans=0
  a=0
  b=0
  c=0
  numa=0
  numb=0
  numc=0
  for i in range(n):
    if p[i]=='A':
      a+=l[i]
      numa+=1
    elif p[i]=='B':
      b+=l[i]
      numb+=1
    elif p[i]=='C':
      c+=l[i]
      numc+=1
  ans+=(abs(a-A)+abs(B-b)+abs(C-c)+(numa+numb+numc-3)*10)
  if all(nn!=0 for nn in [numa,numb,numc]):
    ll.append(ans)
print(min(ll))

Buggy python submission (verdict: Runtime Error):
import itertools
A,B,C,n=map(int,input(),split())
l=[int(input()) for i in range(n)]
ll=[]
for p in itertools.product(['A','B','C','Z'].repeat=n):
  ans=0
  a=0
  b=0
  c=0
  for i in range(n):
    if p[i]=='A':
      a+=l[i]
    elif p[i]=='B':
      b+=l[i]
    elif p[i]=='C':
      c+=l[i]
  ans+=(abs(a-A)+abs(B-b)+abs(C-c))
  ll.append(ans)
print(min(ans))


Fixed submission:
import itertools
n,A,B,C=map(int,input().split())
l=[int(input()) for i in range(n)]
ll=[]
for p in itertools.product(['A','B','C','Z'],repeat=n):
  ans=0
  a=0
  b=0
  c=0
  numa=0
  numb=0
  numc=0
  for i in range(n):
    if p[i]=='A':
      a+=l[i]
      numa+=1
    elif p[i]=='B':
      b+=l[i]
      numb+=1
    elif p[i]=='C':
      c+=l[i]
      numc+=1
  ans+=(abs(a-A)+abs(B-b)+abs(C-c)+(numa+numb+numc-3)*10)
  if all(nn!=0 for nn in [numa,numb,numc]):
    ll.append(ans)
print(min(ll))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,,input().split())
ans=[0]*m
l=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
  k=l[i][0]
  for j in (1,k+1):
    ans[l[i][j]-1]+=1
cnt=0
for aa in ans:
  if aa==n:
    cnt+=1
print(cnt)

Fixed submission:
n,m=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
ans=[0]*m
for x in range(n):
  k=lists[x][0]
  for t in range(k):
    ans[lists[x][t+1]-1]+=1
count=0
for y in range(m):
  if ans[y]==n:
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
ans=[0]*m
for x in range(n):
  k=lists[x][0]
  for t in range(k):
    ans[lists[x][t+1]-1]+=1
count=0
for y in range(m):
  if ans[x]==n:
    count+=1
print(count)

Fixed submission:
n,m=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
ans=[0]*m
for x in range(n):
  k=lists[x][0]
  for t in range(k):
    ans[lists[x][t+1]-1]+=1
count=0
for y in range(m):
  if ans[y]==n:
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
ans=[0]*m
for x in range(n):
  k=lists[x][0]
  for t in range(k):
    ans[lists[x][t+1]-1]+=1
count=0
for x in range(n):
  if ans[x]==n:
    count+=1
print(count)

Fixed submission:
n,m=map(int,input().split())
lists=[list(map(int,input().split())) for x in range(n)]
ans=[0]*m
for x in range(n):
  k=lists[x][0]
  for t in range(k):
    ans[lists[x][t+1]-1]+=1
count=0
for y in range(m):
  if ans[y]==n:
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
n=int(input()) 
lis=list(map(int,input().split()))
m=min(lis)
new=lis
while True:
  for i in range(n):
    new[i]%=m
  if all(nn==0 for nn in new):
    print(m)
    exit()
  ll=[m]
  for nn in new:
    if nn!=0:
      ll.append(nn)
  new=ll
  m=min(new)


Fixed submission:
n=int(input()) 
lis=list(map(int,input().split()))
m=min(lis)
new=lis
num=0
while True:
  for i in range(n+num):
    new[i]%=m
  if all(nn==0 for nn in new):
    print(m)
    exit()
  new.append(m)
  sl={m}
  for i in range(n+num):
    if new[i]!=0:
      sl.add(new[i])
  m=min(sl)
  num+=1
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
m=max(list)
list.remove(m)
print('Yes' if m<sum(list) else 'No')

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
m=max(l)
l.remove(m)
print('Yes' if m<sum(l) else 'No')
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=list(map(int,input().split()))
l=[]
for i in range(n-1):
  l.append(x[i+1]-x[i])
l.sort(reverse=True)
cnt=sum(l[:m-1])
print(x[m-1]-x[0]-cnt)

Fixed submission:
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
l=[]
for i in range(m-1):
  l.append(x[i+1]-x[i])
l.sort(reverse=True)
cnt=sum(l[:n-1])
print(sum(l)-cnt)
Buggy python submission (verdict: Runtime Error):
int(input())
list=[s]
num=2
while num<=1000000:
  if num%2==0:
    list.append(list[num-2]/2)
  else:
    list.append(list[num-2]*3+1)
  if list[num-1] in list[:num-1]:
    print(num)
    break
  num+=1

Fixed submission:
s=int(input())
list=[s]
num=2
while num<=1000000:
  if list[num-2]%2==0:
    list.append(list[num-2]/2)
  else:
    list.append(list[num-2]*3+1)
  if list[num-1] in list[:num-1]:
    break
  num+=1
print(num)

Buggy python submission (verdict: Runtime Error):
int(input())
list=[s]
num=2
while num<=1000000:
  if num%2==0:
    list.append(list[num-2]/2)
  else:
    list.append(list[num-2]*3+1)
  if list[num-1] in list[:num-1]:
    break
  num+=1
print(num)

Fixed submission:
s=int(input())
list=[s]
num=2
while num<=1000000:
  if list[num-2]%2==0:
    list.append(list[num-2]/2)
  else:
    list.append(list[num-2]*3+1)
  if list[num-1] in list[:num-1]:
    break
  num+=1
print(num)
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
h=np.array(h)
ans=0
while True:
  if all(hhh==0 for hhh in h):
    print(ans)
    exit()
  for i in range(n):
    k=n-i
    cnt=0
  for j in range(1,k):
    if all(hh!=0 for hh in h[i:i+j+1]):
      cnt+=1
  h[i:i+cnt+1]=-1
  ans+=1


Fixed submission:
n=int(input())
h=list(map(int,input().split()))
sum=h[0]
for i in range(n-1):
  if h[i+1]>h[i]:
    sum+=h[i+1]-h[i]
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
h=list(map(int,input().split()))
h=np.array(h)
ans=0
while True:
  for i in range(n):
    k=n-i
    cnt=0
    for j in range(1,k):
      if all(hh!=0 for hh in h[i:i+j+1]):
        cnt+=1
    h[i:i+cnt+1]=-1
    ans+=1
print(ans)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
sum=h[0]
for i in range(n-1):
  if h[i+1]>h[i]:
    sum+=h[i+1]-h[i]
print(sum)
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(n-2):
  dp(i+2)=min(dp[i]+abs(h[i+2]-h[i]),dp[i+1]+abs(h[i+2]-h[i]))
print(dp[n-1])

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(n-2):
  dp[i+2]=min(dp[i]+abs(h[i+2]-h[i]),dp[i+1]+abs(h[i+2]-h[i+1]))
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
n,k=map(int,input().split())
h=np.array(list(map(int,input().split())))
dp=np.array([10**10]*(n+k))
dp[0]= 0
for i in range(n):
    dp[i+1:i+k+1]=np.minimum(dp[i+1:i+k+1],np.abs(h[i+1:i+k+1]-h[i])+dp[i])
print(dp[n-1])

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
m=max(h)*(n-1)
dp=[m]*n
dp[0]=0
for i in range(n):
  if i+1+k<=n:
    r=k
  else:
    r=n-i-1
  for kk in range(1,r+1):
    dp[i+kk]=min(dp[i+kk],dp[i]+abs(h[i+kk]-h[i]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=np.full(n+k,10**10,dtype=np.int64)
dp[0]=0
for i in range(1,n):
  dp[i:i+k+1]=np.minimum(dp[i:i+k+1],dp[i]+np.abs(h[i:i+k+1]-h[i]))
print(dp[n-1])
        

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
m=max(h)*(n-1)
dp=[m]*n
dp[0]=0
for i in range(n):
  if i+1+k<=n:
    r=k
  else:
    r=n-i-1
  for kk in range(1,r+1):
    dp[i+kk]=min(dp[i+kk],dp[i]+abs(h[i+kk]-h[i]))
print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=list(map(int,input().split()))
m=max(h)*(n-1)
dp=[m]*n
dp[0]=0
for i in range(n):
  if i+1+k<=n:
    r=k
  else:
    r=n-i-1
  for kk in range(1,r+1):
    dp[i+kk]=min(dp[i+kk],dp[i]+abs(h[i+kk]-h[i]))
print(dp[n-1])


Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
m=max(h)*(n-1)
dp=[m]*n
dp[0]=0
for i in range(n):
  if i+1+k<=n:
    r=k
  else:
    r=n-i-1
  for kk in range(1,r+1):
    dp[i+kk]=min(dp[i+kk],dp[i]+abs(h[i+kk]-h[i]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
m=max(h)*(n-1)
dp=[m]*n
dp[0]=0
for i in range(n):
  if i+k<=n:
    r=k
  else:
    r=n-i
  for kk in range(1,r+1):
    dp[i+kk]=min(dp[i+kk],dp[i]+h[i+kk]-h[i])
print(dp[n-1])

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
m=max(h)*(n-1)
dp=[m]*n
dp[0]=0
for i in range(n):
  if i+1+k<=n:
    r=k
  else:
    r=n-i-1
  for kk in range(1,r+1):
    dp[i+kk]=min(dp[i+kk],dp[i]+abs(h[i+kk]-h[i]))
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
import copy
l=[list(map(int,input().split())) for i in range(n)]
q=copy.copy(l)
dp=[0]*(n+1)
dp[0]=0
dp[1]=max(l[0])
for i in range(1,n-1):
  if l[i+1].index(max(l[i+1]))==l[i].index(max(l[i]):
    qq=q[i+1].sort()                                      
    dp[i+1]=max(dp[i-1]+max(l[i+1]),dp[i]+qq[1])
print(n)
                

Fixed submission:
n=int(input())
abc=[list(map(int,input().split())) for i in range(n)]
dp=[[0,0,0] for _ in range(n+1)]
for i in range(n):
  for a in range(3):
    for b in range(3):
      if a!=b:
        dp[i+1][a]=max(dp[i][b]+abc[i][a],dp[i+1][a])
print(max(dp[n]))