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

Fixed submission:
n = int(input())
D = 0
for i in range(1,10):
  for j in range(1,10):
    if j*i == n:
      D = 1
      break
if D == 1:
  print('Yes')
elif D == 0:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [9,8,7,6,5,4,3,2,1]
if 0 < n and n <= 81:
    for i in range(9):
        if n % a[i] == 0:
            if n / a[i] > 9:
                print('No')
            else:
                print('Yes')
                break
else:
    print('No')
Problem p02578 (python)

Fixed submission:
N=int(input())
A = list(map(int, input().split()))
i = 0
sum = 0
while i<N-1:
  if A[i]<=A[i+1]:
    f=0
  else:
    f=A[i]-A[i+1]
  A[i+1]+=f
  sum+=f
  i+=1
print(sum)

Buggy submission (verdict: Runtime Error):
N=int(input())
A = list(map(int, input().split()))
i = 0
sum = 0
while i<N:
  if A[i]<=A[i+1]:
    f=0
  else:
    f=A[i]-A[i+1]
  A[i+1]+=f
  sum+=f
  i+=1
print(sum)
Problem p02577 (python)

Fixed submission:
s = input()
sum = 0
for i in s:
  sum+=int(i)
if sum%9==0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s == 0
for i in n:
  s += i
if s % 9 == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = 0
for i in n:
  s += n[i]
if s % 9 == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s == 0
for i in n:
  s += n[i]
if s % 9 == 0:
  print("Yes")
else:
  print("No")
Problem p02699 (python)

Fixed submission:
s, w = map(int, input().split())
 
if s <= w:
  print('unsafe')
else:
  print('safe')

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
if W >= S:
  print("unsafe")
else:
  print("safe")

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
if S > W:
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
if S > W:
  print("safe")
else:
  print("unsafe")
Problem p02711 (python)

Fixed submission:
N = input()
l = len(N)
for i in range(l):
  if N[i] =="7":
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
l = len(N)
for i in range(l):
  if N[i] ==7:
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
l = len(N)
for i in range(l):
  if N.index(i) ==7:
    print("Yes")
    exit()
print("No")
Problem p02753 (python)

Fixed submission:
s = list(input())
if s[0] == s[1] == s[2]:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
S = list(input())
if S[0］== S[1] == S[2]:
     print("No")
else:
     print("Yes")
Problem p02577 (python)

Fixed submission:
N = input()

sum = 0
if int(N) != 0:
    data_size = len(N)
    for data_size in range(data_size):
        sum += int(N[data_size])

else:
    sum = 0

if sum%9 == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math
N = input()

sum = 0
if int(N) != 0:
    data_size = int(math.log10(int(N)) + 1)
    for data_size in range(data_size):
        sum += int(N[data_size])

else:
    sum = 0
    
if sum%9 == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math
N = input()

sum = 0
data_size = int(math.log10(int(N)) + 1)
for data_size in range(data_size):
    sum += int(N[data_size])

if sum%9 == 0:
    print('Yes')
else:
    print('No')
Problem p02594 (python)

Fixed submission:
x = input()
if( int(x) >= 30):
  print("Yes")
else :
  print("No")

Buggy submission (verdict: Runtime Error):
import sys

x = input()
if( x >= 30):
  print("Yes")
else :
  print("No")

Buggy submission (verdict: Runtime Error):
x = input()
if( x >= 30):
  print("Yes")
else :
  print("No")
Problem p02595 (python)

Fixed submission:
import sys
import math

line = input()
N = line.split(' ')[0]
D = line.split(' ')[1]

count = 0

for i in range(int(N)):
  inputs = input()
  X = int(inputs.split(' ')[0])
  Y = int(inputs.split(' ')[1])
  if(math.sqrt(pow(X,2) + pow(Y,2)) <= int(D) ):
    count = count + 1

print(count)

Buggy submission (verdict: Runtime Error):
import sys
import math

line = input()
N = line.split(' ')[0]
D = line.split(' ')[1]

count = 0

for i in range(1,int(D)):
  inputs = input()
  X = int(inputs.split(' ')[0])
  Y = int(inputs.split(' ')[1])
  if(math.sqrt(pow(X,2) + pow(Y,2)) <= int(D) ):
    count = count + 1

print(count)
Problem p03127 (python)

Fixed submission:
# Hariom_Pandey
# 11.11.2019
from functools import reduce
from fractions import gcd
import sys
n = int(sys.stdin.readline())
H = list(map(int,sys.stdin.readline().split()))
print(reduce(gcd,H))

Buggy submission (verdict: Runtime Error):
# Hariom_Pandey
# 11.11.2019
from functools import reduce
import math as mt
import sys
n = int(sys.stdin.readline())
H = list(map(int,sys.stdin.readline().split()))
print(reduce(mt.gcd,H))

Buggy submission (verdict: Runtime Error):
# Hariom_Pandey
# 11.11.2019
from functools import reduce
import math as mt
n = int(sys.stdin.readline())
H = list(map(int,sys.stdin.readline().split())) 
print(reduce(mt.gcd,H))
Problem p02915 (python)

Fixed submission:
n=int(input())
c=n**3
print(c)

Buggy submission (verdict: Runtime Error):
n=int(inpt())
c=n**3
print(c)
Problem p02598 (python)

Fixed submission:
import heapq
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if k == 0:
    print(a[0])
    exit(0)
mean_a = sum(a) / k
q = []
for aa in a:
    d = max(math.floor(aa / mean_a), 1)
    q.append((-aa/d, d))
    k -= (d-1)
heapq.heapify(q)

for _ in range(k):
    aa, n = heapq.heappop(q)
    heapq.heappush(q, (aa*n/(n+1), n+1))

ans, _ = heapq.heappop(q)
print(math.ceil(-ans))

Buggy submission (verdict: Runtime Error):
import heapq
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
mean_a = sum(a) / k
q = []
for aa in a:
    d = max(math.floor(aa / mean_a), 1)
    q.append((-aa/d, d))
    k -= (d-1)
heapq.heapify(q)

for _ in range(k):
    aa, n = heapq.heappop(q)
    heapq.heappush(q, (aa*n/(n+1), n+1))

ans, _ = heapq.heappop(q)
print(math.ceil(-ans))
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
S = []
tmp = -1
for _ in range(m):
  a = int(input())
  S.append(a-tmp-2)
  tmp = a
S.append(n-tmp-1)

fib = [1 for _ in range(n+1)]
for i in range(n-1):
  fib[i+2] = fib[i] + fib[i+1]

total = 1
for x in S:
  if x == -1:
    print(0)
    exit()
  total *= fib[x]

#print(S)
print(total%1000000007)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
S = []
tmp = int(input())
s = tmp + 1
for _ in range(m-1):
  a = int(input())
  S.append(a-tmp)
  tmp = a
g = n-tmp+1

fib = [1 for _ in range(n+1)]
for i in range(2, n-1):
  fib[i+2] = fib[i] + fib[i+1]
total = fib[s]*fib[g]

fib[1] = 0

for x in S:
  total *= fib[x]
  
print(s, S, g)
print(total%1000000007)
Problem p02707 (python)

Fixed submission:
n = int(input())
hash = [0 for i in range(n)]
a = [int(i) for i in input().split()]
for i in a:
	hash[i-1] += 1
for i in hash:
	print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
hash = [0 for i in range(n)]
a = [int(i) for i in input().split()]
for i in a:
	hash[i-1] += 1
for i in hash:
	print(i

Buggy submission (verdict: Runtime Error):
n = int(input())
hash = [0 for i in range(n))
a = [int(i) for i in input().split()]
for i in a:
	hash[i-1] += 1
for i in hash:
	print(i)
Problem p02777 (python)

Fixed submission:
a = [i for i in input().split()]
nums = [int(i) for i in input().split()]
thr = input()
if(thr == a[0]):
	nums[0] -= 1
else:
	nums[1] -= 1
print(nums[0],nums[1])

Buggy submission (verdict: Runtime Error):
a = [i in input().split()]
nums = [int(i) in input().split()]
thr = input()
if(thr == a[0]):
	nums[0] -= 1
else:
	nums[1] -= 1
print(nums[0],nums[1])
Problem p02577 (python)

Fixed submission:
N=input()
l = [int(x) for x in list(N)]
s=sum(l)
if s%9==0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=int(nput())
if n%9==0:
  print("Yes")
else:
  print("No")
Problem p02578 (python)

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

ans=0
cur_max=0

for x in a:
  if cur_max>x:
    ans+=cur_max-x
  cur_max=max(cur_max,x)

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input(),split()))

ans=0
cur_max=0

for x in a:
  if cur_max>x:
    ans+=cur_max-x
  cur_max=max(cur_max,x)

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=map(int,input(),split())

ans=0
cur_max=0

for x in a:
  if cur_max>x:
    ans+=cur_max-x
  cur_max=max(cur_max,x)

print(ans)
Problem p02594 (python)

Fixed submission:
X=int(input(""))
if 30<=X:
   print("Yes")
else:
   print("No")

Buggy submission (verdict: Runtime Error):
X=int(input())
if 30<=X<=40:
   print("Yes")
elif:-40<=X<30
   print("No")

Buggy submission (verdict: Runtime Error):
X=int(input("X:"))
if 30<=X<=40:
	print("Yes")
elif:-40<=X<30
	print("No")

Buggy submission (verdict: Runtime Error):
X=int(input("X="))
if 30<=X<=40:
    print("Yes")
elif:-40<=X<30
    print("No")

Buggy submission (verdict: Runtime Error):
X=int(input("X="))
if 30<=X<=40:
   print("Yes")
elif:-40<=X<30
   print("No")
Problem p02859 (python)

Fixed submission:
from sys import stdin
 
r = int(stdin.readline().rstrip())
 
print(r ** 2)

Buggy submission (verdict: Runtime Error):
from sys import stdin

r = stdin.readline().rstrip()

print(r ** 2)
Problem p02790 (python)

Fixed submission:
a, b = [int(x) for x in input().split()]

As = str(a) * b
Bs = str(b) * a

print(min(As, Bs))

Buggy submission (verdict: Runtime Error):
a, b = [int(x) for x in input().split()]

as = str(a) * b
bs = str(b) * a

print(as if as < b else bs)
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()

if n % 2 != 0:
  print("No")
else:
  half = n // 2
  found = False
  for i in range(0, half):
    if s[i] != s[half + i]:
      found = True
      break
  print("No" if found else "Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

if n % 2 != 0:
  print("No")
else:
  half = n // 2
  found = False
  for i in range(0, half + 1):
    if s[i] != s[half + i]:
      found = True
      break
  print("No" if found else "Yes")
Problem p02623 (python)

Fixed submission:
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
_sum = 0

for i in range(n):
  a.append(a[i] + A[i])
for i in range(m):
  b.append(b[i] + B[i])
  
j = m
counts = [0]
for i in range(n + 1):
  if (a[i] > k):
    break
  while b[j] > k - a[i]:
    j -= 1
  counts.append(i + j)
  
print (max(counts))

Buggy submission (verdict: Runtime Error):
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

count = 0
now_a = 0
now_b = 0
while k > 0 and a[now_a] < k or b[now_b] < k:
  if a[0] > b[0] and now_a > len(a) or now_b < len(b):
    k -= b[now_b]
    now_b += 1
  else:
    k -= a[now_a]
    now_a += 1
  count += 1
  
print (count)
Problem p02773 (python)

Fixed submission:
from collections import Counter
n = int(input())
s = [input() for i in range(n)]

a = Counter(s)

b = a.most_common()[0][1]

s = list(set(s)) #sの重複した要素を消す
s.sort()

for i in s:
    if a[i] == b:
        print(i)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
s = [input() for i in range(n)]

a = Counter(s)
print(type(a))
b = a.most_common()[0][1]

s = list(set(s)) #sの重複した要素を消す


for i in s:
    if s[i] == b:
        print(i)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
s = [input() for i in range(n)]

a = Counter(s)
b = a.most_common()[0][1]

s = list(set(s)) #sの重複した要素を消す

print(a[])

for i in s:
    if a[i] == b:
        print(i)
Problem p02779 (python)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)

if c.most_common()[0][1] == 1:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = list(map(int.input().split()))
c = Counter(a)

if c.most_common()[0][1] == 1:
    print("Yes")
else:
    print("No")
Problem p02707 (python)

Fixed submission:
n=int(input())-1
a=list(map(int,input().split()))
r=[]
for i in range(n):
    r.append(0)
    r[a[i]-1]+=1
for i in range (n):
    print (r[i])
print (0)

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

Fixed submission:
n=int(input())
r=n-1
for i in range(1,int(n**0.5)+1):
    if (n%i==0):
        s=(n//i)+i-2
        if s<r:
            r=s
print(r)

Buggy submission (verdict: Runtime Error):
n=int(input())
r=n-1
for i in range(int(n**0.5)+1):
    if (n%i==0):
        s=(n//i)+i-2
        if s<r:
            r=s
print(r)

Buggy submission (verdict: Runtime Error):
=int(input())
r=n-1
for i in range(2,int(n**0.5)):
    if (n%i==0):
        s=n//i+i-2
        if s<r:
            r=s
print(r)

Buggy submission (verdict: Runtime Error):
n=int(input()) 
r=False
i=2
m=n-1
i=2
while (i<=int(n**0.5)):
	if ((n%i)==0 ):		
        s=i+n//i-2
		if (s<m):
			m=s
	i+=1
print(m)
Problem p02622 (python)

Fixed submission:
S = input()
T = input()
cnt = 0
for i in range(len(S)):
  if S[i] != T[i]:
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
S, T = input().split()
cnt = 0
for i in range(len(S)):
  if S[i] != T[i]:
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
S, T = input().split()
cnt = 0
for i in range(len(S)):
  if S[i] != T[i]:
    cnt += 1
print(i)
Problem p02627 (python)

Fixed submission:
if input().isupper():
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
if input().isUpper():
  print('A')
else:
  print('a')
Problem p02781 (python)

Fixed submission:
import math
def combi(n,r):
    if r > n:return 0
    return math.factorial(n) // (math.factorial(n - r)*(math.factorial(r)))


def solve(i,k,smaller):
    #一番最後の桁まで調べたら終了
    if i == N:
        if k == 0:return 1
        else: return 0

    #途中であっても0以外の数字を使い切ったら終了
    if k == 0:return 1

    #Nより小さいことが確定すれば残りの桁数（N-i）のうち
    #k個所に0以外の数字（9**k通り）を使い，それ以外の桁の数字は0なので
    #C(n-i,n-i-k)=C(n-i,k)個所に0をはめる
    if smaller: return combi(N-i, k)*(9**k)
    else:
        #i桁目が0なら，smallerであるといえない
        if S[i] == '0':return solve(i+1,k,False)
        else:
            zero = solve(i+1, k, True)
            aida = solve(i+1, k-1, True) * (int(S[i])-1)
            icchi = solve(i+1, k-1, False)
            return zero + aida + icchi

#0出ない数字がちょうどＫ個であるようなN以下の整数を探索
S = input()
N = len(S)
K = int(input())
print((solve(0,K,False)))

Buggy submission (verdict: Runtime Error):
import math
def combi(n,r):
    if r > n:return 0
    return math.factorial(n) // (math.factorial(n - r)*(math.factorial(r)))


def solve(i,k,smaller):
    #一番最後の桁まで調べたら終了
    if i == N:
        if k == 0:return 1
        else: 0
    #途中であっても0以外の数字を使い切ったら終了
    if k == 0:return 1

    #Nより小さいことが確定すれば残りの桁数（N-i）のうち
    #k個所に0以外の数字（9**k通り）を使い，それ以外の桁の数字は0なので
    #C(n-i,n-i-k)=C(n-i,k)個所に0をはめる
    if smaller: return combi(N-i, k)*(9**k)
    else:
        #i桁目が0なら，smallerであるといえない
        if S[i] == '0':return solve(i+1,k,False)
        else:
            zero = solve(i+1, k, True)
            aida = solve(i+1, k-1, True) * (int(S[i])-1)
            icchi = solve(i+1, k-1, False)
            return zero + aida + icchi

#0出ない数字がちょうどＫ個であるようなN以下の整数を探索
S = input()
N = len(S)
K = int(input())
print((solve(0,K,False)))
Problem p02860 (python)

Fixed submission:
N = int(input())
S = input()
if len(S)%2 != 0:
    print("No")
    exit()
if S[:len(S)//2] == S[len(S)//2:]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
1
z
Problem p02880 (python)

Fixed submission:
import sys
N = int(input())
for i in range(1,10):
    for j in range(1,10):
        if i*j == N:
            print("Yes")
            sys.exit()
print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
for i in range(1,10):
    for j in range(1,10):
        if i*j == N:
            print("Yes")
            sys.exit()
print("No")
Problem p02881 (python)

Fixed submission:
import sys
import os

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

N = int(input())
listN = make_divisors(N)
mini = 10**12
if len(listN) == 1:
    x = N
    y = 1
else:
    for i in range(len(listN)):
        x = listN[i]
        y = N//x
        mini = min(x+y,mini)
print(x-1+y-1)

Buggy submission (verdict: Runtime Error):
def factorize(n):
    b = 2
    fct = []
    fct.append(1)
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
 
N = int(input())
listN = factorize(N)
x = 0
y = 0
mini = 10**12
if len(listN) == 1:
    x = N
    y = 1
else:
    for i in range(1,len(listN)):
        tmp = list(itertools.combinations(listN,i))
        tmp = list(set(tmp))
        for j in range(len(tmp)):
            x0,y0 = 1,1
            for k in range(len(tmp[j])):
                x0 *= tmp[j][k]
                y0 = N//x0
                if mini > abs(x0+y0):
                    mini = abs(x0+y0)
                    x = x0
                    y = y0
print(x-1+y-1)

Buggy submission (verdict: Runtime Error):
import sys
import os
import math

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

N = int(input())
listN = make_divisors(N)
mini = 10**12
if len(listN) == 1:
    x = N
    y = 1
else:
    for i in range(0,len(listN),2):
        x = listN[i]
        y = listN[i+1]
        mini = min(x+y,mini)
print(x-1+y-1)
Problem p02891 (python)

Fixed submission:
import sys
S = input()
K = int(input())
if len(S) == 1:
    print(K//2)
    sys.exit()
cnt0 = 1
cntL = 1
cnt = 1
ans = 0
i = 0
while i < len(S)-1:
    for j in range(i+1,len(S)):
        if S[i] == S[j]:
            cnt +=1
        else:
            if i == 0:
                cnt0 = cnt
            i = j
            break
    if cnt > 1:
        ans += cnt//2
        cnt = 1
        i = j

for i in range(len(S)-1,0,-1):
    if S[i] == S[i-1]:
        cntL +=1
    else:
        break
ans = K*ans
if S[0] == S[-1] and cnt0%2 != 0 and cntL %2 != 0:
    ans += K-1
if cntL == len(S):
    if (K*cntL)%2==0:
        print((K*cntL)//2)
    else:
        print((K*cntL-1)//2)
    sys.exit()
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import os

S = input()
K = int(input())

cnt = 1
ans = 0
i = 0
while i < len(S)-1:
    for j in range(i+1,len(S)):
        if S[i] == S[j]:
            cnt +=1
        else:
            i = j
            break
    if cnt > 1:
        ans += cnt//2
        cnt = 1
        i = j
ans = K*ans
if S[0] == S[-1]:
    if S[0] != S[1] and S[-2] != S[-1]:
        ans += K-1
print(ans)
Problem p02897 (python)

Fixed submission:
import sys
import os
import math

N  = int(input())
if N%2==0:
    print((N/2)/N)
else:
    print(math.ceil(N/2)/N)

Buggy submission (verdict: Runtime Error):
#解説放送見てからの書き直し
import sys
import os

INF = 10**12
ans = INF
N, M = map(int,input().split())
A = [0 for _ in range(M)]
B = [0 for _ in range(M)]
C = []
for i in range(M):
    a, b = map(int,input().split())
    A[i] = a  #鍵の金額
    B[i] = b  #開けられる宝箱の種類数
    tmp = list((map(int,input().split())))
    s = 0
    for j in range(b):
        t = tmp.pop(0)-1
        s |= 1 << t
    C.append(s)
dp = [INF]*(1<<N) #2^N
dp[0] = 0
for s in range(1<<N):
    for j in range(M):
        t = s | C[j]
        cost = dp[s] + A[j]
        dp[t] = min(dp[t],cost)
ans = dp[-1]
if ans == INF:
    ans = -1
print(ans)
Problem p02912 (python)

Fixed submission:
import sys
import os
import math
import heapq

N, M = map(int,input().split())
A = list(map(int,input().split()))
#大きいものから取り出したいので-1倍してqueueに入れる

Q = []
for a in A:
    heapq.heappush(Q,-a)

for i in range(M):
    first = -heapq.heappop(Q)
    first = first//2
    heapq.heappush(Q,-first)

print(-sum(Q))

Buggy submission (verdict: Runtime Error):
import math
import sys

N, M = map(int,input().split())
A = list(map(int,input().split()))
if N == 1:
    while A[0] > 0:
        A[0] = A[0]//2
    print(0)
    sys.exit()

list.sort(A,reverse = True)
a = A[0]
b = A[1]
x = 0
for _ in range(M):
    a = A[0]
    b = A[1]
    x = max(math.ceil(math.log2(a/b)),1)
    if M >= x:
        if x <= 3:
            a = a//(2**x)
            _ += x
        else:
            a = 0
            _ += x
    else:
        if M <= 3:
            a = a//(2**M)
            _ = M
        else:
            a = 0
            _ = M
    A[0] = a
    for i in range(0,N-1):
        if A[i] < A[i+1]:
            A[i] , A[i+1] = A[i+1] , A[i]

print(sum(A))

Buggy submission (verdict: Runtime Error):
import math
import sys

N, M = map(int,input().split())
A = list(map(int,input().split()))
if N == 1:
    while A[0] > 0:
        A[0] = A[0]//2
    print(0)
    sys.exit()

list.sort(A,reverse = True)
a = A[0]
b = A[1]
x = 0
for _ in range(M):
    a = A[0]
    b = A[1]
    x = max(math.ceil(math.log2(a/b)),1)
    if M >= x:
        a = a//(2**x)
        _ += x
    else:
        a = a//(2**M)
        _ = M
    A[0] = a
    for i in range(0,N-1):
        if A[i] < A[i+1]:
            A[i] , A[i+1] = A[i+1] , A[i]

print(sum(A))

Buggy submission (verdict: Runtime Error):
import sys

N, M = map(int,input().split())
A = list(map(int,input().split()))
if N == 1:
    while A[0] > 0:
        A[0] = A[0]//2
    print(0)
    sys.exit()

list.sort(A,reverse = True)
for i in range(M):
    while A[0] >= A[1]:
        A[0] = A[0]//2
    for i in range(0,M-1):
        if A[i] < A[i+1]:
            A[i] , A[i+1] = A[i+1] , A[i]

print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(int,input().split()))
if N == 1:
    while A[0] > 0:
        A[0] = A[0]//2
    print(0)
    sys.exit()

list.sort(A,reverse = True)
for i in range(M):
    while A[0] >= A[1]:
        A[0] = A[0]//2
    for i in range(0,M-1):
        if A[i] < A[i+1]:
            A[i] , A[i+1] = A[i+1] , A[i]

print(sum(A))
Problem p02954 (python)

Fixed submission:
def move(s):
    returnR = 0
    returnL = 0
    cntR = s.count("R")
    cntL = s.count("L")
    if cntR%2 == 0:
        returnL += cntR//2
        returnR += cntR//2
    else:
        returnL += cntR//2
        returnR += cntR//2 + 1
        
    if cntL%2 == 0:
        returnR += cntL//2
        returnL += cntL//2
    else:
        returnR += cntL//2 
        returnL += cntL//2 + 1

    for i in range(cntR-1):
        print("0"+" ",end="")
    print(str(returnR)+" ",end="")

    print(str(returnL)+" ",end="")
    for i in range(cntL-1):
        print("0"+" ",end="")

    
s = input()
listS = []

while s.find("LR") > 0:
    listS.append(s[:s.find("LR")+1])
    s=s[s.find("LR")+1:]
listS.append(s)

for s in listS:
    move(s)

Buggy submission (verdict: Runtime Error):
def move(str):
    returnR = 0
    returnL = 0
    cntR = str.count("R")
    cntL = str.count("L")
    if cntR%2 == 0:
        returnL += cntR//2
        returnR += cntR//2
    else:
        returnL += cntR//2
        returnR += cntR//2 + 1
        
    if cntL%2 == 0:
        returnR += cntL//2
        returnL += cntL//2
    else:
        returnR += cntL//2 
        returnL += cntL//2 + 1

    for i in range(cntR-1):
        print(0+" ",end="")
    print(returnR,end="")

    print(returnL,end="")
    for i in range(cntL-1):
        print(0+" ",end="")

    
s = input()
listS = []

while s.find("LR") > 0:
    listS.append(s[:s.find("LR")+1])
    s=s[s.find("LR")+1:]
listS.append(s)

for s in listS:
    move(s)