ZhenlongDai/ACPR huggingface dataset:
Problem: p03018
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def sol(S):
  N = len(S)
  nums = [0 for _ in range(N+1)]
  i = N-1
  while i >= 0:
    if S[i-1:i+1] == 'BC':
      nums[i-1] = nums[i+1] + 1
      nums[i] = nums[i+1] + 1
      i -= 2
    else:
      nums[i] = nums[i+1]
      i -= 1
  ans = 0
  for i, s in enumerate(S):
    if s == 'A':
      ans += nums[i]
  return ans

S = input()
ans = 0
for s1 in S.split('BB'):
  for s2 in s1.split('CC'):
    ans += sol(s2)
print(ans)

Failing test case input:
ADCBABBCAABCCBBBD

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
def sol(S):
  N = len(S)
  nums = [0 for _ in range(N+1)]
  i = N-1
  while i >= 0:
    if S[i-1:i+1] == 'BC':
      nums[i-1] = nums[i+1] + 1
      nums[i] = nums[i+1] + 1
      i -= 2
    else:
      nums[i] = nums[i+1]
      i -= 1
  ans = 0
  for i, s in enumerate(S):
    if s == 'A':
      ans += nums[i]
  return ans

S = input()
ans = 0
N = len(S)
si, i = 0, 0
while i < N:
  if S[i] == 'A':
    i += 1
  elif S[i:i+2] == 'BC':
    i += 2
  else:
    ans += sol(S[si:i+1])
    si = i + 1
    i += 1
ans += sol(S[si:])
print(ans)

Problem: p03018
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s=list(input())
count=0
for i in range(len(s)-2):
    if s[i:i+3]==['A','B','C']:
        count+=1
        s[i]='B'
        s[i+1]='C'
        s[i+2]='A'
        for j in range(1,len(s)):
            if i-j<0:
                break
            if s[i-j]=='A':
                count+=1
                s[i-j]='B'
                s[i-j+1]='C'
                s[i-j+1]='A'
                
            
            else:
                break
        
print(count)


        
    
        

        
    


Failing test case input:
ACCAAABCAABCCBBBD

Expected output:
8


Actual output:
6


Fixed submission (verdict: Accepted):
s=list(input())
count=0
count1=0
for i in range(len(s)-2):
    if s[i:i+3]==['A','B','C']:
        count+=1
        s[i]='B'
        s[i+1]='C'
        s[i+2]='A'

            
        for j in range(1,len(s)):
            if i-j<0:
                count+=count1
                break
            if s[i-j]=='A':
                count1+=1
            else:
                count+=count1
                break
            
    if s[i:i+3]==['A','A','A'] or s[i:i+3]==['A','A','B'] or s[i:i+3]==['C','A','A'] or s[i:i+3]==['C','A','B'] or s[i:i+3]==['B','C','A']:
        continue
    else:
        count1=0


print(count)
Problem: p03018
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def sol(S):
  N = len(S)
  nums = [0 for _ in range(N+1)]
  i = N-1
  while i >= 0:
    if S[i-1:i+1] == 'BC':
      nums[i-1] = nums[i+1] + 1
      nums[i] = nums[i+1] + 1
      i -= 2
    else:
      nums[i] = nums[i+1]
      i -= 1
  ans = 0
  for i, s in enumerate(S):
    if s == 'A':
      ans += nums[i]
  return ans

S = input()
ans = 0
for s1 in S.split('BB'):
  for s2 in s1.split('CC'):
    for s3 in s2.split('CB'):
      ans += sol(s2)
print(ans)

Failing test case input:
ADCB@BBCAABCCCBBD

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
def sol(S):
  N = len(S)
  nums = [0 for _ in range(N+1)]
  i = N-1
  while i >= 0:
    if S[i-1:i+1] == 'BC':
      nums[i-1] = nums[i+1] + 1
      nums[i] = nums[i+1] + 1
      i -= 2
    else:
      nums[i] = nums[i+1]
      i -= 1
  ans = 0
  for i, s in enumerate(S):
    if s == 'A':
      ans += nums[i]
  return ans

S = input()
ans = 0
N = len(S)
si, i = 0, 0
while i < N:
  if S[i] == 'A':
    i += 1
  elif S[i:i+2] == 'BC':
    i += 2
  else:
    ans += sol(S[si:i+1])
    si = i + 1
    i += 1
ans += sol(S[si:])
print(ans)

Problem: p03018
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

WALL = 0
ACTIVATE = 1
CHANCE, BINGO = 2, 3

nBC = 0
score = 0
state = WALL
for c in reversed(S):
	if c == 'A':
		state = ACTIVATE
	elif c == 'B' and state == CHANCE:
		state = BINGO
	elif c == 'C':
		if state == CHANCE:
			nBC = 0
		state = CHANCE
	else:
		state = WALL
	
	if state == WALL:
		nBC = 0
	elif state == ACTIVATE:
		score += nBC
	elif state == BINGO:
		nBC += 1

print(score)


Failing test case input:
ACBAACBCCABCCBBBA

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
S = input()

WALL = 0
ACTIVATE = 1
CHANCE, BINGO = 2, 3

nBC = 0
score = 0
state = WALL
for c in reversed(S):
	if c == 'A' and (state == BINGO or state == ACTIVATE):
		state = ACTIVATE
	elif c == 'B' and state == CHANCE:
		state = BINGO
	elif c == 'C':
		if state == CHANCE:
			nBC = 0
		state = CHANCE
	else:
		state = WALL
	
	if state == WALL:
		nBC = 0
	elif state == ACTIVATE:
		score += nBC
	elif state == BINGO:
		nBC += 1

print(score)

Problem: p03018
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
ans = 0
tmp = 0
i = 0
while i < len(s):
    if s[i] == "A":
        tmp += 1
    elif s[i] == "B":
        if i+1 == len(s):
            break
        if s[i+1] == "C":
            ans += tmp
            i += 1
        else:
            tmp = 0
    i += 1
print(ans)

Failing test case input:
ACCAAABCAABCCBBBD

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
s = input()
ans = 0
tmp = 0
i = 0
while i < len(s)-1:
    if s[i] == "A":
        tmp += 1
    elif s[i] == "B":
        if s[i+1] == "C":
            ans += tmp
            i += 1
        else:
            tmp = 0
    else:
        tmp = 0
    i += 1
print(ans)
Problem: p03018
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s=input()
ans=0
a=[0 for i in range(len(s))]
bc=[0 for i in range(len(s))]
for i in range(len(s)):
  if s[i]=="A":
    a[i]=1
for i in range(len(s)-1):
  if s[i]=="B" and s[i+1]=="C":
    bc[i]=1
for i in range(len(s)-1):
  if a[i+1]>0:
    a[i+1]+=a[i]
    a[i]=0
for i in range(len(s)-2,-1,-1):
  if bc[i-2]>0:
    bc[i-2]+=bc[i]
    bc[i]=0
for i in range(len(s)-2):
  if a[i]>0 and bc[i+1]>0:
    ans+=a[i]*bc[i+1]
print(ans)
  

Failing test case input:
ABCABC

Expected output:
3

Actual output:
2


Fixed submission (verdict: Accepted):
s=input()
ans=0
a=[0 for i in range(len(s))]
bc=[0 for i in range(len(s))]
if len(s)<3:
  print(0)
else:
  for i in range(len(s)-2):
    if s[i]=="A":
      a[i]+=1
    if s[i+1]=="B" and s[i+2]=="C":
      a[i+2]+=a[i]
    if s[i+1]=="A":
      a[i+1]+=a[i]
      
  for i in range(len(s)-1):
    if s[i]=="B" and s[i+1]=="C":
      bc[i]=1
  
   
    
     
  
   
    
  
   
    
     
  
   
    
     
  
  for i in range(len(s)-2):
    if a[i]>0 and bc[i+1]>0:
      ans+=a[i]*bc[i+1]
  print(ans)

Problem: p03018
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s = input()
a = 0
count = 0
for i in range(len(s)-1):
  if s[i] == 'A':
    a += 1
  elif s[i] == 'B' and s[i+1]== 'C':
    count += a
  elif s[i]==s[i+1]=='B' or s[i]==s[i+1]=='C' or (s[i]=='B' and s[i+1]=='C'):
    a = 0
print(count)

Failing test case input:
ACBAACBCAABCCBBBC

Expected output:
2


Actual output:
8


Fixed submission (verdict: Accepted):
s = input()
a = 0
count = 0

i = 0
while i < len(s)-1:
  if s[i]=='A':
    a += 1
    i += 1
  elif s[i]=='B' and s[i+1]=='C':
    count += a
    i += 2
  else:
    a = 0
    i += 1
print(count)

Problem: p03018
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def f(ss):
  n=len(ss)
  ct,res=0,0
  for i in range(n):
    if ss[i]=="x":
      ct+=1
    else:
      res+=ct
  return res
s=input()
s=s.replace("BC","y")
s=s.replace("A","x")
ans=0
chk=""
for i in range(len(s)):
  if s[i]=="x" or s[i]=="y":
    chk+=s[i]
  else:
    ans+=f(chk)
    chk=""
print(ans)


Failing test case input:
ABCABC

Expected output:
3

Actual output:
0


Fixed submission (verdict: Accepted):
def f(ss):
  n=len(ss)
  ct,res=0,0
  for i in range(n):
    if ss[i]=="x":
      ct+=1
    else:
      res+=ct
  return res
s=input()
s=s.replace("BC","y")
s=s.replace("A","x")
s+="z"
ans=0
chk=""
for i in range(len(s)):
  if s[i]=="x" or s[i]=="y":
    chk+=s[i]
  else:
    ans+=f(chk)
    chk=""
print(ans)
Problem: p03018
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=list(input())

i=0
j=0
ans=0
z=[]
while i!=len(s)-1:
    try:
        if s[i]=="B" and s[i+1]=="C":
            z.append(1)
            i=i+2

        else:
            if s[i]=="A":
                z.append(2)
                i=i+1

            else:
                z.append(0)
                i=i+1

    except:
      break

ans=0
i=0
r1=0


print(z)


while i!=len(z):
    if z[i]==2:
         r1=r1+1

    elif z[i]==1:
        ans=ans+r1

    else:
        r1 = 0


    i=i+1
print(ans)




Failing test case input:
CGAB@B

Expected output:
0


Actual output:
[0, 0, 2, 0, 0]
0


Fixed submission (verdict: Accepted):
s=list(input())

i=0
j=0
ans=0
z=[]
while i!=len(s)-1:
    try:
        if s[i]=="B" and s[i+1]=="C":
            z.append(1)
            i=i+2

        else:
            if s[i]=="A":
                z.append(2)
                i=i+1

            else:
                z.append(0)
                i=i+1

    except:
      break

ans=0
i=0
r1=0





while i!=len(z):
    if z[i]==2:
         r1=r1+1

    elif z[i]==1:
        ans=ans+r1

    else:
        r1 = 0


    i=i+1
print(ans)

Problem: p03018
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
a=s.replace("BC","D")[::-1]
ans=0
i=0
while i<len(a):
  if a[i]=="D":
    k=1
    while True:
      try:
        if a[i+k]=="A" or a[i+k]=="D":
          ans+=1;k+=1
        else:
          i+=k-1
          break
      except:break
  i+=1
print(ans)

Failing test case input:
ADCBABBCAABCCBBBD

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
s=input()
t=""
i=0
while i<len(s):
    if s[i:i+2]=="BC":
        t+="T"
        i+=2
    else:
        t+=s[i]
        i+=1
ans=0
Acnt=0
for i in t:
    if i=="A":
        Acnt+=1
    elif i=="T":
        ans+=Acnt
    else:
        Acnt=0
print(ans)

Problem: p03018
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
S=input()

N=len(S)
if N<3:
    print(0)
    exit()
S=list(S)

As=0

BCs=0
ans=0
flag=False
for i in range(N-2):
    if "".join(S[i:i+3])=="ABC":
        ans+=1
        ans+=BCs
        ans+=As
        BCs=0
        As=0
        S[i]="B"
        S[i+1]="C"
        S[i+2]="A"
    elif S[i]=="A":
        As+=1
    else:
        As=0

print(ans)

Failing test case input:
ACCAAABCAABCCBBBD

Expected output:
8


Actual output:
6


Fixed submission (verdict: Accepted):
S=input()

N=len(S)
if N<3:
    print(0)
    exit()
S=list(S)

As=0

BCs=0
ans=0
flag=False
safe=-1
for i in range(N-2):
    if "".join(S[i:i+3])=="ABC":
        ans+=1
        ans+=As


        S[i]="B"
        S[i+1]="C"
        S[i+2]="A"
        safe=i+1

    elif S[i]=="A":
        As+=1
    else:
        if i!=safe:
            As=0
    

print(ans)
Problem: p03018
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
ans = 0
tmp = 0
i = 0
while i < len(s):
    if s[i] == "A":
        tmp += 1
    elif s[i] == "B":
        if i+1 == len(s):
            break
        if s[i+1] == "C":
            ans += tmp
            i += 1
            tmp = 1
        else:
            tmp = 0
    i += 1
print(ans)

Failing test case input:
DBBCACDBCCBA>CDB@

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
s = input()
ans = 0
tmp = 0
i = 0
while i < len(s)-1:
    if s[i] == "A":
        tmp += 1
    elif s[i] == "B":
        if s[i+1] == "C":
            ans += tmp
            i += 1
        else:
            tmp = 0
    else:
        tmp = 0
    i += 1
print(ans)

Problem: p03018
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
import re
sys.setrecursionlimit(10 ** 7)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def SI(): return input()


def main():
    S = SI()
    ans = 0
    now = 0
    while(1):
        a = S.find("ABC")
        if a == -1:
            break
        ans += 1
        i = 1
        while(S[a-i] == 'A'):
            ans += 1
            i += 1
        S = S[a+3:]
        while(S[:2] == "BC"):
            ans += 1
            S = S[2:]
        S = "A" + S
        now = a + i

    print(ans)


main()


Failing test case input:
ACCAAABCAABCCBBBD

Expected output:
8


Actual output:
6


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


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def SI(): return input()


def main():
    S = SI()
    ans = 0
    S = S.replace("A", "0")
    S = S.replace("BC", "1")
    a = 0
    b = 0
    for s in S:
        if s == "0":
            a += 1
        elif s == "1":
            ans += a
            b = 1
        else:
            a = 0
    print(ans)


main()

Problem: p03018
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    s = list(input().rstrip())
    ans = 0
    cnt = 0
    for i in range(len(s)-2):
        if s[i] == "A":
            cnt += 1
        else:
            cnt = 0
        if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
            ans += cnt
            cnt = 0
            s[i+2] = "A"
    print(ans)

if __name__ == "__main__":
    main()

Failing test case input:
ACCAAABCAABCCBBBC

Expected output:
8


Actual output:
6


Fixed submission (verdict: Accepted):
def main():
    s = list(input().rstrip())
    ans = 0
    cnt = 0
    for i in range(len(s)-2):
        if s[i] == "A":
            cnt += 1
        else:
            cnt = 0
        if s[i] == "A" and s[i+1] == "B" and s[i+2] == "C":
            ans += cnt
            if cnt == 1:
                s[i+2] = "A"
                cnt = 0
            else:
                s[i+1] = "A"
                s[i+2] = "A"
                cnt -= 2
    print(ans)

if __name__ == "__main__":
    main()
Problem: p03018
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

WALL = 0
ACTIVATE = 1
CHANCE, BINGO = 2, 3

nBC = 0
score = 0
state = WALL
for c in reversed(S):
	if c == 'A':
		state = ACTIVATE
	elif c == 'B' and state == CHANCE:
		state = BINGO
	elif c == 'C':
		state = CHANCE
	else:
		state = WALL
	
	if state == WALL:
		nBC = 0
	elif state == ACTIVATE:
		score += nBC
	elif state == BINGO:
		nBC += 1

print(score)


Failing test case input:
ABCAACBCAABCCBBBC

Expected output:
3


Actual output:
9


Fixed submission (verdict: Accepted):
S = input()

WALL = 0
ACTIVATE = 1
CHANCE, BINGO = 2, 3

nBC = 0
score = 0
state = WALL
for c in reversed(S):
	if c == 'A' and (state == BINGO or state == ACTIVATE):
		state = ACTIVATE
	elif c == 'B' and state == CHANCE:
		state = BINGO
	elif c == 'C':
		if state == CHANCE:
			nBC = 0
		state = CHANCE
	else:
		state = WALL
	
	if state == WALL:
		nBC = 0
	elif state == ACTIVATE:
		score += nBC
	elif state == BINGO:
		nBC += 1

print(score)

Problem: p03018
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def agc034_b():
    s = str(input())
    n = len(s)
    if n < 3: return print(0)

    r = s[::-1]
    cb = 0
    ans = 0
    for i in range(1, n):
        if r[i] == 'A':
            ans += cb
        elif r[i] == 'B':
            if r[i-1] == 'C': cb += 1
            else: cb = 0
        else:
            if r[i-1] == 'C': cb = 0
            else: continue
    print(ans)

if __name__ == '__main__':
    agc034_b()

Failing test case input:
ACBAACBCCABCCBBBA

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
def agc034_b():
    s = str(input())
    n = len(s)
    if n < 3: return print(0)

    r = s[::-1]
    cb = 0
    ans = 0
    for i in range(1, n):
        if r[i] == 'A':
            if r[i-1] == 'C': cb = 0
            else: ans += cb
        elif r[i] == 'B':
            if r[i-1] == 'C': cb += 1
            else: cb = 0
        else:
            if r[i-1] == 'C': cb = 0
            else: continue
    print(ans)

if __name__ == '__main__':
    agc034_b()

Problem: p03018
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

WALL = 0
ACTIVATE = 1
CHANCE, BINGO = 2, 3

nBC = 0
score = 0
state = WALL
for c in reversed(S):
	if c == 'A' and state == BINGO:
		state = ACTIVATE
	elif c == 'B' and state == CHANCE:
		state = BINGO
	elif c == 'C':
		if state == CHANCE:
			nBC = 0
		state = CHANCE
	else:
		state = WALL
	
	if state == WALL:
		nBC = 0
	elif state == ACTIVATE:
		score += nBC
	elif state == BINGO:
		nBC += 1

print(score)


Failing test case input:
ADDB@BBCAABCCCBBD

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
S = input()

WALL = 0
ACTIVATE = 1
CHANCE, BINGO = 2, 3

nBC = 0
score = 0
state = WALL
for c in reversed(S):
	if c == 'A' and (state == BINGO or state == ACTIVATE):
		state = ACTIVATE
	elif c == 'B' and state == CHANCE:
		state = BINGO
	elif c == 'C':
		if state == CHANCE:
			nBC = 0
		state = CHANCE
	else:
		state = WALL
	
	if state == WALL:
		nBC = 0
	elif state == ACTIVATE:
		score += nBC
	elif state == BINGO:
		nBC += 1

print(score)
Problem: p03018
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s = input().rstrip()

concurrent_BC_cnt = 0
old1 = ""
cnt = 0
for tmp in (reversed(s)):
	if tmp == "A":
		cnt += concurrent_BC_cnt
		
	else:
		if tmp == "B" and old1 == "C":
			concurrent_BC_cnt += 1
		elif tmp == "C" and old1 == "B":
			pass
		else:
			concurrent_BC_cnt = 0
			
		old1=tmp
	
print(cnt)

Failing test case input:
ABCAACBCAABCCBBBC

Expected output:
3


Actual output:
7


Fixed submission (verdict: Accepted):
s = input().rstrip()

concurrent_BC_cnt = 0
old1 = ""
cnt = 0
for tmp in (reversed(s)):
	if tmp == "A":
		if old1 == "B":
			cnt += concurrent_BC_cnt
		else:
			concurrent_BC_cnt = 0
			old1 = "A"
		
	else:
		if tmp == "B" and old1 == "C":
			concurrent_BC_cnt += 1
		elif tmp == "C" and old1 == "B":
			pass
		else:
			concurrent_BC_cnt = 0
			
		old1=tmp
	
print(cnt)

Problem: p03018
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=list(input())

i=0
j=0
ans=0
z=[]
while i!=len(s)-2:
    try:
        if s[i]=="B" and s[i+1]=="C":
            z.append(1)
            i=i+2

        else:
            if s[i]=="A":
                z.append(2)
                i=i+1

            else:
                z.append(0)
                i=i+1

    except:
      break

ans=0
i=0
r1=0





while i!=len(z):
    if z[i]==2:
         r1=r1+1

    elif z[i]==1:
        ans=ans+r1

    else:
        r1 = 0


    i=i+1
print(ans)

Failing test case input:
DBAABC

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
s=list(input())

i=0
j=0
ans=0
z=[]
while i!=len(s)-1:
    try:
        if s[i]=="B" and s[i+1]=="C":
            z.append(1)
            i=i+2

        else:
            if s[i]=="A":
                z.append(2)
                i=i+1

            else:
                z.append(0)
                i=i+1

    except:
      break

ans=0
i=0
r1=0





while i!=len(z):
    if z[i]==2:
         r1=r1+1

    elif z[i]==1:
        ans=ans+r1

    else:
        r1 = 0


    i=i+1
print(ans)
Problem: p03018
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())

ans = 0
i = 0
while i < len(s) - 3:
    
    if s[i] == 'A':
        i += 1
        count = 1
        while i < len(s) - 1:
            if s[i] == 'A':
                count += 1
                i += 1
            else:
                if s[i] == 'B' and s[i+1] == 'C':
                    ans += count
                    s[i] = 'C'
                    s[i+1] = 'A'
                i += 1
                break
    else:
        i += 1

print(ans)

Failing test case input:
ACCAAABCAABCCBBBC

Expected output:
8


Actual output:
6


Fixed submission (verdict: Accepted):
s = list(input())

t = []

i = 0
while i < len(s) - 1:
    if s[i] == 'A':
        t.append('A')
        i += 1
    elif s[i] == 'B':
        if s[i+1] == 'C':
            t.append('D')
            i += 2
        else:
            t.append('B')
            i += 1
    else:
        t.append('C')
        i += 1

mode = 0
ans = 0
count = 0

for x in t:
    if mode == 0:
        if x == 'A':
            count = 1
            mode = 1
    else:
        if x == 'A':
            count += 1
        elif x == 'D':
            ans += count
        else:
            mode = 0

print(ans)

Problem: p03018
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
idx = 0
a_cnt = 0
cnt = 0
len_s = len(S)
while idx < len_s:
  if S[idx:idx+3] == 'ABC':
    cnt += 1 + a_cnt
    idx += 3
    a_cnt = 0
    bc_cnt = 0
    while idx < len(S):
      if S[idx:idx+2] == 'BC':
        bc_cnt += 1
        idx += 2
      else:
        break
    cnt += bc_cnt
  else:
    if S[idx] == 'A':
      a_cnt += 1
    idx += 1
print(cnt)

Failing test case input:
DBBBCCBAACBBABCCA

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
S = input()
idx = 0
a_cnt = 0
cnt = 0
len_s = len(S)
while idx < len_s:
  if S[idx:idx+3] == 'ABC':
    cnt += 1 + a_cnt
    idx += 3
    a_cnt += 1
    bc_cnt = 0
    while idx < len(S):
      if S[idx:idx+2] == 'BC':
        cnt += a_cnt
        idx += 2
      else:
        break
  else:
    if S[idx] == 'A':
      a_cnt += 1
    else:
      a_cnt = 0
    idx += 1
print(cnt)
Problem: p03018
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s=input()
ans=0
a=[0 for i in range(len(s))]
bc=[0 for i in range(len(s))]
if len(s)<3:
  print(0)
else:
  for i in range(len(s)):
    if s[i]=="A":
      a[i]=1
  for i in range(len(s)-1):
    if s[i]=="B" and s[i+1]=="C":
      bc[i]=1
  for i in range(len(s)-2,-1,-1):
    if bc[i-2]>0:
      bc[i-2]+=bc[i]
      bc[i]=0
  for i in range(len(s)-2):
    if a[i]>0 and bc[i+1]>0:
      a[i+2]=1
  for i in range(len(s)-1):
    if a[i+1]>0:
      a[i+1]+=a[i]
      a[i]=0
  
  for i in range(len(s)-2):
    if a[i]>0 and bc[i+1]>0:
      ans+=a[i]*bc[i+1]
  print(ans)
  

Failing test case input:
ACCAAABCAABCCBBBD

Expected output:
8


Actual output:
6


Fixed submission (verdict: Accepted):
s=input()
ans=0
a=[0 for i in range(len(s))]
bc=[0 for i in range(len(s))]
if len(s)<3:
  print(0)
else:
  for i in range(len(s)-2):
    if s[i]=="A":
      a[i]+=1
    if s[i+1]=="B" and s[i+2]=="C":
      a[i+2]+=a[i]
    if s[i+1]=="A":
      a[i+1]+=a[i]
      
  for i in range(len(s)-1):
    if s[i]=="B" and s[i+1]=="C":
      bc[i]=1
  
   
    
     
  
   
    
  
   
    
     
  
   
    
     
  
  for i in range(len(s)-2):
    if a[i]>0 and bc[i+1]>0:
      ans+=a[i]*bc[i+1]
  print(ans)

Problem: p03018
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s = list(input())
ans = 0
ls = len(s)
i = 0
ca = 0
while i < ls-2:
    if s[i:i+3] == ['A', 'B', 'C']:
        ans += 1 + ca
        s[i+2] = 'A'
        continue
    elif s[i] == 'A':
        ca += 1
    else:
        ca = 0
    i += 1

print(ans)


Failing test case input:
ACCAAABCAABCCBBBC

Expected output:
8


Actual output:
6


Fixed submission (verdict: Accepted):
s = list(input())
ans = 0
ls = len(s)
i = 0
ca = 0
while i < ls-2:
    if s[i:i+3] == ['A', 'B', 'C']:
        ans += 1 + ca
        
        s[i+2] = 'A'
        if ca >= 1:
            ca -= 2
            s[i+1] = 'A'
        else:
            ca = 0
        continue
    elif s[i] == 'A':
        ca += 1
    else:
        ca = 0
    i += 1

print(ans)
Problem: p03910
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve():
    N = int(input())
    
    s = sum([i for i in range(1, N+1)])
    for i in reversed(range(1, N+1)):
        if s - i <= N:
            return i
        s -= i
        
print(solve())

Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:
23


Fixed submission (verdict: Accepted):
def solve():
    N = int(input())
    score = 0
    for i in range(1, N+1):
        score += i
        if score >= N:
            break
    x = score - N
    res = list(range(1, x)) + list(range(x+1, i+1))
    return '\n'.join(map(str, res))
    
print(solve())

Problem: p03910
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
half = n
a = n-half

if n == 1:
    print(1)
    sys.exit()
if n == 2:
    print(2)
    sys.exit()

print(a)
print(half)
    

Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:
0
273


Fixed submission (verdict: Accepted):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

N = int(input())
k = 0
while k * (k+1) 
  k += 1
while N > 0:
  print(min(k, N))
  N -= min(k, N)
  k -= 1
Problem: p03910
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
now = n
for i in range(1,n+1):
  if now == i:
    print(i);break
  elif now - i <= i:continue
  else:
    now -= i
    print(i)

Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
42


Fixed submission (verdict: Accepted):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
now = n
for i in range(1,n+1):
  if now == i:
    key = -1
    top = i
    break
  elif now - i < 0:
    key = i - now
    top = i
    break
  else:
    now -= i
for i in range(1,top+1):
  if i != key:print(i)

Problem: p03910
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())
if N == 1:
    print(1)
    exit()
ans = 0
for i in range(1, N+1):
    ans += i
    if ans >= N:
        end = i
        break
res = ans - N
for i in range(1, end):
    if i != res:
        print(i)

Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22


Fixed submission (verdict: Accepted):

N = int(input())
if N == 1:
    print(1)
    exit()
ans = 0
for i in range(1, N+1):
    ans += i
    if ans >= N:
        end = i
        break
res = ans - N
for i in range(1, end+1):
    if i != res:
        print(i)

Problem: p03910
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())

W = [0]*(N+1)
W[1] = 1

for i in range(1, N+1):
    W[i] += W[i-1]
    if W[i] >= N:
        for j in range(1, i+1):
            if j != (W[i] - N):
                print(j)
            break

Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:

Fixed submission (verdict: Accepted):
N = int(input())

W = 0

for i in range(1, N+1):
    W += i
    if W >= N:
        for j in range(1, i+1):
            if j != (W - N):
                print(j)
        break

Problem: p03910
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
ans=0
for i in range(1,N+1):
    if ans+i==N:
        print(i)
        break
    if N-(ans+i)>=i+1:
        print(i)
        ans+=i
    else:
        continue


Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
42


Fixed submission (verdict: Accepted):
N=int(input())
ans=0
reject=0
A=[]
for i in range(1,N+1):
    ans+=i
    if ans>=N:
        reject=ans-N
        for j in range(1,i+1):
            if j!=reject:
                print(j)
        break
Problem: p03910
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
n = int(stdin.readline().rstrip())
point = 0
for i in range(1,n+1):
    point += i
    if point >= n:
        print(i)
        if n-i != 0:
            print(n-i)
        break

Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:
23
250


Fixed submission (verdict: Accepted):
from sys import stdin
n = int(stdin.readline().rstrip())
point = 0
for i in range(1,n+1):
    point += i
    if point >= n:
        sa = point-n
        for k in [j for j in range(1,i+1) if j != sa]:print(k)
        break

Problem: p03910
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
ans = []

index = 1
while(True): 
  ans.append(index)
  if sum(ans) == N:
    break
  if (N-sum(ans)) < index:
    ans.pop(-1)
  index+=1
  
for i in ans:
  print(i)

Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
42


Fixed submission (verdict: Accepted):
N = int(input())
s = 0
ans = []
for i in range(1, N+1):
  ans.append(i)
  s += i
  if s == N:
    break
  elif s > N:
    ans.pop(s-N-1)
    break
  
for i in ans:
  print(i)

Problem: p03910
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
sum_i = 0
for i in range(n):
    i += 1
    
    if n - (sum_i + i) >= i:
        sum_i += i
        print(i)
    else:
        print(n - sum_i)
        break

Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
42


Fixed submission (verdict: Accepted):
n = int(input())
sum_i = 0  
i = 0
while sum_i < n:
    i += 1
    sum_i += i
for ans in range(1, i+1):
    if ans == sum_i - n:
        continue
    print(ans)

Problem: p03910
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve(n):
    score = 0
    res = []
    for p in range(1, n+1):
        res.append(p)
        score += p
        if score >= n:
            break
    return "\n".join(map(str, res))

n = int(input())
print(solve(n))

Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Fixed submission (verdict: Accepted):
def solve(n):
    score = 0
    for p in range(1, n+1):
        score += p
        if score >= n:
            break
    x = score - n
    res = list(range(1,x)) + list(range(x+1,p+1))
    return "\n".join(map(str, res))

n = int(input())
print(solve(n))
Problem: p03910
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    N = int(input())
    if N == 1 or N == 2:
        return print(N)
    ans = set()

    for i in range(1, N+1):
        N -= i
        if N in ans or N <= 2:
            N += i
            ans.add(N)
            break
        ans.add(i)
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()


Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
42


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    ans = []
    ans_sum = 0
    for i in range(1, N+1):
        ans_sum += i
        ans.append(i)
        if N <= ans_sum:
            dis = ans_sum - N
            for a in ans:
                if a != dis:
                    print(a)
            return


if __name__ == '__main__':
    main()

Problem: p03910
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = []
tmp = 0
for i in range(1,n+1):
    if tmp + i <= n:
        ans.append(i)
        tmp += i
    else:
        ans.pop()
        ans.append(i)
        break
for i in ans:
    print(i)


Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
23


Fixed submission (verdict: Accepted):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = []
tmp = 0
for i in range(1,n+1):
    if tmp + i <= n:
        ans.append(i)
        tmp += i
    else:
        tmp += i
        ans.append(i)
        ans.remove(tmp - n)
        break
for i in ans:
    print(i)
Problem: p03910
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = []
tmp = 0
for i in range(1,n+1):
    if tmp + i <= n:
        ans.append(i)
        tmp += i
    else:
        ans.pop()
        ans.append(n - (tmp-(i-1)))
        break
for i in ans:
    print(i)


Failing test case input:
273

Expected output:
1
2
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


Actual output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
42


Fixed submission (verdict: Accepted):



import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = []
tmp = 0
for i in range(1,n+1):
    if tmp + i <= n:
        ans.append(i)
        tmp += i
    else:
        tmp += i
        ans.append(i)
        ans.remove(tmp - n)
        break
for i in ans:
    print(i)
Problem: p02574
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
L = 10**6 + 1

N = int(input())
A = list(map(int, input().split()))
memo = [0] * L
flag = 0 

for a in A:
    memo[a] = 1

for i in range(2, L):
    if sum(memo[i::i]) > 1:
        flag = 1
        break

g = 0
for i in range(N):
    g = math.gcd(g, A[i])

if flag == 0:
    answer = 'pairwise coprime'
elif flag == 1 and g == 1:
    answer = 'setwise coprime'
else:
    answer = 'not coprime'

print(answer)

Failing test case input:
3
4 4 1

Expected output:
setwise coprime


Actual output:
pairwise coprime


Fixed submission (verdict: Accepted):
import math
L = 10**6 + 1

N = int(input())
A = list(map(int, input().split()))
memo = [0] * L
flag = 0 

for a in A:
    memo[a] += 1

for i in range(2, L):
    if sum(memo[i::i]) > 1:
        flag = 1
        break

g = 0
for i in range(N):
    g = math.gcd(g, A[i])

if flag == 0:
    answer = 'pairwise coprime'
elif flag == 1 and g == 1:
    answer = 'setwise coprime'
else:
    answer = 'not coprime'

print(answer)

Problem: p02574
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

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

flag = 0 

for i in range(N-1): 
    if math.gcd(A[i], A[i+1]) != 1:
        flag = 1 
        break

g = 0
for i in range(N):
    g = math.gcd(g, A[i])

if flag == 0:
    answer = 'pairwise coprime'
elif flag == 1 and g == 1:
    answer = 'setwise coprime'
else:
    answer = 'not coprime'

print(answer)

Failing test case input:
3
4 1 4

Expected output:
setwise coprime


Actual output:
pairwise coprime


Fixed submission (verdict: Accepted):
import math
L = 10**6 + 1

N = int(input())
A = list(map(int, input().split()))
memo = [0] * L
flag = 0 

for a in A:
    memo[a] += 1

for i in range(2, L):
    if sum(memo[i::i]) > 1:
        flag = 1
        break

g = 0
for i in range(N):
    g = math.gcd(g, A[i])

if flag == 0:
    answer = 'pairwise coprime'
elif flag == 1 and g == 1:
    answer = 'setwise coprime'
else:
    answer = 'not coprime'

print(answer)

Problem: p02574
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

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

flag = 0 

for i in range(N-1): 
    if math.gcd(A[i], A[i-1]) != 1:
        flag = 1 
        break

g = 0
for i in range(N):
    g = math.gcd(g, A[i])

if flag == 0:
    answer = 'pairwise coprime'
elif flag == 1 and g == 1:
    answer = 'setwise coprime'
else:
    answer = 'not coprime'

print(answer)


Failing test case input:
3
1 3 12

Expected output:
setwise coprime


Actual output:
pairwise coprime


Fixed submission (verdict: Accepted):
import math
L = 10**6 + 1

N = int(input())
A = list(map(int, input().split()))
memo = [0] * L
flag = 0 

for a in A:
    memo[a] += 1

for i in range(2, L):
    if sum(memo[i::i]) > 1:
        flag = 1
        break

g = 0
for i in range(N):
    g = math.gcd(g, A[i])

if flag == 0:
    answer = 'pairwise coprime'
elif flag == 1 and g == 1:
    answer = 'setwise coprime'
else:
    answer = 'not coprime'

print(answer)
Problem: p02574
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
from math import gcd

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

b = gcd(a[0], a[1])
for i in range(2, n):
    b = gcd(b, a[i])
if b != 1:
    print('not coprime')
else:
    
    c = set()
    for j in a:
        for i in range(2, int(j**0.5)+1):
            while n%i == 0:
                if i in c:
                    print('setwise coprime')
                    sys.exit()
                c.add(i)
                n 
            if n != 1:
                c.add(n)
    print('pairwise coprime')


Failing test case input:
3
1 1 24

Expected output:
pairwise coprime


Actual output:
setwise coprime


Fixed submission (verdict: Accepted):
import sys
from math import gcd

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

b = gcd(a[0], a[1])
for i in range(2, n):
    b = gcd(b, a[i])
if b != 1:
    print('not coprime')
else:
    c = set()
    num = max(a)
    m = 1000000
    vals = [0]*(m+1)

    for i in range(2, m):
        if vals[i] != 0:
            continue
        j = 1
        while True:
            t = i*j
            if t > m:
                break
            if vals[t] == 0:
                vals[t] = i
            j += 1
    d = dict()
    for i in a:
        p = i
        while p != 1:
            if p in d:
                print("setwise coprime")
                sys.exit()
            d[p] = 1
            p = int(p/vals[p])
    print("pairwise coprime")

Problem: p02574
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))

import math 

ans = a[0]
for i in range(1, n):
    ans = math .gcd(ans, a[i])

if ans!=1:
    
    print("not coprime")
    exit()
else:
    checked=[0]*(int(max(a)**(0.5))+100)

    for item in a:

        for j in range(2,int(item**0.5)+1):
            if item%j==0 and j*j<=item:
                if checked[j]==0:
                    checked[j]+=1
                else:
                    
                    print("setwise coprime")
                    exit()
print("pairwise coprime")





Failing test case input:
3
8 5 15

Expected output:
setwise coprime


Actual output:
pairwise coprime


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

import math 

ans = a[0]
for i in range(1, n):
    ans = math .gcd(ans, a[i])

if ans!=1:
    
    print("not coprime")
    exit()
else:
    checked=[0]*(int(max(a))+1)
    
    for item in a:
        for j in range(1,int(item**0.5)+1):
            if item%j==0 and j*j<=item:
                if checked[j]==0:
                    if j!=1:
                        checked[j]+=1
                    
                    if j*j!=item:
                        if checked[item
                            checked[item
                        else:
                            
                            print("setwise coprime")
                            exit() 
                else:
                    
                    print("setwise coprime")
                    exit()
print("pairwise coprime")
Problem: p02574
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from math import gcd

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

h = True
checker = [0 for _i in range(10**6+1)]
for i in a:
    checker[i] += 1
    if sum(checker[i::i]) > 1:
        h = False
        break

if h == True:
    print('pairwise coprime')
else:
    r = a[0]
    for i in a:
        r = gcd(r, i)
    if r == 1:
        print('setwise coprime')
    else:
        print('not coprime')

Failing test case input:
3
5 4 1

Expected output:
pairwise coprime


Actual output:
setwise coprime


Fixed submission (verdict: Accepted):
from math import gcd

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

checker = [0 for _i in range(10**6+1)]
for i in a:
    checker[i] += 1

if all(sum(checker[i::i])<2 for i in range(2,10**6+1)):
    print('pairwise coprime')
else:
    r = a[0]
    for i in a:
        r = gcd(r, i)
    if r == 1:
        print('setwise coprime')
    else:
        print('not coprime')

Problem: p02574
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
import copy
from functools import reduce

n = int(input())
a_list = list(map(int, input().split()))

for i in range(2, a_list[n - 2] + 1):
    damy = copy.deepcopy(a_list)
    damy = list(map(lambda x: x % i, damy))
    damy.sort()
    if damy[0] == 0 and damy[1] == 0:
        if reduce(math.gcd, a_list) == 1:
            print("setwise coprime")
            exit()
        else:
            print("not coprime")
            exit()
print("pairwise coprime")


Failing test case input:
3
6 1 6

Expected output:
setwise coprime


Actual output:
pairwise coprime


Fixed submission (verdict: Accepted):
import math
from functools import reduce
L = 10**6 + 1
n = int(input())
a_list = list(map(int, input().split()))
memo = [0] * L

for a in a_list:
    memo[a] += 1

for i in range(2, L):
    if sum(memo[i::i]) > 1:
        if reduce(math.gcd, a_list) == 1:
            print("setwise coprime")
            exit()
        else:
            print("not coprime")
            exit()

print("pairwise coprime")
Problem: p02574
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from math import gcd
N = int(input())
A = list(map(int, input().split()))
max_A = max(A)
happend_numbers = [False]*(max_A+1)  
for a in A:
    happend_numbers[a] = True

for i in range(2, max_A+1):
    true_count = 0
    for j in range(i, max_A+1, i):
        if happend_numbers[j]:
            true_count += 1
    if true_count >= 2:
        break
else:
    print("pairwise coprime")
    exit()

now = A[0]
for a in A[1:]:
    now = gcd(a, now)
if now == 1:
    print("setwise coprime")
    exit()
print("not coprime")


Failing test case input:
3
6 1 6

Expected output:
setwise coprime


Actual output:
pairwise coprime


Fixed submission (verdict: Accepted):
from math import gcd
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
max_A = max(A)

happend_numbers = defaultdict(int)
for a in A:
    happend_numbers[a] += 1
    

for i in range(2, max_A+1):
    true_count = 0
    for j in range(i, max_A+1, i):
        
        true_count += happend_numbers[j]
    if true_count >= 2:
        break
else:
    print("pairwise coprime")
    exit()

now = A[0]
for a in A[1:]:
    now = gcd(a, now)
if now == 1:
    print("setwise coprime")
    exit()
print("not coprime")

Problem: p02574
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from math import gcd
n=int(input())
a=list(map(int,input().split()))
a.sort()
lis=[False]*(10**6+1)
ok=True
s=set(a)
for num in range(2,10**6+1):
    if lis[num]:
        continue
    cnt=0
    for i in range(num,10**6+1,num):
        lis[i]=True
        if i in s:
            cnt+=1
    if cnt>=2:
        ok=False
if ok:
    print("pairwise coprime")
else:
    g=a[0]
    for num in a:
        g=gcd(g,num)
    if g==1:
        print("setwise coprime")
    else:
        print("not coprime")

Failing test case input:
3
4 1 4

Expected output:
setwise coprime


Actual output:
pairwise coprime


Fixed submission (verdict: Accepted):
from math import gcd
n=int(input())
a=list(map(int,input().split()))
a.sort()
lis=[False]*(10**6+1)
ok=True
d=dict()
for num in a:
    if num in d:
        d[num]+=1
    else:
        d[num]=1
for num in range(2,10**6+1):
    if lis[num]:
        continue
    cnt=0
    for i in range(num,10**6+1,num):
        lis[i]=True
        if i in d:
            cnt+=d[i]
    if cnt>=2:
        ok=False
if ok:
    print("pairwise coprime")
else:
    g=a[0]
    for num in a:
        g=gcd(g,num)
    if g==1:
        print("setwise coprime")
    else:
        print("not coprime")
Problem: p02574
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from math import gcd

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

checker = [0 for _i in range(10**6+1)]
for i in a:
    checker[i] += 1

if any(sum(checker[i::i])>1 for i in range(2, 10**6+1)):
    print('pairwise coprime')
else:
    r = a[0]
    for i in a:
        r = gcd(r, i)
    if r == 1:
        print('setwise coprime')
    else:
        print('not coprime')

Failing test case input:
3
5 5 15

Expected output:
not coprime


Actual output:
pairwise coprime


Fixed submission (verdict: Accepted):
from math import gcd

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

checker = [0 for _i in range(10**6+1)]
for i in a:
    checker[i] += 1

if all(sum(checker[i::i])<2 for i in range(2,10**6+1)):
    print('pairwise coprime')
else:
    r = a[0]
    for i in a:
        r = gcd(r, i)
    if r == 1:
        print('setwise coprime')
    else:
        print('not coprime')

Problem: p02574
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from math import gcd
flag=0
N=int(input())
A=list(map(int,input().split()))
Max=max(A)
a=[0]*(Max+1)
for i in A:
    a[i]+=1
s=2
while s*s<=Max:
    if sum(a[s::s])>=2:
        flag=1
        break
    s+=1
if flag==0:
    print('pairwise coprime')
else:
    r=A[0]
    for i in A:
        r=gcd(r,i)
    if r==1:
        print('setwise coprime')
    else:
        print("not coprime")

Failing test case input:
3
17 10 15

Expected output:
setwise coprime


Actual output:
pairwise coprime


Fixed submission (verdict: Accepted):
from math import gcd
flag=0
N=int(input())
A=list(map(int,input().split()))
Max=max(A)
a=[0]*(Max+1)
for i in A:
    a[i]+=1
for i in range(2,Max+1):
    if sum(a[i::i])>=2:
        flag=1
        break
if flag==0:
    print('pairwise coprime')
else:
    r=A[0]
    for i in A:
        r=gcd(r,i)
    if r==1:
        print('setwise coprime')
    else:
        print("not coprime")