Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
s=set(a)

sei=[]
cho=[]



for i in s:
    x= a.count(i)
    
    if x >= 4:
        sei.append(i)
    elif x >= 2:
        cho.append(i)

cho2=sorted(cho,reverse=True)


        
if sei==[] and len(cho)<2:        
    print(0)
    exit()
else:
    print(max(max(sei)**2,cho2[0]*cho2[1],max(sei)*cho2[0]))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)


count=0
ans=[]
flag=0
for i in range(1,n):
    if a[i]==a[i-1] and flag==1:
        flag=0


    elif a[i]==a[i-1] and flag==0:
        count += 1
        ans.append(a[i])
        flag=1

    elif a[i] != a[i-1]:
        flag=0

    if count==2:
        print(ans[0]*ans[1])
        exit()


print(0)

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

sei=[]
cho=[]



for i in s:
    x= a.count(i)
    
    if x >= 4:
        sei.append(i)
    elif x >= 2:
        cho.append(i)

cho2=sorted(cho,reverse=True)
        
if sei==[] and len(cho)<2:        
    print(0)
    exit()
else:
    print(max(max(sei)**2,cho2[0]*cho2[1],max(sei)*cho2[0]))



Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a=sorted(a,reverse=True)


count=0
ans=[]
flag=0
for i in range(1,n):
    if a[i]==a[i-1] and flag==1:
        flag=0


    elif a[i]==a[i-1] and flag==0:
        count += 1
        ans.append(a[i])
        flag=1

    elif a[i] != a[i-1]:
        flag=0

    if count==2:
        print(ans[0]*ans[1])
        exit()


print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
start=[]
end=[]
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        start.append(b)
    elif b==N:
        end.append(a)

for i in start:
    if i in end:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Fixed submission:
N,M=map(int,input().split())
start=[]
end=[]
for i in range(M):
    a,b=map(int,input().split())
    if a==1:
        start.append(b)
    elif b==N:
        end.append(a)

startset=set(start)
endset=set(end)
if startset & endset:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
for i in a:
    if i%2==0:
        k +=1
m=n-k

ans_x=ans_y=0

def cbn(b,c):
    z=1
    for i in range(2,b+1):
        z *= i
    for i in range(2,c+1):
        z //= i
    for i in range(2,b-c+1):
        z //= i
    return(z)


if p==0:

    for i in range(k+1):
        ans_x += cbn(k,i)
    for i in range(0,m+1,2):
        ans_y += cbn(m,i)

    print(ans_x * ans_y)

else:

    for i in range(k+1):
        ans_x += cbn(k,i)
    for i in range(1,m+1,2):
        ans_y += cbn(m,i)

    print(ans_x * ans_y) 

Fixed submission:
n,p=map(int,input().split())
a=list(map(int,input().split()))
k=m=0
for i in a:
    if i%2==0:
        k +=1
m=n-k

ans_x=ans_y=0

def cbn(b,c):
    z=1
    for i in range(2,b+1):
        z *= i
    for i in range(2,c+1):
        z //= i
    for i in range(2,b-c+1):
        z //= i
    return(z)


if p==0:

    for i in range(k+1):
        ans_x += cbn(k,i)
    for i in range(0,m+1,2):
        ans_y += cbn(m,i)

    print(ans_x * ans_y)

else:

    for i in range(k+1):
        ans_x += cbn(k,i)
    for i in range(1,m+1,2):
        ans_y += cbn(m,i)

    print(ans_x * ans_y)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[]

for i in range(n):

    if n-i*2-1 > 0:
        b.append(a[n-i*2-1])
    else:
        k=abs(n-i*2)
        b.append(a[k])


print(*b)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]

if n%2==0:

    for i in range(n):

        if n-i*2-1 > 0:
            b.append(a[n-i*2-1])
        else:
            k=abs(n-i*2)
            b.append(a[k])

else:
    
    for i in range(n):

        if n-i*2-1 >= 0:
            b.append(a[n-i*2-1])
        else:
            k=abs(n-i*2-1)
            b.append(a[k-1])

print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]

if n%2==1:
    for i in range(n):
        if i%2==1:
            b.append(a[i])
        else:
            b.insert(0,a[i])

else:
    for i in range(n):
        if i%2==0:
            b.append(a[i])
        else:
            b.insert(0,a[i])

print(*b)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]

if n%2==0:

    for i in range(n):

        if n-i*2-1 > 0:
            b.append(a[n-i*2-1])
        else:
            k=abs(n-i*2)
            b.append(a[k])

else:
    
    for i in range(n):

        if n-i*2-1 >= 0:
            b.append(a[n-i*2-1])
        else:
            k=abs(n-i*2-1)
            b.append(a[k-1])

print(*b)
Buggy python submission (verdict: Time Limit Exceeded):
mode=1000000007

def factorial(x):
    ans=1
    for i in range(2,x+1):
        ans *= i % mode
    return ans


n,m=map(int,input().split())

if n==m:
    print(2*factorial(n)**2 % mode)
elif abs(n-m)==1:
    print(factorial(n)*factorial(m) % mode)
else:
    print(0)


Fixed submission:
import math
mode=1000000007


n,m=map(int,input().split())

if n==m:
    ans=math.factorial(n) % mode
    print(2*ans*ans % mode)
elif abs(n-m)==1:
    ans_n=math.factorial(n) % mode
    ans_m=math.factorial(m) % mode
    print(ans_n*ans_m % mode)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c=map(int,input().split())
g = math.gcd(a,b)
if c % g ==0 :
    print('YES')
else:
    print('NO')


Fixed submission:
import fractions
a,b,c=map(int,input().split())
g = fractions.gcd(a,b)
if c % g ==0 :
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
b=sorted(a)
ans1=sum(b[N:2*N])

ans2=0
for i in range(N):
    ans2 += b[i*3+1]

ans3=0
for i in range(N):
    ans3 += b[i*2+4]

print(max(ans1,ans2,ans3))

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
b=sorted(a)

ans3=0
for i in range(N):
    ans3 += b[i*2+N]

print(ans3)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

      
if n%2==0:
    for i in range(1,n,2):
        if a.count(i) != 2:
            print(0)
            break
    else:
        print(2**(n//2) % (10**9+7))

if n%2==1:
    if a.count(0)!=1:
            print(0)
            exit()        
    for i in range(2,n,2):
        if a.count(i) != 2:
            print(0)
            break
    else:
        print(2**((n-1)//2) % (10**9+7))


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
if n%2==1:
    b=b[1:]

if n%2==0:
    for i in range(n):
        if b[i] != (i//2)*2+1:
            print(0)
            exit()
    else:
        print(2**(n//2) % (10**9+7))

if n%2==1:
    for i in range(n-1):
        if b[i] != (i//2)*2+2:
            print(0)
            exit()
    else:
        print(2**(n//2) % (10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
S=str(input())
ans=0
while S.find('ST')!= -1:
    S=S.replace('ST','')

print(len(S))

Fixed submission:
S=list(str(input()))
ans=[]
for i in S:
    if i=='S':
        ans.append(i)
    elif i=='T' and len(ans)==0:
        ans.append(i)
    elif i=='T' and ans[-1]=='T':
        ans.append(i)
    elif i=='T' and ans[-1]=='S':
        del ans[-1]
print(len(ans))

Buggy python submission (verdict: Time Limit Exceeded):
S=str(input())
ans=0
while S.find('ST')!= -1:
    S=S.replace('ST','')

print(len(S))

Fixed submission:
S=list(str(input()))
ans=[]
for i in S:
    if i=='S':
        ans.append(i)
    elif i=='T' and len(ans)==0:
        ans.append(i)
    elif i=='T' and ans[-1]=='T':
        ans.append(i)
    elif i=='T' and ans[-1]=='S':
        del ans[-1]
print(len(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
s=str(input())
m=len(s)
for i in range(m-1):
    for j in range(i+1,m):
        target =s[i:j+1]
        c=collections.Counter(target)
        mc=c.most_common()
        if mc[0][1]>(j-i+1)//2:
            print(i+1,j+1)
            exit()
                
print('-1 -1')

Fixed submission:
s=str(input())
L=len(s)
if L==1:
    print('-1 -1')
    exit()
elif L==2 and s[0]==s[1]:
    print('1 2')
    exit()
elif L==2 and s[0]!=s[1]:
    print('-1 -1')
    exit()
    


for i in range(L-1):
    if s[i]==s[i+1] and i+1==L-1:
        print(i,i+2)
        exit()
    elif s[i]==s[i+1] and i+1<L-1:
        print(i+1,i+3)
        exit()
        
for i in range(L-2):
    if s[i]==s[i+2]:
        print(i+1,i+3)
        exit()
 
print('-1 -1')
Buggy python submission (verdict: Time Limit Exceeded):
a=list(map(int,input().split()))
if a.count(5)==2 and a.count(7)==1:
    print('YES')
else:
    print('NO')


Fixed submission:
a=list(map(str,input().split()))
if a.count('5')==2 and a.count('7')==1:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
import scipy.misc as scm
def combi(p,q):
    return scm.comb(p,q,1)

ans=0
n=int(input())
k=[]
for i in range(n):
    a,b=map(int,input().split())
    k.append([a,b])

for i in range(n-1):
    for j in range(i+1,n):
        p=k[i][0]+k[i][1]+k[j][0]+k[j][1]
        q=k[i][0]+k[j][0]
        ans += combi(p,q) % (10**9+7)


ans = ans % (10**9+7)
print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
ans=0
for i in range(0,n*2,2):
    ans += min(b[i],b[i+1])
print(ans)
Buggy python submission (verdict: Runtime Error):
(n,m),*a=[map(int,t.split())for t in open(0)]
p=[-1]*-~n
for a in a:
 b,a=sorted(map(r:=lambda x:x*(p[x]<0)or r(p[x]),a),key=p.__getitem__)
 if a-b:p[a]+=p[b];p[b]=a
print(sum(i<0for i in p)-2)

Fixed submission:
code = r"""
# distutils: language=c++
# distutils: include_dirs=/opt/ac-library
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/dsu>" namespace "atcoder":
    cdef cppclass dsu:
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
        vector[vector[int]] groups()
from libc.stdio cimport getchar, printf
cdef inline int read() nogil:
    cdef int b, c = 0
    while 1:
        b = getchar() - 48
        if b < 0: return c
        c = c * 10 + b
cdef int n = read(), i
cdef dsu *u = new dsu(n)
for i in range(read()): u.merge(read() - 1, read() - 1)
printf('%lu\n', u.groups().size() - 1)
"""
import os, sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Buggy python submission (verdict: Runtime Error):
(n,m),*a=[map(int,t.split())for t in open(0)]
p=[-1]*-~n
for a in a:
 a,b=map(r:=lambda x:x*(p[x]<0)or r(p[x]),a)
 if a-b:p[a]+=p[b];p[b]=a
print(sum(i<0for i in p)-2)

Fixed submission:
code = r"""
# distutils: language=c++
# distutils: include_dirs=/opt/ac-library
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/dsu>" namespace "atcoder":
    cdef cppclass dsu:
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
        vector[vector[int]] groups()
from libc.stdio cimport getchar, printf
cdef inline int read() nogil:
    cdef int b, c = 0
    while 1:
        b = getchar() - 48
        if b < 0: return c
        c = c * 10 + b
cdef int n = read(), i
cdef dsu *u = new dsu(n)
for i in range(read()): u.merge(read() - 1, read() - 1)
printf('%lu\n', u.groups().size() - 1)
"""
import os, sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve
Buggy python submission (verdict: Runtime Error):
print('NYoe s'[[*'000']in[eval(eval(t.replace(*' -')))for t in open(0)]::2])

Fixed submission:
_,*d=[{*t.split()}for t in open(0)]
print('YNeos'[all(max(map(len,d[i:i+3]))>1for i in range(len(d)-2))::2])
Buggy python submission (verdict: Time Limit Exceeded):
(n,_),*s=[[*map(int,t.split())]for t in open(0)]
d=[1,-1]+[0]*2*n
for i in range(n):
  d[i]+=d[i-1]
  for l,r in s:
    d[i+l]+=d[i]
    d[i-~r]-=d[i]
print(d[n-1]%998244353)

Fixed submission:
M=998244353
class BIT:
    def __init__(self,n):
        self.size=n
        self.tree=[0]*-~n
    def sum(self,i):
        s=0
        while i:
            s=(s+self.tree[i])%M
            i-=i&-i
        return s
    def add(self,i,x):
        while i<=self.size:
            self.tree[i]=(self.tree[i]+x)%M
            i+=i&-i
(n,k),*s=[[*map(int,t.split())]for t in open(0)]
bit=BIT(n+5)
bit.add(1,1)
bit.add(2,-1)
for i in range(1,n):
    p=bit.sum(i)
    for l,r in s:
        l+=i
        r+=i
        if l>n:l=n+1
        if r>n:r=n+1
        bit.add(l,p)
        bit.add(r+1,-p)
print(bit.sum(n))

Buggy python submission (verdict: Time Limit Exceeded):
(n,_),*s=[[*map(int,t.split())]for t in open(0)]
d=[1,-1]+[0]*2*n
for i in range(n):
  d[i]+=d[i-1]
  for l,r in s:
    d[i+l]+=d[i]
    d[i-~r]-=d[i]
print(d[n-1]%998244353)

Fixed submission:
M=998244353
class BIT:
    def __init__(self,n):
        self.size=n
        self.tree=[0]*-~n
    def sum(self,i):
        s=0
        while i:
            s=(s+self.tree[i])%M
            i-=i&-i
        return s
    def add(self,i,x):
        while i<=self.size:
            self.tree[i]=(self.tree[i]+x)%M
            i+=i&-i
(n,k),*s=[[*map(int,t.split())]for t in open(0)]
bit=BIT(n+5)
bit.add(1,1)
bit.add(2,-1)
for i in range(1,n):
    p=bit.sum(i)
    for l,r in s:
        l+=i
        r+=i
        if l>n:l=n+1
        if r>n:r=n+1
        bit.add(l,p)
        bit.add(r+1,-p)
print(bit.sum(n))
Buggy python submission (verdict: Runtime Error):
a,b,c=1,0,0
exec('a,b,c=b,c,a+c;'*int(input()))
print(a%(1e9+7))

Fixed submission:
from functools import*
M=10**9+7
@lru_cache(None)
def f(s):
    if s<3:return 0
    c=1
    for i in range(s-2):
        c+=f(i)
    return(sum(map(f,range(s-2)))+1)%M
print(f(int(input())))
Buggy python submission (verdict: Runtime Error):
a,b=[],
for z in[*open(0)][1:]:x,y=map(int,z.split());a+=x+y,;b+=x-y,
print(max(abs(max(a)-min(a)),abs(max(b)-min(b))))

Fixed submission:
n,*z=map(int,open(0).read().split())
a,b=[],[]
for x,y in zip(*[iter(z)]*2):
    a+=x+y,
    b+=x-y,
print(max(abs(max(a)-min(a)),abs(max(b)-min(b))))
Buggy python submission (verdict: Runtime Error):
code = r"""
# distutils: language=c++
# distutils: include_dirs=opt/atcoder-stl
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/dsu>" namespace "atcoder" nogil:
    cdef cppclass dsu:
        dsu(int n)
        int merge(int a, int b)
        bool same(int a, int b)
        int leader(int a)
        int size(int a)
        vector[vector[int]] groups()
from cython.parallel cimport prange
from libc.stdio cimport getchar, putchar
cdef inline int read() nogil:
    cdef int b, c = 0
    while 1:
        b = getchar() - 48
        if b < 0: break
        c = c * 10 + b
    return c
cdef int i
cdef dsu *d = new dsu(read())
for i in prange(read(), nogil=1):
    if read():
        if d.same(read(), read()): putchar(49)
        else: putchar(48)
        putchar(10)
    else: d.merge(read(), read())
"""
import os, sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('solve.pyx', 'w').write(code)
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Fixed submission:
p=[-1]*8**6
for q in[*open(0)][1:]:
 q,*x=map(int,q.split());a,b=sorted(map(f:=lambda x:f(p[x])if~p[x]<0else x,x))
 if q:print(+(a==b))
 elif a<b:p[b]=a
Buggy python submission (verdict: Time Limit Exceeded):
def f(i,x):
  while i<=n:
    b[i]+=x
    i+=i&-i
def g(i):
  s=0
  while i:
    s+=b[i]
    i-=i&-i
  return s
(n,q),a,*t=[map(int,t.split())for t in open(0)]
b=[0]*-~n
*map(f,range(1,n+1),a),
for q,l,r in t:
  if q:print(g(r)-g(l))
  else:f(l+1,r)

Fixed submission:
def f(i,x):
  while i<=n:
    b[i]+=x
    i+=i&-i
def g(i):
  s=0
  while i:
    s+=b[i]
    i-=i&-i
  return s
(n,q),a,*t=[map(int,t.split())for t in open(0)]
b=[0]*-~n
*map(f,range(1,n+1),a),
for q,l,r in t:
  if q:print(g(r)-g(l))
  else:f(l+1,r)
Buggy python submission (verdict: Runtime Error):
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${TYO>cuR480@qAH2g<Sknro9VRsPM>-Bp2oMbdN;6g4ub)FGU-bp-_x$|gq%wU6t>WT*wMOY0gzARgSm<PTl{O42M-acZ>GgR)gKaC@nKT&GwVX(kN~!u8ucZ|Y8b(B=Z50NhloinL<u!3pzz_z0QZz6)r3^d(FK|_Vvacc{$MMog(mIMk_qA%XFaU}f;tT}jkofYgQLTh@BDvrMPL85@DXWT*4|sdefE$V53*yuSSxFN(66Zu54;pEIj0Umt)k-X-adrW>{z!kgU_m32?B0nU8teJJ*Jbf$fUB%#Xa*evWbUMjfo0CYP1$BMPdnFcOFr$kY1JE0q&D4MM1o^;p2n+H;kN0%y<G_x??~H8ckBt`JBapy@RS2z&0Fv3lRmuIfi5g*;$zvl;E!eJz;4T<{4pQ(_Xsb%`n(^%9vv^Ycp5Is*%R6LGR8Cv{L_vO&*hgs(2dYZ{{h3n*31")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Fixed submission:
from networkx import*
print(max(*map(len,connected_components(Graph([*map(str.split,open(0))][1:]))),1,1))
Buggy python submission (verdict: Runtime Error):
n=int(input())
1/(n>3)

Fixed submission:
n,*a=map(int,open(0).read().split())
m=6**8
c=[0]*m
p=[1,1]+c[:]
for i in range(m):
  if p[i]<1:
    for j in range(i,m,i):p[j]=i
for a in a:
  s={a}
  while a!=p[a]:
    s|={p[a]}
    a//=p[a]
    s|={a}
  for i in s:c[i]+=1
print(('not','psaeitr'[max(c[2:])>1::2]+'wise')[max(c[2:])<n],'coprime')

Buggy python submission (verdict: Runtime Error):
c=[m:=0]*6**8
n,a=open(0)
for a in a.split():c[int(a)]+=1
print(('not','psaeitr'[any((m:=max(m,sum(c[i::i])))>1for i in range(2,6**8))::2]+'wise')[m<int(n)],'coprime')

print(('not','psaeitr'[any(c:=[max(0,sum(c[i::i])-1)for i in range(2,6**8)])::2]+'wise')[max(c)+1<int(n)],'coprime')

1/(max(c)+1==m)

Fixed submission:
n,*a=map(int,open(0).read().split())
m=6**8
c=[0]*m
p=[1,1]+c[:]
for i in range(m):
  if p[i]<1:
    for j in range(i,m,i):p[j]=i
for a in a:
  s={a}
  while a!=p[a]:
    s|={p[a]}
    a//=p[a]
    s|={a}
  for i in s:c[i]+=1
print(('not','psaeitr'[max(c[2:])>1::2]+'wise')[max(c[2:])<n],'coprime')

Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
m=6**8
c=[0]*m
p=[1,1]+c[:]
for i in range(m):
  if p[i]<1:
    for j in range(i,m,i):p[j]=i
for a in a:
  c[a]+=1
  while p[a]!=a:
    a//=p[a]
    c[a]+=1
1/(max(c[2:])<n)
print(('not','psaeitr'[max(c[2:])>1::2]+'wise')[max(c[2:])<n],'coprime')

Fixed submission:
n,*a=map(int,open(0).read().split())
m=6**8
c=[0]*m
p=[1,1]+c[:]
for i in range(m):
  if p[i]<1:
    for j in range(i,m,i):p[j]=i
for a in a:
  s={a}
  while a!=p[a]:
    s|={p[a]}
    a//=p[a]
    s|={a}
  for i in s:c[i]+=1
print(('not','psaeitr'[max(c[2:])>1::2]+'wise')[max(c[2:])<n],'coprime')

Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
m=6**8
c=[0]*m
p=[1,1]+c[:]
for i in range(m):
  if p[i]<1:
    for j in range(i,m,i):p[j]=i
for a in a:
  c[a]+=1
  while p[a]!=a:
    a//=p[a]
    c[a]+=1
1/(max(c[2:])==n)
print(('not','psaeitr'[max(c[2:])>1::2]+'wise')[max(c[2:])<n],'coprime')

Fixed submission:
n,*a=map(int,open(0).read().split())
m=6**8
c=[0]*m
p=[1,1]+c[:]
for i in range(m):
  if p[i]<1:
    for j in range(i,m,i):p[j]=i
for a in a:
  s={a}
  while a!=p[a]:
    s|={p[a]}
    a//=p[a]
    s|={a}
  for i in s:c[i]+=1
print(('not','psaeitr'[max(c[2:])>1::2]+'wise')[max(c[2:])<n],'coprime')

Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0).read().split())
m=max(a)+1
c=[0]*m
p=[1,1]+c[:]
for i in range(m):
  if p[i]<1:
    for j in range(i,m,i):p[j]=i
for a in a:
  c[a]+=1
  while p[a]!=a:
    a//=p[a]
    c[a]+=1
print(('not','psaeitr'[max(c[2:])>1::2]+'wise')[max(c)<n],'coprime')

Fixed submission:
n,*a=map(int,open(0).read().split())
m=6**8
c=[0]*m
p=[1,1]+c[:]
for i in range(m):
  if p[i]<1:
    for j in range(i,m,i):p[j]=i
for a in a:
  s={a}
  while a!=p[a]:
    s|={p[a]}
    a//=p[a]
    s|={a}
  for i in s:c[i]+=1
print(('not','psaeitr'[max(c[2:])>1::2]+'wise')[max(c[2:])<n],'coprime')
Buggy python submission (verdict: Runtime Error):
from numpy import*
z=loadtxt(open(0),int,skiprows=1)
r=zeros(9**6,int)
c=copy(r)
for y,x in z:r[y]+=1;c[x]+=1
h,w=max(r),max(c)
y,x=z.T
print(h+w-(sum(r==h)*sum(w==c)==sum(h+w==r[y]+c[x])))

Fixed submission:
from collections import*
(h,w,m),*z=[tuple(map(int,o.split()))for o in open(0)]
s=set(z)
y,x=[Counter(t).most_common()for t in zip(*z)]
a,b=y[0][1],x[0][1]
p=[i for i,v in y if v==a]
q=[i for i,v in x if v==b]
for i in p:
  for j in q:
    if(i,j)not in s:exit(print(a+b))
print(a+b-1)
Buggy python submission (verdict: Runtime Error):
z=[map(int,t.split())for t in open(0)];print(sum(x*x+y*y<=z[0][1]**2for x,y in z))

Fixed submission:
(n,d),*z=[map(int,t.split())for t in open(0)]
print(sum(x*x+y*y<=d*d for x,y in z))
Buggy python submission (verdict: Runtime Error):
from functools import*
@lru_cache(None)
def solve(n,m):
  if not n:return 1
  n%=m
  return-~solve(n,bin(n).count('1'))
n=int(input())
s=input()
a=int(s,2)
*x,=map(int,s)
h=sum(x)
a,b=a%(h-1),a%(h+1)
for i in range(n):
  if x[i]:
    x[i]=0
    t=(a-pow(2,~i+n,h-1))%(h-1)
  else:
    x[i]=1
    t=(b+pow(2,~i+n,h+1))%(h+1)
  r=solve(t,bin(t).count('1'))
  x[i]^=1
  print(r)

Fixed submission:
from functools import*
@lru_cache(None)
def solve(n,m):
  if not n:return 1
  n%=m
  return-~solve(n,bin(n).count('1'))
n=int(input())
s=input()
a=int(s,2)
*x,=map(int,s)
h=sum(x)
try:a,b=a%(h-1),a%(h+1)
except:b=a%(h+1)
for i in range(n):
  if x[i]:
    if not h-1:
      print(0)
      continue
    x[i]=0
    t=(a-pow(2,~i+n,h-1))%(h-1)
  else:
    x[i]=1
    t=(b+pow(2,~i+n,h+1))%(h+1)
  r=solve(t,bin(t).count('1'))
  x[i]^=1
  print(r)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import*
i=input
for s in[0]*int(i()):
 n,x,*y=int(i()),[]
 for _ in'_'*n:k,l,r=t=[*map(int,i().split())];x+=[t]*(l>r);y+=[[n-k,r,l]]*(l<=r)
 for x in x,y:
  x.sort();n,*h=len(x),
  while h+x:
   while[[n]]<x[-1:]:k,l,r=x.pop();heappush(h,(r-l,l,r))
   if h:s+=heappop(h)[2-(n>0)]
   n-=1
 print(s)

Fixed submission:
import sys
from heapq import*
input=sys.stdin.buffer.readline
def solve():
    n=int(input())
    x,y=[],[]
    for _ in range(n):
        k,l,r=map(int,input().split())
        if l>r:
            x+=(k,l,r),
        else:
            y+=(n-k,r,l),
    x.sort()
    y.sort()
    s=0
    h=[]
    for i in range(len(x),0,-1):
        while x and x[-1][0]>=i:
            k,l,r=x.pop()
            heappush(h,(r-l,l,r))
        if h:s+=heappop(h)[1]
    s+=sum(r for _,_,r in x+h)
    h=[]
    for i in range(len(y),0,-1):
        while y and y[-1][0]>=i:
            k,l,r=y.pop()
            heappush(h,(r-l,l,r))
        if h:s+=heappop(h)[1]
    s+=sum(r for _,_,r in y+h)
    return s
t=int(input())
print('\n'.join(str(solve())for _ in range(t)))

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import*
i=input
for _ in'_'*int(i()):
 n,s,x,*y=int(i()),0,[];exec('k,l,r=t=[*map(int,i().split())];x+=[t]*(l>r);y+=[(n-k,r,l)]*(l<=r);'*n)
 for x in x,y:
  x.sort();n,*h=len(x),
  while n:
   n-=1
   while x and x[-1][0]>n:k,l,r=x.pop();heappush(h,(r-l,l,r))
   if h:s+=heappop(h)[1]
  for*_,r in x+h:s+=r
 print(s)

Fixed submission:
import sys
from heapq import*
input=sys.stdin.buffer.readline
def solve():
    n=int(input())
    x,y=[],[]
    for _ in range(n):
        k,l,r=map(int,input().split())
        if l>r:
            x+=(k,l,r),
        else:
            y+=(n-k,r,l),
    x.sort()
    y.sort()
    s=0
    h=[]
    for i in range(len(x),0,-1):
        while x and x[-1][0]>=i:
            k,l,r=x.pop()
            heappush(h,(r-l,l,r))
        if h:s+=heappop(h)[1]
    s+=sum(r for _,_,r in x+h)
    h=[]
    for i in range(len(y),0,-1):
        while y and y[-1][0]>=i:
            k,l,r=y.pop()
            heappush(h,(r-l,l,r))
        if h:s+=heappop(h)[1]
    s+=sum(r for _,_,r in y+h)
    return s
t=int(input())
print('\n'.join(str(solve())for _ in range(t)))