Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b = int(input().split())
print((b-a)*(b-a-1)//2 - a)

Fixed submission:
a,b = map(int, input().split())
print((b-a)*(b-a-1)//2 - a)

Buggy python submission (verdict: Runtime Error):
a,b = int(input().split())
print((b-a)*(b-a-1)/2 - a)

Fixed submission:
a,b = map(int, input().split())
print((b-a)*(b-a-1)//2 - a)
Buggy python submission (verdict: Time Limit Exceeded):
n,c = map(int,input().split())

cp = [0]*n
cp_rev = [0]*n
d = [0]*n

for i in range(n):
    x,v = map(int,input().split())
    d[i] = x
    cp[i] = v
    cp_rev[n-1-i] = v

sm = [0]*n
sm_rev = [0]*n

sm[0] = cp[0] - d[0]
sm_rev[0] = cp_rev[0] - (c - d[n-1])

for i in range(1,n):
    sm[i] = sm[i-1] + cp[i] - d[i] + d[i-1]
    sm_rev[i] = sm_rev[i-1] + cp_rev[i] - (c - d[n-1-i]) + c - d[n-i]

ret_ind = sm.index(max(sm))
ret_ind_rev = sm_rev.index(max(sm_rev)) 

ans = 0

for i in range(ret_ind + 1):
    ans = max(ans, sm[i])
    if n-i-2 >= 0:
        ans = max(ans, sm[i] - d[i] + max(sm_rev[:n-i-1]))

for i in range(ret_ind_rev + 1):
    ans = max(ans, sm_rev[i])
    if n-i-2 >= 0:
        ans = max(ans,sm_rev[i] - (c - d[n-1-i]) + max(sm[:n-i-1]))

print(ans)

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

cp = [0]*n
cp_rev = [0]*n
d = [0]*n

for i in range(n):
    x,v = map(int,input().split())
    d[i] = x
    cp[i] = v
    cp_rev[n-1-i] = v

sm = [0]*n
sm_rev = [0]*n
max_sm = [0]*n
max_sm_rev = [0]*n

sm[0] = cp[0] - d[0]
sm_rev[0] = cp_rev[0] - (c - d[n-1])
max_sm[0] = sm[0]
max_sm_rev[0] = sm_rev[0]

for i in range(1,n):
    sm[i] = sm[i-1] + cp[i] - d[i] + d[i-1]
    sm_rev[i] = sm_rev[i-1] + cp_rev[i] - (c - d[n-1-i]) + c - d[n-i]
    max_sm[i] = max(max_sm[i-1],sm[i])
    max_sm_rev[i] = max(max_sm_rev[i-1],sm_rev[i])

ret_ind = sm.index(max(sm))
ret_ind_rev = sm_rev.index(max(sm_rev)) 

ans = 0

for i in range(ret_ind + 1):
    ans = max(ans, sm[i])
    if n-i-2 >= 0:
        ans = max(ans, sm[i] - d[i] + max_sm_rev[n-i-2])

for i in range(ret_ind_rev + 1):
    ans = max(ans, sm_rev[i])
    if n-i-2 >= 0:
        ans = max(ans,sm_rev[i] - (c - d[n-1-i]) + max_sm[n-i-2])

print(ans)
Buggy python submission (verdict: Runtime Error):
return min(N*A,B)

Fixed submission:
n,a,b = map(int, input().split(' '))
print(min(n*a,b))
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop, heappush
n = int(input())
INF = 10**13
g = [[INF for __ in range(n)] for _ in range(n)]

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


def dijkstra(s, n, edges):
    # edges[i][j] : the cost of i→j
    # import 'heap'
    d = [INF] * n
    d[s] = 0
    q = [(0, s)]
    while q:
        dist_u, u = heappop(q)
        if d[u] < dist_u:
            continue
        for v, c in enumerate(edges[u]):
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q, (d[v], v))
    return d


q, k = map(int, input().split())
d = dijkstra(k-1, n, g)

for _ in range(q):
    x, y = map(int, input().split())
    print(d[x-1]+d[y-1])


Fixed submission:
from heapq import heappop, heappush
n = int(input())
g = [[] for _ in range(n)]

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


def dijkstra(s, n, edges):
    # edges[i][j] : the cost of i→j
    # import 'heap'
    d = [10**18] * n
    d[s] = 0
    q = [(0, s)]
    while q:
        dist_u, u = heappop(q)
        if d[u] < dist_u:
            continue
        for v, c in edges[u]:
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q, (d[v], v))
    return d


q, k = map(int, input().split())
d = dijkstra(k-1, n, g)

for _ in range(q):
    x, y = map(int, input().split())
    print(d[x-1]+d[y-1])
Buggy python submission (verdict: Runtime Error):
print( 800*int(input()) - 200*(int(input()) // 15))

Fixed submission:
a = int(input())
print( 800*a - 200*(a//15) )
Buggy python submission (verdict: Runtime Error):
a,b,c,d = input().split()
print(max(a*b,c*d))

Fixed submission:
a,b,c,d = map(int, input().split())
print(max(a*b,c*d))
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int, input().split())

x =0

for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i + j + l == s:
                x +=1

print(x)

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

x =0

for i in range(min(k+1,s+1)):
    x += max(0, min(s-i,k)+1 - max(0,s-i-k) )

print(x)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = [int(x)-i-1 for i, x in enumerate(input().split())]
x = sorted(zip(x, range(1, n+1)))

stack = []
for v, i in x[::-1]:
    for _ in range(i-1):
        stack.append(i)

cur = 0
ans = []
res = []
cnt = [0]*(n+1)
for i in range(n):
    for _ in range(x[i][0]-cur):
        if stack:
            nxt = stack.pop()
        elif res:
            nxt = res.pop()
        else:
            print('No')
            exit()
        ans.append(nxt)
        cnt[nxt] += 1
    if cnt[x[i][1]] < x[i][1]-1:
        print('No')
        exit()
    ans.append(x[i][1])
    for _ in range(n-x[i][1]):
        res.append(x[i][1])
    cur += x[i][0]

for v, i in x:
    if ans[v+i-1] != i:
        print('No')
        exit()

print('Yes')
print(*ans)


Fixed submission:
n = int(input())
x = [int(x) for i, x in enumerate(input().split())]
x = sorted(zip(x, range(1, n+1)))

stack = []
for v, i in x[::-1]:
    for _ in range(i-1):
        stack.append(i)

cur = 1
ans = []
res = []
cnt = [0]*(n+1)
for i in range(n):
    for _ in range(x[i][0]-cur):
        if stack:
            nxt = stack.pop()
        elif res:
            nxt = res.pop()
        else:
            print('No')
            exit()
        ans.append(nxt)
        cnt[nxt] += 1
    if cnt[x[i][1]] != x[i][1]-1:
        print('No')
        exit()
    ans.append(x[i][1])
    for _ in range(n-x[i][1]):
        res.append(x[i][1])
    cur = x[i][0]+1

ans += res

print('Yes')
print(*ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
x = [int(x)-i-1 for i, x in enumerate(input().split())]
x = sorted(zip(x, range(1, n+1)))

stack = []
for v, i in x[::-1]:
    for _ in range(i-1):
        stack.append(i)

cur = 0
ans = []
res = []
cnt = [0]*(n+1)
for i in range(n):
    for _ in range(x[i][0]-cur):
        if stack:
            nxt = stack.pop()
        else:
            nxt = res.pop()
        ans.append(nxt)
        cnt[nxt] += 1
    if cnt[x[i][1]] < x[i][1]-1:
        print('No')
        exit()
    ans.append(x[i][1])
    for _ in range(n-x[i][1]):
        res.append(x[i][1])
    cur += x[i][0]

print('Yes')
print(*ans)


Fixed submission:
n = int(input())
x = [int(x) for i, x in enumerate(input().split())]
x = sorted(zip(x, range(1, n+1)))

stack = []
for v, i in x[::-1]:
    for _ in range(i-1):
        stack.append(i)

cur = 1
ans = []
res = []
cnt = [0]*(n+1)
for i in range(n):
    for _ in range(x[i][0]-cur):
        if stack:
            nxt = stack.pop()
        elif res:
            nxt = res.pop()
        else:
            print('No')
            exit()
        ans.append(nxt)
        cnt[nxt] += 1
    if cnt[x[i][1]] != x[i][1]-1:
        print('No')
        exit()
    ans.append(x[i][1])
    for _ in range(n-x[i][1]):
        res.append(x[i][1])
    cur = x[i][0]+1

ans += res

print('Yes')
print(*ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a] + b)

Fixed submission:
a = input().split()

if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))

Buggy python submission (verdict: Runtime Error):
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = int(input()).split()
  test[a] = b
  print(sum(test))

Fixed submission:
a = input().split()

if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))

Buggy python submission (verdict: Runtime Error):
N = input()
test = list(map(int,input()))
M = input() 
  
for _ in range(M):
  a,b = int(input()).split()
  test[a] = b
  print(sum(test))

Fixed submission:
a = input().split()

if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))

Buggy python submission (verdict: Runtime Error):
a = input().split()
return int(a[0]) + int(a[2]) if a[1] == "+" else int(a[0]) - int(a[2])

Fixed submission:
a = input().split()

if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))

Buggy python submission (verdict: Runtime Error):
a = input().split("")
return int(a[0]) + int(a[2]) if a[1] == "+" else int(a[0]) - int(a[2])

Fixed submission:
a = input().split()

if a[1] == "+":
  print(int(a[0]) + int(a[2]))
else:
  print(int(a[0]) - int(a[2]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a] + b)

Fixed submission:
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a-1] + b)

Buggy python submission (verdict: Runtime Error):
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  test[a] = b
  print(sum(test))

Fixed submission:
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a-1] + b)

Buggy python submission (verdict: Runtime Error):
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = int(input()).split()
  test[a] = b
  print(sum(test))

Fixed submission:
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a-1] + b)

Buggy python submission (verdict: Runtime Error):
N = input()
test = list(map(int,input().split()))
M = input() 
  
for _ in range(M):
  a,b = int(input()).split()
  test[a] = b
  print(sum(test))

Fixed submission:
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a-1] + b)

Buggy python submission (verdict: Runtime Error):
N = input()
test = list(map(int,input()))
M = input() 
  
for _ in range(M):
  a,b = int(input()).split()
  test[a] = b
  print(sum(test))

Fixed submission:
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a-1] + b)

Buggy python submission (verdict: Runtime Error):
N = input()
test = list(map(int,input()))

for _ in range(input()):
  a,b = int(input()).split()
  test[a] = b
  print(sum(test))

Fixed submission:
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a-1] + b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
from math import ceil, gcd

tkhs = 1
aoki = 1

for _ in range(n):
    t, a = map(int, input().split())
    t, a = t // gcd(t,a), a // gcd(t,a)
    k = max(ceil(tkhs/t), ceil(aoki/a))
    tkhs = k*t
    aoki = k*a

print(tkhs+aoki)



Fixed submission:
n = int(input())
from math import ceil

tkhs = 1
aoki = 1

for _ in range(n):
    t, a = map(int, input().split())
    k = max((tkhs+t-1)//t, (aoki+a-1)//a)
    tkhs = k*t
    aoki = k*a

print(tkhs+aoki)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

tkhs = 1
aoki = 1

for _ in range(n):
    t, a = map(int, input().split())
    k = 1
    while not(tkhs <= k*t and aoki <= k*a):
        k += 1
    tkhs = k*t
    aoki = k*a

print(tkhs+aoki)


Fixed submission:
n = int(input())
from math import ceil

tkhs = 1
aoki = 1

for _ in range(n):
    t, a = map(int, input().split())
    k = max((tkhs+t-1)//t, (aoki+a-1)//a)
    tkhs = k*t
    aoki = k*a

print(tkhs+aoki)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, k = map(int, input().split())
a = [int(x)-1 for x in input().split()]
ans = 0
if a[0] != 0:
    ans += 1
    a[0] = 0

g = [[] for _ in range(n)]
for i in range(1, n):
    g[i].append(a[i])
    g[a[i]].append(i)


f = [0]*n


def dfs(v, par):
    global ans
    for w in g[v]:
        if w != par:
            dfs(w, v)
            if f[w]+1 == k and v != 0:
                ans += 1
                continue
            f[v] = max(f[v], f[w]+1)
    return ans


print(dfs(0, -1))


Fixed submission:
from collections import deque
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, k = map(int, input().split())
a = [int(x)-1 for x in input().split()]
ans = 0
if a[0] != 0:
    ans += 1
    a[0] = 0


# g = [[] for _ in range(n)]
# for i in range(1, n):
#     g[i].append(a[i])
#     g[a[i]].append(i)


def dfs(v, par):
    global ans
    for w in g[v]:
        if w != par:
            dfs(w, v)
            if f[w]+1 == k and v != 0:
                ans += 1
                continue
            f[v] = max(f[v], f[w]+1)
    return ans


# TLE
# f = [0]*n
# print(dfs(0, -1))


# Topological Sort (TS)をDFSの代わりとする。
g = [[] for _ in range(n)]
indeg = [0]*n
for i in range(1, n):
    g[a[i]].append(i)
    indeg[i] += 1
q = deque([0])
TS = [0]
while q:
    v = q.popleft()
    for w in g[v]:
        indeg[w] -= 1
        if indeg[w] == 0:
            TS.append(w)
            q.append(w)

f = [0]*n
for w in TS[::-1]:
    if f[w] + 1 == k and a[w] != 0:
        ans += 1
        continue
    f[a[w]] = max(f[a[w]], f[w]+1)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,a = map(int,input().split())
x = list(map(int,input().split()))
x = list(map(lambda y:y-a,x))

ans = -1

for i in range(2**n):
    tmp = 0
    for j in range(n):
        if (i >> j) & 1:
            tmp += x[j]
    if tmp == 0:
        ans += 1

print(ans)

Fixed submission:
n,a = map(int,input().split())
x = sorted(list(map(lambda y:int(y)-a,input().split())))

sx = max(abs(x[0]),abs(x[-1]))*n

dp = [[0 for _ in range(2*sx+2)] for _ in range(n+1)]
dp[0][0] = 1

for j in range(n):
    for t in range(-sx-1,sx+1):
        if -sx <= t-x[j] and t-x[j] <= sx: 
            dp[j+1][t] = dp[j][t] + dp[j][t-x[j]]
        else:
            dp[j+1][t] = dp[j][t]

print(dp[n][0]-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = int(input())

ans = float('inf')

for b in range(2, 10**6):
    res = n
    tmp = 0
    while res > 0:
        tmp += res % b
        res = (res-res % b)//b
    if tmp == s:
        ans = min(ans, b)

if n < 10**6:
    print(ans if ans != float('inf') else -1)
    exit()

for p in range(1, 10**6):
    if (n-s) % p != 0:
        continue
    else:
        b = (n-s)//p + 1
        if n % b == s-p:
            ans = min(ans, b)
        
print(ans if ans != float('inf') else -1)

Fixed submission:
n = int(input())
s = int(input())

import math

ans = float('inf')

if s == n:
    print(n+1)
    exit()

for b in range(2, 10**6):
    res = n
    tmp = 0
    while res > 0:
        tmp += res % b
        res = (res-res % b)//b
    if tmp == s:
        ans = min(ans, b)

if n < 10**6:
    print(ans if ans != float('inf') else -1)
    exit()

for p in range(1, 10**6):
    if (n-s) % p != 0:
        continue
    else:
        b = (n-s)//p + 1
        if b > math.sqrt(n) and n % b == s-p:
            ans = min(ans, b)
        
print(ans if ans != float('inf') else -1)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

total_vote = np.sum(A)
threshold = total_vote/(4*M)
A.sort(reverse = True)
if A[M] > threshold:
    print('Yes')
else:
    print('No')

Fixed submission:
import numpy as np

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

total_vote = np.sum(A)
threshold = total_vote/(4*M)
A.sort(reverse = True)
if A[M-1] >= threshold:
    print('Yes')
else:
    print('No')

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

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

total_vote = np.sum(A)
threshold = total_vote*(1/4*M)
A.sort(reverse = True)
if A[M] > threshold:
    print('Yes')
else:
    print('No')

Fixed submission:
import numpy as np

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))

total_vote = np.sum(A)
threshold = total_vote/(4*M)
A.sort(reverse = True)
if A[M-1] >= threshold:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
K, N = list(map(int,input().split()))
A = list(map(int,input().split()))
for i in range(len(A)):
    min_this = 0
    for j in range(len(A)-1):
        now_point = A[i+j-len(A)]
        next_point = A[i+j+1-len(A)]
        if next_point - now_point < 0:
            min_this += (K-now_point) + next_point
        else:
            min_this += next_point - now_point
    if i==0:
        total_min = min_this
    else:
        if min_this < total_min:
            total_min = min_this
print(total_min)

Fixed submission:
K, N = list(map(int,input().split()))
A = list(map(int,input().split()))
for i in range(len(A)):
    now_point = A[i]
    last_point = A[i-1]
    if last_point == 0:
        last_point = K
    if last_point - now_point <= 0:
        now_min = (K-now_point) + last_point
    else:
        now_min = last_point - now_point
    if i==0:
        total_min = now_min
    else:
        if now_min < total_min:
            total_min = now_min
print(total_min)
Buggy python submission (verdict: Runtime Error):
import numpy as np
A, B = list(map(int,input().split()))
ans = np.lcm(A, B)
print(ans)

Fixed submission:
import numpy as np
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x%y == 0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z
        
def lcm(m, n):
    return int(m*n/gcd(m,n))

A, B = list(map(int,input().split()))
ans = lcm(A, B)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K, Q=list(map(int,input().split()))
points = K * np.ones(N)
for i in range(Q):
    A = int(input()) - 1
    points -= 1
    points[A] += 1
for i in range(N):
    if points[i] > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
import numpy as np

N, K, Q=list(map(int,input().split()))
points = K * np.ones(N)
A_list = np.zeros(Q)

for i in range(Q):
    A = int(input()) - 1
    A_list[i] = A

points = points - Q
for i in A_list:
    points[int(i)] += 1

for i in range(N):
    if points[i] > 0:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Runtime Error):
N, K, Q=list(map(int,input().split()))
points = K * np.ones(N)
for i in range(Q):
    A = int(input()) - 1
    points -= 1
    points[A] += 1
for i in range(N):
    if points[i] > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
import numpy as np

N, K, Q=list(map(int,input().split()))
points = K * np.ones(N)
A_list = np.zeros(Q)

for i in range(Q):
    A = int(input()) - 1
    A_list[i] = A

points = points - Q
for i in A_list:
    points[int(i)] += 1

for i in range(N):
    if points[i] > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
import numpy as np
a=int(input())
b=int(input())

if a>b:
  c=a+(a-1)
if a<b:
  c=b+(b-1)
if a==b:
  c=a+b
print(c)

Fixed submission:
import numpy as np
a,b=map(int, input().split())

if a>b:
  c=a+(a-1)
if a<b:
  c=b+(b-1)
if a==b:
  c=a+b
print(c)
Buggy python submission (verdict: Runtime Error):
import sys
S = input()
T = "AKIHABARA"
posS = 0
posT = 0
while True:
    if posS == len(S) and posT >= len(T)-1:
        print("YES")
        sys.exit()
    if posT >= len(T):
        print("NO")
        sys.exit()
    if S[posS] == T[posT]:
        posS += 1
        posT += 1
    elif T[posT] == 'A':
        posT += 1
    else:
        print("NO")
        sys.exit()

Fixed submission:
import sys
S = input()
T = "AKIHABARA"
posS = 0
posT = 0
while True:
    if posS == len(S):
        if posT >= len(T)-1:
            print("YES")
        else:
            print("NO")
        sys.exit()
    if posT >= len(T):
        print("NO")
        sys.exit()
    if S[posS] == T[posT]:
        posS += 1
        posT += 1
    elif T[posT] == 'A':
        posT += 1
    else:
        print("NO")
        sys.exit()

Buggy python submission (verdict: Runtime Error):
import sys
S = input()
T = "AKIHABARA"
pos = 0
for x in S:
    if pos >= len(T):
        print("NO")
        sys.exit()
    if x == T[pos]:
        pos += 1
    elif T[pos] == 'A':
        pos += 1
        if x == T[pos]:
            pos += 1
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
print("YES")

Fixed submission:
import sys
S = input()
T = "AKIHABARA"
posS = 0
posT = 0
while True:
    if posS == len(S):
        if posT >= len(T)-1:
            print("YES")
        else:
            print("NO")
        sys.exit()
    if posT >= len(T):
        print("NO")
        sys.exit()
    if S[posS] == T[posT]:
        posS += 1
        posT += 1
    elif T[posT] == 'A':
        posT += 1
    else:
        print("NO")
        sys.exit()
Buggy python submission (verdict: Runtime Error):
S = input()
flag = False
for i in range(26):
    c = chr(ord('a')+i)
    if c not in S:
        print(c)
        flag = True
        break
if !flag:
    print('None')

Fixed submission:
S = input()
flag = False
for i in range(26):
    c = chr(ord('a')+i)
    if c not in S:
        print(c)
        flag = True
        break
if flag == False:
    print('None')
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, input().split()))
if (a == 'H' and b == 'H') or (a == 'D' and b == 'D'):
    print('H')
else:
    print('D')

Fixed submission:
a, b = list(map(str, input().split()))
if (a == 'H' and b == 'H') or (a == 'D' and b == 'D'):
    print('H')
else:
    print('D')
Buggy python submission (verdict: Runtime Error):
str = "CODEFESTIVAL2016"
s =input()
cnt = 0
for i in range(16):
  if s[i]!=str[i]:
    cnt++
print(cnt)

Fixed submission:
str = "CODEFESTIVAL2016"
s =input()
cnt = 0
for i in range(16):
  if s[i]!=str[i]:
    cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
x = min(b-1, n)
ans = max(int((a*x)/b) - a*int(x/b))
print(ans)


Fixed submission:
a, b, n = map(int, input().split())
x = min(b-1, n)
ans = int((a*x)/b) - a*int(x/b)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys

a, b, n = map(int, input().split())
step = math.ceil(1/10**3)
array = range(1, n+1, step)
ans = -sys.maxsize-1

for x in array:
    val = int((a*x)/b) - a*int(x/b)
    if val > ans:
        ans = val

print(ans)


Fixed submission:
a, b, n = map(int, input().split())
x = min(b-1, n)
ans = int((a*x)/b) - a*int(x/b)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import sys

a, b, n = map(int, input().split())
array = range(1, n+1, math.ceil(1/10**5))
ans = -sys.maxsize-1

for x in array:
    val = int((a*x)/b) - a*int(x/b)
    if val > ans:
        ans = val

print(ans)


Fixed submission:
a, b, n = map(int, input().split())
x = min(b-1, n)
ans = int((a*x)/b) - a*int(x/b)
print(ans)

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

a, b, n = map(int, input().split())
array = np.arange(1, n+1, math.ceil(1/10**5))
ans = -sys.maxsize-1

for x in array:
    val = int((a*x)/b) - a*int(x/b)
    if val > ans:
        ans = val

print(ans)


Fixed submission:
a, b, n = map(int, input().split())
x = min(b-1, n)
ans = int((a*x)/b) - a*int(x/b)
print(ans)