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

Fixed submission:
N, K = map(int, input().split())
S = list(map(int, input()))
lst = []
cnt = 0
now = 1

for i in range(N):
	if S[i] == now:
		cnt += 1
	else:
		lst.append(cnt)
		cnt = 1
		now = 1 - now
		
lst.append(cnt)

#1 0 1 0 1の形にしたい
if len(lst) % 2 == 0:
	lst.append(0)

ret = 0
add = 2 * K + 1
left = 0
right = 0
total = 0

for i in range(0, len(lst), 2):
	nextleft = i
	nextright = min(i + add, len(lst))
	while nextleft > left:
		total -= lst[left]
		left += 1
	while nextright > right:
		total += lst[right]
		right += 1
	ret = max(ret, total)
	
print(ret)

Buggy submission (verdict: Runtime Error):
N, K  = (map(int, input().split()))
S = list(map(int, input()))
length = len(S)
lst = []

# 前処理
for i in range(length):
	if i == 0:
		lst.append(1)
		start = S[0]
	else:
		if S[i - 1] == S[i]:
			lst[-1] += 1
		else:
			lst.append(1)
				
# print(lst)
if (len(lst) + 1) / 2 < K:
	# print(sum(lst))
else:
	# 探索
	# 始点
	maximum = 0
	score = 0
	for i in range(start, length, 2):
		if len(lst) >= i + 2 * (K - 1) + 2:
			if i == start:
				score = sum(lst[max(0, i - 1) : min(len(lst), i + 2 * (K - 1) + 2)])
			else:
				# print(score)
				score -= sum(lst[i - 3 : i - 1])
				# print(sum(lst[i - 3 : i - 1]))
				score += sum(lst[i + 2 * (K - 1) : i + 2 * (K - 1) + 2])
				# print(sum(lst[i + 2 * (K - 1) : i + 2 * (K - 1) + 2]))
			# print(max(0, i - 1), min(len(lst), i + 2 * (K - 1) + 2))
			# print("score={}".format(score))
			if score > maximum:
				maximum = score
	print(maximum)
Problem p03085 (python)

Fixed submission:
S = str(input())
 
if S == 'A':
  print('T')
elif S == 'G':
  print('C')
elif S == 'T':
  print('A')
else:
  print('G')

Buggy submission (verdict: Runtime Error):
S = str(input())

if S = 'A':
  print('T')
elif S = 'G':
  print('C')
elif S = 'T':
  print('A')
else:
  print('G')
Problem p03102 (python)

Fixed submission:
N, M, C = (map(int, input().split()))
B = list(map(int, input().split()))
counter = 0
for i in range(N):
	tmp = list(map(int, input().split()))
	total = C
	for j in range(M):
		total += B[j] * tmp[j]
	if total > 0:
		counter += 1
			
print(counter)

Buggy submission (verdict: Runtime Error):
N, M, C = (map(int, input().split()))
B = list((map(int, input().split())))
counter = 0
for i in range(N):
	tmp = list((map(int, input().split())))
	total = C
	for j in range(M):
		total += B[i] * tmp[i]
		if total > 0:
			counter += 1
			break
			
print(counter)
Problem p03213 (python)

Fixed submission:
import math

N = int(input())

prime = [0 for _ in range(47 + 1)]
lst = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]

for i in range(2, N + 1):
	num = i
	# 素因数分解
	for p in lst:
		while True:
			if num % p == 0:
				num //= p
				prime[p] += 1
			else: break
			if num == 1: break
		

_75 = 0
_25 = 0
_15 = 0
_5 = 0
_3 = 0

for i in range(len(prime)):
	if prime[i] >= 2:
		_3 += 1
	if prime[i] >= 4:
		_5 += 1
	if prime[i] >= 14:
		_15 += 1
	if prime[i] >= 24:
		_25 += 1
	if prime[i] >= 74:
		_75 += 1
		
def comb(a, b):
	return math.factorial(a) / (math.factorial(b) * math.factorial(a - b))
		
ans = 0
ans += _75
ans += (_3 - 1) * _25 # かけられている数で1引いているのは、かける数で使っているものをかけられる数でも使う場合を除くため
ans += (_5 - 1) * _15
if _5 >= 2:
	ans += (_3 - 2) * comb(_5, 2)

print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

prime = [0 for _ in range(47 + 1)]
lst = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]

for i in range(2, N + 1):
	num = i
	# 素因数分解
	for p in lst:
		while True:
			if num % p == 0:
				num //= p
				prime[p] += 1
			else: break
			if num == 1: break
		

_75 = 0
_25 = 0
_15 = 0
_5 = 0
_3 = 0

for i in range(len(prime)):
	if prime[i] >= 2:
		_3 += 1
	if prime[i] >= 4:
		_5 += 1
	if prime[i] >= 14:
		_15 += 1
	if prime[i] >= 24:
		_25 += 1
	if prime[i] >= 74:
		_75 += 1
		
def comb(a, b):
	return math.factorial(a) / (math.factorial(b) * math.factorial(a - b))
		
ans = 0
ans += _75
ans += (_3 - 1) * _25 # かけられている数で1引いているのは、かける数で使っているものをかけられる数でも使う場合を除くため
ans += (_5 - 1) * _15
ans += (_3 - 2) * comb(_5, 2)

print(int(ans))
Problem p03262 (python)

Fixed submission:
from fractions import gcd

N, X = (int(i) for i in input().split())

x = [abs(int(i) - X) for i in input().split()]  
for i in range(1,N):
	x[i] = gcd(x[i-1], x[i])

print(x[-1])

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
city_lst = list(map(int, input().split()))
city_lst.sort()
dif_lst = []
tmp = city_lst[0]
for i in range(1, N):
	dif_lst.append(city_lst[i] - tmp)
	tmp = city_lst[i]
# print(city_lst)

if X < city_lst[0]:
	maximum_D = city_lst[0] - X
else:
	for i in range(N - 1):
		if city_lst[i] < X:
			maximum_D = min(abs(X - city_lst[i]), abs(city_lst[i + 1] - X))
			break

# print(maximum_D)
for D in reversed(range(1, maximum_D + 1)):
	fail = 0
	# print("D = {}".format(D))
	for dif in dif_lst:
		if dif % D != 0:
			fail = 1
			# print("fail = 1")
			break
	if not fail:
		print(D)
		break

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
city_lst = list(map(int, input().split()))
city_lst.sort()
dif_lst = []
for i in range(1, N):
	dif_lst.append(city_lst[i] - city_lst[i - 1])
# print(city_lst)

if X < city_lst[0]:
	maximum_D = city_lst[0] - X
else:
	for i in range(N - 1):
		if city_lst[i] < X:
			maximum_D = min(abs(X - city_lst[i]), abs(city_lst[i + 1] - X))
			break

# print(maximum_D)
for D in reversed(range(1, maximum_D + 1)):
	fail = 0
	# print("D = {}".format(D))
	for dif in dif_lst:
		if dif % D != 0:
			# print(city_lst[i], city_lst[i - 1])
			fail = 1
			# print("fail = 1")
			break
	if not fail:
		print(D)
		break

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
city_lst = list(map(int, input().split()))
city_lst.sort()
# print(city_lst)

if X < city_lst[0]:
	maximum_D = city_lst[0] - X
else:
	for i in range(N - 1):
		if city_lst[i] < X:
			maximum_D = min(abs(X - city_lst[i]), abs(city_lst[i + 1] - X))
			break

# print(maximum_D)
for D in reversed(range(1, maximum_D + 1)):
	fail = 0
	# print("D = {}".format(D))
	for i in range(1, N):
		if (city_lst[i] - city_lst[i - 1]) % D != 0:
			# print(city_lst[i], city_lst[i - 1])
			fail = 1
			# print("fail = 1")
			break
	if not fail:
		print(D)
		break

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

if X < city_lst[0]:
	maximum_D = city_lst[0] - X
else:
	for i in range(N - 1):
		if city_lst[i] < X:
			maximum_D = min(abs(X - city_lst[i]), abs(city_lst[i + 1] - X))
			break

# print(maximum_D)
for D in reversed(range(1, maximum_D + 1)):
	fail = 0
	for i in range(1, N + 1):
		if not (city_lst[i] - city_lst[i - 1]) % D:
			break
	if not fail:
		print(D)
		break

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

if X < city_lst[0]:
	maximum_D = city_lst[0] - X
else:
	for i in range(N - 1):
		if city_lst[i] < X:
			maximum_D = min(abs(X - city_lst[i]), abs(city_lst[i + 1] - X))
			break

# print(maximum_D)
for D in reversed(range(1, maximum_D + 1)):
	fail = 0
	for i in range(1, N + 1):
		if not city_lst[i] - city_lst[i - 1] == D:
			break
	if not fail:
		print(D)
		break
Problem p03380 (python)

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

if N == 2:
	print(A[0], A[1])
else:
	q = max(A)
	B = list(map(lambda x : abs(q // 2 - x),  A))
	print(q, A[B.index(min(B))])

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb
N = int(input())
A = sorted(list(map(int, input().split())), reverse = True)

if N == 2:
	print(A[0], A[1])
else:
	q = max(A)
	B = list(map(lambda x : abs(q // 2 - x),  A))
	print(q, A[B.index(min(B))])

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
N = int(input())
A = sorted(list(map(int, input().split())), reverse = True)

if N == 2:
	print(A[0], A[1])
else:
	q = max(A)
	B = list(map(lambda x : abs(q // 2 - x),  A))
	print(q, A[B.index(min(B))])
Problem p03486 (python)

Fixed submission:
S = sorted(list(map(str, input())))
T = sorted(list(map(str, input())), reverse = True)
length = min(len(S), len(T))

flg = 2

for i in range(length):
	if S[i] < T[i]:
		flg = 1
		break
	elif S[i] > T[i]:
		flg = 0
		break

if flg == 1:		
	print("Yes")
elif flg == 0:
	print("No")
else:
	if len(S) < len(T):
		print("Yes")
	else:
		print("No")

Buggy submission (verdict: Runtime Error):
S = sorted(list(map(str, input())))
T = sorted(list(map(str, input())), reverse = True)
len = min(len(S), len(T))

flg = 2

for i in range(len):
	if S[i] < T[i]:
		flg = 1
		break
	elif S[i] > T[i]:
		flg = 0
		break

if flg == 1:		
	print("Yes")
elif flg == 0:
	print("No")
else:
	if len(S) < len(T):
		print("Yes")
	else:
		print("No")

Buggy submission (verdict: Runtime Error):
S = sorted(list(map(str, input())))
T = sorted(list(map(str, input())), reverse = True)
len = min(len(S), len(T))

print(S, T)
flg = 2

for i in range(len):
	if S[i] < T[i]:
		flg = 1
		break
	elif S[i] > T[i]:
		flg = 0
		break

if flg == 1:		
	print("Yes")
elif flg == 0:
	print("No")
else:
	if len(S) <= len(T):
		print("Yes")
	else:
		print("No")
Problem p03565 (python)

Fixed submission:
S_prime = list(map(str, input()))
T = list(map(str, input()))

len_S = len(S_prime)
len_T = len(T)

un = 1

for i in reversed(range(0, len_S - len_T + 1)):
	match = 1
	for j in range(i, i + len_T):
		# print(S_prime[j], T[j - i])
		if S_prime[j] == "?": continue
		if not S_prime[j] == T[j - i]:
			match = 0
			break
	if match:
		un = 0
		# print(i)
		init = i
		break
		
if un:
	print("UNRESTORABLE")
else:
	for i in range(init, init + len_T):
		S_prime[i] = T[i - init]
	
	for i in range(len_S):
		if S_prime[i] == "?":
			print("a", end = "")
		else:
			print(S_prime[i], end = "")

Buggy submission (verdict: Runtime Error):
S_dash = list(map(str, input()))
T = list(map(str, input()))


for i in reversed(range(len(S_dash) - len(T) + 1)):
	flg = 1
	for j in range(len(T)):
		if S_dash[i + j] != "?" and S_dash[i + j] != T[j]:
			flg = 0
			break
	if flg:
		for j in range(len(T)):
			S_dash[i + j] = T[j]
		break
		
if flg:
	for i in range(len(S_dash)):
		pass
		# if S_dash[i] == "?":
			# print("a", end = "")
		# else:
			# print(S_dash[i], end = "")
else:
	print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
S_dash = list(map(str, input()))
T = list(map(str, input()))


for i in reversed(range(len(S_dash) - len(T) + 1)):
	flg = 1
	for j in range(len(T)):
		if S_dash[i + j] != "?" and S_dash[i + j] != T[j]:
			flg = 0
			break
	if flg:
		for j in range(len(T)):
			S_dash[i + j] = T[j]
		break
		
if flg:
	for i in range(len(S_dash)):
		# if S_dash[i] == "?":
			# print("a", end = "")
		# else:
			# print(S_dash[i], end = "")
else:
	print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
S_dash = list(map(str, input()))
T = list(map(str, input()))


for i in reversed(range(len(S_dash) - len(T) + 1)):
	flg = 1
	for j in range(len(T)):
		if S_dash[i + j] != "?" and S_dash[i + j] != T[j]:
			flg = 0
			break
	if flg:
		for j in range(len(T)):
			S_dash[i + j] = T[j]
		break
		
if flg:
	for i in range(len(S_dash)):
		if S_dash[i] == "?":
			print("a", end = "")
		else:
			print(S_dash[i], end = "")
else:
	print("UNRESTORABLE")
Problem p03633 (python)

Fixed submission:
N = int(input())
T = []

for _ in range(N):
	T.append(int(input()))
	
def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

ans = 1
	
for i in range(N):
	ans = ans * T[i] // gcd(ans, T[i])
	
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = []

for _ in range(N):
	T.append(int(input()))
	
def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

ans = 1
	
for i in range(N):
	ret = ret * T[i] // gcd(ret, T[i])
	
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = []

for _ in range(N):
	T.append(int(input()))
	
def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

ans = 1
	
for i in range(N):
	ret = ret * T[i] // gcd(ret, T[i]])
	
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = []

for _ in range(N):
	T.append(int(input()))
	
def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

ans = 1
	
while T:
	cur = T.pop(0)
	ans = (ans * cur) / gcd(ans, cur)
	
print(int(ans))
Problem p03844 (python)

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

if p == "+":
  print(a + b)
else:
  print(a - b)

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

if p == "+":
  print(a + b)
else:
  print(a - b)
Problem p04034 (python)

Fixed submission:
import copy
N, M = map(int, input().split())
XY = []
for _ in range(M):
    x, y = map(int, input().split())
    XY.append([x - 1, y - 1])

ball_num = [1] * N
is_red = [False] * N
is_red[0] = True

for i in range(M):
    s = XY[i][0]
    g = XY[i][1]
    if is_red[s]:
        if ball_num[s] == 1:
            ball_num[s] -= 1
            ball_num[g] += 1
            is_red[s] = False
            is_red[g] = True
        else:
            ball_num[s] -= 1
            ball_num[g] += 1
            is_red[g] = True
    else:
        ball_num[s] -= 1
        ball_num[g] += 1

print(sum(is_red))

Buggy submission (verdict: Runtime Error):
import copy
N, M = map(int, input().split())
XY = []
for _ in range(M):
    x, y = map(int, input().split())
    XY.append([x - 1, y - 1])

ans = [0] * N

def dfs(depth, lst):
    if depth == M:
        for i in range(N):
            if lst[i][0] == 1:
                global ans
                ans[i] = 1
                return 0
    start = XY[depth][0]
    goal = XY[depth][1]
    # print(start, goal)
    # print(lst)
    if lst[start][0] == 1 and lst[start][1] == 0:
        lst[start][0] -= 1
        lst[goal][0] += 1
        dfs(depth + 1, lst)
    elif lst[start][0] == 1 and lst[start][1] > 0:
        a = copy.deepcopy(lst)
        lst[start][0] -= 1
        lst[goal][0] += 1
        dfs(depth + 1, lst)

        a[start][1] -= 1
        a[goal][1] += 1
        dfs(depth + 1, a)
    elif lst[start][0] == 0 and lst[start][1] == 0: return 0
    else:
        lst[start][1] -= 1
        lst[goal][1] += 1
        dfs(depth + 1, lst)

tmp = [[0, 1] for _ in range(N)]
tmp[0] = [1, 0]
dfs(0, tmp)

print(sum(ans))
Problem p02717 (python)

Fixed submission:
i = input()
l = i.split()
print(l[2] + ' ' + l[0] + ' ' + l[1])

Buggy submission (verdict: Runtime Error):
i = input().split()
i_int = [int(n) for n in i]
a = input().split()
A = [int(m) for m in a]
N = i_int[0]
M = i_int[1]

th = sum(A)/(4 * M)

##print(threshhold)

c = 0
for val in A:
    if val >= th:
    ##print(val)
        c += 1

if M >= c:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
l = input().split()
l_int = [int(a) for a in l]
N = l_int[0]
K = l_int[1]
 
print(min(N%K, abs(K - (N%K)))

Buggy submission (verdict: Runtime Error):
i = input().split()
i_int = [int(n) for n in i]
a = input().split()
A = [int(m) for m in a]
N = i_int[0]
M = i_int[1]

th = int(sum(A)/(4 * M))

##print(threshhold)

c = 0
for val in A:
    if val >= th:
    ##print(val)
        c += 1

if M > c:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
i = input().split()
i_int = [int(n) for n in i]
a = input().split()
A = [int(m) for m in a]
N = i_int[0]
M = i_int[1]

threshhold = int(sum(A)/(4 * M))

##print(threshhold)

c = 0
for val in A:
    if val > threshhold:
    ##print(val)
        c += 1

if M > c:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
i = input().split()
i_int = [int(n) for n in i]
a = input().split()
A = [int(m) for m in a]
N = i_int[0]
M = i_int[1]

threshhold = int(sum(A)/(4 * M))

##print(threshhold)

c = 0
for val in A:
    if val > threshhold:
    ##print(val)
        c += 1

if M > c:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
i = input().split()
i_int = [int(n) for n in i]
a = input().split()
A = [int(m) for m in a]
N = i_int[0]
M = i_int[1]

threshhold = int(sum(A)/(4 * M))

##print(threshhold)

c = 0
for val in A:
    if val > threshhold:
    ##print(val)
    c += 1

if M > c:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
i = input().split()
i_int = [int(n) for n in i]
a = input().split()
A = [int(m) for m in a]
N = i_int[0]
M = i_int[1]

threshhold = int(sum(A)/(4 * M))

##print(threshhold)

c = 0
for val in A:
  if val > threshhold:
    ##print(val)
    c += 1

if M > c:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
i = input().split()
i_int = [int(n) for n in i]
a = input().split()
A = [int(m) for m in a]
N = i_int[0]
M = i_int[1]

threshhold = int(sum(A)/(4 * M))

##print(threshhold)

c = 0
for val in A:
  if val > threshhold:
    ##print(val)
    c += 1

if M > c:
  print('No')
else:
  print('Yes')
Problem p02780 (python)

Fixed submission:
from itertools import accumulate
n,k=map(int, input().split())
A=[((int(i)*(int(i)+1))/2)/int(i) for i in input().split()]
al = list(accumulate(A))
ans = al[k-1]
for i in range(k, n):ans=max(ans, al[i]-al[i-k])
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = list(map(lambda x: (((x + 1) * x) / 2) / x, l))
s = list(accumulate(l))
l_2 = [s[k - 1]]
for i in range(len(l) - (k - 1) - 1):
    l_2 += [s[i + k] - s[i]]
print(max(l_2)
Problem p02789 (python)

Fixed submission:
l  = [int(x) for x in input().split()]
if l[0]==l[1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
l  = [int(x) for x in input().split()]
a, b = l[0], l[1]
if a <= b:
    print(int(str(b)*a))
else:
    print(int(str(a)*b))
Problem p03852 (python)

Fixed submission:
c = input()
if c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o':
    print('vowel')
else:
    print('consonant')

Buggy submission (verdict: Runtime Error):
c = input()
if c == a or c == i or c == u or c ==e or c == o:
    print('vowel')
else:
    print('consonant')
Problem p02772 (python)

Fixed submission:
n = int(input())
m = map(int, input().split())
flag = "APPROVED"

for i in m:
	if i % 2 == 0:
		if i % 3 != 0 and i % 5 != 0:
			flag = "DENIED"
    
print(flag)

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

for i in m:
	if i % 2 == 0:
		if i % 3 != 0 and i % 5 != 0:
    		flag = "DENIED"
    
print(flag)
Problem p02743 (python)

Fixed submission:
# C
# 解説みた
a, b, c = map(int, input().split())

if 4*a*b < (c - a - b)**2 and 0 < c - a - b: 
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
# C
# 解説みた
a, b, c = map(int, input().split())

if 4*a*b < (c - a - b)**(1/2) and 0 < c - a - b: 
    print('Yes')
else:
    print('No')
Problem p02747 (python)

Fixed submission:
# A 
s = input()

for i in range(0, len(s), 2):
    if len(s)%2 == 1:
        bool = False
        break
    elif s[i] == 'h' and s[i+1] == 'i':
        bool = True
    else:
        bool = False
        break
        
print('Yes' if bool else 'No')

Buggy submission (verdict: Runtime Error):
# A 
s = input()

for i in range(0, len(s), 2):
    if len(s) < 2:
        bool = False
        break
    elif s[i] == 'h' and s[i+1] == 'i':
        bool = True
    else:
        bool = False
        break
        
print('Yes' if bool else 'No')

Buggy submission (verdict: Runtime Error):
# A
s = input()

for i in range(0, len(s), 2):
    if s[i] == 'h' and s[i+1] == 'i':
        bool = True
    else:
        bool = False
        break
        
print('Yes' if bool else 'No')
Problem p02806 (python)

Fixed submission:
n = int(input())
s = []
t = []
for i in range(n):
    ss, tt = map(str, input().split())
    s.append(ss)
    t.append(int(tt))
x =input()

song= s.index(x)
res = 0
for i in range(song+1, n):
    res += t[i]
    
print(res)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(3000)
n = int(input())
x = list(map(int, input().split()))

dx = [0]*(n-1)
for i in range(n-1):
    dx[i] = x[i+1] - x[i]

def fact(n):
    if n <= 1:
        return n
    else:
        return n*fact(n-1)
    
r = fact(n-1)//2
res = 0
for j in range(n-1):
    if j == 0:
        res += dx[j]*fact(n-1)
    else:
        res += dx[j]*fact(n-1) + r
        r = r + r//(j+1)
        
ans = res%(10**9+7)
print(ans)
Problem p02817 (python)

Fixed submission:
s = list(map(str, input().split()))

print(s[1]+s[0])

Buggy submission (verdict: Runtime Error):
A,B,K =map(int,input().split())
if A >= K:
  print(A-K,B)
elif B-(K-A) >= 0:
  print(0,B-(K-A))
else:
  print(0,0)
Problem p02885 (python)

Fixed submission:
a, b = map(int, input().split())
if a-2*b >= 0:
    print(a-2*b)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a-2b >= 0:
  print(a-2b)
else:
  print(0)
Problem p02909 (python)

Fixed submission:
s = input()
if s == "Sunny":
    print('Cloudy')
elif s == 'Cloudy':
    print('Rainy')
elif s == 'Rainy':
    print('Sunny')

Buggy submission (verdict: Runtime Error):
s = input()
l = ['Sunny', 'Cloudy', 'Rainy']
if s == l[0]:
    print(l[1])
elif s == l[1]:
    print(l[2]):
elif s == l[2]:
    print(l[0])

Buggy submission (verdict: Runtime Error):
s = input()
if s = 'Sunny':
    print('Cloudy')
elif s = 'Cloudy':
    print('Rainy')
elif s = 'Rainy':
    print('Sunny')
Problem p02910 (python)

Fixed submission:
S = list(map(str, input()))

bool = True
i = 0
while i != len(S):
    if i%2 == 0 and S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
        bool = True
        i += 1
    elif i%2 == 1 and S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
        bool = True
        i += 1
    else:
        bool = False
        i = len(S)
        
if bool:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = list(map(int, input()))
for i in range(len(s)):
    if i%2 == 0 and s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
        bool = True
    elif i%2 == 1 and s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
        bool = True
    else:
        bool = False
        break
        
if bool == True:
    print('Yes')
elif bool == False:
    print('No')
Problem p02922 (python)

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

s = a-1
t = b-1
ans = int((s+t-1)/s)
        
print(ans)

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

s = a-1
t = b-1
ans = int((s+t-1)/t)
        
print(ans)
Problem p02946 (python)

Fixed submission:
k, x = map(int, input().split())
l = []
for i in range(k):
    l.append(x+i)
    if i > 0:
        l.append(x-i)
l = sorted(l)
for j in range(2*k-1):
    print(l[j], end=" ")

Buggy submission (verdict: Runtime Error):
k, x = map(int, input().split())
ans = []
for i in range(N):
    ans.append(k-i)
for j in range(1, N, 1):
    ans.append(k+i)
ans = sorted(ans)
 
for k in ans:
    print(ans[k])

Buggy submission (verdict: Runtime Error):
k, x = map(int, input().split())
ans = []
for i in range(N):
  ans.append(k-i)
for j in range(1, N, 1):
  ans.append(k+i)
  
ans = sorted(ans)

for k in ans:
  print(ans[k])

Buggy submission (verdict: Runtime Error):
k, x = map(int, input().split())
l = []
for i in range(k):
    l.append(x+i)
    if i > 0:
        l.append(x-i)
l = sorted(l)
for j in range(10000):
    print(l[j], end=" ")
Problem p02952 (python)

Fixed submission:
N = int(input())

import math
ans = 0
for i in range(1, N+1, 1):
    order = int(math.log10(i))+1
    if order%2 == 1:
        ans += 1
    else:
        continue

print(ans)

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

ans = 0
for i in range(1, n+1):
  x = len(i)
  if x%2 == 1:
    ans += 1
    
print(ans)
Problem p02953 (python)

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

for i in range(N):
    H[i] -= 1

for j in range(N-1):
    if H[j] > H[j+1]:
        H[j+1] += 1

if H == sorted(H):
    print('Yes')
else:
    print('No')

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

for i in range(1, N):
    if H[i] > H[i+1]:
        H[i] -= 1

if H == sorted(H):
    print('Yes')
else:
    print('No')