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

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

a = [1]
p = [1]

for i in range(n):
    a.append(a[i]*2+3) 
    p.append(p[i]*2+1)

def patty_count(num, x_bot):
    if num == 0:
        return 0 if x_bot<=0 else 1
    elif x_bot<=1+a[num-1]:
        return patty_count(num-1, x_bot-1)
    else:
        return p[num-1] + 1 + patty_count(num-1, x_bot-2-a[num-1])
 
print(patty_count(n, x))
# print()

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

b_str = "1"
for i in range(n):
    b_str = "0" + b_str + "1" + b_str + "0"

print(b_str[:x].count("1"))
Problem p02793 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
P = 10 ** 9 + 7
p = 10 ** 9 + 7
mo = P
inv_t = [0]+[1]
for i in range(2,1000009):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

#print("俺のソフト")

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

M = a[0]
for i in range(1, n):
    M = M * a[i] // gcd(M, a[i])

M = M%p
ans = 0
for i in range(n):
    ans += M*inv_t[a[i]]
    ans = ans %p

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = sorted(list(set(a)))
P = 10 ** 9 + 7
p = P

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

M = b[0]
for i in range(1, n):
    M = M * b[i] // gcd(b[i], M)

ans = 0
for i in range(n):
    ans += M //a[i]
    ans = ans %p

print(ans)
Problem p03017 (python)

Fixed submission:
n,a,b,c,d = map(int,input().split())
s = input()

def judge(start,goal):
    for i in range(start,goal-1):
        if s[i] == "#" and s[i+1] == "#":
            return 0
    return 1

def full_judge (start,obst,obfin,goal):
    if s[obst-2] == "." and s[obst] == "." :
        return 1
    for i in range(obst-1,obfin-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return 1
    return 0


if c<b:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
elif c<d:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
else:
    if judge(b,d) and full_judge(a,b,d,c) and judge(a,c):
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d = map(int,input().split())
s = input()

def judge(start,goal):
    for i in range(start,goal-1):
        if s[i] == "#" and s[i+1] == "#":
            return 0
    return 1

def full_judge (start,obst,obfin,goal):
    if s[obst-2] = "." and s[obst] == "." :
        return 1
    for i in range(start-1,goal-2):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return 1
    return 0


if c<b:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
elif c<d:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
else:
    if judge(b,d) and full_judge(a,b,d,c) and judge(a,c):
        print("Yes")
    else:
        print("No")
Problem p03286 (python)

Fixed submission:
n = int(input())

a = []
s = 0
while (-2)**s<10000000000:
    a.append((-2)**s)
    s += 1


def judge(n):
    sum = 0
    count = 0
    dig = 0
    if n >0:
        for num in a:
            count += 1
            if num >0:
                sum += num
            if sum >= n:
                dig = count
                break
    else:
        for num in a:
            count += 1
            if num <0:
                sum += num
            if sum <= n:
                dig = count
                break
            
    return dig
    
ans = ["0" for i in range(judge(n))]


while n!=0:
    ans[judge(n)-1] = "1"
    n -= a[judge(n)-1]

    
answer = ""
for i in range(len(ans)-1,-1,-1):
    answer += ans[i]
    
print(answer)

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

a = []
s = 0
while (-2)**s<1000000000:
    a.append((-2)**s)
    s += 1


def judge(n):
    sum = 0
    count = 0
    dig = 0
    if n >0:
        for num in a:
            count += 1
            if num >0:
                sum += num
            if sum >= n:
                dig = count
                break
    else:
        for num in a:
            count += 1
            if num <0:
                sum += num
            if sum <= n:
                dig = count
                break
            
    return dig
    
ans = ["0" for i in range(judge(n))]

while n!=0:
    ans[judge(n)-1] = "1"
    n -= a[judge(n)-1]

    
answer = ""
for i in range(len(ans)-1,-1,-1):
    answer += ans[i]
    
print(answer)
Problem p02793 (python)

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


def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def lcm(a,b):
    return a*b//gcd(a,b)

L = 1

D = 1000000007
for i in range(N):
    L = lcm(L,A[i]) 
L = L % D

res = 0
for i in range(N):
    res = (res + L * pow(A[i],D-2,D)) % D  
print(int(res))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))


def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def lcm(a,b):
    return a*b/gcd(a,b)

L = 1

D = 1000000007
for i in range(N):
    L = lcm(L,A[i]) 
L = L % D

res = 0
for i in range(N):
    res = (res + L * pow(A[i],D-2,D)) % D  
print(int(res))
Problem p02862 (python)

Fixed submission:
import math

I=list(map(int,input().split()))
X=(2*I[1]-I[0])//3
Y=(2*I[0]-I[1])//3
n=X+Y
r=X

if (X<0 or Y<0 or (I[0]+I[1])%3!=0):
    print(0)
    exit()

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

print(cmb(n, r, p))

Buggy submission (verdict: Runtime Error):
import math

I=list(map(int,input().split()))
X=(2*I[1]-I[0])//3
Y=(2*I[0]-I[1])//3
n=X+Y
r=X

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

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

print(cmb(n, r, p))
Problem p02879 (python)

Fixed submission:
a, b = map(int, input().split())
if a<=9 and b<=9:
	print(a*b)
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
bool1=False
#print(a,"to",b) a=21 b=1 i=3 j=7 out
if 1<=a and a<=20 and 1<=b and b<=20:
	for i+1 in range(10):
		for j+1 in range(10):
			#print(i)
			if i*j == a*b:
				#print("a")
				bool1=True
				#print(bool1)
				break
			else:
				#print("j={0}".format(j))
				pass
		if bool1==True:
			break
#print(bool1)
if bool1==True:
	print(a*b)
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
bool1=False
#print(a,"to",b) a=21 b=1 i=3 j=7 out
if 1<=a and a<=20 and 1<=b and b<=20
for i in range(10):
	for j in range(10):
		#print(i)
		if i*j == a*b:
			#print("a")
			bool1=True
			#print(bool1)
			break
		else:
			#print("j={0}".format(j))
			pass
	if bool1==True:
		break
#print(bool1)
if bool1==True:
	print(a*b)
else:
	print(-1)
Problem p03011 (python)

Fixed submission:
p,q,r=list(map(int,(input().split())))
pq=p+q
qr=q+r
rp=r+p
print(min([pq,qr,rp]))

Buggy submission (verdict: Runtime Error):
p,q,r=list(map(int,(input().split())))
pq=p+q
qr=q+r
rp=r+p
print(min([pq,qr,rp])
Problem p03018 (python)

Fixed submission:
s=list(input())

i=0
j=0
ans=0
z=[]
while i!=len(s)-1:
    try:
        if s[i]=="B" and s[i+1]=="C":
            z.append(1)
            i=i+2

        else:
            if s[i]=="A":
                z.append(2)
                i=i+1

            else:
                z.append(0)
                i=i+1

    except:
      break

ans=0
i=0
r1=0


#print(z)
#ｚ＝判定数列

while i!=len(z):
    if z[i]==2:#"A"
         r1=r1+1

    elif z[i]==1:#"BC"
        ans=ans+r1

    else:#"gomi"
        r1 = 0


    i=i+1
print(ans)

Buggy submission (verdict: Runtime Error):
s=list(input())

i=0
j=0
ans=0
while i!=len(s)-2:
   if s[i]=="A":

       if s[i+1]=="B":

           if s[i+2]=="C":

               s[i]="B"
               s[i+1]="C"
               s[i+2]="A"
               ans=ans+1
               if i>1:
                   i=i-2
   i=i+1
print(ans)
Problem p02831 (python)

Fixed submission:
from fractions import gcd

a, b= list(map(int, input().strip().split(' ')))

print(int(a*b/gcd(a,b)))

Buggy submission (verdict: Runtime Error):
import math

a, b= list(map(int, input().strip().split(' ')))

print(int(a*b/math.gcd(a,b)))

Buggy submission (verdict: Runtime Error):
import math

a, b= list(map(int, input().strip().split(' ')))

print(int(a*b/math.gcd(a,b)))
Problem p02819 (python)

Fixed submission:
s = int(input())
if s <= 2:
  print(2)
  exit()
elif s <= 3:
  print(3)
  exit()
elif s <= 5:
  print(5)
  exit()

while True:
  for i in range(2,s // 2):
    if s % i == 0:
      break
  if i == s //2 -1:
    print(s)
    exit()
  s += 1

"""
prime_data = [2,3,5]

for i in range(3,10**5):
  tmp = int(i//2)
  for j in range(2,tmp):
    if i % j == 0:
      break
    if j == tmp-1:
      prime_data.append(i)
print(prime_data)
"""

Buggy submission (verdict: Runtime Error):
s = int(input())
if s <= 2:
  print(2)
elif s <= 3:
  print(3)
elif s <= 5:
  print(5)

while True:
  for i in range(2,s // 2):
    if s % i == 0:
      break
  if i == s //2 -1:
    print(s)
    exit()
  s += 1

"""
prime_data = [2,3,5]

for i in range(3,10**5):
  tmp = int(i//2)
  for j in range(2,tmp):
    if i % j == 0:
      break
    if j == tmp-1:
      prime_data.append(i)
print(prime_data)
"""
Problem p03137 (python)

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

data = [int(s) for s in input().split()]
data.sort()
l = []
if n >= m:
    print(0)
else:
    for i in range(m-1):
        l.append(data[i+1]-data[i])
    l.sort(reverse = True)

    x = 0
    for i in range(n-1):
        x += l[i]
    print(data[m-1] - data[0] - x)

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

data = [int(s) for s in input().split()]
data.sort()
l = []
for i in range(m-1):
    l.append(data[i+1]-data[i])
l.sort(reverse = True)

x = 0
for i in range(n-1):
    x += l[i]
print(data[m-1] - data[0] - x)
Problem p03012 (python)

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

S = sum(W)
l = 0
r = S

rrr = []
for i in range(N):
    rrr.append(r - l)
    l = sum(W[:i+1])
    r = S - l
print(min(map(abs, (rrr))))

Buggy submission (verdict: Runtime Error):
N=int(input())
W=list(map(int,input().split())
s = sum(W)
s2 = s//2

a=[0]
k=[]
sss = 0
for w in W:
    sss += w
    a.append(sss)
    k.append(a[-1] - a[-2])
print(min(k))
Problem p03041 (python)

Fixed submission:
N, K =map(int, input().split())
S = input()
S=list(S)
S[K-1] = S[K-1].lower()
print("".join(S))

Buggy submission (verdict: Runtime Error):
N, K =map(int, input().split())
S = input()
S=list(S)
S[K] = S[K].lower()
print("".join(S))
Problem p02831 (python)

Fixed submission:
'''input
123 456
'''
# A coding delight
from sys import stdin
from collections import defaultdict

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

# main starts
a, b = list(map(int, stdin.readline().split()))

print((a * b) // (gcd(a, b)))

Buggy submission (verdict: Runtime Error):
'''input
123 456
'''
# A coding delight
from sys import stdin
from collections import defaultdict
from math import gcd

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

# main starts
print(gcd(12, 2))
a, b = list(map(int, stdin.readline().split()))

print((a * b) // (gcd(a, b)))

Buggy submission (verdict: Runtime Error):
'''input
123 456
'''
# A coding delight
from sys import stdin
from collections import defaultdict
from math import gcd


# main starts
a, b = list(map(int, stdin.readline().split()))

print((a * b) // (gcd(a, b)))

Buggy submission (verdict: Runtime Error):
'''input
2
ip cc
'''
# A coding delight
from sys import stdin
from collections import defaultdict
from math import gcd


# main starts
a, b = list(map(int, stdin.readline().split()))

print((a * b) / (gcd(a, b)))
Problem p02831 (python)

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

print(int(a * b / fractions.gcd(a, b)))

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

print(int(a * b / math.gcd(a, b)))
Problem p02990 (python)

Fixed submission:
from scipy.misc import comb
X = 10 ** 9 + 7

n, k = map(int, input().split())
c = n - k + 1

for i in range(1, k+1):
    print(int(comb(c, i, exact=True) * comb(k-1, i-1, exact=True)) % X)

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb
X = 10 ** 9 + 7

n, k = map(int, input().split())
c = n - k + 1

for i in range(1, k+1):
    print(int(comb(c, i) * comb(k-1, i-1) % X))
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
a = [0] * 100100
dp = [1, 1]
x = 0
for i in range(m):
    a[i] = int(input())
if a[0] == 1:
    dp[1] = 0
    x = 1

for i in range(len(a)-1):
    if a[i+1] - a[i] == 1:
        print(0)
        exit(0)


for i in range(2, n+1):
    if i != a[x]:
        dp.append((dp[-1] + dp[-2]) % 1000000007)
    else:
        dp.append(0)
        if x < len(a)-1:
            x += 1
# print(dp)
print(dp[-1])

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

for i in range(len(a)-1):
    if a[i+1] - a[i] == 1:
        print(0)
        exit(0)


for i in range(2, n+1):
    if i != a[x]:
        dp.append((dp[-1] + dp[-2]) % 1000000007)
    else:
        dp.append(0)
        if x < len(a)-1:
            x += 1
# print(dp)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [0] * m
dp = [1, 1]

for i in range(m):
    a[i] = int(input())

for i in range(len(a)-1):
    if a[i+1] - a[i] == 1:
        print(0)
        exit(0)

x = 0
for i in range(1, n+1):
    if i != a[x]:
        dp.append((dp[-1] + dp[-2]) % 1000000007)
    else:
        dp.append(0)
        if x < len(a)-1:
            x += 1
# print(dp)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [0] * m
dp = [1, 1]

for i in range(m):
    a[i] = int(input())

for i in range(len(a)-1):
    if a[i+1] - a[i] == 1:
        print(0)
        exit()

x = 0
for i in range(1, n+1):
    if i != a[x]:
        dp.append((dp[-1] + dp[-2]) % 1000000007)
    else:
        dp.append(0)
        if x < len(a)-1:
            x += 1
# print(dp)
print(dp[-1])
Problem p03107 (python)

Fixed submission:
s = input()
print(min(s.count('0'), s.count('1')) * 2)

Buggy submission (verdict: Runtime Error):
s = input()
count = 0
while '10' in s:
    s = s.replace('10', '', 1)
    count += 1
    print(s)

while '01' in s:
    s = s.replace('01', '', 1)
    count += 1
print(count * 2)
Problem p03127 (python)

Fixed submission:
import fractions

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

for i in range(N - 1):
    a[i + 1] = fractions.gcd(a[i], a[i+1])

print(a[N-1])

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
a = list(map(int, input().split()))
for i in range(N - 1):
    a[i + 1] = math.gcd(a[i], a[i+1])
print(a[N-1])

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
a = list(map(int, input().split()))

for i in range(N - 1):
    a[i + 1] = math.gcd(a[i], a[i+1])

print(a[N-1])

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
a = list(map(int, input().split()))

for i in range(N - 1):
    a[i + 1] = int(math.gcd(a[i], a[i+1]))

print(a[N-1])

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
a = list(map(int, input().split()))

for i in range(N - 1):
    a[i + 1] = int(math.gcd(a[i], a[i+1]))
    print(a)

print(a[N-1])
Problem p03631 (python)

Fixed submission:
import sys
n = input()
for i in range(len(n)//2):
  if n[i] != n[-(i+1)]:
  	print('No')
  	sys.exit(0)
print('Yes')

Buggy submission (verdict: Runtime Error):
n = input()
for i in range(len(n)//2){
  if n[i] != n[-(i+1)]:
  	print('No')
  	exit(0)
print('Yes')
Problem p02880 (python)

Fixed submission:
a = [0] * 100
for i in range(1, 10):
    for j in range(1, 10):
        a[i * j] = 1
num = int(input())
if num < 100 and a[num] == 1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a = [0] * 100
for i in range(1, 10):
    for j in range(1, 10):
        a[i * j] = 1
num = int(input())
if a[num] == 1:
    print('Yes')
else:
    print('No')
Problem p02881 (python)

Fixed submission:
def solve(n):
    ans = int(1e12)
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0 and i + n // i - 2 < ans:
            ans = i + n // i - 2
    return int(ans)


num = int(input())
print(solve(num))

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

a = []


def dis(n):
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0: a.append(i)


num = int(input())
dis(num)
ans = 100000000
for e in a:
    ans = min(ans, e + num // e - 2)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import inf

a = []


def dis(n):
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            a.append(int(i))


num = int(input())
dis(num)
ans = inf
for e in a:
    if e + num // e - 2 < ans:
        ans = e + num // e - 2
    # ans = min(ans, e + num / e - 2)
print(int(ans))

Buggy submission (verdict: Runtime Error):
from math import inf

a = []


def dis(n):
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            a.append(int(i))


num = int(input())
dis(num)
ans = inf
for e in a:
    if e + num / e - 2 < ans:
        ans = e + num / e - 2
    # ans = min(ans, e + num / e - 2)
print(int(ans))

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

a = []


num = int(input())
for i in range(1, int(num ** 0.5) + 1):
    if num % i == 0:
        a.append(int(i))
ans = inf
for e in a:
    ans = min(ans, e + num / e - 2)
print(int(ans))

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

a = []


def dis(n):
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            a.append(int(i))


num = int(input())
dis(num)
ans = inf
for e in a:
    ans = min(ans, e + num / e - 2)
print(int(ans))

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

a = []


def dis(n):
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            a.append(int(i))


num = int(input())
dis(num)
ans = inf
for e in a:
    ans = min(ans, e + num / e - 2)
print(int(ans))

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

a = []


def dis(n):
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            a.append(i)


num = int(input())
dis(num)
ans = inf
for e in a:
    ans = min(ans, e + num // e - 2)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

a = []


def dis(n):
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0: a.append(i)


num = int(input())
dis(num)
ans = inf
for e in a:
    ans = min(ans, e + num // e - 2)
print(ans)
Problem p03038 (python)

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

card_list.sort()
compare_list = []

for i in range(M):
  (B, C) = list(map(int, input().split(' ')))
  compare_list.append((C,B))
    
compare_list.sort()

ans = 0
for i in range(N):
  if compare_list == []:
    ans += sum(card_list[i:])
    break
  if card_list[-1] > compare_list[-1][0]:
    ans += card_list.pop()
  elif compare_list[-1][1] > 0:
    ans += compare_list[-1][0]
    tmp = compare_list.pop()
    a = tmp[0]
    b = tmp[1]
    if b != 1:
      compare_list.append((a,b-1)) 
      
print(ans)

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

card_list.sort()

C_list = [0] * N
for i in range(M):
  [B, C] = list(map(int, input().split(' ')))
  if C_list[0] > C:
    continue
  else:
    for k in range(B):
      if C < card_list[k] or C_list[k] >= C:
        break
      else C_list[k] < C:
        C_list[k] = C
  C_list.sort()
  
C_list.sort()

ans = 0
count = 0
for i in range(N):
  if card_list[-1] > C_list[-1]:
    ans += card_list.pop()
    count += 1
  else:
    ans += C_list.pop()
    count += 1
      
print(ans)

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

card_list.sort()

C_list = [0] * N
for i in range(M):
  [B, C] = list(map(int, input().split(' ')))
  if C_list[0] > C:
    continue
  else:
    for k in range(B):
      C_list[k] = C
      if C_list[k + 1] > C:
        break
    C_list.sort()
  
C_list.sort()

ans = 0
count = 0
for i in range(N):
  if card_list[-1] > C_list[-1]:
    ans += card_list.pop()
    count += 1
  else:
    ans += C_list.pop()
    count += 1
    
  if C_list == []:
    for k in range(N - count):
      ans += card_list.pop()
    break
      
print(ans)
Problem p03041 (python)

Fixed submission:
N,K = map(int, input().split())
S = input()
newS = ''
for i in range(N):
  if i == K-1:
    if S[i] == 'A':
      newS += 'a'
    if S[i] == 'B':
      newS += 'b'
    if S[i] == 'C':
      newS += 'c'
  else:
    newS += '{}'.format(S[i])

print(newS)

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
S = input()

if S[K] = 'A':
  S[K] = 'a'
if S[K] = 'B':
  S[K] = 'b'
if S[K] = 'C':
  S[K] = 'c'

print(S)
Problem p03209 (python)

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

def paty(n,x):
  #print('n:{}'.format(n))
  #print('x:{}'.format(x))
  if x == 0:
    return 0
  if n == 0:
    return x
  elif ((2**(n+2))-3 - 1) / 2 >= x:
    return paty(n-1,x-1)
  elif ((2**(n+2))-3 + 1) / 2 == x:
    return 2**n
  elif ((2**(n+2))-3) - 1 <= x:
    return 2**(n+1) - 1
  else:
    return 2**n + paty(n-1, x-((2**(n+1))-3) -2)
  
ans = paty(N,X)
print(ans)

Buggy submission (verdict: Runtime Error):
[N,X] = list(map(int,input().split(' ')))

def paty(n,x):
  if n == 0:
    if x == 1:
      return 1
    elif x == 0:
      return 0
  elif int((2**(n+2)-3 - 1) / 2) >= x:
    return paty(n-1,x-2)
  elif int((2**(n+2)-3 + 1) / 2) == x:
    return paty(n-1,x-2) + 1
  else:
    return 2**n + paty(n-1, x-(2**(n+1)-3) -3)
  
ans = paty(N,X)
print(ans)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
MOD = 10**9+7
a = set()
for i in range(M):
    a.add(int(input()))
step = [0]*(N+1)
step[0] = 1
for i in range(N+1):
    if i == 0:
        pass
    elif i in a:
        step[i] = 0
    elif i == 1:
        step[i] = step[0]
    else:
        step[i] = step[i-1]+step[i-2]
    step[i] %= MOD
print(step[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
MOD = 10**9+7
a = set()
for i in range(M):
    a.add(int(input()))

memo = [-1]*(N+1)
memo[0] = 1

def dodp(x):
    if memo[x] != -1:
        pass
    elif x in a:
        memo[x] = 0
    elif x == 1:
        memo[x] = dodp(x-1)
    else:
        memo[x] = dodp(x-1)+dodp(x-2)
    memo[x] %= MOD
    return memo[x]
    
dodp(N)
print(memo[N])
Problem p03127 (python)

Fixed submission:
import fractions
from functools import reduce
 
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
 
n = int(input())
a = list(map(int, input().split()))
print(gcd(*a))

Buggy submission (verdict: Runtime Error):
import fraction
from functools import reduce
 
def gcd(*numbers):
    return reduce(fraction.gcd, numbers)
 
n = int(input())
a = list(map(int, input().split()))
print(gcd(*a))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

n = int(input())
a = list(map(int, input().split()))
print(gcd(*a))