giulio98/xlcost-single-prompt huggingface dataset:
# minimum number of swaps required to sort an array | swap function ; indexof function ; return the minimum number of swaps required to sort the array ; this is checking whether the current element is at the right place or not ; swap the current element with the right index so that arr [ 0 ] to arr [ i ] is sorted ; 
def swap(arr, i, j):
    temp = arr[i]
    arr[i] = arr[j]
    arr[j] = temp


def indexOf(arr, ele):
    for i in range(len(arr)):
        if (arr[i] == ele):
            return i
    return -1


def minSwaps(arr, N):
    ans = 0
    temp = sorted(arr .copy())
    for i in range(N):
        if (arr[i] != temp[i]):
            ans += 1
            swap(arr, i, indexOf(arr, temp[i]))
    return ans


if __name__ == "__main__":
    a = [101, 758, 315, 730, 472, 619, 460, 479]
    n = len(a)
    print(minSwaps(a, n))

# Expected output:
5
# minimum number of swaps required to sort an array | return the minimum number of swaps required to sort the array ; dictionary which stores the indexes of the input array ; this is checking whether the current element is at the right place or not ; if not , swap this element with the index of the element which should come here ; update the indexes in the hashmap accordingly ; 
def minSwap(arr, n):
    ans = 0
    temp = arr .copy()
    h = {}
    temp .sort()
    for i in range(n):
        h[arr[i]] = i
    init = 0
    for i in range(n):
        if (arr[i] != temp[i]):
            ans += 1
            init = arr[i]
            arr[i], arr[h[temp[i]]] = arr[h[temp[i]]], arr[i]
            h[init] = h[temp[i]]
            h[temp[i]] = i
    return ans


a = [101, 758, 315, 730, 472, 619, 460, 479]
n = len(a)
print(minSwap(a, n))

# Expected output:
5
# union and intersection of two sorted arrays | function prints union of arr1 [ ] and arr2 [ ] m is the number of elements in arr1 [ ] n is the number of elements in arr2 [ ] ; print remaining elements of the larger array ; 
def printUnion(arr1, arr2, m, n):
    i, j = 0, 0
    while i < m and j < n:
        if arr1[i] < arr2[j]:
            print(arr1[i])
            i += 1
        elif arr2[j] < arr1[i]:
            print(arr2[j])
            j += 1
        else:
            print(arr2[j])
            j += 1
            i += 1
    while i < m:
        print(arr1[i])
        i += 1
    while j < n:
        print(arr2[j])
        j += 1


arr1 = [1, 2, 4, 5, 6]
arr2 = [2, 3, 5, 7]
m = len(arr1)
n = len(arr2)
printUnion(arr1, arr2, m, n)

# Expected output:
1
2
3
4
5
6
7
# union and intersection of two sorted arrays | python3 program to find union of two sorted arrays ( handling duplicates ) ; taking max element present in either array ; finding elements from 1 st array ( non duplicates only ) . using another array for storing union elements of both arrays assuming max element present in array is not more than 10 ^ 7 ; first element is always present in final answer ; incrementing the first element ' s ▁ count ▁ ▁ in ▁ it ' s corresponding index in newtable ; starting traversing the first array from 1 st index till last ; checking whether current element is not equal to it 's previous element ; finding only non common elements from 2 nd array ; by checking whether it 's already  present in newtable or not ; 
def UnionArray(arr1, arr2):
    m = arr1[-1]
    n = arr2[-1]
    ans = 0
    if m > n:
        ans = m
    else:
        ans = n
    newtable = [0] * (ans + 1)
    print(arr1[0], end=" ")
    newtable[arr1[0]] += 1
    for i in range(1, len(arr1)):
        if arr1[i] != arr1[i - 1]:
            print(arr1[i], end=" ")
            newtable[arr1[i]] += 1
    for j in range(0, len(arr2)):
        if newtable[arr2[j]] == 0:
            print(arr2[j], end=" ")
            newtable[arr2[j]] += 1


if __name__ == "__main__":
    arr1 = [1, 2, 2, 2, 3]
    arr2 = [2, 3, 4, 5]
    UnionArray(arr1, arr2)

# Expected output:
1 2 3 4 5
# union and intersection of two sorted arrays | function prints intersection of arr1 [ ] and arr2 [ ] m is the number of elements in arr1 [ ] n is the number of elements in arr2 [ ] ; 
def printIntersection(arr1, arr2, m, n):
    i, j = 0, 0
    while i < m and j < n:
        if arr1[i] < arr2[j]:
            i += 1
        elif arr2[j] < arr1[i]:
            j += 1
        else:
            print(arr2[j])
            j += 1
            i += 1


arr1 = [1, 2, 4, 5, 6]
arr2 = [2, 3, 5, 7]
m = len(arr1)
n = len(arr2)
printIntersection(arr1, arr2, m, n)

# Expected output:
2
5
# count numbers less than n containing digits from the given set : digit dp | python3 implementation to find the count of numbers possible less than n , such that every digit is from the given set of digits ; function to convert integer into the string ; recursive function to find the count of numbers possible less than n , such that every digit is from the given set of digits ; base case ; condition when the subproblem is computed previously ; condition when the number chosen till now is definietly smaller than the given number n ; loop to traverse all the digits of the given set ; loop to traverse all the digits from the given set ; store the solution for current subproblem ; function to count the numbers less then n from given set of digits ; converting the number to string ; find the solution of all the number equal to the length of the given number n ; loop to find the number less in in the length of the given number ; 

import numpy as np
dp = np .ones((15, 2)) * -1


def convertToString(num):
    return str(num)


def calculate(pos, tight, D, sz, num):
    if (pos == len(num)):
        return 1
    if (dp[pos][tight] != -1):
        return dp[pos][tight]
    val = 0
    if (tight == 0):
        for i in range(sz):
            if (D[i] < (ord(num[pos]) - ord('0'))):
                val += calculate(pos + 1, 1, D, sz, num)
            elif (D[i] == ord(num[pos]) - ord('0')):
                val += calculate(pos + 1, tight, D, sz, num)
    else:
        for i in range(sz):
            val += calculate(pos + 1, tight, D, sz, num)
    dp[pos][tight] = val
    return dp[pos][tight]


def countNumbers(D, N, sz):
    num = convertToString(N)
    length = len(num)
    ans = calculate(0, 0, D, sz, num)
    for i in range(1, length):
        ans += calculate(i, 1, D, sz, num)
    return ans


if __name__ == "__main__":
    sz = 3
    D = [1, 4, 9]
    N = 10
    print(countNumbers(D, N, sz))

# Expected output:
3.0
# maximum sum of elements divisible by k from the given array | python3 implementation ; function to return the maximum sum divisible by k from elements of v ; check if sum of elements excluding the current one is divisible by k ; check if sum of elements including the current one is divisible by k ; store the maximum ; 

dp = [[-1 for i in range(1001)]for j in range(1001)]


def find_max(i, sum, v, k):
    if (i == len(v)):
        return 0
    if (dp[i][sum] != -1):
        return dp[i][sum]
    ans = 0
    if ((sum + find_max(i + 1, sum, v, k)) % k == 0):
        ans = find_max(i + 1, sum, v, k)
    if ((sum + v[i] + find_max(i + 1, (sum + v[i]) % k, v, k)) % k == 0):
        ans = max(ans, v[i] + find_max(i + 1, (sum + v[i]) % k, v, k))
    dp[i][sum] = ans
    return dp[i][sum]


if __name__ == '__main__':
    arr = [43, 1, 17, 26, 15]
    k = 16
    print(find_max(0, 0, arr, k))

# Expected output:
32
# find union and intersection of two unsorted arrays | function to find intersection ; when both are equal ; 
def intersection(a, b, n, m):
    i = 0
    j = 0
    while (i < n and j < m):
        if (a[i] > b[j]):
            j += 1
        else:
            if (b[j] > a[i]):
                i += 1
            else:
                print(a[i], end=" ")
                i += 1
                j += 1


if __name__ == "__main__":
    a = [1, 3, 2, 3, 4, 5, 5, 6]
    b = [3, 3, 5]
    n = len(a)
    m = len(b)
    a .sort()
    b .sort()
    intersection(a, b, n, m)

# Expected output:
3 3 5
# find union and intersection of two unsorted arrays | prints intersection of arr1 [ 0. . n1 - 1 ] and arr2 [ 0. . n2 - 1 ] ; iterate first array ; iterate second array ; prints union of arr1 [ 0. . n1 - 1 ] and arr2 [ 0. . n2 - 1 ] ; placezeroes function ; function to itreate array ; placevalue function ; hashing collision happened increment position and do recursive call ; 
def printUnion(v, ans, zero):
    zero1 = 0
    print("Union:", end="")
    for i in range(v):
        if ((zero == 0 and ans[i] == 0) or (ans[i] == 0 and zero1 > 0)):
            continue
        if (ans[i] == 0):
            zero1 += 1
        print(ans[i], end=",")


def placeZeros(v, ans, zero):
    if (zero == 2):
        print("0")
        d = [0]
        placeValue(d, ans, 0, 0, v)
    if (zero == 1):
        d = [0]
        placeValue(d, ans, 0, 0, v)


def iterateArray(a, v, ans, i):
    if (a[i] != 0):
        p = a[i] % v
        placeValue(a, ans, i, p, v)
    else:
        return 1
    return 0


def placeValue(a, ans, i, p, v):
    p = p % v
    if (ans[p] == 0):
        ans[p] = a[i]
    else:
        if (ans[p] == a[i]):
            print(a[i], end=",")
        else:
            p = p + 1
            placeValue(a, ans, i, p, v)

def findPosition(a, b):
    v = len(a) + len(b)
    ans = [0] * v
    zero1 = zero2 = 0
    print("Intersection :", end=" ")
    for i in range(len(a)):
        zero1 = iterateArray(a, v, ans, i)
    for j in range(len(b)):
        zero2 = iterateArray(b, v, ans, j)
    zero = zero1 + zero2
    placeZeros(v, ans, zero)
    printUnion(v, ans, zero)


a = [7, 1, 5, 2, 3, 6]
b = [3, 8, 6, 20, 7]
findPosition(a, b)

# Expected output:
Intersection : 3,6,7,Union:1,2,3,5,6,7,8,20,
# minimum number of coins that can generate all the values in the given range | function to return the count of minimum coins required ; to store the required sequence ; creating list of the sum of all previous bit values including that bit value ; 
def findCount(N):
    list = []
    sum = 0
    for i in range(0, 20):
        sum += 2 ** i
        list .append(sum)
    for value in list:
        if (value >= N):
            return (list .index(value) + 1)


N = 10
print(findCount(N))

# Expected output:
4
# sort an array of 0 s , 1 s and 2 s | function to sort array ; function to print array ; 
def sort012(a, arr_size):
    lo = 0
    hi = arr_size - 1
    mid = 0
    while mid <= hi:
        if a[mid] == 0:
            a[lo], a[mid] = a[mid], a[lo]
            lo = lo + 1
            mid = mid + 1
        elif a[mid] == 1:
            mid = mid + 1
        else:
            a[mid], a[hi] = a[hi], a[mid]
            hi = hi - 1
    return a


arr = [0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1]
arr_size = len(arr)
arr = sort012(arr, arr_size)
for k in arr:
    print(k, end=' ')

# Expected output:
0 0 0 0 0 1 1 1 1 1 2 2
# calculate the number of set bits for every number from 0 to n | function to find the count of set bits in all the integers from 0 to n ; dp [ i ] will store the count of set bits in i initialise the dp array ; count of set bits in 0 is 0 ; for every number starting from 1 ; if current number is even ; count of set bits in i is equal to the count of set bits in ( i / 2 ) ; if current element is odd ; count of set bits in i is equal to the count of set bits in ( i / 2 ) + 1 ; print the count of set bits in i ; 
def findSetBits(n):
    dp = [0] * (n + 1)
    print(dp[0], end=" ")
    for i in range(1, n + 1):
        if (i % 2 == 0):
            dp[i] = dp[i // 2]
        else:
            dp[i] = dp[i // 2] + 1
        print(dp[i], end=" ")


if __name__ == "__main__":
    n = 5
    findSetBits(n)

# Expected output:
0 1 1 2 1 2
# sort an array of 0 s , 1 s and 2 s | utility function to print contents of an array ; function to sort the array of 0 s , 1 s and 2 s ; count the number of 0 s , 1 s and 2 s in the array ; update the array ; store all the 0 s in the beginning ; then all the 1 s ; finally all the 2 s ; prthe sorted array ; 
def printArr(arr, n):
    for i in range(n):
        print(arr[i], end=" ")


def sortArr(arr, n):
    cnt0 = 0
    cnt1 = 0
    cnt2 = 0
    for i in range(n):
        if arr[i] == 0:
            cnt0 += 1
        elif arr[i] == 1:
            cnt1 += 1
        elif arr[i] == 2:
            cnt2 += 1
    i = 0
    while (cnt0 > 0):
        arr[i] = 0
        i += 1
        cnt0 -= 1
    while (cnt1 > 0):
        arr[i] = 1
        i += 1
        cnt1 -= 1
    while (cnt2 > 0):
        arr[i] = 2
        i += 1
        cnt2 -= 1
    printArr(arr, n)


arr = [0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1]
n = len(arr)
sortArr(arr, n)

# Expected output:
0 0 0 0 0 1 1 1 1 1 2 2
# Find the Minimum length Unsorted Subarray , sorting which makes the complete array sorted | Python3 program to find the Minimum length Unsorted Subarray , sorting which makes the complete array sorted ; step 1 ( a ) of above algo ; step 1 ( b ) of above algo ; step 2 ( a ) of above algo ; step 2 ( b ) of above algo ; step 2 ( c ) of above algo ; step 3 of above algo
def printUnsorted(arr, n):
    e = n - 1
    for s in range(0, n - 1):
        if arr[s] > arr[s + 1]:
            break
    if s == n - 1:
        print("The complete array is sorted")
        exit()
    e = n - 1
    while e > 0:
        if arr[e] < arr[e - 1]:
            break
        e -= 1
    max = arr[s]
    min = arr[s]
    for i in range(s + 1, e + 1):
        if arr[i] > max:
            max = arr[i]
        if arr[i] < min:
            min = arr[i]
    for i in range(s):
        if arr[i] > min:
            s = i
            break
    i = n - 1
    while i >= e + 1:
        if arr[i] < max:
            e = i
            break
        i -= 1
    print("The unsorted subarray which makes the given array")
    print("sorted lies between the indexes %d and %d" % (s, e))


arr = [10, 12, 20, 30, 25, 40, 32, 31, 35, 50, 60]
arr_size = len(arr)
printUnsorted(arr, arr_size)

# Expected output:
The unsorted subarray which makes the given array
sorted lies between the indexes 3 and 8
# count the number of possible triangles | function to count all possible triangles with arr [ ] elements ; count of triangles ; the three loops select three different values from array ; the innermost loop checks for the triangle property ; sum of two sides is greater than the third ; 
def findNumberOfTriangles(arr, n):
    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                if (arr[i] + arr[j] > arr[k] and arr[i] + arr[k]
                        > arr[j] and arr[k] + arr[j] > arr[i]):
                    count += 1
    return count


arr = [10, 21, 22, 100, 101, 200, 300]
size = len(arr)
print("Total number of triangles possible is",
      findNumberOfTriangles(arr, size))

# Expected output:
Total number of triangles possible is 6
# count the number of possible triangles | function to count all possible triangles with arr [ ] elements ; sort array and initialize count as 0 ; initialize count of triangles ; fix the first element . we need to run till n - 3 as the other two elements are selected from arr [ i + 1. . . n - 1 ] ; initialize index of the rightmost third element ; fix the second element ; find the rightmost element which is smaller than the sum of two fixed elements the important thing to note here is , we use the previous value of k . if value of arr [ i ] + arr [ j - 1 ] was greater than arr [ k ] , then arr [ i ] + arr [ j ] must be greater than k , because the array is sorted . ; total number of possible triangles that can be formed with the two fixed elements is k - j - 1. the two fixed elements are arr [ i ] and arr [ j ] . all elements between arr [ j + 1 ] to arr [ k - 1 ] can form a triangle with arr [ i ] and arr [ j ] . one is subtracted from k because k is incremented one extra in above while loop . k will always be greater than j . if j becomes equal to k , then above loop will increment k , because arr [ k ] + arr [ i ] is always greater than arr [ k ] ; 
def findnumberofTriangles(arr):
    n = len(arr)
    arr .sort()
    count = 0
    for i in range(0, n - 2):
        k = i + 2
        for j in range(i + 1, n):
            while (k < n and arr[i] + arr[j] > arr[k]):
                k += 1
            if (k > j):
                count += k - j - 1
    return count


arr = [10, 21, 22, 100, 101, 200, 300]
print("Number of Triangles:", findnumberofTriangles(arr))

# Expected output:
Number of Triangles: 6
# count the number of possible triangles | counttriangles function ; if it is possible with a [ l ] , a [ r ] and a [ i ] then it is also possible with a [ l + 1 ] . . a [ r - 1 ] , a [ r ] and a [ i ] ; checking for more possible solutions ; if not possible check for higher values of arr [ l ] ; 
def CountTriangles(A):
    n = len(A)
    A .sort()
    count = 0
    for i in range(n - 1, 0, -1):
        l = 0
        r = i - 1
        while (l < r):
            if (A[l] + A[r] > A[i]):
                count += r - l
                r -= 1
            else:
                l += 1
    print("No of possible solutions: ", count)


if __name__ == '__main__':
    A = [4, 3, 5, 7, 6]
    CountTriangles(A)

# Expected output:
No of possible solutions:  9
# flip minimum signs of array elements to get minimum sum of positive elements possible | function to return the minimum number of elements whose sign must be flipped to get the positive sum of array elements as close to 0 as possible ; boolean variable used for toggling between maps ; calculate the sum of all elements of the array ; initializing first map ( dp [ 0 ] ) with int_max because for i = 0 , there are no elements in the array to flip ; base case ; for toggling ; required sum is minimum non - negative so , we iterate from i = 0 to sum and find the first i where dp [ flag ^ 1 ] [ i ] != int_max ; in worst case we will flip max n - 1 elements ; 
def solve(A, n):
    dp = [[0 for i in range(2000)]for i in range(2000)]
    flag = 1
    sum = 0
    for i in range(n):
        sum += A[i]
    for i in range(-sum, sum + 1):
        dp[0][i] = 10 ** 9
    dp[0][0] = 0
    for i in range(1, n + 1):
        for j in range(-sum, sum + 1):
            dp[flag][j] = 10 ** 9
            if (j - A[i - 1] <= sum and j - A[i - 1] >= -sum):
                dp[flag][j] = dp[flag ^ 1][j - A[i - 1]]
            if (j + A[i - 1] <= sum and j + A[i - 1] >= -
                    sum and dp[flag ^ 1][j + A[i - 1]] != 10 ** 9):
                dp[flag][j] = min(dp[flag][j], dp[flag ^ 1][j + A[i - 1]] + 1)
        flag = flag ^ 1
    for i in range(sum + 1):
        if (dp[flag ^ 1][i] != 10 ** 9):
            return dp[flag ^ 1][i]
    return n - 1


arr = [10, 22, 9, 33, 21, 50, 41, 60]
n = len(arr)
print(solve(arr, n))

# Expected output:
3
# find number of pairs ( x , y ) in an array such that x ^ y > y ^ x | python3 program to find the number of pairs ( x , y ) in an array such that x ^ y > y ^ x ; function to return count of pairs with x as one element of the pair . it mainly looks for all values in y where x ^ y [ i ] > y [ i ] ^ x ; if x is 0 , then there cannot be any value in y such that x ^ y [ i ] > y [ i ] ^ x ; if x is 1 , then the number of pairs is equal to number of zeroes in y ; find number of elements in y [ ] with values greater than x , bisect . bisect_right gets address of first greater element in y [ 0. . n - 1 ] ; if we have reached here , then x must be greater than 1 , increase number of pairs for y = 0 and y = 1 ; decrease number of pairs for x = 2 and ( y = 4 or y = 3 ) ; increase number of pairs for x = 3 and y = 2 ; function to return count of pairs ( x , y ) such that x belongs to x , y belongs to y and x ^ y > y ^ x ; to store counts of 0 , 1 , 2 , 3 , and 4 in array y ; sort y so that we can do binary search in it ; initialize result ; take every element of x and count pairs with it ; 

import bisect


def count(x, Y, n, NoOfY):
    if x == 0:
        return 0
    if x == 1:
        return NoOfY[0]
    idx = bisect .bisect_right(Y, x)
    ans = n - idx
    ans += NoOfY[0] + NoOfY[1]
    if x == 2:
        ans -= NoOfY[3] + NoOfY[4]
    if x == 3:
        ans += NoOfY[2]
    return ans


def count_pairs(X, Y, m, n):
    NoOfY = [0] * 5
    for i in range(n):
        if Y[i] < 5:
            NoOfY[Y[i]] += 1
    Y .sort()
    total_pairs = 0
    for x in X:
        total_pairs += count(x, Y, n, NoOfY)
    return total_pairs


if __name__ == '__main__':
    X = [2, 1, 6]
    Y = [1, 5]
    print("Total pairs = ", count_pairs(X, Y, len(X), len(Y)))

# Expected output:
Total pairs =  3
# count all distinct pairs with difference equal to k | a simple program to count pairs with difference k ; pick all elements one by one ; see if there is a pair of this picked element ; 
def countPairsWithDiffK(arr, n, k):
    count = 0
    for i in range(0, n):
        for j in range(i + 1, n):
            if arr[i] - arr[j] == k or arr[j] - arr[i] == k:
                count += 1
    return count


arr = [1, 5, 3, 4, 2]
n = len(arr)
k = 3
print("Count of pairs with given diff is ", countPairsWithDiffK(arr, n, k))

# Expected output:
Count of pairs with given diff is  2
# count all distinct pairs with difference equal to k | standard binary search function ; returns count of pairs with difference k in arr [ ] of size n . ; sort array elements ; pick a first element point ; 
def binarySearch(arr, low, high, x):
    if (high >= low):
        mid = low + (high - low) // 2
        if x == arr[mid]:
            return (mid)
        elif (x > arr[mid]):
            return binarySearch(arr, (mid + 1), high, x)
        else:
            return binarySearch(arr, low, (mid - 1), x)
    return -1


def countPairsWithDiffK(arr, n, k):
    count = 0
    arr .sort()
    for i in range(0, n - 2):
        if (binarySearch(arr, i + 1, n - 1, arr[i] + k) != -1):
            count += 1
    return count


arr = [1, 5, 3, 4, 2]
n = len(arr)
k = 3
print("Count of pairs with given diff is ", countPairsWithDiffK(arr, n, k))

# Expected output:
Count of pairs with given diff is  2
# count all distinct pairs with difference equal to k | returns count of pairs with difference k in arr [ ] of size n . ; sort array elements ; arr [ r ] - arr [ l ] < sum ; 
def countPairsWithDiffK(arr, n, k):
    count = 0
    arr .sort()
    l = 0
    r = 0
    while r < n:
        if arr[r] - arr[l] == k:
            count += 1
            l += 1
            r += 1
        elif arr[r] - arr[l] > k:
            l += 1
        else:
            r += 1
    return count


if __name__ == '__main__':
    arr = [1, 5, 3, 4, 2]
    n = len(arr)
    k = 3
    print("Count of pairs with given diff is ", countPairsWithDiffK(arr, n, k))

# Expected output:
Count of pairs with given diff is  2
# count of sub | python3 implementation of the approach ; function to return the total number of required sub - sets ; variable to store total elements which on dividing by 3 give remainder 0 , 1 and 2 respectively ; create a dp table ; process for n states and store the sum ( mod 3 ) for 0 , 1 and 2 ; use of mod for large numbers ; final answer store at dp [ n - 1 ] [ 0 ] ; 

import math


def totalSubSets(n, l, r):
    MOD = 1000000007
    zero = (math .floor(r / 3) - math .ceil(l / 3) + 1)
    one = (math .floor((r - 1) / 3) - math .ceil((l - 1) / 3) + 1)
    two = (math .floor((r - 2) / 3) - math .ceil((l - 2) / 3) + 1)
    dp = [[0 for x in range(3)]for y in range(n)]
    dp[0][0] = zero
    dp[0][1] = one
    dp[0][2] = two
    for i in range(1, n):
        dp[i][0] = ((dp[i - 1][0] * zero) + (dp[i - 1][1]
                    * two) + (dp[i - 1][2] * one)) % MOD
        dp[i][1] = ((dp[i - 1][0] * one) + (dp[i - 1][1]
                    * zero) + (dp[i - 1][2] * two)) % MOD
        dp[i][2] = ((dp[i - 1][0] * two) + (dp[i - 1][1] * one) +
                    (dp[i - 1][2] * zero)) % MOD
    return dp[n - 1][0]


n = 5
l = 10
r = 100
print(totalSubSets(n, l, r))

# Expected output:
80107136