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

Fixed submission:
#D問題
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

N, K = map(int, input().split())
red = N - K
for i in range(1,K+1):
        if N-K+1 < i:
            print(0)
        else:
            divide_line = combinations_count(red+1, i)
            case =combinations_count(K-1,i-1) * divide_line
            ans = case%(10**9+7)
            print(ans)

Buggy submission (verdict: Runtime Error):
#D問題
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

N, K = map(int, input().split())
red = N - K
for i in range(K):
    if i+1 ==1:
        ans = (red+1)
        print(ans)
    else:
        if i + 1 < K:
            divide_line = combinations_count(red+1, i+1)
            case =combinations_count(K-1,i) * divide_line
            ans = case%(10**9+7)
            print(ans)
        else:
            ans = combinations_count(red+1,K)%(10**9 + 7)
            print(ans)

Buggy submission (verdict: Runtime Error):
#D問題
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

N, K = map(int, input().split())
red = N - K
for i in range(K):
    if i+1 ==1:
        ans = (red+1)
        print(ans)
    else:
        if i + 1 < K:
            divide_line = combinations_count(K-1, i)
            case =combinations_count(red+1,i+1) * divide_line
            ans = case%(10**9+7)
            print(ans)
        else:
            ans = combinations_count(red+1,K)%(10**9 + 7)
            print(ans)
Problem p03038 (python)

Fixed submission:
import heapq as hq
N, M = map(int, input().split())
A = list(map(int,input().split()))
A = [(-i,1) for i in A]
hq.heapify(A)
for i in range(M):
    B, C = map(int, input().split())
    hq.heappush(A,(-C,B))
sum_A = 0
for i in range(N):
    add_num = hq.heappop(A)
    sum_A += add_num[0]*-1
    if add_num[1] > 1:
        hq.heappush(A,(add_num[0],add_num[1]-1))
print(sum_A)

Buggy submission (verdict: Runtime Error):
#D問題
N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(M):
    B, C = map(int, input().split())
    A.extend([C]*B)
A.sort()
print(sum(A[:n]))
Problem p03208 (python)

Fixed submission:
N,K = map(int,input().split())
tree_list = [int(input()) for _ in range(N)]
tree_list = sorted(tree_list)
ans = 10**9
for i in range(N-K+1):
    compare = tree_list[i+K-1]-tree_list[i]
    if ans > compare:
        ans = compare
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
tree_list = [int(input()) for _ in range(N)]
tree_list = sorted(tree_list)
ans = 10**9
for i in range(N-K+1):
    compare = tree_list[i+2]-tree_list[i]
    if ans > compare:
        ans = compare
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
tree_list = []
for i in range(N):
    tree_list.append(int(input()))
tree_list = sorted(tree_list)
ans = 10**9
for i in range(N-K+1):
    compare = tree_list[i+2]-tree_list[i]
    if ans > compare:
        ans = compare
    if ans == 0:
      break
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
tree_list = []
for i in range(N):
    tree_list.append(int(input()))
tree_list = sorted(tree_list)
ans = 10**9
for i in range(N-K+1):
    compare = tree_list[i+2]-tree_list[i]
    if ans > compare:
        ans = compare
print(ans)
Problem p03221 (python)

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


length = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
  length[i].insert(2,i)
length = sorted(length)
ans_list =[0]*M
count = 1
for i in range(M):
  if i == 0:
    ans = str(length[i][0]).zfill(6) + str(count).zfill(6)
    ans_list[i] = [length[i][2],ans]
  elif i >= 1 and length[i][0] == length[i-1][0]:
    count += 1
    ans = str(length[i][0]).zfill(6) + str(count).zfill(6)
    ans_list[i] = [length[i][2],ans]
  elif i >= 1 and length[i][0] != length[i-1][0]:
    count = 1
    ans = str(length[i][0]).zfill(6) + str(count).zfill(6)
    ans_list[i] = [length[i][2],ans]
ans_list.sort(key=lambda x: x[0])
for i in range(M):
  print(ans_list[i][1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
length = [list(map(int,input().split()).append(i)) for _ in range(M)]
print(length)
Problem p02792 (python)

Fixed submission:
def left(text, n):
  return text[:n]

def right(text, n):
  return text[-n:]

def mid(text, n, m):
  return text[n-1:n+m-1]
  
n = int(input())

rangeSet = [[0]*10 for i in range(10)]

# [1,9][9,1]など先頭＋最終の組み合わせを設定
for i in range(1,n+1):
	first = int(left(str(i),1))
	end = int(right(str(i),1))
	rangeSet[first][end] += 1

kumiawase = 0
for k in range(1,10):
	for l in range(1,10):
		tmp = rangeSet[k][l] * rangeSet[l][k]
		kumiawase += tmp	
print(kumiawase)

Buggy submission (verdict: Runtime Error):
def left(text, n):
  return text[:n]

def right(text, n):
  return text[-n:]

def mid(text, n, m):
  return text[n-1:n+m-1]
  
n = int(input())

rangeSet = [[0]*10 for i in range(10)]

# [1,9][9,1]など先頭＋最終の組み合わせを設定
for i in range(1,n+1):
	first = int(left(str(i),1))
	end = int(right(str(i),1))
	rangeSet[first][end] += 1

    kumiawase = 0
for k in range(1,10):
	for l in range(1,10):
		tmp = rangeSet[k][l] * rangeSet[l][k]
		kumiawase += tmp	
print(kumiawase)
Problem p03013 (python)

Fixed submission:
import sys
input = sys.stdin.readline

MOD = 1000000007


def main():
    n, m = [int(i) for i in input().split()]
    a = {int(input()) for _ in range(m)}
    steps = [0] * (n + 1)
    steps[0] = 1

    for now in range(n):
        for next_ in range(now + 1, min(now + 2, n) + 1):
            if next_ not in a:
                steps[next_] += steps[now] % MOD
                steps[next_] %= MOD
    print(steps[-1])


if __name__ == '__main__':
    main()

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

MOD = 1000000007


def main():
    n, m = [int(i) for i in input().split()]
    a = {int(input()) for _ in range(m)}
    steps = [0] * (n + 1)
    steps[0] = 1

    for now in range(n):
        for next_ in range(now + 1, min(now + 2, n) + 1):
            if next_ not in a:
                steps[next_] += steps[now] % MOD
                steps[next_ %= MOD]
    print(steps[-1])


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

Fixed submission:
S = input()

head = int(S[:2])
tail = int(S[2:])

ans = "NA"
if 1 <= head <= 12:
    if 1 <= tail <= 12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"
elif 1 <= tail <= 12:
    ans = "YYMM"

print(ans)

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

head = int(S[:2])
tail = int(s[2:])

ans = "NA"
if 1 <= head <= 12:
    if 1 <= tail <= 12:
        ans = "AMBIGUOUS"
    else:
        "YYMM"
elif 1 <= tail <= 12:
    ans = "MMYY"
    
print(ans)
Problem p03072 (python)

Fixed submission:
N = int(input())
H = [int(i) for i in input().split()]
viewable = []

max_h = H[0]
for h in H:
    if h >= max_h:
        viewable.append(1)
    else:
        viewable.append(0)
    max_h = max(max_h, h)

ans = sum(viewable)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = [int(i) for i in input().split()]
viewable = []

max_h = h[0]
for h in H:
    if h >= max_h:
        viewable.append(1)
    else:
        viewable.append(0)
    max_h = max(max_h, h)

ans = sum(viewable)
print(ans)
Problem p03221 (python)

Fixed submission:
import collections
City = collections.namedtuple("City", ("number", "pref", "year"))

n, m = [int(i) for i in input().split()]
cities = []
for i in range(m):
    pref, year = input().split()
    city = City(i, int(pref), int(year))
    cities.append(city)
id_numbers = []
cities.sort(key=lambda x: x.year)
cities.sort(key=lambda x: x.pref)
prev_pref = None
for city in cities:
    if prev_pref is None or city.pref != prev_pref:
        rank = 1
    else:
        rank += 1
    id_numbers.append((city.number, city.pref, rank))
    prev_pref = city.pref
id_numbers.sort(key=lambda x: x[0])
for i in id_numbers:
    print("{:0>6}{:0>6}".format(i[1], i[2]))

Buggy submission (verdict: Runtime Error):
import collections
City = collections.namedtuple("City", ("number", "pref", "year"))

n, m = [int(i) for i in input().split()]
cities = []
for i in range(m):
    pref, year = input().split()
    city = City(i, int(pref), int(year))
    cities.append(city)
id_numbers = []
cities.sort(key=lambda x: x.year)
cities.sort(key=lambda x: x.pref)
prev_pref = None
for city in cities:
    if prev_pref is None or city.pref != prev_pref:
        rank = 1
    else:
        rank += 1
    id_numbers.append((city.number, city.pref, rank))
    prev_pref = city.pref
id_numbers.sort(key=lambda x: x[0])
for i in id_numbers:
    print(f"{i[1]:0>6}{i[2]:0>6}")
Problem p03315 (python)

Fixed submission:
s = input()
ans = 0

for c in s:
  if c == "+":
    ans += 1
  else:
    ans -= 1

print(ans)

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

for c in s:
  if c == "+":
    ans += 1
  else:
    ans -= 1

print(ans)
Problem p03038 (python)

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

card = []
card_num = []

for a in A_list:
    card.append(a)
    card_num.append(1)
        
for _ in range(M):
    B, C = list(map(int, input().split()))
    card.append(C)
    card_num.append(B)
    
union = zip(card, card_num)
sorted_union = sorted(union, key=lambda x:x[0])[-1::-1]
sorted_card, sorted_card_num = zip(*sorted_union)

ans = 0
current_num = 0
for c, c_num in zip(sorted_card, sorted_card_num):
    if current_num + c_num < N:
        current_num += c_num
        ans += c * c_num
    else:
        ans += c * (N - current_num)
        current_num = N
        break
print(ans)

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

card = []
card_num = []

for a in A_list:
    card.append(a)
    card_num.append(1)
    
for _ in range(M):
    B, C = list(map(int, input().split()))
    card.append(C)
    card_num.append(B)
    
union = zip(card, card_num)
sorted_union = sorted(union, key=lambda x:x[0])[-1::-1]
sorted_card, sorted_card_num = zip(*sorted_union)a

ans = 0
current_num = 0
for c, c_num in zip(sorted_card, sorted_card_num):
    if current_num + c_num <= N:
        current_num += c_num
        ans += c * c_num
    else:
        current_num = N
        ans += c * (N - current_num)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = list(map(int, input().split()))
A_list = list(map(int, input().split()))

card_num = np.zeros(10**9+1)
max_num = -1
for a in A_list:
    card_num[a] += 1
    if max_num < a:
        max_num = a

for _ in range(M):
    B, C = list(map(int, input().split()))
    card_num[C] += B
    if max_num < C:
        max_num = C

ans = 0
current_num = 0
for i in range(max_num, 0, -1):
    num = card_num[i]
    if num == 0:
        continue
    else:
        if current_num + num <= N:
            ans += num * i
            current_num += num
        else:
            ans += (N-current_num) * i
            break
print(int(ans))
Problem p03107 (python)

Fixed submission:
S = input()

save = []
flag = False
modori_flag = False
count = 0
for idx, s in enumerate(S):
    if modori_flag:
        modori_flag = False
    elif flag:
        flag = False
        continue
            
    this_ = int(s)
    if len(save) > 0 and this_ + save[-1] == 1:
        modori_flag = True
        del save[-1]
        count += 2
        continue
    if idx == len(S) -1:
        break
    next_ = int(S[idx+1])
    if this_ + next_ == 1:
        flag = True
        count += 2
        continue
        
    save.append(this_)
    
print(count)

Buggy submission (verdict: Runtime Error):
#c

S = input()

def clean(seq):
#     print("seq: ", seq)
    if len(seq) == 1:
        return seq
    
    def get_removee_left(cand_seq):
        if len(cand_seq) == 1:
            return -1
        for idx, s in enumerate(cand_seq[:-1]):
            if int(s) + int(cand_seq[idx+1]) == 1:
                return idx
        return -1
        
    ans = seq
    
    left = get_removee_left(seq)
#     print("left: ",left)
    if left > 0:
#         print("give:",seq[:left]+seq[left+2:])
        give = seq[:left]+seq[left+2:]
        ans = clean(give)
    elif left == 0:
#         print("give:", seq[left+2:])
        ans = clean(seq[left+2:])
    else:
        pass
        
    return ans
    
    
#     cleaned_seq = []
#     remove_flag = False
#     for idx, s in enumerate(seq):
#         if remove_flag:
#             ans = clean(clean_seq)
            
#         if idx == len(seq)-1:
#             cleaned_seq.append(s)
#             break

#         this_ = int(s)
#         next_ = int(seq[idx+1])
#         if this_ + next_ == 1:
#             remove_flag = True
#         else:
#             cleaned_seq.append(s)
            
#     return cleaned_seq

# former_cleaned = []
# cleaned = S
# while(not len(cleaned) == len(former_cleaned)):
#     former_cleaned = cleaned
#     cleaned = clean(former_cleaned)
    
# print(len(S) - len(cleaned))
print(len(S) - len(clean(S)))
Problem p03135 (python)

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

print(T/X)

Buggy submission (verdict: Runtime Error):
T, X = map(int, input(),split())
print(T/X)
Problem p04049 (python)

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(1000000)
def calc_dist(b,h,dist,E,D,ne):
	D[dist] += 1
	for nxt in E[h]:
		if nxt == b or nxt == ne:
			continue
		calc_dist(h,nxt,dist+1,E,D,ne) 

def solve():
	N,K = map(int,raw_input().split())
	pairs = []
	E = [[] for i in xrange(N)]
	for i in xrange(N-1):
		a,b = map(lambda x:int(x)-1,raw_input().split())
		E[a].append(b)
		E[b].append(a)
		pairs.append((a,b))
	ans = N
	rad = K/2
	if K % 2 == 0:
		for i in xrange(N):
			D = [0]*N
			calc_dist(-1,i,0,E,D,-1)
			for j in xrange(rad):
				D[rad-j-1] += D[rad-j]
			ans = min(N-D[0],ans)
	else:
		for a,b in pairs:
			D1 = [0]*N
			D2 = [0]*N
			calc_dist(-1,a,0,E,D1,b)
			calc_dist(-1,b,0,E,D2,a)
			for j in xrange(rad):
				D1[rad-j-1] += D1[rad-j]
				D2[rad-j-1] += D2[rad-j]
			ans = min(N-D1[0]-D2[0],ans)
	print ans

solve()

Buggy submission (verdict: Runtime Error):
def calc_dist(b,h,dist,E,D,ne):
	D[dist] += 1
	for nxt in E[h]:
		if nxt == b or nxt == ne:
			continue
		calc_dist(h,nxt,dist+1,E,D,ne) 

def solve():
	N,K = map(int,raw_input().split())
	pairs = []
	E = [[] for i in xrange(N)]
	for i in xrange(N-1):
		a,b = map(lambda x:int(x)-1,raw_input().split())
		E[a].append(b)
		E[b].append(a)
		pairs.append((a,b))
	ans = N
	rad = K/2
	if K % 2 == 0:
		for i in xrange(N):
			D = [0]*N
			calc_dist(-1,i,0,E,D,-1)
			for j in xrange(rad):
				D[rad-j-1] += D[rad-j]
			ans = min(N-D[0],ans)
	else:
		for a,b in pairs:
			D1 = [0]*N
			D2 = [0]*N
			calc_dist(-1,a,0,E,D1,b)
			calc_dist(-1,b,0,E,D2,a)
			for j in xrange(rad):
				D1[rad-j-1] += D1[rad-j]
				D2[rad-j-1] += D2[rad-j]
			ans = min(N-D1[0]-D2[0],ans)
	print ans

solve()
Problem p02984 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 7)

debug = True
debug = False


def dprint(*objects):
    if debug == True:
        print(*objects)


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    def check(A, x):
        ans = [x]
        for i in range(1, N):
            tmp = A[i - 1] - ans[i - 1]
            if tmp < 0:
                if i % 2 == 1:
                    return 1, ans
                else:
                    return -1, ans
            else:
                ans.append(tmp)

        tmp = A[N - 1] - (ans[N - 1])
        if x > tmp:
            return 1, ans
        elif x < tmp:
            return -1, ans
        else:
            return 0, ans

    x = min(A[0], A[N - 1])
    jump = min(A[0], A[N - 1]) // 2

    # i = 0
    while True:
        # i += 1
        # if i > 10:
        #     break
        ret, ans = check(A, x)
        if ret == 1:
            x = x - jump
        elif ret == -1:
            x = x + jump
        else:
            dprint(x, ret, ans, jump)
            break
        jump = max(jump // 2, 1)
        dprint(x, ret, ans, jump)

    print(" ".join([str(i * 2) for i in ans]))


solve()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)


def solve():
    N = int(input())
    a_list = list(map(int, input().split()))
    import numpy as np
    q = np.zeros(shape=(N, N))
    for i in range(N):
        for j in range(N):
            if i == j:
                q[i][j] = 1
            if i == N-1:
                q[i][0] = 1
            else:
                if i+1 == j:
                    q[i][j] = 1

    a = np.array(a_list)
    qinv = np.linalg.inv(q)
    dprint(q)
    x = 2 * np.dot(qinv, a)
    dprint(x)
    x = list(x.astype(int))
    print(" ".join([str(i) for i in x]))

solve()
Problem p02990 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

mx = 10**9 + 7

from math import factorial
# def npr(n, r):
#     ans = math.factorial(n+r) // (math.factorial(n) * math.factorial(r))
#     return ans

def ncr(n, r):
    a = factorial(n) // (factorial(r) * factorial(n - r))
    return a

def solve():
    N, K = map(int, input().split())
    M = N - K

    for i in range(1, K+1):
        if M+1 < i:
            print(0)
            continue
        # まず、赤がM個あるので、両端を含む隙間 M+1 から、i個選ぶ
        agroup = ncr(M+1, i)

        # そのあと、青iこの箱にKをを分ける
        bagroup = ncr(K-1, i-1)

        print((agroup * bagroup) % mx)

solve()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

mx = 10**9 + 7

from math import factorial
# def npr(n, r):
#     ans = math.factorial(n+r) // (math.factorial(n) * math.factorial(r))
#     return ans

def ncr(n, r):
    a = factorial(n) // (factorial(r) * factorial(n - r))
    return a

def solve():
    N, K = map(int, input().split())
    M = N - K

    for i in range(1, K+1):
        # まず、赤がM個あるので、両端を含む隙間 M+1 から、i個選ぶ
        agroup = ncr(M+1, i)

        # そのあと、青iこの箱にKをを分ける
        bagroup = ncr(K-1, i-1)

        print((agroup * bagroup) % mx)

solve()
Problem p03634 (python)

Fixed submission:
import sys
import os
from collections import defaultdict
adj = defaultdict(list)
vis =[0 for i in range(1000000)]
dis =[0 for i in range(1000000)]
def dfs(u, p):
	for v, w in adj[u]:
		if v==p:
			continue
		dis[v]=dis[u]+w
		dfs(v, u)

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

	q, k = map(int , input().split())
	sys.setrecursionlimit(1000000)
	dfs(k , 0)
	for i in range(q):
		x, y  =map(int , input().split())
		print(dis[x]+dis[y])
#	rec_limit= sys.getrecursionlimit()
#	print(rec_limit)


if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
adj = defaultdict(list)
vis =[0 for i in range(1000000)]
dis =[0 for i in range(1000000)]
def dfs(u, p):
	for v, w in adj[u]:
		if v==p:
			continue
		dis[v]=dis[u]+w
		dfs(v, u)

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

	q, k = map(int , input().split())
	dfs(k , 0)
	for i in range(q):
		x, y  =map(int , input().split())
		print(dis[x]+dis[y])

if __name__ == "__main__":
	main()
Problem p02897 (python)

Fixed submission:
N = int(input())
odd = 0
same = 0
for x in range(1,N+1,1):
  if x % 2 == 0:
    same += 1
  else:
    odd += 1
print(odd / (odd + same))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = input().split()
R = []
for i in range(1,N+1):
  dx = A.index(str(i))
  R.append(str(dx+1))

out = ' '.join(R)
print(out)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = input().split()
R = []
for i in range(1,N+1):
  dx = A.index(str(i))
  R.append(str(dx+1))

out = ' '.join(R)
print(out)
Problem p02766 (python)

Fixed submission:
X,n = map(int,input().split(" "))
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
a=Base_10_to_n(X, n)
print(len(str(a)))

Buggy submission (verdict: Runtime Error):
X,n = map(int,input().split(" "))
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
 print(Base_10_to_n(X, n))
Problem p02859 (python)

Fixed submission:
r = input()
r = int(r) ** 2
print(r)

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

N = int(N)

if N % 2 == 1:
  print("No")
elif list(S)[0:N//2] == list(S)[N//2:N]:
  print("Yes")
else:
  print("No")
Problem p02753 (python)

Fixed submission:
S = str(input())
if S.count('AB') is 0 and S.count('BA') is 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
S = input()
N,A,B = S.split(' ')
N = int(N)
A = int(A)
B = int(B)
ans = N //(A+B) * A
left = N % (A+B)
if left > A:
    ans += A
else:
    ans += left
print(ans)

Buggy submission (verdict: Runtime Error):
S = str(Input())
if S.count('AB') is 0 and S.count('BA') is 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
S = Input()
if S.count('AB') is 0 and S.count('BA') is 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
S = Input()
if S.count('AB') is 0 and S.count('BA') is 0:
    print('No')
else:
    print('Yes')
Problem p02754 (python)

Fixed submission:
S = input()
N,A,B = S.split(' ')
N = int(N)
A = int(A)
B = int(B)
ans = N //(A+B) * A
left = N % (A+B)
if left > A:
    ans += A
else:
    ans += left
print(ans)

Buggy submission (verdict: Runtime Error):
S = Input()
N,A,B = S.split(' ')
N = int(N)
A = int(A)
B = int(B)
ans = N //(A+B) * A
left = N % (A+B)
if left > A:
    ans += A
else:
    ans += left
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
N,A,B = S.split(' ')
N = int(N)
A = int(A)
B = int(B)
till = int(N/(A+B))*(A+B)
left = N - till
leftover = ('b'*A + 'r'*B)[:left]
leftcount = leftover.count('b')
print(int(N/(A+B))*A + leftcount)
Problem p02754 (python)

Fixed submission:
N,A,B = map(int, input().split())
adds = A + B
times = N // adds
boalsLen = adds * times
count = A * times


while True:
    if boalsLen > N:
        break
    
    tmpBoalsLen = boalsLen + A
    if tmpBoalsLen > N:
        addBoals = N - boalsLen
        count += addBoals
        break
    
    boalsLen = tmpBoalsLen
    boalsLen += B
    count += A

print(count)

Buggy submission (verdict: Runtime Error):
N,A,B = map(int, input().split())
addBlue = 'b'*A
addRed = 'r'*B
count = 0
boals = ''

while len(boals) < N:
    boals += addBlue
    boals += addRed
    count += A

print(count - boals[N:len(boals)].count('b'))

Buggy submission (verdict: Runtime Error):
N,A,B = map(int, input().split())
addBlue = 'b'*A
addRed = 'r'*B
boals = ''

while len(boals) < N:
    boals += addBlue
    boals += addRed

print(boals[:N].count('b'))
Problem p02832 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 0
i = 1

for a in A:
    if a != i:
        count += 1
    else:
        i += 1

if count == len(A):
    print(-1)
else:
    print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = 0
ans = -1
i = 0

while len(A) != 0:
    if A[i] != i + 1:
        A.remove(A[i])
        count += 1
    elif i < len(A) -1:
        i += 1
    else:
        ans = count
        break

print(ans)