#335. Python 2 (Cython), 620 bytes, A000157
335. Python 2 (Cython), 620 bytes, A000157
from itertools import*
from math import*
from functools import*
n=int(input())+1#offset 1
a=0#answer
for p in permutations(range(n)):
for i in range(2**n):#inversion
v=[0]*(2**n)#visited
c=0#number of cycles
e=1#all is even
for x in range(2**n):
if v[x]:continue
w=1#1 if this cycle is even
while 1>v[x]:
v[x]=1;w^=1
x=reduce(lambda x,y:x+x+y,[1&(x>>s)for s in p])^i
e&=w;c+=1
a+=2**c*(1+e)
print(a//(2**n*factorial(n)*4))
#Come on... it's not that hard.
#Time complexity: 4**n*factorial(n)
#Memory complexity: 2**n
#(which is actually order of magnitude
#faster than the naive algorithm)
Originally intended to work in Python3, but Python 3 (Cython) raises an error "deallocating None".
Sorry for using Python, but programming on mobile is not easy. Posted 2 days ago in chat while waiting for someone else to post, probably with another language.
The next sequence has some chemistry-related things, but the recurrence relation is easy to implement. Ideally I hope someone will explain what the sequence is about. (I don't even explain most of my own answers...)
(Side note: Syntax highlighting fails for some comments)