Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

b = [a[i] - (i+1) for i in range(n)]

b.sort()

m1 = b[n//2]
s1 = sum([abs(b[i] - m1) for i in range(n)])

m2 = b[n//2 + 1]
s2 = sum([abs(b[i] - (m2)) for i in range(n)]) 

print(min(s1, s2))

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

b = [a[i] - (i+1) for i in range(n)]

b.sort()

m1 = b[n//2]
s1 = sum([abs(b[i] - m1) for i in range(n)])

if n % 2 == 1:
    m1 = b[n//2]
    s1 = sum([abs(b[i] - m1) for i in range(n)])
    print(s1)
else:
    m1 = b[n//2-1]
    m2 = b[n//2]
    if (m1 + m2) % 2 == 0:
        l1 = (m1 + m2) // 2
        s1 = sum([abs(b[i] - l1) for i in range(n)])
        print(s1)
    else:
        l1 = (m1 + m2) // 2
        l2 = l1 + 1
        s1 = sum([abs(b[i] - l1) for i in range(n)])
        s2 = sum([abs(b[i] - l2) for i in range(n)]) 

        print(min(s1, s2))
Buggy python submission (verdict: Runtime Error):
h, w = list(map(int, input().split()))

s = [list(input()) for _ in range(w)]

flag = True

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            sub_flag = False
            if i > 0 and s[i-1][j] == "#":
                sub_flag = True
            if j > 0 and s[i][j-1] == "#":
                sub_flag = True
            if i < h-1 and s[i+1][j] == "#":
                sub_flag = True
            if j < w-1 and s[i][j+1] == "#":
                sub_flag = True
            if sub_flag:
                pass
            else:
                flag = False
                break

if flag:
    print("Yes")
else:
    print("No")

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

s = [list(input()) for _ in range(h)]

flag = True

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            sub_flag = False
            if i > 0 and s[i-1][j] == "#":
                sub_flag = True
            if j > 0 and s[i][j-1] == "#":
                sub_flag = True
            if i < h-1 and s[i+1][j] == "#":
                sub_flag = True
            if j < w-1 and s[i][j+1] == "#":
                sub_flag = True

            if sub_flag:
                pass
            else:
                flag = False
                break

if flag:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

d = [a[0]]
for i in range(n-1):
    d.append(a[i+1] - a[i])

d.append(-a[-1])

for i in range(n):
    s = 0
    for j in range(n+1):
        if j == i:
            s += abs(d[j] + d[j+1])
        elif j == i + 1:
            pass
        else:
            s += abs(d[j])
    print(s)

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

d = [abs(a[0])]
for i in range(n-1):
    d.append(abs(a[i+1] - a[i]))

d.append(abs(a[-1]))

s = sum(d)

for i in range(n):
    if i == 0:
        t = s - d[i] - d[i+1] + abs(a[i+1])
    elif i == n-1:
        t = s - d[i] - d[i+1] + abs(-a[i-1])
    else:
        t = s - d[i] - d[i+1] + abs(a[i+1] - a[i-1])
    print(t)
Buggy python submission (verdict: Runtime Error):
l, x, y, s, d = list(map(int, input().split()))

if d >= s:
    a, b = d-s, l-(d-s)
else:
    a, b = l-(s-d), s-d

if x >= y:
    print(a/(x+y))
else:
    print(min(a/(x+y), b/(y-x)))


Fixed submission:
h, w = list(map(int, input().split()))
A = [input() for i in range(h)]

B = [[0]*w for i in range(h)]

d = [-1, 0, 1]

for i in range(h):
    for j in range(w):
        if A[i][j] == "#":
            B[i][j] = "#"
            for k in d:
                for l in d:
                    if 0 <= i+k < h and 0 <= j+l < w:
                        if B[i+k][j+l] != "#":
                            B[i+k][j+l] += 1


B_str = [map(str, B[i]) for i in range(h)]
for i in range(h):
    print("".join(B_str[i]))
Buggy python submission (verdict: Runtime Error):
n=input()
mk=input().split()
t=0
s=0
ans=0
for k in mk:
  pk=int(k)
  t+=pk
  s+=(pk**2)
px=round(t/n)
ans+=s+n*(px**2)-2*px*t
print(ans)


Fixed submission:
n=int(input())
mk=input().split()
t=0
s=0
ans=0
for k in mk:
  pk=int(k)
  t+=pk
  s+=(pk**2)
px=round(t/n)
ans+=s+n*(px**2)-2*px*t
print(ans)

Buggy python submission (verdict: Runtime Error):
n=input()
mk=input().split()
m=[]
t=0
s=0
for k in mk:
  pk=int(k)
  t+=pk
  s+=(pk**2)
  m.append(pk)
px=round(t/n)
ans=s+n*(px**2)-2*px*t
print(ans)

Fixed submission:
n=int(input())
mk=input().split()
t=0
s=0
ans=0
for k in mk:
  pk=int(k)
  t+=pk
  s+=(pk**2)
px=round(t/n)
ans+=s+n*(px**2)-2*px*t
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
ref=[]
out=0
for C in range(1,N):
    out+=len(make_divisors(N-C))
print(out)

Fixed submission:

N = int(input())

cnt=0
for A in range(1,N):
    for B in range(1,N):
        if A*B >= N:
            break
        else:
            cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):

[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))
# print('A:',A)
hyoten=[0]*N

dammy=1
for i in range(K):
    dammy*=A[i]
# print('dammy0:', dammy)
hyoten[K-1] = dammy

for i in range(K,N):
    dammy/=A[i-K]
    dammy*=A[i]
    hyoten[i]=dammy

# print('hyoten:',hyoten)

for i in range(K,N):
    if hyoten[i-1]<hyoten[i]:
        print('Yes')
    else:
        print('No')


Fixed submission:

[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))
# print('A:',A)

for i in range(K,N):
    if A[i-K]<A[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
# print('A:',A)

from itertools import product
a=[0,1]  #0:buy  1:sell
Ls = list(product(a, repeat=N-1))
# print('Ls:',Ls)

out=0
for L in Ls:
    # print('L:',L)
    money=1000
    kabu=0
    for i in range(N-1):
        if L[i]==0:
            kabu+=money // A[i]
            money=money % A[i]

        else:
            money+=kabu*A[i]
            kabu=0
        # print('money,kabu:',money,kabu)
    money+=kabu*A[N-1]  #last
    out=max(out,money)

print(out)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
# print('A:',A)
money=1000
kabu=0

for i in range(N-1):
    if A[i] < A[i+1]:
        kabu+=money // A[i]
        money=money % A[i]
    elif A[i] > A[i+1]:
        money+=kabu*A[i]
        kabu=0
money+=kabu*A[N-1]  #last

print(money)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
# print('A:',A)

from itertools import product
a=[0,1]  #0:buy  1:sell
Ls = list(product(a, repeat=N))
# print('Ls:',Ls)
out=0
for L in Ls:
    # print('L:',L)
    money=1000
    kabu=0
    for i in range(N):
        if L[i]==0:
            kabu+=money // A[i]
            money=money % A[i]

        else:
            money+=kabu*A[i]
            kabu=0
        # print('money,kabu:',money,kabu)
    out=max(out,money)

print(out)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
# print('A:',A)
money=1000
kabu=0

for i in range(N-1):
    if A[i] < A[i+1]:
        kabu+=money // A[i]
        money=money % A[i]
    elif A[i] > A[i+1]:
        money+=kabu*A[i]
        kabu=0
money+=kabu*A[N-1]  #last

print(money)
Buggy python submission (verdict: Runtime Error):
from itertools import product

N = int(input())

cnt = [0]*1000000000

for x in range(1,N):
    flag=0
    for y in range(1,N):
        if flag==1:
            break
        elif x*y>=10**4:
            break
        for z in range(1,N):
            if x*z>=10**4 or y*z>=10**4:
                flag=1
                break
            else:
                cnt[x**2 + y**2 + z**2 + x*y + y*z + z*x -1] += 1



for i in range(N):
    print(cnt[i])

Fixed submission:
from itertools import product

N = int(input())

cnt = [0]*100000000

for x in range(1,N):
    flag=0
    for y in range(1,N):
        if x*y>=10**4:
            flag=1
            break
        for z in range(1,N):
            if flag==1:
                break
            elif x*z>=10**4 or y*z>=10**4:
                # flag=1
                break
            else:
                if x**2 + y**2 + z**2 + x*y + y*z + z*x <=10**4+1:
                    cnt[x**2 + y**2 + z**2 + x*y + y*z + z*x -1] += 1



for i in range(N):
    print(cnt[i])

Buggy python submission (verdict: Runtime Error):
from itertools import product

N = int(input())

cnt = [0]*10000000

for x in range(1,N):
    flag=0
    for y in range(1,N):
        if flag==1:
            break
        elif x*y>=10**4:
            break
        for z in range(1,N):
            if x*z>=10**4 or y*z>=10**4:
                flag=1
                break
            else:
                cnt[x**2 + y**2 + z**2 + x*y + y*z + z*x -1] += 1



for i in range(N):
    print(cnt[i])


Fixed submission:
from itertools import product

N = int(input())

cnt = [0]*100000000

for x in range(1,N):
    flag=0
    for y in range(1,N):
        if x*y>=10**4:
            flag=1
            break
        for z in range(1,N):
            if flag==1:
                break
            elif x*z>=10**4 or y*z>=10**4:
                # flag=1
                break
            else:
                if x**2 + y**2 + z**2 + x*y + y*z + z*x <=10**4+1:
                    cnt[x**2 + y**2 + z**2 + x*y + y*z + z*x -1] += 1



for i in range(N):
    print(cnt[i])
Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


N = int(input())

out=0
for i in range(1,N+1):
    out+=i * len(make_divisors(i))
print(out)

Fixed submission:
N = int(input())

yaku = [0]*(N+1)
for i in range(1,N+1):
    yaku[i] = ((N//i)/2) * (2*i + ((N//i)-1)*i)

print(int(sum(yaku)))

Buggy python submission (verdict: Runtime Error):

import sympy
N = int(input())

out=0
for i in range(1,N+1):
    out+=i * len(sympy.divisors(i))
print(out)

Fixed submission:
N = int(input())

yaku = [0]*(N+1)
for i in range(1,N+1):
    yaku[i] = ((N//i)/2) * (2*i + ((N//i)-1)*i)

print(int(sum(yaku)))
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())
A = []
B = []
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    A.append(in1)
    B.append(in2)
AA = sorted(A)
BB = sorted(B)

if N%2==1:
    low = AA[N//2  ]
    high = BB[N//2  ]
    print(high - low +1)

else:
    low = (AA[N//2-1] + AA[N//2]) / 2
    high = (BB[N//2-1] + BB[N//2]) / 2
    #print(low,high)
    count=0
    while True:
        low +=  0.5
        count+=1
        if low==high:
            break
    #low = math.floor(low)
    #high = math.ceil(high)
    print(count+1)

Fixed submission:
import math

N = int(input())
A = []
B = []
for i in range(N):
    in1, in2 = list(map(int,input().split()))
    A.append(in1)
    B.append(in2)
AA = sorted(A)
BB = sorted(B)

if N%2==1:
    low = AA[N//2]
    high = BB[N//2]
    print(high - low +1)

else:
    low = AA[N//2-1] + AA[N//2]
    high = BB[N//2-1] + BB[N//2]
    #print(low,high)
    print(high - low +1)
Buggy python submission (verdict: Runtime Error):

import math
[A,B,H,M] = list(map(int,input().split()))

tm = 60*H + M
#print('time', tm)
#進んだ距離
Dji = 0.5 * tm
Dhu = 6 * tm
#print('1', Dji,Dhu)
'''
#げんじつ感のある角度に
Dji2 = Dji % 180
Dhu2 = Dhu % 180
#print('2', Dji2,Dhu2)

#間の角度
kaku = abs(Dji2 - Dhu2)
#print('kakudo',kaku)
'''
Dji2 = Dji % 360
Dhu2 = Dhu % 360
#print('2', Dji2,Dhu2)

if abs(Dji2 - Dhu2) <=180:
    kaku = abs(Dji2 - Dhu2)
else:
    kaku = (360 - abs(Dji2 - Dhu2)) % 180


#余弦定理
if kaku ==0:
    out = Dhu - Dji

if kaku == 180:
    out == Dhu + Dji
else:
    out = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(kaku)))


print(out)

Fixed submission:

import math
[A,B,H,M] = list(map(int,input().split()))

tm = 60*H + M
#print('time', tm)
#進んだ距離
Dji = 0.5 * tm
Dhu = 6 * tm
#print('1', Dji,Dhu)
'''
#げんじつ感のある角度に
Dji2 = Dji % 180
Dhu2 = Dhu % 180
#print('2', Dji2,Dhu2)

#間の角度
kaku = abs(Dji2 - Dhu2)
#print('kakudo',kaku)
'''
Dji2 = Dji % 360
Dhu2 = Dhu % 360
#print('2', Dji2,Dhu2)

if abs(Dji2 - Dhu2) <=180:
    kaku = abs(Dji2 - Dhu2)
else:
    kaku = 360 - abs(Dji2 - Dhu2)


#余弦定理
if kaku ==0:
    out = B - A

if kaku == 180:
    out = B + A
else:
    out = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(kaku)))


print(out)

Buggy python submission (verdict: Runtime Error):

import math
[A,B,H,M] = list(map(int,input().split()))

tm = 60*H + M
#print('time', tm)
#進んだ距離
Dji = 0.5 * tm
Dhu = 6 * tm
#print('1', Dji,Dhu)
'''
#げんじつ感のある角度に
Dji2 = Dji % 180
Dhu2 = Dhu % 180
#print('2', Dji2,Dhu2)

#間の角度
kaku = abs(Dji2 - Dhu2)
#print('kakudo',kaku)
'''
Dji2 = Dji % 360
Dhu2 = Dhu % 360
#print('2', Dji2,Dhu2)

if abs(Dji2 - Dhu2) <=180:
    kaku = abs(Dji2 - Dhu2)
else:
    kaku = 360 - abs(Dji2 - Dhu2)


#余弦定理
if kaku ==0:
    out = Dhu - Dji

if kaku == 180:
    out == Dhu + Dji
else:
    out = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(kaku)))


print(out)

Fixed submission:

import math
[A,B,H,M] = list(map(int,input().split()))

tm = 60*H + M
#print('time', tm)
#進んだ距離
Dji = 0.5 * tm
Dhu = 6 * tm
#print('1', Dji,Dhu)
'''
#げんじつ感のある角度に
Dji2 = Dji % 180
Dhu2 = Dhu % 180
#print('2', Dji2,Dhu2)

#間の角度
kaku = abs(Dji2 - Dhu2)
#print('kakudo',kaku)
'''
Dji2 = Dji % 360
Dhu2 = Dhu % 360
#print('2', Dji2,Dhu2)

if abs(Dji2 - Dhu2) <=180:
    kaku = abs(Dji2 - Dhu2)
else:
    kaku = 360 - abs(Dji2 - Dhu2)


#余弦定理
if kaku ==0:
    out = B - A

if kaku == 180:
    out = B + A
else:
    out = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(kaku)))


print(out)
Buggy python submission (verdict: Runtime Error):
from collections import deque
[N,M] = list(map(int,input().split()))
AB = []
for i in range(M):
    AB.append(list(map(int,input().split())))

#そこから直で行けるところをまとめる
ikeru = [[] for i in range(N)]
for i in range(M):
    ikeru[AB[i][0]-1].append(AB[i][1]-1)
    ikeru[AB[i][1]-1].append(AB[i][0]-1)
# print('ikeru:',ikeru)



que = deque([])
que.append(0)
# print('que ini:',que)
out=[10**6]*N
out[0]=0

while que:
    p = que.popleft()
    print('p,que:',p,que)

    for next in ikeru[p]:
        print('next,out:',next,out)
        if out[next]==10**6:
            que.append(next)
            out[next]=p+1


# print(out)
print('Yes')
for i in range(1,N):
    print(out[i])


Fixed submission:
from collections import deque
[N,M] = list(map(int,input().split()))
AB = []
for i in range(M):
    AB.append(list(map(int,input().split())))

#そこから直で行けるところをまとめる
ikeru = [[] for i in range(N)]
for i in range(M):
    ikeru[AB[i][0]-1].append(AB[i][1]-1)
    ikeru[AB[i][1]-1].append(AB[i][0]-1)
# print('ikeru:',ikeru)



que = deque([])
que.append(0)
# print('que ini:',que)
out=[10**6]*N
out[0]=0

while que:
    p = que.popleft()
    # print('p,que:',p,que)

    for next in ikeru[p]:
        # print('next,out:',next,out)
        if out[next]==10**6:
            que.append(next)
            out[next]=p+1


# print(out)
print('Yes')
for i in range(1,N):
    print(out[i])
Buggy python submission (verdict: Runtime Error):
[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))

#ループする場合
flag=[0]*N
patt=[]
i=0
while True:
    patt.append(i)
    if flag[i]==1:
        #del patt[-1]
        break
    flag[i]=1
    i=A[i]-1

srt = patt.index(patt[-1])
#print(srt)
end = len(patt)-2
ptrn = patt[srt:end+1]

B = (K-srt) % len(ptrn)
if B==0:
    print(ptrn[0]+1)
else:
    print(ptrn[B+1])
    #print('0000000')

Fixed submission:
[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))
 
#ループする場合
flag=[0]*N
patt=[]
aaaa=0
i=0
while True:
    patt.append(i)
    if flag[i]==1:
        #del patt[-1]
        break
    flag[i]=1
    i=A[i]-1
 
 
srt = patt.index(patt[-1])
#print('srt',srt)
end = len(patt)-2
ptrn = patt[srt:end+1]
 
if K<srt:
    print(patt[K]+1)
else:
    B = (K-srt) % len(ptrn)
    #print('B',B)
 
    print(ptrn[B]+1)
    #print('0000000')
 
    #print('ptrm',ptrn)
    #print(patt)
Buggy python submission (verdict: Runtime Error):
[N,M,Q] = list(map(int,input().split()))

abcd = []
for i in range(Q):
    abcd.append(list(map(int,input().split())))

from itertools import permutations, combinations,combinations_with_replacement,product
AA=range(1,M+1)
CM = list(combinations(AA,N))


wa =0
A=[0]*N
dammy=[]
for i in range(len(CM)):
        A = sorted(CM[i])
        for j in range(Q):
            #print(abcd[2][j])
            if (A[abcd[j][1]-1] - A[abcd[j][0]-1]) == abcd[j][2]:
                wa+=abcd[j][3]
        dammy.append(wa)
        wa =0

print(max(dammy))


Fixed submission:
[N,M,Q] = list(map(int,input().split()))

abcd = []
for i in range(Q):
    abcd.append(list(map(int,input().split())))

from itertools import permutations, combinations,combinations_with_replacement,product
AA=range(1,M+1)
CM = list(combinations_with_replacement(AA,N))
#print(CM)
wa = 0
A = [0]*N
dammy=[]
for i in range(len(CM)):
    A = CM[i]
    for j in range(Q):
        #print(abcd[2][j])
        if (A[abcd[j][1]-1] - A[abcd[j][0]-1]) == abcd[j][2]:
            wa+=abcd[j][3]
    dammy.append(wa)
    wa =0

print(max(dammy))

Buggy python submission (verdict: Runtime Error):
[N,M,Q] = list(map(int,input().split()))

abcd = []
for i in range(Q):
    abcd.append(list(map(int,input().split())))

from itertools import permutations, combinations,combinations_with_replacement,product
AA=range(1,M+1)
CM = list(combinations(AA,N))


wa =0
A=[0]*N
dammy=[]
for i in range(len(CM)):
        A = sorted(CM[i])
        for j in range(Q):
            #print(abcd[2][j])
            if (A[abcd[j][1]-1] - A[abcd[j][0]-1]) == abcd[j][2]:
                wa+=abcd[j][3]
        dammy.append(wa)
        wa =0

print(max(dammy))

Fixed submission:
[N,M,Q] = list(map(int,input().split()))

abcd = []
for i in range(Q):
    abcd.append(list(map(int,input().split())))

from itertools import permutations, combinations,combinations_with_replacement,product
AA=range(1,M+1)
CM = list(combinations_with_replacement(AA,N))
#print(CM)
wa = 0
A = [0]*N
dammy=[]
for i in range(len(CM)):
    A = CM[i]
    for j in range(Q):
        #print(abcd[2][j])
        if (A[abcd[j][1]-1] - A[abcd[j][0]-1]) == abcd[j][2]:
            wa+=abcd[j][3]
    dammy.append(wa)
    wa =0

print(max(dammy))
Buggy python submission (verdict: Time Limit Exceeded):
[A,B,N] = list(map(int,input().split()))

x=N
dammy=[]
while x > N//(1.1):
    dammy.append((A*x)//B - A * int(x/B))
    x = x -1
print(max(dammy))


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

W = N//B
dammy=[]
x=N
dammy.append((A*x)//B - A * int(x/B))
x=(B * W)-1
dammy.append((A*x)//B - A * int(x/B))


print(max(dammy))

Buggy python submission (verdict: Time Limit Exceeded):
[A,B,N] = list(map(int,input().split()))

x=N
dammy=[]
while x > N//(1.5):
    dammy.append((A*x)//B - A * int(x/B))
    x = x -1
print(max(dammy))

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

W = N//B
dammy=[]
x=N
dammy.append((A*x)//B - A * int(x/B))
x=(B * W)-1
dammy.append((A*x)//B - A * int(x/B))


print(max(dammy))

Buggy python submission (verdict: Time Limit Exceeded):

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

dammy=[]
for x in range(N+1):
    dammy.append((A*x)//B - A * int(x/B))

print(max(dammy))


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

W = N//B
dammy=[]
x=N
dammy.append((A*x)//B - A * int(x/B))
x=(B * W)-1
dammy.append((A*x)//B - A * int(x/B))


print(max(dammy))
Buggy python submission (verdict: Runtime Error):
H = int(input())

i=1
while True:
    A=2**i
    if H==A:
        jo=i
        break
        
    elif H<A:
        jo=i-1
        break
    i+=1

for j in range(0,jo+1):
    result=result+2**j
print(result)

Fixed submission:
H = int(input())

#Hは２のjo乗より小さい
i=1
while True:
    A=2**i
    if H==A:
        jo=i
        break
        
    elif H<A:
        jo=i-1
        break
    i+=1

result=0
for j in range(0,jo+1):
    result=result+2**j
print(result)

Buggy python submission (verdict: Runtime Error):
H = int(input())

i=1
while True:
    A=2**i
    if H==A:
        jo=i
        break
        
    elif H<A:
        jo=i-1
        break
    i+=1

for j in range(0,jo+1):
    result=result+2**j
print(result)

Fixed submission:
H = int(input())

#Hは２のjo乗より小さい
i=1
while True:
    A=2**i
    if H==A:
        jo=i
        break
        
    elif H<A:
        jo=i-1
        break
    i+=1

result=0
for j in range(0,jo+1):
    result=result+2**j
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))

count=0
for i in range(N):
    A=P[i]
    if min(P[0:i+1])==A:
        count += 1
    else:
        continue
print(count)

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

count=0
mi=P[0]  #minimum

for i in range(N):
    A=P[i]
    if A<=mi:
        mi=A
        count+=1
    else:
        continue

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
[A,B,K] = list(map(int,input().split()))
for i in range(0,K):
    if A>=1:
        A-=1
    else:
        if B>=1:
            B-=1
        else:
            continue
print(A,B)

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

if A<=K:
    K = K-A
    A = 0
    if B>=K:
        B=B-K
    else:
        B=0
    
else:
    A=A-K

print(A,B)
Buggy python submission (verdict: Runtime Error):
[X,Y] = list(map(int,input().split()))

n = (-4*X+5*Y)//3)
m = (2*X-Y)//3)

if (X+Y)%3 !=0:
    print(0)

elif n<0 or m<0:
    print(0)

#コンビネーションを何回も計算する問題で使える関数
MAXN = (10**6)+10
MOD = 10**9 + 7
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod


print(nCr(n+m,n,10**9 + 7))


Fixed submission:

[X,Y] = list(map(int,input().split()))

n = (-1*X+2*Y)//3
m = (2*X-Y)//3

if (X+Y)%3 !=0:
    print(0)

elif n<0 or m<0:
    print(0)

else:
    MAXN = (10**6)+10
    MOD = 10**9 + 7
    f = [1]
    for i in range(MAXN):
        f.append(f[-1] * (i+1) % MOD)
    def nCr(n, r, mod=MOD):
        return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod


    print(nCr(n+m,n,10**9 + 7))
Buggy python submission (verdict: Runtime Error):
S =  list(input())
K = int(input())
#print(S)
N=len(S)

#if K==1:
kosuu=[]
cnt=1
for i in range(N-1):
    if S[i]==S[i+1]:
        cnt+=1
        if i==N-2:
            kosuu.append(cnt)
    elif S[i]!=S[i+1]:
        kosuu.append(cnt)
        cnt=1
#print('kosuu', kosuu)
dammy=0
for i in range(len(kosuu)):
    dammy+=kosuu[i]//2

#else:
if K==1:
    out=dammy

elif S[0]!=S[-1]:
    out = dammy * K

else:
    #kotei=kosuu[1:-1]  #少ないとき
    kotei = dammy - kosuu[0]//2 - kosuu[-1]//2
    aida = (kosuu[0] + kosuu[-1]) // 2
    #print('aida',aida)
    out = kosuu[0]//2 + (kotei*K) + aida*(K-1) + kosuu[-1]//2

print(out)

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

#if K==1:
kosuu=[]
cnt=1
for i in range(N-1):
    if S[i]==S[i+1]:
        cnt+=1
        if i==N-2:
            kosuu.append(cnt)
    elif S[i]!=S[i+1]:
        kosuu.append(cnt)
        cnt=1
#print('kosuu', kosuu)
dammy=0
for i in range(len(kosuu)):
    dammy+=kosuu[i]//2

#else:
if K==1:
    out=dammy

elif S[0]!=S[-1]:
    out = dammy * K

elif len(S)==1:
    out=K//2

elif len(kosuu)==1:
    out=(kosuu[0]*K)//2

else:
    #kotei=kosuu[1:-1]  #少ないとき
    kotei = dammy - kosuu[0]//2 - kosuu[-1]//2
    aida = (kosuu[0] + kosuu[-1]) // 2
    #print('aida',aida)
    out = kosuu[0]//2 + (kotei*K) + aida*(K-1) + kosuu[-1]//2

print(out)