giulio98/xlcost-single-prompt huggingface dataset:
# count of numbers in range where the number does not contain more than k non zero digits | this function returns the count of required numbers from 0 to num ; last position ; if count of non zero digits is less than or equal to k ; if this result is already computed simply return it ; maximum limit upto which we can place digit . if tight is 1 , means number has already become smaller so we can place any digit , otherwise num [ pos ] ; if the current digit is nonzero increment currcnt ; at this position , number becomes smaller ; next recursive call ; this function converts a number into its digit vector and uses above function to compute the answer ; initialize dp ; 
def countInRangeUtil(pos, cnt, tight, num):
    if pos == len(num):
        if cnt <= K:
            return 1
        return 0
    if dp[pos][cnt][tight] != -1:
        return dp[pos][cnt][tight]
    ans = 0
    limit = 9 if tight else num[pos]
    for dig in range(limit + 1):
        currCnt = cnt
        if dig != 0:
            currCnt += 1
        currTight = tight
        if dig < num[pos]:
            currTight = 1
        ans += countInRangeUtil(pos + 1, currCnt, currTight, num)
    dp[pos][cnt][tight] = ans
    return dp[pos][cnt][tight]


def countInRange(x):
    global dp, K, M
    num = []
    while x:
        num .append(x % 10)
        x //= 10
    num .reverse()
    dp = [[[-1, -1]for i in range(M)]for j in range(M)]
    return countInRangeUtil(0, 0, 0, num)


if __name__ == "__main__":
    dp = []
    M = 20
    K = 0
    L = 1
    R = 1000
    K = 3
    print(countInRange(R) - countInRange(L - 1))
    L = 9995
    R = 10005
    K = 2
    print(countInRange(R) - countInRange(L - 1))

# Expected output:
1000
6
# balanced expressions such that 

N = 1000
dp = [[-1 for x in range(N)]for y in range(N)]
adj = [1, 0, 0, 0]


def find(index, openbrk, n):
    if (openbrk < 0):
        return 0
    if (index == n):
        if (openbrk == 0):
            return 1
        else:
            return 0
    if (dp[index][openbrk] != -1):
        return dp[index][openbrk]
    if (adj[index] == 1):
        dp[index][openbrk] = find(index + 1, openbrk + 1, n)
    else:
        dp[index][openbrk] = (
            find(
                index +
                1,
                openbrk +
                1,
                n) +
            find(
                index +
                1,
                openbrk -
                1,
                n))
    return dp[index][openbrk]


n = 2
print(find(0, 0, 2 * n))

# Expected output:
2
# maximize array elements upto given number | variable to store maximum value that can be obtained . ; if entire array is traversed , then compare current value in num to overall maximum obtained so far . ; case 1 : subtract current element from value so far if result is greater than or equal to zero . ; case 2 : add current element to value so far if result is less than or equal to maxlimit . ; def to find maximum possible value that can be obtained using array elements and given number . ; variable to store current index position . ; call to utility def to find maximum possible value that can be obtained . ; 

ans = 0


def findMaxValUtil(arr, n, num, maxLimit, ind):
    global ans
    if (ind == n):
        ans = max(ans, num)
        return
    if (num - arr[ind] >= 0):
        findMaxValUtil(arr, n, num - arr[ind], maxLimit, ind + 1)
    if (num + arr[ind] <= maxLimit):
        findMaxValUtil(arr, n, num + arr[ind], maxLimit, ind + 1)


def findMaxVal(arr, n, num, maxLimit):
    global ans
    ind = 0
    findMaxValUtil(arr, n, num, maxLimit, ind)
    return ans


num = 1
arr = [3, 10, 6, 4, 5]
n = len(arr)
maxLimit = 15
print(findMaxVal(arr, n, num, maxLimit))

# Expected output:
9
# print equal sum sets of array ( partition problem ) | set 1 | function to print the equal sum sets of the array . ; print set 1. ; print set 2. ; utility function to find the sets of the array which have equal sum . ; if entire array is traversed , compare both the sums . ; if sums are equal print both sets and return true to show sets are found . ; if sums are not equal then return sets are not found . ; add current element to set 1. ; recursive call after adding current element to set 1. ; if this inclusion results in an equal sum sets partition then return true to show desired sets are found . ; if not then backtrack by removing current element from set1 and include it in set 2. ; recursive call after including current element to set 2 and removing the element from set 2 if it returns false ; return true if array arr can be partitioned into two equal sum sets or not . ; calculate sum of elements in array . ; if sum is odd then array cannot be partitioned . ; declare vectors to store both the sets . ; find both the sets . ; 
def printSets(set1, set2):
    for i in range(0, len(set1)):
        print("{} ".format(set1[i]), end="")
    print("")
    for i in range(0, len(set2)):
        print("{} ".format(set2[i]), end="")
    print("")


def findSets(arr, n, set1, set2, sum1, sum2, pos):
    if (pos == n):
        if (sum1 == sum2):
            printSets(set1, set2)
            return True
        else:
            return False
    set1 .append(arr[pos])
    res = findSets(arr, n, set1, set2, sum1 + arr[pos], sum2, pos + 1)
    if (res):
        return res
    set1 .pop()
    set2 .append(arr[pos])
    res = findSets(arr, n, set1, set2, sum1, sum2 + arr[pos], pos + 1)
    if not res:
        set2 .pop()
    return res


def isPartitionPoss(arr, n):
    sum = 0
    for i in range(0, n):
        sum += arr[i]
    if (sum % 2 != 0):
        return False
    set1 = []
    set2 = []
    return findSets(arr, n, set1, set2, 0, 0, 0)


arr = [5, 5, 1, 11]
n = len(arr)
if (isPartitionPoss(arr, n) == False):
    print("-1")

# Expected output:
5 5 1 
11
# maximum subarray sum in o ( n ) using prefix sum | python3 program to find out maximum subarray sum in linear time using prefix sum . ; function to compute maximum subarray sum in linear time . ; initialize minimum prefix sum to 0. ; initialize maximum subarray sum so far to - infinity . ; initialize and compute the prefix sum array . ; loop through the array keep track of minimum prefix sum so far and maximum subarray sum . ; test case 1 ; 

import math


def maximumSumSubarray(arr, n):
    min_prefix_sum = 0
    res = -math .inf
    prefix_sum = []
    prefix_sum .append(arr[0])
    for i in range(1, n):
        prefix_sum .append(prefix_sum[i - 1] + arr[i])
    for i in range(n):
        res = max(res, prefix_sum[i] - min_prefix_sum)
        min_prefix_sum = min(min_prefix_sum, prefix_sum[i])
    return res


arr1 = [-2, -3, 4, -1, -2, 1, 5, -3]
n1 = len(arr1)
print(maximumSumSubarray(arr1, n1))
arr2 = [4, -8, 9, -4, 1, -8, -1, 6]
n2 = len(arr2)
print(maximumSumSubarray(arr2, n2))

# Expected output:
7
9
# counting numbers of n digits that are monotone | considering all possible digits as { 1 , 2 , 3 , . .9 } ; dp [ i ] [ j ] is going to store monotone numbers of length i + 1 considering j + 1 digits . ; unit length numbers ; single digit numbers ; filling rest of the entries in bottom up manner . ; 

DP_s = 9


def getNumMonotone(ln):
    DP = [[0] * DP_s for i in range(ln)]
    for i in range(DP_s):
        DP[0][i] = i + 1
    for i in range(ln):
        DP[i][0] = 1
    for i in range(1, ln):
        for j in range(1, DP_s):
            DP[i][j] = DP[i - 1][j] + DP[i][j - 1]
    return DP[ln - 1][DP_s - 1]


print(getNumMonotone(10))

# Expected output:
43758
# newman | to declare array import module array ; to store values of sequence in array ; 

import array


def sequence(n):
    f = array .array('i', [0, 1, 1])
    for i in range(3, n + 1):
        r = f[f[i - 1]] + f[i - f[i - 1]]
        f .append(r)
    return r


def main():
    n = 10
    print(sequence(n))


if __name__ == '__main__':
    main()

# Expected output:
6
# hosoya 's triangle | python3 code to print hosoya 's triangle of height n. ; base case ; recursive step ; print the hosoya triangle of height n . ; 
def Hosoya(n, m):
    if ((n == 0 and m == 0) or (n == 1 and m == 0) or (
            n == 1 and m == 1) or (n == 2 and m == 1)):
        return 1
    if n > m:
        return Hosoya(n - 1, m)
        +Hosoya(n - 2, m)
    elif m == n:
        return Hosoya(n - 1, m - 1)
        +Hosoya(n - 2, m - 2)
    else:
        return 0


def printHosoya(n):
    for i in range(n):
        for j in range(i + 1):
            print(Hosoya(i, j), end=" ")
        print("",  end="")


n = 5
printHosoya(n)

# Expected output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
# eulerian number | return euleriannumber a ( n , m ) ; 
def eulerian(n, m):
    if (m >= n or n == 0):
        return 0
    if (m == 0):
        return 1
    return ((n - m) * eulerian(n - 1, m - 1) + (m + 1) * eulerian(n - 1, m))


n = 3
m = 1
print(eulerian(n, m))

# Expected output:
4
# largest divisible pairs subset | ''function to find the longest subsequence ; dp [ i ] is going to store size of largest divisible subset beginning with a [ i ] . ; since last element is largest , d [ n - 1 ] is 1 ; fill values for smaller elements ; find all multiples of a [ i ] and consider the multiple that has largest subset beginning with it . ; return maximum value from dp [ ] ; 
def largestSubset(a, n):
    dp = [0 for i in range(n)]
    dp[n - 1] = 1
    for i in range(n - 2, -1, -1):
        mxm = 0
        for j in range(i + 1, n):
            if a[j] % a[i] == 0 or a[i] % a[j] == 0:
                mxm = max(mxm, dp[j])
        dp[i] = 1 + mxm
    return max(dp)


a = [1, 3, 6, 13, 17, 18]
n = len(a)
print(largestSubset(a, n))

# Expected output:
4
# friends pairing problem | returns count of ways n people can remain single or paired up . ; filling dp [ ] in bottom - up manner using recursive formula explained above . ; 
def countFriendsPairings(n):
    dp = [0 for i in range(n + 1)]
    for i in range(n + 1):
        if (i <= 2):
            dp[i] = i
        else:
            dp[i] = dp[i - 1] + (i - 1) * dp[i - 2]
    return dp[n]


n = 4
print(countFriendsPairings(n))

# Expected output:
10
# friends pairing problem | returns count of ways n people can remain single or paired up . ; 
def countFriendsPairings(n):
    a, b, c = 1, 2, 0
    if (n <= 2):
        return n
    for i in range(3, n + 1):
        c = b + (i - 1) * a
        a = b
        b = c
    return c


n = 4
print(countFriendsPairings(n))

# Expected output:
10
# check whether row or column swaps produce maximum size binary sub | python3 program to find maximum binary sub - matrix with row swaps and column swaps . ; precompute the number of consecutive 1 below the ( i , j ) in j - th column and the number of consecutive 1 s on right side of ( i , j ) in i - th row . ; travesing the 2d matrix from top - right . ; if ( i , j ) contain 0 , do nothing ; counting consecutive 1 on right side ; travesing the 2d matrix from bottom - left . ; if ( i , j ) contain 0 , do nothing ; counting consecutive 1 down to ( i , j ) . ; return maximum size submatrix with row swap allowed . ; copying the column ; sort the copied array ; find maximum submatrix size . ; return maximum size submatrix with column swap allowed . ; copying the row . ; sort the copied array ; find maximum submatrix size . ; solving for row swap and column swap ; comparing both . ; 

R, C = 5, 3


def precompute(mat, ryt, dwn):
    for j in range(C - 1, -1, -1):
        for i in range(0, R):
            if mat[i][j] == 0:
                ryt[i][j] = 0
            else:
                ryt[i][j] = ryt[i][j + 1] + 1
    for i in range(R - 1, -1, -1):
        for j in range(0, C):
            if mat[i][j] == 0:
                dwn[i][j] = 0
            else:
                dwn[i][j] = dwn[i + 1][j] + 1


def solveRowSwap(ryt):
    b = [0] * R
    ans = 0
    for j in range(0, C):
        for i in range(0, R):
            b[i] = ryt[i][j]
        b .sort()
        for i in range(0, R):
            ans = max(ans, b[i] * (R - i))
    return ans


def solveColumnSwap(dwn):
    b = [0] * C
    ans = 0
    for i in range(0, R):
        for j in range(0, C):
            b[j] = dwn[i][j]
        b .sort()
        for i in range(0, C):
            ans = max(ans, b[i] * (C - i))
    return ans


def findMax1s(mat):
    ryt = [[0 for i in range(C + 2)]for j in range(R + 2)]
    dwn = [[0 for i in range(C + 2)]for j in range(R + 2)]
    precompute(mat, ryt, dwn)
    rswap = solveRowSwap(ryt)
    cswap = solveColumnSwap(dwn)
    if rswap > cswap:
        print("RowSwap", rswap)
    else:
        print("ColumnSwap", cswap)


if __name__ == "__main__":
    mat = [[0, 0, 0], [1, 1, 0], [1, 1, 0], [0, 0, 0], [1, 1, 0]]
    findMax1s(mat)

# Expected output:
RowSwap 6
# lcs ( longest common subsequence ) of three strings | returns length of lcs for x [ 0. . m - 1 ] , y [ 0. . n - 1 ] and z [ 0. . o - 1 ] ; following steps build l [ m + 1 ] [ n + 1 ] [ o + 1 ] in bottom up fashion . note that l [ i ] [ j ] [ k ] contains length of lcs of x [ 0. . i - 1 ] and y [ 0. . j - 1 ] and z [ 0. . ... k - 1 ] ; l [ m ] [ n ] [ o ] contains length of lcs for x [ 0. . n - 1 ] and y [ 0. . m - 1 ] and z [ 0. . o - 1 ] ; 
def lcsOf3(X, Y, Z, m, n, o):
    L = [[[0 for i in range(o + 1)]for j in range(n + 1)]for k in range(m + 1)]
    for i in range(m + 1):
        for j in range(n + 1):
            for k in range(o + 1):
                if (i == 0 or j == 0 or k == 0):
                    L[i][j][k] = 0
                elif (X[i - 1] == Y[j - 1] and X[i - 1] == Z[k - 1]):
                    L[i][j][k] = L[i - 1][j - 1][k - 1] + 1
                else:
                    L[i][j][k] = max(
                        max(L[i - 1][j][k], L[i][j - 1][k]), L[i][j][k - 1])
    return L[m][n][o]


X = 'AGGT12'
Y = '12TXAYB'
Z = '12XBA'
m = len(X)
n = len(Y)
o = len(Z)
print('Length of LCS is', lcsOf3(X, Y, Z, m, n, o))

# Expected output:
Length of LCS is 2
# longest subsequence such that difference between adjacents is one | ''
def longestSubsequence(A, N):
    L = [1] * N
    hm = {}
    for i in range(1, N):
        if abs(A[i] - A[i - 1]) == 1:
            L[i] = 1 + L[i - 1]
        elif hm .get(A[i] + 1, 0) or hm .get(A[i] - 1, 0):
            L[i] = 1 + max(hm .get(A[i] + 1, 0), hm .get(A[i] - 1, 0))
        hm[A[i]] = L[i]
    return max(L)


A = [1, 2, 3, 4, 5, 3, 2]
N = len(A)
print(longestSubsequence(A, N))

# Expected output:
6
# printing shortest common supersequence | returns shortest supersequence of x and y ; dp [ i ] [ j ] contains length of shortest supersequence for x [ 0. . i - 1 ] and y [ 0. . j - 1 ] ; fill table in bottom up manner ; below steps follow recurrence relation ; string to store the shortest supersequence ; start from the bottom right corner and one by one push characters in output string ; if current character in x and y are same , then current character is part of shortest supersequence ; put current character in result ; reduce values of i , j and index ; if current character in x and y are different ; put current character of y in result ; reduce values of j and index ; put current character of x in result ; reduce values of i and index ; if y reaches its end , put remaining characters of x in the result string ; if x reaches its end , put remaining characters of y in the result string ; reverse the string and return it ; 
def printShortestSuperSeq(x, y):
    m = len(x)
    n = len(y)
    dp = [[0 for i in range(n + 1)]for j in range(n + 1)]
    for i in range(m + 1):
        for j in range(n + 1):
            if i == 0:
                dp[i][j] = j
            elif j == 0:
                dp[i][j] = i
            elif x[i - 1] == y[j - 1]:
                dp[i][j] = 1 + dp[i - 1][j - 1]
            else:
                dp[i][j] = 1 + min(dp[i - 1][j], dp[i][j - 1])
    string = ""
    i = m
    j = n
    while i > 0 and j > 0:
        if x[i - 1] == y[j - 1]:
            string += x[i - 1]
            i -= 1
            j -= 1
        elif dp[i - 1][j] > dp[i][j - 1]:
            string += y[j - 1]
            j -= 1
        else:
            string += x[i - 1]
            i -= 1
    while i > 0:
        string += x[i - 1]
        i -= 1
    while j > 0:
        string += y[j - 1]
        j -= 1
    string = list(string)
    string .reverse()
    return ''.join(string)


if __name__ == "__main__":
    x = "AGGTAB"
    y = "GXTXAYB"
    print(printShortestSuperSeq(x, y))

# Expected output:
AGXGTXAYB
# longest repeating subsequence | this function mainly returns lcs ( str , str ) with a condition that same characters at same index are not considered . ; create and initialize dp table ; fill dp table ( similar to lcs loops ) ; if characters match and indexes are not same ; if characters do not match ; 
def findLongestRepeatingSubSeq(str):
    n = len(str)
    dp = [[0 for i in range(n + 1)]for j in range(n + 1)]
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            if (str[i - 1] == str[j - 1] and i != j):
                dp[i][j] = 1 + dp[i - 1][j - 1]
            else:
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j])
    return dp[n][n]


if __name__ == '__main__':
    str = "aabb"
    print(
        "The length of the largest subsequence that repeats itself is : ",
        findLongestRepeatingSubSeq(str))

# Expected output:
The length of the largest subsequence that repeats itself is :  2
# count all possible paths from top left to bottom right of a mxn matrix | returns count of possible paths to reach cell at row number m and column number n from the topmost leftmost cell ( cell at 1 , 1 ) ; create a 1d array to store results of subproblems ; 
def numberOfPaths(p, q):
    dp = [1 for i in range(q)]
    for i in range(p - 1):
        for j in range(1, q):
            dp[j] += dp[j - 1]
    return dp[q - 1]


print(numberOfPaths(3, 3))

# Expected output:
6
# minimum numbers to be appended such that mean of array is equal to 1 | function to calculate minimum number of operations ; storing sum of array arr [ ] ; 
def minumumOperation(N, arr):
    sum_arr = sum(arr)
    if sum_arr >= N:
        print(sum_arr - N)
    else:
        print(1)


N = 4
arr = [8, 4, 6, 2]
minumumOperation(N, arr)

# Expected output:
16
# find nth term of series 1 , 4 , 15 , 72 , 420. . . | function to find factorial of n with recursion ; base condition ; use recursion ; calculate nth term of series ; 
def factorial(N):
    if N == 0 or N == 1:
        return 1
    return N * factorial(N - 1)


def nthTerm(N):
    return (factorial(N) * (N + 2) // 2)


N = 6
print(nthTerm(N))

# Expected output:
2880
# check if a string is substring of another | python program for the above approach ; iterate from 0 to len - 1 ; 
def Substr(Str, target):
    t = 0
    Len = len(Str)
    i = 0
    for i in range(Len):
        if (t == len(target)):
            break
        if (Str[i] == target[t]):
            t += 1
        else:
            t = 0
    if (t < len(target)):
        return -1
    else:
        return (i - t)


print(Substr("GeeksForGeeks", "Fr"))
print(Substr("GeeksForGeeks", "For"))

# Expected output:
-1
5
# count anagrams having first character as a consonant and no pair of consonants or vowels placed adjacently | ''python 3 program for the above approach include <bits/stdc++.h> ; ''function to compute factorials till n ; '' iterate in the range [1, n] ; '' update ans to ans*i ; ''store the value of ans  in fac[i] ; ''function to check whether the current character is a vowel or not ; ''function to count the number of anagrams of s satisfying the given condition ; '' store the factorials upto n ; '' function call to generate  all factorials upto n ; '' create a hashmap to store  frequencies of all characters ; '' store the count of  vowels and consonants ; '' iterate through all  characters in the string ; ''update the frequency  of current character ; ''check if the character  is vowel or consonant ; '' check if c==v+1 or c==v ; ''store the denominator ; '' calculate the denominator of the expression ; '' multiply denominator by factorial of counts of all letters ; '' store the numerator ; '' store the answer by dividing  numerator by denominator ; '' print the answer ; ''otherwise, print 0 ; ''

mod = 1000000007
N = 1000001

fac = {}


def Precomputefact():
    global fac
    ans = 1
    for i in range(1, N+1, 1):
        ans = (ans * i) % mod
        fac[i] = ans

    return


def isVowel(a):
    if (a == 'A' or a == 'E' or a == 'I' or a == 'O' or a == 'U'):
        return True
    else:
        return False


def countAnagrams(s, n):
    global fac
    Precomputefact()
    count = {}
    vo = 0
    co = 0
    for i in range(n):
        if s[i] in count:
            count[s[i]] += 1
        else:
            count[s[i]] = 1
        if (isVowel(s[i])):
            vo += 1
        else:
            co += 1
    if ((co == vo + 1) or (co == vo)):
        deno = 1
        for key, value in count.items():
            deno = (deno * fac[value]) % mod
        nume = fac[co] % mod
        nume = (nume * fac[vo]) % mod
        ans = nume // deno
        print(ans)
    else:
        print(0)


if __name__ == '__main__':
    S = "GADO"
    l = len(S)
    countAnagrams(S, l)

# Expected output:
4
# modify string by increasing each character by its distance from the end of the word | function to transform and return the transformed word ; stores resulting word ; iterate over the word ; add the position value to the letter ; convert it back to character ; add it to the string ; function to transform the given string ; size of string ; stores resultant string ; iterate over given string ; end of word is reached ; print ( s [ j : j + i ] ) append the word ; for the last word ; 
def util(sub):
    n = len(sub)
    i = 0
    ret = ""
    while i < n:
        t = (ord(sub[i]) - 97) + n - 1 - i
        ch = chr(t % 26 + 97)
        ret = ret + ch
        i = i + 1
    return ret


def manipulate(s):
    n = len(s)
    i = 0
    j = 0
    res = ""
    while i < n:
        if s[i] == ' ':
            res += util(s[j:j + i])
            res = res + " "
            j = i + 1
            i = j + 1
        else:
            i = i + 1
    res = res + util(s[j:j + i])
    print(res)


if __name__ == "__main__":
    s = "acm fkz"
    manipulate(s)

# Expected output:
cdm hlz
# check if given words are present in a string | helper function to the finding bigstring ; initialize leftbigidx and rightbigidx and leftsmallidx variables ; iterate until leftbigidx variable reaches less than or equal to rightbigidx ; check if bigstring [ leftbigidx ] is not equal to smallstring [ leftsmallidx ] or check if bigstring [ rightbigidx ] is not equal to smallstring [ rightsmallidx ] than return false otherwise increment leftbigidx and leftsmallidx decrement rightbigidx and rightsmallidx ; function to the bigstring ; iterate in the bigstring ; check if length of smallstring + i is greater than the length of bigstring ; call the function isinbigstringhelper ; function to the multistringsearch ; iterate in the smallstring ; calling the isinbigstring function ; 
def isInBigStringHelper(bigString, smallString, startIdx):
    leftBigIdx = startIdx
    rightBigIdx = startIdx + len(smallString) - 1
    leftSmallIdx = 0
    rightSmallIdx = len(smallString) - 1
    while (leftBigIdx <= rightBigIdx):
        if (bigString[leftBigIdx] != smallString[leftSmallIdx]
                or bigString[rightBigIdx] != smallString[rightSmallIdx]):
            return False
        leftBigIdx += 1
        rightBigIdx -= 1
        leftSmallIdx += 1
        rightSmallIdx -= 1
    return True


def isInBigString(bigString, smallString):
    for i in range(len(bigString)):
        if (i + len(smallString) > len(bigString)):
            break
        if (isInBigStringHelper(bigString, smallString, i)):
            return True
    return False


def multiStringSearch(bigString, smallStrings):
    solution = []
    for smallString in smallStrings:
        solution .append(isInBigString(bigString, smallString))
    return solution


if __name__ == '__main__':
    str1 = "this is a big string"
    substr = ["this", "yo", "is", "a", "bigger", "string", "kappa"]
    ans = multiStringSearch(str1, substr)
    for i in range(len(ans)):
        if (ans[i] == 1):
            print("true", end=" ")
        else:
            print("false", end=" ")

# Expected output:
true false true true false true false