Problem:
Bit Operation I Given a non-negative decimal integer $x$, convert it to binary representation $b$ of 32 bits. Then, print the result of the following operations to $b$ respecitvely.  Inversion: change the state of each bit to the opposite state  Logical left shift: shift left by 1  Logical right shift: shift right by 1  Input The input is given in the following format. $x$ Output Print the given bits, results of inversion, left shift and right shift in a line respectively. Constraints  $0 \leq x \leq 2^{32} - 1$  Sample Input 1 8 Sample Output 1 00000000000000000000000000001000
11111111111111111111111111110111
00000000000000000000000000010000
00000000000000000000000000000100 Sample Input 2 13 Sample Output 2 00000000000000000000000000001101
11111111111111111111111111110010
00000000000000000000000000011010
00000000000000000000000000000110

Solution (Python):
def out(n):
    mask = 2**32 -1
    print(format(n&mask,"032b"))

n = int(input())

out(n)
out(~n)
out(n<<1)
out(n>>1)

Solution (Python):
x = int(input())
MASK = (1 << 32) - 1
print("{:032b}".format(x))
print("{:032b}".format(~x & MASK))
print("{:032b}".format((x << 1) & MASK))
print("{:032b}".format((x >> 1) & MASK))

Solution (Python):
x = int(input())
print(f'{x:032b}')
print(f'{~x & 0xffffffff:032b}')
print(f'{x << 1 & 0xffffffff:032b}')
print(f'{x >> 1:032b}')

Solution (Python):
x = int(input())
print("{:032b}".format(x))
print("{:032b}".format(~x & (2**32-1)))
print("{:032b}".format(x << 1 & (2**32-1)))
print("{:032b}".format(x >> 1))

Solution (Python):
n=int(input())
m=(1<<32)-1

print("{:032b}".format(n))
print("{:032b}".format(~n&m))
print("{:032b}".format(n<<1&m))
print("{:032b}".format(n>>1))

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

    b  = format(num, "032b")
    bi = format( ~num & 0b11111111111111111111111111111111, "032b")
    bl = format(num << 1, "032b")
    br = format(num >> 1, "032b")
    
    print(b)
    print(bi)
    if len(bl) > 32:
        print(bl[-32:])
    else:
        print(bl)

    print(br)

main()

Solution (Python):
x = int(input())
s = "{:032b}".format(x)
print(s)
print(s.replace("0","2").replace("1","0").replace("2","1"))
print(s[1:] + "0")
print("0" + s[:-1])

Solution (Python):
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

SIZE = 32

POW = [None]*SIZE
POW[0] = 1
for i in range(1,SIZE):
    POW[i] = POW[i-1]*2

x = int(input())
BIT = [0]*SIZE

for i in range(0,SIZE):
    if POW[(SIZE-1)-i] <= x:
        BIT[i] = 1
        x -= POW[(SIZE-1)-i]


for i in range(SIZE):
    print("%d"%(BIT[i]),end="")
print()


for i in range(SIZE):
    print("%d"%(1-BIT[i]),end="")
print()


for i in range(1,SIZE):
    print("%d"%(BIT[i]),end="")
print("0")


print("0",end="")
for i in range(SIZE-1):
    print("%d"%(BIT[i]),end="")
print()

Solution (Python):
n=format(int(input()),'032b')
n_li=list(n)
inversion_n=["1" if n_li[i]=="0"  else "0" for i in range(len(n_li))]
inversion_n= "".join(inversion_n)
left=n[1:len(n)]+"0"
right="0"+n[0:len(n)-1]
print(n)
print(inversion_n)
print(left)
print(right)

Solution (Python):
x = int(input())
print( format(x, "032b") )
print( format( ~x & 0b11111111111111111111111111111111, "032b") )
print( format( x<<1, "032b")[-32:] )
print( format( x>>1, "032b") )

Solution (Python):
b = int(input())
MAX = (1 << 32) - 1
print("{:032b}".format(b))
print("{:032b}".format(~b & MAX))
print("{:032b}".format((b << 1) & MAX))
print("{:032b}".format((b >> 1) & MAX))

Solution (Python):
if __name__ == "__main__":
    x = int(input())
    mask = (1 << 32) - 1
    print(f"{x:032b}")
    print(f"{~x & mask:032b}")
    print(f"{(x << 1) & mask:032b}")
    print(f"{(x >> 1) & mask:032b}")

Solution (Python):
x=int(input())
y=format(x,"b").zfill(10)
ly=len(y)
ly=32-ly
pady="0"*ly
print(pady+y)
rev=2**32-1-x
z=format(rev,"b").zfill(10)
lz=len(z)
lz=32-lz
padz="0"*lz
print(padz+z)
left=x*2
if left>=2**32:
    left-=2**32
u=format(left,"b").zfill(10)
lu=len(u)
lu=32-lu
padu="0"*lu
print(padu+u)

right=x//2
v=format(right,"b").zfill(10)
lv=len(v)
lv=32-lv
padv="0"*lv
print(padv+v)

Solution (Python):

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

"""
x = int(input())
print(f'{x:032b}')
print(f'{x:032b}'.translate(str.maketrans('01', '10')))
print(f'{x<<1:032b}'[-32:])
print(f'{x>>1:032b}')

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

BITMASK = (1 << 32) - 1

print("{:032b}".format(x))
print("{:032b}".format(~x & BITMASK))
print("{:032b}".format((x << 1) & BITMASK))
print("{:032b}".format((x >> 1) & BITMASK))

Solution (Python):
n = int(input())
mask = (1<<32)-1
print('{:032b}'.format(n))
print('{:032b}'.format(~n & mask))
print('{:032b}'.format((n<<1)& mask))
print('{:032b}'.format((n>>1)& mask))

Solution (Python):
x = int(input())
MASK = (1 << 32) - 1

print("{:032b}".format(x))
print("{:032b}".format(~x & MASK))
print("{:032b}".format((x << 1) & MASK))
print("{:032b}".format((x >> 1) & MASK))

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

b=~x&0b11111111111111111111111111111111
c=(x<<1)&0b11111111111111111111111111111111
d=(x>>1)&0b11111111111111111111111111111111
print(format(x,'032b'))
print(format(b,'032b'))
print(format(c,'032b'))
print(format(d,'032b'))

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

print('{:032b}'.format(x))
print('{:032b}'.format(~x & (2 ** 32 - 1)))
print('{:032b}'.format(x << 1 & (2 ** 32 - 1)))
print('{:032b}'.format(x >> 1))

Solution (Python):
n = int(input())
MASK = (1 << 32) -1
print("{:032b}".format(n))
print("{:032b}".format(~n & MASK))
print("{0:032b}".format(n << 1 & MASK))
print("{0:032b}".format(n >> 1 & MASK))

Solution (Python):
n = int(input())
print(f'{n:032b}')
print(f'{~n & 0xffffffff:032b}')
print(f'{((n << 1) & 0xffffffff):032b}')
print(f'{n >> 1:032b}')

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

bin_x = format(x, '032b')
bin_x1 = format(~x & 0b11111111111111111111111111111111, '032b')
bin_x2 = format(x << 1 & 0b11111111111111111111111111111111, '032b')
bin_x3 = format(x >> 1 & 0b11111111111111111111111111111111, '032b')

print(bin_x)
print(bin_x1)
print(bin_x2)
print(bin_x3)

Solution (Python):
x = int(input())
MASK = (1 << 32) - 1
print("{:032b}".format(x))
print("{:032b}".format(~x & MASK))
print("{:032b}".format((x << 1) & MASK))
print("{:032b}".format((x >> 1) & MASK))

Solution (Python):




def run():
    n = int(input())
    fmt = "{:032b}"

    print(fmt.format(n))
    print(fmt.format(~n + 2**32))
    print(fmt.format(n << 1 & ~(1 << 32)))
    print(fmt.format(n >> 1))


if __name__ == '__main__':
    run()

Solution (Python):
n = int(input())
print(bin(n)[2:].zfill(32))
print(bin(2**32-n-1)[2:].zfill(32))
a = bin(n<<1)[2:].zfill(32)
print(a[-32:])
print(bin(n>>1)[2:].zfill(32))