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

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

Buggy submission (verdict: Runtime Error):
n=int(input())
i=0
while 1:
  if 2**i>n:break
  i+=1
print(2**(i-1))

Buggy submission (verdict: Runtime Error):
import math
n=int(input());print(round(2**(math.log(n,2)//1)))
Problem p03645 (python)

Fixed submission:
n,m=map(int,input().split());a=[]
for i in range(m):
  aa,bb=map(int,input().split())
  if aa==1:a.append(bb)
  if bb==n:a.append(aa)
a.sort()
for i in range(len(a)-1):
  if a[i]==a[i+1]:print("POSSIBLE");exit()
print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
s,t=set(),set()
for _ in range(m):
  a,b=map(int,input().split())
  if a==1:t.add(b)
  if b==n:s.add(a)
if s%t:print("POSSIBLE")
else:print("IMPOSSIBLE")
Problem p03658 (python)

Fixed submission:
n,k=map(int,input().split())
s=list(map(int,input().split()));s.sort();print(sum(s[-k:]))

Buggy submission (verdict: Runtime Error):
n,k,s=map(int,input().split()),list(map(int,input().split()));s.sort();print(sum(s[-k:]))
Problem p03671 (python)

Fixed submission:
a=list(map(int,input().split()));print(sum(a)-max(a))

Buggy submission (verdict: Runtime Error):
a=list(map(inti,input().split()));print(sum(a)-max(a))
Problem p03679 (python)

Fixed submission:
a,b,c=map(int,input().split())
if b>=c:print("delicious")
elif a<c-b:print("dangerous")
else:print("safe")

Buggy submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
if b-a>x:print("dangerous")
elif b-a<=0:print("delicious")
else:print("safe")
Problem p03680 (python)

Fixed submission:
n,ans=int(input()),-1
a,m=[int(input())for i in range(n)],1
for i in range(n):
  m=a[m-1]
  if m==2:
    ans=i+1
    break
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b,m=int(input()),[int(input())for i in range(n)],[],1
while m!=2 and m in b:
  b.append(m)
  m=b[m-1]
if m==2:print(len(b))
else:print(-1)
Problem p03687 (python)

Fixed submission:
s=input()
ans=len(s)
for i in "abcdefghijklmnopqrstuvwxyz":
  t=a=0
  for j in s:
    if j==i:a=max(a,t);t=0
    else:t+=1
  a=max(a,t)
  ans=min(ans,a)
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
ans=len(s)
def a(s,t):
  ss=""
  a=0
  b=False
  for i in range(len(s)-1):
    if s[i]!=t!=s[i+1]:ss+=s[i];b=True
    else:ss+=t
  if b:a=a(ss,t)
  return a+1
for i in s:ans=min(ans,a(s,i))
print(ans)
Problem p03688 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if max(a)-min(a)>=2:exit(print("No"))
if len(set(a))==1:
  m=a[0]
  if m==n-1 or 2*m<=n:print("Yes")
  else:print("No")
else:
  x=a.count(min(a))
  y=n-x
  if x<max(a) and 2*(max(a)-x)<=y:print("Yes")
  else:print("No")

Buggy submission (verdict: Runtime Error):
yes="Yes"
no="No"
n=int(input())
a=list(map(int,input().split()))
if max(a)-min(a)>1:exit(print(no))
if a==[a[0]]*n:
  if a[0]==n-1:print(yes)
  elif 2*a[0]<=n:print(yes)
  else:print(no)
else:
  mi=a.count(min(a))
  ma=n-mi
  if mi<max(a):print(yes)
  elif 2*(max(a)-mi)<=y:print(yes)
  else:print(no)
Problem p03693 (python)

Fixed submission:
a,b,c=map(int,input().split())
if (b*10+c)%4==0:print("YES")
else:print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input())
if (b*10+c)%4==0:print("YES")
else:print("NO")
Problem p03713 (python)

Fixed submission:
h,w=map(int,input().split())
ans=h*w
for i in range(1,h):
  a=w*i
  bb=w//2
  cc=(w-1)//2+1
  b=(h-i)*bb
  c=(h-i)*cc
  ans=min(ans,max(a,b,c)-min(a,b,c))
  bb=(h-i)//2
  cc=((h-i)-1)//2+1
  b=w*bb
  c=w*cc
  ans=min(ans,max(a,b,c)-min(a,b,c))
for i in range(1,w):
  a=h*i
  bb=h//2
  cc=(h-1)//2+1
  b=(w-i)*bb
  c=(w-i)*cc
  ans=min(ans,max(a,b,c)-min(a,b,c))
  bb=(w-i)//2
  cc=((w-i)-1)//2+1
  b=h*bb
  c=h*cc
  ans=min(ans,max(a,b,c)-min(a,b,c))
print(ans)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
ans=h*w
for i in range(1,h):ans=min(ans,max(i*w,(h-i)*(w//2),(h-i)*((w-1)//2)+1)-min(i*w,(h-i)*(w//2),(h-i)*((w-1)//2)+1)
for i in range(1,w):ans=min(ans,max(i*h,(w-i)*(h//2),(w-i)*((h-1)//2)+1)-min(i*h,(w-i)*(h//2),(w-i)*((h-1)//2)+1)
print(ans)

Buggy submission (verdict: Runtime Error):
h,w=map()
ans=h*w
for i in range(1,h):ans=min(ans,max(i*w,(h-i)*w//2)-min(i*w,(h-i)*w//2))
for i in range(1,w):ans=min(ans,max(i*h,(w-i)*h//2)-min(i*h,(w-i)*h//2))
print(ans)
Problem p03720 (python)

Fixed submission:
n,m=map(int,input().split())
x=[0 for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  x[a-1]+=1;x[b-1]+=1
for i in range(n):print(x[i])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=[0 for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  x[a-1]+=1;x[b-1]+=1
for i in range(n):print(n[i])
Problem p03730 (python)

Fixed submission:
a,b,c=map(int,input().split())
ans="NO"
for i in range(b):
  if (a*(i+1))%b==c:ans="YES"
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
ans="NO"
for i in range(b):
  if (a*(i+1))%b==c:ans"YES"
print(ans)
Problem p03738 (python)

Fixed submission:
a,b=int(input()),int(input());print("GREATER"if a>b else"LESS"if a<b else"EQUAL")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split());print("GREATER"if a>b else"LESS"if a<b else"EQUAL")
Problem p03739 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
ans=10**15
for i in[-1,1]:
    ansi,sum=0,0
    for a in A:
        sum+=a
        if sum*i<=0:ansi+=abs(sum-i);sum=i
        i*=-1
    ans=min(ans,ansi)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
ans=10**15
for i in[-1,1]:
    ansi,sum=0,0
    for a in A:
        sum+=a
        if sum*i<=0:;ansi+=abs(sum-i);sum=i
        i*=-1
    ans=min(ans,ansi)
print(ans)
Problem p03760 (python)

Fixed submission:
a,b,s=input(),input(),""
for i in range(len(a)-1):s+=a[i]+b[i]
if len(a)!=len(b):s+=a[-1]
else:s+=a[-1]+b[-1]
print(s)

Buggy submission (verdict: Runtime Error):
a=""
s,t=input(),input()
for i in range(len(s)):a+=s[i]+t[i]
print(a)
Problem p03778 (python)

Fixed submission:
w,a,b=map(int,input().split())
if b+w<a:print(a-b-w)
else:print(max(0,b-a-w))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
if b+w<a:print(a-b-w)
else:print(max(0,b-a-w))
Problem p03838 (python)

Fixed submission:
x,y=map(int,input().split())
if x==0:print(abs(y)+(y<0))
elif y==0:print(abs(x)+(x>0))
elif 0<x<y or x<y<0:print(abs(y-x))
elif 0<y<x or y<x<0:print(2+abs(x-y))
else:print(abs(abs(x)-abs(y))+1)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
if x=0:print(abs(y)+(y<0))
elif y=0:print(abs(x)+(x>0))
elif 0<x<y or x<y<0:print(abs(y-x))
elif 0<y<x or y<x<0:print(2+abs(x-y))
else:print(abs(abs(x)-abs(y))+1)
Problem p03840 (python)

Fixed submission:
I,O,R,J,L,S,Z=map(int,input().split())
a=(I//2+J//2+L//2)*2
b=0
if I*J*L!=0:b=(2*((I-1)//2+(J-1)//2+(L-1)//2)+3)
print(max(a,b)+O)

Buggy submission (verdict: Runtime Error):
I,O,R,J,L,S,Z=map(int,input().split())
ans=O
m=min(I,J,L):
I-=m
J-=m
L-=m
ans+=m*3
ans+=I//2*2
ans+=J//2*2
ans+=L//2*2
print(ans)
Problem p03855 (python)

Fixed submission:
from collections import*
class u():#UnionFind f-根探し u-連結 s-連結? c-要素数
  def __init__(self,n):self.n,self.r=[-1]*n,[0]*n
  def f(self,x):
    if self.n[x]<0:return x
    else:self.n[x]=self.f(self.n[x]);return self.n[x]
  def u(self,x,y):
    x,y=self.f(x),self.f(y)
    if x==y:return
    elif self.r[x]>self.r[y]:self.n[x]+=self.n[y];self.n[y]=x
    else:self.n[y]+=self.n[x];self.n[x]=y;self.r[y]+=self.r[x]==self.r[y]
  def s(self,x,y):return self.f(x)==self.f(y)
  def c(self,x):return -self.n[self.f(x)]
n,k,l=map(int,input().split())
d=u(n);t=u(n)
for _ in range(k):a,b=map(int,input().split());d.u(a-1,b-1)
for _ in range(l):a,b=map(int,input().split());t.u(a-1,b-1)
p=[(d.f(i),t.f(i))for i in range(n)]
c=Counter(p)
print(*[c[p[i]]for i in range(n)])

Buggy submission (verdict: Runtime Error):
from collections import*
n,k,l=map(int,input().split());d=[-1]*n;t=[-1]*n;M=lambda:map(int,input().split())
def f(l,x):return x if l[x]<0else f(l,l[x])
def u(l,x,y):
  if f(l,x)!=f(l,y):l[f(l,y)]=f(l,x)
for _ in range(k):a,b=M();u(d,a-1,b-1)
for _ in range(l):a,b=M();u(t,a-1,b-1)
p=[(f(d,i),f(t,i))for i in range(n)];c=Counter(p);print(*[c[p[i]]for i in range(n)])

Buggy submission (verdict: Runtime Error):
from collections import*
n,k,l=map(int,input().split());d=[-1]*n;t=[-1]*n
def f(l,x):
  if l[x]<0:return x
  else:l[x]=f(l,l[x]);return l[x]
def u(l,x,y):l[f(l,y)]=f(l,x)
for _ in range(k):a,b=map(int,input().split());u(d,a-1,b-1)
for _ in range(l):a,b=map(int,input().split());u(t,a-1,b-1)
p=[(f(d,i),f(t,i))for i in range(n)];c=Counter(p);print(*[c[p[i]]for i in range(n)])
Problem p03866 (python)

Fixed submission:
import sys
input=sys.stdin.readline
sx,sy,tx,ty=map(int,input().split())
n=int(input())
p=[(sx,sy,0)]
for _ in range(n):
  x,y,r=map(int,input().split())
  p.append((x,y,r))
p.append((tx,ty,0))
n+=2
edge=[[]for _ in range(n)]
for i in range(n-1):
  for j in range(i+1,n):
    sx,sy,sr=p[i]
    tx,ty,tr=p[j]
    t=(abs(sx-tx)**2+abs(sy-ty)**2)**0.5
    c=max(0,t-(sr+tr))
    edge[i].append((j,c))
    edge[j].append((i,c))
from heapq import heappop,heappush
inf=10**20
ans=[inf]*n
ans[0]=0
root=[-1]*n
h=[(0,0)]
while h:
  c,v=heappop(h)
  if ans[v]<c:continue
  for u,t in edge[v]:
    if c+t<ans[u]:
      ans[u]=c+t
      root[u]=v
      heappush(h,(c+t,u))
print(ans[n-1])

Buggy submission (verdict: Runtime Error):
def main()
  import sys
  input=sys.stdin.readline
  sx,sy,tx,ty=map(int,input().split())
  n=int(input())
  p=[(sx,sy,0)]
  for _ in range(n):
    x,y,r=map(int,input().split())
    p.append((x,y,r))
  p.append((tx,ty,0))
  n+=2
  edge=[[]for _ in range(n)]
  for i in range(n-1):
    for j in range(i+1,n):
      sx,sy,sr=p[i]
      tx,ty,tr=p[j]
      t=(abs(sx-tx)**2+abs(sy-ty)**2)**0.5
      c=max(0,t-(sr+tr))
      edge[i].append((j,c))
      edge[j].append((i,c))
  from heapq import heappop,heappush
  def dijkstra(s,n,edge):
    inf=10**20
    ans=[inf]*n
    ans[s]=0
    root=[-1]*n
    h=[[0,s]]
    while h:
      c,v=heappop(h)
      if ans[v]<c:continue
      for u,t in edge[v]:
        if c+t<ans[u]:
          ans[u]=c+t
          root[u]=v
          heappush(h,[c+t,u])
    print(ans[n-1])
  dijkstra(0,n,edge)
if __name__ == "__main__":
  main()
Problem p03920 (python)

Fixed submission:
n,c=int(input()),0
for j in range(n+1):
  if c<n:c+=j+1
  else:break	
for i in range(j,0,-1):
  if i<=n:print(i);n-=i

Buggy submission (verdict: Runtime Error):
n=int(input());print(int(round(int(input()))*2)+1if n!=1else"1")
Problem p03937 (python)

Fixed submission:
h,w=map(int,input().split());c=0
for i in range(h):
  a=input()
  b=[]
  for j in range(w):b.append(a[j])
  c+=b.count("#")
print("Possible"if h+w-1==c else"Impossible")

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split());c=0
for i in range(h):
  a=input().split(".")
  c+=len(a)
print("Possible"if h+w-1==ans else"Impossible")
Problem p03943 (python)

Fixed submission:
a=list(map(int,input().split()))
if sum(a)/2==max(a):print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
a=list(map(int,input()).split())
if sum(a)/2==max(a):print("YES")
else:print("NO")
Problem p03993 (python)

Fixed submission:
n=int(input());a=list(map(int,input().split()));ans=0
for i in range(n):
  if i+1==a[a[i]-1]:ans+=1
print(ans//2)

Buggy submission (verdict: Runtime Error):
n=int(input());a=list(map(int,input().split()));ans=0
for i in range(n):
  if i+1=a[a[i]-1]:ans+=1
print(ans)
Problem p03994 (python)

Fixed submission:
s=input()
k=int(input())
t="abcdefghijklmnopqrstuvwxyz"
a=[t.index(i)for i in s]
i=0
while k:
  if i==len(s)-1:a[i]+=k;a[i]%=26;k=0
  if a[i]==0 or 26-a[i]>k:i+=1
  else:a[i]+=1;a[i]%=26;k-=1
print("".join([t[i]for i in a]))

Buggy submission (verdict: Runtime Error):
t="abcdefghijklmnopqrstuvwxyz"
s=input()
k=int(input())
a=[t.index(i)for i in s]
ans=""
for i in a:
  if i==0:
    ans+="a"
    continue
  j=i
  if k>=26-i:
    k-=26-i
    j=0
  ans+=t[j]
j+=k
j%=26
ans=ans[:-1]+t[j]
print(ans)
Problem p04012 (python)

Fixed submission:
s,ans=input(),0;a=[s[i]for i in range(len(s))];a.sort()
for i in a:
  if a.count(i)%2!=0:ans=1
if ans==0:print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
s,ans=input(),0;a=[s[i]for i in range(len(s))];a.sort()
for i in a:
  if a.count(i)%2!=0:ans=1
if ans=0:print("Yes")
else:print("No")
Problem p04013 (python)

Fixed submission:
n,a=map(int,input().split())
x=list(map(int,input().split()))
X=max(max(x),a)
dp=[[[0]*(X*n+1)for j in range(n+1)]for i in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
  xi=x[i-1]
  for j in range(i+1):
      for h in range(j*X+1):
        if h<xi:dp[i][j][h]=dp[i-1][j][h]
        if xi<=h and j>=1:dp[i][j][h]=dp[i-1][j][h]+dp[i-1][j-1][h-xi]
ans=0
for j in range(1,n+1):ans+=dp[n][j][j*a]
print(ans)

Buggy submission (verdict: Runtime Error):
n,a=map(int,input().split())
x=list(map(int,input().split()))
X=sum(x)
dp=[[[0]*(X+1)for j in range(n+1)]for i in range(n+1)]
dp[0][0][0]=1
for i in range(1,n+1):
  xi=x[i-1]
  for j in range(n+1):
      for h in range(X+1):
        if h<xi:dp[i][j][h]=dp[i-1][j][h]
        if xi<=h and j>=1:dp[i][j][h]=dp[i-1][j][h]+dp[i-1][j-1][h-xi]
ans=0
for j in range(1,n+1):ans+=dp[n][j][j*a]
print(ans)
Problem p04031 (python)

Fixed submission:
a,b=int(input()),list(map(int,input().split()))
ans=-1
for i in range(-100,100+1):
  c=0
  for j in range(a):c+=(b[j]-i)**2
  if ans==-1:ans=c
  elif ans>c:ans=c
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=int(input()),list(map(int,input().split()));b.sort();c=(b[0]+b[-1])//2;if (b[0]+b[-1])%2==1 and c+1 in b:c+=1
d=[(b[i]-c)**2 for i in range(a)];print(sum(d))

Buggy submission (verdict: Runtime Error):
a,b=int(input()),list(map(int,input().split()));b.sort();c=(b[0]+b[-1])//2;if (b[0]+b[-1])%2==1 and c+1 in b:c+=1;d=[(b[i]-c)**2 for i in range(a)];print(sum(d))
Problem p04032 (python)

Fixed submission:
s=input()
l=len(s)
for i in range(1,l):
  if s[i-1]==s[i]:print(i,i+1);exit()
for i in range(2,l):
  if s[i-2]==s[i]:print(i-1,i+1);exit()
print(-1,-1)

Buggy submission (verdict: Runtime Error):
s=input()
l=len(s)
for i in range(1,l)
  if s[i-1]==s[i]:print(i,i+1);exit()
for i in range(2,l)
  if s[i-2]==s[i]:print(i-1,i+1);exit()
print(-1,-1)
Problem p04033 (python)

Fixed submission:
a,b=map(int,input().split())
if a*b<=0:print("Zero")
elif 0<a:print("Positive")
else:
  if (b-a)%2==1:print("Positive")
  else:print("Negative")

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a*b=0:print("Zero")
elif 0<a:print("Positive")
else:
  if -a%2==0:print("Positive")
  else:print("Negative")
Problem p04035 (python)

Fixed submission:
n,l=map(int,input().split())
a=list(map(int, input().split()))
for i in range(n-1):
  if a[i]+a[i+1]>=l:
    print("Possible")
    for j in range(i):print(j+1)
    for j in range(n-1,i,-1):print(j)
    exit()
print("Impossible")

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
a=list(map(int, input().split()))
for i in range(n-1):
  if a[i]+a[i+1]>=L:
    print("Possible")
    for j in range(i):print(j+1)
    for j in range(n-1,i,-1):print(i)
    exit()
print("Impossible")
Problem p04046 (python)

Fixed submission:
h,w,a,b=map(int,input().split());m=10**9+7;f=[1]
for i in range(h+w):f+=[f[-1]*(i+1)%m]
def comb(a,b,m):return f[a]*pow(f[b],m-2,m)*pow(f[a-b],m-2,m)%m
x=0
for i in range(b,w):x+=comb(h-a+i-1,i,m)*comb(a+w-i-2,a-1,m)%m
print(x%m)

Buggy submission (verdict: Runtime Error):
h,w,a,b=map(int,input().split())m=10**9+7;f=[1]
for i in range(h+w):f+=[f[-1]*(i+1)%m]
def comb(a,b,m):return f[a]*pow(f[b],m-2,m)*pow(f[a-b],m-2,m)%m
x=0
for i in range(b,w):x+=comb(h-a+i-1,i,m)*comb(a+w-i-2,a-1,m)%m
print(x%m)
Problem p02536 (python)

Fixed submission:
n,m=map(int,input().split())
g=[[] for i in range(n)]
for i in range(m):
	u,v=map(int,input().split())
	u-=1
	v-=1
	g[u].append(v)
	g[v].append(u)

vis=[False]*n
stk=[]

cnt=0
tt=0
for i in range(n):
	if not vis[i]:
		cnt+=1
		stk.append(i)
	while len(stk)!=0:
		u=stk[-1]
		stk.pop()
		if vis[u]:
			continue
		vis[u]=True
		for v in g[u]:
			tt+=1
			if not vis[v]:
				stk.append(v)
print(cnt-1)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
g=[[],]*n
for i in range(m):
	u,v=map(int,input().split())
	u-=1
	v-=1
	g[u].append(v)
	g[v].append(u)

vis=[False]*n
def dfs(u):
	if vis[u]:
		return
	vis[u]=True
	for v in g[u]:
		dfs(v)

cnt=0
for i in range(n):
	if not vis[i]:
		cnt+=1
		dfs(i)
print(cnt-1)
Problem p03096 (python)

Fixed submission:
n=int(input())
c=list(int(input()) for i in range(n))
dp=[0]*n
rec=[0]*(2*10**5+1)
dp[0]=1
rec[c[0]]=1
for i in range(1,n):
	if c[i]==c[i-1]:
		dp[i]=dp[i-1]
		continue
	dp[i]=(dp[i-1]+rec[c[i]])%(10**9+7)
	rec[c[i]]=dp[i]
print(dp[-1])

Buggy submission (verdict: Runtime Error):
M=10**9+7
n=int(input())
c=list(int(input()) for i in range(n))
dp=[0]*n
rec=[0]*n
dp[0]=1
rec[c[0]]=1
for i in range(1,n):
	if c[i]==c[i-1]:
		dp[i]=dp[i-1]
		continue
	dp[i]=(dp[i-1]+rec[c[i]])%M
	rec[c[i]]=dp[i]
print(dp[-1])
Problem p03161 (python)

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

Buggy submission (verdict: Runtime Error):
#include<cstdio>
#include<cstring>
#include<cassert>
#include<iostream>
#include<algorithm>
#include<queue>

using namespace std;

#define Whats(x) cout<<#x<<" is "<<(x)<<endl
#define Divhim() cout<<">>>>>>>>>>>>>>>"<<endl
#define Divher() cout<<"<<<<<<<<<<<<<<<"<<endl
#define Oops() cout<<"!!!!!!!!!!!!!!!"<<endl

template<typename T> bool GetMin(T &a,T b)
{
	return ((a<=b)?false:(a=b,true));
}

template<typename T> bool GetMax(T &a,T b)
{
	return ((a>=b)?false:(a=b,true));
}

/*
	 -<Unlimited Blade Works>-
 */

#define LL long long

const int N=1e6+10;
const int H=1e5+10;
const LL INF=0x3f3f3f3f3f3f3f3f;

struct Heap
{

	priority_queue<LL,vector<LL>,greater<LL> > P,Q;

	void Push(LL x)
	{
		P.push(x);
	}

	void Del(LL x)
	{
		Q.push(x);
	}

	LL Top()
	{
		while(!Q.empty()&&P.top()==Q.top())
		{
			P.pop();
			Q.pop();
		}
		return P.empty()?INF:P.top();
	}

};

LL tr0[H<<2],tr1[H<<2];
Heap hp0[H<<2],hp1[H<<2];

void Insert(int p,LL w0,LL w1,int o=1,int l=1,int r=H)
{
	if(l==r)
	{
		hp0[o].Push(w0);
		hp1[o].Push(w1);
		GetMin(tr0[o],w0);
		GetMin(tr1[o],w1);
		return;
	}
	int mid=(l+r)>>1,lc=o<<1,rc=lc^1;
	if(p<=mid)
		Insert(p,w0,w1,lc,l,mid);
	else
		Insert(p,w0,w1,rc,mid+1,r);
	tr0[o]=min(tr0[lc],tr0[rc]);
	tr1[o]=min(tr1[lc],tr1[rc]);
}

void Del(int p,LL w0,LL w1,int o=1,int l=1,int r=H)
{
	if(l==r)
	{
		hp0[o].Del(w0);
		hp1[o].Del(w1);
		tr0[o]=hp0[o].Top();
		tr1[o]=hp1[o].Top();
		//Whats(tr0[o]);
		//Whats(tr1[o]);
		return;
	}
	int mid=(l+r)>>1,lc=o<<1,rc=lc^1;
	if(p<=mid)
		Del(p,w0,w1,lc,l,mid);
	else
		Del(p,w0,w1,rc,mid+1,r);
	tr0[o]=min(tr0[lc],tr0[rc]);
	//cout<<l<<","<<r<<endl;
	tr1[o]=min(tr1[lc],tr1[rc]);
}

LL Ask(int ql,int qr,LL *tr,int o=1,int l=1,int r=H)
{
	if(ql<=l&&r<=qr)
		return tr[o];
	int mid=(l+r)>>1,lc=o<<1,rc=lc^1;
	LL res=INF;
	if(ql<=mid)
		GetMin(res,Ask(ql,qr,tr,lc,l,mid));
	if(qr>mid)
		GetMin(res,Ask(ql,qr,tr,rc,mid+1,r));
	return res;
}

int n,ki,h[N];
LL dp[N];

void Insert(int x)
{
	Insert(h[x],dp[x]-h[x],dp[x]+h[x]);
}

void Del(int x)
{
	Del(h[x],dp[x]-h[x],dp[x]+h[x]);
}

int main()
{
	memset(tr0,0x3f,sizeof tr0);
	memset(tr1,0x3f,sizeof tr1);
	scanf("%d%d",&n,&ki);
	for(int i=1;i<=n;++i)
		scanf("%d",h+i);
	for(int i=1;i<=n;++i)
	{
		if(i>1)
			dp[i]=min(Ask(1,h[i],tr0)+h[i],Ask(h[i],H,tr1)-h[i]);
		if(i<n)
		{
			Insert(i);
			if(i>ki)
				Del(i-ki);
		}
		//Whats(i);
		//Whats(dp[i]);
	}
	printf("%lld",dp[n]);
	return 0;
}
Problem p02583 (python)

Fixed submission:
n = int(input())
if n < 3:
  print(0)
  exit()
l = map(int,input().split())
l = sorted(l)
c = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if l[i] + l[j] > l[k] and l[i] != l[j] and l[j] != l[k]:
        c += 1
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n < 3:
  print(0)
  exit()
l = map(int,input().split())
l.sort()
c = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if l[i] + l[j] > l[k] and l[i] != l[j] and l[j] != l[k]:
        c += 1
print(c)
Problem p02683 (python)

Fixed submission:
def bit_set(num:int,n:int):
  if num & (1<<n):
    return True
  return False

n,m,x = map(int,input().split())
ca_list = [list(map(int,input().split())) 
           for nesya in range(n)]
c = -1
for i in range(2**n):
  skill = [0]*m
  cost = 0
  for k in range(n):
    if bit_set(i,k) == True:
      ca =  ca_list[k]
      cost += ca[0]
      a = ca[1:]
      skill = [j+l for (j,l) in zip(skill, a)]
  if all((hoge >= x) for hoge in skill):
    if c == -1:
      c = cost
    else:
      c = min(c,cost)
print(c)

Buggy submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
c_list = [list(map(int,input().split())) 
          for nesya in range(n)]
arugo = [0]*m
hoge = 0
for c in c_list:
  arugo[0] += c[1]
  arugo[1] += c[2]
  arugo[2] += c[3]
  hoge += c[0]
if arugo[0] < 10 or arugo[1] < 10 or arugo[2] < 10:
  print(-1)
else:
  print(hoge)

Buggy submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
c_list = [list(map(int,input().split())) 
          for nesya in range(n)]
arugo = [0]*m
hoge = 0
while c in c_list:
  arugo[0] += c[1]
  arugo[1] += c[2]
  arugo[2] += c[3]
  hoge += c[0]
if arugo[0] < 10 or arugo[1] < 10 or arugo[2] < 10:
  print(-1)
else:
  print(hoge)
Problem p02705 (python)

Fixed submission:
import math
a = int(input())
b = 2*a*math.pi
print(b)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
s = input()
a_list = s.split()
dic =  Counter(a_list)
k = 1
while k <= n:
  print(dic[str(k)])
  k += 1

Buggy submission (verdict: Runtime Error):
a = int(input())
b = a*pi()
print(b)
Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
if m != 0:
  a = [list(map(int,input().split())) for raw in range(m)]
  b = sorted(a)
  ans = 0
  if int((b[0])[0]) != 1:
    ans += 10**(n-1)
  t = 0
  u = -1
  che = 0
  for hoge in b:
    x = hoge[0]
    y = hoge[1]
    if x == 1 and y == 0:
      if n != 1:
        che += 1
    if x != t:
      ans += y*(10**(n-x))
    if x == t and y != u:
      che +=1
    t = x
    u = y
  if che == 0 and ans !=0:
    print(ans)
  elif che == 0 and n == 1:
    print(0)
  else:
    print(-1)
else:
  if n == 1:
    print(0)
  else:
    print(10**(n-1))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
if m != 0:
  a = [list(map(int,input().split())) for raw in range(m)]
  b = sorted(a)
ans = 0
if int((b[0])[0]) != 1:
  ans += 10**(n-1)
t = 0
u = -1
che = 0
for hoge in b:
  x = hoge[0]
  y = hoge[1]
  if x == 1 and y == 0:
    che += 1
  if x != t:
    ans += y*(10**(n-x))
  if x == t and y != u:
    che +=1
  t = x
  u = y
if che == 0 and ans !=0:
  print(ans)
elif che == 0 and n == 1:
  print(0)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [list(map(int,input().split())) for raw in range(m)]
b = sorted(a)
ans = 0
if int((b[0])[0]) != 1:
  ans += 10**(n-1)
t = 0
u = -1
che = 0
for hoge in b:
  x = hoge[0]
  y = hoge[1]
  if x == 1 and y == 0:
    che += 1
  if x != t:
    ans += y*(10**(n-x))
  if x == t and y != u:
    che +=1
  t = x
  u = y
if che == 0 and ans !=0:
  print(ans)
elif che == 0 and n == 1:
  print(0)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [list(map(int,input().split())) for raw in range(m)]
b = sorted(a)
ans = 0
if (b[0])[0] != 1:
  ans += 10**(n-1)
t = 0
u = -1
che = 0
for hoge in b:
  x = hoge[0]
  y = hoge[1]
  if x == 1 and y == 0:
    che += 1
  if x != t:
    ans += y*(10**(n-x))
  if x == t and y != u:
    che +=1
  t = x
  u = y
if che == 0 and ans !=0:
  print(ans)
elif che == 0 and n == 1:
  print(0)
else:
  print(-1)