Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
if N==2:
    print(-1)
    break
if K>cmb(N-1,2):
    print(-1)
else:
    count=cmb(N-1,2)-K
    print(cmb(N,2)-K)
    for i in range(2,N+1):
        print(1,i)

    for i in range(2,N):
        for j in range(i+1,N+1):
            if count==0:
                exit()
            print(i,j)
            count-=1


Fixed submission:
N,K=map(int,input().split())
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
if N==2 and K>=1:
    print(-1)
    exit()
if K>cmb(N-1,2):
    print(-1)
else:
    count=cmb(N-1,2)-K
    print(cmb(N,2)-K)
    for i in range(2,N+1):
        print(1,i)

    for i in range(2,N):
        for j in range(i+1,N+1):
            if count==0:
                exit()
            print(i,j)
            count-=1
Buggy python submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
ans=w*h/2
if w/2=x and h/2=y:
    print(ans,1)
else:
    print(ans,0)


Fixed submission:
w,h,x,y=map(int,input().split())
ans=[w*h/2]
if (x==0 and y==0) or (x==0 and y==h) or (x==w and y==0) or (x==w and y==h):
    ans.append(0)
elif y*w==x*h or y*h==x*w:
    ans.append(1)
else:ans.append(0)
print(*ans)

Buggy python submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
ans=w*h/2
if w=2*x and h=2*y:
    print(ans,1)
else:
    print(ans,0)


Fixed submission:
w,h,x,y=map(int,input().split())
ans=[w*h/2]
if (x==0 and y==0) or (x==0 and y==h) or (x==w and y==0) or (x==w and y==h):
    ans.append(0)
elif y*w==x*h or y*h==x*w:
    ans.append(1)
else:ans.append(0)
print(*ans)

Buggy python submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
ans=[w*h/2]
if y/x==h/w or y/x==w/h:
    ans.append(1)
else:ans.append(0)
print(*ans)


Fixed submission:
w,h,x,y=map(int,input().split())
ans=[w*h/2]
if (x==0 and y==0) or (x==0 and y==h) or (x==w and y==0) or (x==w and y==h):
    ans.append(0)
elif y*w==x*h or y*h==x*w:
    ans.append(1)
else:ans.append(0)
print(*ans)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
s=[input() for _ in range(h)]
yoko=[[0]*w for _ in range(h)]
tate=[[0]*w for _ in range(h)]
count=0
for i in range(h):
    a=[0]
    for j in range(w):
        if s[i][j]=="#":
            a.append(j+1)
    a.append(w+1)
    for j in range(1,len(a)):
        for k in range(a[j-1],a[j]-1):
            yoko[i][k]=a[j]-a[j-1]-1
for i in range(w):
    a=[0]
    for j in range(h):
        if s[j][i]=="#":
            a.append(j+1)
    a.append(h+1)
    for j in range(1,len(a)):
        for k in range(a[j-1],a[j]-1):
            tate[k][i]=a[j]-a[j-1]-1

ans=1
for i in range(w):
    for j in range(h):
        ans=max(ans,yoko[i][j]+tate[i][j]-1)
print(ans)


Fixed submission:
h,w=map(int,input().split())
s=[input() for _ in range(h)]
yoko=[[0]*w for _ in range(h)]
tate=[[0]*w for _ in range(h)]
count=0
for i in range(h):
    a=[0]
    for j in range(w):
        if s[i][j]=="#":
            a.append(j+1)
    a.append(w+1)
    for j in range(1,len(a)):
        for k in range(a[j-1],a[j]-1):
            yoko[i][k]=a[j]-a[j-1]-1
for i in range(w):
    a=[0]
    for j in range(h):
        if s[j][i]=="#":
            a.append(j+1)
    a.append(h+1)
    for j in range(1,len(a)):
        for k in range(a[j-1],a[j]-1):
            tate[k][i]=a[j]-a[j-1]-1

ans=1
for i in range(h):
    for j in range(w):
        ans=max(ans,yoko[i][j]+tate[i][j]-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
sp=[]
for i in range(n):
    s,p=input().split()
    sp.append(s,-int(p),i+1)
sp.sort()
for i in sp:
    print(i[2])


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

sp.sort(key=lambda x:x[1],reverse=True)

sp.sort(key=lambda x:x[0])
for i in range(n):
    print(sp[i][2])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for _ in range(m)]
A.sort()
BC.sort(key=lambda x:-x[1])

B=[]
for bc in BC:
    B+=[bc[1]]*bc[0]
    if len(B)>=N:
        break
B+=[0]*(N-len(B))
print(sum([max(A[i],B[i]) for i in range(N)]))


Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=[list(map(int,input().split())) for _ in range(M)]
A.sort()
BC.sort(key=lambda x:-x[1])

B=[]
for bc in BC:
    B+=[bc[1]]*bc[0]
    if len(B)>=N:
        break
B+=[0]*(N-len(B))
print(sum([max(A[i],B[i]) for i in range(N)]))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(max(a+b)+max(max(a+b)-1,min(a,b)))


Fixed submission:
a,b=map(int,input().split())
print(max(a,b)+max(max(a,b)-1,min(a,b)))
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if mac(a,b,c,d,e)-min(a,b,c,d,e)<=k:
    print("Yay!")
else:
    print(":(")


Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if max(a,b,c,d,e)-min(a,b,c,d,e)<=k:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())

def xor(n):
    ret=0
    i=1
    while True:
        div,mod=divmod(n,i)
        flg=i*(div//2)
        if div%2==1:
            flag+=(mod+1)
        if flg%2==1:
            ret+=i
        i*=2
        if i>n:
            break
    return ret
print(xor(a-1)^xor(b))


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

def xor(n):
    ret=0
    i=1
    while True:
        div,mod=divmod(n,i)
        flg=i*(div//2)
        if div%2==1:
            flg+=(mod+1)
        if flg%2==1:
            ret+=i
        i*=2
        if i>n:
            break
    return ret
print(xor(a-1)^xor(b))

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

def xor(n):
    ret=0
    i=1
    while True:
        div,mod=divmod(n,i)
        flg=i*(div//2)
        if div%2==1:
            flag+=(mod+1)
        if flg%2==1:
            ret+=i
        i*=2
        if i>n:
            break
    return ret
print(xor(a-1)^xor(b))

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

def xor(n):
    ret=0
    i=1
    while True:
        div,mod=divmod(n,i)
        flg=i*(div//2)
        if div%2==1:
            flg+=(mod+1)
        if flg%2==1:
            ret+=i
        i*=2
        if i>n:
            break
    return ret
print(xor(a-1)^xor(b))
Buggy python submission (verdict: Runtime Error):
from math import gcd
a,b,k=map(int,input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

C=make_divisors(gcd(a,b))
C.sort()
#print(C)
print(C[-k])


Fixed submission:
from fractions import gcd
a,b,k=map(int,input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

C=make_divisors(gcd(a,b))
C.sort()
#print(C)
print(C[-k])
Buggy python submission (verdict: Runtime Error):
s=intput()
if int(s[:4])<=2019:
    if int(s[4:6])<=4:
        if int(s[6:]):
            print("Heisei")
            exit()
print("TBD")


Fixed submission:
s=input()
if int(s[:4])<=2019:
    if int(s[5:7])<=4:
        if int(s[8:]):
            print("Heisei")
            exit()
print("TBD")
Buggy python submission (verdict: Runtime Error):
n=int(input())
xu=[list(map(str,input().split())) for _ in range(n)]
ans=0
for i in range(n):
    if xu[i][1]=="JPY":
        ans+=int(xu[i][0])
    else:
        ans+=int(xu[i][0]*380000.0)
print(ans)


Fixed submission:
n=int(input())
xu=[list(map(str,input().split())) for _ in range(n)]
ans=0
for i in range(n):
    if xu[i][1]=="JPY":
        ans+=float(xu[i][0])
    else:
        ans+=float(xu[i][0])*380000.0
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())

l=[0]*n
for i in range(n):
    ka=list(map(int,input().split()))
    A=ka[1:]
    for a in A:
        l[a-1]+=1
ans=0
for i in l:
    if i==n:
        ans+=1
print(ans)


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

l=[0]*m
for i in range(n):
    ka=list(map(int,input().split()))
    A=ka[1:]
    for a in A:
        l[a-1]+=1
ans=0
for i in l:
    if i==n:
        ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
k=[]
a=[]
for i in range(n):
    k.append(int(input()))
    a.append(list(map(int,input().split())))
ans=0
for i in range(n):
    f=True
    for j in range(m):
        if a[j]==0:
            f=False
    if f:
        ans+=1
print(ans)


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

l=[0]*m
for i in range(n):
    ka=list(map(int,input().split()))
    A=ka[1:]
    for a in A:
        l[a-1]+=1
ans=0
for i in l:
    if i==n:
        ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input())
k=[]
a=[]
for i in range(n):
    k.append(int(input()))
    a.append(list(map(int,input().split())))
ans=0
for i in range(n):
    f=True
    for j in range(m):
        if a[j]==0:
            f=False
    if f:
        ans+=1
print(ans)


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

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


Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
for i in range(1,n):
    ans=gcd(ans,a[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
x=int(iput())
if x==3 or x==5 or x==7:
    print("Yes")
else:
    print("No")


Fixed submission:
x=int(input())
if x==3 or x==5 or x==7:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
s=input()
ans=10000
for i in range(8):
    ans=min(ans,abs(int(s[i:i+3])-753))
print(ans)


Fixed submission:
s=input()
ans=10000
for i in range(len(s)-2):
    ans=min(ans,abs(int(s[i:i+3])-753))
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y=map(int(input().split())
print(x+y//2)


Fixed submission:
x,y=map(int,input().split())
print(x+y//2)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
P=[[] for _ in range(n+1)]
for i in range(m):
    p,y=map(int,input().split())
    P[p].append([y,i+1])
ans=[]
for j in range(m):
    if P[j]:
        P[j].sort()
        for i in range(len(P[j])):
            #print(P[j])
            ans.append([P[j][i][1],str((j*10**6+i+1)).zfill(12)])
ans.sort()
for i in range(m):
    print(ans[i][1])


Fixed submission:
n,m=map(int,input().split())
P=[[] for _ in range(n+1)]
for i in range(m):
    p,y=map(int,input().split())
    P[p].append([y,i+1])
ans=[]
for j in range(n+1):
    if P[j]:
        P[j].sort()
        for i in range(len(P[j])):
            #print(P[j])
            ans.append([P[j][i][1],str((j*10**6+i+1)).zfill(12)])
ans.sort()
for i in range(m):
    print(ans[i][1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n==1:
    print("Hello World")
if n==2:
    a,b=map(int,input().split())
    print(a+b)


Fixed submission:
n=int(input())
if n==1:
    print("Hello World")
if n==2:
    a=int(input())
    b=int(input())
    print(a+b)
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split())).sort()
print(a[2]*10+a[1]+a[0])


Fixed submission:
a=list(map(int,input().split()))
a.sort()
print(a[2]*10+a[1]+a[0])
Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(N):
    if abs(x[i]-X)==0:
        continue
    x[i]=abs(x[i]-X)
for i in range(N-1):
    ans=gcd(x[i],x[i+1])
print(gcd)


Fixed submission:
from fractions import gcd
N,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(N):
    if abs(x[i]-X)==0:
        continue
    x[i]=abs(x[i]-X)

ans=x[0]
for i in range(N):
    ans=gcd(ans,x[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
a=[list(map(int,input().split())) for i in range(H)]
for h in range(H):
    for w in range(W):
        if a[h][w]%2==0:
            a[h][w]=0
        else:
            a[h][w]=1
ans=[]
for h in range(H):
    for w in range(W-1):
        if a[h][w]==1:
            a[h][w+1]=a[h][w+1]^a[h][w]
            ans.append([h+1,w+1,h+1,w+2])
for h in range(H-1):
    if a[h][-1]==1:
        a[h+1][-1]=a[h+a][-1]^a[h][-1]
        ans.append([h+1,W,h+2,W])
print(len(ans))
for i in ans:
    print(*i)


Fixed submission:
H,W=map(int,input().split())
a=[list(map(int,input().split())) for i in range(H)]
for h in range(H):
    for w in range(W):
        if a[h][w]%2==0:
            a[h][w]=0
        else:
            a[h][w]=1
ans=[]
for h in range(H):
    for w in range(W-1):
        if a[h][w]==1:
            a[h][w+1]=a[h][w+1]^a[h][w]
            ans.append([h+1,w+1,h+1,w+2])
for h in range(H-1):
    if a[h][-1]==1:
        a[h+1][-1]=a[h+1][-1]^a[h][-1]
        ans.append([h+1,W,h+2,W])
print(len(ans))
for i in ans:
    print(*i)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
num=[0]*k
for i in range(n):
    num[i%k]+=1
for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c)%k!=0:continue
    res+=num[a]*num[b]*num[c]
print(res)


Fixed submission:
n,k=map(int,input().split())
num=[0]*k
for i in range(1,n+1):
    num[i%k]+=1
res=0
for a in range(k):
    b=(k-a)%k
    c=(k-a)%k
    if (b+c)%k!=0:continue
    res+=num[a]*num[b]*num[c]
print(res)
Buggy python submission (verdict: Runtime Error):
from math import log2
L=int(input())
ans=[]
i=1
while True:
    if 2**i>L:
        last=i
        break
    ans.append([i,i+1,2**(i-1)])
    ans.append([i,i+1,0])
    i+=1
"""for i in ans:
    print(i)
print(last)"""
num=2**(last-1)
a=L-num
while a>0:
    ans.append([int(log2(a))+1,last,num])
    num+=2**(int(log2(a)))
    a=L-num
for i in ans:
    print(*i)


Fixed submission:
from math import log2
L=int(input())
ans=[]
i=1
while True:
    if 2**i>L:
        last=i
        break
    ans.append([i,i+1,2**(i-1)])
    ans.append([i,i+1,0])
    i+=1
"""for i in ans:
    print(i)
print(last)"""
num=2**(last-1)
a=L-num
while a>0:
    ans.append([int(log2(a))+1,last,num])
    num+=2**(int(log2(a)))
    a=L-num
print(last,len(ans))
for i in ans:
    print(*i)

Buggy python submission (verdict: Runtime Error):
from math import log2
L=int(input())
ans=[]
i=1
while True:
    if 2**i>L:
        last=i
        break
    ans.append([i,i+1,2**(i-1)])
    ans.append([i,i+1,0])
    i+=1
"""for i in ans:
    print(i)
print(last)"""
num=2**(last-1)
a=L-num
while a>0:
    ans.append([int(log2(a))+1,last,num])
    num+=2**(int(log2(a)))
    a=L-num
for i in ans:
    print(i)


Fixed submission:
from math import log2
L=int(input())
ans=[]
i=1
while True:
    if 2**i>L:
        last=i
        break
    ans.append([i,i+1,2**(i-1)])
    ans.append([i,i+1,0])
    i+=1
"""for i in ans:
    print(i)
print(last)"""
num=2**(last-1)
a=L-num
while a>0:
    ans.append([int(log2(a))+1,last,num])
    num+=2**(int(log2(a)))
    a=L-num
print(last,len(ans))
for i in ans:
    print(*i)
Buggy python submission (verdict: Runtime Error):
def divisor(n):
    divisors=[]
    for i in range(1,int(n**0.5+1)):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
n=int(input())
ans=0
for i in range(2,n):
    num=divisors(i)
    if len(num)==8:
        ans+=1
print(ans)


Fixed submission:
def divisor(n):
    divisors=[]
    for i in range(1,int(n**0.5+1)):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
n=int(input())
ans=0
for i in range(2,n+1):
    num=divisor(i)
    if i%2==1 and len(num)==8:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
ans=1
for i in range(len(s)):
    if s[i]!="1":
        num=i
        ans=s[i]
        break
if k<=num:
    print(1)
else:
    print(ans)


Fixed submission:
s=input()
k=int(input())
ans=1
num=1000
for i in range(len(s)):
    if s[i]!="1":
        num=i
        ans=s[i]
        break
if k<=num:
    print(1)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
for i in range(len(s)):
    if s[i]!="1":
        num=i
        ans=s[i]
        break
if k<=num:
    print(1)
else:
    print(ans)


Fixed submission:
s=input()
k=int(input())
ans=1
num=1000
for i in range(len(s)):
    if s[i]!="1":
        num=i
        ans=s[i]
        break
if k<=num:
    print(1)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
for i in range(len(s)):
    if s[i]!="1":
        num=i
        ans=s[i]
        break
if k<=num:
    print(1)
else:
    print(ans)


Fixed submission:
s=input()
k=int(input())
ans=1
num=1000
for i in range(len(s)):
    if s[i]!="1":
        num=i
        ans=s[i]
        break
if k<=num:
    print(1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n==0:print(0)
bi=''
while n!=0:
    bi+=str(n%abs(k))
    if k<0:n=-(-n//k)
    else:n=n//k
print(bi[::-1])


Fixed submission:
N=int(input())
if N==0:print(0)
ans=""
while N!=0:
    r=N%2
    N=(N-r)//(-2)
    ans+=str(r)
ans=ans[::-1]
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
if N==0:print(0)
bi=''
while n!=0:
    bi+=str(n%abs(k))
    if k<0:n=-(-n//k)
    else:n=n//k
print(bi[::-1])

Fixed submission:
N=int(input())
if N==0:print(0)
ans=""
while N!=0:
    r=N%2
    N=(N-r)//(-2)
    ans+=str(r)
ans=ans[::-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
flg=True
if s[i]!="A":
    flg=False
cnt=0
for i in s[3:-2]:
    if i=="C":
        cnt+=1
if cnt!=1:
    flg=False
cnt=0
for i in s:
    if i.isupper():
        cnt+=1
if cnt!=2:
    flg=False
if flg:
    print("AC")
else:
    print("WA")


Fixed submission:
s=input()
flg=True
if s[0]!="A":
    flg=False
cnt=0

for i in s[2:-1]:
    if i=="C":
        cnt+=1
#print(cnt)
if cnt!=1:
    flg=False
cnt=0
for i in s:
    if i.isupper():
        cnt+=1
if cnt!=2:
    flg=False
if flg:
    print("AC")
else:
    print("WA")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
if n=1:
    print(0)
    exit()
for i in range(n):
    a[i]=a[i]-i-1
a.sort()
b1=a[n//2]
b2=a[n//2+1]
ans1=[]
ans2=[]
for i in range(n):
    ans1.append(abs(a[i]-b1))
for i in range(n):
    ans2.append(abs(a[i]-b2))
print(min(sum(ans1),sum(ans2)))


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if n==1:
    print(0)
    exit()
for i in range(n):
    a[i]=a[i]-i-1
a.sort()
b1=a[n//2]
b2=a[n//2+1]
ans1=[]
ans2=[]
for i in range(n):
    ans1.append(abs(a[i]-b1))
for i in range(n):
    ans2.append(abs(a[i]-b2))
print(min(sum(ans1),sum(ans2)))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]=a[i]-i-1
a.sort()
b1=a[n//2]
b2=a[n//2+1]
ans1=[]
ans2=[]
for i in range(n):
    ans1.append(abs(a[i]-b1))
for i in range(n):
    ans2.append(abs(a[i]-b2))
print(min(sum(ans1),sum(ans2)))


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if n==1:
    print(0)
    exit()
for i in range(n):
    a[i]=a[i]-i-1
a.sort()
b1=a[n//2]
b2=a[n//2+1]
ans1=[]
ans2=[]
for i in range(n):
    ans1.append(abs(a[i]-b1))
for i in range(n):
    ans2.append(abs(a[i]-b2))
print(min(sum(ans1),sum(ans2)))
Buggy python submission (verdict: Runtime Error):
s=input()
n=0
for i in range(s):
    if s[i]=="+":
        n+=1
print(n-(4-n))


Fixed submission:
s=input()
n=0
for i in range(len(s)):
    if s[i]=="+":
        n+=1
print(n-(4-n))
Buggy python submission (verdict: Runtime Error):
n=input()
sn=""
for i in range(len(n)):
    sn+=str(n[i])
if int(n)%sn==0:
    print("Yes")
else:
    print("No")


Fixed submission:
n=input()
sn=0
for i in range(len(n)):
    sn+=int(n[i])
if int(n)%sn==0:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
n=input()
sn=""
for i in range(len(n)):
    sn+=str(n[i])
if int(n)%sm==0:
    print("Yes")
else:
    print("No")


Fixed submission:
n=input()
sn=0
for i in range(len(n)):
    sn+=int(n[i])
if int(n)%sn==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
m=float("INF")
sunukes=[]
for i in range(2,-1,-1):
    for j in range(100,10,-1):
        #print(i,j)
        sunuke=j*(10**i)-1
        s=str(sunuke)
        sn=0
        for k in range(len(s)):
            sn+=int(s[k])
        x=sunuke/sn
        #print(sn,x,i,j,j*10**i-1)
        if x<=m :
            m=x
            sunukes.append(sunuke)
for i in range(9,0,-1):
    sunukes.append(i)
k=int(input())
#print(sunukes)
print(sunukes[-k])


Fixed submission:
m=float("INF")
sunukes=[]
for i in range(7,-1,-1):
    for j in range(1000,10,-1):
        #print(i,j)
        sunuke=j*(100**i)-1
        s=str(sunuke)
        sn=0
        for k in range(len(s)):
            sn+=int(s[k])
        x=sunuke/sn
        #print(sunuke,x)
        if x<=m :
            m=x
            sunukes.append(sunuke)
for i in range(9,0,-1):
    sunukes.append(i)
sunukes=sunukes[::-1]
k=int(input())
#print(sunukes)
for i in range(k):
    print(sunukes[i])
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
cake=[list(map(int,input().split())) for _ in range(N)]
ans=0
if M=0:
    print(ans)
    exit()
for i in range(1<<3):
    point=[0]*N
    for j in range(N):
        for k in range(3):
            point[j]+=(-1+(i>>k & 1)*2)*cake[j][k]
    point.sort()
    ans=max(ans,sum(point[-M:]))
print(ans)


Fixed submission:
N,M=map(int,input().split())
cake=[list(map(int,input().split())) for _ in range(N)]
ans=0
for i in range(1<<3):
    point=[0]*N
    for j in range(N):
        for k in range(3):
            point[j]+=(-1+(i>>k & 1)*2)*cake[j][k]
    point.sort()
    ans=max(ans,sum(point[-M:]))
    if M==0:
        ans=0
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
num=0
nums=[]
for i in range(1,1000):
    num+=i
    nums.append(num)
for i in range(1,999):
    if nums[i]-a==num[i+1]-b:
        print(nums[i])


Fixed submission:
a,b=map(int,input().split())
num=0
nums=[]
for i in range(1,1000):
    num+=i
    nums.append(num)
for i in range(998):
    if nums[i]-a==nums[i+1]-b:
        print(nums[i]-a)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
a,b=map(int,input().split())
print("YES" if b<=x<=a+b else "NO")


Fixed submission:
import sys
input = sys.stdin.readline
a,b,x=map(int,input().split())
print("YES" if a<=x<=a+b else "NO")