Problem p02975 (python)

Fixed submission:
from collections import Counter,OrderedDict

N=int(input())
a=list(map(int,input().split()))
d=OrderedDict(Counter(a))
e=list(d)
e.sort()

if len(d)>3:
    ans="No"
else:
    ans="No"
    if len(d)==1:
        if e[0]==0:
            ans="Yes"
    elif len(d)==2:
        if N%3==0:
            if e[0]==0 and d[0]==N//3 and d[e[1]]==2*N//3:
                ans="Yes"
    else:
        if N%3==0:
            if d[e[0]]==d[e[1]]==d[e[2]]:
                if e[0]^e[1]^e[2]==0:
                    ans="Yes"
                   
print(ans)

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

if bin(a[N-2] ^ a[0]) == bin(a[N-1]):
  if bin(a[N-1] ^ a[1]) == bin(a[0]):
    if N!=3:
      for i in range(0,N-2):
        if Flag==True:
          if bin(a[N] ^ a[N+2])!=bin(a[N+1]):
            Flag=False
            break  
      if Flag==True:
        print("Yes")
      else:
        print("No")
    else:
      if bin(a[0] ^ a[2]) == bin(a[1]):
        print("Yes")
      else:
        print("No")
  else:
    print("No")    
else:
  print("No")

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

#print(bin(a[N-1] ^ a[1]))
#print(bin(a[0]))

if bin(a[N-2] ^ a[0]) == bin(a[N-1]):
  if bin(a[N-1] ^ a[1]) == bin(a[0]):
    if N!=3:
      for i in range(0,N-3):
        #print(bin(a[N] ^ a[N+2]),bin(a[N+1]))
        if Flag:
          if bin(a[N] ^ a[N+2])!=bin(a[N+1]):
            Flag=False
            break  
      if Flag:
        print("Yes")
      else:
        print("No")
    else:
      if bin(a[0] ^ a[2]) == bin(a[1]):
        print("Yes")
      else:
        print("No")
  else:
    print("No")    
else:
  print("No")

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

#print(bin(a[N-1] ^ a[1]))
#print(bin(a[0]))

if bin(a[N-2] ^ a[0]) == bin(a[N-1]):
  if bin(a[N-1] ^ a[1]) == bin(a[0]):
    if N!=3:
      for i in range(0,N-3):
        #print(bin(a[N] ^ a[N+2]),bin(a[N+1]))
        if Flag:
          if bin(a[N] ^ a[N+2])!=bin(a[N+1]):
            Flag=False
            break  
      if Flag:
        print("Yes")
    else:
      if bin(a[0] ^ a[2]) == bin(a[1]):
        print("Yes")
      else:
        print("No")
  else:
    print("No")    
else:
  print("No")

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

#print(bin(a[N-1] ^ a[1]))
#print(bin(a[0]))

if bin(a[N-2] ^ a[0]) == bin(a[N-1]):
  if bin(a[N-1] ^ a[1]) == bin(a[0]):
    for i in range(0,N-3):
      #print(bin(a[N] ^ a[N+2]),bin(a[N+1]))
      if Flag:
        if bin(a[N] ^ a[N+2])!=bin(a[N+1]):
          Flag=False
          break  
    if Flag:
      print("Yes")
    else:
      print("No")
  else:
    print("No")    
else:
  print("No")

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

#print(bin(a[N-1] ^ a[1]))
#print(bin(a[0]))

if bin(a[N-2] ^ a[0]) == bin(a[N-1]):
  if bin(a[N-1] ^ a[1]) == bin(a[0]):
    for i in range(0,N-3):
      #print(bin(a[N] ^ a[N+2]),bin(a[N+1]))
      if Falg:
        if bin(a[N] ^ a[N+2])!=bin(a[N+1]):
          Flag=False
          break  
    else:
      print("Yes")
  else:
    print("No")
    
else:
  print("No")

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

#print(bin(a[N-1] ^ a[1]))
#print(bin(a[0]))

if bin(a[N-2] ^ a[0]) == bin(a[N-1]):
  if bin(a[N-1] ^ a[1]) == bin(a[0]):
    for i in range(0,N-3):
      print(bin(a[N] ^ a[N+2]),bin(a[N+1]))
      if Falg:
        if bin(a[N] ^ a[N+2])!=bin(a[N+1]):
          Flag=False
          break  
    else:
      print("Yes")
  else:
    print("No")
    
else:
  print("No")