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

Fixed submission:
import math

n, m = map(int, input().split())
c = 0
f = [math.floor(n/2), math.floor(n/2) + 1]
if n % 2 == 0:
    while c < m:
        c += 1
        if c == math.floor(n/4) + 1:
            if (f[1] + 1) % n == 0:
                f[1] = n
            else:
                f[1] = (f[1] + 1) % n
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n
else:
    while c < m:
        c += 1
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n

Buggy submission (verdict: Runtime Error):
import math

n, m = map(int, input().split())
c = 0
f = [math.floor(n/2), math.floor(n/2) + 1]
if n % 2 == 0:
    while c < m:
        c += 1
        if c == math.ceil((n/4)　+ 1):
            if (f[1] + 1) % n == 0:
                f[1] = n
            else:
                f[1] = (f[1] + 1) % n
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n
else:
    while c < m:
        c += 1
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n

Buggy submission (verdict: Runtime Error):
import math

n, m = map(int, input().split())
c = 0
f = [math.floor(n/2), math.floor(n/2) + 1]
if n % 2 == 0:
    while c < m:
        c += 1
        if c == math.ceil(n/4)　+ 1:
            if (f[0] - 1) % n == 0:
                f[0] = n
            else:
                f[0] = (f[0] - 1) % n
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n
if n % 2 == 1:
    while c < m:
        c += 1
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n
Problem p02717 (python)

Fixed submission:
x, y, z = map(int, input().split())
x_swap_1 = y
y_swap_1 = x
x = x_swap_1
y = y_swap_1
x_swap_2 = z
z_swap_2 = x
x = x_swap_2
z = z_swap_2
print(str(x) + ' ' + str(y) + ' ' + str(z))

Buggy submission (verdict: Runtime Error):
k = int(input())
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(k):
    if a[i] % 10 != 0:
        a.append(10*a[i] + a[i] % 10 - 1)
    a.append(10*a[i] + a[i] % 10)
    if a[i] % 10 != 9:
        a.append(10*a[i] + a[i] % 10 + 1)

print(a[k - 1])
Problem p02720 (python)

Fixed submission:
k = int(input())
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(k):
    if a[i] % 10 != 0:
        a.append(10*a[i] + a[i] % 10 - 1)
    a.append(10*a[i] + a[i] % 10)
    if a[i] % 10 != 9:
        a.append(10*a[i] + a[i] % 10 + 1)

print(a[k - 1])

Buggy submission (verdict: Runtime Error):
k = int(input())
a[i] = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(k):
    if a[i] % 10 != 0:
        a.append(10*a[i] + a[i] % 10 - 1)
    a.append(10*a[i] + a[i] % 10)
    if a[i] % 10 != 9:
        a.append(10*a[i] + a[i] % 10 + 1)

print(a[k - 1])
Problem p03493 (python)

Fixed submission:
# 文字列を入力
number = list(input())
# カウントの設置
count = 0
# 各桁の判定
if number[0] == '1':
    count += 1
if number[1] == '1':
    count += 1
if number[2] == '1':
    count += 1
# 出力
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
numbers = list(map(int, input().split()))
ans = 0
while True:
    index = 1
    for i in range(n):
        if numbers[i] % 2 == 0:
            numbers[i] = numbers[i] / 2
        else:
            index = 0
            break
    if index == 1:
        ans += 1
    else:
        break
print(ans)
Problem p03854 (python)

Fixed submission:
s_init = input()
s_list = list(reversed(s_init))
s = ''.join(s_list)
t = ""
words = ["maerd", "remaerd", 'esare', 'resare']
s_list = list(s)
t_list = list(t)
while s != t:
    t_fixed = t
    if len(s_list) < len(t_list):
        break
    elif t == 'gameover':
        break
    else:
        for word in words:
            if s.startswith(t + word):
                t = t + word
                break
        if t == t_fixed:
            t = 'gameover'
if s == t:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
s_init = input()
s_list = list(reversed(s_init))
s = ''.join(s_list)
t = ""
words = ["maerd", "remaerd", 'esare', 'resare']
s_list = list(s)
t_list = list(t)
while s != t:
    t_fixed = t
    if len(s_list) < len(t_list):
        break
    elif t == 'gameover':
        break
    else:
        for word in words:
            if s.startswith(t + word):
                t = t + word
                break
        if t = t_fixed:
            t == 'gameover'
if s == t:
    print('YES')
else:
    print('NO')
Problem p02555 (python)

Fixed submission:
n=int(input())
dp=[1 for i in range(n+2)]
dp[0]=dp[1]=dp[2]=0
modd=1e9+7
for i in range(3,n):
    for j in range(3,n-i+1):
        dp[i+j]=(dp[i+j]+dp[i])%modd
print(int(dp[n]))

Buggy submission (verdict: Runtime Error):
n=int(input())
dp=[1 for i in range(n+1)]
dp[0]=dp[1]=dp[2]=0
modd=1e9+7
for i in range(3,n):
    for j in range(3,n-i+1):
        dp[i+j]=(dp[i+j]+dp[i])%modd
print(int(dp[n]))
Problem p02641 (python)

Fixed submission:
x,n= map(int,input().split(' '))
if n!=0:
    arr= list(map(int,input().split(' ')))
    for j in range(x+1):
        for i in range(-1,2):
            if arr.count(x+i*j)==0:
                print(x+i*j)
                exit(0)
else:
    print(x)

Buggy submission (verdict: Runtime Error):
def bin_search(arr,k):
    low, high = 0, n - 1
    while (low <= high):
        mid= low+(high-low)//2
        if arr[mid]==k:
            return mid
        if arr[mid]>k:
            high=mid-1
        else:
            low=mid+1

x,n= map(int,input().split(' '))
if n!=0:
    arr= list(map(int,input().split(' ')))
    arr.sort()
    idx= bin_search(arr,x)

    l,r=-1,-1
    for i in range(1,idx):
        left= arr[idx-i]
        if x-left>i:
            l=(arr[idx-i+1]-1)
            break
    if l==-1:
        l=arr[0]-1
    for i in range(1,n-idx):
        right= arr[idx+i]
        if right-x>i:
            r=(arr[idx+i-1]+1)
            break
    if r==-1:
        r=arr[n-1]+1
    if (x-l)<=(r-x):
        print(l)
    else:
        print(r)
else:
    print(x)
Problem p03167 (python)

Fixed submission:
h, w = map(int, input().split(" "))
dp = [[0 for i in range(w)] for j in range(h)]
mod=1e9+7
for i in range(h):
    s = input()
    for j in range(w):
        if i==0 and j==0:
            dp[0][0]= 1 if (s[j]=='.') else 0
        elif i==0:
            dp[0][j]= dp[0][j-1] if (s[j]=='.') else 0
        elif j==0:
            dp[i][0]= dp[i-1][0] if (s[0]=='.') else 0
        else:
            dp[i][j]= (dp[i-1][j]%mod+dp[i][j-1]%mod)%mod if s[j]=='.' else 0
print(int(dp[h-1][w-1]%mod))

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split(" "))
dp = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    s = input()
    for j in range(w):
        if i==0 and j==0:
            dp[0][0]= 1 if (s[j]=='.') else 0
        elif i==0:
            dp[0][j]= dp[0][j-1] if (s[j]=='.') else 0
        elif j==0:
            dp[i][0]= dp[i-1][0] if (s[0]=='.') else 0
        else:
            dp[i][j]= dp[i-1][j]+dp[i][j-1] if s[j]=='.' else 0
mod=1e9+7
print(int(dp[h-1][w-1]%mod))
Problem p03280 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
if n < 105:
  print(0)
else:
  ans = 0
  for i in range(n,103,-2):
    count = 1
    for j in range(1,99,2):
      nj = n%j
      if nj == 0:
        count += 1
      if count == 9:
        ans -= 1
    if count == 8:
      ans += 1
print(ans)
Problem p03281 (python)

Fixed submission:
n = int(input())
a = 0
for i in range(1,n+1,2):
  c = 0
  for j in range(1,n+1):
    if i%j == 0:
      c += 1
  if c == 8:
    a +=1
print(a)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n < 105:
  print(0)
else:
  ans = 0
  for i in range(n,103,-2):
    count = 1
    for j in range(1,99,2):
      nj = n%j
      if nj == 0:
        count += 1
      if count == 9:
        ans -= 1
    if count == 8:
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n < 105:
  print(0)
else:
  ans = 0
  for i in range(n,103,-2):
    count = 1
    for j in range(1,101,2):
      nj = n%j
      if nj == 0:
        count += 1
      if count == 9:
        break
    if count == 8:
      ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n < 105:
  print(0)
else:
  ans = 0
  for i in range(n,103,-2):
    count = 1
    for j in range(1,99,2):
      nj = n%j
      if nj == 0:
        count += 1
      if count == 9:
        break
    if count == 8:
      ans += 1
print(ans)
Problem p03359 (python)

Fixed submission:
a,b = map(int, input().split())
if a > b:
  print(a-1)
else:
  print(a)

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split()))
a.sort()
k = int(input())
a[2] = a[2]*2**k
print(sum(a))
Problem p03385 (python)

Fixed submission:
import sys

S = input()
T = "abc"
if len(S) > 3:
  print("No")
else:
  for i in S:
    if i in T:
      T = T.replace(i,'')
    else:
      print("No")
      sys.exit()
  print("Yes")

Buggy submission (verdict: Runtime Error):
import sys

A,B,K = map(int, input().split())
for i in range(A,B+1):
  if i <= A + K-1 or i>= B-K+1:
    print(i)
Problem p02642 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
set(a)
ans=[0]*1000005
x=1
for i in a:
    if(ans[i]!=0):
        ans[i]=2
        continue
    for j in range(i,1000005,i):
        ans[j]=ans[j]+1
cnt=0
for i in range(0,n):
    if(ans[a[i]]==1):
        cnt=cnt+1
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
set(a)
ans=[0]*1000000
x=1
for i in a:
    if(ans[i]!=0):
        ans[i]=2
        continue
    for j in range(i,1000000,i):
        ans[j]=ans[j]+1
cnt=0
for i in range(0,n):
    if(ans[a[i]]==1):
        cnt=cnt+1
print(cnt)
Problem p02830 (python)

Fixed submission:
n=int(input())
a,b=map(str,input().split())
for i in range(n):
    print(a[i],end="")
    print(b[i],end="")
print()

Buggy submission (verdict: Runtime Error):
n=int(input())
a=input()
b=input()
for i in range(n):
    print(a[i],end="")
    print(b[i],end="")
print()
Problem p02537 (python)

Fixed submission:

n,k = map(int, input().split())
a = []
for i in range(n):
    a.append(int(input()))
a.reverse()
# dp[i] := i番目の数字から始めたときの最大値
dp = [0 for i in range(n)]
#####segfunc######
def segfunc(x,y):
    return max(x,y)

def init(init_val):
    #set_val
    for i in range(len(init_val)):
        seg[i+num-1]=init_val[i]   
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

max_a = 300020
#####単位元######
ide_ele = 0
num =2**(max_a-1).bit_length()
seg=[ide_ele]*(2*num - 1)
#阪堺区間に注意
dp[0] = 1
update(a[0], 1)
for i in range(1,n):
    # print("{} {}".format(max(a[i]-k, 0), min(max_a, a[i]+k+1)))
    dp[i] = query(max(a[i]-k, 0), min(max_a, a[i]+k+1)) + 1
    update(a[i], dp[i])
print(max(dp))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
n,k = map(int, input().split())
a = []
for i in range(n):
    a.append(int(input()))
a.reverse()
# dp[i] := i番目の数字から始めたときの最大値
dp = [0 for i in range(n)]
#####segfunc######
def segfunc(x,y):
    return max(x,y)

def init(init_val):
    #set_val
    for i in range(len(init_val)):
        seg[i+num-1]=init_val[i]   
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0
num =2**(n-1).bit_length()
seg=[ide_ele]*(2*num - 1)
#阪堺区間に注意
dp[0] = 1
update(a[0], 1)
max_a = max(a) + 1
for i in range(1,n):
    # print("{} {}".format(max(a[i]-k, 0), min(max_a, a[i]+k+1)))
    dp[i] = query(max(a[i]-k, 0), min(max_a, a[i]+k+1)) + 1
    update(a[i], dp[i])
print(max(dp))
Problem p02588 (python)

Fixed submission:

n = int(input())
T = 45
F = 19
a = [[0 for i in range(F)] for j in range(T)]
p = pow(10,9)
two_size = 18
five_size = 18
count = 0
for i in range(n):
    s = input()
    if '.' in s:
        index = s.index('.')
        s += '0' * (  9 - (len(s) - 1 - index))
        s = s.replace('.','')
    else :
        s += '0' * 9
    k = int(s)
    two = 0
    five = 0
    while k % 2 == 0:
        two += 1
        k //= 2
    while k % 5 == 0:
        five += 1
        k //= 5
    t, f = two_size - two, five_size - five
    for x in range(t, T):
        for y in range(f, F):
            count += a[x][y]
    a[two][five] += 1
print(count)

Buggy submission (verdict: Runtime Error):
from math import gcd
from collections import defaultdict
n = int(input())
N = 30
a = [[0 for i in range(N)] for j in range(N)]
p = pow(10,9)
two_size = 18
five_size = 18
count = 0
for i in range(n):
    k = float(input()) * p
    two = 0
    five = 0
    while k % 2 == 0:
        two += 1
        k //= 2
    while k % 5 == 0:
        five += 1
        k //= 5
    t, f = two_size - two, five_size - five
    for x in range(t, N):
        for y in range(f, N):
            count += a[x][y]
    a[two][five] += 1
print(count)

Buggy submission (verdict: Runtime Error):
from math import gcd
from collections import defaultdict
n = int(input())
a = [[0 for i in range(20)] for j in range(20)]
data = []
ans = 0
p = pow(10,9)
two_size = 18
five_size = 18
count = 0
for i in range(n):
    k = float(input()) * p
    two = 0
    five = 0
    while k % 2 == 0:
        two += 1
        k //= 2
    while k % 5 == 0:
        five += 1
        k //= 5
    t, f = two_size - two, five_size - five
    for x in range(t, 20):
        for y in range(f, 20):
            count += a[x][y]
    a[two][five] += 1
print(count)
Problem p02618 (python)

Fixed submission:
d = int(input())
c = list(map(int, input().split()))
score = []
for i in range(d):
    score.append(list(map(int, input().split())))
for i in range(d):
    print(score[i].index(max(score[i])) + 1)

Buggy submission (verdict: Runtime Error):
d = int(input())
c = list(map(int, input().split()))
score = []
for i in range(d):
    score.append(list(map(int, input().split())))
last_day = [0 for i in range(26)]
k = 0
for i in range(d):
    ans = 0
    max_score = -10**9
    for j in range(1, 27):
        s = score[i][j-1]
        for k in range(1,27):
            if j == k:
                continue
            else:
                s -= c[k-1] * (d - i+1 - last_day[k-1])
        if s > max_score:
            ans = j
            max_score = s
    last_day[ans] = i+1
    print(ans)
    k += max_score
Problem p02664 (python)

Fixed submission:
t = input()
print(t.replace("?", "D"))

Buggy submission (verdict: Runtime Error):
Vt = input()
print(t.replace("?", "D"))
Problem p02678 (python)

Fixed submission:
from collections import deque
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
adjacent_list = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)
ans = [-1 for i in range(n+1)]
def bfs():
    #start at 1
    que = deque([1])
    while que:
        node = que.popleft()
        for i in adjacent_list[node]:
            if ans[i] == -1:
                que.append(i)
                ans[i] = node
bfs()
print("Yes")
for i in range(2,n+1):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
adjacent_list = [[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    adjacent_list[a].append(b)
    adjacent_list[b].append(a)
ans = [-1 for i in range(n+1)]
def bfs():
    #start at 1
    que = deque([1])
    while que:
        node = que.popleft()
        finished.add(node)
        for i in adjacent_list[node]:
            if ans[i] == -1:
                que.append(i)
                ans[i] = node
bfs()
print("Yes")
for i in range(2,n+1):
    print(ans[i])
Problem p02684 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n,k = map(int, input().split())
a = list(map(int, input().split()))
adjacent_list = [[] for i in range(n+1)]
for i in range(n):
    adjacent_list[i+1].append(a[i])
finished = set()
route = []
def dfs(node):
    finished.add(node)
    route.append(node)
    for i in adjacent_list[node]:
        if i not in finished:
            dfs(i)
dfs(1)
if len(route) > k:
    print(route[k])
else:
    index = route.index(adjacent_list[route[-1]][0])
    k -= index
    route = route[index:]
    print(route[k % len(route)])

Buggy submission (verdict: Runtime Error):
import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[]
now=0
for i in range(n+1):
        ans.append(a[now])
        now=a[now]-1
#print(ans)

ans2=collections.Counter(ans)

ac=ans2.most_common()[0][0]
#print(ac)
index=-1
index2=-1

for i in range(len(ans)):
    if ans[i]==ac:
        if index==-1:        
            index=i
        else:
            index2=i
assert(index2 == -1)
#print(index,index2)
#print((k-index-1)%(index2-index))
if k < index:
    print(ans[k])
else:
    print(ans[(k-index-1)%(index2-index)+index])

Buggy submission (verdict: Runtime Error):
import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[1]
now=0
passed = set()
for i in range(n+1):
    if a[now] in passed:
        ans.append(a[now])
        break
    else:
        ans.append(a[now])
        passed.add(a[now])
        now=a[now]-1
#print(ans)
#変更
passed = set()
index = ans[:-1].index(ans[-1])
index_1 = len(ans)-2
#print(index)
#print(index_1)
print(ans[(k-index-1)%(index_1-index)+index])
Problem p02690 (python)

Fixed submission:
x = int(input())
for i in range(-1000,1000+1):
    for j in range(-1000,1001):
        if pow(i,5) - pow(j,5) == x:
            print("{} {}".format(i,j))
            exit()

Buggy submission (verdict: Runtime Error):
x = int(input())
start = int(pow(x,0.2))
for i in range(-1000,1000+1):
    k = pow(x + pow(i,5),0.2)
    k = round(k,7)
    if pow(int(k),5) - pow(i,5) == x:
        print(int(k),i)
        exit()

Buggy submission (verdict: Runtime Error):
x = int(input())
start = int(pow(x,0.2))+1
for i in range(-start,start):
    k = pow(x + pow(i,5),0.2)
    k = round(k,6)
    if type(k) != type(1+1j) and pow(int(k),5) - pow(i,5) == x:
        print(int(k),i)
        exit()
Problem p02692 (python)

Fixed submission:
n,a,b,c = map(int, input().split())
ans = []
number = dict()
number['A'] = a
number['B'] = b
number['C'] = c
query = [input() for i in range(n)]
for i in range(n):
    s = query[i]
    s_1, s_2 = s[0], s[1]
    if number[s_1] == 0 and number[s_2] == 0:
        print("No")
        exit()
    else:
        if number[s_1] > number[s_2]:
            number[s_1] -= 1
            number[s_2] += 1
            ans.append(s_2)
        elif number[s_1] < number[s_2]:
            number[s_2] -= 1
            number[s_1] += 1
            ans.append(s_1)
        else:
            if i == n-1:
                number[s_2] -= 1
                number[s_1] += 1
                ans.append(s_1)
            else:
                if query[i+1] == s_1 + s_2:
                    number[s_2] -= 1
                    number[s_1] += 1
                    ans.append(s_1)
                else:
                    n_1,n_2 = query[i+1]
                    if s_1 in set([n_1,n_2]):
                        number[s_2] -= 1
                        number[s_1] += 1
                        ans.append(s_1)
                    else:
                        number[s_1] -= 1
                        number[s_2] += 1
                        ans.append(s_2)

    #print("A:{} B:{} C:{}".format(number['A'],number['B'],number['C']))
print("Yes")
for i in range(n):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n,a,b,c = map(int, input().split())
ans = []
number = dict()
number['A'] = a
number['B'] = b
number['C'] = c
query = [input() for i in range(n)]
for i in range(n):
    s = query[i]
    s_1, s_2 = s[0], s[1]
    if number[s_1] == 0 and number[s_2] == 0:
        print("No")
        exit()
    else:
        if number[s_1] > number[s_2]:
            number[s_1] -= 1
            number[s_2] += 1
            ans.append(s_2)
        elif number[s_1] < number[s_2]:
            number[s_2] -= 1
            number[s_1] += 1
            ans.append(s_1)
        else:
            if i == n-1:
                number[s_2] -= 1
                number[s_1] += 1
                ans.append(s_1)
            else:
                if query[i+1] == s_1 + s_2:
                    number[s_2] -= 1
                    number[s_1] += 1
                    ans.append(s_1)
                else:
                    n_1,n_2 = query[i+1]
                    if s_1 in set(n_1,n_2):
                        number[s_2] -= 1
                        number[s_1] += 1
                        ans.append(s_1)
                    else:
                        number[s_1] -= 1
                        number[s_2] += 1
                        ans.append(s_2)

    #print("A:{} B:{} C:{}".format(number['A'],number['B'],number['C']))
print("Yes")
for i in range(n):
    print(ans[i])
Problem p02696 (python)

Fixed submission:
def fn(x):
    return ((a*x)//b) - a*(x//b)
a,b,n = map(int, input().split())
ans = 0
if b <= n:
    ans = b-1
else:
    ans = n
print(fn(ans))

Buggy submission (verdict: Runtime Error):
11 10 9