TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B, C, D = lr()
S = input()
# if C > D:
#     if "..." not in S[B-1:D]:
#         print("No")
#         exit(0)
# if "##" in S[A-1:C] or "##" in S[B-1:D]:
#     print("No")
# else:
#     print("Yes")
if "##" in S[A-1:C] or "##" in S[B-1:D]:
    print("No")
elif C < D:
    print("YES")
elif "..." not in S[B-1:D]:
    print("No")
    exit(0)
else:
    print("Yes")


import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B, C, D = lr()
S = input()
# if C > D:
#     if "..." not in S[B-1:D]:
#         print("No")
#         exit(0)
# if "##" in S[A-1:C] or "##" in S[B-1:D]:
#     print("No")
# else:
#     print("Yes")

# ans = "Yes"
# if C > D:
#     tmp = S[B-2:D+1].count("...")
#     if tmp == 0:
#         ans = "No"

# tmp = S[A-1:max(C, D)].count("##")
# if tmp > 0:
#     ans = "No"
# print(ans)

ans="Yes"

if D<C:
  if "..." not in S[B-2:D+1]:
    ans="No"

if "##" in S[A-1:max(C,D)]:
  ans="No"

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):

if C < D:
    if st[A:C].find('##') >= 0 or st[B:D].find('##') >= 0:
        print('No')
    else:
        print('Yes')
else:
    
    if st[A:C].find('##') >= 0:
        print('No')
    else:
        fnd = st.find('...', B-1, D+1)
        if fnd >= 0:
            print('Yes')
        else:
            print('No')

import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def SI(): return input()

N,A,B,C,D=LI()
st=input()

if C < D:
    if st[A:C].find('##') >= 0 or st[B:D].find('##') >= 0:
        print('No')
    else:
        print('Yes')
else:
    
    if st.find('##', A-1, C) >= 0:
        print('No')
    else:
        fnd = st.find('...', B-2, D+1)
        if fnd >= 0:
            print('Yes')
        else:
            print('No')


Verdicts: Runtime Error

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
n,a,b,c,d=map(int,input().split());s=input()
if c<=b:
  if "##"in s[a-1:c] or"##"in s[b-1:d]:print("No")
  else:print("Yes")
else:
  if "..." not in s[b-1:d]:print("No");exit()
  if "##"in s[a-1:max(c,d)]:print("No")
  else:print("Yes")

n,a,b,c,d=map(int,input().split());s=input()
if c<=d:
  if "##"in s[a-1:c] or"##"in s[b-1:d]:print("No")
  else:print("Yes")
else:
  if "..." not in s[max(0,b-2):d+1]:print("No");exit()
  if "##"in s[a-1:c] or"##"in s[b-1:d]:print("No")
  else:print("Yes")


Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):

N = int(input())
A = list(map(lambda x: int(x),input().split()))

judge=False
#print(A)

for i in range(1,N):
    left = A[0]
    right = A[i]
    tmp_1=A[:]
    #print(tmp_1)
    tmp_1.remove(right)
    tmp_1.remove(left)
    tmp_2=[]
    isAble=True
    while isAble:
        #print(tmp_1)
        #print(tmp_2)
        x = right ^ left
        #print(x)
        if x in tmp_1:
            #print(x)
            left = right
            right = x
            tmp_1.remove(x)
            tmp_2.append(x)
        else:
            isAble=False

    if len(tmp_1)==0:
        judge=True
        break
    else:
        continue


ans = 'Yes' if judge else 'No'
print(ans)


N,A,B,C,D = list(map(lambda x: int(x),input().split()))
S = input()
def isAble():
    if "##" in S:
        return "No"
    if C>D:
        if "..." not in S:
            return "No"
    return "Yes"


N,A,B,C,D = list(map(lambda x: int(x),input().split()))
S = " "+input()
def isAble():
    if "##" in S[A:C+1] or "##" in S[B:D+1]:
        return "No"
    if C>D:
        if "..." not in S[B-1:D+2]:
            return "No"
    return "Yes"

print(isAble())

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
N, A, B, C, D = map(int, input().split())
S = input()

if A < C < B < D:
    if not (S.find("##", A - 1) < C - 1 and S.find("##", A - 1) != -1) and not (
            S.find("##", B - 1) < D - 1 and S.find("##", B - 1) != -1):
        print("Yes")
    else:
        print("No")
elif C < D:
    if S.find("##", A - 1) > D - 1 or S.find("##", A - 1) == -1:
        print("No")
    else:
        print("Yes")
else:
    if S.find("...", B - 1) < D - 1 and S.find("...", B - 1) != -1:
        if S.find("##", A - 1) > C - 1 or S.find("##", A - 1) == -1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


N, A, B, C, D = map(int, input().split())
S = input()

if C < D:
    if S.find("##") > D - 1 or S.find("##") == -1:
        print("YES")
    else:
        print("NO")
else:
    if S.find("...") < D - 1 and S.find("...") != -1:
        if S.find("##") > C - 1 or S.find("##") == -1:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")


N, A, B, C, D = map(int, input().split())
S = input()

if A < C < B < D:
    if not (S.find("##", A - 1) < C - 1 and S.find("##", A - 1) != -1) and not (
            S.find("##", B - 1) < D - 1 and S.find("##", B - 1) != -1):
        print("Yes")
    else:
        print("No")
elif C < D:
    if S.find("##", A - 1) > D - 1 or S.find("##", A - 1) == -1:
        print("Yes")
    else:
        print("No")
else:
    if S.find("...", B - 2) < D - 1 and S.find("...", B - 2) != -1:
        if S.find("##", A - 1) > C - 1 or S.find("##", A - 1) == -1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
import sys
N,A,B,C,D = map(int, input().split())
S = input()
NG = N+3
OOmin = N+2
OOmax = 0
for i in range(N-1):
  if S[i] == S[i+1] == '#':
    if i+1 < C or i+1 < D:
      print("No")
      sys.exit()
    if i+1 > A:
      print("No")
      sys.exit()
for i in range(N-2):
  if S[i] == S[i+1] == S[i+2] == '.':
    if C>D and (i+2 > D or i+2 < B):
      if i == N-3:
        print("No")
        sys.exit()
    else:
      break
  else:
    if i == N-3:
      print("No")
      sys.exit()
print("Yes")


import sys
N,A,B,C,D = map(int, input().split())
S = input()
for i in range(N-1):
  if S[i] == S[i+1] == '#':
    if A < i+1 < C or B < i+1 < D:
      print("No")
      sys.exit()
if C>D:
  for i in range(N-2):
    if S[i] == S[i+1] == S[i+2] == '.':
      if B <= i+2 <= D:
        break
    if i == N-3:
      print("No")
      sys.exit()
print("Yes")

Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
n,a,b,c,d=(int(i) for i in input().split())
s=input()
r="Yes"
for i in(a,d):
  if s[i]=="#":
    if s[i+1]=="#":
      r="No"
      break
if r=="Yes" and c>d:
  r="No"
  for i in range(d-b+1):
    if s[i+b-2]==".":
      if s[i+b-1]==".":
        if s[i+b]==".":
          r="Yes"
          break
print(r)

n,a,b,c,d=(int(i) for i in input().split())
s=input()
r="Yes"
for i in range(d-a+1):
  if s[i+a-1]=="#":
    if s[i+a]=="#":
      r="No"
      break
if r=="Yes" and c>d:
  r="No"
  for i in range(d-b+1):
    if s[i+b-2]==".":
      if s[i+b-1]==".":
        if s[i+b]==".":
          r="Yes"
          break
print(r)

Verdicts: Runtime Error

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
n,a,b,c,d=map(int,input().split())
s="0"+input()
x=s[a:c+1]
y=s[b:d+1]
if "##" in s[a:c+1]:
    print("No")
    exit()

if "##" in s[b:d+1]:
    print("No")
    exit()

if c>d:
    if "..." in s[b:d+1]:
        print("Yes")
    else:
        print("No")

n,a,b,c,d=map(int,input().split())
s="0"+input()
x=s[a:c+1]
y=s[b:d+1]
if "##" in s[a:c+1]:
    print("No")
    exit()

if "##" in s[b:d+1]:
    print("No")
    exit()

if c>d:
    if not "..." in s[b-1:d+2]:
        print("No")
        exit()
    
print("Yes")

Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
l = list(map(int,input().split()))
N = l[0]
A = l[1] 
B = l[2]
C = l[3]
D = l[4]
S = input()
S_list = list(S)

if B < C < D :
    count = 0
    for i in range(A, D-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else : 
        print('Yes')
elif C < B < D :
        count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    for i in range(B, D-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else :
        print('Yes')
elif B < D < C
    count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    count = 0
    for i in range(B-2, D-1):
        if S_list[i] == S_list[i+1] == S_list[i+2] == '.' :
            count += 1
    if count >= 1:
        print('Yes')  
    else:
        print('No') 


l = list(map(int,input().split()))
N = l[0]
A = l[1] 
B = l[2]
C = l[3]
D = l[4]
S = input()
S_list = list(S)

if B < C < D :
    count = 0
    for i in range(A, D-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else : 
        print('Yes')
elif C < B < D :
    count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    for j in range(B, D-1):
        if S_list[j] == S_list[j+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else :
        print('Yes')
elif B < D < C:
    count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1

    cou = 0
    for i in range(B-2, D-1):
        if S_list[i] == S_list[i+1] == S_list[i+2] == '.' :
            cou += 1
    if cou >= 1 and count < 1 :
        print('Yes')  
    else:
        print('No') 


Verdicts: Runtime Error

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
n, a, b, c, d = map(int, input().split())

s = input()

flag1 = True
flag2 = True
flag3 = True

for i in range(b, d):
    if s[i:i+2] == "##":
        flag1 = False
for i in range(a, c):
    if s[i:i+2] == "##":
        flag2 = False
for i in range(b-2, d-1):
    if s[i:i+3] != "...":
        flag3 = False

if flag1 and flag2 and flag3:
    print("Yes")
else:
    print("No")


n, a, b, c, d = map(int, input().split())

s = input()

for i in range(b, d):
    if s[i:i+2] == "##":
        print('No')
        exit()
for i in range(a, c):
    if s[i:i+2] == "##":
        print('No')
        exit()
if c < d:
    print('Yes')
else:
    for i in range(b-2, d-1):
        if s[i:i+3] == "...":
            print('Yes')
            exit()
    print('No')


Verdicts: Wrong Answer

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
N,A,B,C,D=map(int,input().split())
A,B,C,D=A-1,B-1,C-1,D-1
S=input()

Aleft=A
Aright=min(S.find("
Bleft=B
Bright=min(S.find("

ans=True
if C<Aleft or Aright<C:
  ans=False
if D<Bleft or Bright<D:
  ans=False
  
if (A-B)*(C-D)<0:
  commonL=max(Aleft,Bleft)
  commonR=min(Aright,Bright)
  if commonR<commonL:
    ans=False
  elif "..." not in S[commonL:commonR+1]:
    ans=False

print(("No","Yes")[ans])


N,A,B,C,D=map(int,input().split())
A,B,C,D=A-1,B-1,C-1,D-1
S=input()

Aleft=max(S[:A].rfind("##"),0)
Aright=S.find("

Bleft=max(S[:B].rfind("##"),0)
Bright=S.find("

ans=True
if C<Aleft or Aright<C:
  ans=False
if D<Bleft or Bright<D:
  ans=False
  
if (A-B)*(C-D)<0:
  commonL=max(Aleft,Bleft)
  commonR=min(Aright,Bright)
  if "..." not in S[commonL:commonR+1]:
    ans=False

print(("No","Yes")[ans])

N,A,B,C,D=map(int,input().split())
A,B,C,D=A-1,B-1,C-1,D-1
S=input()

Aleft=max(S[:A].rfind("##"),0)
Aright=S.find("

Bleft=max(S[:B].rfind("##"),0)
Bright=S.find("

ans=True
if C<Aleft or Aright<C:
  ans=False
if D<Bleft or Bright<D:
  ans=False
  
if (A-B)*(C-D)<0:
  commonL=max(Aleft,Bleft)
  commonR=min(Aright,Bright)
  if commonR<commonL:
    ans=False
  elif "..." not in S[commonL:commonR+1]:
    ans=False

print(("No","Yes")[ans])


N,A,B,C,D=map(int,input().split())
A,B,C,D=A-1,B-1,C-1,D-1
S=input()

Aleft=max(S[:A].rfind("##"),0)
Aright=S.find("

Bleft=max(S[:B].rfind("##"),0)
Bright=S.find("

ans=True
if C<Aleft or Aright<C:
  ans=False
if D<Bleft or Bright<D:
  ans=False
  
if C>D:
  commonL=max(Aleft,Bleft)
  commonR=min(Aright,Bright)
  if "..." not in S[commonL:commonR+1]:
    ans=False

print(("No","Yes")[ans])

N,A,B,C,D=map(int,input().split())
A,B,C,D=A-1,B-1,C-1,D-1
S=input()

ans=True
if "##" in S[A:C+1]:
  ans=False
if "##" in S[B:D+1]:
  ans=False

if (A-B)*(C-D)<0:
  commonL=max(A,B)
  if commonL>0:
    commonL-=1
  commonR=min(C,D)
  if commonL<len(S)-1:
    commonR+=1
  if commonR<commonL:
    ans=False
  elif "..." not in S[commonL:commonR+1]:
    ans=False

print(("No","Yes")[ans])


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
s=[0]+list(input())
if c<d:
    for i in range(a,d):
        if s[i]==s[i+1]=="#":
            print("No")
            break
    else:
        print("Yes")
else:
    for j in range(a,c):
        if s[j]==s[j+1]=="#":
            print("No")
            break
    else:
        for k in range(b-1,d-2):
            if s[k]==s[k+1]==s[k+2]==".":
                    print("Yes")
                    break
        else:
            print("No")

n,a,b,c,d=map(int,input().split())
s=[0]+list(input())
if c<d:
    for i in range(a,d):
        if s[i]==s[i+1]=="#":
            print("No")
            break
    else:
        print("Yes")
else:
    for j in range(a,c):
        if s[j]==s[j+1]=="#":
            print("No")
            break
    else:
        for k in range(b-1,d):
            if s[k]==s[k+1]==s[k+2]==".":
                    print("Yes")
                    break
        else:
            print("No")

Verdicts: Runtime Error

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
def a_kenken_race(N, A, B, C, D, S):
    
    
    cond1 = S[A:C + 1].count('##') == 0 and S[B:D + 1].count('##') == 0
    cond2 = S[B:D + 1].count('...') >= 1
    if C < D:
        
        ans = 'Yes' if cond1 else 'No'
    else:
        
        ans = 'Yes' if cond1 and cond2 else 'No'
    return ans

S = input()
print(a_kenken_race(N, A, B, C, D, S))

def a_kenken_race(N, A, B, C, D, S):
    
    
    cond1 = '##' in S[A - 1:C] or '##' in S[B - 1:D]
    cond2 = '...' not in S[B - 2:D + 1]

    if cond1:
        ans = 'No'
    elif C > D and cond2:
        ans = 'No'
    else:
        ans = 'Yes'  
    return ans

N, A, B, C, D = [int(i) for i in input().split()]
S = input()
print(a_kenken_race(N, A, B, C, D, S))

Verdicts: Runtime Error

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
N,A,B,C,D = map(int,input().split())
S = list(input())
ans = "Yes"
is_reversed = False
flag = False

if D < C:
  is_reversed = True

for i in range(A,max(C,D) -1):
  if S[i] == S[i + 1] == "#":
    ans = "No"
if is_reversed == True:
  for i in range(B - 2,D - 1):
    if S[i] == S[i + 1] == S[i + 2] == ".":
 
  if flag == False:
    ans = "No"
print(ans)

N,A,B,C,D = map(int,input().split())
S = list(input())
ans = "Yes"
is_reversed = False
flag = False
if D < C:
  is_reversed = True
for i in range(A,max(C,D) -1):
  if S[i] == S[i + 1] == "#":
    ans = "No"
for i in range(B - 2,D - 1):
  if S[i] == S[i + 1] == S[i + 2] == ".":
    flag = True

if is_reversed == True and flag == False:
  ans = "No"
print(ans)

N,A,B,C,D = map(int,input().split())
S = list(input())

ans = "Yes"
is_reversed = False
flag = False
# cnt = 0
# max_cnt = 0
if D < C:
  is_reversed = True

for i in range(A,max(C,D) -1):
  if S[i] == S[i + 1] == "#":
    ans = "No"
if is_reversed == True:
  for i in range(B - 2,D - 1):
    if S[i] == S[i + 1] == S[i + 2] == ".":
      flag = True
    # if S[i] == ".":
    #   cnt += 1
    # elif S[i] == "#":
    #   cnt = 0
    # max_cnt = max(max_cnt,cnt)
    
  # if is_reversed == True and max_cnt < 3:
  #   ans = "No"
  if flag == False:
    ans = "No"
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
number_of_masu, firstsunuke, firstfunuke, lastsunuke, lastfunuke = map(int, input().split())
s = str(input())
tobenaiflag = 0
nukaseruflag = 0
lastfunuke -= 1
lastsunuke -= 1
firstsunuke -= 1
firstfunuke -= 1


#    if s[i] == '#' and s[i+1] == '#':

#        break
# for k in range(firstfunuke, lastfunuke-1):
#    if s[k] == '#' and s[k+1] == '#':

#        break
tobenaiflag = 1
if lastfunuke < lastsunuke:
    for j in range(max(firstsunuke, firstfunuke)-1, lastfunuke-1):
        if s[j] == '.' and s[j+1] == '.' and s[j+2] == '.':
            nukaseruflag += 1
            break
else:
    nukaseruflag += 1
# if tobenaiflag == 0 and nukaseruflag == 1:
#    print('Yes')
# else:
#    print('No')
print('No')


number_of_masu, firstsunuke, firstfunuke, lastsunuke, lastfunuke = map(int, input().split())
s = str(input())
tobenaiflag = 0
nukaseruflag = 0
lastfunuke -= 1
lastsunuke -= 1
firstsunuke -= 1
firstfunuke -= 1


#    if s[i] == '#' and s[i+1] == '#':

#        break
# for k in range(firstfunuke, lastfunuke-1):
#    if s[k] == '#' and s[k+1] == '#':

#        break
tobenaiflag = 1
if lastfunuke < lastsunuke:
    for j in range(max(firstsunuke, firstfunuke)-1, lastfunuke-1):
        if s[j] == '.' and s[j+1] == '.' and s[j+2] == '.':
            nukaseruflag += 1
            break
else:
    nukaseruflag += 1
if tobenaiflag == 0 and nukaseruflag == 1:
    print('Yes')
else:
    print('No')


number_of_masu, firstsunuke, firstfunuke, lastsunuke, lastfunuke = map(int, input().split())
s = str(input())
tobenaiflag = 0
nukaseruflag = 0
lastfunuke -= 1
lastsunuke -= 1
firstsunuke -= 1
firstfunuke -= 1
for i in range(firstsunuke, lastsunuke-1):
    if s[i] == '#' and s[i+1] == '#':
        tobenaiflag += 1
        break
for k in range(firstfunuke, lastfunuke-1):
    if s[k] == '#' and s[k+1] == '#':
        tobenaiflag += 1
        break
if lastfunuke < lastsunuke:
    for j in range(firstfunuke, lastfunuke+1):
        if s[j] == '.' and s[j-1] == '.' and s[j+1] == '.':
            nukaseruflag += 1
            break
else:
    nukaseruflag += 1
if number_of_masu == 4:
    print('Yes')
elif tobenaiflag == 0 and nukaseruflag == 1:
    print('Yes')
else:
    print('No')


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty.  In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.  You can repeat the following operation any number of times:    * Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.  You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.  Determine whether this is possible.

Submission attempts (in order):
def resolve():
    N, A, B, C, D = map(int, input().split())
    S = str(input())
    if C < D:
        if '##' in S[min(A, B):D]:
            print('No')
        else:
            print('Yes')
    elif C > D:
        if '##' in S[min(A, B):C]:
            print('No')
        else:
            if '...' in S[B-2:D+2]:
                print('Yes')
            else:
                print('No')

N, A, B, C, D = map(int, input().split())
S = str(input())
if C < D:
    if '##' in S[min(A, B):D]:
        print('No')
    else:
        print('Yes')
elif C > D:
    if '##' in S[min(A, B):C]:
        print('No')
    else:
        
        if '...' in S[B - 2:D + 1]:
            print('Yes')
        else:
            print('No')


Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
import re
s=input()
ans=0
match_s = re.search(r'A*(ABC)+(BC)*',s)

while(True):
    if(match_s):
        abc=match_s.group()
        while(abc.find('ABC')!=-1):
            abc=abc.replace('ABC','BCA')
            ans+=1
        s=abc+s[match_s.end():]
        match_s = re.search(r'A*(ABC)+(BC)*',s)
    else:
        break
print(ans)

import re
s=input()
ans=0

s=re.sub('BC', 'D', s)

re_ad=re.compile(r'[AD]+')
ad=re.findall(re_ad,s)
#print(s)
#print(ad)
for adi in ad:
    adi_a=0
    for adij in adi:
        if(adij=='A'):
            adi_a+=1
        else:
            ans+=adi_a

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s=list(input())
l=[]
x=-100
for i in range(len(s)-1):
  if x==i:
    pass
  else:
    if s[i]=='B' and s[i+1]=='C':
      l.append('D')
      x=i+1
    else:
      l.append(s[i])
f=0
ct=0
for i in range(len(l)):
  if l[i]=='A':
    f+=1
  if l[i]=='B' or l[i]=='C':
    f=0
  if l[i]=='D':
    ct+=f
  print(ct)
print(ct)

s=list(input())
l=[]
x=-100
for i in range(len(s)-1):
  if x==i:
    pass
  else:
    if s[i]=='B' and s[i+1]=='C':
      l.append('D')
      x=i+1
    else:
      l.append(s[i])
f=0
ct=0
for i in range(len(l)):
  if l[i]=='A':
    f+=1
  if l[i]=='B' or l[i]=='C':
    f=0
  if l[i]=='D':
    ct+=f
print(ct)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input().strip().replace('BC', 'D')
n = len(s)

count = 0
a_count = 0
print(s)
for i in range(n):
  if s[i] == 'A':
    a_count += 1
  elif a_count > 0 and s[i] == 'D':
    count += a_count
  else:
    a_count = 0

print(count)

s = input().strip().replace('BC', 'D')
n = len(s)

count = 0
a_count = 0
for i in range(n):
  if s[i] == 'A':
    a_count += 1
  elif a_count > 0 and s[i] == 'D':
    count += a_count
  else:
    a_count = 0

print(count)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
import re
s = input()
ans = 0
for v in re.finditer('(A(BC)+A?)+', s):
    sub = s[v.start():v.end()]
    total = sub.count('BC')
    abc_num = sub.count('ABC')
    ans += total * (total - 1) // 2 + abc_num
    
print(ans)

s = input().replace('BC', 'D')
ans = 0
cnt = 0

for c in s:
    if c == 'A':
        cnt += 1
    elif c == 'D':
        ans += cnt
    else:
        cnt = 0
print(ans)



Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input()
s = s.split('BC')
count = [0]
count_all = 0
Icount = 0

for i in range(0,len(s)-1):
    Icount = 0
    j = 1
    while(j<=len(s[i]) and s[i][-j]=='A'):
        Icount = Icount + 1
        j = j + 1
        
    if (s[i]=='' or s[i]=='A'*len(s[i])):
        Icount = Icount + count[-1]
   
    count.append(Icount)
  
        
count_all = sum(count)  
print(count)
print(count_all)

s = input()
s = s.split('BC')
count = [0]
count_all = 0
Icount = 0

for i in range(0,len(s)-1):
    Icount = 0
    j = 1
    while(j<=len(s[i]) and s[i][-j]=='A'):
        Icount = Icount + 1
        j = j + 1
        
    if (s[i]=='' or s[i]=='A'*len(s[i])):
        Icount = Icount + count[-1]
   
    count.append(Icount)
  
        
count_all = sum(count)  
print(count_all)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
import copy
S = input()
#print(S)
S2 = S.replace("BC", "D")
#print(S2)
flag = 0
countnum = 0
start = -1
count = 0
for i in range(len(S2)):
    #print(S2[i])
    if S2[i] == "A" or S2[i] == "D":
        if flag == 0:
            start = i
        countnum += 1
        flag = 1
    elif flag == 1:
        for j in range(start + countnum - 1, start - 1, -1):
            #print(S2[j], j)
            if S2[j] == "D":
                for k in range(j, start - 1, -1):
                    if S2[k] == "A":
                        count += 1
        flag = 0
        countnum = 0
    #print(S3)
    #print(s4)
if countnum != 0:
    for i in range(start + countnum - 1, start - 1, -1):
        print(S2[i], i)
        if S2[i] == "D":
            for j in range(i, start - 1, -1):
                if S2[j] == "A":
                    count += 1
#print(S3)

print(count)

import copy
S = input()
#print(S)
S2 = S.replace("BC", "D")
#print(S2)
count = 0
Acount = 0
Dcount = 0
for i in range(len(S2)):
    if S2[i] == 'A' or S2[i] == 'D':
        if S2[i] == 'A':
            Acount += 1
        else:
            count += Acount
    else:
        Acount = 0
    #print(count, Acount, S2[i])
print(count)


Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input()
a = "ABC"
ans = 0

while("ABC" in s):
    s = s.replace("ABC","BCA")
    ans += 1

print(ans)


s = input()
ans = 0
pre_chance = 0
pos_chance = 0

for i in range(len(s)-1):
    if s[i] == "A":
        if s[i:i+2] == "AA":
            pre_chance += 1
            pos_chance = 0
        elif s[i:i+3] == "ABC":
            ans += pre_chance + 1
            pre_chance = 0
        else:
            pre_chance = 0
            pos_chance = 0
    elif s[i] == "B":
        if s[i:i+2] == "BC" and pos_chance == 1:
            ans += 1
            pre_chance = 0
        else:
            pre_chance = 0
            pos_chance = 0
    elif s[i] == "C":
        if s[i-1:i+2] == "BCA" and pos_chance == 1:
            pre_chance += 1
        elif s[i-1:i+1] == "BC" and pos_chance == 1:
            pos_chance = 1
        elif s[i-2:i+2] == "ABCB":
            pos_chance = 1
        else:
            pre_chance = 0
            pos_chance = 0

print(ans)


s = input()
ans = 0
pre_chance = 0
pos_chance = 0

for i in range(len(s)-1):
    if s[i] == "A":
        if s[i:i+2] == "AA":
            pre_chance += 1
            pos_chance = 0
        elif s[i:i+3] == "ABC":
            ans += pre_chance + 1
            pre_chance = 0
        else:
            pre_chance = 0
            pos_chance = 0
    elif s[i] == "B":
        if s[i:i+2] == "BC" and pos_chance == 1:
            ans += 1
            pre_chance = 0
        else:
            pre_chance = 0
            pos_chance = 0
    elif s[i] == "C":
        if s[i-1:i+2] == "BCA" and pos_chance == 1:
            pre_chance += 1
            pos_chance = 1
        elif s[i-1:i+1] == "BC" and pos_chance == 1:
            pos_chance = 1
        elif s[i-2:i+2] == "ABCB":
            pos_chance = 1
        else:
            pre_chance = 0
            pos_chance = 0

print(ans)


s = input()
s = s.replace("BC","X")
ans = []
c = 0

for i in range(1,len(s)+1):
    if s[-1 * i] == "X":
        c += 1
    elif s[-1 * i] == "A":
        ans.append(c)
    else:
        c = 0
print(sum(ans))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s=input()
s=s.replace('BC','D')
s=list(s)
count=0
 
def change():
  global count
  flg=False
  for i in range(len(s)-2):
    if s[i]=='A' and s[i+1]=='D':
      s[i]='D'
      s[i+1]='A'
      count+=1
      flg=True
      
  return flg
      
while(change()):
  pass
 
print(count)

s=input()
s=s.replace('BC','D')
s=list(s)
count=0
 
def change():
  global count
  flg=False
  acount=0
  for i in range(len(s)-1):
    if s[i]=='A' and s[i+1]=='D':
      s[i]='D'
      s[i+1]='A'
      count+=1
      flg=True
      count+=acount
    elif s[i]=='A':
      acount+=1
    else:
      acount=0
      
  return flg
      
change()
 
print(count)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
S = input()
L = [" "]
for s in S:
  if s == 'A':
    L.append('0')
  elif s == 'B':
    L.append('B')
  elif s == 'C' and L[-1] == 'B':
    L[-1] = '1'
  else:
    L.append('C')

ans = 0
a = 0
while True:
  a = 0
  for i in range(1,len(L)):
    if L[i] == '0' and L[i + 1] == '1':
      L[i],L[i + 1] = L[i + 1],L[i]
      ans += 1
      a += 1
#      print("".join(L),i)
  if a == 0:
    print(ans)
    break
    

S = input()
L = [" "]
for s in S:
  if s == 'A':
    L.append('0')
  elif s == 'B':
    L.append('B')
  elif s == 'C' and L[-1] == 'B':
    L[-1] = '1'
  else:
    L.append('C')

def func(a,b):
#  print(a,b)
  return a * b

ans = 0
a,b = 0,0
i = 0
while i < len(S):
  if S[i] == 'A':
    if b != 0:
      ans += func(a,b)
      b = 0
    a += 1
  elif S[i:i + 2] == 'BC':
    b += 1
  elif S[i - 1:i + 1] == "BC":
    ()
  else:
    ans += func(a,b)
    a,b = 0,0
  i += 1
print(ans + func(a,b))

Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
import re

S = input()
ct = 0

while True:
  D = re.findall('A+BC',S)
  if len(D)==0:
    break
  for d in D:
    num = len(d)-2
    ct += num
    S=S.replace(d,'BC'+'A'*num)
print(ct)

import re

S = input()
ct = 0

na = 0
bf = False
ct = 0
for s in S:
  if s =='A':
    if bf==True:
      na = 1
    else:
      na += 1
    bf = False
      
  if s == 'B':
    if na > 0 and bf==False:
      bf = True
    else:
      na = 0
      bf = False
  if s == 'C':
    if bf:
      ct += na
    else:
      na = 0
    bf = False
print(ct)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
S = input()
S.replace('BC','X')
res = 0
cnt = 0
for i in range(len(S)):
    if S[i] == 'A' :
        cnt += 1
    elif S[i] == 'X':
        res += cnt
    else:
        cnt = 0
print(res)


S = input()
T = S.replace('BC','X')
res = 0
cnt = 0
for s in T:
    if s == 'A' :
        cnt += 1
    elif s == 'X':
        res += cnt
    else:
        cnt = 0
print(res)


Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
S = input()
N = len(S)
ans = 0
for i in range(N-2):
  if S[i:i+3] == "ABC":
    ans += 1
for i in range(N-3):
  if S[i:i+4] == "AABC":
    ans += 1
for i in range(N-4):
  if S[i:i+5] == "ABCBC":
    ans += 1
for i in range(N-8):
  if S[i:i+9] == "ABCBCAABC":
    ans += 1
print(ans)

S = input()
T = ""
N = len(S)
flag = 0
for i in range(N):
  if flag == 1:
    flag = 0
    continue
  elif S[i:i+2] == "BC":
    T += "D"
    flag = 1
  else:
    T += S[i]

M = len(T)
count = 0
ans = 0
for i in range(M):
  if T[i] == "A":
    count += 1
  elif T[i] == "D":
    ans += count
  else:
    count = 0
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
def main():
    S = input()
    S = S.replace("BC", "D")
    N = len(S)
    ans = 0
    a_cnt = 0
    for i in range(N-1):
        if S[i] == "A":
            a_cnt += 1
        elif S[i] == "D":
            ans += a_cnt
        else:
            a_cnt = 0
    print(ans)


if __name__ == '__main__':
    main()


def main():
    S = input()
    S = S.replace("BC", "D")
    N = len(S)
    ans = 0
    a_cnt = 0
    for i in range(N):
        if S[i] == "A":
            a_cnt += 1
        elif S[i] == "D":
            ans += a_cnt
        else:
            a_cnt = 0
    print(ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s=input()
l=s.replace('BC','D')
a=0
ans=0
for i in range(len(l)):
  if s[i]=='A':
    a+=1
  elif s[i]=='D':
    ans+=a
  else:
    a=0
print(ans)

s=input()
l=s.replace('BC','D')
a=0
ans=0
for i in range(len(l)):
  if l[i]=='A':
    a+=1
  elif l[i]=='D':
    ans+=a
  else:
    a=0
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
import math
import numpy as np
import re


def inputs(): return [int(s) for s in input().split()]


def main():
    s = input()
    cnt = 0
    s = s.replace('A', '1').replace('BC', '0')
    arr = re.split('[A-C]', s)
    arr = [list(x) for x in arr]
    flag = True
    while flag:
        flag = False
        for a in arr:
            tmp = 0
            for i in a:
                tmp += i
                if i is 0:
                    cnt += tmp
                    
    return cnt


if __name__ == '__main__':
    print(main())


import math
import numpy as np
import re


def inputs(): return [int(s) for s in input().split()]


def main():
    s = input()
    cnt = 0
    s = s.replace('A', '1').replace('BC', '0')
    arr = re.split('[A-C]', s)
    arr = [list(x) for x in arr]

    for a in arr:
        tmp = 0
        for i in a:
            i = int(i)
            tmp += i
            if i is 0:
                cnt += tmp

    return cnt


if __name__ == '__main__':
    print(main())


Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input()
 
ans = 0
s = s.replace("BC","D")
cnt_A = 0
 

for i in s:
    if i == "A":
        cnt_A += 1
    elif s == "D":
        ans += cnt_A
    else:
        cnt_A = 0

print(ans)

s = input()
 
ans = 0
s = s.replace("BC","D")
cnt_A = 0
 

for i in s:
    if i == "A":
        cnt_A += 1
    elif i == "D":
        ans += cnt_A
    else:
        cnt_A = 0

print(ans)

Verdicts: Wrong Answer

Accepted