Problem:
Bit Flag A state with $n$ flags of ON or OFF can be represented by a sequence of bits where $0, 1, ..., n-1$ -th flag corresponds to 1 (ON) or 0 (OFF).
  The state can be managed by the corresponding decimal integer, because the sequence of bits is a binary representation where each bit is 0 or 1. Given a sequence of bits with 64 flags which represent a state, perform the following operations. Note that each flag of the bits is initialized by OFF.  test(i): 		Print 1 if $i$-th flag is ON, otherwise 0  set(i): 		Set $i$-th flag to ON  clear(i):		Set $i$-th flag to OFF  flip(i): 		Inverse $i$-th flag  all:		Print 1 if all flags are ON, otherwise 0  any:		Print 1 if at least one flag is ON, otherwise 0  none:		Print 1 if all flags are OFF, otherwise 0  count:		Print the number of ON flags  val:		Print the decimal value of the state  Input The input is given in the following format. $q$
$query_1$
$query_2$
:
$query_q$ Each query $query_i$ is given in the following format: 0 $i$ or 1 $i$ or 2 $i$ or 3 $i$ or 4 or 5 or 6 or 7 or 8 The first digit 0 , 1 ,..., 8 represents the operation test(i), set(i), clear(i), flip(i), all, any, none, count or val respectively. Output Print the result in a line for each test, all, any, none, count and val operation. Constraints  $1 \leq q \leq 200,000$  $0 \leq i < 64$  Sample Input 1 14
1 0
1 1
1 2
2 1
0 0
0 1
0 2
0 3
3 3
4
5
6
7
8 Sample Output 1 1
0
1
0
0
1
0
3
13

Solution (Python):
l = [0 for _ in range(64)]

for i in range(int(input())):
    query = list(input().split())
    order = query[0]
    if order == "0":
        print(1 if l[int(query[1])] else 0)
    elif order == "1":
        l[int(query[1])] = 1
    elif order == "2":
        l[int(query[1])] = 0
    elif order == "3":
        l[int(query[1])] ^= 1
    elif order == "4":
        print(1 if all(l) else 0)
    elif order == "5":
        print(1 if any(l) else 0)
    elif order == "6":
        print(1 if not any(l) else 0)
    elif order == "7":
        print(sum(l))
    elif order == "8":
        tmp = 0
        for i in reversed(range(64)):
            tmp += l[i] * 2**i
        print(tmp)

Solution (Python):
x = 0
mask = 2**64 - 1
def test(i):
    global x
    print(+((x & (1 << i)) != 0))
def Set(i):
    global x
    x |= 1 << i
def clear(i):
    global x
    x &= mask - (1 << i)
def flip(i):
    global x
    x ^= 1 << i
def all():
    global x
    print(+(x == mask))
def any():
    global x
    print(+(x != 0))
def none():
    global x
    print(+(x == 0))
def count():
    global x
    print(bin(x).count('1'))
def val():
    global x
    print(x)
    
f = [test, Set, clear, flip, all, any, none, count, val].__getitem__
for _ in range(int(input())):
    op, *i = map(int, input().split())
    f(op)(*i)

Solution (Python):

"""
Bitset I - Bit Flag
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_10_C&lang=jp

"""
class Bit:
    def __init__(self):
        self.data = 0

    def process(self, op, arg):
        funcs = (self.test, self.set, self.clear, self.flip, self.all, self.any, self.none, self.count, self.val)
        funcs[int(op)](arg)

    def test(self, arg):
        print(int(bool(self.data & 1 << int(arg))))

    def set(self, arg):
        self.data |= 1 << int(arg)

    def clear(self, arg):
        self.data &= ~(1 << int(arg))

    def flip(self, arg):
        self.data ^= 1 << int(arg)

    def all(self, arg):
        print(int(bin(self.data).count('1') == 64))

    def any(self, arg):
        print(int(self.data != 0))

    def none(self, arg):
        print(int(self.data == 0))

    def count(self, arg):
        print(bin(self.data).count('1'))

    def val(self, arg):
        print(self.data)

b = Bit()
for _ in range(int(input())):
    op, arg = (input() + ' 1').split()[:2]
    b.process(op, arg)

Solution (Python):
q = int(input())
x = 0
MASK = 2 ** 64 - 1

def x_test(i):
    return int((x & (1 << i)) > 0)
def x_set(i):
    global x
    x |= 1 << i
def x_clear(i):
    global x
    if x & (1 << i):
        x ^= 1 << i
def x_flip(i):
    global x
    x ^= 1 << i
def x_all():
    return int(x & MASK == MASK)
def x_any():
    return int(x & MASK > 0)
def x_none():
    return int(x & MASK == 0)
def x_count():
    return bin(x).count("1")
def x_val():
    return x
    
command = [
    x_test,
    x_set,
    x_clear,
    x_flip,
    x_all,
    x_any,
    x_none,
    x_count,
    x_val
]

for j in range(q):
    t, *cmd = map(int, input().split())
    ans = command[t](*cmd)
    if ans is not None:
        print(ans)

Solution (Python):
def showBit(self):
    print("{:b}".format(data))

def bitCheck(n,i):
    return (int(bool(n&1<<i)))

def bitOn(n,i):
    return n|1<<i

def bitOff(n,i):
    return n&~(1<<i)

def bitFlip(n,i):
    return n^1<<i

def isbitAll(n):
    return int(bitCount(n)==64)

def isbitAny(n):
    return int(bitCount(n)>0)

def isbitNone(n):
    return int(bitCount(n)==0)

def bitCount(n):
    return bin(n).count('1')

n=0
q=int(input())
for i in range(q):
    qry=list(map(int,input().split()))
    if qry[0]==0:
        print(bitCheck(n,qry[1]))
    elif qry[0]==1:
        n=bitOn(n,qry[1])
    elif qry[0]==2:
        n=bitOff(n,qry[1])
    elif qry[0]==3:
        n=bitFlip(n,qry[1])
    elif qry[0]==4:
        print(isbitAll(n))
    elif qry[0]==5:
        print(isbitAny(n))
    elif qry[0]==6:
        print(isbitNone(n))
    elif qry[0]==7:
        print(bitCount(n))
    elif qry[0]==8:
        print(n)

Solution (Python):
def main():
    q = int(input())

    state = 0
    flag  = 1

    for _ in range(q):

        param = input().split()
        c = int(param[0])
        if len(param) >= 2:
            param[1] = int(param[1])

        if c == 0:
            if state & (flag << (param[1])) :
                print("1")
            else:
                print("0")

        elif c == 1:
            state = state | (flag << (param[1] ))

        elif c == 2:
            state = state & (~(flag << (param[1] )) & 0xffffffffffffffff)
            
        elif c == 3:
            state = state ^ (flag << (param[1] ))

        elif c == 4:
            if state & 0xffffffffffffffff == 0xffffffffffffffff:
                print("1")
            else:
                print("0")
            
        elif c == 5:
            if (state & 0xffffffffffffffff) != 0:
                print("1")
            else:
                print("0")

        elif c == 6:
            if (state & 0xffffffffffffffff) == 0:
                print("1")
            else:
                print("0")

        elif c == 7:
            print(format(state, "064b").count("1"))

        elif c == 8:
            print(int(state))

main()

Solution (Python):
def ope_all(l):
    cnt=[1 if sum(l)==64 else 0]
    return print(*cnt)

def ope_any(l):
    cnt=[0 if sum(l)==0 else 1]
    return print(*cnt)

def ope_none(l):
         cnt=[1 if sum(l)==0 else 0]
         return print(*cnt)    
         
li=[0]*64
n=int(input())
ope=[input().split() for i in range(n)]
ope =[[int(j) for j in ope[i]] for i in range(len(ope))]
for i in range(n):
    if ope[i][0]==0:
        n=[1 if li[ope[i][1]]==1 else 0]
        print(*n)
    elif ope[i][0]==1:
        li[ope[i][1]]=1
    elif ope[i][0]==2:
         li[ope[i][1]]=0       
    elif ope[i][0]==3:
        if li[ope[i][1]]==1:
            li[ope[i][1]]=0
        else:
            li[ope[i][1]]=1
    elif ope[i][0]==4:
        ope_all(li)
    elif ope[i][0]==5:
        ope_any(li)
    elif ope[i][0]==6:
         ope_none(li)
    elif ope[i][0]==7:
         print(li.count(1))
    else:
        int_li ="".join(map(str, li))
        int_li ="".join(list(reversed(int_li)))
        print(int(int_li,2))

Solution (Python):
class Bits:
    def __init__(self):
        self.bits = 0
        self.mask = 2**64 - 1

    def test(self,k):
        return self.bits & (1<<k) != 0

    def set(self, k):
        self.bits |= 1<<k

    def clear(self, k):
        self.bits &= ~(1<<k) & self.mask

    def flip(self, k):
        if self.test(k):
            self.clear(k)
        else:
            self.set(k)

    def all(self):
        return self.bits == self.mask

    def any(self):
        return self.bits != 0

    def none(self):
        return self.bits == 0

    def count(self):
        c = 0
        for i in range(64):
            if self.test(i):
                c += 1
        return(c)

    def val(self):
        return(self.bits)

    def __str__(self):
        return format(self.bits, "064b")

n = int(input())
b = Bits()

for _ in range(n):
    c, k = [int(x) for x in (input() + " 0").split()][:2]
    

    if  c == 0:
        if b.test(k):
            print(1)
        else:
            print(0)
    elif c == 1:
        b.set(k)
    elif c == 2:
        b.clear(k)
    elif c == 3:
        b.flip(k)
    elif c == 4:
        if b.all():
            print(1)
        else:
            print(0)
    elif c == 5:
        if b.any():
            print(1)
        else:
            print(0)
    elif c == 6:
        if b.none():
            print(1)
        else:
            print(0)
    elif c == 7:
        print( b.count())
    else:
        print( b.val() )

Solution (Python):
if __name__ == "__main__":
    num_query = int(input())
    bits = [0] * 64

    for _ in range(num_query):
        op, *v = map(lambda x: int(x), input().split())
        if (0 == op):
            if (1 == bits[v[0]]):
                print(1)
            else:
                print(0)
        elif (1 == op):
            bits[v[0]] = 1
        elif (2 == op):
            bits[v[0]] = 0
        elif (3 == op):
            bits[v[0]] = 1 if bits[v[0]] == 0 else 0
        elif (4 == op):
            if all(bits):
                print(1)
            else:
                print(0)
        elif (5 == op):
            if any(bits):
                print(1)
            else:
                print(0)
        elif (6 == op):
            if not sum(bits):
                print(1)
            else:
                print(0)
        elif (7 == op):
            print(sum(bits))
        else:
            bin_str = "".join([str(elem) for elem in bits[::-1]])
            print(f"{int(bin_str, 2)}")

Solution (Python):

"""
Bitset I - Bit Flag
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_10_C&lang=jp

"""
class Bit:
    def __init__(self):
        self.data = 0

    def process(self, op, arg):
        funcs = (self.test, self.set, self.clear, self.flip, self.all, self.any, self.none, self.count, self.val)
        funcs[int(op)](arg)

    def test(self, arg):
        print(int(bool(self.data & 1 << int(arg))))

    def set(self, arg):
        self.data |= 1 << int(arg)

    def clear(self, arg):
        self.data &= ~(1 << int(arg))

    def flip(self, arg):
        self.data ^= 1 << int(arg)

    def all(self, arg):
        print(int(bin(self.data).count('1') == 64))

    def any(self, arg):
        print(int(self.data != 0))

    def none(self, arg):
        print(int(self.data == 0))

    def count(self, arg):
        print(bin(self.data).count('1'))

    def val(self, arg):
        print(self.data)

b = Bit()
for _ in range(int(input())):
    op, arg = (input() + ' 1').split()[:2]
    b.process(op, arg)

Solution (Python):
q = int(input())

bit_flag = 0
BIT_MASK = (1 << 64) - 1

for _ in range(q):

    command, *list_num = input().split()

    if   command == "0":
        
        i = int(list_num[0])
        if bit_flag & (2 ** i):
            print(1)
        else:
            print(0)
    elif command == "1":
        
        i = int(list_num[0])
        bit_flag = bit_flag | (2 ** i)
    elif command == "2":
        
        i = int(list_num[0])
        bit_flag = bit_flag & ~(2 ** i)
    elif command == "3":
        
        i = int(list_num[0])
        bit_flag = bit_flag ^ (2 ** i)
    elif command == "4":
        
        if not(~bit_flag & BIT_MASK):
            print(1)
        else:
            print(0)
    elif command == "5":
        
        if bit_flag:
            print(1)
        else:
            print(0)
    elif command == "6":
        
        if not bit_flag:
            print(1)
        else:
            print(0)
    elif command == "7":
        
        print("{:64b}".format(bit_flag).count("1"))
    elif command == "8":
        
        print(bit_flag)
    else:
        raise

Solution (Python):
mask = (1<<64)-1
a = 0
def test(a,i):
    if a>>i & 1:
        print(1)
    else:
        print(0)
def _set(a,i):
    a = a | (1<<i)
    return a
def clear(a,i):
    a = a & ~(1<<i)
    return a
def flip(a,i):
    a = a ^ (1<<i)  
    return a
def _all(a):
    if a & mask == mask:
        print(1)
    else:
        print(0)
def _any(a):
    if a == 0:
        print(0)
    else:
        print(1)
def none(a):
    if a & mask == 0:
        print(1)
    else:
        print(0)
def count(a):
    print(bin(a).count('1'))
q = int(input())
for i in range(q):
    s, *t = map(int, input().split())
    if s == 0:test(a,t[0])
    if s == 1:a = _set(a,t[0])
    if s == 2:a = clear(a,t[0])
    if s == 3:a = flip(a,t[0])
    if s == 4:_all(a)
    if s == 5:_any(a)
    if s == 6:none(a)
    if s == 7:count(a)
    if s == 8:print(a)

Solution (Python):
flag=[0 for i in range(64)]

def Test(flag,i):
    print(flag[i])

def Set(flag,i):
    flag[i]=1
    return flag

def Clear(flag,i):
    flag[i]=0
    return flag

def Flip(flag,i):
    if flag[i]==0:
        flag[i]=1
    else:
        flag[i]=0
    return flag

def All(flag):
    if all(flag)==True:
        print(1)
    else:
        print(0)

def Any(flag):
    if any(flag)==True:
        print(1)
    else:
        print(0)

def none(flag):
    if not any(flag)==True:
        print(1)
    else:
        print(0)

def Val(flag):
    a=''.join(map(str,flag[::-1]))
    print(int(a,2))

q=int(input())
for i in range(q):
    query=list(map(int,input().split()))
    if query[0]==0:
        Test(flag,query[1])
    elif query[0]==1:
        flag=Set(flag,query[1])
    elif query[0]==2:
        flag=Clear(flag,query[1])
    elif query[0]==3:
        flag=Flip(flag,query[1])
    elif query[0]==4:
        All(flag)
    elif query[0]==5:
        Any(flag)
    elif query[0]==6:
        none(flag)
    elif query[0]==7:
        print(flag.count(1))
    else:
        Val(flag)

Solution (Python):
q = int(input())

MASK = (1 << 64) -1
n = 0
for i in range(q):
    query = [i for i in map(int,input().split())]
    if query[0] == 0:
        temp = 1 << query[1]
        if (n & temp) == 0:
            print(0)
        else:
            print(1)

    elif query[0] == 1:
        temp = 1 << query[1]
        n = (n | temp)

    elif query[0] == 2:
        temp = 1 << query[1]
        n = n & (~temp & MASK)
        
    elif query[0] == 3:
        temp = 1 << query[1]
        n = n ^ temp
        
    elif query[0] == 4:
        if n == MASK:
            print(1)
        else:
            print(0)
    elif query[0] == 5:
        if n & MASK > 0:
            print(1)
        else:
            print(0)
            
    elif query[0] == 6:
        if n == 0:
            print(1)
        else:
            print(0)
            
    elif query[0] == 7:
        temp = n
        one = 1
        counter = 0
        for i in range(64):
            if one & temp == 1:
                counter += 1
            temp = temp >> 1
        print(counter)
        
    elif query[0] == 8:
        print(n)

Solution (Python):
import sys

class BitFlag:
    ALL_ON  = 0xffffffffffffffff
    ALL_OFF = 0x0000000000000000

    def __init__(self):
        self.FLAGS = self.ALL_OFF
        self.Masks = [1 << i for i in range(64)]

    def _test(self, i):
        return self.FLAGS & self.Masks[i] != 0b00

    def _set(self, i):
        self.FLAGS |= self.Masks[i]

    def _clear(self, i):
        self.FLAGS &= ~self.Masks[i]

    def _flip(self, i):
        self.FLAGS ^= self.Masks[i]

    def _all(self):
        return self.FLAGS & self.ALL_ON == self.ALL_ON

    def _any(self):
        return self.FLAGS & self.ALL_ON != self.ALL_OFF

    def _none(self):
        return self.FLAGS & self.ALL_ON == self.ALL_OFF

    def _count(self):
        return bin(self.FLAGS).count('1')

    def _val(self):
        return self.FLAGS


bf = BitFlag()

commands = {'0': bf._test,
            '1': bf._set,
            '2': bf._clear,
            '3': bf._flip,
            '4': bf._all,
            '5': bf._any,
            '6': bf._none,
            '7': bf._count,
            '8': bf._val
            }

qn = int(input())
lines = sys.stdin.readlines()
ans = [None] * qn

for i in range(qn):
    q, *arg = lines[i].split()
    if len(arg):
        ans[i] = commands[q](int(arg[0]))
    else:
        ans[i] = commands[q]()

[print(int(x)) for x in ans if x is not None]

Solution (Python):
q = int(input())
bin_q = format(0, '064b')
qlist = list(bin_q)

for _ in range(q):
    query = list(map(int, input().split()))
    command = query[0]

    if command == 0:    
        i = 63 - query[1]
        print(qlist[i])
    elif command == 1:  
        i = 63 - query[1]
        qlist[i] = '1'
    elif command == 2:  
        i = 63 - query[1]
        qlist[i] = '0'
    elif command == 3:  
        i = 63 - query[1]
        if qlist[i] == '0':
            qlist[i] = '1'
        else:
            qlist[i] = '0'
    elif command == 4:  
        c = qlist.count('1')
        if c == 64:
            print(1)
        else:
            print(0)
    elif command == 5:  
        c = qlist.count('1')
        if c > 0:
            print(1)
        else:
            print(0)
    elif command == 6:  
        c = qlist.count('1')
        if c == 0:
            print(1)
        else:
            print(0)
    elif command == 7:  
        c = qlist.count('1')
        print(c)
    elif command == 8:  
        bin_q = ''.join(str(q) for q in qlist)
        dec_q = int(bin_q, 2)
        print(dec_q)

Solution (Python):
Q = int(input())

MASK = (1 << 64) - 1

x = 0
def c_test(i):
    return+(x & (1 << i) > 0)
def c_set(i):
    global x
    x |= 1 << i
def c_clear(i):
    global x
    if x & (1 << i):
        x ^= 1 << i
def c_flip(i):
    global x
    x ^= 1 << i
def c_all():
    return+(x & MASK == MASK)
def c_any():
    return+(x & MASK > 0)
def c_none():
    return+(x & MASK == 0)
def c_count():
    return bin(x).count('1')
def c_val():
    return x


fmap = [
    c_test,
    c_set,
    c_clear,
    c_flip,
    c_all,
    c_any,
    c_none,
    c_count,
    c_val,
]
def query(Q):
    for q in range(Q):
        t, *cmd = map(int, input().split())
        res = fmap[t](*cmd)
        if res is not None:
            yield res
print(*query(Q), sep='\n')

Solution (Python):




class BitFlag:
    def __init__(self, size):
        self.size = size
        self.mask = ~(1 << self.size)
        self.data = 0 & (1 << self.size)

    def set(self, i):
        self.data |= (1 << i) & self.mask

    def test(self, i):
        return self.data & (1 << i) > 0

    def clear(self, i):
        self.data &= ~(1 << i) & self.mask

    def flip(self, i):
        self.data ^= (1 << i) & self.mask

    def all(self):
        return self.data == 2**self.size - 1

    def any(self):
        return not self.data == 0

    def none(self):
        return self.data == 0

    def count(self):
        return sum(1 for i in range(self.size) if self.test(i))

    def val(self):
        return self.data


def run():
    flg = BitFlag(64)
    q = int(input())
    for _ in range(q):
        cmd = input().split()

        if cmd[0] == '0':
            if flg.test(int(cmd[1])):
                print(1)
            else:
                print(0)
        elif cmd[0] == '1':
            flg.set(int(cmd[1]))
        elif cmd[0] == '2':
            flg.clear(int(cmd[1]))
        elif cmd[0] == '3':
            flg.flip(int(cmd[1]))
        elif cmd[0] == '4':
            if flg.all():
                print(1)
            else:
                print(0)
        elif cmd[0] == '5':
            if flg.any():
                print(1)
            else:
                print(0)
        elif cmd[0] == '6':
            if flg.none():
                print(1)
            else:
                print(0)
        elif cmd[0] == '7':
            print(flg.count())
        elif cmd[0] == '8':
            print(flg.val())


if __name__ == '__main__':
    run()

Solution (Python):
n = int(input())
num = ["0" for i in range(64)]
for i in range(n):
    query = input().split()
    if query[0] == "0":
        print(0 if num[int(query[1])] == "0" else 1)
    elif query[0] == "1":
        num[int(query[1])] = "1"
    elif query[0] == "2":
        num[int(query[1])] = "0"
    elif query[0] == "3":
        num[int(query[1])] = "1" if num[int(query[1])] == "0" else "0"
    elif query[0] == "4":
        print("1" if num.count("1") == 64 else "0")
    elif query[0] == "5":
        print("1" if num.count("1") >= 1 else "0")
    elif query[0] == "6":
        print("1" if num.count("1") == 0 else "0")
    elif query[0] == "7":
        print(num.count("1"))
    elif query[0] == "8":
        print(int("".join(num[::-1]),2))