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

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N - 1):
	for j in range(1, min(K + 1, N - i)):
		dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[N - 1])

Buggy submission (verdict: Runtime Error):
def chmin(a, b):
  if a > b:
    a = b

n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float(inf)]*n
dp[0] = 0
for i in range(n):
  for j in range(i+1, min(i+k, n-2)):
    chmin(dp[j], dp[i] + abs(h[j]-h[i]))
print(h[n-1])
Problem p03212 (python)

Fixed submission:
n = int(input())
from itertools import product
ans = 0
for i in range(1, 11):
  for p in product("357", repeat=i):
    v = "".join(p)
    if "3" in v and "5" in v and "7" in v and int("".join(p)) <= n:
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
from itertools import product
ans = 0
for i in range(1, 11):
  for p in product("357", repeat=i):
    v = "".join(p)
    if "3" in v and "5" in v and "7" in v and int("".join(p)) <= N:
      ans += 1
print(ans)
Problem p03238 (python)

Fixed submission:
n=int(input())
if n ==1:
    print("Hello World")
else:
    a=int(input())
    b=int(input())
    print(a+b)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=int(input())
b=int(input())
if n==1:
    print("Hello World")
else:
    print(a+b)
Problem p03241 (python)

Fixed submission:
n,m=map(int, input().split())
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
ans = 1
for i in make_divisors(m):
    if i>=n:
        ans=max(ans,m//i)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
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
ans = 1
for i in make_divisors:
    if i>=n:
        ans=max(ans,m//i)
print(ans)
Problem p03262 (python)

Fixed submission:
from fractions import gcd
n,x=map(int, input().split())
town=list(map(int, input().split()))+[x]
town.sort()
if n == 1:
    town.remove(x)
    print(abs(town[0]-x))
    exit()

d1 = abs(town[0]-town[1])
d2 = abs(town[1]-town[2])
ans = gcd(d1,d2)

for i in range(2,n):
    d = abs(town[i]-town[i+1])
    ans = gcd(d,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
n,x=map(int, input().split())
town=list(map(int, input().split()))+[x]
town.sort()
if n == 1:
    town.remove(x)
    print(abs(town[0]-x))
    exit()

d1 = abs(town[0]-town[1])
d2 = abs(town[1]-town[2])
ans = gcd(d1,d2)

for i in range(2,n):
    d = abs(town[i]-town[i+1])
    ans = gcd(d,ans)
print(ans)
Problem p03316 (python)

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

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

Fixed submission:
a,b,c,d=list(map(int,input().split()))
print(max([a*c,a*d,b*c,b*d]))

Buggy submission (verdict: Runtime Error):
a,b,c,d=int(input()),int(input()),int(input()),int(input())
x=range(a,b+1)
y=range(c,d+1)
i=0
J=0
list=[]
for i in x:
    for j in y:
        list.append(i*j)
        j=j+1
    i=i+1
print(max(list))
Problem p02842 (python)

Fixed submission:
import math
N=int(input())
a=math.ceil(N/(1.08))
if math.floor(a*1.08)==N:
        print(a)
else:
        print(':(')

Buggy submission (verdict: Runtime Error):
import math
N=float(input())
a=math.ceil(N/(1.08))
for i in range(a,N):
    if math.floor(i*1.08)==N:
        print(a)
        break
    else:
        print(':(')

Buggy submission (verdict: Runtime Error):
import math
N=float(input())
a=math.ceil(N/(1.08))
for i in range(a,N):
    if math.floot(i*1.08)==N:
        print(a)
        break
    else:
        print(':(')

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
a=math.ceil(N/(1.08))
for i in range(a,N):
    pass in range(a,N):
    if i==N:
        print(a)
        break
    else:
        print(':(')
Problem p02783 (python)

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

ans = (H + (A - 1)) // A

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]

max_damage = max(damage for damage, cost in magic)
dp = [0] * (H + max_damage)

for x in range(1, H + max_damage):
    dp[x] = min(dp[x - damage] + cost for damage, cost in magic)

ans = min(dp[H:])

print(ans)
Problem p02993 (python)

Fixed submission:
s = input()
msg = "Good"

for i in range(3):
    if s[i] == s[i + 1]:
        msg = "Bad"

print(msg)

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


a, b, c, d = map(int, input().split())


def lcm(x, y):
    # DeprecationWarning: fractions.gcd() is deprecated. Use math.gcd() instead.
    return x * y // fractions.gcd(x, y)


a1 = a - 1
div_a = (a1 // c) + (a1 // d) - (a1 // lcm(c, d))
div_b = (b // c) + (b // d) - (b // lcm(c, d))

print((b - a + 1) - (div_b - div_a))
Problem p02995 (python)

Fixed submission:
# import math
import fractions


a, b, c, d = map(int, input().split())


def lcm(x, y):
    # DeprecationWarning: fractions.gcd() is deprecated. Use math.gcd() instead.
    return x * y // fractions.gcd(x, y)


a1 = a - 1
div_a = (a1 // c) + (a1 // d) - (a1 // lcm(c, d))
div_b = (b // c) + (b // d) - (b // lcm(c, d))

print((b - a + 1) - (div_b - div_a))

Buggy submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())


def lcm(x, y):
    return x * y // math.gcd(x, y)


a1 = a - 1
div_a = (a1 // c) + (a1 // d) - (a1 // lcm(c, d))
div_b = (b // c) + (b // d) - (b // lcm(c, d))

print((b - a + 1) - (div_b - div_a))
Problem p03000 (python)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
cnt = 1

for i in range(n):
    d += l[i]
    if d > x:
        break
    else:
        cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
cnt = 0

while d <= x:
    d = d + l[cnt]
    cnt += 1

print(cnt)
Problem p03244 (python)

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


even = [0] * (10 ** 5)
odd = [0] * (10 ** 5)

for i in range(0, n, 2):
    even[v[i] - 1] += 1

for i in range(1, n, 2):
    odd[v[i] - 1] += 1

even_max = max(even)
odd_max = max(odd)

even_max_i = even.index(even_max)
odd_max_i = odd.index(odd_max)

if even_max_i == odd_max_i:
    even[even_max_i] = 0
    odd[odd_max_i] = 0

    even_max_2 = max(even)
    odd_max_2 = max(odd)

    ans = n - max(even_max + odd_max_2, even_max_2 + odd_max)
else:
    ans = n - (even_max + odd_max)

print(ans)

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

if len(set(v)) == 1:
    ans = n // 2
else:
    even = [0] * 10 ** 5
    odd = [0] * 10 ** 5

    for i in range(0, n, 2):
        even[v[i]] += 1

    for i in range(1, n, 2):
        odd[v[i]] += 1

    ans = n - max(even) - max(odd)

print(ans)
Problem p03359 (python)

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

print(a if a <= b else a - 1)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
K = int(input())

max_n = max(A, B, C)
print(sum([A, B, C]) + (2 ** K - 1) * max_n)
Problem p03425 (python)

Fixed submission:
N = int(input())

w = "MARCH"
count = {key: 0 for key in w}

for i in range(N):
    S = input()
    c = S[0]
    if c in w:
        count[c] += 1

ans = 0
M = len(w)

for i in range(M):
    for j in range(i + 1, M):
        for k in range(j + 1, M):
            ans += count[w[i]] * count[w[j]] * count[w[k]]

print(ans)

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

w = "MARCH"
count = {key: 0 for key in w}

for i in range(N):
    S = input()
    c = S[0]
    if c in w:
        count[c] += 1

ans = 0

for i in range(N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            ans += count[w[i]] * count[w[j]] * count[w[k]]

print(ans)
Problem p03607 (python)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

paper = {}

for a in A:
    paper.setdefault(a - 1, 0)
    paper[a - 1] += 1

ans = len(list(filter(lambda x: x % 2 == 1, paper.values())))
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

paper = [0] * 100000

for a in A:
    paper[a - 1] += 1

ans = len(list(filter(lambda x: x % 2 == 1, paper)))
print(ans)
Problem p02585 (python)

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

# D - Moving Piece
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

# 問題文とインデックスの位置を揃える
P.insert(0, 0)
C.insert(0, 0)

# マス目を周期ごとに分割する
groups = []
appeared = set()

for i in range(1, N + 1):
	if not i in appeared:
		group = []
		s = set()
		j = i

		while not j in s:
			group.append(j)
			s.add(j)
			appeared.add(j)
			j = P[j]

		groups.append(group)

MIN = -sys.maxsize
ans = MIN

# 周期ごとにハイスコアを算出
for group in groups:
	n = len(group)

	# スタート位置を1マスずつズラす
	for g in group:
		score = 0
		max_score = MIN
		scores = []
		scores.append(MIN)
		Pi = P[g]

		for j in range(n):
			score += C[Pi]
			max_score = max(max_score, score)
			scores.append(max_score)
			Pi = P[Pi]

		if K > n and score > 0:
			s = scores[K % n] + score * (K // n)
			ans = max(ans, s)

			s = max_score + score * (K // n - 1)
			ans = max(ans, s)
		elif K > n:
			ans = max(ans, max_score)
		else:
			ans = max(ans, scores[K])

print(ans)

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

# D - Moving Piece
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

# 問題文とインデックスの位置を揃える
P.insert(0, 0)
C.insert(0, 0)

# マス目を周期ごとに分割する
groups = []
appeared = set()

for i in range(1, N + 1):
	if not i in appeared:
		group = []
		s = set()
		j = i

		while not j in s:
			group.append(j)
			s.add(j)
			appeared.add(j)
			j = P[j]

		groups.append(group)

ans = -sys.maxsize

# 周期ごとにハイスコアを算出
for group in groups:
	# スタート位置を1マスずつズラす
	for g in group:
		score = 0
		max_score = -sys.maxsize
		scores = []
		scores.append(-sys.maxsize)
		Pi = P[g]

		for j in range(len(group)):
			score += C[Pi]
			max_score = max(max_score, score)
			scores.append(max_score)
			Pi = P[Pi]

		if K > N and score > 0:
			s = scores[K % len(group)] + score * (K // len(group))
			ans = max(ans, s)
		elif K > N:
			ans = max(ans, max_score)
		else:
			ans = max(ans, scores[K])

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

# D - Moving Piece
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

# 問題文とインデックスの位置を揃える
P.insert(0, 0)
C.insert(0, 0)

# マス目を周期ごとに分割する
groups = []
appeared = set()

for i in range(1, N + 1):
	if not i in appeared:
		group = []
		s = set()
		j = i

		while not j in s:
			group.append(j)
			s.add(j)
			appeared.add(j)
			j = P[j]

		groups.append(group)

ans = -sys.maxsize

# 周期ごとにハイスコアを算出
for group in groups:
	# スタート位置を1マスずつズラす
	for g in group:
		score = 0
		max_score = -sys.maxsize
		scores = []
		scores.append(-sys.maxsize)
		Pi = P[g]

		for j in range(len(group)):
			score += C[Pi]
			max_score = max(max_score, score)
			scores.append(max_score)
			Pi = P[Pi]

		if K > N and score > 0:
			s = scores[K % len(group)] + score * (K // len(group))
			ans = max(ans, s)
		elif K > N:
			ans = max(ans, max_score)
		else:
			ans = max(ans, scores[K])

print(ans)
Problem p02678 (python)

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

# D - .. (Double Dots)
from collections import deque
sys.setrecursionlimit(pow(10, 6))

def set_route(start, goal):
	global routes
	
	routes[goal].append(start)


def search(que):
	global routes
	global guides

	if len(que) > 0:
		goal = que.popleft()

		for start in routes[goal]:
			if guides[start] == 0:
				guides[start] = goal
				que.append(start)
		
		search(que)
	else:
		return 


n, m = map(int, input().split())
routes = dict()

# 空の辞書(routes)を作成
for i in range(1, n + 1):
	routes[i] = []

# すべての出入り口の情報を取得("routes"に保存)
for i in range(m):
	a, b = map(int, input().split())
	set_route(a, b)
	set_route(b, a)

# 道しるべ(最後に出力)を保存するためのリスト
guides = [0] * (n + 1)

que = deque()
que.append(1)
search(que)

ans = guides[2:]

if 0 in ans:
	print('No')
else:
	print('Yes')
	
	for a in ans:
		print(a)

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

# D - .. (Double Dots)
from collections import deque
sys.setrecursionlimit(pow(10, 5))

def set_route(start, goal):
	global routes
	
	routes[goal].append(start)


def search(que):
	global routes
	global guides

	if len(que) > 0:
		goal = que.popleft()

		for start in routes[goal]:
			if guides[start] == 0:
				guides[start] = goal
				que.append(start)
		
		search(que)
	else:
		return 


n, m = map(int, input().split())
routes = dict()

# 空の辞書(routes)を作成
for i in range(1, n + 1):
	routes[i] = []

# すべての出入り口の情報を取得("routes"に保存)
for i in range(m):
	a, b = map(int, input().split())
	set_route(a, b)
	set_route(b, a)

# 道しるべ(最後に出力)を保存するためのリスト
guides = [0] * (n + 1)

que = deque()
que.append(1)
search(que)

ans = guides[2:]

if 0 in ans:
	print('No')
else:
	print('Yes')
	
	for a in ans:
		print(a)

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

# D - .. (Double Dots)
from collections import deque

def set_route(start, goal):
	global routes
	
	routes[goal].append(start)


def search(que):
	global routes
	global guides

	if len(que) > 0:
		goal = que.popleft()

		for start in routes[goal]:
			if guides[start] == 0:
				guides[start] = goal
				que.append(start)
		
		search(que)
	else:
		return 


n, m = map(int, input().split())
routes = dict()

# 空の辞書(routes)を作成
for i in range(1, n + 1):
	routes[i] = []

# すべての出入り口の情報を取得("routes"に保存)
for i in range(m):
	a, b = map(int, input().split())
	set_route(a, b)
	set_route(b, a)

# 道しるべ(最後に出力)を保存するためのリスト
guides = [0] * (n + 1)

que = deque()
que.append(1)
search(que)

ans = guides[2:]

if 0 in ans:
	print('No')
else:
	print('Yes')
	
	for a in ans:
		print(a)
Problem p02690 (python)

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

# D - I hate Factorization
def meet_condition(i, j):
	pi = pows[i]
	pj = pows[j]
	
	if pi - pj == x:
		return i, j
	elif pi + pj == x:
		return i, -j


pows = []

for i in range(200):
	pows.append(pow(i, 5))

x = int(input())

for i in range(len(pows)):
	for j in range(len(pows)):
		if meet_condition(i, j) != None:
			a, b = meet_condition(i, j)
			print(a, b)
			exit()

Buggy submission (verdict: Runtime Error):
# D - I hate Factorization
def meet_condition(i, j):
	pi = pows[i]
	pj = pows[j]
	
	if pi - pj == x:
		return i, j
	elif pi + pj == x:
		return i, -j


pows = []

for i in range(100):
	pows.append(pow(i, 5))

x = int(input())

for i in range(len(pows)):
	for j in range(len(pows)):
		if meet_condition(i, j) != None:
			a, b = meet_condition(i, j)
			print(a, b)
			sys.exit()
Problem p02713 (python)

Fixed submission:
# C - Sum of gcd of Tuples (Easy)

import math

K = int(input())
ans = 0

for a in range(1, K + 1):
	for b in range(1, K + 1):
		for c in range(1, K + 1):
			ans += math.gcd(a, math.gcd(b, c))

print(ans)

Buggy submission (verdict: Runtime Error):
# C - Sum of gcd of Tuples (Easy)

import math

K = int(input())
ans = 0

for a in range(1, K + 1):
	for b in range(1, K + 1):
		ab = math.gcd(a, b)
		
		for c in range(1, K + 1):
			ans += math.gcd(ab, c))

print(ans)
Problem p02714 (python)

Fixed submission:
# D - RGB Triplets
	
N = int(input())
S = input()
	
r, g, b = 0, 0, 0
	
for s in S:
	if s == 'R':
		r += 1
	elif s == 'G':
		g += 1
	else:
		b += 1
	
ans = r * g * b
	
for i in range(N - 2):
	for j in range(i + 1, N - 1):
		k = j * 2 - i
			
		if k < N:
			if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
				if j -i == k -j:
					ans -= 1
	
print(ans)

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

# テストケースが複数行の場合、iOSだと一気に読み込んでしまう。
# 本番環境と同じ挙動になるように、
# iOSではテストケースをいったんテキストファイルにコピーして
# テキストファイルから input() する
if sys.platform == 'ios':
	sample = clipboard.get()
	file = open('input_file.txt', 'w')
	file.write(sample)
	file.close()
	sys.stdin = open('input_file.txt')
# -----------------------------
						

# D - RGB Triplets

N = int(input())
S = input()

r, g, b = 0, 0, 0

for s in S:
	if s == 'R':
		r += 1
	elif s == 'G':
		g += 1
	else:
		b += 1

ans = r * g * b

for i in range(N - 2):
	for j in range(i + 1, N - 1):
		for k in range(j + 1, N):
			if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
				if j -i == k -j:
					ans -= 1

print(ans)
Problem p02717 (python)

Fixed submission:
x, y, z = input().split()
print(z, x, y)

Buggy submission (verdict: Runtime Error):
import sys
#import clipboard

#if sys.platform == 'ios':
#	input = clipboard.get()
#else: 
	input = input()

arr = input.split()

X, Y, Z = arr
print(Z, X, Y)

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

if sys.platform == 'ios':
	input = clipboard.get()
else:
	input = input()

arr = input.split()

X, Y, Z = arr
print(Z, X, Y)
Problem p02797 (python)

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

# C - Subarray Sum
n, k, s = map(int, input().split())
ans = ''
str_s = str(s)

if s < pow(10, 9):
	str_another = str(s + 1)
else:
	str_another = '1'

for i in range(n):
	if i < k:
		ans += str_s + ' '
	else:
		ans += str_another + ' '

print(ans[:len(ans)-1])

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

# C - Subarray Sum
n, k, s = map(int, input().split())
ans = ''
str_s = str(s)

if s < pow(10, 9):
	str_another = str(s + 1)
else:
	str_another = 1

for i in range(n):
	if i < k:
		ans += str_s + ' '
	else:
		ans += str_another + ' '

print(ans[:len(ans)-1])
Problem p02854 (python)

Fixed submission:
# B - Iron Bar Cutting
N = int(input())
A = list(map(int, input().split()))

left = 0
right = sum(A)
ans = right

for a in A:
	left += a
	right -= a
	
	diff = abs(right - left)
	ans = min(ans, diff)
	
	if left > right:
		break

print(ans)

Buggy submission (verdict: Runtime Error):
# B - Iron Bar Cutting
N = int(input())
A = [map(int, input().split())]

left = 0
right = sum(A)
ans = right

for a in A:
	left += a
	right -= a
	
	diff = abs(right - left)
	ans = min(ans, diff)
	
	if left > right:
		break

print(ans)
Problem p02975 (python)

Fixed submission:
def get_caps(a):
  dic = dict()

  for ai in a:
    dic.setdefault(ai, 0)
    dic[ai] += 1

  return dic


def is_match(caps):
  global N

  if 0 in caps.keys():
    if caps[0] == N:
      return True
  
  if N % 3 == 0:
    if 0 in caps.keys() and len(caps) == 2:
      if caps[0] == N//3:
        return True
    elif len(caps) == 3:
      x, y, z = caps.keys()
    
      if x ^ y ^ z == 0:
        if caps[x] == caps[y] == caps[z] == N//3:
          return True


# A - XOR Circle
N = int(input())
a = list(map(int, input().split()))

# 帽子の情報をdictに入れる
caps = get_caps(a)

if is_match(caps):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
def get_caps(a):
  dic = dict()

  for ai in a:
    dic.setdefault(ai, 0)
    dic[ai] += 1

  return dic


def is_match(caps):
  global N

  if 0 in caps.keys():
    if caps[0] == N:
      return True
  
  if N % 3 == 0:
    if 0 in caps.keys() and len(caps) == 2:
      if caps[0] == N//3:
        return True
    elif len(caps) == 3:
      x, y, z = caps.keys()
    
      if x ^ y ^ z == 0:
        if caps[x] == caps[y] == caps[z] == N//3:
        return True


# A - XOR Circle
N = int(input())
a = list(map(int, input().split()))

# 帽子の情報をdictに入れる
caps = get_caps(a)

if is_match(caps):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
def get_caps(a):
  dic = dict()

  for ai in a:
    dic.setdefault(ai, 0)
    dic[ai] += 1

  return dic


def is_match(caps):
  global N

  if 0 in caps.keys():
    if caps[0] == N:
      return True
  
  if N % 3 == 0:
    if 0 in caps.keys() and len(caps) == 2:
      if caps[0] == M//3:
        return True
    elif len(caps) == 3:
      x, y, z = caps.keys()
    
      if x ^ y ^ z == 0:
        return True


# A - XOR Circle
N = int(input())
a = list(map(int, input().split()))

# 帽子の情報をdictに入れる
caps = get_caps(a)

if is_match(caps):
  print('Yes')
else:
  print('No')
Problem p03150 (python)

Fixed submission:
# B - KEYENCE String
def is_keyence_string():
	for i in range(1, len(key)):
		left = key[:i]
		right = key[i-len(key):]
		
		if S.startswith(left) and S.endswith(right):
			return True
	
	return False


S = input().strip()
key = 'keyence'

if S.startswith(key):
	print('YES')
elif S.endswith(key):
	print('YES')
elif is_keyence_string():
	print('YES')
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
# B - KEYENCE String
def is_keyence_string():
	for i in range(1, len(key)):
		left = key[:i]
		right = key[i-len(key):]
		
		if S.startswith(left) and S.endswith(right):
			return True
	
	return False


S = input().trim()
key = 'keyence'

if S.startswith(key):
	print('YES')
elif S.endswith(key):
	print('YES')
elif is_keyence_string():
	print('YES')
else:
	print('NO')

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

# B - KEYENCE String
def is_keyence_string():
	i = 0

	for s in S:
		if s == key[i]:
			i += 1
			if i == len(key) and S.endswith('e'):
				return True

	return False


S = input()
key = 'keyence'

if S.find(key) > -1:
	print('YES')
elif is_keyence_string():
	print('YES')
else:
	print('NO')
Problem p03427 (python)

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

# A - Digit Sum 2
def digit_sum(str_num):
	sum = 0	
	
	for i in range(len(str_num)):
		sum += int(str_num[i])
	
	return sum


N = input()
patterns = [N]

for i in range(len(N)-1):
	if N[i] != '0':
		left, right = '', ''  
				
		if i > 0:
			left = N[:i]
		
		n = int(N[i]) - 1
		
		if i < len(N) - 1:
			right = '9' * (len(N)-i-1) 
		
		patterns.append(left + str(n) + right)

ans = 0

for p in patterns:
	ans = max(ans, digit_sum(p))
	
print(ans)

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

# A - Digit Sum 2
def digit_sum(str_num):
	sum = 0	
	
	for i in range(len(str_num)):
		sum += int(str_num[i])
	
	return sum


N = input()
patterns = [N]

for i in range(len(N)-1):
	if N[i] != '0':
		left, right = '', ''  
				
		if i > 0:
			left = N[:i]
		
		n = int(N[i]) - 1
		
		if i < len(N) - 1:
			right = '9' * (len(N)-i-1) 
		
		patterns.append(left + str(n) + right)

ans = 0

for p in patterns:
	ans = max(ans, digit_sum(p))
	
print(ans)
Problem p03494 (python)

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

while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
# B - Shift Only
import sys
import clipboard

# テストケースが複数行の場合、iOSだと一気に読み込んでしまうので
# 1行ずつ読み込むように、テキストファイルにいったんコピーする
if sys.platform == 'ios':
	sample = clipboard.get()
	file = open('input_file.txt', 'w')
	file.write(sample)
	file.close()
	sys.stdin = open('input_file.txt')
		
						
input()
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    count += 1
print(count)