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

Fixed submission:
p = {"JPY": 0, "BTC": 0}
for _ in range(int(input())):
    price, currency = input().split()
    price = float(price)
    p[currency] += price

print(p["JPY"] + 380000.0 * p["BTC"])

Buggy submission (verdict: Runtime Error):
p = {"JPY": 0, "BTC": 0}
for _ in range(int(input())):
    price, currency = input().split()
    price = int(price)
    p[currency] += price

print(p["JPY"] + 380000.0 * p["BTC"])
Problem p03146 (python)

Fixed submission:
s = int(input())
rec = set()


def f(x):
    if x % 2 == 0:
        return x//2
    else:
        return 3*x + 1


c = 1
while True:
    if s in rec:
        print(c)
        exit()
    rec.add(s)
    s = f(s)
    c += 1

Buggy submission (verdict: Runtime Error):
s = int(input())
rec = {}


def f(x):
    if x % 2 == 0:
        return x//2
    else:
        return 3*x + 1


c = 0
while True:
    if s in rec:
        print(c)
        exit()
    rec.add(s)
    s = f(s)
    c += 1
Problem p03160 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
dp = [float('inf')] * N
dp[0] = 0
for i in range(1, N):
    dp[i] = min(dp[i-1] + abs(H[i]-H[i-1]), dp[i-2] + abs(H[i]-H[i-2])
                ) if i >= 2 else dp[i-1] + abs(H[i] - H[i-1])
#print(*dp)
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
dp = [float('inf')] * N
dp[0] = 0
dp[1] = abs(H[1] - H[0])


def rec(i):
    if dp[i] != float('inf'):
        return dp[i]
    else:
        dp[i] = min(rec(i-1) + abs(H[i]-H[i-1]), rec(i-2) + abs(H[i]-H[i-2]))
        return dp[i]


# print(*dp)
print(rec(N-1))
Problem p03163 (python)

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

dp = [[0] + [-1] * W for _ in range(N+1)]
dp[0] = [0] * (W+1)

for i in range(1, N+1):
    for w in range(1, W+1):
        dp[i][w] = max(dp[i-1][w], dp[i-1][w - T[i-1][0]] + T[i-1]
                       [1]) if w - T[i-1][0] >= 0 else dp[i-1][w]

# print(*dp, sep='\n')
print(dp[N][W])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)


dp = [[-1] * 10010 for _ in range(110)]


def knap(i, j):
    if dp[i][j] >= 0:
        return dp[i][j]

    if i == N:
        dp[i][j] = 0
    elif j < W[i]:
        dp[i][j] = knap(i+1, j)
    else:
        dp[i][j] = max(knap(i+1, j), knap(i+1, j - W[i]) + V[i])

    return dp[i][j]


print(knap(0, L))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)


dp = [[-1] * 10010 for _ in range(110)]


def knap(i, j):
    if dp[i][j] >= 0:
        return dp[i][j]

    if i == N:
        dp[i][j] = 0
    elif j < W[i]:
        dp[i][j] = knap(i+1, j)
    else:
        dp[i][j] = max(knap(i+1, j), knap(i+1, j - W[i]) + V[i])

    return dp[i][j]


print(knap(0, L))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)


dp = [[-1] * 10010 for _ in range(110)]


def knap(i, j):
    if dp[i][j] >= 0:
        return dp[i][j]

    if i == N:
        dp[i][j] = 0
    elif j < W[i]:
        dp[i][j] = knap(i+1, j)
    else:
        dp[i][j] = max(knap(i+1, j), knap(i+1, j - W[i]) + V[i])

    return dp[i][j]


print(knap(0, L))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**10)
N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)


dp = [[-1] * 10010 for _ in range(110)]


def knap(i, j):
    if dp[i][j] >= 0:
        return dp[i][j]

    if i == N:
        dp[i][j] = 0
    elif j < W[i]:
        dp[i][j] = knap(i+1, j)
    else:
        dp[i][j] = max(knap(i+1, j), knap(i+1, j - W[i]) + V[i])

    return dp[i][j]


print(knap(0, L))

Buggy submission (verdict: Runtime Error):
import sys
N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)

sys.setrecursionlimit(10**8)

dp = [[-1] * 10010 for _ in range(110)]


def knap(i, j):
    if dp[i][j] >= 0:
        return dp[i][j]

    if i == N:
        dp[i][j] = 0
    elif j < W[i]:
        dp[i][j] = knap(i+1, j)
    else:
        dp[i][j] = max(knap(i+1, j), knap(i+1, j - W[i]) + V[i])

    return dp[i][j]


print(knap(0, L))
Problem p03164 (python)

Fixed submission:
N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)

VMAX = 10**5 + 100
ans = 0
dp = [[float('inf')] * (VMAX+1) for _ in range(N+1)]
dp[0][0] = 0
for n in range(N):
    for v in range(VMAX):
        if dp[n][v] != float('inf'):
            dp[n+1][v] = min(dp[n+1][v], dp[n][v])
            dp[n+1][v+V[n]] = min(dp[n+1][v+V[n]], dp[n][v] + W[n])

            if dp[n+1][v+V[n]] <= L:
                ans = max(ans, v+V[n])
# print(*dp, sep='\n')
print(ans)

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
W = []
V = []
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)

VMAX = 10**4 + 100
ans = 0
dp = [[float('inf')] * (VMAX+1) for _ in range(N+1)]
dp[0][0] = 0
for n in range(N):
    for v in range(VMAX):
        if dp[n][v] != float('inf'):
            dp[n+1][v] = min(dp[n+1][v], dp[n][v])
            dp[n+1][v+V[n]] = min(dp[n+1][v+V[n]], dp[n][v] + W[n])

            if dp[n+1][v+V[n]] <= L:
                ans = max(ans, v+V[n])
# print(*dp, sep='\n')
print(ans)

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

dp = [[0] + [-1] * W for _ in range(N+1)]
dp[0] = [0] * (W+1)

for i in range(1, N+1):
    for w in range(1, W+1):
        dp[i][w] = max(dp[i-1][w], dp[i-1][w - T[i-1][0]] + T[i-1]
                       [1]) if w - T[i-1][0] >= 0 else dp[i-1][w]

# print(*dp, sep='\n')
print(dp[N][W])

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

dp = [[0] + [-1] * W for _ in range(N+1)]
dp[0] = [0] * (W+1)

for i in range(1, N+1):
    for w in range(1, W+1):
        dp[i][w] = max(dp[i-1][w], dp[i-1][w - T[i-1][0]] + T[i-1]
                       [1]) if w - T[i-1][0] >= 0 else dp[i-1][w]

# print(*dp, sep='\n')
print(dp[N][W])
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**8)
N, M = map(int, input().split())
G = dict([[i, []] for i in range(N)])
for _ in range(M):
    x, y = map(int, input().split())
    G[x-1].append(y-1)

dp = [-1] * N


def rec(v):
    if dp[v] >= 0:
        return dp[v]
    if len(G[v]) == 0:
        return 0

    ret = -1
    for nv in G[v]:
        ret = max(ret, rec(nv) + 1)

    dp[v] = ret
    return ret


print(max([rec(v) for v in range(N)]))

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

dp = [-1] * N


def rec(v):
    if dp[v] >= 0:
        return dp[v]
    if len(G[v]) == 0:
        return 0

    ret = -1
    for nv in G[v]:
        ret = max(ret, rec(nv) + 1)

    return ret


print(max([rec(v) for v in range(N)]))
Problem p03219 (python)

Fixed submission:
x, y = map(int, input().split())
print(x + y//2)

Buggy submission (verdict: Runtime Error):
print(int(input()) + int(input())//2)
Problem p03260 (python)

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

Buggy submission (verdict: Runtime Error):
print("Yes" if (int(input())*int(input())) % 2 != 0 else "No")

Buggy submission (verdict: Runtime Error):
print("Yes" if (int(input)*int(input)) % 2 != 0 else "No")

Buggy submission (verdict: Runtime Error):
print("Yes" if int(input)*int(input) % 2 != 0 else "No")
Problem p03262 (python)

Fixed submission:
from functools import reduce
from fractions import gcd
N, K = map(int, input().split())
X = sorted(list(map(int, input().split())) + [K])
# print(X)
S = [X[i+1] - X[i] for i in range(N)]
# print(S)
D = reduce(gcd, S, S[0])
print(D)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd
N, K = map(int, input().split())
X = sorted(list(map(int, input().split())) + [K])
# print(X)
S = [X[i+1] - X[i] for i in range(N)]
# print(S)
D = reduce(gcd, S, S[0])
print(D)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd
N, K = map(int, input().split())
X = sorted(list(map(int, input().split())) + [K])
# print(X)
S = [X[i+1] - X[i] for i in range(N)]
# print(S)
D = reduce(gcd, S, S[0])
print(D)
Problem p03323 (python)

Fixed submission:
A, B = map(int, input().split())
print("Yay!" if A <= 8 and B <= 8 else ":(")

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print("Yay!" if A <= 8 and B <= 8)
Problem p03324 (python)

Fixed submission:
D, N = map(int, input().split())
print(N*100**D if N < 100 else (N+1)*100**D)

Buggy submission (verdict: Runtime Error):
D, N = int(input())
print(100*(D+N) if D > 0 else N)
Problem p03352 (python)

Fixed submission:
import numpy as np
X = int(input())
ans = 1
for b in range(2, 1+int(np.ceil(np.sqrt(X)))):
    p = 0
    while np.power(b, p) <= X:
        p += 1
    p -= 1
    ans = max(ans, np.power(b, p))
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
X = int(input())
ans = 1
for b in range(int(np.ceil(np.sqrt(X)))):
    p = 0
    while np.pow(b, p) <= X:
        p += 1
    p -= 1
    ans = max(ans, np.pow(b, p))
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
X = int(input())
ans = 1
for b in range(np.ceil(np.sqrt(X))):
    p = 0
    while b**p <= X:
        p += 1
    p -= 1
    ans = max(ans, b**p)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
X = int(input())
for b in range(np.ceil(np.sqrt(X))):
    p = 0
    while b**p <= X:
        p += 1
    p -= 1
    ans = max(ans, b**p)
print(ans)
Problem p03378 (python)

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

l = 0
r = 0
for a in A:
    if(a < X):
        l += 1
    else:
        r += 1

print(min(l, r))

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


def ssum(A, l, r):
    ssum = 0
    for i in range(l, r):
        ssum += A[i]
    return ssum


print(min(ssum(A, 0, X), ssum(A, X, N+1)))
Problem p03379 (python)

Fixed submission:
import bisect
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X.copy())
for x in X:
    print(Y[N//2-1] if bisect.bisect(Y, x) > N//2 else Y[N//2])

Buggy submission (verdict: Runtime Error):
import bisect
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X.copy())
for x in X:
    print(Y[N//2-1] if bisect.bisect(Y, x) >= N//2 else Y[N//2])

Buggy submission (verdict: Runtime Error):
import bisect
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X.copy())
for x in X:
    print(Y[N//2-1] if bisect.bisect(Y, x) >= N//2 else Y[N//2])
Problem p03386 (python)

Fixed submission:
A, B, K = map(int, input().split())
S = sorted(set(list(range(A, B+1)[:K]) + list(range(A, B+1)[-K:])))
print(*S, sep="\n")

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input())
S = sorted(set(list(range(A, B+1)[:K]) + list(range(A, B+1)[-K:])))
print(*S, sep="\n")
Problem p03448 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
print([0 <= X - 500*a - 100*b and (X - 500*a - 100*b) %
       50 == 0 and (X - 500*a - 100*b) // 50 <= C for a in range(A+1) for b in range(B+1)].count(True))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
print([0 <= X - 500*a - 100*b and X - 500*a - 100*b %
       50 == 0 and X - 500*a - 100*b // 50 <= C for a in A for b in B].count(True))
Problem p03456 (python)

Fixed submission:
A, B = input().split()
N = int(A + B)
if (N**0.5) % 1:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N = 10*(int(input())) + int(input())
if N % 1:
    print("Yes")
else:
    print("No")
Problem p03474 (python)

Fixed submission:
A, B = map(int, input().split())
S = input().split("-")
print("Yes" if len(S) == 2 and len(S[0]) == A and len(S[1]) == B else "No")

Buggy submission (verdict: Runtime Error):
A, B = input().split()
S1, S2 = input().split("-")
print("Yes" if len(S1) == A and len(S2) == B else "No")
Problem p03486 (python)

Fixed submission:
s = sorted(input())
t = sorted(input())[:: -1]
print("Yes" if s < t else "No")

Buggy submission (verdict: Runtime Error):
s = sorted(input())
t = sorted(input()).reverse()
print("Yes" if s < t else "No")

Buggy submission (verdict: Runtime Error):
s = sorted([char for char in input()])
t = sorted([char for char in input()]).reverse()
print("Yes" if s < t else "No")

Buggy submission (verdict: Runtime Error):
s = sorted(list(map(str, input().split(""))))
t = sorted(list(map(str, input().split("")))).reverse()
print("Yes" if s < t else "No")

Buggy submission (verdict: Runtime Error):
s = sorted(input())
t = sorted(input()).reverse()
print("Yes" if s < t else "No")
Problem p03547 (python)

Fixed submission:
X, Y = input().split(" ")
print("<" if X < Y else "=" if X == Y else ">")

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split(" "))
print("<" if X < Y else "=" if X == Y else ">")

Buggy submission (verdict: Runtime Error):
X, Y = map(int, input().split(" "))
print("<" if X < Y else "=" if X == Y else Y)
Problem p03578 (python)

Fixed submission:
N = int(input())
D = sorted(list(map(int, input().split())))
M = int(input())
T = sorted(list(map(int, input().split())))
C = {}
for d in D:
    if d in C:
        C[d] += 1
    else:
        C[d] = 1
E = {}
for t in T:
    if t in E:
        E[t] += 1
    else:
        E[t] = 1
for key, val in E.items():
    if key in C:
        C[key] //= val

print('YES' if min([C[t] if t in C else 0 for t in T]) > 0 else 'NO')

Buggy submission (verdict: Runtime Error):
N = int(input())
D = sorted(list(map(int, input().split())))
M = int(input())
T = sorted(list(map(int, input().split())))
C = [0] * 3*10**5
for d in D:
    if d in C:
        C[d] += 1
    else:
        C[d] = 1
E = [0] * 3*10**5
for t in T:
    if t in E:
        E[t] += 1
    else:
        E[t] = 1
for key, val in enumerate(E):
    if val != 0:
        C[key] //= val

print('YES' if min(C[t] for t in T if t) > 0 else 'NO')
Problem p03607 (python)

Fixed submission:
A = set()
for i in range(int(input())):
    A ^= set([int(input())])
print(len(A))

Buggy submission (verdict: Runtime Error):
A = set()
for i in range(int(input())):
    a = int(input())
    A ^= set(a)
print(len(A))
Problem p03672 (python)

Fixed submission:
S = [c for c in input()]
while len(S):
    S.pop()
    if len(S) % 2 == 0 and S[:len(S)//2] == S[len(S)//2:]:
        print(len(S))
        exit()

Buggy submission (verdict: Runtime Error):
S = input()
while len(S):
    S.pop()
    if S[:len(S)//2+1] == S[len(S)//2+1:]:
        print(len(S[:len(S)//2+1]))
        exit()
Problem p03673 (python)

Fixed submission:
from collections import deque
N = int(input())
a = list(map(int, input().split()))
ans = deque([])
for i in range(N):
    if (i+1) % 2 == N % 2:
        ans.appendleft(a[i])
    else:
        ans.append(a[i])
print(*ans, sep=" ")

Buggy submission (verdict: Runtime Error):
 n = int(input())
 a = list(map(int, input().split()))
 ans = []
 for i in range(N):
    if (i+1) % 2 == N % 2:
         ans = [a.pop(0)] + ans
    else:
         ans = ans + [a.pop()]
print(*ans, sep=" ")
Problem p03695 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
C = [0] * 9
for a in A:
    C[min(8, a//400)] += 1
s = sum([c > 0 for c in C[:-1]])
# print(C)
print(max(s, 1), s + C[-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
C = [0] * 9
for a in A:
    C[a//400] += 1
s = sum([c > 0 for c in C[:-1]])
print(max(s, 1), min(9, s + C[-1]))
Problem p03699 (python)

Fixed submission:
N = int(input())
S = sorted([int(input()) for _ in range(N)])
s = sum(S)
if s % 10 != 0:
    print(s)
    exit()

for si in S:
    if si % 10 != 0:
        print(s - si)
        exit()

print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = sorted([int(input()) for _ in range(N)])
s = sum(S)
if s % 10 != 0:
    print(s)
    exit()

for si in range(S):
    if si % 10 != 0:
        print(s - si)
        exit()

print(0)
Problem p03738 (python)

Fixed submission:
A = int(input())
B = int(input())
print("EQUAL" if A == B else "GREATER" if A > B else "LESS")

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
print("EQUAL" if A==B else "GREATER" if A>B else "LESS")
Problem p02756 (python)

Fixed submission:
from collections import deque
 
S = deque(input())
Q = int(input())
 
Q_list = [list(map(str, input().split())) for i in range(Q)]
 
rev = False
 
for i in range(Q):
  if int(Q_list[i][0]) == 1:
    rev = not rev
  
  else:
    F = Q_list[i][1]
    C = Q_list[i][2]
    
    if rev ^ (int(F) == 1): # 排他的論理和片方真片方ぎの時真になる
      S.appendleft(C)
    else:
      S.append(C)
      
if rev:
  S.reverse()
  
print(''.join(S))

Buggy submission (verdict: Runtime Error):
from collections import deque
 
S = deque(input())
Q = int(input())
 
Q_list = [list(map(str, input().split())) for i in range(Q)]

rev = False

for i in range(Q):
  if int(Q_list[i][0]) == 1:
    rev = not rev
  
  else:
    F = Q_list[i][1]
    C = Q_list[i][2]
    
    if rev ^ (int(F) == 1): # 排他的論理和片方真片方ぎの時真になる
      S.appendleft(C)
    else:
      S.append(C)
      
if rev:
  S = S[::-1]
  
print(''.join(S))

Buggy submission (verdict: Runtime Error):
from collections import deque
 
S = deque(input())
Q = int(input())
 
Q_list = [list(map(str, input().split())) for i in range(Q)]
 
for i in range(Q):                
  if int(Q_list[i][0]) == 1:
    if len(S) >= 2:
      S = S[::-1]
  
  else:
    F = Q_list[i][1]
    C = Q_list[i][2]
    
    if int(F) == 1:
      S.appendleft(C)
    else:
      S.append(C)
      
print(''.join(S))

Buggy submission (verdict: Runtime Error):
from collections import deque

S = input()
Q = deque(int(input()))
 
Q_list = [list(map(str, input().split())) for i in range(Q)]
 
for i in range(Q):                
  if int(Q_list[i][0]) == 1:
    if len(S) >= 2:
      S = S[::-1]
  
  else:
    F = Q_list[i][1]
    C = Q_list[i][2]
    
    if int(F) == 1:
      S.appendleft(C)
    else:
      S.append(C)
      
print(''.join(S))
Problem p02801 (python)

Fixed submission:
S = input()
 
list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
 
s_index = list.index(S)
 
print(list[s_index+1])

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

list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y"]

s_index = list.index(S)

print(list[s_index+1])
Problem p02918 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 
import numpy as np
 
N, K = map(int, input().split())
S = np.array(list(input()), dtype='U1')
 
S_slide = S[1:]
S_2 = S[:-1]
 
happiness = np.count_nonzero(S_slide == S_2)
happiness += 2*K
 
happiness = min(happiness, N-1)
 
print(happiness)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 
import numpy as np

N, K = map(int, input().split())
S = np.array(list(input()), dtype='U1')

S_slide = S[1:]
S_2 = S[:-1]

happiness = np.count_nonzero(S_slide == S_2)
happiness += 2*K

happiness = min(happiness, N-1)

print(happiness)
Problem p02921 (python)

Fixed submission:
s = input()
t = input()

ans = 0

for i in range(len(s)):
    if s[i] == t[i]:
        ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
ans = 0

for i in range(len(s)):
    if s[i] == t[i]:
        ans+=1

print(ans)
Problem p02922 (python)

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

ans = 0
outlet = 1

while outlet < B:
  outlet += A - 1
  ans += 1
  
print(ans)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

ans_tmp = (B-1)/(A-1)

if ans_tmp > 1 and ans_tmp < 2:
    print(int(ans_tmp) + 1)
elif ans_tmp < 1:
    print(1)
else:
    print(int(ans_tmp))
Problem p02923 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
t = 0
result = 0
for i in range(n - 1):
  if h[i + 1] <= h[i]:
    t += 1
  else:
    result = max(t, result)
    t = 0
result = max(t, result)
print(result)

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

ans = [0] * (n-1)

for i in range(n-1):
    for j in range(i,n-1):
        if h[j] >= h[j+1]:
            ans[i] += 1
        else:
            break           

print(max(ans))
Problem p02934 (python)

Fixed submission:
N = int(input())
list_a = list(map(int, input().split())) 
 
gyaku_su_list = [1/a for a in list_a]
print(1 / sum(gyaku_su_list))

Buggy submission (verdict: Runtime Error):
N = int(input())
list_a = [i for i in input()]
 
gyaku_su_list = [1/a for a in list_a]
print(1 / sum(gyaku_su_list))

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

gyaku_su_list = [1/a for a in list_a]
print(1 / sum(gyaku_su_list))
Problem p02936 (python)

Fixed submission:
n,q=map(int,input().split())
T=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)
C=[0]*n
for i in range(q):
    p,x=map(int,input().split())
    C[p-1]+=x
S=[0]
P=[0]*n
while S:
    s=S.pop()
    for t in T[s]:
        if t==P[s]:
            continue
        P[t]=s
        S.append(t)
        C[t]+=C[s]
print(' '.join(map(str,C)))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
n, q = map(int, input().split())

trees = [[] for i in range(n)]
for i in range(n-1):
  a, b = map(int, input().split())
  trees[a-1].append(b-1)
  
values = [0 for i in range(n)]

for i in range(q):
  p, x = map(int, input().split())
  values[p-1] += x
  
def dfs(i):
  for j in trees[i]:
    values[j] += values[i]
    dfs(j)
    
dfs(0)
print(*values)

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

trees = [[] for i in range(n)]

for i in range(n-1):
    a, b = map(int, input().split())
    trees[a-1].append(b-1)

#print("trees: ", trees)    
    
values = [0 for i in range(n)]
for i in range(q):
    p, x = map(int, input().split())
    values[p-1] += x

#print("values: ", values)

def dfs(i):
    for j in trees[i]:
        values[j] += values[i]
        #print("values",i , j, values)
        dfs(j)

dfs(0)
print(*values)
Problem p02945 (python)

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

print(max(A-B, A+B, A*B))

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

A, B = map(int, input().split())

print(np.max(A-B, A+B, A*B)
Problem p02958 (python)

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

cnt = 0
for i in range(N):
    if i + 1 == p[i]:
        cnt += 1

if cnt >= N - 2:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
res = 0
a_sort = sorted(a)
 
for i in range(n):
    if a_sort[i] == a[i]:
        res += 1
 
if res >= n - 2:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
res = 0
a_sort = sorted(a)

for i in range(n):
    if a_sort[i] != a[i]:
        res += 1

if res > 2:
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
a