dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
from sys import maxsize
def maxSubArraySum ( a , size ) :
    max_so_far = - maxsize - 1
    max_ending_here = 0
    start = 0
    end = 0
    s = 0
    for i in range ( 0 , size ) :
        max_ending_here += a [ i ]
        if max_so_far < max_ending_here :
            max_so_far = max_ending_here
            start = s
            end = i
        if max_ending_here < 0 :
            max_ending_here = 0
            s = i + 1
    print ( " Maximum ▁ contiguous ▁ sum ▁ is ▁ % d " % ( max_so_far ) )
    print ( " Starting ▁ Index ▁ % d " % ( start ) )
    print ( " Ending ▁ Index ▁ % d " % ( end ) )
a = [ - 2 , - 3 , 4 , - 1 , - 2 , 1 , 5 , - 3 ]
maxSubArraySum ( a , len ( a ) )

Index/key variables: i
Accumulator variables: max_ending_here
Iterator variables: i
Python program:
def NextFit ( blockSize , m , processSize , n ) :
    allocation = [ - 1 ] * n
    j = 0
    for i in range ( n ) :
        while j < m :
            if blockSize [ j ] >= processSize [ i ] :
                allocation [ i ] = j
                blockSize [ j ] -= processSize [ i ]
                break
            j = ( j + 1 ) % m
    print ( " Process ▁ No . ▁ Process ▁ Size ▁ Block ▁ no . " )
    for i in range ( n ) :
        print ( i + 1 , " ▁ " , processSize [ i ] , end = " ▁ " )
        if allocation [ i ] != - 1 :
            print ( allocation [ i ] + 1 )
        else :
            print ( " Not ▁ Allocated " )
if __name__ == ' _ _ main _ _ ' :
    blockSize = [ 5 , 10 , 20 ]
    processSize = [ 10 , 20 , 5 ]
    m = len ( blockSize )
    n = len ( processSize )
    NextFit ( blockSize , m , processSize , n )

Index/key variables: i, j
Iterator variables: i
Python program:
class newnode :
    def __init__ ( self , data ) :
        self . data = data
        self . left = self . right = None
def printPathUtil ( node , s , root_data ) :
    if ( node == None ) :
        return False
    rem = root_data - node . data
    if rem in s :
        return True
    s . add ( node . data )
    res = printPathUtil ( node . left , s , root_data ) or printPathUtil ( node . right , s , root_data )
    s . remove ( node . data )
    return res
def isPathSum ( root ) :
    s = set ( )
    return printPathUtil ( root . left , s , root . data ) or printPathUtil ( root . right , s , root . data )
if __name__ == ' _ _ main _ _ ' :
    root = newnode ( 8 )
    root . left = newnode ( 5 )
    root . right = newnode ( 4 )
    root . left . left = newnode ( 9 )
    root . left . right = newnode ( 7 )
    root . left . right . left = newnode ( 1 )
    root . left . right . right = newnode ( 12 )
    root . left . right . right . right = newnode ( 2 )
    root . right . right = newnode ( 11 )
    root . right . right . left = newnode ( 3 )
    print ( " Yes " ) if ( isPathSum ( root ) ) else print ( " No " )

Class/struct names: newnode
Python program:
def findMinAvgSubarray ( arr , n , k ) :
    if ( n < k ) : return 0
    res_index = 0
    curr_sum = 0
    for i in range ( k ) :
        curr_sum += arr [ i ]
    min_sum = curr_sum
    for i in range ( k , n ) :
        curr_sum += arr [ i ] - arr [ i - k ]
        if ( curr_sum < min_sum ) :
            min_sum = curr_sum
            res_index = ( i - k + 1 )
    print ( " Subarray ▁ between ▁ [ " , res_index , " , ▁ " , ( res_index + k - 1 ) , " ] ▁ has ▁ minimum ▁ average " )
arr = [ 3 , 7 , 90 , 20 , 10 , 50 , 40 ]
k = 3
n = len ( arr )
findMinAvgSubarray ( arr , n , k )

Index/key variables: i
Accumulator variables: curr_sum
Iterator variables: i
Python program:
def findLargest ( m , s ) :
    if ( s == 0 ) :
        if ( m == 1 ) :
            print ( " Largest ▁ number ▁ is ▁ " , "0" , end = " " )
        else :
            print ( " Not ▁ possible " , end = " " )
        return
    if ( s > 9 * m ) :
        print ( " Not ▁ possible " , end = " " )
        return
    res = [ 0 ] * m
    for i in range ( 0 , m ) :
        if ( s >= 9 ) :
            res [ i ] = 9
            s = s - 9
        else :
            res [ i ] = s
            s = 0
    print ( " Largest ▁ number ▁ is ▁ " , end = " " )
    for i in range ( 0 , m ) :
        print ( res [ i ] , end = " " )
s = 9
m = 2
findLargest ( m , s )

Index/key variables: i
Iterator variables: i
Python program:
def minJumps ( arr , l , h ) :
    if ( h == l ) :
        return 0
    if ( arr [ l ] == 0 ) :
        return float ( ' inf ' )
    min = float ( ' inf ' )
    for i in range ( l + 1 , h + 1 ) :
        if ( i < l + arr [ l ] + 1 ) :
            jumps = minJumps ( arr , i , h )
            if ( jumps != float ( ' inf ' ) and jumps + 1 < min ) :
                min = jumps + 1
    return min
arr = [ 1 , 3 , 6 , 3 , 2 , 3 , 6 , 8 , 9 , 5 ]
n = len ( arr )
print ( ' Minimum ▁ number ▁ of ▁ jumps ▁ to ▁ reach ' , ' end ▁ is ' , minJumps ( arr , 0 , n - 1 ) )

Index/key variables: l
Iterator variables: i
Python program:
dp = [ [ - 1 for i in range ( 3001 ) ] for j in range ( 1001 ) ]
def recBananaCnt ( A , B , C ) :
    if ( B <= A ) :
        return 0
    if ( B <= C ) :
        return B - A
    if ( A == 0 ) :
        return B
    if ( dp [ A ] [ B ] != - 1 ) :
        return dp [ A ] [ B ]
    maxCount = - 2 ** 32
    tripCount = ( ( 2 * B ) // C ) - 1 if ( B % C == 0 ) else ( ( 2 * B ) // C ) + 1
    for i in range ( 1 , A + 1 ) :
        curCount = recBananaCnt ( A - i , B - tripCount * i , C )
        if ( curCount > maxCount ) :
            maxCount = curCount
            dp [ A ] [ B ] = maxCount
    return maxCount
def maxBananaCnt ( A , B , C ) :
    return recBananaCnt ( A , B , C )
A = 1000
B = 3000
C = 1000
print ( maxBananaCnt ( A , B , C ) )

Index/key variables: A, B
Iterator variables: i
Python program:
def minJumps ( arr , n ) :
    jumps = [ 0 for i in range ( n ) ]
    for i in range ( n - 2 , - 1 , - 1 ) :
        if ( arr [ i ] == 0 ) :
            jumps [ i ] = float ( ' inf ' )
        elif ( arr [ i ] >= n - i - 1 ) :
            jumps [ i ] = 1
        else :
            min = float ( ' inf ' )
            for j in range ( i + 1 , n ) :
                if ( j <= arr [ i ] + i ) :
                    if ( min > jumps [ j ] ) :
                        min = jumps [ j ]
            if ( min != float ( ' inf ' ) ) :
                jumps [ i ] = min + 1
            else :
                jumps [ i ] = min
    return jumps [ 0 ]
arr = [ 1 , 3 , 6 , 3 , 2 , 3 , 6 , 8 , 9 , 5 ]
n = len ( arr )
print ( ' Minimum ▁ number ▁ of ▁ jumps ▁ to ▁ reach ' , ' end ▁ is ' , minJumps ( arr , n - 1 ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
dp = [ [ - 1 ] * 100 ] * 1000
prime = [ True ] * 1005
def SieveOfEratosthenes ( n ) :
    prime [ 0 ] = prime [ 1 ] = False
    p = 2
    while ( p * p <= n ) :
        if ( prime [ p ] == True ) :
            for i in range ( p * p , n + 1 , p ) :
                prime [ i ] = False
        p += 1
def countOfNumbers ( index , sum , N ) :
    if ( index == N + 1 ) :
        if ( prime [ sum ] == True ) :
            return 1
        return 0
    val = dp [ index ] [ sum ]
    if ( val != - 1 ) :
        return val
    val = 0
    if ( index == 1 ) :
        for digit in range ( ( ( 0 , 1 ) [ N == 1 ] ) + 1 , 10 , 1 ) :
            val += countOfNumbers ( index + 1 , sum + digit , N )
    else :
        for digit in range ( 0 , 10 , 1 ) :
            val += countOfNumbers ( index + 1 , sum + digit , N )
    return val
SieveOfEratosthenes ( 1000 )
N = 6
print ( countOfNumbers ( 1 , 0 , N ) )

Index/key variables: i, index, p, sum
Accumulator variables: val
Iterator variables: digit, i
Python program:
memo = { }
def dfs ( V , left , K ) :
    q = 0
    v = [ str ( int ) for int in V ]
    key = " , " . join ( v )
    key += str ( left )
    if key in memo :
        return memo [ key ]
    elif left == 0 :
        for i in range ( 1 , K ) :
            if V [ i ] > 0 :
                V [ i ] -= 1
                q = max ( q , 1 + dfs ( V , K - i , K ) )
                V [ i ] += 1
    else :
        for i in range ( 1 , K ) :
            if V [ i ] > 0 :
                V [ i ] -= 1
                if i <= left :
                    nleft = left - i
                else :
                    nleft = K + left - i
                q = max ( q , dfs ( V , nleft , K ) )
                V [ i ] += 1
    if key in memo :
        memo [ key ] = q
    else :
        memo [ key ] = q
    return q
def maxGroups ( K , arr ) :
    V = [ 0 ] * ( K )
    for x in range ( len ( arr ) ) :
        V [ arr [ x ] % K ] += 1
    memo = { }
    ans = V [ 0 ] + dfs ( V , 0 , K )
    return ans
arr = [ 1 , 2 , 3 , 4 , 5 , 6 ]
K = 3
print ( maxGroups ( K , arr ) )

Index/key variables: i, key, x
Iterator variables: i, x
Python program:
def smallestSubWithSum ( arr , n , x ) :
    min_len = n + 1
    for start in range ( 0 , n ) :
        curr_sum = arr [ start ]
        if ( curr_sum > x ) :
            return 1
        for end in range ( start + 1 , n ) :
            curr_sum += arr [ end ]
            if curr_sum > x and ( end - start + 1 ) < min_len :
                min_len = ( end - start + 1 )
    return min_len ;
arr1 = [ 1 , 4 , 45 , 6 , 10 , 19 ]
x = 51
n1 = len ( arr1 )
res1 = smallestSubWithSum ( arr1 , n1 , x ) ;
if res1 == n1 + 1 :
    print ( " Not ▁ possible " )
else :
    print ( res1 )
arr2 = [ 1 , 10 , 5 , 2 , 7 ]
n2 = len ( arr2 )
x = 9
res2 = smallestSubWithSum ( arr2 , n2 , x ) ;
if res2 == n2 + 1 :
    print ( " Not ▁ possible " )
else :
    print ( res2 )
arr3 = [ 1 , 11 , 100 , 1 , 0 , 200 , 3 , 2 , 1 , 250 ]
n3 = len ( arr3 )
x = 280
res3 = smallestSubWithSum ( arr3 , n3 , x )
if res3 == n3 + 1 :
    print ( " Not ▁ possible " )
else :
    print ( res3 )

Index/key variables: end, start
Accumulator variables: curr_sum
Iterator variables: end, start
Python program:
def smallestSubWithSum ( arr , n , x ) :
    curr_sum = 0
    min_len = n + 1
    start = 0
    end = 0
    while ( end < n ) :
        while ( curr_sum <= x and end < n ) :
            curr_sum += arr [ end ]
            end += 1
        while ( curr_sum > x and start < n ) :
            if ( end - start < min_len ) :
                min_len = end - start
            curr_sum -= arr [ start ]
            start += 1
    return min_len
arr1 = [ 1 , 4 , 45 , 6 , 10 , 19 ]
x = 51
n1 = len ( arr1 )
res1 = smallestSubWithSum ( arr1 , n1 , x )
print ( " Not ▁ possible " ) if ( res1 == n1 + 1 ) else print ( res1 )
arr2 = [ 1 , 10 , 5 , 2 , 7 ]
n2 = len ( arr2 )
x = 9
res2 = smallestSubWithSum ( arr2 , n2 , x )
print ( " Not ▁ possible " ) if ( res2 == n2 + 1 ) else print ( res2 )
arr3 = [ 1 , 11 , 100 , 1 , 0 , 200 , 3 , 2 , 1 , 250 ]
n3 = len ( arr3 )
x = 280
res3 = smallestSubWithSum ( arr3 , n3 , x )
print ( " Not ▁ possible " ) if ( res3 == n3 + 1 ) else print ( res3 )

Index/key variables: end, start
Accumulator variables: curr_sum
Python program:
class getNode :
    def __init__ ( self , data ) :
        self . data = data
        self . left = self . right = None
def SumOfLongRootToLeafPath ( root , Sum , Len , maxLen , maxSum ) :
    if ( not root ) :
        if ( maxLen [ 0 ] < Len ) :
            maxLen [ 0 ] = Len
            maxSum [ 0 ] = Sum
        elif ( maxLen [ 0 ] == Len and maxSum [ 0 ] < Sum ) :
            maxSum [ 0 ] = Sum
        return
    SumOfLongRootToLeafPath ( root . left , Sum + root . data , Len + 1 , maxLen , maxSum )
    SumOfLongRootToLeafPath ( root . right , Sum + root . data , Len + 1 , maxLen , maxSum )
def SumOfLongRootToLeafPathUtil ( root ) :
    if ( not root ) :
        return 0
    maxSum = [ - 999999999999 ]
    maxLen = [ 0 ]
    SumOfLongRootToLeafPath ( root , 0 , 0 , maxLen , maxSum )
    return maxSum [ 0 ]
if __name__ == ' _ _ main _ _ ' :
    root = getNode ( 4 )
    root . left = getNode ( 2 )
    root . right = getNode ( 5 )
    root . left . left = getNode ( 7 )
    root . left . right = getNode ( 1 )
    root . right . left = getNode ( 2 )
    root . right . right = getNode ( 3 )
    root . left . right . left = getNode ( 6 )
    print ( " Sum ▁ = ▁ " , SumOfLongRootToLeafPathUtil ( root ) )

Class/struct names: getNode
Python program:
def numberOfArrays ( n , l ) :
    dp = [ [ 0 for i in range ( n + 1 ) ] for i in range ( l + 1 ) ]
    dp [ 0 ] [ 1 ] = 1
    for i in range ( l ) :
        for j in range ( 1 , n + 1 ) :
            for k in range ( j , n + 1 , j ) :
                dp [ i + 1 ] [ k ] += dp [ i ] [ j ]
    ans = 0
    for i in range ( 1 , n + 1 ) :
        ans += dp [ l ] [ i ]
    return ans
if __name__ == ' _ _ main _ _ ' :
    N , L = 2 , 4
    print ( numberOfArrays ( N , L ) )

Index/key variables: i, j, k, l
Accumulator variables: ans
Iterator variables: i, j, k
Python program:
def countMinOperations ( target , n ) :
    result = 0 ;
    while ( True ) :
        zero_count = 0 ;
        i = 0 ;
        while ( i < n ) :
            if ( ( target [ i ] & 1 ) > 0 ) :
                break ;
            elif ( target [ i ] == 0 ) :
                zero_count += 1 ;
            i += 1 ;
        if ( zero_count == n ) :
            return result ;
        if ( i == n ) :
            for j in range ( n ) :
                target [ j ] = target [ j ] // 2 ;
            result += 1 ;
        for j in range ( i , n ) :
            if ( target [ j ] & 1 ) :
                target [ j ] -= 1 ;
                result += 1 ;
arr = [ 16 , 16 , 16 ] ;
n = len ( arr ) ;
print ( " Minimum ▁ number ▁ of ▁ steps ▁ required ▁ to " , 	 	 " get the given target array is " , countMinOperations ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: result, zero_count
Iterator variables: j
Python program:
def recursiveChoosing ( arr , start , M , dp ) :
    key = ( start , M )
    if start >= N :
        return 0
    if N - start <= 2 * M :
        return sum ( arr [ start : ] )
    psa = 0
    total = sum ( arr [ start : ] )
    if key in dp :
        return dp [ key ]
    for x in range ( 1 , 2 * M + 1 ) :
        psb = recursiveChoosing ( arr , start + x , max ( x , M ) , dp )
        psa = max ( psa , total - psb )
    dp [ key ] = psa
    return dp [ key ]
arr = [ 2 , 7 , 9 , 4 , 4 ]
N = len ( arr )
dp = { }
print ( recursiveChoosing ( arr , 0 , 1 , dp ) )

Index/key variables: key
Iterator variables: x
Python program:
import bisect
def findSubset ( arr , n , k ) :
    vect1 , vect2 , subset1 , subset2 = [ ] , [ ] , [ ] , [ ]
    for i in range ( 0 , n ) :
        if arr [ i ] > k :
            continue
        if i <= n // 2 :
            vect1 . append ( arr [ i ] )
        else :
            vect2 . append ( arr [ i ] )
    for i in range ( 0 , ( 1 << len ( vect1 ) ) ) :
        value = 1
        for j in range ( 0 , len ( vect1 ) ) :
            if i & ( 1 << j ) :
                value *= vect1 [ j ]
        if value <= k :
            subset1 . append ( value )
    for i in range ( 0 , ( 1 << len ( vect2 ) ) ) :
        value = 1
        for j in range ( 0 , len ( vect2 ) ) :
            if i & ( 1 << j ) :
                value *= vect2 [ j ]
        if value <= k :
            subset2 . append ( value )
    subset2 . sort ( )
    count = 0
    for i in range ( 0 , len ( subset1 ) ) :
        count += bisect . bisect ( subset2 , ( k // subset1 [ i ] ) )
    count -= 1
    return count
if __name__ == " _ _ main _ _ " :
    arr = [ 4 , 2 , 3 , 6 , 5 ]
    n = len ( arr )
    k = 25
    print ( findSubset ( arr , n , k ) )

Index/key variables: i, j
Accumulator variables: count, subset1, subset2, value, vect1, vect2
Iterator variables: i, j
Python program:
def maxSum ( arr , i , n , prev , is_selected , dp ) :
    if ( i == n ) :
        return 0
    cur = abs ( arr [ i ] ) % 2
    if ( dp [ i ] [ prev ] != - 1 ) :
        return dp [ i ] [ prev ]
    if ( i == n - 1 and is_selected == 0 ) :
        dp [ i ] [ prev ] = arr [ i ]
        return dp [ i ] [ prev ]
    if ( cur != prev ) :
        dp [ i ] [ prev ] = arr [ i ] + maxSum ( arr , i + 1 , n , cur , 1 , dp )
    dp [ i ] [ prev ] = max ( dp [ i ] [ prev ] , maxSum ( arr , i + 1 , n , prev , is_selected , dp ) )
    return dp [ i ] [ prev ]
def maxSumUtil ( arr , n ) :
    dp = [ [ - 1 for i in range ( 3 ) ] for j in range ( 100 ) ]
    print ( maxSum ( arr , 0 , n , 2 , 0 , dp ) )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 6 , 8 , - 5 , 10 ]
    N = len ( arr )
    maxSumUtil ( arr , N )

Index/key variables: i, prev
Python program:
def findMinOps ( arr , n ) :
    ans = 0
    i , j = 0 , n - 1
    while i <= j :
        if arr [ i ] == arr [ j ] :
            i += 1
            j -= 1
        elif arr [ i ] > arr [ j ] :
            j -= 1
            arr [ j ] += arr [ j + 1 ]
            ans += 1
        else :
            i += 1
            arr [ i ] += arr [ i - 1 ]
            ans += 1
    return ans
arr = [ 1 , 4 , 5 , 9 , 1 ]
n = len ( arr )
print ( " Count ▁ of ▁ minimum ▁ operations ▁ is ▁ " + str ( findMinOps ( arr , n ) ) )

Index/key variables: i, j
Accumulator variables: ans
Python program:
def findSmallest ( arr , n ) :
    res = 1
    for i in range ( 0 , n ) :
        if arr [ i ] <= res :
            res = res + arr [ i ]
        else :
            break
    return res
arr1 = [ 1 , 3 , 4 , 5 ]
n1 = len ( arr1 )
print ( findSmallest ( arr1 , n1 ) )
arr2 = [ 1 , 2 , 6 , 10 , 11 , 15 ]
n2 = len ( arr2 )
print ( findSmallest ( arr2 , n2 ) )
arr3 = [ 1 , 1 , 1 , 1 ]
n3 = len ( arr3 )
print ( findSmallest ( arr3 , n3 ) )
arr4 = [ 1 , 1 , 3 , 4 ]
n4 = len ( arr4 )
print ( findSmallest ( arr4 , n4 ) )

Index/key variables: i
Iterator variables: i
Python program:
s = set ( [ ] )
def countXOR ( arr , comb , start , end , index , r ) :
    if ( index == r ) :
        new_xor = 0
        for j in range ( r ) :
            new_xor ^= comb [ j ]
        s . add ( new_xor )
        return
    i = start
    while i <= end and ( end - i + 1 ) >= ( r - index ) :
        comb [ index ] = arr [ i ]
        countXOR ( arr , comb , i + 1 , end , index + 1 , r )
        i += 1
def maxSizeSet ( arr , N ) :
    for r in range ( 2 , N + 1 ) :
        comb = [ 0 ] * ( r + 1 )
        countXOR ( arr , comb , 0 , N - 1 , 0 , r )
    print ( len ( s ) )
arr = [ 1 , 2 , 3 , 4 , 5 ]
N = len ( arr )
maxSizeSet ( arr , N )

Index/key variables: i, index, j
Accumulator variables: new_xor
Iterator variables: j, r
Python program:
from sys import maxsize
def maxSubArraySum ( a , size ) :
    max_so_far = - maxsize - 1
    max_ending_here = 0
    start = 0
    end = 0
    s = 0
    for i in range ( 0 , size ) :
        max_ending_here += a [ i ]
        if max_so_far < max_ending_here :
            max_so_far = max_ending_here
            start = s
            end = i
        if max_ending_here < 0 :
            max_ending_here = 0
            s = i + 1
    return ( end - start + 1 )
a = [ - 2 , - 3 , 4 , - 1 , - 2 , 1 , 5 , - 3 ]
print ( maxSubArraySum ( a , len ( a ) ) )

Index/key variables: i
Accumulator variables: max_ending_here
Iterator variables: i
Python program:
def LongSubarrSeq ( arr1 , arr2 ) :
    M = len ( arr1 ) ;
    N = len ( arr2 ) ;
    maxL = 0 ;
    DP = [ [ 0 for i in range ( N + 1 ) ] for j in range ( M + 1 ) ] ;
    for i in range ( 1 , M + 1 ) :
        for j in range ( 1 , N + 1 ) :
            if ( arr1 [ i - 1 ] == arr2 [ j - 1 ] ) :
                DP [ i ] [ j ] = 1 + DP [ i - 1 ] [ j - 1 ] ;
            else :
                DP [ i ] [ j ] = DP [ i ] [ j - 1 ] ;
    for i in range ( M + 1 ) :
        for j in range ( 1 , N + 1 ) :
            maxL = max ( maxL , DP [ i ] [ j ] ) ;
    return maxL ;
if __name__ == ' _ _ main _ _ ' :
    arr1 = [ 4 , 2 , 3 , 1 , 5 , 6 ] ;
    arr2 = [ 3 , 1 , 4 , 6 , 5 , 2 ] ;
    print ( LongSubarrSeq ( arr1 , arr2 ) ) ;

Index/key variables: i, j
Iterator variables: i, j
Python program:
def findMinDiff ( arr , n ) :
    diff = 10 ** 20
    for i in range ( n - 1 ) :
        for j in range ( i + 1 , n ) :
            if abs ( arr [ i ] - arr [ j ] ) < diff :
                diff = abs ( arr [ i ] - arr [ j ] )
    return diff
arr = [ 1 , 5 , 3 , 19 , 18 , 25 ]
n = len ( arr )
print ( " Minimum ▁ difference ▁ is ▁ " + str ( findMinDiff ( arr , n ) ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
dp = [ [ [ - 1 for i in range ( 5005 ) ] for i in range ( 12 ) ] for i in range ( 12 ) ]
def findCountUtil ( N , maxDigit , position , previous , count ) :
    global dp
    if ( position == N ) :
        return 1
    ans = dp [ position ] [ previous ] [ count ]
    if ( ans != - 1 ) :
        return ans
    ans = 0
    for i in range ( 10 ) :
        if ( count == 0 and previous != i ) :
            ans = ( ans + ( findCountUtil ( N , maxDigit , position + 1 , i , maxDigit [ i ] - 1 ) ) % 1000000007 ) % 1000000007
        elif ( count != 0 ) :
            ans = ( ans + ( findCountUtil ( N , maxDigit , position + 1 , i , count - 1 if ( previous == i and position != 0 ) else maxDigit [ i ] - 1 ) ) % 1000000007 ) % 1000000007
    dp [ position ] [ previous ] [ count ] = ans
    return ans
def findCount ( N , maxDigit ) :
    ans = findCountUtil ( N , maxDigit , 0 , 0 , 1 )
    print ( ans )
if __name__ == ' _ _ main _ _ ' :
    N = 2
    maxDigit = [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ]
    findCount ( N , maxDigit )

Index/key variables: count, i, position, previous
Iterator variables: i
Python program:
def findMinDiff ( arr , n ) :
    arr = sorted ( arr )
    diff = 10 ** 20
    for i in range ( n - 1 ) :
        if arr [ i + 1 ] - arr [ i ] < diff :
            diff = arr [ i + 1 ] - arr [ i ]
    return diff
arr = [ 1 , 5 , 3 , 19 , 18 , 25 ]
n = len ( arr )
print ( " Minimum ▁ difference ▁ is ▁ " + str ( findMinDiff ( arr , n ) ) )

Index/key variables: i
Iterator variables: i
Python program:
import math
a = 2
b = 10
size = abs ( b - a ) + 1
array = [ 0 ] * size
for i in range ( a , b + 1 ) :
    if ( i % 2 == 0 or i % 5 == 0 ) :
        array [ i - a ] = 1
print ( " MULTIPLES ▁ of ▁ 2 ▁ and ▁ 5 : " )
for i in range ( a , b + 1 ) :
    if ( array [ i - a ] == 1 ) :
        print ( i , end = " ▁ " )

Iterator variables: i
Python program:
class newNode :
    def __init__ ( self , data ) :
        self . data = data
        self . left = self . right = None
def Print ( root ) :
    if ( root != None ) :
        Print ( root . left )
        print ( root . data , end = " ▁ " )
        Print ( root . right )
def pruneUtil ( root , k , Sum ) :
    if ( root == None ) :
        return None
    lSum = [ Sum [ 0 ] + ( root . data ) ]
    rSum = [ lSum [ 0 ] ]
    root . left = pruneUtil ( root . left , k , lSum )
    root . right = pruneUtil ( root . right , k , rSum )
    Sum [ 0 ] = max ( lSum [ 0 ] , rSum [ 0 ] )
    if ( Sum [ 0 ] < k [ 0 ] ) :
        root = None
    return root
def prune ( root , k ) :
    Sum = [ 0 ]
    return pruneUtil ( root , k , Sum )
if __name__ == ' _ _ main _ _ ' :
    k = [ 45 ]
    root = newNode ( 1 )
    root . left = newNode ( 2 )
    root . right = newNode ( 3 )
    root . left . left = newNode ( 4 )
    root . left . right = newNode ( 5 )
    root . right . left = newNode ( 6 )
    root . right . right = newNode ( 7 )
    root . left . left . left = newNode ( 8 )
    root . left . left . right = newNode ( 9 )
    root . left . right . left = newNode ( 12 )
    root . right . right . left = newNode ( 10 )
    root . right . right . left . right = newNode ( 11 )
    root . left . left . right . left = newNode ( 13 )
    root . left . left . right . right = newNode ( 14 )
    root . left . left . right . right . left = newNode ( 15 )
    print ( " Tree ▁ before ▁ truncation " )
    Print ( root )
    print ( )
    root = prune ( root , k )
    print ( " Tree ▁ after ▁ truncation " )
    Print ( root )

Class/struct names: newNode