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

Fixed submission:
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]

def check(string):
    for s, c in SC:
        if string[s - 1] != str(c):
            return False
    return True 

if N == 1:
    for i in range(10 ** 1):
        if check(str(i)):
            print (i)
            exit()
    print (-1)
    exit()
else:
    for i in range(10 ** (N - 1), 10 ** (N)):
        if check(str(i)):
            print (i)
            exit()
    print (-1)
    exit()

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]



def check(string):
    for s, c in SC:
        if string[s - 1] != str(c):
            return False
    return True 



if N == 1:
    for i in range(10 ** i):
        if check(str(i)):
            print (i)
            exit()
    print (-1)
    exit()
else:
    for i in range(10 ** (N - 1), 10 ** (N)):
        if check(str(i)):
            print (i)
            exit()
    print (-1)
    exit()
Problem p02782 (python)

Fixed submission:
r1, c1, r2, c2 = map(int, input().split())
MOD = 10 **9 + 7

ans = 0

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

F = Factorial(r2 + c2 + 3, MOD)

ans = F.comb(c1 + r1, c1) - F.comb(c1 + r2 + 1, c1) - F.comb(c2 + r1 + 1, c2 + 1) + F.comb(c2 + r2 + 2, c2 + 1)

print (ans % MOD)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

class Factorial:
    def __init__(self, n, mod):
        self.f = [1]
        self.mod = mod
        for j in range(1, n + 1):
            self.f.append(self.f[-1] * j % mod)
        self.i = [pow(self.f[-1], mod - 2, mod)]
        for j in range(n, 0, -1):
            self.i.append(self.i[-1] * j % mod)
        self.i.reverse()
    def factorial(self, j):
        return self.f[j]
    def ifactorial(self, j):
        return self.i[j]
    def comb(self, n, k):
        return self.f[n] * self.i[n - k] % self.mod * self.i[k] % self.mod if n >= k else 0

C = Factorial(10 ** 6 + 5, MOD).comb

r1, c1, r2, c2 = map(int, input().split())

ans = 0
for i in range(c2 - c1 + 1):
    tmp = C(r2 + c2 + 1 - i, r2) - C(r1 + c2 - i, r1 - 1)
    # print (tmp, C(r2 + c2 + 1 - i, r2), C(r1 + c2 - i, r1 - 1))

    ans += tmp
    ans %= MOD

print (ans)
Problem p02787 (python)

Fixed submission:
INF = 10 ** 18


H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

dp = [[INF] * (H + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for j in range(H + 1):
        if j < AB[i][0]:
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][0] + AB[i][1])
        else:
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - AB[i][0]] + AB[i][1])
    
print (dp[N][H])

# for d in dp:
#     print (d)

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

    INF = 10 ** 18

    H, N = map(int, input().split())

    dp = [INF] * (H + 1)
    dp[0] = 0

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

    # for d in dp:
    #     print (d)

if __name__ == '__main__':
    main()
Problem p02853 (python)

Fixed submission:
X, Y = map(int, input().split())

ans = max(0, (4 - X) * 100000)
ans+= max(0, (4 - Y) * 100000)

if X == Y == 1:
    ans += 100000 * 4

print (ans)

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

ans = max(0, (4 - X) * 100000)
ans+ = max(0, (4 - Y) * 100000)

if X == Y == 1:
    ans += 100000 * 4

print (ans)
Problem p02882 (python)

Fixed submission:
import math

a, b, x = map(int, input().split())

V = a * a * b

if V == x:
    print (0)
    exit()

if x * 2 <= V:
    tmp = 2 * x / (a * b * b)
else:
    tmp = a / (2 * (b - x / (a ** 2)))

print (90 - math.degrees(math.atan(tmp)))

Buggy submission (verdict: Runtime Error):
import math

a, b, x = map(int, input().split())

V = a * a * b
if x * 2 <= V:
    tmp = 2 * x / (a * b * b)
else:
    tmp = a / (2 * (b - x / (a ** 2)))

print (90 - math.degrees(math.atan(tmp)))
Problem p02900 (python)

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

def make_divisors(a, b):
    n = min(a, b)
    m = max(a, b)
    import math
    divisors = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n == 1:
            break
        if n % i == 0: #割り切れるとき
            if m % i == 0:
                divisors.append(i)
            while n % i == 0 and n != 1:
                n //= i
    if n != 1 and m % n == 0:
        divisors.append(n)
    return divisors

lst = make_divisors(A, B) #この中から素数を数えたらいい
print (len(lst) + 1)

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

# def make_divisors(a, b):
#     n = min(a, b)
#     m = max(a, b)
#     import math
#     divisors = []
#     for i in range(1, int(math.sqrt(n)) + 1):
#         if n % i == 0: #割り切れるとき
#             if m % i == 0:
#                 divisors.append(i)
#             if i != n//i:
#                 if m % (n // i) == 0:
#                     divisors.append(n//i)
#     divisors.sort()
#     return divisors

# lst = make_divisors(A, B)
# print (lst)

a = min(A, B)
def primes(n):
    import math
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(math.sqrt(n)) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

prime_lst = primes(a)

count = 1
for i in prime_lst:
    if A % i == B % i == 0:
        count += 1

print (count)
Problem p02910 (python)

Fixed submission:
s = list(input())
for i in range(len(s)):
  if i % 2 == 0:
    if not s[i] in "RUD":
      print ("No") 
      exit() 
  else: 
    if not s[i] in "LUD":
      print("No")
      exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s = list(input())
for i in range(len(s)):
  if i % 2 == 0:
    if not s[i] in "RUD":
      print ("No") 
      exit() 
  else: 
    if nit s[i] in "LUD":
      print("No")
      exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
s = list(input())
for i in range(len(s)):
  if i % 2 == 0:
    if not s[i] in "RUD":
      print ("No") 
      exit() 
  else: 
    if not s[i] in "LUD":
      print("No")
      exit()
print("Yes"

Buggy submission (verdict: Runtime Error):
s = list(input())
for i in range(len(s)):
  if i % 2 == 0:
    if not s[i] in "RUD":
      print ("No") 
      exit() 
  else: 
    if nit s[i] in "LUD":
      print("No")
      exit()
print("Yes"
Problem p02919 (python)

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

index_lst = [0] * N
for index, i in enumerate(P):
    index_lst[i - 1] = index

left_next_Index = list(range(-1, N - 1)) + [-1, -1]
right_next_Index = list(range(1, N + 1)) + [N, N]
# print (left_next_Index)
# print (right_next_Index)
ans = 0
for i in range(1, N):
    index = index_lst[i - 1]
    # print (i, index)
    l1 = left_next_Index[index]
    l2 = left_next_Index[l1]
    r1 = right_next_Index[index]
    r2 = right_next_Index[r1]
    # print ('l1 =', l1, ' l2 =', l2, ' r1 =', r1, ' r2 =', r2)
    ans += i * ((index - l1) * (r2 - r1) + (r1 - index) * (l1 -l2))

    left_next_Index[r1] = l1
    right_next_Index[l1] = r1

print (ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = [None] + list(map(int, input().split()))

p_to_index = [None] * (N + 1)
for index, x in enumerate(P[1:], 1):
    p_to_index[x] = index

#大きい数から挿入
#左隣にあるインデックスを取得できるようにする
#[1, i]内で書き込んだ数の個数を獲得できるBITを構築する

def BIT_add(i):
    while i <= N:
        tree[i] += 1
        i += i & (-i)

def BIT_sum(i):
    s = 0
    while i:
        s += tree[i]
        i -= i & (-i)
    return s

def BIT_search(x):
    i = 0
    s = 0
    step = 1 << (N.bit_length() - 1)
    while step:
        if i + step <= N and s + tree[i + step] < x:
            i += step
            s += tree[i]
        step >>= 1
    return i + 1

tree = [0] * (N + 1)
ans = 0
for x in range(N, 0, -1):
    c = p_to_index[x]
    L = BIT_sum(c) #左側にある既に書き込んだ数の個数
    BIT_add(c)
    R = N - x - L #右側にある既に書き込んだ数の個数
    a = BIT_search(L - 1) if L >= 2 else 0
    b = BIT_search(L) if L >= 1 else 0
    d = BIT_search(L + 2) if R >= 1 else N + 1
    e = BIT_search(L + 3) if R >= 2 else N + 1
    tmp = 0
    if b != 0:
        tmp += (b - a) * (d - c)
    if d != 0:
        tmp += (e - d) * (c - b)
    ans += tmp * x

print (ans)
Problem p02939 (python)

Fixed submission:
S = ['0'] + list(input())
N = len(S)

ans = 0
flag = False #直前の文字を使って2文字にするとき True
for i in range(1, N):
    #同じ文字が連続している時
    if S[i] == S[i - 1]:
        # print ('A')
        if flag == True: #その前に連続で使っているとき
            ans += 1
            flag = False
        elif flag == False: #その前を不連続で使っているとき
            flag = None
        elif flag == None:
            ans += 1
            flag = True

    #直前の文字と異なるとき-->1文字だけで使う
    elif S[i] != S[i - 1]:
        # print ('B')
        if flag == True: #直前が連続
            ans += 1
            flag = False
        elif flag == False: #直前が不連続
            ans += 1
            flag = False
        elif flag == None:
            ans += 1
            flag = True

print (ans)

Buggy submission (verdict: Runtime Error):
S = ['0'] + list(input())

def g(i):
    if i == 0:
        return 0
    if i == 1:
            return 1
    if i == 2:
        if S[2] == S[1]:
            return 1
        else:
            return 2     

    if S[i] == S[i - 1]:
        return g(i - 3) + 2
    if S[i] != S[i - 1]:
        return g(i - 1) + 1
# print (len(S) - 1)
print (g(len(S) - 1))
Problem p02949 (python)

Fixed submission:
#単一始点最短経路問題
#負の辺があっても動作する

#最短経路を求める
#計算量O(N * M)

INF = 10 ** 15
#入力
# N = int(input()) #頂点の数
# M = int(input()) #辺の数
N, M, P = map(int, input().split())

# 入力は1-index
# 内部で0-indexにして処理
G = []
for _ in range(M): #M個の辺の情報を受け取る
    l, r, s = map(int, input().split()) #lからrへ重みsの辺が存在
    G += [[l-1, r-1, -(s-P)]] #有向グラフのときはここだけ
    # G += [[r-1, l-1, s]] #無向グラフのときはこの行も必要


#メイン文
d = [0] * N #最短距離を記録しておくリスト
# prev = [-1] * N
def shortest_path(s): #S番目の頂点から各頂点への最短距離を求める
    s -= 1
    for i in range(N):
        d[i] = INF
    d[s] = 0
    count = 0
    while True:
        count += 1
        update = False
        for i in range(M): #無向グラフのときは辺は実質的には2倍
            e = G[i]
            if d[e[0]] != INF and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                update = True
                # prev[e[1]] = e[0]
        if not update: #更新が終わったとき
            return True
        if count == N - 1: #永遠に更新が起きているとき
            tmp = d[N -1]
        if count == 2 * N:
            if d[N - 1] == tmp:
                return True #N-1の値が更新されていないとき
            else:
                return False #N + 2回目でもN - 1の値が小さくなっている-->得点が無限に大きくなる

#呼び出しスタート地点を入れる
if not shortest_path(1):
    print (-1)
    # print (d)
    exit()
# print (d)

print (max(0, -d[N - 1]))

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

lst = []
for _ in range(N):
    tmp = list(input())
    tmp.sort()
    lst.append(tmp)
lst.sort()
tmp = lst[0]
count = 1
ans = 0
for i in range(1, N):
    if tmp == lst[i]:
        count += 1
    else:
        ans = ans + (count * (count - 1))//2
        count = 1
        tmp = lst[i]
ans = ans + (count * (count - 1))//2
print (ans)
Problem p02963 (python)

Fixed submission:
import math
S = int(input())
X1 = 0
Y1 = 0
X2 = 0
Y2 = 0
X3 = 0
Y3 = 0
if  S <= 10 ** 9:
    X2 = S
    Y3 = 1
elif S == 1000000000000000000:
    X2 = int(math.sqrt(S))
    Y3 = X2
else:
    X2 = int(math.sqrt(S) + 1)
    Y3 = X2
    s = X2 ** 2  - S #残りの面積
    for i in range(1, int(math.sqrt(s) + 1)):
        if s%i == 0 and s//i <= 10 ** 9 and i <= 10 ** 9:
            X3 = i
            Y2 = s//i
            break

print (X1, Y1, X2, Y2, X3, Y3)

Buggy submission (verdict: Runtime Error):
import math
S = int(input())
X1 = 0
Y1 = 0
X2 = 0
Y2 = 0
X3 = 0
Y3 = 0
if  S <= 10 ** 9:
    X2 = S
    Y3 = 1
else:
    X2 = int(math.sqrt(S+1))
    Y3 = X2
    s = X2 ** 2  - S #残りの面積
    for i in range(1, int(math.sqrt(s) + 1)):
        if s%i == 0 and s%i <= 10 ** 9 and i <= 10 ** 9:
                X3 = i
                Y2 = s
                break


print (X1, Y1, X2, Y2, X3, Y3)

Buggy submission (verdict: Runtime Error):
import math
S = int(input())
X1 = 0
Y1 = 0
X2 = 0
Y2 = 0
X3 = 0
Y3 = 0
if  S <= 10 ** 9:
    X2 = S
    Y3 = 1
else:
    X2 = int(math.sqrt(S)+0.00001)
    Y3 = X2
    s = X2 ** 2  - S #残りの面積
    for i in range(1, int(math.sqrt(s) + 1)):
        if s%i == 0 and s%i <= 10 ** 9 and i <= 10 ** 9:
                X3 = i
                Y2 = s
                break


print (X1, Y1, X2, Y2, X3, Y3)

Buggy submission (verdict: Runtime Error):
import math
S = int(input())
X1 = 0
Y1 = 0
X2 = 0
Y2 = 0
X3 = 0
Y3 = 0
if  S <= 10 ** 9:
    X2 = S
    Y3 = 1
else:
    X2 = math.sqrt(S)//1
    Y3 = X2
    s = X2 ** 2  - S #残りの面積
    for i in range(1, int(math.sqrt(s) + 1)):
        if s%i == 0 and s%i <= 10 ** 9 and i <= 10 ** 9:
                X3 = i
                Y2 = s
                break


print (X1, Y1, X2, Y2, X3, Y3)
Problem p02969 (python)

Fixed submission:
r = int(input())

print (3 * r * r)

Buggy submission (verdict: Runtime Error):
#全探索でO(N^2)
N = int(input())
A = [int(input()) for _ in range(N)]

count = 0
tmp = - 10 ** 10
for i in range(N):
    # print ('i', i)
    if A[i] == -10 ** 11:
        continue
    else:
        tmp = A[i]
        count += 1
        for j in range(i + 1, N):
            if tmp < A[j]:
                tmp = A[j]
                A[j] = - 10  ** 11
            if j == N - 1:
                tmp = - 10 ** 10
# print (A)
print (count)
Problem p02981 (python)

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

print (min(N*A, B))

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

print (min(A * N, B))
Problem p02985 (python)

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

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


def permutation(n,r):
    import math
    return math.factorial(n)//math.factorial(n-r)

cal_lst = [None] * (K)
def calc(n):
    if cal_lst[n] != None:
        return cal_lst[n]
    if n == 0:
        cal_lst[n] = 1
        return cal_lst[n]
    if n > K-2:
        return 0;
    cal_lst[n] = permutation(K-2, n)
    return cal_lst[n]

g = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    g[a] += [b]
    g[b] += [a]

# print (g)

s = 1
Q = deque([s])
ans = K
searced = [0] * (N+1)
searced[s] = 1
cand = K-1
while len(Q) != 0:
    tmp = 1
    v = Q.popleft()
    for i in g[v]:
        if searced[i] == 1:
            continue
        else:
            searced[i] = 1
            tmp = (tmp * cand) % MOD
            cand -= 1
            Q.append(i)
    ans = (ans * tmp) % MOD
    cand = K-2
print (ans % MOD)

Buggy submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7

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


def permutation(n,r):
    import math
    return math.factorial(n)//math.factorial(n-r)

cal_lst = [None] * (K)
def calc(n):
    if cal_lst[n] != None:
        return cal_lst[n]
    if n == 0:
        cal_lst[n] = 1
        return cal_lst[n]
    if n > K-2:
        return 0;
    cal_lst[n] = permutation(K-2, n)
    return cal_lst[n]

lst = [0] * (N)
children = []
for _ in range(N-1):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    #子の数を記録
    lst[a-1] += 1
    #親が1のもののリスト
    if a-1 == 0:
        children += [b-1]

# lst2.sort()
# print (lst)
# print (lst2)

ans = K
for i in range(N):
    if i == 0:
        ans *= permutation(K-1, lst[i])
    else:
        # if lst[i] in children:
        #     ans *= permutation(K-1, lst[i])
        ans *= calc(lst[i])
    ans = ans%MOD
print (ans)
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())

print (W * H /2, end = ' ')
if W/2 == x and H/2 == y:
    print (1)
else:
    print (0)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int main(){
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    if (x * 2 == W and y * 2 == H) {
        cout << H / 2 * W << " " << 1 << endl;     
    }
    else cout << H / 2 * W << " " << 0 << endl;     


    return 0;
}
Problem p03008 (python)

Fixed submission:
N = int(input())
gA, sA, bA = map(int, input().split())
gB, sB, bB = map(int, input().split())

#[重さ,価値]を要素とする配列
lstAB_2 = [[gA, gB-gA], [sA, sB-sA], [bA, bB-bA]]
lstBA_2 = [[gB, gA-gB], [sB, sA-sB], [bB, bA-bB]]
lstAB = []
for i in range(3):
    if lstAB_2[i][1] > 0:
        lstAB += [lstAB_2[i]]  

lstBA = []
for i in range(3):
    if lstBA_2[i][1] > 0:
        lstBA += [lstBA_2[i]]

dp = [[0] * (N+1) for _ in range(len(lstAB)+1)]
for i in range(len(lstAB)):
    for j in range(N+1):
        if j < lstAB[i][0]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i+1][j-lstAB[i][0]]+lstAB[i][1])

N += dp[len(lstAB)][N]
# print (N)

dp2 = [[0] * (N+1) for _ in range(len(lstBA)+1)]
for i in range(len(lstBA)):
    for j in range(N+1):
        if j < lstBA[i][0]:
            dp2[i+1][j] = dp2[i][j]
        else:
            dp2[i+1][j] = max(dp2[i][j], dp2[i+1][j-lstBA[i][0]]+lstBA[i][1])
print (N + dp2[len(lstBA)][N])

Buggy submission (verdict: Runtime Error):
N = int(input())
gA, sA, bA = map(int, input().split())
gB, sB, bB = map(int, input().split())

dp = [[0] * (2 * N+ 2) for _ in range(2 * N + 2)]
#[重さ,価値]を要素とする配列
lstAB = [[gA, gB-gA], [sA, sB-sA], [bA, bB-bA]]
lstBA = [[gB, gA-gB], [sB, sA-sB], [bB, bA-bB]]
for i in range(3):
    for j in range(N+1):
        if j < lstAB[i][0]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i+1][j-lstAB[i][0]]+lstAB[i][1])

N += dp[3][N]
# print (N)

dp2 = [[0] * (2 * N+ 2) for _ in range(2 * N + 2)]
for i in range(3):
    for j in range(N+1):
        if j < lstBA[i][0]:
            dp2[i+1][j] = dp2[i][j]
        else:
            dp2[i+1][j] = max(dp2[i][j], dp2[i+1][j-lstBA[i][0]]+lstBA[i][1])
print (N + dp2[3][N])
Problem p03074 (python)

Fixed submission:
#何も考えずに全探索したらO(N^2)で間に合わない

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

#左端の文字は前の文字と変わった直後のみが候補
lst = [0]
for i in range(0, N-1):
    if S[i] != S[i+1]:
        lst += [i+1]

ans = 0
roop = len(lst)
lst = lst + [N]*(N+10**5)
# print (lst)
# print ('roop', roop)
for i in range(roop):
    if S[lst[i]] == '0':
        # print ('A', lst[i+2*K]- lst[i])
        ans = max(ans, lst[i+2*K]- lst[i])
    if S[lst[i]] == '1':
        # print ('B', lst[i+2*K +1]- lst[i])
        ans = max(ans, lst[i+2*K +1]- lst[i])
print (ans)

Buggy submission (verdict: Runtime Error):
#何も考えずに全探索したらO(N^2)で間に合わない

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

#左端の文字は前の文字と変わった直後のみが候補
lst = [0]
for i in range(0, N-1):
    if S[i] != S[i+1]:
        lst += [i+1]

ans = 0
roop = len(lst)
lst = lst + [N]*(N+100)
# print (lst)
# print ('roop', roop)
for i in range(roop):
    if S[lst[i]] == '0':
        # print ('A', lst[i+2*K]- lst[i])
        ans = max(ans, lst[i+2*K]- lst[i])
    if S[lst[i]] == '1':
        # print ('B', lst[i+2*K +1]- lst[i])
        ans = max(ans, lst[i+2*K +1]- lst[i])
print (ans)
Problem p03076 (python)

Fixed submission:
a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())

a_syo = a//10
b_syo = b//10
c_syo = c//10
d_syo = d//10
e_syo = e//10
time1 = (a_syo + b_syo + c_syo + d_syo + e_syo) * 10

a_amari = a%10
b_amari = b%10
c_amari = c%10
d_amari = d%10
e_amari = e%10
lst = []
if a_amari == 0:
    pass
else:
    lst = lst + [a_amari]
if b_amari == 0:
    pass
else:
    lst = lst + [b_amari]
if c_amari == 0:
    pass
else:
    lst = lst + [c_amari]
if d_amari == 0:
    pass
else:
    lst = lst + [d_amari]
if e_amari == 0:
    pass
else:
    lst = lst + [e_amari]
if len(lst) == 0:
    print (time1)
else:
    #print (lst)
    count = len(lst) - 1
    #print (count)
    lst.sort()
    #print (lst)
    time2 = (len(lst) -1)*10 + lst[0]
    print (time1 + time2)

Buggy submission (verdict: Runtime Error):
a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())

a_syo = a//10
b_syo = b//10
c_syo = c//10
d_syo = d//10
e_syo = e//10
time1 = (a_syo + b_syo + c_syo + d_syo + e_syo) * 10

a_amari = a%10
b_amari = b%10
c_amari = c%10
d_amari = d%10
e_amari = e%10
lst = []
if a_amari == 0:
    pass
else:
    lst = lst + [a_amari]
if b_amari == 0:
    pass
else:
    lst = lst + [b_amari]
if c_amari == 0:
    pass
else:
    lst = lst + [c_amari]
if d_amari == 0:
    pass
else:
    lst = lst + [d_amari]
if e_amari == 0:
    pass
else:
    lst = lst + [e_amari]
#print (lst)
count = len(lst) - 1
#print (count)
lst.sort()
#print (lst)
time2 = (len(lst) -1)*10 + lst[0]
print (time1 + time2)
Problem p03079 (python)

Fixed submission:
lst = list(map(int, input().split()))
s = set(lst)

if len(s) == 1:
  print ('Yes')
else:
  print ('No')

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

if len(s) == 1:
  print (`Yes`)
else:
  print (`No`)
Problem p03089 (python)

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

#成り立たせることができるかどうか
for i in range(1, N + 1):
    if b[i - 1] > i:
        print (-1)
        exit()


check_lst = [False] * N #i番目の数を使ったかどうか

ans_lst = [] #答えの逆順
index = N - 1
while len(ans_lst) != N:
    if check_lst[index] == False and b[index] <= check_lst[:index].count(True) + 1:
        ans_lst.append(b[index])
        check_lst[index] = True
        index = N - 1
    else:
        index -= 1

for i in ans_lst:
    print (i)

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

#成り立たせることができるかどうか
for i in range(1, N + 1):
    if b[i - 1] > i:
        print (-1)
        exit()


check_lst = [False] * N #i番目の数を使ったかどうか

ans_lst = [] #答えの逆順
for i in range(N - 1, -1, -1):
    if check_lst[i]: #True --> 既に使ったとき
        continue #次のiから続ける
    count = b[i] - 1
    index = i - 1
    # print ('count', count)
    # print ('index', index)
    while count > 0:
        if b[index] < b[i] and b[index] <= len(ans_lst) + 1: #次に入れたいやつより小さくて、iより大きいもの
            count -= 1
            # print ('B')
            if check_lst[index] == False:
                check_lst[index] = True
                # print (b[index])
                ans_lst.append(b[index])
        index -= 1
    ans_lst.append(b[i])
    check_lst[i] = True

for i in ans_lst:
    print (i)
Problem p03139 (python)

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

print (min(A, B), max(A + B - N, 0))

Buggy submission (verdict: Runtime Error):
import sys
# from heapq import heappop, heappush
from collections import deque
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

N, M = map(int, input().split())
check_lst = [0] * N
lst = [[] for _ in range(N)]
for _ in range(N + M - 1):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    lst[A].append(B)
    check_lst[B] += 1

n = check_lst.index(0)
ans = [0] * N
que = deque()
que.append(n)
while que:
    v = que.popleft()
    for v2 in lst[v]:
        check_lst[v2] -= 1
        if check_lst[v2] == 0:
            que.append(v2)
            ans[v2] = v + 1
print (*ans, sep = '\n')