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

Fixed submission:
h,w=map(int,input().split())
f=[]
f.append("."*(w+2))
for i in range(h):
  f.append("."+input()+".")
f.append("."*(w+2))
a=[]
for i in range(1,h+1):
  dumy2=""
  for j in range(1,w+1):
    if f[i][j]==".":
      dumy=f[i-1][j-1]+f[i-1][j]+f[i-1][j+1]+f[i][j-1]+f[i][j]+f[i][j+1]+f[i+1][j-1]+f[i+1][j]+f[i+1][j+1]
      n=dumy.count("#")
      dumy2+=str(n)
    else:
      dumy2+="#"
  a.append(dumy2)
for i in range(h):
  print(a[i])

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
f=[]
f.append("."*(w+2))
for i in range(h):
  f.append("."+input()+".")
a=[]*h[]*w
for i in range(1,h+1):
  for j in range(1,w+1):
    if f[i][j]=".":
      dumy=f[i-1][j-1]+f[i-1][j]+f[i-1][j+1]+f[i][j-1]+f[i][j]+f[i][j+1]+f[i+1][j-1]+f[i+1][j]+f[i+1][j+1]
      a[i-1][j-1]=count(dumy.index("#"))
    else:
      a[i-1][j-1]="#"
      
for i in range(h):
  print(a[i])
Problem p03601 (python)

Fixed submission:
a,b,c,d,e,f=map(int,input().split())
dp=[0]*(f+1)
w=[]
s=[]
for i in range(f+1):
  if i%(a*100)==0:dp[i]=i
  if i%(b*100)==0:dp[i]=i
  if i>a*100 and dp[i-a*100]:dp[i]=i
  if i>a*100 and dp[i-b*100]:dp[i]=i
for i in dp:
  if i:w.append(i)
m=w[-1]*e//100+1
dp=[0]*(m)
for i in range(m):
  if i%c==0:dp[i]=i
  if i%d==0:dp[i]=i
  if i>c and dp[i-c]:dp[i]=i
  if i>d and dp[i-d]:dp[i]=i
for i in dp:
  if i: s.append(i)
g=0
ans=(w[0],0)
for i in w:
  for j in s:
    if i+j<=f and g<j/(i+j)<=e/(100+e):
      g=j/(i+j)
      ans=(i+j,j)
print(*ans)

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,f=map(int,input().split())
dp=[0]*(f+1)
w=[]
s=[]
for i in range(f+1):
  if i%(a*100)==0:dp[i]=i
  if i%(b*100)==0:dp[i]=i
  if i>a*100 and dp[i-a*100]:dp[i]=i
  if i>a*100 and dp[i-b*100]:dp[i]=i
for i in dp:
  if i:w.append(i)
m=w[-1]*e//100+1
dp=[0]*(m)
for i in range(m):
  if i%c==0:dp[i]=i
  if i%d==0:dp[i]=i
  if i>c and dp[i-c]:dp[i]=i
  if i>d and dp[i-d]:dp[i]=i
for i in dp:
  if i: s.append(i)
g=0
for i in w:
  for j in s:
    if i+j<=f and g<j/(i+j)<=e/(100+e):
      g=j/(i+j)
      ans=(i+j,j)
print(*ans)
Problem p03607 (python)

Fixed submission:
from collections import Counter 
n=int(input())
a=Counter([int(input()) for _ in range(n)])
ans=0
for i in a.values():
  ans+=i%2
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
b=[0]*10**9
for i in range(n):
  j=int(input())-1
  if b[j]:
    b[j]=0
  else:
    b[j]=1
print(sum(b))

Buggy submission (verdict: Runtime Error):
n = int(input())
b=[0]*100000
for i in range(n):
  j=int(input())-1
  if b[j]:
    b[j]=0
  else:
    b[j]=1
print(sum(b))

Buggy submission (verdict: Runtime Error):
n = int(input())
b=[0]*100000
for i in range(n):
  j=int(input())
  if b[j]:
    b[j]=0
  else:
    b[j]=1
print(sum(b))
Problem p03632 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
if b<=c or a>=d:
  t=0
else:
  if a<=c:
    if b<d:
      t=b-c
    else:
      t=d-c
  else:
    if b<d:
      t=b-a
    else:
      t=d-a
print(t)

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if b<=c or a=>d:
  t=0
else:
  if a<=c:
    if b<d:
      t=b-c
    else:
      t=d-c
  else:
    if c<d:
      t=b-a
    else:
      t=d-a
print(t)
Problem p03636 (python)

Fixed submission:
s=input()
a=s[0]+str(len(s)-2)+s[len(s)-1]
print(a)

Buggy submission (verdict: Runtime Error):
s=input()
a=a[0]+str(len(s)-2)+a[len(s)-1]
print(a)
Problem p03646 (python)

Fixed submission:
k=int(input())
n=min(k+2,50)
a=list(range(n))
for i in range(n):
  a[i]+=k//n
for i in range(k%n):
  a[i]+=n
  for j in range(n):
    if i==j:continue
    a[j]-=1
print(n)
print(*a)

Buggy submission (verdict: Runtime Error):
k=int(input())
n=min(k,50)
a=list(range(n))
for i in range(n):
  a[i]+=(k+n-1)//n
for i in range(k%n):
  a[i]+=n
  for j in range(n):
    if i==j:continue
    a[j]-=1
print(n)
print(*a)

Buggy submission (verdict: Runtime Error):
k=int(input())
n=min(k,50)
a=list(range(n))
for i in range(n):
  a[i]+=(k+n-1)//n
for i in range(k%n):
  a[i]+=n
  for j in range(n):
    if i==j:continue
    a[i]-=1
print(n)
print(*a)
Problem p03672 (python)

Fixed submission:
s=list(input())
n=len(s)
s1=s[:n//2]
s2=s[n//2:]
for i in range(n//2):
  s2=[s1[-1]]+s2[:-2]
  s1=s1[:-1]
  if s2==s1:
    break
print(len(s1+s2))

Buggy submission (verdict: Runtime Error):
s=list(input())
n=len(s)
s1=s[:n//2]
s2=s[n//2:]
for i in range(n//2):
  s2=s1[-1]+s2[:-2]
  s1=s1[:-1]
  if s2==s1:
    break
print(len(s1+s2))

Buggy submission (verdict: Runtime Error):
s=list(input())
n=len(s)
s1=s[:n//2]
s2=s[n//2:]
for i in range(n//2):
  s2=s1[-1]+s2[:-2]
  s1=s1[:-1]
  if s2==s1:
    break
print(len(s1+s2)
Problem p03680 (python)

Fixed submission:
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
i=0
count=1
frag=-1
for j in range(n):
  if a[i]==2:
    frag=count
    break
  else:
    i=a[i]-1
    count+=1
print(frag)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
  a.appent(int(input()))
i=0
count=1
while(1):
  if a[i]==1:
    frag=-1
    break
  elif a[i]==2:
    frag=count
    break
  else:
    i=a[i]-1
    count+=1
print(frag)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
  a.appent(int(input))
i=0
count=1
while(1):
  if a[i]==1:
    frag=-1
    break
  elif a[i]==2:
    frag=count
    break
  else:
    i=a[i]-1
    count+=1
print(frag)
Problem p03682 (python)

Fixed submission:
from heapq import heappop,heappush
import sys
sys.setrecursionlimit(10**6)
n=int(input())
pair=[i for i in range(n)]
que=[]
e=[None]*n
for i in range(n):
  x,y=map(int,input().split())
  e[i]=(i,x,y)
ex=sorted(e,key=lambda x:x[1])
ey=sorted(e,key=lambda x:x[2])
for i in range(n-1):
  w=ex[i+1][1]-ex[i][1]
  heappush(que,(w,ex[i][0],ex[i+1][0]))
for i in range(n-1):
  w=ey[i+1][2]-ey[i][2]
  heappush(que,(w,ey[i][0],ey[i+1][0]))
def find(x):
  if x==pair[x]:return x
  else:
    tmp=find(pair[x])
    pair[x]=tmp
    return tmp
q=[]
ans=0
while que:
  w,s,t=heappop(que)
  root_s=find(s)
  root_t=find(t)
  if root_s!=root_t:
    pair[root_s]=root_t
    ans+=w
print(ans)

Buggy submission (verdict: Runtime Error):
from heapq import heappop,heappush
n=int(input())
pair=[i for i in range(n)]
que=[]
e=[None]*n
for i in range(n):
  x,y=map(int,input().split())
  e[i]=(i,x,y)
ex=sorted(e,key=lambda x:x[1])
ey=sorted(e,key=lambda x:x[2])
for i in range(n-1):
  w=ex[i+1][1]-ex[i][1]
  heappush(que,(w,ex[i][0],ex[i+1][0]))
for i in range(n-1):
  w=ey[i+1][2]-ey[i][2]
  heappush(que,(w,ey[i][0],ey[i+1][0]))
def find(x):
  if x==pair[x]:return x
  else:
    tmp=find(pair[x])
    pair[x]=tmp
    return tmp
q=[]
ans=0
while que:
  w,s,t=heappop(que)
  root_s=find(s)
  root_t=find(t)
  if root_s!=root_t:
    pair[root_s]=root_t
    ans+=w
print(ans)

Buggy submission (verdict: Runtime Error):
from heapq import heappop,heappush
n=int(input())
pair=[i for i in range(n)]
e=[]
que=[]
que1=[]
for i in range(n):
  s,t=map(int,input().split())
  heappush(e,(s,t))
s,t=heappop(e)
heappush(que1,(t,s,0))
for i in range(n-1):
  s1,t1=heappop(e)
  heappush(que,(s1-s,i,i+1))
  s,t=s1,t1
  heappush(que1,(t,s,i+1))
t,s,i=heappop(que1)
for _ in range(n-1):
  t1,s1,j=heappop(que1)
  heappush(que,(t1-t,i,j))
  s,t,i=s1,t1,j
def find(x):
  if x==pair[x]:return x
  else:
    tmp=find(pair[x])
    pair[x]=tmp
    return tmp
ans=0
while que:
  w,s,t=heappop(que)
  root_s=find(s)
  root_t=find(t)
  if root_s!=root_t:
    pair[root_s]=root_t
    ans+=w
print(ans)

Buggy submission (verdict: Runtime Error):
from heapq import heappop,heappush
n=int(input())
pair=[i for i in range(n)]
e=[]
que=[]
que1=[]
for i in range(n):
  s,t=map(int,input().split())
  heappush(e,(s,t))
s,t=heappop(e)
heappush(que1,(t,s,0))
for i in range(n-1):
  s1,t1=heappop(e)
  heappush(que,(s1-s,i,i+1))
  s,t=s1,t1
  heappush(que1,(t,s,i+1))
t,s,i=heappop(que1)
for _ in range(n-1):
  t1,s1,j=heappop(que1)
  heappush(que,(t1-t,i,j))
  s,t,i=s1,t1,j
def find(x):
  if x==pair[x]:return x
  else:
    tmp=find(pair[x])
    pair[x]=tmp
    return tmp
ans=0
while que:
  w,s,t=heappop(que)
  root_s=find(s)
  root_t=find(t)
  if root_s!=root_t:
    pair[root_s]=root_t
    ans+=w
print(ans)
Problem p03695 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in a:
  b[min(i//400,8)]+=1
print(max(8-b[:8].count(0),1),8-b[:8].count(0)+b[8])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[0]*9
for i in a:
  b[min(i//400,9)]+=1
print(8-b[:8].count(0),min(8-b[:8].count(0)+b[8],8))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[0]*9 
for i in a:
  b[i//400]+=1
print(8-b[:8].count(0),min(8-b[:8].count(0)+b[8],8))
Problem p03698 (python)

Fixed submission:
s=input()
frag="yes"
for i in range(len(s)):
  n=s.count(s[i])
  if n >1:
    frag="no"
    break
    
print(frag)

Buggy submission (verdict: Runtime Error):
s=input()
frag="yes"
for i in range(s):
  n=s.count(s[i])
  if n >1:
    frag="no"
    break
    
print(frag)
Problem p03720 (python)

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

for i in range(n):
  dumy=a.count(i+1)
  print(dumy)

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

for i in range(n):
  dumy=a.count(i+1)
  print(dumy)

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

for i in range(n):
  dumy=a.count(i+1)
  print(dumy)
Problem p03721 (python)

Fixed submission:
n,k=map(int,input().split())
d=[0]*(10**5+1)
for i in range(n):
  a,b=map(int,input().split())
  d[a]+=b
for i in range(10**5+1):
  if d[i]>=k:
    print(i)
    break
  else:k-=d[i]

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a,b=map(int,input().split())
d=[]*(10**5+1)
for i in range(n-1):
  a,b=map(int,input().split())
  d[a]+=b
for i in range(10**5+1):
  if d[i]>k:
    print(i)
    break
  else:k-=d[i]

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a,b=map(int,input().split())
s=[]
s+=[a]*b
for i in range(n-1):
  a,b=map(int,input().split())
  if a>s[-1]:
    continue
  s+=[a]*b
  p=sorted(s)[:k]
print(p[k-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a,b=map(int,input().split())
s=[]
s+=[a]*b
for i in range(n-1):
  a,b=map(int,input().split())
  if a>max(s) and len(s)>k:
    continue
  s+=[a]*b
print(p[k-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=[]
for i in range(n):
  a,b=map(int,input().split())
  if a>max(s) and len(s)>k:
    continue
  s+=[a]*b
p=sorted(s)
print(p[k-1])
Problem p03730 (python)

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

frag='NO'
for i in range(b-1):
  if (i+1)*a%b==c:
    frag='YES'
    break

print(frag)

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

d=a%b
if c%d==0:
  frag="YES"
else:
  frag="NO"
print(frag)
Problem p03738 (python)

Fixed submission:
a=list(input())
b=list(input())
frag="EQUAL"
if len(a)!=len(b):
  if len(a)>len(b):
    frag="GREATER"
  else:
    frag="LESS"
else:
  for i in range(len(a)):
    if a[i]>b[i]:
      frag="GREATER"
      break
    elif a[i]<b[i]:
      frag="LESS"
      break
      
print(frag)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
frag="EQUAL"
if a>b:
  frag="GREATER"
elif a[i]<b[i]:
  frag="LESS"
      
print(frag)
Problem p03814 (python)

Fixed submission:
s=list(input())
n=len(s)
a=s.index("A")
for i in range(n,0,-1):
  if s[i-1]=='Z':
    z=i
    break
sum=z-a
print(sum)

Buggy submission (verdict: Runtime Error):
s=list(input())

a=s.index("A")
for i in range(len(s),0):
  if s[i-1]=="Z":
    z=i-1
z-=len(s)-1
sum=z-a+1
print(sum)
Problem p03845 (python)

Fixed submission:
n=int(input())
t=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=t[i]

m=int(input())
for i in range(m):
  p,x=map(int,input().split())
  sumi=sum-t[p-1]+x
  print(sumi)

Buggy submission (verdict: Runtime Error):
n=int(input())
t=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=t[i]
m=int(input())
for i in range(m):
  p,x=map(int,input().split())
  sumi=sum-t[p]+x
  print(sumi)
Problem p03853 (python)

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

a=[]
for i in range(h):
  b=input()
  a.append(b)
  a.append(b)
for i in range(2*h):
  print(a[i])

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[]
for i range(h):
  a.append=list(map(list,input().split()))
  a.append=list(map(list,input().split()))
print(a)
Problem p03855 (python)

Fixed submission:
from collections import Counter
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def find(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.find(self.root[x])
      return self.root[x]
  def unite(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if(x == y):
      return 
    elif(self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1
  def same(self, x, y):
    return self.find(x) == self.find(y)
n,k,l=map(int,input().split())
e=[[i]for i in range(n+1)]
ur=UnionFind(n)
ut=UnionFind(n)
for i in range(k):
  a,b=map(int,input().split())
  ur.unite(a,b)
for _ in range(l):
  a,b=map(int,input().split())
  ut.unite(a,b)
pair=[(ur.find(i),ut.find(i)) for i in range(1,n+1)]
c=Counter(pair)
ans=[c[i] for i in pair]
print(*ans)

Buggy submission (verdict: Runtime Error):
def dfs(now,vis,e,j,el):
  vis+=[now]
  e[now]=j
  res=set([now])
  for to in el[now]:
    if to in vis:continue
    res=res|dfs(to,vis[:],e,j,el)
    e[to]=j
  return res
n,k,l=map(int,input().split())
el=[set() for _ in range(n+1)]
et=[set() for _ in range(n+1)]
ela=[set() for _ in range(n+1)]
eta=[set() for _ in range(n+1)]
eml=[0]*(n+1)
emt=[0]*(n+1)
ans=[0]*(n+1)
for _ in range(k):
  p,q=map(int,input().split())
  el[p].add(q)
  el[q].add(p)
j=0
for i in range(n+1):
  if eml[i]:continue
  ela[j]=dfs(i,[],eml,j,el)
  j+=1
for _ in range(l):
  p,q=map(int,input().split())
  et[p].add(q)
  et[q].add(p)
j=0
for i in range(n+1):
  if emt[i]:continue
  eta[j]=dfs(i,[],emt,j,et)
  j+=1
for i in range(n+1):
  ans[i]=len(eta[emt[i]]&ela[eml[i]])
print(*ans[1:])
Problem p04001 (python)

Fixed submission:
s=input()
m=len(s)
sm=0
for i in range(2**(m-1)):
  a=list(str(bin(i)))[::-1]
  b=list(s)
  for j in range(len(a)-1,-1,-1):
    if a[j]=='1':
      b.insert(-j-1,'+')
  sm+=eval(''.join(b))
print(sm)

Buggy submission (verdict: Runtime Error):
s=input()
m=len(s)
sm=0
for i in range(2**(m-1)):
  a=list(str(bin(i)))[::-1]
  b=list(s)
  for j in range(len(a)):
    if a[j]==1:
      b.insert(-j-1,'+')
  sm+=eval(''.join(b))
print(sm)s=input()
m=len(s)
sm=0
for i in range(2**(m-1)):
  a=list(str(bin(i)))[::-1]
  b=list(s)
  for j in range(len(a)-1,-1,-1):
    if a[j]=='1':
      b.insert(-j-1,'+')
  sm+=eval(''.join(b))
print(sm)
Problem p04012 (python)

Fixed submission:
s=list(input())
flag="Yes"
while(len(s)>0):
  d=s[0]
  if s.count(d)%2==1:
    flag="No"
    break
  else:
    for i in range(s.count(d)):
      s.remove(d)
print(flag)

Buggy submission (verdict: Runtime Error):
s=list(input())
flag="Yes"
while(len(s)>0):
  d=s[0]
  if s.count(d)%2==1:
    flag="No"
    break
  else:
    for i in range(s.count(d)):
      s.remove(d)
print(frag)
Problem p04020 (python)

Fixed submission:
from copy import copy
n=int(input())
a=[0]+[int(input()) for _ in range(n)]
ans=0
for i in range(n):
  ans+=(a[i+1]+a[i])//2
  if a[i+1]:a[i+1]=(a[i+1]+a[i])%2
print(ans)

Buggy submission (verdict: Runtime Error):
from copy import copy
n=int(input())
a=[int(input()) for _ in range(n)]
b=copy(a)
ans1=0
for i in range(n-1):
  ans1+=min(a[i],a[i+1])
  k=max(a[i]-a[i+1],0)
  a[i+1]=max(a[i+1]-a[i],0)
  a[i]=k
for i in a:
  ans1+=i//2
ans2=0
for i in range(n-1,0,-1):
  ans2+=min(b[i],b[i-1])
  k=max(b[i]-b[i-1],0)
  b[i+1]=max(b[i-1]-b[i],0)
  b[i]=k
for i in b:
  ans2+=i//2
print(max(ans1,ans2))
Problem p04030 (python)

Fixed submission:
s=input()
n=len(s)
a=[]
b=""
for i in range(n):
  if s[i]=="B":
    if len(a)!=0:
      a.pop()
  else:
    a.append(s[i])
for i in range(len(a)):
  b+=a[i]
print(b)

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
a=[]
b=""
for i in range(s):
  if s[i]=="B":
    a.pop()
  else:
    a.append(s[i])
for i in range(len(a)):
  b+=a[i]
print(b)
Problem p04044 (python)

Fixed submission:
n,l=map(int,input().split())
s=[]
for i in range(n):
  dumy=input()
  s.append(dumy)
n_s=sorted(s)

b=''
for i in range(n):
  b+=n_s[i]

print(b)

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
s=[[]]
for i in range(n):
  dumy=inout()
  s.append(dumy)
n_s=sorted(s)

b=''
for i in range(n):
  b+=n_s[i]

print(b)
Problem p02958 (python)

Fixed submission:
N=int(input())
p=list(map(int,input().split()))
q=sorted(p)
count=0
for i in range(N):
    if p[i]!=q[i]:
        count+=1
if count<=2:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
from statistics import mode
import numpy as np
N=input()
p=list(map(int,input().split()))
p=np.array(p)
q=p-np.arange(len(p-1))
q = list(q)
r = len(list(set(q)))
if sum(list(q))==2*mode(q):
    print('YES')
else:
    print('NO')
Problem p02993 (python)

Fixed submission:
S=input()
for i in range(3):
  if S[i]==S[i+1]:
    print('Bad')
    exit()
print('Good')

Buggy submission (verdict: Runtime Error):
S=int(input())
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
    print('Bad')
else:
    print('Good')
Problem p02995 (python)

Fixed submission:
import fractions 
a,b,c,d=map(int,input().split())
f=lambda n:n-(n//c+n//d-n//(c*d//fractions.gcd(c,d)))
print(f(b)-f(a-1))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
f=lambda n:n-(n//c+n//d-n//(c*d//math.gcd(c,d)))
print(f(b)-f(a-1))
Problem p03160 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
dp=[1000000000]*(n)
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]))
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
INF=1000100
dp=[INF]*(100010)
n=int(input())
h=list(map(int,input().split()))

def rec(i):
    if dp[i]<INF:return dp[i]

    if i==0:return 0

    res=INF
    res=min(res,rec(i-1)+abs(h[i]-h[i-1]))
    if i>1:res=min(res,rec(i-2)+abs(h[i]-h[i-2]))
    dp[i]=res
    return dp[i]

print(rec(n-1))
Problem p02619 (python)

Fixed submission:
import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(date, LastDay, type, score):
  res = score
  res += s[date-1][type]
  for i in range(26):
    if i == type:
      continue
    res -= (date - LastDay[i]) *c[i]
  return res

D = I()
c = IL()
s = [IL() for i in range(D)]
ans = [I() for i in range(D)]

LastDay = [0]*26
score = 0
for d in range(D):
  score = tami(d+1, LastDay, ans[d]-1, score)
  LastDay[ans[d]-1] = d+1
  print(score)

Buggy submission (verdict: Runtime Error):
import sys
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(ans, score):
  LastDay = [0]*26
  for i in range(D):
    score += s[i][ans[i]-1]
  for i in range(D):
    score += (D - i+1) * (i+1 - LastDay[ans[i]-1])*c[i]
  return score

D = I()
c = IL()
s = [IL() for i in range(D)]
ans = [I() for i in range(D)]

score = 0
for i in range(26):
  score -= D * (2*c[i] + (D - 1)*c[i])//2

print(max(0, 10**6 + tami(ans, score)))
Problem p02630 (python)

Fixed submission:
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]

ans = 0
data = [0]*100010
for i in a:
  data[i] += 1
  ans += i

for b,c in bc:
  ans += c*data[b] - b*data[b]
  data[c] += data[b]
  data[b] = 0
  print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]

ans = 0
data = [0]*10
for i in a:
  data[i] += 1
  ans += i

for b,c in bc:
  ans += c*data[b] - b*data[b]
  data[c] += data[b]
  data[b] = 0
  print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [a = list(map(int,input().split())) for i in range(q)]

ans = 0
data = [0]*100020
for i in a:
  data[i] += 1
  ans += i

for b,c in bc:
  data[c] += data[b]
  data[b] = 0
  ans += c*data[b] - b*data[b]
  print(ans)
Problem p02690 (python)

Fixed submission:
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

X = I()

a = [0,1]
for i in range(2,300):
  a.append(i**5)
#print(a)

for i,j in itertools.combinations(a, 2):
  #print(i,j)
  for k in [-1,1]:
    if j - i*k == X:
      print(int(j**0.2), int(i**0.2)*k)
      exit()
print(error)

Buggy submission (verdict: Runtime Error):
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

X = I()

a = [0,1]
for i in range(2,70):
  a.append(i**5)
#print(a)

for i,j in itertools.combinations(a, 2):
  #print(i,j)
  for k in [-1,1]:
    if j - i*k == X:
      print(int(j**0.2), int(i**0.2)*k)
      exit()
print(error)