Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
A,B=map(int,input().split())
s=[]
for i in range(A,B+1):
    s.append(format(i,'b'))
for i in range(len(s)):
    while len(s[i])<len(s[-1]):
        s[i]='0'+s[i]
a=np.array(s)
b=[list(map(int,a[i])) for i in range(len(a))]
b=np.array(b)
x=[0]*len(s[-1])#x[0]~s[len(s[-1])-1]
ans=''
for i in reversed(range(len(s[-1]))):
    if np.sum(b[:,i])%2==0:
        x[i]='0'
    else:
         x[i]='1'
for i in range(len(s[-1])):
    ans+=x[i]
print(int(ans,2))

Fixed submission:
A,B=map(int,input().split())
def f(n):
    if n%4==0:
        return n
    elif n%4==1:
        return 1
    elif n%4==2:
        return n^1
    else:
        return 0
print(f(A-1)^f(B))

Buggy python submission (verdict: Runtime Error):
import numpy as np
A,B=map(int,input().split())
s=[]
for i in range(A,B+1):
    s.append(format(i,'b'))
for i in range(len(s)):
    if len(s[i])<len(s[-1]):
        s[i]='0'+s[i]
a=np.array(s)
b=[list(map(int,a[i])) for i in range(len(a))]
b=np.array(b)
x=[0]*len(s[-1])#x[0]~s[len(s[-1])-1]
ans=''
for i in range(len(s[-1])):
    if np.sum(b[:,i])%2==0:
        x[len(s[-1])-1-i]='0'
    else:
         x[len(s[-1])-1-i]='1'
for i in range(len(s[-1])):
    ans+=x[i]
print(ans)
print(int(ans,2))

Fixed submission:
A,B=map(int,input().split())
def f(n):
    if n%4==0:
        return n
    elif n%4==1:
        return 1
    elif n%4==2:
        return n^1
    else:
        return 0
print(f(A-1)^f(B))
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
D=B//A-C
if D>0:
  print(C)
else:
  print(B//A)

Fixed submission:
A,B,C=map(int,input().split())
D=B//A-C
if D>0:
  print(C)
else:
  print(B//A)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
while A<1 or A>100 or B<1 or B>100 or C<1 or C>100:
	A=int(input())
    B=int(input())
    C=int(input())
D=B//A-C
if D>0:
  print(C)
else:
  print(B//A)

Fixed submission:
A,B,C=map(int,input().split())
D=B//A-C
if D>0:
  print(C)
else:
  print(B//A)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
while A<1 or A>100 or B<1 or B>100 or C<1 or C>100:
	A=int(input())
    B=int(input())
    C=int(input())
D=B//A-C
if D>0:
  print(C)
else:
  print(B//A)


Fixed submission:
A,B,C=map(int,input().split())
D=B//A-C
if D>0:
  print(C)
else:
  print(B//A)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
while A<1 or A>100 or B<1 or B>100 or C<1 or C>100:
 A=int(input()),B=int(put()),C=int(input())
D=B//A-C
if D>0:
  print(C)
else:
  print(B//A)

Fixed submission:
A,B,C=map(int,input().split())
D=B//A-C
if D>0:
  print(C)
else:
  print(B//A)

Buggy python submission (verdict: Runtime Error):
A=int(input()),B=int(put()),C=int(input())
while A<1 or A>100 or B<1 or B>100 or C<1 or C>100:
 A=int(input()),B=int(put()),C=int(input())
D=B//A-C
if D>0:
  print(C)
else:
  print(B//A)

Fixed submission:
A,B,C=map(int,input().split())
D=B//A-C
if D>0:
  print(C)
else:
  print(B//A)
Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
i=0
j=1
a=[]
while A%j==0 and B%j==0:
    a.append(j)
    j+=1
print(a[-K])


Fixed submission:
A,B,K=map(int,input().split())
i=0
j=1
a=[]
while j<=max(A,B):
    if A%j==0 and B%j==0:
        a.append(j)
    j+=1
print(a[-K])

Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
i=0
j=1
a=[]
if A%j==0 and B%j==0:
    a.append(j)
    j+=1
print(a[-K])

Fixed submission:
A,B,K=map(int,input().split())
i=0
j=1
a=[]
while j<=max(A,B):
    if A%j==0 and B%j==0:
        a.append(j)
    j+=1
print(a[-K])

Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
i=0
j=1
a=[]
if A%j==0 and B%j==0:
    a.append(j)
    j+=1
print(a[-4])

Fixed submission:
A,B,K=map(int,input().split())
i=0
j=1
a=[]
while j<=max(A,B):
    if A%j==0 and B%j==0:
        a.append(j)
    j+=1
print(a[-K])

Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
i=1
j=2
if A%j=0 and B%j=0 and i<K:
  i+=1
  j+=1
print(j)

Fixed submission:
A,B,K=map(int,input().split())
i=0
j=1
a=[]
while j<=max(A,B):
    if A%j==0 and B%j==0:
        a.append(j)
    j+=1
print(a[-K])
Buggy python submission (verdict: Runtime Error):
S=list(map(int,input()))
a=0
b=0
for i in range(lin(S)):
  if S[i]==1:
    a+=1
  else:
    b+=1
print(2*min(a,b))

Fixed submission:
S=list(map(int,input()))
a=0
b=0
for i in range(len(S)):
    if S[i]==1:
        a+=1
    else:
        b+=1
print(2*min(a,b))

Buggy python submission (verdict: Time Limit Exceeded):
def make_list(x,S):#x:元の配列から切り取る番号 S:リスト受け取り
    a=[]
    for i in range(0,x):#S[0]~S[x-1]までを追加
        a.append(S[i])
    if x<len(S)-2:
        for i in range(x+2,len(S)):
            a.append(S[i])
    return a
S=list(map(int,input()))
N=len(S)#S[0]~S[N-1]
count=0
j=0
while j==0 and N!=1:
    for i in range(N-1):#S[0]~S[N-2]
        if (S[i]==0 and S[i+1]==1)or(S[i]==1 and S[i+1]==0):
            count+=2
            S=make_list(i,S)#Sの書き換え
            N=len(S)#Nの書き換え
            if N==0:
                j=1
            break
        elif i==N-2:
            j=1
print(count)

Fixed submission:
S=list(map(int,input()))
a=0
b=0
for i in range(len(S)):
    if S[i]==1:
        a+=1
    else:
        b+=1
print(2*min(a,b))

Buggy python submission (verdict: Time Limit Exceeded):
S=list(map(int,input()))
N=len(S)#S[0]~S[N-1]
count=0
j=0
def make_list(x,S):#x:元の配列から切り取る番号 S:リスト受け取り
    a=[]
    for i in range(0,x):#S[0]~S[x-1]までを追加
        a.append(S[i])
    if x<len(S)-2:
        for i in range(x+2,len(S)):
            a.append(S[i])
    return a
while j==0 and N!=1:
    for i in range(N-1):#S[0]~S[N-2]
        if (S[i]==0 and S[i+1]==1)or(S[i]==1 and S[i+1]==0):
            count+=2
            S=make_list(i,S)#Sの書き換え
            N=len(S)#Nの書き換え
            if N==0:
                j=1
            break
        elif i==N-2:
            j=1
print(count)

Fixed submission:
S=list(map(int,input()))
a=0
b=0
for i in range(len(S)):
    if S[i]==1:
        a+=1
    else:
        b+=1
print(2*min(a,b))

Buggy python submission (verdict: Time Limit Exceeded):
S=list(map(int,input()))
N=len(S)#S[0]~S[N-1]
count=0
j=0
def make_list(x,S):#x:元の配列から切り取る番号 S:リスト受け取り
    a=[]
    for i in range(0,x):#S[0]~S[x-1]までを追加
        a.append(S[i])
    if x<len(S)-2:
        for i in range(x+2,len(S)):
            a.append(S[i])
    return a
while j==0:
    for i in range(N-1):#S[0]~S[N-2]
        if (S[i]==0 and S[i+1]==1)or(S[i]==1 and S[i+1]==0):
            count+=2
            S=make_list(i,S)#Sの書き換え
            N=len(S)#Nの書き換え
            if N==0:
                j=1
            break
        elif i==N-2:
            j=1
print(count)

Fixed submission:
S=list(map(int,input()))
a=0
b=0
for i in range(len(S)):
    if S[i]==1:
        a+=1
    else:
        b+=1
print(2*min(a,b))
Buggy python submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
inf=10**9
def dfs(d,a,b,c):
    if d==n:#合成完了
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf #無からは作れない#0に合成するのにmpは使わないので-30
    ret0=dfs(d+1,a,b,c)#l[d]を使わない
    ret1=dfs(d+1,a+l[d],b,c)+10#l[d]をAに
    ret2=dfs(d+1,a,b+l[d],c)+10#l[d]をBに
    ret3=dfs(d+1,a,b,c+l[d])+10#l[d]をCに
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

Fixed submission:
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
inf=10**9
def dfs(d,a,b,c):
    if d==N:#合成完了
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf #無からは作れない#0に合成するのにmpは使わないので-30
    ret0=dfs(d+1,a,b,c)#l[d]を使わない
    ret1=dfs(d+1,a+l[d],b,c)+10#l[d]をAに
    ret2=dfs(d+1,a,b+l[d],c)+10#l[d]をBに
    ret3=dfs(d+1,a,b,c+l[d])+10#l[d]をCに
    ans=min(ret0,ret1,ret2,ret3)
    return ans
print(dfs(0,0,0,0))

Buggy python submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
inf=10**9
def dfs(d,a,b,c):
    if d==n:#合成完了
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf #無からは作れない
    ret0=dfs(d+1,a,b,c)#l[d]を使わない
    ret1=dfs(d+1,a+l[d],b,c)+10#l[d]をAに
    ret2=dfs(d+1,a,b+l[d],c)+10#l[d]をBに
    ret3=dfs(d+1,a,b,c+l[d])+10#l[d]をCに
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

Fixed submission:
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
inf=10**9
def dfs(d,a,b,c):
    if d==N:#合成完了
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf #無からは作れない#0に合成するのにmpは使わないので-30
    ret0=dfs(d+1,a,b,c)#l[d]を使わない
    ret1=dfs(d+1,a+l[d],b,c)+10#l[d]をAに
    ret2=dfs(d+1,a,b+l[d],c)+10#l[d]をBに
    ret3=dfs(d+1,a,b,c+l[d])+10#l[d]をCに
    ans=min(ret0,ret1,ret2,ret3)
    return ans
print(dfs(0,0,0,0))

Buggy python submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
inf=10**9
def dfs(d,a,b,c):
    if d==n:#合成完了
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    ret0=def(d+1,a,b,c)#l[d]を使わない
    ret1=def(d+1,a+l[d],b,c)+10#l[d]をAに
    ret2=def(d+1,a,b+l[d],c)+10#l[d]をBに
    ret3=def(d+1,a,b,c+l[d])+10#l[d]をCに
    return min(ret0,ret1,ret2,ret3)
print(def(0,0,0,0))

Fixed submission:
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
inf=10**9
def dfs(d,a,b,c):
    if d==N:#合成完了
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf #無からは作れない#0に合成するのにmpは使わないので-30
    ret0=dfs(d+1,a,b,c)#l[d]を使わない
    ret1=dfs(d+1,a+l[d],b,c)+10#l[d]をAに
    ret2=dfs(d+1,a,b+l[d],c)+10#l[d]をBに
    ret3=dfs(d+1,a,b,c+l[d])+10#l[d]をCに
    ans=min(ret0,ret1,ret2,ret3)
    return ans
print(dfs(0,0,0,0))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print(int(a*b/2)

Fixed submission:
a,b,c=map(int,input().split())
print(int(a*b/2))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**10]*(N)#dp[i]→i+1番目の柱にくる最小コスト
dp[0]=0
for i in range(N-1):
    dp[i+1]=min(dp[i+1-j]+abs(h[i+1]-h[i+1-j]) for j in range(1,min(i+1,K)+1))
print(dp[N-1])

Fixed submission:
N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**10]*(N)#dp[i]→i+1番目の柱にくる最小コスト
dp[0]=0
for i in range(N-1):
    dp[i+1]=min(dp[i+1-j]+abs(h[i+1]-h[i+1-j]) for j in range(1,min(i+1,K)+1))
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,X=map(int,input().split())
l=[2**(i+2)-3 for i in range(N+1)]#レベルLバーガー層数
p=[2**(i+1)-1 for i in range(N+1)]#レベルL パティ数
bp=[[0 for i in range(X+1)] for j in range(N+1)]
bp[0][1]=1
for i in range(N):
    for j in range(X+1):
        if j==1:
            bp[i+1][j]=0
        elif 1<j<=l[i]+1:
            bp[i+1][j]=bp[i][j-1]
        elif j==l[i]+2:
            bp[i+1][j]=p[i]+1
        elif l[i]+2<j<l[i+1]:
            bp[i+1][j]=p[i]+1+bp[i][j-l[i]-2]
        elif j==l[i+1]:
            bp[i+1][j]=p[i+1]
print(bp[N][X])

Fixed submission:
N,X=map(int,input().split())
l=[2**(i+2)-3 for i in range(N+1)]#レベルLバーガー層数
p=[2**(i+1)-1 for i in range(N+1)]#レベルL パティ数
def f(n,x):
    if n==0:
        return 1
    elif x==1:
        return 0
    elif 1<x<=l[n-1]+1:
        return f(n-1,x-1)
    elif x==l[n-1]+2:
        return p[n-1]+1
    elif l[n-1]+2<x<l[n]:
        return p[n-1]+1+f(n-1,x-l[n-1]-2)
    elif x==l[n]:
        return p[n]
print(f(N,X))
Buggy python submission (verdict: Runtime Error):
N=int(input())

def dfs(s):
    if int(s)>N:
        return 0:
    ret=1 if all (s.count(c)>0 for c in '753') else 0
    for c in '753':
        ret+=dfs(s+c)
    return ret

print(dfs('0'))

Fixed submission:
S=list(map(int,input()))
m=[]
for i in range(len(S)-2):
    m.append(abs(753-(100*S[i]+10*S[i+1]+S[i+2])))
print(min(m))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
count=0
if N<357:
    print(count)
else:
    for i in range(357,N+1):
        a=[0,0,0]#3,5,7の個数
        s=str(i)#文字列に直す
        for j in range(len(s)):# iの各桁の探索
            if s[j]=='3':
                a[0]+=1
            elif s[j]=='5':
                a[1]+=1
            elif s[j]=='7':
                a[2]+=1
            else:
                break
        b=a[0]+a[1]+a[2]#3,5,7の個数
        if a[0]>0 and a[1]>0 and a[2]>0 and b==len(s):
            count+=1
    print(count)

Fixed submission:
N=int(input())

def dfs(s):
    if int(s)>N:
        return 0
    ret=1 if all (s.count(c)>0 for c in '753') else 0
    for c in '753':
        ret+=dfs(s+c)
    return ret

print(dfs('0'))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for i in range(M)]
a=np.array(PY)
p=a[:,0]# 属する県の情報
q=a[:,1]
x=[i for i in range(M)]#答え
def make_number(p,x):
    return str(p*10**6+x).zfill(12)
for i in range(1,N+1):
    y=[]
    for j in range(M):
         if p[j]==i:
                y.append(a[j][1])#県iに属する市の誕生年
    y2=sorted(y) 
    for l in range(len(y2)):
        for k in range(len(q)):
            if q[k]==y2[l]:
                x[k]=make_number(i,l+1)
for i in range(M):
    print(x[i])

Fixed submission:
n,m=map(int,input().split())
pys=[]
def make_number(p,x):
    return str(p*10**6+x).zfill(12)
for i in range(m):
    a,b=map(int,input().split())
    pys.append([a,b,i])
pys.sort()
ans=[i for i in range(m)]
c=-1
j=0
for [p,y,s] in pys:
    if c!=p:
        j=1
        c=p
    ans[s]=make_number(p,j)
    j+=1
for i in range(m):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N==1:
    print('Hello World')
else:
    A,B=map(int,input().split())
    print(A+B)

Fixed submission:
N=int(input())
if N==1:
    print('Hello World')
else:
    A=int(input())
    B=int(input())
    print(A+B)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
import math
from scipy import special
a=[]
ans=1
def calc(n):#nの素因数分解
    for i in range(2,int(n**0.5)+10):
        count=0
        while n%i==0:
            n//=i
            count+=1
        if count>=1:
            a.append([i,count])
    if n!=1:
        a.append([n,1])
calc(M)
for i in range(len(a)):
    ans*=special.comb(a[i][1]+N-1,a[i][1],True)
print(ans%(10**9+7))

Fixed submission:
N,M=map(int,input().split())
a=[]
ans=1
def calc(n):#nの素因数分解
    for i in range(2,int(n**0.5)+10):
        count=0
        while n%i==0:
            n//=i
            count+=1
        if count>=1:
            a.append([i,count])
    if n!=1:
        a.append([n,1])
calc(M)
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
for i in range(len(a)):
    ans*=cmb(a[i][1]+N-1,a[i][1])
print(ans%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
import math
a=[]
ans=1
def calc(n):#nの素因数分解
    for i in range(2,int(n**0.5)+10):
        count=0
        while n%i==0:
            n//=i
            count+=1
        if count>=1:
            a.append([i,count])
    if n!=1:
        a.append([n,1])
def conb(n,k):
    return math.factorial(n)//(math.factorial(n-k)*math.factorial(k))
calc(M)
for i in range(len(a)):
    ans*=conb(a[i][1]+N-1,a[i][1])
print(ans%(10**9+7))

Fixed submission:
N,M=map(int,input().split())
a=[]
ans=1
def calc(n):#nの素因数分解
    for i in range(2,int(n**0.5)+10):
        count=0
        while n%i==0:
            n//=i
            count+=1
        if count>=1:
            a.append([i,count])
    if n!=1:
        a.append([n,1])
calc(M)
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
for i in range(len(a)):
    ans*=cmb(a[i][1]+N-1,a[i][1])
print(ans%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
c=0
for i in range(1,N+1):
    ans=[0,0,0]
    for j in range(1,2*N//K+1):
        if 1<=j*K-i<=N:
            for l in range(1,2*N//K+1):
                if 1<=l*K-j*K+i<=N and (2*i+l*K-j*K)%K==0:
                    count=0
                    ans[0]=i
                    ans[1]=j*K-i
                    ans[2]=l*K-j*K+i
                    ans.sort()
                    c+=1
print(c)

Fixed submission:
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
N,K=map(int,input().split())
if K%2==0:
    print((N//K)**3+(((N-K//2)//K+1)**3))
else:
    print((N//K)**3)
Buggy python submission (verdict: Runtime Error):
S=input()
K=int(input())
if S[0]!='1':
    print(S[0])
else:
    for i in range(len(S)):
        if S[i]!='1':
            if K<=i:
                print('1'):
            else:
                print(S[i])
            break

Fixed submission:
S=input()
K=int(input())
if S[0]!='1':
    print(S[0])
else:
    flag=True
    for i in range(len(S)):
        if S[i]!='1':
            if K<=i:
                print('1')
            else:
                print(S[i])
            flag=False
            break
    if flag:
        print(1)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0 for i in range(N+1)] for j in range(N+1)]
count=0
for i in range(N):
    dp[i+1][i+1]=a[i]
    if a[i]%M==0:
        count+=1
    if N==1:
        break
    else:
        for j in range(i+2,N+1):
            dp[i+1][j]=dp[i+1][j-1]+a[j-1]
            if dp[i+1][j]%M==0:
                count+=1
print(count)

Fixed submission:
from collections import Counter
N,M=map(int,input().split())
a=list(map(int,input().split()))
s=[a[0]]
if N==1:
    if a[0]%M==0:
        print(1)
    else:
        print(0)
else:
    for i in range(N-1):
        s.append(s[i]+a[i+1])
    for i in range(N):
        s[i]%=M
    count=0
    b=Counter(s)
    c=b.most_common()
    def calc(n):
        ans=0
        for i in range(1,n+1):
            ans+=i
        return ans
    for i in range(len(c)):
        if c[i][1]!=1:
            count+=calc(c[i][1]-1)
            if c[i][0]==0:
                count+=c[i][1]
        else:
            break
    print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
    b[i]=a[i]-(i+1)
s=0
for i in range(n):
    s+=b[i]
mean=s//(len(b))
ans=10**10
mi=mean-10**3
ma=mean+10**3
for i in range(mi,ma):
    w=0
    c=list(map(lambda x:abs(x-i),b))
    for j in range(n):
        w+=c[j]
    if w<ans:
        ans=w
print(ans)

Fixed submission:
import statistics
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
    b[i]=a[i]-(i+1)
b.sort()
if n%2==1:
    m=statistics.median(b)
    b=list(map(lambda x:abs(x-m),b))
    ans=0
    for i in range(n):
        ans+=b[i]
else:
    m1=b[n//2]
    m2=b[n//2+1]
    k=list(map(lambda x:abs(x-m1),b))
    l=list(map(lambda x:abs(x-m2),b))
    ans1=0
    ans2=0
    for i in range(n):
        ans1+=k[i]
        ans2+=l[i]
    ans=min(ans1,ans2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
    b[i]=a[i]-(i+1)
s=0
for i in range(n):
    s+=b[i]
mean=s//(len(b))
ans=10**10
mi=mean-10**4
ma=mean+10**4
for i in range(mi,ma):
    w=0
    c=list(map(lambda x:abs(x-i),b))
    for j in range(n):
        w+=c[j]
    if w<ans:
        ans=w
print(ans)

Fixed submission:
import statistics
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
    b[i]=a[i]-(i+1)
b.sort()
if n%2==1:
    m=statistics.median(b)
    b=list(map(lambda x:abs(x-m),b))
    ans=0
    for i in range(n):
        ans+=b[i]
else:
    m1=b[n//2]
    m2=b[n//2+1]
    k=list(map(lambda x:abs(x-m1),b))
    l=list(map(lambda x:abs(x-m2),b))
    ans1=0
    ans2=0
    for i in range(n):
        ans1+=k[i]
        ans2+=l[i]
    ans=min(ans1,ans2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
b = {}
for _ in range(int(input())): s=input(); b[s]=b.get(s,0)+1
print(*sorted(k for k in b if b[k]==max(b.values())))

Fixed submission:
b = {}
for _ in range(int(input())): s=input(); b[s]=b.get(s,0)+1
m = max(b.values())
print(*sorted(k for k in b if b[k]==m))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = int(input())
a = []
for i in range(n):
    a.append(input())
b = Counter(a)
for k, v in sorted(b.items()):
    if v == max(b.values()):
        print(k)


Fixed submission:
b = {}
for _ in range(int(input())): s=input(); b[s]=b.get(s,0)+1
m = max(b.values())
print(*sorted(k for k in b if b[k]==m))
Buggy python submission (verdict: Runtime Error):
n = int(input())
sp = [list(map(int, input().split())) for _ in range(n)]

d = sorted(sp, key=lambda x:(x[0],-x[1]))
for i in range(len(sp)):
    print(sp.index(d[i]))

Fixed submission:
n = int(input())
sp = [list(input().split()) for _ in range(n)]
for i in range(len(sp)):
    sp[i][1] = int(sp[i][1])
d = sorted(sp, key=lambda x:(x[0],-x[1]))
for i in range(len(sp)):
    print(sp.index(d[i])+1)

Buggy python submission (verdict: Runtime Error):
n = int(input())
sp = [list(map(int, input().split())) for _ in range(n)]

sorted(sp, key=lambda x:(x[0],-x[1]))
for i in range(len(sp)):
    print(sp[i])

Fixed submission:
n = int(input())
sp = [list(input().split()) for _ in range(n)]
for i in range(len(sp)):
    sp[i][1] = int(sp[i][1])
d = sorted(sp, key=lambda x:(x[0],-x[1]))
for i in range(len(sp)):
    print(sp.index(d[i])+1)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

def Buttons(x, y):
  if x > y:
    return 2x+1
  elif x < y:
    return 2y+1
  elif x==y:
    return x+y


Buttons(a,b)

Fixed submission:
a, b = map(int, input().split())
 
def Buttons(x, y):
  if x > y:
    return 2*x-1
  elif x < y:
    return 2*y-1
  else:
    return x+y
 
 
print(Buttons(a,b))

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

def Bottuns(x, y):
  if x > y:
    return 2x+1
  elif x < y:
    return 2y+1
  elif x==y:
    return x+y


Buttons(a,b)

Fixed submission:
a, b = map(int, input().split())
 
def Buttons(x, y):
  if x > y:
    return 2*x-1
  elif x < y:
    return 2*y-1
  else:
    return x+y
 
 
print(Buttons(a,b))
Buggy python submission (verdict: Runtime Error):
n = int(input())
List = []
List.append(int(input()))
List.append(int(input()))
List.append(int(input()))
List.append(int(input()))
List.append(int(input()))

#import math
print(math.ceil(n/min(List))+4)

Fixed submission:
n = int(input())
List = []
List.append(int(input()))
List.append(int(input()))
List.append(int(input()))
List.append(int(input()))
List.append(int(input()))

import math
print(math.ceil(n/min(List))+4)
Buggy python submission (verdict: Runtime Error):
b = input()

if b="A":
  print("T")
elif b="T":
  print("A")
elif b="C":
  print("G")
else:
  print("C")
  

Fixed submission:
b = input()
 
if b =="A":
  print("T")
elif b=="T":
  print("A")
elif b=="C":
  print("G")
else:
  print("C")
Buggy python submission (verdict: Runtime Error):
s = input()

L = []
cnt = 0

for x in s:
    if x == "A" or x == "C" or x == "G" or x == "T":
        cnt += 1
    else:
        L.append(cnt)
        
max(L)

Fixed submission:
s = list(input())

L = []
cnt = 0

for x in s:
    if x == "A" or x == "C" or x == "G" or x == "T":
        cnt += 1
    else:
        L.append(cnt)
        cnt = 0
L.append(cnt)

print(max(L))