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

Fixed submission:
sd=input()
t=input()
n=len(sd)
m=len(t)
if n<m:
    print("UNRESTORABLE")
    exit(0)
for i in range(n-m,-1,-1):
    t_kana=sd[i:i+m]
    for j in range(m+1):
        if j==m :
            print((sd[:i]+t+sd[i+len(t):]).replace("?","a"))
            exit(0)
        if t_kana[j]=="?":
            continue
        elif t_kana[j]!=t[j]:
            break
print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
sd=input()
t=input()
n=len(sd)
m=len(t)
if n<m:
    print("UNRESTORABLE")
    exit(0)
for i in range(n-m,-1,-1):
    t_kana=sd[i:i+m]
    for j in range(m):
        if j==m :
            print(sd[:i]+t+sd[i+len(t):]).replace("?","a")
        if t_kana=="?":
            continue
        elif t_kamo[j]!=t[j]:
            break
print("UNRESTORABLE")
Problem p03633 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
n=int(input())
t=[]
for _ in range(n):
    a=int(input())
    t.append(a)
def lcm_base(x,y):
    return (x*y // gcd(x,y))
def lcm_list(l):
    return reduce(lcm_base,l,1)
print(lcm_list(t))

Buggy submission (verdict: Runtime Error):
from fraction import gcd
n=int(input())
t=[]
for _ in range(n):
    a=int(input())
    t.append(a)
def lcm_base(x,y):
    return (x*y // gcd(x,y))
def lcm_list(l):
    return reduce(lcm_base,l,1)
Problem p03720 (python)

Fixed submission:
n,m=map(int,input().split())
c=[]
for _ in range(m):
    a,b=map(int,input().split())
    c.append(a)
    c.append(b)
for i in range(1,n+1):
    print(c.count(i))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
c=[]
for _ in range:
    a,b=map(int,input().split())
    c.append(a)
    c.append(b)
for i in range(1,n+1):
    print(c.count(i))
Problem p03846 (python)

Fixed submission:
import numpy as np
MOD = 10**9 + 7
N = int(input())
A = np.array([int(x) for x in input().split()])

left = np.arange(N)
right = N-1-left
cnt_1 = np.bincount(np.abs(left-right))
cnt_2 = np.bincount(A)

if cnt_1.shape != cnt_2.shape or (cnt_1 != cnt_2).any():
  answer = 0
else:
  answer = pow(2, N//2, MOD)
  
print(answer)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
even=[]
odd=[]
for i in range(0,n // 2):
    even.append(2*i+1)
even=even+even
even.sort()
for j in range(1,(n-1 // 2)+1):
    odd.append(2*j)
odd =odd + odd
odd.append(0)
odd.sort()
if n % 2 == 1:
    if a == odd:
        print(pow(2,n-1 // 2,10**9+7)
    else:
        print(0)
else:
    if a == even:
        print(2,n // 2,10**9+7)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[int(x) for x in input().split()]
a.sort()
set_a=list(set(a))
if N % 2 ==0:
	for i in range(N):
		a[i] != 2*(i // 2) + 1
		print(0)
		exit(0)
else:
	if a[0] != 0:
		print(0)
		exit(0)
	else:
		for i in range(1,N):
			a[i] != 2(i+1 // 2) +1
			print(0)
			exit(0)
if N % 2==1:
	len=len(set_a)-1
else:
	len=len(set(a))
ans=2**len
print(ans)

Buggy submission (verdict: Runtime Error):
N,x=map(int,input().split())
a=[int(x) for x in input().split()]
a.sort()
set_a=list(set(a))
if N % 2 ==0:
	for i in range(N):
		a[i] != 2*(i // 2) + 1
		print(0)
		exit(0)
else:
	if a[0] != 0:
		print(0)
		exit(0)
	else:
		for i in range(1,N):
			a[i] != 2(i+1 // 2) +1
			print(0)
			exit(0)
if N % 2==1:
	len=len(set_a)-1
else:
	len=len(set(a))
ans=2**len
print(ans)
Problem p03945 (python)

Fixed submission:
s=input()
ans=[]
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		ans.append(s[i])
ans.append(s[-1])
print(len(ans)-1)

Buggy submission (verdict: Runtime Error):
s=input()
ans=[]
for i in range(len(s)-1):
	if s[i] != s[i+1]:
		ans.append(s[i])
if s[-1] != s[-2]:
	ans.append(s[-1])
print(ans)
print(len(ans)-1)
Problem p04029 (python)

Fixed submission:
n=int(input())
x=0
for i in range(1,n+1):
  x += i
print(x)

Buggy submission (verdict: Runtime Error):
s=input()
a=[]
for i in s:
	if i == 'B':
      if a:
		a.pop()
	else:
		a.append(i)
print(''.join(a))
Problem p04030 (python)

Fixed submission:
s=input()
a=[]
for i in s:
	if i == 'B':
		if a:
			a.pop()
		else:
			pass
	else:
		a.append(i)
print(''.join(a))

Buggy submission (verdict: Runtime Error):
s=input()
a=[]
for i in s:
  if i == 'B':
    if a:
		a.pop()
  else:
	a.append(i)
print(''.join(a))

Buggy submission (verdict: Runtime Error):
s=input()
a=[]
for i in s:
	if i == 'B':
      if a:
		a.pop()
	else:
		a.append(i)
print(''.join(a))

Buggy submission (verdict: Runtime Error):
s=input()
a=[]
for i in s:
	if i == 'B':
		a.pop()
	else:
		a.append(i)
print(''.join(a))
Problem p04031 (python)

Fixed submission:
import numpy as np
n=int(input())
a=np.array([int(x) for x in input().split()])
x=[]
for i in range(-100,101):
	s=np.sum((a-i)*(a-i))
	x.append(s)
print(min(x))

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=np.array([int(x) for x in input().split()])
x=[]
for i in range(np.max(a)):
	s=np.sum((a-i)*(a-i))
	x.append(s)
print(min(x))
Problem p04043 (python)

Fixed submission:
abc = [int(x) for x in input().split()]
abc.sort()
print("YES" if abc == [5,5,7] else "NO")

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
s=list(input() for _ in range(n))
s.sort()
result=''.join(s)
print(result)

Buggy submission (verdict: Runtime Error):
s=input()
a=[]
for i in s:
	if i == 'B':
      if x:
		a.pop()
	else:
		a.append(i)
print(''.join(a))
Problem p04044 (python)

Fixed submission:
n,l=map(int,input().split())
s=list(input() for _ in range(n))
s.sort()
result=''.join(s)
print(result)

Buggy submission (verdict: Runtime Error):
s=input()
a=[]
for i in s:
	if i == 'B':
      if x:
		a.pop()
	else:
		a.append(i)
print(''.join(a))

Buggy submission (verdict: Runtime Error):
n,l = map(int,input().split())
s=[]
for i in range(n):
	i=input()
	s.append(i)
s.sort()
result=''.join(s)
print(reault)
Problem p04045 (python)

Fixed submission:
n,k=map(int,input().split())
s=set(input().split())
while True:
    l=list(str(n))
    for i in l:
        if i in s:
            break
    else:
        break
            
    n += 1
print(n)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
d={int(x) for x in input().split()}
e={0,1,2,3,4,5,6,7,8,9}
f=list(d^e)
ans=[]
for i in f:
    for j in f:
        for k in f:
            for l in f:
                ans.append(1000*i+100*j+10*k+l)
ans=[m for m in ans if m>= n]
print(min(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
m,k=map(int,input().split())
d={int(x) for x in input().split()}
e={np.arange(10)}
f=list(d&e)
ans=[]
for i in f:
    for j in f:
        for k in f:
            for l in f:
                ans.append(1000*i+100*j+10*k+l)
print(min(ans))
Problem p02768 (python)

Fixed submission:
n,a,b = list(map(int,input().split(" ")))
mod = 10**9 + 7

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = int(numerator[k]) * result % mod

    return result

def m_power_n_mod(m,n,mod):
    q = 1
    f = m
    while(n > 0):
        c = n % 2
        n = int((n-c)/2)
        q = (q * f**c) % mod
        f = f**2 % mod
    return q

print((m_power_n_mod(2,n,mod) - 1 - cmb(n,a)%mod - cmb(n,b)%mod)%mod)

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

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = int(numerator[k]) * result % mod

    return result
  
 def m_power_n_mod(m,n,mod):
    q = 1
    f = m
    while(n > 0):
        c = n % 2
        n = int((n-c)/2)
        q = (q * f**c) % mod
        f = f**2 % mod
    return q
 
print((m_power_n_mod(2,n,mod) - 1 - cmb(n,a)%mod - cmb(n,b)%mod)%mod)
Problem p02947 (python)

Fixed submission:

n = int(input())

# c_hash = {}
c_list = []
# n = 3
for i in range(n):
    s = input()
    c_list.append(''.join(sorted(s)))

# print(sorted(c_list))

c_hash = {}
for c in c_list:
    if c not in c_hash:
        c_hash[c] = 0
    c_hash[c] += 1
count = 0    
for k, v in c_hash.items():
    if v >= 2:

        
        # temp = factorial(v) / factorial(2) / factorial(v - 2)
        # temp = len(list(combinations(range(v),2)))
        temp = v * (v-1)/ 2
        count += temp

print(int(count))

Buggy submission (verdict: Runtime Error):
# from itertools import product, permutations,combinations
from math import factorial

n = int(input())

# c_hash = {}
c_list = []
# n = 3
for i in range(n):
    s = input()
    c_list.append(''.join(sorted(s)))

# print(sorted(c_list))

c_hash = {}
for c in c_list:
    if c not in c_hash:
        c_hash[c] = 0
    c_hash[c] += 1
count = 0    
for k, v in c_hash.items():
    if v >= 2:

        
        temp = factorial(v) / factorial(2) / factorial(v - 2)
        # temp = len(list(combinations(range(v),2)))
        count += temp

print(round(count))
Problem p02767 (python)

Fixed submission:
import sys
input = sys.stdin.readline

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

E = [0 for i in range(100)]

for i in range(100):
    E[i] = 0
    for x in K:
        E[i] += (x-i)**2

print(min(E))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

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

E = [0 for i in range(max(K)-min(K))]

for i in range(max(K)-min(K)):
    E[i] = 0
    for x in K:
        E[i] += (x-(i+min(K)))**2

print(min(E))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

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

E = [0 for i in range(max(K)-min(K))]

for i in range(max(K)-min(K)):
    E[i] = 0
    for x in K:
        E[i] += (x-(i+min(K)))**2

print(min(E))
Problem p02787 (python)

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

A = [0] * (N+1)
B = [0] * (N+1)
#magic = np.zeros((N+1, 2), dtype=int)

for i in range(1, N+1):
    A[i], B[i] = map(int, input().split())

# print(magic)
# print(A)
# print(B)

INF = 100000010  # 10^4 * 10^4 + spare

#dp = np.full((N+1, H*2+1), INF)
#dp[0][0] = 0

dp = [INF]*(H+1)
#dp = np.full(H+1, INF, dtype=int)
dp[0] = 0

for i in range(1, N+1):
    for j in range(H + 1):
        # 貰うDP
        if j-A[i] >= 0:
            dp[j] = min(dp[j - A[i]] + B[i], dp[j])
        else:
            dp[j] = min(dp[0] + B[i], dp[j])

#        print(dp[i])
#    print(dp)

print(dp[H])

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

magic = [[0] * 2 for i in range(N+1)]

# for i in range(1, N+1):
#    magic[i] = list(map(int, input().split()))

dp = [[0] * (H+1) for i in range(N+1)]

for i in range(1, N + 1):
    A, B = map(int, input().split())
    for j in range(1, H + 1):
        old_data = dp[i-1][j]
        new_data = dp[i][j-A] + B
        if (old_data == 0):
            dp[i][j] = new_data
        else:
            dp[i][j] = min(old_data, new_data)

# print(dp)

print(dp[N][H])
Problem p02765 (python)

Fixed submission:
s = input().split()

K = int(s[0])
N = int(s[1])

if K >= 10:
  print(N)
else:
  print(N + 100*(10-K))

Buggy submission (verdict: Runtime Error):
input_line = int(input())
for i in range(input_line):
  s = input().rstrip().split(' ')
  print("hello = "+s[0]+" , world = "+s[1])
Problem p03260 (python)

Fixed submission:
a, b = map(int, input().split())
d = a*b
if d%2 == 0:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
d = a*c
if d%2 == 0:
  print("No")
else:
  print("Yes")
Problem p02823 (python)

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

t = float('inf')
if abs(A - B) % 2 == 0:
    t = min(abs(A - B) // 2, t)
    
t = min(B - 1, t)
t = min(N - A, t)
t = min((A - 1 + 1) + (B - A - 1) // 2, t)
t = min((N - B + 1) + (N - (A + (N - B + 1))) // 2, t)

print(t)

Buggy submission (verdict: Runtime Error):
N, A, B = (int(i) for i in input().split())

def f(A, B):
  return int((B - A) / 2)
  
def f2(N, A, B):
    if (B - A) % 2 == 0:
        ans = f(A, B)
    else:
        # Aが1に向かうとき
        ans_a = A + f(1, B - A)
        # BがNに向かうとき
        if (A + N - B +1) <  N:
            ans_b = (N - B + 1) + f(A + N - B +1, N)
            ans_b = N
            
        ans = min(ans_a, ans_b)
    
    return ans
  
print(f2(N, A, B))
Problem p02842 (python)

Fixed submission:
import math

n = int(input())

nontax = math.floor(n / 1.08)

if math.floor(nontax * 1.08) == n:
    print(nontax)
elif math.floor((nontax + 1) * 1.08) == n:
    print(nontax+1)
else:
    print(':(')

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

if (n*100 // 108) == (n*100 / 108):
  print((n*100 // 108))
else:
  print(':(')

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

if (n // 1.08) == (n % 1.08):
  print(int(n // 1.08))
else:
  print(':(')
Problem p02743 (python)

Fixed submission:
a, b, c = map(int, input().split())
 
if c - a - b > 0 and 4 * a * b < (c - a - b)**2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import numpy as np
 
a, b, c = map(int, input().split())

if c - a - b > 0 and 4 * a * b < (c - a - b)**2:
  print("Yes")
else:
  print("No")
Problem p02982 (python)

Fixed submission:
import numpy as np

N, D = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for m in range(N)]
X = np.array(X)
l = 0

for i in range(N):
  for j in range(i+1, N):
    if sum((X[i] - X[j])**2)**0.5 % 1 == 0:
      l += 1

print(l)

Buggy submission (verdict: Runtime Error):
import numpy as np

N, D = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for m in range(N)]
X = np.array(X)
l = 0

for i in range(N):
  for j in range(i+1, N):
    if sum((X[i] - X[j])**2)**0.5 % 1 == 0:
      l += 1

print(l)
Problem p02995 (python)

Fixed submission:
import math
import fractions

A, B, C, D = map(int, input().split())
E = (C * D) // fractions.gcd(C, D)
count_div = 0
 
n = (A-1) // C
m = B // C
count_div += m - n

l = (A-1) // D
k = B // D
count_div += k - l

j = (A-1) // E
i = B // E
count_div -= i - j

print(B - A + 1 - count_div)

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

A, B, C, D = map(int, input().split())
E = (C * D) // fractions.gcd(C, D)
count_div = 0

n_ = (A-1) // C
n = math.ceil(A / C) - 1
m = B // C
if m >= n:
  count_div += m - n

l_ = (A-1) // D
l = math.ceil(A / D) - 1
k = B // D
if k >= l:
  count_div += k - l

j_ = (A-1) // E
j = math.ceil(A / E) - 1
i = B // E
if i >= j:
  count_div -= i - j

if (n_ != n) or (l_ != l) or (j_ != j):
  sleep(2)
else:
  print(B - A + 1 - count_div)
Problem p02975 (python)

Fixed submission:
from sys import stdin
import numpy as np
from operator import itemgetter

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]

ans = "Yes"
L = []
L_cnt = {}
for a in A:
    if a in L:
        L_cnt[a]+=1
        continue

    if len(L)>=3:
        ans = "No"
        break
    L.append(a)
    L_cnt[a]=1

if len(L)==3:
    l1, l2, l3 = L
    if N%3!=0:
        ans="No"
    if not L_cnt[l1]==L_cnt[l2]==L_cnt[l3]:
        ans="No"
    while ans=="Yes":
        sumL = l1%2 + l2%2 + l3%2
        if sumL!=0 and sumL!=2:
            ans = "No"
            break
        l1 = l1//2
        l2 = l2//2
        l3 = l3//2
        if l1+l2+l3==0:
            break
    print(ans)
elif len(L)==2:
    if N%3!=0:
        ans="No"
    if L_cnt[0]!=N//3:
        ans="No"
    if L[0]!=0 and L[1]!=0:
        ans="No"
    print(ans)
else:
    if sum(L)!=0:
        ans="No"
    print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import numpy as np
from operator import itemgetter

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]

ans = "Yes"
L = []
if N%3!=0:
    if sum(A)==0:
        print("Yes")
    else:
        print("No")
else:
    for a in A:
        if a in L:
            continue

        if len(L)>=3:
            ans = "No"
            break
        L.append(a)

    l1, l2, l3 = L
    while ans=="Yes":
        sumL = l1%2 + l2%2 + l3%2
        if sumL!=0 and sumL!=2:
            ans = "No"
            break
        l1 = l1//2
        l2 = l2//2
        l3 = l3//2
        if l1+l2+l3==0:
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import numpy as np
from operator import itemgetter

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]

ans = "Yes"
L = []
for a in A:
    if a in L:
        continue

    if len(L)>=3:
        ans = "No"
        break
    L.append(a)

l1, l2, l3 = L
while ans=="Yes":
    sumL = l1%2 + l2%2 + l3%2
    if sumL!=0 and sumL!=2:
        ans = "No"
        break
    l1 = l1//2
    l2 = l2//2
    l3 = l3//2
    if l1+l2+l3==0:
        break
print(ans)
Problem p03069 (python)

Fixed submission:
from sys import stdin
# import math
import numpy as np
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

N = int(stdin.readline().rstrip().split()[0])
S = stdin.readline().rstrip().split()[0]

B =[]
W =[]
b=0
w=0
for i in range(N):
  if S[i]==".":
    w+=1
  W.append(w)
  
  if S[N-1-i]=="#":
    b+=1
  B.append(b)

W=np.array(W)
B=np.array(B[::-1])
ans = N-np.max(W+B)
print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
# import math
import numpy as np
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

N = int(stdin.readline().rstrip().split()[0])
S = stdin.readline().rstrip().split()[0]

white = S.count(".")
ans1=0
if white == N:
  ans1=0
else:
  first_black = S.index("#")
  ans1 = white - first_black
  
ans2=0
black = N-white
last_white = S[::-1].index(".")
ans2=black-last_white

if ans1>ans2:
  print(ans2)
else:
  print(ans1)
Problem p03087 (python)

Fixed submission:
from sys import stdin

N, Q = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()

ac_idx = [0]
count = 0

for i in range(N-1):
  if S[i]=="A" and S[i+1]=="C":
    count+=1
  ac_idx.append(count)

for j in range(Q):
  l,r = [int(x) for x in stdin.readline().rstrip().split()]
  print(ac_idx[r-1]-ac_idx[l-1])

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

N, Q = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()

def func(Str):
  if "AC" in Str:
    idx = Str.index("A")
    if Str[idx+1] == "C":
      return idx
    else:
      return func(Str[idx+2:])
  else:
    return -1

i = 0
ac_idx = []
while i<N:
  a = func(S[i:])
  if a != -1:
    ac_idx.append(a+i)
    i = a+i+2
  else:
    break
ac_idx = np.array(ac_idx)
for j in range(Q):
  l,r = [int(x) for x in stdin.readline().rstrip().split()]
  print(np.sum((ac_idx>=l-1)&(ac_idx<r-1)))
Problem p03294 (python)

Fixed submission:
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]

print(sum(A)-len(A))

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

N = int(stdin.readline().rstrip().split()[0])
A = [int(x) for x in stdin.readline().rstrip().split()]

def LCM(_a, _b):
  if _a < _b:
    a, b = _b, _a
  else:
    a, b = _a, _b
  while True:
    c = a%b
    if c==0:
      break
    a,b = b,c
  return (_a*_b)//b

def func(a_list):
  size = len(a_list)
  if size ==2:
    return LCM(a_list[0],a_list[1])
  else:
    return LCM(a_list[0], func(a_list[1:]))

lcm_1 = func(A)-1
print(sum(list(map(lambda x: lcm_1%x, A))))
Problem p02817 (python)

Fixed submission:
S, T = input().split()
print(T+S)

Buggy submission (verdict: Runtime Error):
S, T = map(input().split())
print(T+S)
Problem p02855 (python)

Fixed submission:
H, W, K = map(int, input().split())
grid = []
for _ in range(H):
    w = input()
    grid.append(w)

output = [[0] * W for _ in range(H)]
k = 1
for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            output[i][j] = k
            k += 1

def h_paint(i, j):
    dj = j
    k = output[i][j]
    while (dj-1 >= 0):
        if output[i][dj - 1] == 0:
            output[i][dj - 1] = k
            dj -= 1
        else:
            break
    dj = j
    while (dj + 1 < W):
        if output[i][dj + 1] == 0:
            output[i][dj + 1] = k
            dj += 1
        else:
            break
            

for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            h_paint(i, j)

for i in range(H-2, -1, -1):
    for j in range(W):
        if output[i][j] == 0:
            output[i][j] = output[i + 1][j]

for i in range(1, H):
    for j in range(W):
        if output[i][j] == 0:
            output[i][j] = output[i-1][j]

for o in output:
    print(*o)

Buggy submission (verdict: Runtime Error):
H, W, K = map(int, input().split())
grid = []
for _ in range(H):
    w = input()
    grid.append(w)

output = [[0] * W for _ in range(H)]
k = 1
for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            output[i][j] = k
            k += 1

def h_paint(i, j):
    dj = j
    k = output[i][j]
    while (dj-1 >= 0):
        if output[i][dj - 1] == 0:
            output[i][dj - 1] = k
            dj -= 1
        else:
            break
    dj = j
    while (dj + 1 < W):
        if output[i][dj + 1] == 0:
            output[i][dj + 1] = k
            dj += 1
        else:
            break
            

for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            h_paint(i, j)

for i in range(H-1, -1, -1):
    for j in range(W):
        if output[i][j] == 0:
            output[i][j] = output[i + 1][j]

for i in range(1, H):
    for j in range(W):
        if output[i][j] == 0:
            output[i][j] = output[i-1][j]

for o in output:
    print(*o)
Problem p02883 (python)

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

# 考え方
# 目標：最大値の最小化
# にぶたん
# 必要条件：A[i] <= A[i+1] => F[i] >= F[i+1]

# sort
# Aは昇順、Fは降順(任意)
A = sorted(A)
F = sorted(F, reverse=True)

# にぶたん(参考：juppy)
ng = -1
ok = 10 ** 12  # 取り得る最大値

while ok - ng > 1:  # 収束判定
    mid = (ok + ng) // 2
    cost = 0

    for i, e in enumerate(A):
        cost += max(0, e - mid // F[i])
    
    if cost <= K:
        ok = mid
    
    else:
        ng = mid

print(ok)

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

# 考え方
# 目標：最大値の最小化
# にぶたん
# 必要条件：A[i] <= A[i+1] => F[i] >= F[i+1]

# sort
# Aは昇順、Fは降順(任意)
A = sorted(A)
F = sorted(F, reverese=True)

# にぶたん(参考：juppy)
ng = -1
ok = 10 ** 12  # 取り得る最大値

while ok - ng > 1:  # 収束判定
    mid = (ok + ng) // 2
    cost = 0

    for i, e in enumerate(A):
        cost += max(0, e - mid // F[i])
    
    if cost <= K:
        ok = mid
    
    else:
        ng = mid

print(ok)