Midori like chocolates and he loves to try different ones. There are N shops in a market labelled from 1 to N and each shop offers a different variety of chocolate. Midori starts from ith shop and goes ahead to each and every shop. But as there are too many shops Midori would like to know how many more shops he has to visit. You have been given L denoting number of bits required to represent N. You need to return the maximum number of shops he can visit.
Example 1:
Input: i = 2, L = 3
Output: 6
Explanation: There are 3 bits So N = 8
Hence midori can visit 8 - 2 = 6 more shops.
Example 2:
Input: i = 1, L = 2
Output: 3
Explanation: There are 2 bits so N = 4
Hence midori can visit 4 - 1 = 3 more shops.
Your Task:  
You dont need to read input or print anything. Complete the function leftShops() which takes i and L as input parameter and returns the maximum number of shops that midori can visit.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
1<= i <=N
1<= L <=30

Source: geeksforgeeks | Difficulty: EASY
Tags: Bit manipulation

Data structures

Starter code: #User function Template for python3

class Solution:

    def leftShops (self, i, L):

        # code here 

Solutions:
class Solution:

	def leftShops(self, i, L):
		return 2 ** L - i


class Solution:

	def leftShops(self, i, L):
		x = 1 << L
		return x - i


class Solution:

	def leftShops(self, i, L):
		num = 1 << L
		return num - i


import math

class Solution:

	def leftShops(self, i, L):
		return pow(2, L) - i


class Solution:

	def leftShops(self, i, L):
		t = 2 ** L
		ans = t - i
		return ans


class Solution:

	def leftShops(self, i, l):
		a = 2 ** l
		return a - i


class Solution:

	def leftShops(self, i, L):
		n = pow(2, L)
		return n - i


class Solution:

	def leftShops(self, i, L):
		b = pow(2, L)
		return b - i


class Solution:

	def leftShops(self, i, l):
		return pow(2, l) - i


class Solution:

	def leftShops(self, i, L):
		N = 2 ** L
		v = N - i
		return v


class Solution:

	def leftShops(self, i, L):
		string = ''
		for j in range(L):
			string += '1'
		num = int(string, 2) + 1
		return num - i


class Solution:

	def leftShops(self, i, L):
		d = pow(2, L)
		return d - i


class Solution:

	def leftShops(self, i, L):
		x = pow(2, L)
		return x - i


class Solution:

	def leftShops(self, i, L):
		return int('1' * L, 2) - i + 1


class Solution:

	def leftShops(self, i, L):
		n = eval('0b' + '1' * L)
		return n - i + 1


class Solution:

	def leftShops(self, i, L):
		return 2 ** L - i
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(i, L) = input().split()
		i = int(i)
		L = int(L)
		ob = Solution()
		print(ob.leftShops(i, L))


import math

class Solution:

	def leftShops(self, i, L):
		p = math.pow(2, L)
		return int(p - i)
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(i, L) = input().split()
		i = int(i)
		L = int(L)
		ob = Solution()
		print(ob.leftShops(i, L))


class Solution:

	def leftShops(self, i, L):
		shops = 2 << L - 1
		return shops - i


class Solution:

	def leftShops(self, i, L):
		n = 2 ** L
		v = n - i
		return v


class Solution:

	def leftShops(self, i, L):
		total = pow(2, L)
		ans = total - i
		return ans