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

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

num = 0
res = 0

for i in range(len(s)):
  if s[i] == 'I':
    num += 1
  else:
    num -= 1
  if num > res:
    res = num

print(res)

Buggy submission (verdict: Runtime Error):
# this is cumulative
n = int(input())
s = input()

point = 0
cum_sum = []

for i in s:
    if i == "I":
        point += 1
    else:
        point -= 1
    cum_sum.append(point)
else:
    print(max(cum_sum,0))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = str(input())

num = 0
res = 0

for i in range(len(s)):
  if str[i] == 'I':
    num += 1
  else:
    num -= 1
  if num > res:
    res = num

print(res)
Problem p03993 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
res = 0

for i in range(n):
  sel = a[i] -1
  if a[sel] == i+1:
    res += 1
else:
  print(int(res/2))

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

for i in range(n):
  sel = a[i]
  if a[sel] == i:
    res += 1
else:
  print(res/2)

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

for i in range(n):
  sel = a[i]
  if a[sel] = i:
    res += 1
else:
  print(res/2)
Problem p03997 (python)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())


print(int((a+b)*h/2))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())

print((a+b)*h/2)

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

print((a+b)*h/2)
Problem p04012 (python)

Fixed submission:
s = input()
#l = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
l = []
roll = ord('z')-ord('a')+1

for i in range(roll):
    l.append(0)

for i in range(len(s)):
    num = ord(s[i])
    l[num-97] += 1
    #print(num)

for i in range(roll):
    if l[i]%2 != 0:
        print("No")
        break
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
s = input()
#l = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
l = []
roll = ord('z')-ord('a')

for i in range(roll):
    l.append(0)

for i in range(len(s)):
    num = ord(s[i])
    l[num-97] += 1
    #print(num)

for i in range(roll):
    if l[i]%2 != 0:
        print("No")
        break
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
s = input()
#l = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
l = []
roll = ord('z')-ord('a')

for i in range(roll):
    l.append(0)

for i in range(len(s)):
    num = ord(s[i])
    l[num-97] += 1
    #print(num)

for i in range(roll):
    if l[i]%2 != 0:
        print("No")
        exit()
else:
    print("Yes")
Problem p03243 (python)

Fixed submission:
input_line = input()
n = int(int(input_line) / 111)
if int(input_line) % 111 == 0:
  print(n *111)
else:
  print(111 + n *111)

Buggy submission (verdict: Runtime Error):
input_line = input()
n = int(input_line / 111)
print(111 + n * 111)

Buggy submission (verdict: Runtime Error):
input_line = input()
n = int(input_line / 111)
print(n*111)

Buggy submission (verdict: Runtime Error):
str = input()
n = str / 111

print(n*111)
Problem p02613 (python)

Fixed submission:
number = int(input())
 
ac = 0
wa = 0
tle = 0
re = 0
for i in range(number):
  character = input()
  if character == 'AC':
    ac += 1
  if character == 'WA':
    wa += 1
  if character == 'TLE':
    tle += 1
  if character == 'RE':
    re += 1
 
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Buggy submission (verdict: Runtime Error):
number = int(input())

ac = 0
wa = 0
tle = 0
re = 0
for i in range(number):
  character = input()
  if character == 'AC':
    ac += 1
  if character == 'WA':
    wa += 1
  if character == 'TLE':
    tle += 1
  if character == 'RE':
    re += 1

print("AC x " + ac)
print("WA x " + wa)
print("TLE x " + tle)
print("RE x " + re)
Problem p02612 (python)

Fixed submission:
n = int(input())
 
if n % 1000 == 0 :
    a = n / 1000
else :
    a = int(n / 1000 + 1)
 
b = a * 1000
answer = int(b - n)
 
print(answer)

Buggy submission (verdict: Runtime Error):
n = int(input())
 
if n % 1000 == 0 :
    a = n / 1000
else :
    int(a) = n / 1000 + 1
 
b = a * 1000
answer = int(b - n)
 
print(answer)

Buggy submission (verdict: Runtime Error):
n = int(input())
for s in range(1,10) :
    if n <= s*1000 :
       x = s*1000 - n 
       break()
print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
for s in range(1,10) :
    if n <= s*1000 :
       x = s*1000 - n 
       
print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
for s in range(1,10) :
    if n <= s*1000 :
       x = s*1000 - n 
       break
print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
for s in range(1,10) :
    if n <= s*1000 :
        x = s*1000 - n 
        break
print(x)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
A,B = map(int.input(),split())
print(A * B)
Problem p02675 (python)

Fixed submission:
N=input()
if N[-1] == '2' :
    print("hon")
elif N[-1] == '4' :
    print("hon")
elif N[-1] == '5' :
    print("hon")
elif N[-1] == '7' :
    print("hon")
elif N[-1] == '9' :
    print("hon")
elif N[-1] == '0' :
    print("pon")
elif N[-1] == '1' :
    print("pon")
elif N[-1] == '6' :
    print("pon")
elif N[-1] == '8' :
    print("pon")
else :
    print("bon")

Buggy submission (verdict: Runtime Error):
N=int(input())
if N[-1] == 2 :
    print("hon")
elif N[-1] == 4 :
    print("hon")
elif N[-1] == 5 :
    print("hon")
elif N[-1] == 7 :
    print("hon")
elif N[-1] == 9 :
    print("hon")
elif N[-1] == 1 :
    print("pon")
elif N[-1] == 6 :
    print("pon")
elif N[-1] == 8 :
    print("pon")
else :
    print("bon")

Buggy submission (verdict: Runtime Error):
N=int(input())
if N[-1] == 2 :
    print("hon")
elif N[-1] == 4 :
    print("hon")
elif N[-1] == 5 :
    print("hon")
elif N[-1] == 7 :
    print("hon")
elif N[-1] == 9 :
    print("hon")
elif N[-1] == 1 :
    print("pon")
elif N[-1] == 6 :
    print("pon")
elif N[-1] == 8 :
    print("pon")
else :
    print("bon")

Buggy submission (verdict: Runtime Error):
N=input()
if N[-1] = 2 :
    print("hon")
elif N[-1] = 4 :
    print("hon")
elif N[-1] = 5 :
    print("hon")
elif N[-1] = 7 :
    print("hon")
elif N[-1] = 9 :
    print("hon")
elif N[-1] = 1 :
    print("pon")
elif N[-1] = 6 :
    print("pon")
elif N[-1] = 8 :
    print("pon")
else :
    print("bon")

Buggy submission (verdict: Runtime Error):
N=int(input())
if N[-1] = 2 :
    print("hon")
elif N[-1] = 4 :
    print("hon")
elif N[-1] = 5 :
    print("hon")
elif N[-1] = 7 :
    print("hon")
elif N[-1] = 9 :
    print("hon")
elif N[-1] = 1 :
    print("pon")
elif N[-1] = 6 :
    print("pon")
elif N[-1] = 8 :
    print("pon")
else :
    print("bon")
Problem p02789 (python)

Fixed submission:
n,m=map(int,input().split())
if n == m :
    print("Yes")
else :
    print("No")

Buggy submission (verdict: Runtime Error):
n,m=map(int.input(),split())
if n == m :
    print("Yes")
else :
    print("No")
Problem p02811 (python)

Fixed submission:
k,x = map(int,input().split())
if x <= 500*k :
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
k,x = map(int.input(),split())
if x <= k :
    print('Yes')
else :
    print('No')

Buggy submission (verdict: Runtime Error):
k,x=map(int.input(),split())
if x <= k :
    print("Yes")
else :
    print("No")

Buggy submission (verdict: Runtime Error):
k,x=map(int.input(),split())
if x <= k :
  print('Yes')
else :
  print('No')

Buggy submission (verdict: Runtime Error):
k=intinput()
x=intinput()
if x <= k :
  print("Yes")
else :
  print("No")

Buggy submission (verdict: Runtime Error):
k=int(input())
x=int(input())
if x <= k :
  print("Yes")
else :
  print("No")
Problem p02817 (python)

Fixed submission:
s,t=input().split()
print(t+s)

Buggy submission (verdict: Runtime Error):
s,t=int(input().split())
print(t+s)

Buggy submission (verdict: Runtime Error):
S,T=map(int,input().split())
	print(T+S)

Buggy submission (verdict: Runtime Error):
S,T=map(int,input().split())
	print(S+T)

Buggy submission (verdict: Runtime Error):
S,T=map(int,input().split())
print(T+S)

Buggy submission (verdict: Runtime Error):
S=input().split("区切り文字")
T=input().split("区切り文字")
print(S+T)
Problem p02630 (python)

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

A = [0] * 100001
for i in a:
  A[i] += 1

ans  = 0
for i in range(len(A)):
  ans += i * A[i]  

for n in range(q):
  b,c = list(map(int, input().split()))
  ans += (c * A[b]) - (b * A[b])
  A[c] += A[b]
  A[b] = 0
  print(ans)

Buggy submission (verdict: Runtime Error):

n = int(input())
a = list(map(int, input().split()))
q = int(input())

a.sort()
A = [0] * 100000
for i in a:
  A[i] += 1

ans  = 0
for i in range(len(A)):
  ans += i * A[i]  

for n in range(q):
  b,c = list(map(int, input().split()))
  ans += (c * A[b]) - (b * A[b])
  A[c] += A[b]
  A[b] = 0
  print(ans)

Buggy submission (verdict: Runtime Error):

n = int(input())
a = list(map(int, input().split()))
q = int(input())

a.sort()
A = [0] * 100000
for i in a:
  A[i] += 1

ans  = 0
for i in range(len(A)):
  ans += i * A[i]  

for n in range(q):
  b,c = list(map(int, input().split()))
  ans += (c * A[b]) - (b * A[b])
  A[c] += A[b]
  A[b] = 0
  print(ans)
Problem p02641 (python)

Fixed submission:
x,n = list(map(int,input().split()))
if n == 0:
  print(x)
  exit()

p = list(map(int,input().split()))
p = [-1] + p + [102]
import bisect
p.sort()
i = bisect.bisect_left(p,x)
if p[i] != x:
    print(x)
    exit()

for h in range(102):
  if p[i-h] != x-h:
    print(x-h)
    exit()
  elif p[i+h] != x+h:
    print(x+h)
    exit()

Buggy submission (verdict: Runtime Error):
x,n = list(map(int,input().split()))
if n == 0:
  print(x)
  exit()

p = list(map(int,input().split()))

import bisect
p.sort()
i = bisect.bisect_left(p,x)

for h in range(1, p[-1]-p[0]+2):
  if p[i-h] != x-h:
    print(x-h)
    exit()
  elif p[i+h] != x+h:
    print(x+h)
    exit()

Buggy submission (verdict: Runtime Error):
x,n = list(map(int,input().split()))
if n == 0:
  print(x)
  exit()

p = list(map(int,input().split()))

import bisect
p.sort()
i = bisect.bisect_left(p,x)
print(p)
for h in range(1, p[-1]-p[0]+2):
  if p[i-h] != x-h:
    print(x-h)
    exit()
  elif p[i+h] != x+h:
    print(x+h)
    exit()
Problem p02642 (python)

Fixed submission:
from collections import Counter
n = int(input())
a= list(map(int,input().split()))
if n == 1:
  print(1)
  exit()

a.sort()

c = Counter(a)
a = list(set(a))
dp = [0] * (10**6 +1)

for x in a:
  t = x * 2
  while t <= 10**6:
    dp[t] = 1
    t += x

ans = 0
for x in a:
  if (c[x] == 1) & (dp[x] == 0):
    ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a= list(map(int,input().split()))
if n == 1:
  print(1)
  exit()

a.sort()
if a[0] == 1:
  print(1)
  exit()

c = Counter(a)
a = list(set(a))
dp = [0] * (10+1)

for x in a:
  t = x * 2
  while t <= 10:
    dp[t] = 1
    t += x

ans = 0
for x in a:
  if (c[x] == 1) & (dp[x] == 0):
    ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a= list(map(int,input().split()))
if n == 1:
  print(1)
  exit()

a.sort()
if a[0] == 1:
  print(1)
  exit()

dp = [1 for _ in range(n)]

def div(k):
  global dp
  for i in range(k):
    if a[k]%a[i] == 0:
      dp[k] = 0
      if a[k] == a[i]:dp[i] = 0
      break
  if k < n-1:div(k+1)

div(1)
print(sum(dp))

Buggy submission (verdict: Runtime Error):
n = int(input())
a= list(map(int,input().split()))
if n == 1:
  print(1)
  exit()

a.sort()
if a[0] == 1:
  print(1)
  exit()

dp = [1 for _ in range(n)]

def div(k):
  global dp
  if dp[k] != 0:
    for i in range(k):
      if a[k]%a[i] == 0:
        dp[k] = 0
        if a[k] == a[i]:dp[i] = 0
        break
  if k < n-1:div(k+1)

div(1)
print(sum(dp))

Buggy submission (verdict: Runtime Error):
n = int(input())
a= list(map(int,input().split()))
if n == 1:
  print(n)
  exit()

a.sort()
if a[0] == 1:
  print(1)
  exit()

dp = [1] * n +[0]

def div(k):
  global dp
  if dp[k] != 0:
    for i in range(k):
      if a[k]%a[i] == 0:
        dp[k] = 0
        if a[k] == a[i]:dp[i] = 0
        break
  if k < n-1:div(k+1)

div(1)
print(sum(dp))

Buggy submission (verdict: Runtime Error):
n = int(input())
a= list(map(int,input().split()))
if n == 1:
  print(n)
  exit()

a.sort()
dp = [1] * n

def div(k):
  global dp
  if k < n-1:div(k+1)

div(1)
print(sum(dp))

Buggy submission (verdict: Runtime Error):
n = int(input())
a= list(map(int,input().split()))
if n == 1:
  print(n)
  exit()

a.sort()
dp = [1] * n

def div(k):
  global dp
  if dp[k] != 0:
    for i in range(k):
      if a[k]%a[i] == 0:
        dp[k] = 0
        if a[k] == a[i]:dp[i] = 0
        break
  if k < n-1:div(k+1)

div(1)
print(sum(dp))

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

a.sort()
dp = [1] * n

def div(k):
  global dp
  if dp[k] != 0:
    for i in range(k):
      if a[k]%a[i] == 0:
        dp[k] = 0
        if a[k] == a[i]:dp[i] = 0
        break
    if k < n-1:div(k+1)

div(1)

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

a.sort()
dp = [1] * len(a)

def div(k):
  global dp
  if dp[k] != 0:
    for i in range(k):
      if a[k]%a[i] == 0:
        dp[k] = 0
        break
    if k < n-1:div(k+1)

div(1)
print(sum(dp))
Problem p02660 (python)

Fixed submission:
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

from itertools import groupby
N = int(input())
P = prime_decomposition(N)
ans = 0
for v, g in groupby(P):
    n = len(list(g))
    for i in range(1, 100000):
        n -= i
        if n >= 0:
            ans += 1
        else:
            break
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import groupby
n =int(input())

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n%i == 0:
      n //= i
      table.append(i)
      i += 1
  if n > 1:
    table.append(n)
  return table

from itertools import groupby
ans = 0
p = prime_decomposition(n)
for k,g in p:
  gn = len(list(g))
  for i in range(1,1000000000000):
    gn -= i
    if gn >= 0:
      ans += 1
    else:
      break
print(ans)
Problem p02678 (python)

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

m = [[] for _ in range(n)]
dp = [0]*n
from collections import deque
que = deque()
for _ in range(M):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  m[a].append(b)
  m[b].append(a)
  if a == 0:
    que.append(b)
    dp[b] = 1
  if b == 0:
    que.append(a)
    dp[a] = 1

while que:
  c = que.popleft()
  for i in m[c]:
    if dp[i] == 0 :
      dp[i] = c+1
      que.append(i)

#[exit(print('No')) for i in range(1,n)  if dp[i] == 0]

print('Yes')
[print(dp[i]) for i in range(1,n)]

Buggy submission (verdict: Runtime Error):
n,M = list(map(int,input().split()))
m = [[0]*n for _ in range(M)]
dp = [0]*n

for _ in range(M):
  a,b = list(map(int,input().split()))
  m[a-1][b-1] = 1
  m[b-1][a-1] = 1

from collections import deque
que = deque()
for i in range(n):
  if m[0][i] == 1:
    que.append(i)
    dp[i] = 1

while que:
  c = que.popleft()
  for i in range(n):
    cn = dp[c]
    if m[c][i] == 1 and dp[i] == 0 :
      dp[i] = c+1
      que.append(i)
      if cn == 1 and i == 0:dp[0] = 0

for i in range(1,n):
  if dp[i] == 0:exit(print('No'))


print('Yes')
for i in range(1,n):
  print(dp[i])
Problem p02684 (python)

Fixed submission:
n,k = list(map(int,input().split()))
A = list(map(int,input().split()))

if k == 1:exit(print(A[0]))
t = 0
dp = [-1] * n
dp[0] = 0
flg = 0
for i in range(1,k+1):
  t = A[t]-1
  if dp[t] != -1:
    flg = 1
    break
  dp[t] = i
if flg == 0:
  exit(print(t+1))
elif k == 2:
  exit(print(t+1))

l = i - dp[t]
K = (k-dp[t])%l + dp[t]

for i in range(n):
  if dp[i] == K:exit(print(i+1))

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

if k == 1:exit(print(A[0]))
t = 0
dp = [-1] * n
dp[0] = 0
for i in range(1,k+1):
  t = A[t]-1
  if dp[t] != -1:break
  dp[t] = i
if k == 2:
  exit(print(t+1))
l = i - dp[t]
K = (k-dp[t])%l + dp[t]

for i in range(n):
  if dp[i] == K:exit(print(i+1))

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

if k == 1:exit(print(A[0]))
t = 0
dp = [-1] * n
dp[0] = 0
for i in range(1,k+1):
  t = A[t]-1
  if dp[t] != -1:break
  dp[t] = i
if k == 2:
  exit(print(t+1))
l = i - dp[t]
K = (k-dp[t])%l + dp[t]
print(dp)
for i in range(n):
  if dp[i] == K:exit(print(i+1))

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

if k == 1:exit(print(A[0]))
t = 0
dp = [-1] * n
dp[0] = 0
for i in range(1,k+1):
  t = A[t]-1
  if dp[t] != -1:break
  dp[t] = i
  
l = i - dp[t]
K = (k-dp[t])%l + dp[t]
print(dp)
for i in range(n):
  if dp[i] == K:exit(print(i+1))

Buggy submission (verdict: Runtime Error):

n,k = list(map(int,input().split()))
A = list(map(int,input().split()))

t = 0
dp = [-1] * n
dp[0] = 0
for i in range(1,k+1):
  t = A[t]-1
  if dp[t] != -1:break
  dp[t] = i
  
l = i - dp[t]
K = (k-dp[t])%l + dp[t]

for i in range(n):
  if dp[i] == K:exit(print(i+1))
Problem p02690 (python)

Fixed submission:

x = int(input())
y = int(pow(x, 1/5))*2
A = [i**5 for i in range(y+1)]
B = [i**5 for i in range(y+1)]

for i in range(len(A)):
  for j in range(len(B)):
    if ( A[i] + B[j] ) == x:
      if A[i] > B[j]:
        exit(print(i, -j))
      else:
        exit(print(j, -i))
    elif ( A[i] - B[j] ) == x:
      exit(print(i, j))

Buggy submission (verdict: Runtime Error):
x = int(input())

b = int(pow(x, 1/5))

for i in range(100000):
  A =  x + (b-i)**5
  a = pow(A, 1/5)
  if float(a).is_integer():
    exit(print(int(a), int(b+i)))
Problem p02691 (python)

Fixed submission:
import numpy as np
from collections import Counter
n = int(input())
a = np.array(list(map(int, input().split())))
ni = np.array([i for i in range(n)])

ap = a + ni
an = (a - ni) * -1

cp = Counter(ap)
cn = Counter(an)

ans = 0
for i in cp.keys():
  ans += cp[i] * cn[i] 

print(ans)

Buggy submission (verdict: Runtime Error):

ni = np.array([i for i in range(n)])

ap = a + ni
an = (a - ni) * -1
an.sort()
ans = 0
for j in an[::-1]:
  if j <= 0:break
  for i in ap:
    if j == i:
      ans += 1

print(ans)
Problem p02692 (python)

Fixed submission:

n,a,b,c = list(map(int, input().split()))
s = [[0]*2 for _ in range(n)]
S = []
for i in range(n):
  X = input()
  S += X
  cnt = 0
  for x in X:
    if x == 'A':
      s[i][cnt] = 0
    elif x == 'B':
      s[i][cnt] = 1
    else:
      s[i][cnt] = 2
    cnt += 1

if (a + b + c) == 0:exit(print('No'))
abc = [a,b,c]
ABC = ['A','B','C']


ans = [0] * n

def zero(xy):
  x = xy[0]
  y = xy[1]
  if abc[x] == 0 and abc[y] == 0:
    return -1,-1
  elif abc[x] == 0:
    return x,y
  elif abc[y] == 0:
    return y,x
  else:
    return 3,3

def main():
  global ans
  global abc
  
  for i in range(n):
    x,y = zero(s[i])
    if x == -1:exit(print('No'))
    if x == 3:
      if i < n-1:
        if s[i][1] in s[i+1]:
          x = s[i][1]
          y = s[i][0]
        else:
          x = s[i][0]
          y = s[i][1]
      else:
        x = s[i][0]
        y = s[i][1]
    ans[i] = x
    abc[x] += 1
    abc[y] -= 1

main()
print('Yes')
for i in range(n):
  print(ABC[ans[i]])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n,a,b,c = list(map(int, input().split()))
s = [[0]*2 for _ in range(n)]
S = []
for i in range(n):
  X = input()
  S += X
  cnt = 0
  for x in X:
    if x == 'A':
      s[i][cnt] = 0
    elif x == 'B':
      s[i][cnt] = 1
    else:
      s[i][cnt] = 2
    cnt += 1

if (a + b + c) == 0:exit(print('No'))
abc = [a,b,c]
x = s[0][0]
y = s[0][1]
if abc[x] == 0 and abc[y] == 0:
  exit(print('No'))


def con(x):
  if x == 0:
    return 'A'
  elif x == 1:
    return 'B'
  else:
    return 'C'

def sel(i):
  x = s[i][0]
  y = s[i][1]
  if abc[x] == 0:
    print(con(x))
    abc[x] += 1
    abc[y] -= 1
  elif abc[y] == 0:
    print(con(y))
    abc[y] += 1
    abc[x] -= 1
  else:
    nx = s[i+1][0]
    ny = s[i+1][1]
    if abc[nx] == 0:
      if nx == x:
        print(con(x))
        abc[x] += 1
        abc[y] -= 1
      elif nx == y:
        print(con(y))
        abc[y] += 1
        abc[x] -= 1 
    elif abc[ny] == 0:
      if ny == x:
        print(con(x))
        abc[x] += 1
        abc[y] -= 1
      elif ny == y:
        print(con(y))
        abc[y] += 1
        abc[x] -= 1              
      else:
        print(con(x))
        abc[x] += 1
        abc[y] -= 1          

print('Yes')
for i in range(n):
  sel(i)
Problem p02702 (python)

Fixed submission:
S = input()
S = S + '0'
mod = 2019
p = [0] * mod
r = 0
d = 1
for s in reversed(S):
  t = int(s)%mod
  r += t*d
  r %= mod
  d = d*10%mod
  p[r] += 1

print(sum([i*(i-1)//2 for i in p]))

Buggy submission (verdict: Runtime Error):
from collections import Counter
S = input()
S = S + '0'
mod = 2019
p = [-1] * len(S)
r = 0
d = 1
for i,s in enumerate(S[::-1]):
  t = int(s)%mod
  r += t*d
  r %= mod
  d = d*10%mod
  p[i] = r

ans = 0
c = Counter(p)
for k,n in c.most_common():
  if n > 1 ans n%2 == 0:
    ans += n//2
  else:break
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
N = (int(s)//2019) + 1
ans = 0
P = [0] * N
for i in range(N):
  P[i] = str(i*2019)

for p in P:
  k = s.find(p)
  if k != -1:
    ans += 1
    while k >= 0:
      k = s[k+1:].find(p)
      if k != -1:ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
n = (int(s)//2019) + 1
ans = 0
p = [0] * (n+1)
for i in range(1,n+1):
  p[i] = (2019 * i)

for j in p:
  ss = s
  while len(ss) > 0:
    idx = ss.find(str(j))
    if idx == -1:
      break
    else:
      ans += 1
      ss = ss[idx+1:]

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
n = (int(s)//2019) + 1
ans = 0
p = [0] * (n+1)
for i in range(n+1):
  p[i] = (2019 * i)

for j in p:
  ss = s
  while len(ss) > 0:
    idx = ss.find(str(j))
    if idx == -1:
      break
    else:
      ans += 1
      ss = ss[idx+1:]


print(ans)
Problem p02761 (python)

Fixed submission:
N,M = list(map(int,input().split()))
SC = [0]*(N+1)
if M == 0:
  if N==1:
    print(0)
    exit()
  else:
    print(1*10**(N-1))
    exit()

for m in range(M):
  sc = list(map(int,input().split()))
  if (sc[0] == 1) and (sc[1] == 0):
    if N==1:
      continue
    else:
      print(-1)
      exit()
  elif sc[0] > N:
    print(-1)
    exit()
  elif SC[sc[0]] == 0:
    SC[sc[0]] = sc[1]
  else:
    if SC[sc[0]] != sc[1]:
      print(-1)
      exit()

if (SC[1]==0) and (N > 1):
  SC[1] = 1
ans = 0
for i in range(N):
  ans += 10**(N-i-1)*SC[i+1]

print(ans)

Buggy submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
SC = [0]*(M+1)
if M == 0:
  print(1*10**(N-1))
  exit()
for m in range(M):
  sc = list(map(int,input().split()))
  if (sc[0] == 1) and (sc[1] == 0):
    print(-1)
    exit()
  elif sc[0] > N:
    print(-1)
    exit()
  elif SC[sc[0]] == 0:
    SC[sc[0]] = sc[1]
  else:
    if SC[sc[0]] != sc[1]:
      print(-1)
      exit()


if SC[1]==0:
  SC[1] = 1
ans = 0
for i in range(N):
  ans += 10**(N-i-1)*SC[i+1]

print(ans)

Buggy submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
SC = [0]*(M+1)
for m in range(M):
  sc = list(map(int,input().split()))
  if (sc[0] == 1) and (sc[1] == 0):
    print(-1)
    exit()
  if sc[0] > N:
    print(-1)
    exit()
  if SC[sc[0]] == 0:
    SC[sc[0]] = sc[1]
  else:
    if SC[sc[0]] != sc[1]:
      print(-1)
      exit()


if SC[1]==0:
  SC[1] = 1
ans = 0
for i in range(N):
  ans += 10**(N-i-1)*SC[i+1]

print(ans)