Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
w=[]
v=[]
for _ in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
V=sum(v)

dp=[[V+1 for _ in range(V+1)] for _ in range(N+1)]
dp[0][0]=0
ans=0

for i in range(N): #i番目の荷物を拾うかどうか
    for j in range(V+1): #価値jを超える重量の最小値
        dp[i+1][j]=min(dp[i][j],dp[i][max(0,j-v[i])]+w[i])
        if dp[i+1][j]<=W:
            ans=max(ans,j)
        
print(ans)

Fixed submission:
N,W=map(int,input().split())
w=[]
v=[]
for _ in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
V=sum(v)

dp=[[10**9 for _ in range(V+1)] for _ in range(N+1)]
dp[0][0]=0
ans=0

for i in range(N): #i番目の荷物を拾うかどうか
    for j in range(V+1): #価値jを超える重量の最小値
        dp[i+1][j]=min(dp[i][j],dp[i][max(0,j-v[i])]+w[i])
        if dp[i+1][j]<=W:
            ans=max(ans,j)
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
v=[]
w=[]
for _ in range(N):
    ww,vv=map(int,input().split())
    v.append(vv)
    w.append(ww)

dp=[[0 for _ in range(W)] for _ in range(N)]

for h in range(W):
    if h+1>=w[0]:
        dp[0][h]=v[0]

for i in range(1,N):
    for j in range(W):
        if j+1>w[i]:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i])
        else:
            dp[i][j]=dp[i-1][j]
print(dp[-1][-1])


Fixed submission:
N,W=map(int,input().split())
w=[]
v=[]
for _ in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
V=sum(v)

dp=[[10**9 for _ in range(V+1)] for _ in range(N+1)]
dp[0][0]=0
ans=0

for i in range(N): #i番目の荷物を拾うかどうか
    for j in range(V+1): #価値jを超える重量の最小値
        dp[i+1][j]=min(dp[i][j],dp[i][max(0,j-v[i])]+w[i])
        if dp[i+1][j]<=W:
            ans=max(ans,j)
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
v=[]
w=[]
for _ in range(N):
    ww,vv=map(int,input().split())
    v.append(vv)
    w.append(ww)
ans=[]

for i in range(2**N):
    bit=bin(i)[2:].zfill(N)
    temp=[0,0]
    for j in range(N):
        temp[0]+=int(bit[j])*v[j]
        temp[1]+=int(bit[j])*w[j]
    if temp[1]>W:
        temp[0]=0
    ans.append(temp[0])
print(max(ans))

Fixed submission:
N,W=map(int,input().split())
w=[]
v=[]
for _ in range(N):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
V=sum(v)

dp=[[10**9 for _ in range(V+1)] for _ in range(N+1)]
dp[0][0]=0
ans=0

for i in range(N): #i番目の荷物を拾うかどうか
    for j in range(V+1): #価値jを超える重量の最小値
        dp[i+1][j]=min(dp[i][j],dp[i][max(0,j-v[i])]+w[i])
        if dp[i+1][j]<=W:
            ans=max(ans,j)
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,P=map(int,input().split())
ans=1
for i in range(2,round(P**(1/N))+1):
    if P%(i**N)==0:
        ans=i
print(ans)

Fixed submission:
N,P=map(int,input().split())
ans=1
pf={}
if N==1:
    print(P)
else:
    M=P
    for p in range(2,round(M**0.5)+1):
        pf[p]=0
        while P%p==0:
            P//=p
            pf[p]+=1
        if P==1:
            break
    for p in pf:
        if pf[p]>=N:
            ans*=p**(pf[p]//N)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,P=map(int,input().split())
ans=1
for i in range(2,round(P**(1/N))+1):
    if P%(i**N)==0:
        ans=i
print(ans)

Fixed submission:
N,P=map(int,input().split())
ans=1
pf={}
if N==1:
    print(P)
else:
    M=P
    for p in range(2,round(M**0.5)+1):
        pf[p]=0
        while P%p==0:
            P//=p
            pf[p]+=1
        if P==1:
            break
    for p in pf:
        if pf[p]>=N:
            ans*=p**(pf[p]//N)
    print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
N,M=map(int,input().split())
S=input()
T=input()

C=N*M//gcd(N,M)
n=C//N
m=C//M

i=0
j=0
ans=C
while i<C and j<C:
    if  i==j:
        if S[i//n]!=T[j//m]:
            ans=-1
        i+=n
        j+=m
    elif i<j:
        i+=n
    else:
        j+=m
print(ans)

Fixed submission:
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

N,M=map(int,input().split())
S=input()
T=input()

C=N*M//gcd(max(N,M),min(N,M))
n=C//N
m=C//M

i=0
j=0
ans=C
while i<C and j<C:
    if  i==j:
        if S[i//n]!=T[j//m]:
            ans=-1
        i+=n
        j+=m
    elif i<j:
        i+=n
    else:
        j+=m
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
L=[list(map(int,input().split())) for _ in range(N)]

for x in range(101):
    for y in range(101):
        cond=True
        H=abs(x-L[0][0])+abs(y-L[0][1])+L[0][2]
        if H<=0:
            cond=False
            continue
        for i in range(1,N):
            if H!=L[i][2]+abs(x-L[i][0])+abs(y-L[i][1]):
                cond=False
                break
        if cond:
            ans=[x,y,H]

print(ans[0],ans[1],ans[2])


Fixed submission:
N=int(input())
L=[]
for h in range(N):
    Cx,Cy,h=map(int,input().split())
    L.append([h,Cx,Cy])
L.sort(reverse=True)

for x in range(101):
    for y in range(101):
        cond=True
        H=L[0][0]+abs(x-L[0][1])+abs(y-L[0][2])
        for i in range(1,N):
            h=L[i][0]+abs(x-L[i][1])+abs(y-L[i][2])
            if L[i][0]>0:
                if h!=H:
                    cond=False
                    break
            else:
                if h<H:
                    cond=False
                    break
        if cond:
            break
    if cond:
        break

print(x,y,H)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())

if N>M:
    print(0)
else:
    ans=M//N
    while True:
        if (M-(N-1)*ans)%ans==0:
            break
        ans-=1
    print(ans)

Fixed submission:
N,M=map(int,input().split())

ans=M//N
while True:
    if (M-(N-1)*ans)%ans==0:
        break
    ans-=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)
from functools import reduce
from operator import mul

def two(a,ans):
    if a%2==0:
        return two(a//2,ans+1)
    else:
        return ans

N=int(input())
A=list(map(int,input().split()))

ans1=0
#ans2=0
p=reduce(mul,A)
ans1=two(p,ans1)
#for i in range(N):
#    ans2=two(A[i],ans2)
print(ans1)

Fixed submission:
from functools import reduce
from operator import mul

def two(a,ans):
    if a%2==0:
        return two(a//2,ans+1)
    else:
        return ans

N=int(input())
A=list(map(int,input().split()))

#ans1=0
ans2=0
#p=reduce(mul,A)
#ans1=two(p,ans1)
for i in range(N):
    ans2=two(A[i],ans2)
print(ans2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)
from functools import reduce
from operator import mul


def two(a,ans):
    if a%2==0:
        return two(a//2,ans+1)
    else:
        return ans

N=int(input())
A=list(map(int,input().split()))

ans1=0
#ans2=0
p=reduce(mul,A)
ans1=two(p,ans1)
#for i in range(N):
#    ans2=two(A[i],ans2)
print(ans1)

Fixed submission:
from functools import reduce
from operator import mul

def two(a,ans):
    if a%2==0:
        return two(a//2,ans+1)
    else:
        return ans

N=int(input())
A=list(map(int,input().split()))

#ans1=0
ans2=0
#p=reduce(mul,A)
#ans1=two(p,ans1)
for i in range(N):
    ans2=two(A[i],ans2)
print(ans2)

Buggy python submission (verdict: Runtime Error):
from functools import reduce
from operator import mul

def two(a,ans):
    if a%2==0:
        return two(a//2,ans+1)
    else:
        return ans

N=int(input())
A=list(map(int,input().split()))

ans1=0
ans2=0
p=reduce(mul,A)
ans1=two(p,ans1)
for i in range(N):
    ans2=two(A[i],ans2)
print(ans2)

Fixed submission:
from functools import reduce
from operator import mul

def two(a,ans):
    if a%2==0:
        return two(a//2,ans+1)
    else:
        return ans

N=int(input())
A=list(map(int,input().split()))

#ans1=0
ans2=0
#p=reduce(mul,A)
#ans1=two(p,ans1)
for i in range(N):
    ans2=two(A[i],ans2)
print(ans2)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
K=int(input())

ch={}
for S in s:
    if S not in ch:
        ch[S]=1

ch=list(ch.keys())

cand=[]
CAND={}
leng=0
for c in ch:
    for i in range(len(s)):
        if s[i]==c:
            for j in range(len(s)-i):
                if s[i:i+j+1] not in CAND:
                    cand.append(s[i:i+j+1])
                    CAND[s[i:i+j+1]]=1
                    leng+=1
    if leng>=K:
        break

cand.sort()
print(cand[K-1])

Fixed submission:
S=list(input())
K=int(input())
N=len(S)

L=[]
for i in range(K):
    for j in range(N-i):
        if S[j:j+i+1] not in L:
            L.append(S[j:j+i+1])

L.sort()
ans=""
for l in L[K-1]:
    ans+=l
print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
SL=list(S)
N=len(S)
M=len(T)

for i in range(N-M+1):
    cond=True
    temp=S[N-M-i:N-i]
    for s in range(M):
        if temp[s]!="?" and temp[s]!=T[s]:
            cond=False
    if cond:
        SL[N-M-i:N-i]=list(T)
        break
if not cond:
    print("UNRESTORABLE")
else:
    for j in range(N):
        if SL[j]=="?":
            SL[j]="a"

    for a in SL:
        print(a,end="")

Fixed submission:
S=input()
T=input()
SL=list(S)
N=len(S)
M=len(T)

if len(S)<len(T):
    print("UNRESTORABLE")
    
else:
    for i in range(N-M+1):
        cond=True
        temp=S[N-M-i:N-i]
        for s in range(M):
            if temp[s]!="?" and temp[s]!=T[s]:
                cond=False
        if cond:
            SL[N-M-i:N-i]=list(T)
            break
    if not cond:
        print("UNRESTORABLE")
    else:
        for j in range(N):
            if SL[j]=="?":
                SL[j]="a"
    
        for a in SL:
            print(a,end="")
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(input() for _ in range(N))
B=list(input() for _ in range(M))
ans="No"
for y in range(N-M+1):
    for x in range(N-M+1):
        if A[y][x]==B[0][0]:
            cond=True
            for i in range(N-M):
                if A[y+i][x:x+M]!=B[i]:
                    cond=False
                    break
            if cond:
                ans="Yes"
                break
    if ans=="Yes":
        break

print(ans)

Fixed submission:
N,M=map(int,input().split())
A=list(input() for _ in range(N))
B=list(input() for _ in range(M))
ans="No"
for y in range(N-M+1):
    for x in range(N-M+1):
        if A[y][x:x+M]==B[0]:
            cond=True
            for i in range(M):
                if A[y+i][x:x+M]!=B[i]:
                    cond=False
                    break
            if cond:
                ans="Yes"
                break
    if ans=="Yes":
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(input() for _ in range(N))
B=list(input() for _ in range(M))
ans="No"
for y in range(N-M+1):
    for x in range(N-M+1):
        if A[y][x]==B[0][0]:
            cond=True
            for i in range(N-M):
                if A[y+i][x:x+M]!=B[i]:
                    cond=False
                    break
            if cond:
                ans="Yes"
print(ans)

Fixed submission:
N,M=map(int,input().split())
A=list(input() for _ in range(N))
B=list(input() for _ in range(M))
ans="No"
for y in range(N-M+1):
    for x in range(N-M+1):
        if A[y][x:x+M]==B[0]:
            cond=True
            for i in range(M):
                if A[y+i][x:x+M]!=B[i]:
                    cond=False
                    break
            if cond:
                ans="Yes"
                break
    if ans=="Yes":
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

for n in range(N):
  print(A.index(n+1)+1,end=" ")

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = [0]*N

for n in range(N):
  B[A[n]-1] = n+1
  
print(*B)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for n in range(N)]

for n in range(N):
  print(max(A[:n]+A[n+1:]))

Fixed submission:
N = int(input())
A = [int(input()) for n in range(N)]
a1 = sorted(A)[-1]
a2 = sorted(A)[-2]

for a in A:
  if a == a1:
    print(a2)
  else:
    print(a1)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
X = [list(map(int,input().split())) for n in range(M)]
L = [0]*N

for m in range(M):
  for g in range(X[m][0],X[m][1]+1):
    L[g-1]+=1
    
print(L.count(M))

Fixed submission:
N,T = map(int,input().split())
X = [list(map(int,input().split())) for n in range(T)]
M = N
m = 0

for a,b in X:
  M = min(M,b)
  m = max(m,a)
  
if M<m:
  print(0)
else:
  print(M-m+1)
Buggy python submission (verdict: Runtime Error):
S = input()
K = input()

if S[0]=="1":
  print(S[1])
  
else:
  print(S[0])

Fixed submission:
S = input()
K = int(input())
one = 0

for s in S:
  if s=="1":
    one+=1
  else:
    ans = s
    break

if K<=one:
  print(1)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split())
S = ["."*(W+2)]+["."+input()+"." for h in range(H)]+["."*(W+2)]

for h in range(1,H+1):
  for w in range(1,W+1):
    if S[h][w]=="#" and S[h-1][w]=="." and S[h+1][w]=="." and S[h][w-1]=="." and S[h][w+1]==".":
      print("No")
      exit()
      
print("Yes")


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

if a<=b:
  print(a)
else:
  print(a-1)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
L = []

for n in range(A,B+1):
  L.append(n)
  
ans = sorted(set(L[:K]+L[-K:]))
  
print(*ans,sep="\n")

Fixed submission:
A,B,K = map(int,input().split())
L = []
M = []

for n in range(A,min(A+K,B+1)):
  L.append(n)
  
for n in range(max(A,B-K),B+1):
  M.append(n)
  
L = sorted(set(L[:K]+M[-K:]))
  
print(*L,sep="\n")
Buggy python submission (verdict: Runtime Error):
N = int(input())
L0 = 2
L1 = 1

for n in range(N-1):
  L = L0+L1
  L0 = L1
  L1 = L
  
print(L)

Fixed submission:
N = int(input())
L0 = 2
L1 = 1

if N==1:
  print(1)

else:
  for n in range(N-1):
    L = L0+L1
    L0 = L1
    L1 = L
  print(L)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n = int(input())
    n += 1
    a = list(map(int, input().split()))
    c = [0] * (n + 1)
    for i in range(n):
        c[i + 1] = c[i] + a[i]
    ans = [0] * n
    for i in range(n):
        ans[i] = c[n] - c[i]
    if n == 1 and a[0] == 0:
        print(-1)
        return
    if n > 1 and a[o] > 0:
        print(-1)
        return
    ans[0] = min(1, ans[0])
    for i in range(1, n):
        ans[i] = min(ans[i], (ans[i-1]-a[i-1]) * 2)
        if ans[i] < a[i]:
            print(-1)
            return

    print(sum(ans))
main()


Fixed submission:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n = int(input())
    n += 1
    a = list(map(int, input().split()))
    c = [0] * (n + 1)
    for i in range(n):
        c[i + 1] = c[i] + a[i]
    ans = [0] * n
    for i in range(n):
        ans[i] = c[n] - c[i]
    if n == 1 and a[0] == 0:
        print(-1)
        return
    if n > 1 and a[0] > 0:
        print(-1)
        return
    ans[0] = min(1, ans[0])
    if ans[0] < a[0]:
        print(-1)
        return
    for i in range(1, n):
        ans[i] = min(ans[i], (ans[i-1]-a[i-1]) * 2)
        if ans[i] < a[i]:
            print(-1)
            return

    print(sum(ans))
main()
Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
print(a * (b-1) // b))

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


Fixed submission:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n, m = map(int, input().split())
    ans = []
    for i in range(1, (m+1)//2+1):
        ans.append([i, m+2-i])

    for i in range(1, (m+1)//2+1):
        if len(ans) == m:
            break
        ans.append([m+1+i, 2*m+2-i])

    for x in ans:
        print(x[0], x[1])

main()

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


Fixed submission:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n, m = map(int, input().split())
    ans = []
    for i in range(1, (m+1)//2+1):
        ans.append([i, m+2-i])

    for i in range(1, (m+1)//2+1):
        if len(ans) == m:
            break
        ans.append([m+1+i, 2*m+2-i])

    for x in ans:
        print(x[0], x[1])

main()

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

Fixed submission:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n, m = map(int, input().split())
    ans = []
    for i in range(1, (m+1)//2+1):
        ans.append([i, m+2-i])

    for i in range(1, (m+1)//2+1):
        if len(ans) == m:
            break
        ans.append([m+1+i, 2*m+2-i])

    for x in ans:
        print(x[0], x[1])

main()
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
if abs(a-b)%2 == 0:
  print(abs(a-b)//2)
else:
  print(min(b-1,n-a,n-b+(b-a-n+b)//2+1,a-1+(b-a-a+1)//2+1)
  

Fixed submission:
n,a,b=map(int,input().split())
if abs(a-b)%2 == 0:
  print(abs(a-b)//2)
else:
  print(min((2*n-a-b)//2+1,(a+b-2)//2+1))

Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
if abs(a-b)%2 == 0:
  print(abs(a-b)//2)
else:
  

Fixed submission:
n,a,b=map(int,input().split())
if abs(a-b)%2 == 0:
  print(abs(a-b)//2)
else:
  print(min((2*n-a-b)//2+1,(a+b-2)//2+1))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[tuple(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  for j in range(i+1,n):
    ans += 

Fixed submission:
n=int(input())
a=[tuple(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  for j in range(i+1,n):
    ans += ((a[i][0] - a[j][0])**2 +(a[i][1] - a[j][1])**2 )**0.5
    
print(ans / n*2)
Buggy python submission (verdict: Runtime Error):
n=input()
print(1 - (n // 2) / 2)from collections import Counter
mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def update(x, y, new_value, dp):
    if 0 <= x < len(dp) and 0 <= y < len(dp):
        dp[x][y] = min(dp[x][y], new_value)

def main():
    n=int(input())
    print(1 - (n // 2) / n)

main()


Fixed submission:
from collections import Counter
mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def update(x, y, new_value, dp):
    if 0 <= x < len(dp) and 0 <= y < len(dp):
        dp[x][y] = min(dp[x][y], new_value)

def main():
    n=int(input())
    print(1 - (n // 2) / n)

main()
Buggy python submission (verdict: Runtime Error):
a=["Sunny","Cloudy","Rainy"]
i=a.index(ioput())
print(a[i-2])

Fixed submission:
a=["Sunny","Cloudy","Rainy"]
i=a.index(input())
print(a[i-2])
Buggy python submission (verdict: Runtime Error):
from collections import Counter
mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n, k = map(int, input().split())
    s = input()
    cnt = 0
    for i in range(n-1):
        if s[i] != s[i+1]:
            cnt += 1
    ans = n - 1 - cnt
    ans += k * 2
    ans = min(ans, n-1)
    print(ans)

main()
c

Fixed submission:
from collections import Counter
mod = 1000000007


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft


def main():
    n, k = map(int, input().split())
    s = input()
    cnt = 0
    for i in range(n-1):
        if s[i] != s[i+1]:
            cnt += 1
    ans = n - 1 - cnt
    while cnt >= 2 and k > 0:
        ans += 2
        cnt -= 2
        k -= 1

    if k > 0 and cnt > 0:
        ans += 1

    print(ans)

main()