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

Fixed submission:
# https://img.atcoder.jp/abc138/editorial.pdf
# https://www.youtube.com/watch?v=lWETOlGiuaI
# このコードは公式解説動画をまんまpythonにしたものです。

# 解説動画
# s = abacaababc (10文字)の場合は
# a: [0, 2, 4, 5, 7, 10, 12, 14, 15, 17]
# b: [1, 6, 8, 11, 16, 18]
# c: [3, 9, 13, 19]
# という二重配列をまず作る。

# 例えばt = 'bbcca'だと
# 現在位置0、bを探す→1
# 現在位置1、bを探す→6
# 現在位置6、cを探す→9
# 現在位置9、cを探す→13(3に戻す)
# 現在位置3、aを探す→4
# で答えは14。


# 解説pdf曰く：
# next(ch, i):=「s'のi文字目以降で文字種chが最初に現れる位置」を
# をO(文字種数×|S|)かけて事前に全て求める

# 文字の先頭に戻る可能性があるので、2回連結しておくと処理が楽になる

from bisect import bisect_left

s = input()
t = input()
n = len(s)
m = len(t)

index_list = [[] for _ in range(26)]

for i in range(n):
    index_list[ord(s[i]) - ord('a')].append(i)
for i in range(n):
    index_list[ord(s[i]) - ord('a')].append(i+n)

p = 0  # p以降
ans = 0
for j in range(m):
    ch = ord(t[j]) - ord('a')
    if len(index_list[ch]) == 0:
        # t内に出現する文字が、sに全く登場しないので、不可
        print(-1)
        exit()
    next_pos = bisect_left(index_list[ch], p)
    p = index_list[ch][next_pos] + 1
    if p >= n:
        p -= n
        ans += n
    # print(p)

ans += p
print(ans)

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

len_s = len(s)
dp = [[-1 for _ in range(len_s)] for _ in range(26)]
# dp[i][j] = いまsのj文字目にいる。次に探しているのはアルファベットのi文字目であるとき、次までの必要文字数。
# print(len(dp))
# print(len(dp[0]))

for idx in range(len_s):

	ch = s[idx]
	i = ord(ch)-ord("a")
#	for j in range(len_s):
	if dp[i][0] == -1:
		dp[i] = [idx] * len_s
	else:
		temp = dp[i][j]
		dp[i][temp+1:idx] = idx

ans = 0
j = 0
first = True
for ch in t:

	i = ord(ch)-ord("a")

	if dp[i][j] < 0:
		print(-1)
		exit()

	distance = dp[i][j] - j
	if (not first )and distance <= 0 :
		distance += len_s
	ans += distance
	j = dp[i][j]

	first = False

print(ans + 1)
Problem p02999 (python)

Fixed submission:
x, a = list(map(int, input().split()))
if x < a:
  print (0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
x, a = list(map(inte, input().split()))
if x < a:
  print (0)
else:
  print(10)
Problem p03029 (python)

Fixed submission:
a, b = list(map(int, input().split()))
print((a*3+b)//2)

Buggy submission (verdict: Runtime Error):
a, b = list(map(int, input().split()))
print((a*3+p)//2)
Problem p03044 (python)

Fixed submission:
# 木の深さ優先探索
import sys

sys.setrecursionlimit(100000+10)


def add_edge(u, v, distance ):
	G[u].append([v, distance])
	G[v].append([u, distance])

def dfs(vertex, distance_from_start):
	global colors

	colors[vertex] = distance_from_start % 2

	for info in G[vertex]:
		v = info[0]
		if colors[v] >= 0: 
			#探索済み
			pass
		else:
			dfs(v, distance_from_start + info[1])

n = int(input())
edges = [list(map(int, input().split())) for _ in range(n-1)]

G = [[] for _ in range(n)] #グラフの隣接リスト表現
for edge in edges:
	add_edge(edge[0]-1, edge[1]-1, edge[2])

colors = [-1] * n
colors[0] = 0

dfs(0, 0)

for i in range(n):
	print(colors[i])

Buggy submission (verdict: Runtime Error):
# 木の深さ優先探索

def add_edge(u, v, distance ):
	G[u].append([v, distance])
	G[v].append([u, distance])

def dfs(vertex, distance_from_start):
	global colors

	colors[vertex] = distance_from_start % 2

	for info in G[vertex]:
		v = info[0]
		if colors[v] >= 0: 
			#探索済み
			pass
		else:
			dfs(v, distance_from_start + info[1])

n = int(input())
edges = [list(map(int, input().split())) for _ in range(n-1)]

G = [[] for _ in range(n)] #グラフの隣接リスト表現
for edge in edges:
	add_edge(edge[0]-1, edge[1]-1, edge[2])

colors = [-1] * n
colors[0] = 0

dfs(0, 0)

for i in range(n):
	print(colors[i])

Buggy submission (verdict: Runtime Error):
# 木の深さ優先探索

def add_edge(u, v, distance ):
	G[u].append([v, distance])
	G[v].append([u, distance])

def dfs(vertex, distance_from_start):
	global colors

	colors[vertex] = distance_from_start % 2

	for info in G[vertex]:
		v = info[0]
		if colors[v] >= 0: 
			#探索済み
			pass
		else:
			dfs(v, distance_from_start + info[1])


n = int(input())
edges = [list(map(int, input().split())) for _ in range(n-1)]

G = [[] for _ in range(n)] #グラフの隣接リスト表現
for edge in edges:
	add_edge(edge[0]-1, edge[1]-1, edge[2])

colors = [-1] * n
colors[0] = 0

dfs(0, 0)

for i in range(n):
	print(colors[i])
Problem p03063 (python)

Fixed submission:
N = int(input())
S = input()

# 白→黒　が許容される状態

ans = N + 1

# 所与→全黒
ans = S.count(".")
prev = ans

for i in range(N):
	if S[i] == "#":
		now = prev + 1
	else:
		now = prev - 1


	if now < ans:
		ans = now
	prev = now

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
mod = 998244353
# DP ナップサックぽいやつ
# DP[i][j] := a_0からa_iまでの部分集合で和がjになるものの個数
# 配るDPの方が場合分けがなくて簡潔に書ける 計算量増えるかも
# DP[i-1][j]→DP[i][j]とDP[i][j + a_i ]に配る

aaa = [int(input()) for _ in range(N)]
sum_aaa = sum(aaa)

sum_now = 0
DP = [[0] * (sum_aaa+1) for i in range(N)]
DP2 = [[0] * (sum_aaa+1) for i in range(N)]

a = aaa[0]
DP[0][0] = 2
DP[0][a] = 1

DP2[0][0] = 1
DP2[0][a] = 1

sum_now += a

for i in range(1, N):
	a = aaa[i]
	sum_now += a
	for j in range(sum_now + 1):

		if (j >= a):
			DP[i][j] = DP[i-1][j]*2 + DP[i-1][j-a]
		else:
			DP[i][j] = DP[i-1][j]*2

		while (DP[i][j] > mod):
			DP[i][j] -= mod

	for j in range(min(sum_now + 1, int(sum_aaa /2)+1)):
		if (j >= a):
			DP2[i][j] = DP2[i-1][j] + DP2[i-1][j-a]
		else:
			DP2[i][j] = DP2[i-1][j]

		while (DP2[i][j] > mod):
			DP2[i][j] -= mod

# print(DP2)
minimum_invalid_length = int((sum_now+1)//2)
num_too_long = sum (DP[N-1][minimum_invalid_length:])
if (sum_aaa %2 == 0):
	num_too_long -= DP2[N-1][int(sum_aaa /2)]
# print(num_too_long)
# print(sum(aaa))
print((3** N - num_too_long * 3) % mod )
Problem p03064 (python)

Fixed submission:
N = int(input())
mod = 998244353
# DP ナップサックぽいやつ
# DP[i][j] := a_0からa_iまでの部分集合で和がjになるものの個数
# 配るDPの方が場合分けがなくて簡潔に書ける 計算量増えるかも
# DP[i-1][j]→DP[i][j]とDP[i][j + a_i ]に配る

aaa = [int(input()) for _ in range(N)]
sum_aaa = sum(aaa)

sum_now = 0
DP = [[0] * (sum_aaa+1) for i in range(N)]
DP2 = [[0] * (sum_aaa+1) for i in range(N)]

a = aaa[0]
DP[0][0] = 2
DP[0][a] = 1

DP2[0][0] = 1
DP2[0][a] = 1

sum_now += a

for i in range(1, N):
	a = aaa[i]
	sum_now += a
	for j in range(sum_now + 1):

		if (j >= a):
			DP[i][j] = DP[i-1][j]*2 + DP[i-1][j-a]
		else:
			DP[i][j] = DP[i-1][j]*2

		while (DP[i][j] > mod):
			DP[i][j] -= mod

	for j in range(min(sum_now + 1, int(sum_aaa /2)+1)):
		if (j >= a):
			DP2[i][j] = DP2[i-1][j] + DP2[i-1][j-a]
		else:
			DP2[i][j] = DP2[i-1][j]

		while (DP2[i][j] > mod):
			DP2[i][j] -= mod

# print(DP2)
minimum_invalid_length = int((sum_now+1)//2)
num_too_long = sum (DP[N-1][minimum_invalid_length:])
if (sum_aaa %2 == 0):
	num_too_long -= DP2[N-1][int(sum_aaa /2)]
# print(num_too_long)
# print(sum(aaa))
print((3** N - num_too_long * 3) % mod )

Buggy submission (verdict: Runtime Error):
N = int(input())
mod = 998244353
# DP ナップサックぽいやつ
# DP[i][j] := a_0からa_iまでの部分集合で和がjになるものの個数
# 配るDPの方が場合分けがなくて簡潔に書ける 計算量増えるかも
# DP[i-1][j]→DP[i][j]とDP[i][j + a_i ]に配る

aaa = [int(input()) for _ in range(N)]

sum_now = 0
DP = [[0] * (sum(aaa)+1) for i in range(N)]
DP2 = [[0] * (sum(aaa)+1) for i in range(N)]

a = aaa[0]
DP[0][0] = 2
DP[0][a] = 1

DP2[0][0] = 1
DP2[0][a] = 1

sum_now += a

for i in range(1, N):
	a = aaa[i]
	for j in range(sum(aaa)):
		DP[i][j] += DP[i-1][j] * 2
		DP[i][j] %= mod
		DP[i][j + a] += DP[i-1][j]

		DP2[i][j] += DP2[i-1][j]
		DP2[i][j] %= mod
		DP2[i][j + a] += DP2[i-1][j]

	sum_now += a

# print(DP2)
minimum_invalid_length = int((sum_now+1)//2)
num_too_long = sum (DP[N-1][minimum_invalid_length:])
if (sum(aaa) %2 == 0):
	num_too_long -= DP2[N-1][int(sum(aaa) /2)]
# print(num_too_long)
# print(sum(aaa))
print((3** N - num_too_long * 3) % mod )
Problem p03067 (python)

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

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

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

end = []
start = []

if s[0] == "1":
	start.append(0)
else:
	#仮想的な1の区間を作る
	start.append(0)
	end.append(0)

for i in range(n-1):
	if s[i] == "1" and s[i+1] == "0":
		end.append(i)
for i in range(1, n):
	if s[i-1] == "0" and s[i] == "1":
		start.append(i)

if s[-1] == "1":
	end.append(n-1)
else:
	#仮想的な1の区間を作る
	start.append(n-1)
	end.append(n-1)

ans = 0

"""print(start, end, ans)
print(len(start), len(end), ans)"""

for j in range(len(start) - k):
	temp = end[j+k] - start[j] + 1 
	if temp > ans:
		ans = temp

if len(start) <= k:
	ans = n

print(ans)

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

end = []
start = []

if s[0] == "1":
	start.append(0)
	end.append(0)
else:
	#仮想的な1の区間を作る
	start.append(0)
	end.append(0)

for i in range(1, n-1):
	if s[i-1] == "0" and s[i] == "1":
		start.append(i)
	if s[i] == "1" and s[i+1] == "0":
		end.append(i)

if s[-1] == "1":
	start.append(n-1)
	end.append(n-1)
else:
	#仮想的な1の区間を作る
	start.append(n-1)
	end.append(n-1)

ans = 0

"""print(start, end, ans)
print(len(start), len(end), ans)
"""
for j in range(len(start) - k):
	temp = end[j+k] - start[j] + 1 
	if temp > ans:
		ans = temp

if len(start) <= k:
	ans = n

print(ans)

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

end = []
start = []

if s[0] == "1":
	start.append(0)
else:
	#仮想的な1の区間を作る
	start.append(0)
	end.append(0)


for i in range(1, n-1):
	if s[i-1] == "0" and s[i] == "1":
		start.append(i)
	if s[i] == "1" and s[i+1] == "0":
		end.append(i)

if s[-1] == "1":
	end.append(n-1)
else:
	#仮想的な1の区間を作る
	start.append(n-1)
	end.append(n-1)

ans = 0
for j in range(len(start) - k):
	temp = end[j+k] - start[j] + 1 
	if temp > ans:
		ans = temp

if len(start) <= k:
	ans = n

print(ans)
Problem p03079 (python)

Fixed submission:
a,b,c =  map(int, input().split())
if a== b and b == c:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c =  map(int, input().split())
if a== b and b == c:
  print(Yes)
else:
  print(No)
Problem p03157 (python)

Fixed submission:
# 幅優先探索か深さ優先探索で、上下左右の隣接と異なる色ならば、連続する1つの領域とする
# 各領域ごとに、白マス数×黒マス数を計算し、その合計が答え

h, w = list(map(int, input().split()))
masu = [input() for _ in range(h)]
visited = [[False for _ in range(w)] for _ in range(h)]
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]

# とりあえず周囲の番兵は使わずに書いてみよう……

# 再帰関数の呼び出し回数が多くなる時はこれが必要！！無いとruntime errorになる。
import sys
sys.setrecursionlimit(400*400 + 10)

def dfs(hi, wi, white, black):
    global colors
    global dx, dy
    global visited

    # print(hi, wi)

    visited[hi][wi] = True
    if masu[hi][wi] == '.':
        white += 1
    if masu[hi][wi] == '#':
        black += 1

    for neighbor in zip(dx, dy):
        h_new = hi + neighbor[0]
        w_new = wi + neighbor[1]
        # print("new: " , h_new, w_new)
        if 0 <= h_new <= h-1 and 0 <= w_new <= w-1:
            if not visited[h_new][w_new]:
                if masu[hi][wi] != masu[h_new][w_new]:
                    white, black = dfs(h_new, w_new, white, black)
    
    return white, black

ans = 0
for hi in range(h):
    for wi in range(w):
        if not visited[hi][wi]:
            white, black = dfs(hi, wi, 0, 0)
            ans += white * black

print(ans)

Buggy submission (verdict: Runtime Error):
# 幅優先探索か深さ優先探索で、上下左右の隣接と異なる色ならば、連続する1つの領域とする
# 各領域ごとに、白マス数×黒マス数を計算し、その合計が答え

h, w = list(map(int, input().split()))
masu = [input() for _ in range(h)]
visited = [[False for _ in range(w)] for _ in range(h)]
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]

# とりあえず周囲の番兵は使わずに書いてみよう……

# 再帰関数の呼び出し回数が多くなる時はこれが必要！！無いとruntime errorになる。
import sys
sys.setrecursionlimit(10)

def dfs(hi, wi, white, black):
    global colors
    global dx, dy
    global visited

    # print(hi, wi)

    visited[hi][wi] = True
    if masu[hi][wi] == '.':
        white += 1
    if masu[hi][wi] == '#':
        black += 1

    for neighbor in zip(dx, dy):
        h_new = hi + neighbor[0]
        w_new = wi + neighbor[1]
        # print("new: " , h_new, w_new)
        if 0 <= h_new <= h-1 and 0 <= w_new <= w-1:
            if not visited[h_new][w_new]:
                if masu[hi][wi] != masu[h_new][w_new]:
                    white, black = dfs(h_new, w_new, white, black)
    
    return white, black

ans = 0
for hi in range(h):
    for wi in range(w):
        if not visited[hi][wi]:
            white, black = dfs(hi, wi, 0, 0)
            ans += white * black

print(ans)
Problem p03262 (python)

Fixed submission:
# import math
import fractions
n, start = list(map(int, input().split()))
x = list(map(int, input().split()))

ans = abs(start - x[0])
for i in range(1, n):
	dist = abs(start - x[i])
	# ans = math.gcd(ans, dist)
	# Python 3.5以上では正解になるはずだが、AtCoderでは3.4.3なのでmath.gcdが使えず、ランタイムエラーになる
	# 3.4以前ではfractions.gcdを使う必要がある。fractions.gcdは3.5以降では非推奨である
	ans = fractions.gcd(ans, dist)
print(ans)

Buggy submission (verdict: Runtime Error):
import math

n, start = list(map(int, input().split()))
x = list(map(int, input().split()))

ans = abs(start - x[0])
for i in range(1, n):
	dist = abs(start - x[i])
	ans = math.gcd(ans, dist)
print(ans)
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())
l = len(s)

first = ''
pos = l
for i in range(l):
	if s[i] != '1':
		first = s[i]
		pos = i
		break

print('1' if k <= pos else first)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
l = len(s)

first = ''
for i in range(l):
	if s[i] != '1':
		first = s[i]
		pos = i
		break

print('1' if k <= pos else first)
Problem p03361 (python)

Fixed submission:
h, w = list(map(int, input().split() ))

s = []
s.append("." * (w+2)) 
for _ in range(h):
	s.append("." + input() + ".")
s.append("." * (w+2)) 

ans = "Yes"
dx = [-1, 0, 1, 0]
dy = [ 0, 1, 0,-1]

for i in range(1, h+1):
	for j in range(1, w+1):
		if s[i][j] == "#":
			CanPaint = False
			for k in range(4):
				if s[i+dx[k]][j+dy[k]] == "#":
					CanPaint = True
			if not CanPaint:
				ans = "No"

print(ans)

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

s = []
s.append("." * (w+2)) 
for _ in range(h):
	s.append("." + input() + ".")
s.append("." * (w+2)) 

ans = "Yes"
dx = [-1, 0, 1, 0]
dy = [ 0, 1, 0,-1]

for i in range(1, h+1):
	for j in range(1, h+1):
		if s[i][j] == "#":
			CanPaint = False
			for k in range(4):
				if s[i+dx[k]][j+dy[k]] == "#":
					CanPaint = True
			if not CanPaint:
				ans = "No"

print(ans)

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

s = []
s.append("." * (w+2)) 
for _ in range(h):
	s.append("." + input() + ".")
s.append("." * (w+2)) 

ans = "Yes"
dx = [-1, 0, 1, 0]
dy = [ 0, 1, 0,-1]

for i in range(1, h+1):
	for j in range(1, h+1):
		if s[i][j] == "#":
			CanPaint = False
			for k in range(4):
				if s[i+dx[k]][j+dy5 5
#.#.#
.#.#.
#.#.#
.#.#.
#.#.#[k]] == "#":
					CanPaint = True
			if not CanPaint:
				ans = "No"

print(ans)
Problem p03463 (python)

Fixed submission:
n, a, b = list(map(int, input().split()))
print("Borys" if (b - a) % 2 == 1 else "Alice")

Buggy submission (verdict: Runtime Error):
n, a, b = list(map(int(), input().split()))
print("Borys" if (b - a) % 2 == 1 else "Alice")
Problem p03566 (python)

Fixed submission:
n = int(input())

tt = list(map(int, input().split()))
v = list(map(int, input().split()))

time = sum(tt);
INF = 999999
border = [0] *(n+1)
start_v = [0] *(n+1)
end_v = [0] *(n+1)

temp = 0
for i in range(n):
	temp += tt[i]
	border[i+1] = temp
	start_v[i] = v[i]
	end_v[i+1] = v[i]

t = 0
idx = 0
ans = 0
vlast = 0
v0 = 0
new_interval = False
limitation_front =0 # 最初の計算に必要

# print (border)
while t < time :
	t += 0.5
	new_interval = False

	#直接制約
	v0 = v[idx]
	if t == border[idx+1]:
		idx += 1
		new_interval = True
#		v0 = min(v0, v[idx])

	if(not new_interval):
		limitation_front += 0.5
		if v0 > limitation_front:
			v0 = limitation_front
	
	if new_interval: 
		limitation_front = INF
		for j in range(n+1):
			if border[j] <= t:
				#前の時刻からの制約
				temp = end_v[j] + (t - border[j])
				if v0 > temp:
					v0 = temp
				if limitation_front > temp:
					limitation_front = temp
			else:
				break
			#print (limitation_front)


	for j in range(n+1):
		if border[j] >= t:
			#後ろの時刻からの制約
			temp = start_v[j] + (border[j] - t)
			if v0 > temp:
				v0 = temp

	#print(v0)

#	ans += 0.5 * (vlast + v0) / 2
	ans += (vlast + v0)
	vlast = v0

ans /= 4.0
print (ans)

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

tt = list(map(int, input().split()))
v = list(map(int, input().split()))

time = sum(tt);

border = [0] *(n+1)
start_v = [0] *(n+1)
end_v = [0] *(n+1)

temp = 0
for i in range(n):
	temp += tt[i]
	border[i+1] = temp
	start_v[i] = v[i]
	end_v[i+1] = v[i]

t = 0
idx = 0
ans = 0
vlast = 0
v0 = 0

# print (border)
while t < time :
	t += 0.5
	
	# tle回避
	if t < border[idx+1] and abs(v0- (vlast-0.5) ) < 0.001:
		v0 = vlast - 0.5
		ans += 0.5 * (vlast + v0) / 2
		vlast = v0
		continue

 	vlast = v0

	#直接制約
	v0 = v[idx]
	if t == border[idx+1]:
		idx += 1
#		v0 = min(v0, v[idx])

	for j in range(n+1):
		
		if border[j] <= t:
			#前の時刻からの制約
			temp = end_v[j] + (t - border[j])
			if v0 > temp:
				v0 = temp
		if border[j] >= t:
			#後ろの時刻からの制約
			temp = start_v[j] + (border[j] - t)
			if v0 > temp:
				v0 = temp

#	print(v0)

	# ans += 0.5 * (vlast + v0) / 2
	ans += 0.5 * (vlast + v0) / 2
# 	vlast = v0

print (ans)
Problem p03695 (python)

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

num_free = 0
num_color = [False] * 8
for rate in nums:
    if rate < 3200:
        num_color[rate // 400] = True
    else:
        num_free += 1

ans = sum(num_color)
print('{} {}'.format(max(ans, 1), ans + num_free))

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

num_free = 0
num_color = [False] * 8
for rate in nums:
    if rate < 3200:
        num_color(rate // 400) = True
    else:
        num_free += 1

ans = sum(num_color)
print('{} {}'.format(ans, ans + num_free))
Problem p03815 (python)

Fixed submission:
# 6, 5, 6, 5, ...

x = int(input())
q = x // 11
r = x % 11
if r == 0:
    ans = q * 2
elif 1 <= r <= 6:
    ans = q * 2 + 1
elif 7 <= r <= 10:
    ans = q * 2 + 2
print(ans)

Buggy submission (verdict: Runtime Error):
# 6, 5, 6, 5, ...

x = int(input())
q = x // 11
r = x % 11
if r == 0:
    ans = q * 2
elif 1 <= r <= 5:
    ans = q * 2 + 1
elif 6 <= ans <= 10:
    ans = q * 2 + 2
print(ans)
Problem p03958 (python)

Fixed submission:
k, t = list(map(int, input().split()))
nums = list(map(int, input().split()))

m = max(nums)
rest = k - m
if m - rest - 1 > 0:
    print(m - rest - 1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
k, t = list(map(int, input().split()))
nums = list(map(int, input().split()))

m = max(nums)
rest = k - m
if max - rest - 1 > 0:
    print(max - rest - 1)
else:
    print(0)
Problem p02553 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# map(int, input().split())
a,b,c,d = list(map(int, input().split()))
 
max_value = max([a*c,a*d,b*c,b*d])

print(max_value)

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

max_value = 0
for i in range(len(lst)):
  for j in range(i):
    max_value = max(max_value, lst[i]*lst[j])

print(max_value)
Problem p02645 (python)

Fixed submission:
# -*- coding: utf-8 -*-
s = input()
print(s[0:3])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
s = input()

return s[0:3]
Problem p02657 (python)

Fixed submission:
# -*- coding: utf-8 -*-
A, B = map(int, input().split())

print(A*B)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A, B = map(int, input().split())

return(A*B)
Problem p02727 (python)

Fixed submission:
# -*- coding: utf-8 -*-
X, Y, A, B, C = map(int, input().split())
red_oishisa = list(map(int, input().split()))
green_oishisa = list(map(int, input().split()))
no_oishisa = list(map(int, input().split()))

red_oishisa = list(sorted(red_oishisa))[::-1]
green_oishisa = list(sorted(green_oishisa))[::-1]
no_oishisa = list(sorted(no_oishisa))[::-1]

oishisa_s = []

i=1
j=1
k=1
while(True):
    if len(oishisa_s) == X+Y:
        break
    
    hikaku_dict = dict()
    if i <= X:
        hikaku_dict['red'] = red_oishisa[i-1]
    if j <= Y:
        hikaku_dict['green'] = green_oishisa[j-1]
    if k <= C:
        hikaku_dict['no'] = no_oishisa[k-1]
    
    max_key, max_value = max(hikaku_dict.items(), key=lambda x:x[1])
    oishisa_s.append(max_value)
    if max_key == 'red':
        i += 1
    elif max_key == 'green':
        j += 1
    elif max_key == 'no':
        k += 1

print(sum(oishisa_s))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
X, Y, A, B, C = map(int, input().split())
red_oishisa = list(map(int, input().split()))
green_oishisa = list(map(int, input().split()))
no_oishisa = list(map(int, input().split()))

red_oishisa = list(sorted(red_oishisa))[::-1]
green_oishisa = list(sorted(green_oishisa))[::-1]
no_oishisa = list(sorted(no_oishisa))[::-1]

eat_oishisas_red = red_oishisa[:X]
eat_oishisas_green = green_oishisa[:Y]

i=1
j=1
k=1
while(True):
    if i > A:
        break
    elif j > B:
        break
    elif k > C:
        break
    elif min([eat_oishisas_red[-i], eat_oishisas_green[-j]]) > no_oishisa[k-1]:
        break

    if eat_oishisas_red[-i] <= eat_oishisas_green[-j]:
        eat_oishisas_red[-i] = no_oishisa[k-1]
        i += 1
    else:
        eat_oishisas_green[-j] = no_oishisa[k-1]
        j += 1
    k += 1

print(sum(eat_oishisas_green) + sum(eat_oishisas_red))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
X, Y, A, B, C = map(int, input().split())
red_oishisa = list(map(int, input().split()))
green_oishisa = list(map(int, input().split()))
no_oishisa = list(map(int, input().split()))

red_oishisa = list(sorted(red_oishisa))[::-1]
green_oishisa = list(sorted(green_oishisa))[::-1]
no_oishisa = list(sorted(no_oishisa))[::-1]

eat_oishisas_red = red_oishisa[:X]
eat_oishisas_green = green_oishisa[:Y]

i=1
j=1
k=1
while(True):
    if i > A:
        break
    elif j > B:
        break
    elif k > C:
        break
    elif min([eat_oishisas_red[-i], eat_oishisas_green[-j]]) >= no_oishisa[k-1]:
        break

    if eat_oishisas_red[-i] <= eat_oishisas_green[-j]:
        eat_oishisas_red[-i] = no_oishisa[k-1]
        i += 1
    else:
        eat_oishisas_green[-j] = no_oishisa[k-1]
        j += 1
    k += 1

print(sum(eat_oishisas_green) + sum(eat_oishisas_red))
Problem p02683 (python)

Fixed submission:
import numpy as np
N,M,X = map(int,input().split())
C = []
A = []
for _ in range(N):
    l = list(map(int,input().split()))
    C.append(l[0])
    A.append(np.array(l[1:]))
ans = 10**100
for i in range(2**N):
    rikaido = np.zeros(M)
    c = 0
    for j in range(N):
        if (i >> j) & 1:
            c += C[j]
            rikaido += A[j]
    if all([x >= X for x in rikaido]):
        ans = min(ans, c)
print(ans if ans != 10**100 else -1)

Buggy submission (verdict: Runtime Error):
C = []
A = []
for _ in range(N):
    l = list(map(int,input().split()))
    C.append(l[0])
    A.append(np.array(l[1:]))
ans = 10**100
for i in range(2**N):
    rikaido = np.zeros(M)
    c = 0
    for j in range(N):
        if (i >> j) & 1:
            c += C[j]
            rikaido += A[j]
    if all([x >= X for x in rikaido]):
        ans = min(ans, c)
print(ans if ans != 10**100 else -1)
Problem p02789 (python)

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

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
print("Yes" N==M else "No")
Problem p02838 (python)

Fixed submission:
import sys
stdin = sys.stdin
 
mod = 10**9 + 7
 
def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))
 
def main():
    n = ni()
    a = na()
    ans = 0
    for i in range(61):
        cnt = 0
        for ai in a:
            if (ai >> i) & 1:
                cnt += 1
        ans += ((cnt * (n - cnt)) * 2**i) % mod
    ans %= mod
    print(ans)
 
 
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from math import log2,floor
N = int(input())
A = list(map(int,input().split()))
L = max([floor(log2(x)) for x in A])+1
bits = [0]*L
for x in A:
    for i in range(L):
        if (x>>i)&1:
            bits[i] += 1
mod = 10**9+7
ans = 0
for i in range(L):
    b = bits[i]
    ans = (ans+b*(N-b)*(2**i))%mod
print(ans)