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

Fixed submission:
N = int(input())
Up = []
Down = []
for _ in range(N):
    S = input()
    L = [0]
    mi = 0
    now = 0
    for __ in range(len(S)):
        if S[__] == '(':
            now += 1
        else:
            now -= 1
            mi = min(mi, now)
    if now > 0:
        Up.append((mi, now))
    else:
        Down.append((mi - now, mi, now))

Up.sort(reverse=True)
Down.sort()

now = 0
for i, j in Up:
    if now + i < 0:
        print('No')
        exit()
    else:
        now += j
for _, i, j in Down:
    if now + i < 0:
        print('No')
        exit()
    else:
        now += j
if now == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
Up = []
Down = []
for _ in range(N):
    S = input()
    L = [0]
    for __ in range(len(S)):
        if S[__] == '(':
            L.append(L[-1] + 1)
        else:
            L.append(L[-1] - 1)
        las = L[-1]
        mi = min(L)
    if las >= 0:
        Up.append((mi, las))
    else:
        Down.append((mi, las))

Up.sort(reverse=True)
Down.sort()

now = 0
for i, j in Up:
    if now + i < 0:
        print('No')
        exit()
    else:
        now += j
for i, j in Down:
    if now + i < 0:
        print('No')
        exit()
    else:
        now += j
if now == 0:
    print('Yes')
else:
    print('No')
N = int(input())
Up = []
Down = []
for _ in range(N):
    S = input()
    L = [0]
    for __ in range(len(S)):
        if S[__] == '(':
            L.append(L[-1] + 1)
        else:
            L.append(L[-1] - 1)
        las = L[-1]
        mi = min(L)
    if las >= 0:
        Up.append((mi, las))
    else:
        Down.append((mi, las))

Up.sort(reverse=True)
Down.sort()

now = 0
for i, j in Up:
    if now + i < 0:
        print('No')
        exit()
    else:
        now += j
for i, j in Down:
    if now + i < 0:
        print('No')
        exit()
    else:
        now += j
if now == 0:
    print('Yes')
else:
    print('No')
Problem p02732 (python)

Fixed submission:
from collections import Counter
N = int(input())
A = tuple(map(int, input().split()))
A_count = Counter(A)
ans = 0
for i, j in A_count.items():
    ans += j * (j - 1) // 2
for k in range(1, N+1):
    n = A_count[A[k-1]]
    ans_ = ans - (n - 1)
    print(ans_)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = tuple(map(int, input().split()))
A_count = Counter(A)
ans = 0
for i, j in A_count:
    ans += j * (j - 1) // 2
for k in range(1, N+1):
    n = A_count[A[k-1]]
    ans_ = ans - (n - 1)
    print(ans_)
Problem p02772 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
flag = True
for a in A:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
            continue
        else:
            flag = False

if flag:
    print('APPROVED')
else:
    print('DENIED')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())
flag = True
for a in A:
    if a % 2 == 0:
        if a % 3 == 0 or a % 5 == 0:
        continue
    flag = False

if flag:
    print('APPROVED')
else:
    print('DENIED')
Problem p02778 (python)

Fixed submission:
n = len(input())
print('x' * n)

Buggy submission (verdict: Runtime Error):
n = len(input())
print('x' + n)
Problem p02814 (python)

Fixed submission:
import fractions, sys
input = sys.stdin.buffer.readline


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


def calc(n, m):
    for i in range(cycle//m+1):
        X = m * (i + 0.5)
        if X > M:
            print(0)
            exit()
            return
        flag = True
        for x in n:
            if (X - x // 2) % x != 0:
                flag = False
                break
        if flag:
            return int(X)
    print(0)
    exit()
    return


N, M = map(int, input().split())
A = list(map(int, input().split()))
cycle = 1
ma = 0
for a in A:
    cycle = lcm(cycle, a)
    ma = max(ma, a)
start = calc(A, ma)

print((M - start) // cycle + 1)

Buggy submission (verdict: Runtime Error):
import math


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


def calc(n, m):
    for i in range(cycle//m+1):
        X = m * (i + 0.5)
        flag = True
        for x in n:
            if (X - x // 2) % x != 0:
                flag = False
                break
        if flag:
            return int(X)
    return -1


N, M = map(int, input().split())
A = list(map(int, input().split()))
cycle = 1
ma = 0
for a in A:
    cycle = lcm(cycle, a)
    ma = max(ma, a)
start = calc(A, ma)

if start == -1:
    print(0)
else:
    print((M - start) // cycle + 1)
Problem p02885 (python)

Fixed submission:
A, B = map(int, input().split())
print(max(0, A - 2 * B))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(max(0, A - 2 * B)
Problem p02900 (python)

Fixed submission:
import fractions
from collections import defaultdict
A, B = map(int, input().split())
C = fractions.gcd(A, B)
c = C

if c == 1:
    print(1)
    exit()


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


print(len(factorization(c))+1)

Buggy submission (verdict: Runtime Error):
import fractions
from collections import defaultdict
A, B = map(int, input().split())
C = fractions.gcd(A, B)
D = set([1])
c = C
for i in range(2, C1):
    while c % i == 0:
        D.add(i)
        c //= i

print(len(D))

Buggy submission (verdict: Runtime Error):
import math
from collections import defaultdict
A, B = map(int, input().split())
C = math.gcd(A, B)
D = set([1])
c = C
for i in range(2, C//2+1):
    while c % i == 0:
        D.add(i)
        c //= i

print(len(D))
Problem p02999 (python)

Fixed submission:
X, A = map(int, input().split())
if X < A:
    print(0)
else:
    print(10)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = tuple(map(int, input().split()))
 
ans = 0
for i in range(N):
    for j in range(i+1, N+1):
        if sum(A[i:j]) >= K:
            ans += N - j + 1
            break
 
print(ans)
Problem p03006 (python)

Fixed submission:
from collections import Counter


N = int(input())
M = [tuple(map(int, input().split())) for _ in range(N)]
Map = []
if N == 1:
    print(1)
    exit()
for i in range(N):
    x1, y1 = M[i]
    for j in range(N):
        if i == j:
            continue
        x2, y2 = M[j]
        Map.append((x2 - x1, y2 - y1))
MapC = Counter(Map)
print(N - MapC.most_common(1)[0][1])

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

N = int(input())
M = [tuple(map(int, input().split())) for _ in range(N)]
Map = []
for i in range(N):
    x1, y1 = M[i]
    for j in range(i + 1, N):
        x2, y2 = M[j]
        Map.append((x2 - x1, y2 - y1))
MapC = Counter(Map)
print(N - MapC.most_common(1)[0][1])
Problem p03030 (python)

Fixed submission:
N = int(input())
Book = [0] * N
for i in range(N):
    s,q = input().split()
    p = int(q)
    Book[i] = (s, 100-p, i)

Book.sort()

for i in range(N):
    print(Book[i][2]+1)

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> Book(N, tuple<string, int, int>());
  
  for (int i = 0; i < N; i++) {
    string s;
    int a;
    cin >> s >> a;
    Book.at(i) = make_tuple(s, 100-a, i);
  }
  
  sort(Book.begin(), Book.end());
  
  for (int i = 0; i < N; i++) {
    cout << get<2>(Book.at(i)) + 1<< endl;
  }
}
Problem p03061 (python)

Fixed submission:
import fractions
N = int(input())
A = list(map(int, input().split()))

DP_first = [0] * N
DP_last = [0] * N

DP_first[0] = A[0]
DP_last[0] = A[-1]

for i in range(1, N):
    DP_first[i] = fractions.gcd(DP_first[i-1], A[i])
    DP_last[i] = fractions.gcd(DP_last[i-1], A[-1-i])

ans = max(DP_first[N-2], DP_last[N-2])
for i in range(1, N-1):
    ans = max(ans, fractions.gcd(DP_first[i-1], DP_last[N-2-i]))
print(ans)

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

DP_first = [0] * N
DP_last = [0] * N

DP_first[0] = A[0]
DP_last[0] = A[-1]

for i in range(1, N):
    DP_first[i] = math.gcd(DP_first[i-1], A[i])
    DP_last[i] = math.gcd(DP_last[i-1], A[-1-i])

ans = max(DP_first[N-2], DP_last[N-2])
for i in range(1, N-1):
    ans = max(ans, math.gcd(DP_first[i-1], DP_last[N-2-i]))
print(ans)

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

DP_first = [0] * N
DP_last = [0] * N

DP_first[0] = A[0]
DP_last[0] = A[-1]

for i in range(1, N):
    DP_first[i] = math.gcd(DP_first[i-1], A[i])
    DP_last[i] = math.gcd(DP_last[i-1], A[-1-i])

ans = max(DP_first[N-2], DP_last[N-2])
for i in range(1, N-1):
    ans = max(ans, math.gcd(DP_first[i-1], DP_last[N-2-i]))
print(ans)
Problem p03164 (python)

Fixed submission:
N, W = map(int, input().split())
Weight = [0]
Value = [0]
ans = 0
for i in range(N):
    w, v = map(int, input().split())
    Weight.append(w)
    Value.append(v)
VS = sum(Value)
DP = [[float('inf')] * (VS + 1) for i in range(N + 1)]

for n in range(N + 1):
    for val in range(VS + 1):
        if val == 0:
            DP[n][val] = 0
        elif Value[n] > val:
            DP[n][val] = DP[n - 1][val]
        else:
            DP[n][val] = min(DP[n - 1][val], DP[n - 1][val - Value[n]] + Weight[n])
            if (n == N) and (DP[n][val] <= W):
                ans = max(ans, val)

print(ans)

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
Items = [tuple(map(int, input().split())) for _ in range(N)]
DP = [float('inf')] * 10 ** 5
DP[0] = 0
for w, v in Items:
    D = DP[:]
    for i, d in enumerate(DP):
        if w + d > W:
            continue
        D[i + v] = min(DP[i + v], w + d)
    DP = D
ans = 0
for i, d in enumerate(DP):
    if d == float('inf'):
        continue
    ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
Weight = [0]
Value = [0]

for i in range(N):
    w, v = map(int, input().split())
    Weight.append(w)
    Value.append(v)
if sum(Weight) <= W:
    print(sum(Value))
    exit()

DP = [[0] * (W + 1) for i in range(N + 1)]
for n in range(1, N + 1):
    for wei in range(W + 1):
        if Weight[n] > wei:
            DP[n][wei] = DP[n - 1][wei]
        else:
            DP[n][wei] = max(DP[n - 1][wei], DP[n - 1][wei - Weight[n]] + Value[n])
print(DP[N][W])
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
Edge = [[]for _ in range(N)]
Far = [-1]*N
for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    Edge[x].append(y)


def long(x):
    if len(Edge[x]) == 0:
        Far[x] = 0
        return 0
    if Far[x] >= 0:
        return Far[x]
    r = 0
    for i in Edge[x]:
        l = long(i) + 1
        r = max(r, l)
    Far[x] = r
    return r


for i in range(N):
    long(i)
print(max(Far))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

N, M = map(int, input().split())
Edge = [[]for _ in range(N)]
Far = [-1]*N
for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    Edge[x].append(y)


def long(x):
    if len(Edge[x]) == 0:
        Far[x] = 0
        return 0
    if Far[x] >= 0:
        return Far[x]
    r = 0
    for i in Edge[x]:
        l = long(i) + 1
        r = max(r, l)
    Far[x] = r
    return r


for i in range(N):
    long(i)
print(max(Far))

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


def long(x):
    if len(Edge[x]) == 0:
        Far[x] = 0
        return 0
    if Far[x] >= 0:
        return Far[x]
    r = 0
    for i in Edge[x]:
        l = long(i) + 1
        r = max(r, l)
    Far[x] = r
    return r


for i in range(N):
    long(i)
print(max(Far))

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


def long(x):
    if len(Edge[x]) == 0:
        Far[x] = 0
        return 0
    if Far[x] >= 0:
        return Far[x]
    r = 0
    for i in Edge[x]:
        l = long(i) + 1
        r = max(r, l)
    Far[x] = r
    return r



for i in range(N):
    long(i)
print(max(Far))

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


def long(x):
    if len(Edge[x]) == 0:
        Far[x] = 0
        return 0
    if Far[x] >= 0:
        return Far[x]
    r = 0
    for i in Edge[x]:
        l = long(i) + 1
        r = max(r, l)
        Far[x] = r
    return r



for i in range(N):
    long(i)
print(max(Far))

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

def Long(x):
    if len(Edge[x]) == 0:
        Far[x] = 0
        return 0
    if Far[x] >= 0:
        return Far[x]
    r = 0
    for i in Edge[x]:
        l = Long(i) + 1
        r = max(r, l)
    return r
ans = 0
for i in range(N):
    ans = max(ans, Long(i))
print(ans)
Problem p03219 (python)

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

print(X + Y//2)

Buggy submission (verdict: Runtime Error):
x = X + Y/2
print(x)
Problem p03262 (python)

Fixed submission:
n, x = map(int,input().split())
City = list(map(int, input().split()))
Distance = [0] * n

for i in range(n):
    Distance[i] = abs(City[i]-x)

Distance.sort()
ans = Distance[0]

def gcd(a,b):
    if a < b:
        a,b = b,a
    while a % b != 0:
        a, b = b, a % b
    return b

for i in range(1,n):
    ans = gcd(ans, Distance[i])

print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce

n, x = map(int,input().split())
City = list(map(int, input().split()))
Distance = [0] * n

for i in range(n):
    Distance[i] = abs(City[i]-x)

ans = reduce(gcd, Distance)

print(ans)
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())
ans = 1
for i, s in enumerate(S):
    if i+1 == K:
        ans = s
        break
    if s == '1':
        continue
    else:
        ans = s
        break

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
K = input()
if S[0] == '1':
    if K == 1:
        print(S[0])
    else:
        print(S[1])
else:
    print(S[0])

Buggy submission (verdict: Runtime Error):
S = input()
K = input()
if S[0] == '1':
    print(S[1])
else:
    print(S[0])
Problem p03380 (python)

Fixed submission:
import bisect

n = int(input())
A = list(map(int, input().split()))
A.sort()
ama = A[-1]
print(ama, end=' ')
ama2 = (ama + 1)//2
w = bisect.bisect_left(A, ama2)

a = A[w-1]
b = A[w]
if abs(a-ama2) > abs(b-ama2):
    print(b)
else:
    print(a)

Buggy submission (verdict: Runtime Error):
import bisect

n = int(input())
A = list(map(int, input().split()))
A.sort()
ama = A[-1]
print(ama, end=' ')
ama2 = (ama + 1)//2
w = bisect.bisect_left(A, ama2)

a = A[w]
b = A[w+1]
if abs(a-ama2) > abs(b-ama2):
    print(b)
else:
    print(a)
Problem p03436 (python)

Fixed submission:
from collections import deque
H, W = map(int, input().split())
maze = [[0 for i in range(W)]for j in range(H)]
ans = -1
for i in range(H):
    S = input()
    for j in range(W):
        maze[i][j] = S[j]
        if maze[i][j] == '.':
            ans += 1

q = deque()
q.append([0, 0])
maze[0][0] = 0
while len(q) != 0:
    x, y = q.popleft()
    for i in range(4):
        nx, ny = x + [0, 1, 0, -1][i], y + [1, 0, -1, 0][i]
        if nx < 0 or ny < 0 or nx >= W or ny >= H:
            continue
        elif maze[ny][nx] == '#':
            continue
        elif maze[ny][nx] == '.':
            maze[ny][nx] = maze[y][x] + 1
            q.append([nx, ny])
if maze[H-1][W-1] == '.':
    print(-1)
else:
    print(ans - maze[H-1][W-1])

Buggy submission (verdict: Runtime Error):
from collections import deque
H, W = map(int, input().split())
maze = [[0 for i in range(W)]for j in range(H)]
ans = -1
for i in range(H):
    S = input()
    for j in range(W):
        maze[i][j] = S[j]
        if maze[i][j] == '.':
            ans += 1

q = deque()
q.append([0, 0])
maze[0][0] = 0
while len(q) != 0:
    x, y = q.popleft()
    for i in range(4):
        nx, ny = x + [0, 1, 0, -1][i], y + [1, 0, -1, 0][i]
        if nx < 0 or ny < 0 or nx >= W or ny >= H:
            continue
        elif maze[ny][nx] == '#':
            continue
        elif maze[ny][nx] == '.':
            maze[ny][nx] = maze[y][x] + 1
            q.append([nx, ny])
print(ans - maze[H-1][W-1])
Problem p03523 (python)

Fixed submission:
x = 'KIHBR'
T = []
for i in range(1<<6):
    t = ''
    for j in range(6):
        if i&(1<<j) and j != 1 and j != 2:
            t += 'A'
        if j != 5:
            t += x[j]
    T.append(t)
S = input()
if S in T:
    print('YES')
else:
    print('NO')

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

List = ['A', 'K', 'I', 'H', 'A', 'B', 'A', 'R', 'A']
num = 0

for i in range(len(S)):
    if num > 8:
        print('NO')
        exit()
    if S[i] == List[num]:
        num += 1
    elif List[num] == 'A':
        num += 1
        if S[i] == List[num]:
            num += 1
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')

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

List = ['A', 'K', 'I', 'H', 'A', 'B', 'A', 'R', 'A']
num = 0

for i in range(len(S)):
    if S[i] == List[num]:
        num += 1
    elif List[num] == 'A':
        num += 1
        if S[i] == List[num]:
            num += 1
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')
Problem p03545 (python)

Fixed submission:
N = input()
A = []
for i in range(len(N)):
    A.append(int(N[i]))

for i in range(2 ** 3):
    List = []
    for j in range(3):
        if (i >> j) & 1 == 1:
            List.append(1)
        elif (i >> j) & 1 == 0:
            List.append(0)
    ans = A[0]
    for k in range(len(List)):
        if (List[k]):
            ans += A[k+1]
        else :
            ans -= A[k+1]

    if ans == 7:
        break

print(A[0], end="")
for i in range(3):
    if List[i]:
        print("+", end="")
    else:
        print("-", end="")
    print(A[i + 1], end="")
print("=7",end="")

Buggy submission (verdict: Runtime Error):
N = input()
a = []
for i in range(len(N)):
    a.append(int(N[i]))

X = [0]*(n-1)
flag = False

for i in range(2**(n-1)):
    if flag:
        break
    S = a[0]
    for j in range(n-1):
        if (i >> j) & 1 == 1:
            X[j] = 1
            S += a[j+1]
        else:
            X[j] = 0
            S -= a[j+1]
    if S == k:
        flag = True
        break
print(a[0], end="")
for i in range(3):
    if X[i] == 1:
        print('+', end='')
    else:
        print('-', end='')
    print(a[i+1], end="")
print('=', end='')
print(k)
Problem p03651 (python)

Fixed submission:
import fractions

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = []
for a1, a2 in zip(A, A[1:]):
    B.append(abs(a2-a1))

if K > max(A):
    print('IMPOSSIBLE')
    exit()
if K in A:
    print('POSSIBLE')
    exit()

g = B[0]
for b in B[1:]:
    g = fractions.gcd(g, b)

if (A[0] - K) % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = []
for a1, a2 in zip(A, A[1:]):
    B.append(abs(a2-a1))

if K > max(A):
    print('IMPOSSIBLE')
    exit()
if K in A:
    print('POSSIBLE')
    exit()

g = B[0]
for b in B[1:]:
    g = math.gcd(g, b)

if (A[0] - K) % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Problem p03697 (python)

Fixed submission:
a = sum(map(int, input().split()))
print(a if a < 10 else 'error')

Buggy submission (verdict: Runtime Error):
A, B =map(int,input.split())
C = A+B
if C >=10:
    print('error')
else:
    print(C)
Problem p03700 (python)

Fixed submission:
import numpy as np

N, A, B = map(int, input().split())
H = np.zeros(shape=N, dtype='int64')
for _ in range(N):
    h = int(input())
    H[_] = h


def calc(num, a):
    a -= num * B
    a = (a - 1)//(A - B) + 1
    if sum(a[a > 0]) <= num:
        return True
    else:
        return False


start = 0
end = 10 ** 10

while end - start > 1:
    mid = (start + end) // 2
    if calc(mid, H.copy()):
        end = mid
    else:
        start = mid

print(end)

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

N, A, B = map(int, input().split())
H = np.zeros(shape=N, dtype='int64')
for _ in range(N):
    h = int(input())
    H[_] = h


def calc(num, a):
    a -= num * B
    a = (a - 1)//(A - B) + 1
    if sum(a[a > 0]) <= num:
        return True
    else:
        return False


start = 0
end = 10 ** 10

while end - start > 1:
    mid = (start + end) // 2
    if calc(mid, H.copy()):
        end = mid
    else:
        start = mid

print(end)
Problem p03729 (python)

Fixed submission:
A, B, C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')
Problem p03854 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000000)

S = input()[::-1]


while len(S) > 0:
    if S[0] == 'r':
        if S[0:6] == 'resare':
            S = S[6:]
        elif S[0:7] == 'remaerd':
            S = S[7:]
        else:
            print('NO')
            exit()
    elif S[0:5] == 'maerd':
        S = S[5:]
    elif S[0:5] == 'esare':
        S = S[5:]
    else:
        print('NO')
        exit()
print('YES')

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000000)

S = input()


while len(S) > 0:
    if S[0] == 'd':
        if S[0:5] == 'dream':
            if S[5:7] == 'er':
                if S[7] == 'a':
                    S = S[5:]
                else:
                    S = S[7:]
            else:
                S = S[5:]
        else:
            print('NO')
            exit()
    elif S[0] == 'e':
        if S[0:5] == 'erase':
            if S[5] == 'r':
                S = S[6:]
            else:
                S = S[5:]
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')

Buggy submission (verdict: Runtime Error):
S = input()
while len(S) > 0:
    if S[0] == 'd':
        if S[0:5] == 'dream':
            if S[5:7] == 'er':
                if S[7] == 'a':
                    S = S[5:]
                else:
                    S = S[7:]
            else:
                S = S[5:]
        else:
            print('NO')
            exit()
    elif S[0] == 'e':
        if S[0:5] == 'erase':
            if S[5] == 'r':
                S = S[6:]
            else:
                S = S[5:]
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')
Problem p03359 (python)

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

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

Buggy submission (verdict: Runtime Error):
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if (a<=b){
			System.out.println(a);
		}else{
			System.out.println(a-1);
		}
	}
}