dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def check ( s , m ) :
    l = len ( s ) ;
    c1 = 0 ;
    c2 = 0 ;
    for i in range ( 0 , l - 1 ) :
        if ( s [ i ] == '0' ) :
            c2 = 0 ;
            c1 = c1 + 1 ;
        else :
            c1 = 0 ;
            c2 = c2 + 1 ;
        if ( c1 == m or c2 == m ) :
            return True ;
    return False ;
s = "001001" ;
m = 2 ;
if ( check ( s , m ) ) :
    print ( " YES " ) ;
else :
    print ( " NO " ) ;

Index/key variables: i
Iterator variables: i
Python program:
def productAtKthLevel ( tree , k ) :
    level = - 1
    product = 1
    n = len ( tree )
    for i in range ( 0 , n ) :
        if ( tree [ i ] == ' ( ' ) :
            level += 1
        elif ( tree [ i ] == ' ) ' ) :
            level -= 1
        else :
            if ( level == k ) :
                product *= ( int ( tree [ i ] ) - int ( '0' ) )
    return product
tree = " ( 0(5(6 ( ) ( ) ) ( 4 ( ) (9 ( ) ( ) ) ) ) ( 7(1 ( ) ( ) ) ( 3 ( ) ( ) ) ) ) "
k = 2
print ( productAtKthLevel ( tree , k ) )

Index/key variables: i
Accumulator variables: level, product
Iterator variables: i
Python program:
def findDuplicates ( a , n , m ) :
    isPresent = [ [ False for i in range ( n ) ] for j in range ( m ) ]
    for i in range ( n ) :
        for j in range ( m ) :
            for k in range ( n ) :
                if i != k and a [ i ] [ j ] == a [ k ] [ j ] :
                    isPresent [ i ] [ j ] = True
                    isPresent [ k ] [ j ] = True
            for k in range ( m ) :
                if j != k and a [ i ] [ j ] == a [ i ] [ k ] :
                    isPresent [ i ] [ j ] = True
                    isPresent [ i ] [ k ] = True
    for i in range ( n ) :
        for j in range ( m ) :
            if not isPresent [ i ] [ j ] :
                print ( a [ i ] [ j ] , end = " " )
if __name__ == " _ _ main _ _ " :
    n = 2
    m = 2
    a = [ " zx " , " xz " ]
    findDuplicates ( a , n , m )

Index/key variables: i, j, k
Iterator variables: i, j, k
Python program:
def isValidISBN ( isbn ) :
    if len ( isbn ) != 10 :
        return False
    _sum = 0
    for i in range ( 9 ) :
        if 0 <= int ( isbn [ i ] ) <= 9 :
            _sum += int ( isbn [ i ] ) * ( 10 - i )
        else :
            return False
    if ( isbn [ 9 ] != ' X ' and 0 <= int ( isbn [ 9 ] ) <= 9 ) :
        return False
    _sum += 10 if isbn [ 9 ] == ' X ' else int ( isbn [ 9 ] )
    return ( _sum % 11 == 0 )
isbn = "007462542X "
if isValidISBN ( isbn ) :
    print ( ' Valid ' )
else :
    print ( " Invalid " )

Index/key variables: i
Accumulator variables: _sum
Iterator variables: i
Python program:
def isVowel ( c ) :
    if ( c == ' a ' or c == ' A ' or c == ' e ' or c == ' E ' or c == ' i ' or c == ' I ' or c == ' o ' or c == ' O ' or c == ' u ' or c == ' U ' ) :
        return True
    return False
def reverserVowel ( string ) :
    j = 0
    vowel = [ 0 ] * len ( string )
    string = list ( string )
    for i in range ( len ( string ) ) :
        if isVowel ( string [ i ] ) :
            vowel [ j ] = string [ i ]
            j += 1
    for i in range ( len ( string ) ) :
        if isVowel ( string [ i ] ) :
            j -= 1
            string [ i ] = vowel [ j ]
    return ' ' . join ( string )
if __name__ == " _ _ main _ _ " :
    string = " hello ▁ world "
    print ( reverserVowel ( string ) )

Index/key variables: i, j
Iterator variables: i
Python program:
def firstLetterWord ( str ) :
    result = " "
    v = True
    for i in range ( len ( str ) ) :
        if ( str [ i ] == ' ▁ ' ) :
            v = True
        elif ( str [ i ] != ' ▁ ' and v == True ) :
            result += ( str [ i ] )
            v = False
    return result
if __name__ == " _ _ main _ _ " :
    str = " geeks ▁ for ▁ geeks "
    print ( firstLetterWord ( str ) )

Index/key variables: i
Accumulator variables: result
Iterator variables: i
Boolean variables: v
Python program:
def dfs ( i , j , grid , vis , ans , z , z_count ) :
    n = len ( grid )
    m = len ( grid [ 0 ] )
    vis [ i ] [ j ] = 1
    if ( grid [ i ] [ j ] == 0 ) :
        z += 1
    if ( grid [ i ] [ j ] == 2 ) :
        if ( z == z_count ) :
            ans += 1
        vis [ i ] [ j ] = 0
        return grid , vis , ans
    if ( i >= 1 and not vis [ i - 1 ] [ j ] and grid [ i - 1 ] [ j ] != - 1 ) :
        grid , vis , ans = dfs ( i - 1 , j , grid , vis , ans , z , z_count )
    if ( i < n - 1 and not vis [ i + 1 ] [ j ] and grid [ i + 1 ] [ j ] != - 1 ) :
        grid , vis , ans = dfs ( i + 1 , j , grid , vis , ans , z , z_count )
    if ( j >= 1 and not vis [ i ] [ j - 1 ] and grid [ i ] [ j - 1 ] != - 1 ) :
        grid , vis , ans = dfs ( i , j - 1 , grid , vis , ans , z , z_count )
    if ( j < m - 1 and not vis [ i ] [ j + 1 ] and grid [ i ] [ j + 1 ] != - 1 ) :
        grid , vis , ans = dfs ( i , j + 1 , grid , vis , ans , z , z_count )
    vis [ i ] [ j ] = 0
    return grid , vis , ans
def uniquePaths ( grid ) :
    z_count = 0
    n = len ( grid )
    m = len ( grid [ 0 ] )
    ans = 0
    vis = [ [ 0 for j in range ( m ) ] for i in range ( n ) ]
    x = 0
    y = 0
    for i in range ( n ) :
        for j in range ( m ) :
            if grid [ i ] [ j ] == 0 :
                z_count += 1
            elif ( grid [ i ] [ j ] == 1 ) :
                x = i
                y = j
    grid , vis , ans = dfs ( x , y , grid , vis , ans , 0 , z_count )
    return ans
if __name__ == ' _ _ main _ _ ' :
    grid = [ [ 1 , 0 , 0 , 0 ] , [ 0 , 0 , 0 , 0 ] , [ 0 , 0 , 2 , - 1 ] ]
    print ( uniquePaths ( grid ) )

Index/key variables: i, j
Accumulator variables: z_count
Iterator variables: i, j
Python program:
def numPairs ( a , n ) :
    ans = 0
    for i in range ( n ) :
        a [ i ] = abs ( a [ i ] )
    a . sort ( )
    for i in range ( n ) :
        index = 0
        for j in range ( i + 1 , n ) :
            if ( 2 * a [ i ] >= a [ j - 1 ] and 2 * a [ i ] < a [ j ] ) :
                index = j
        if index == 0 :
            index = n
        ans += index - i - 1
    return ans
a = [ 3 , 6 ]
n = len ( a )
print ( numPairs ( a , n ) )

Index/key variables: i, j
Accumulator variables: ans
Iterator variables: i, j
Python program:
def find_Centroid ( v ) :
    ans = [ 0 , 0 ]
    n = len ( v )
    signedArea = 0
    for i in range ( len ( v ) ) :
        x0 = v [ i ] [ 0 ]
        y0 = v [ i ] [ 1 ]
        x1 = v [ ( i + 1 ) % n ] [ 0 ]
        y1 = v [ ( i + 1 ) % n ] [ 1 ]
        A = ( x0 * y1 ) - ( x1 * y0 )
        signedArea += A
        ans [ 0 ] += ( x0 + x1 ) * A
        ans [ 1 ] += ( y0 + y1 ) * A
    signedArea *= 0.5
    ans [ 0 ] = ( ans [ 0 ] ) / ( 6 * signedArea )
    ans [ 1 ] = ( ans [ 1 ] ) / ( 6 * signedArea )
    return ans
vp = [ [ 1 , 2 ] , [ 3 , - 4 ] , [ 6 , - 7 ] ]
ans = find_Centroid ( vp )
print ( round ( ans [ 0 ] , 12 ) , ans [ 1 ] )

Index/key variables: i
Accumulator variables: signedArea
Iterator variables: i
Python program:
def isDivisibleByDivisor ( S , D ) :
    S %= D
    hashMap = set ( )
    hashMap . add ( S )
    for i in range ( D + 1 ) :
        S += ( S % D )
        S %= D
        if ( S in hashMap ) :
            if ( S == 0 ) :
                return " Yes "
            return " No "
        else :
            hashMap . add ( S )
    return " Yes "
if __name__ == ' _ _ main _ _ ' :
    S = 3
    D = 6
    print ( isDivisibleByDivisor ( S , D ) )

Accumulator variables: S, hashMap
Iterator variables: i
Python program:
def minimumSteps ( x , y ) :
    cnt = 0
    while ( x != 0 and y != 0 ) :
        if ( x > y ) :
            cnt += x / y
            x %= y
        else :
            cnt += y / x
            y %= x
    cnt -= 1
    if ( x > 1 or y > 1 ) :
        cnt = - 1
    print ( int ( cnt ) )
if __name__ == ' _ _ main _ _ ' :
    x = 3
    y = 1
    minimumSteps ( x , y )

Accumulator variables: cnt, x, y
Python program:
def countMinReversals ( expr ) :
    lenn = len ( expr )
    if ( lenn % 2 ) :
        return - 1
    s = [ ]
    for i in range ( lenn ) :
        if ( expr [ i ] == ' ' and len ( s ) ) :
            if ( s [ 0 ] == ' ' ) :
                s . pop ( 0 )
            else :
                s . insert ( 0 , expr [ i ] )
        else :
            s . insert ( 0 , expr [ i ] )
    red_len = len ( s )
    n = 0
    while ( len ( s ) and s [ 0 ] == ' ' ) :
        s . pop ( 0 )
        n += 1
    return ( red_len // 2 + n % 2 )
if __name__ == ' _ _ main _ _ ' :
    expr = " } } { { "
    print ( countMinReversals ( expr . strip ( ) ) )

Index/key variables: i
Accumulator variables: n
Iterator variables: i
Python program:
def PrintMinNumberForPattern ( arr ) :
    curr_max = 0
    last_entry = 0
    i = 0
    while i < len ( arr ) :
        noOfNextD = 0
        if arr [ i ] == " I " :
            j = i + 1
            while j < len ( arr ) and arr [ j ] == " D " :
                noOfNextD += 1
                j += 1
            if i == 0 :
                curr_max = noOfNextD + 2
                last_entry += 1
                print ( " " , last_entry , end = " " )
                print ( " " , curr_max , end = " " )
                last_entry = curr_max
            else :
                curr_max += noOfNextD + 1
                last_entry = curr_max
                print ( " " , last_entry , end = " " )
            for k in range ( noOfNextD ) :
                last_entry -= 1
                print ( " " , last_entry , end = " " )
                i += 1
        elif arr [ i ] == " D " :
            if i == 0 :
                j = i + 1
                while j < len ( arr ) and arr [ j ] == " D " :
                    noOfNextD += 1
                    j += 1
                curr_max = noOfNextD + 2
                print ( " " , curr_max , curr_max - 1 , end = " " )
                last_entry = curr_max - 1
            else :
                print ( " " , last_entry - 1 , end = " " )
                last_entry -= 1
        i += 1
    print ( )
if __name__ == " _ _ main _ _ " :
    PrintMinNumberForPattern ( " IDID " )
    PrintMinNumberForPattern ( " I " )
    PrintMinNumberForPattern ( " DD " )
    PrintMinNumberForPattern ( " II " )
    PrintMinNumberForPattern ( " DIDI " )
    PrintMinNumberForPattern ( " IIDDD " )
    PrintMinNumberForPattern ( " DDIDDIID " )

Index/key variables: i, j
Accumulator variables: curr_max, last_entry, noOfNextD
Iterator variables: k
Python program:
def printLeast ( arr ) :
    min_avail = 1
    pos_of_I = 0
    v = [ ]
    if ( arr [ 0 ] == ' I ' ) :
        v . append ( 1 )
        v . append ( 2 )
        min_avail = 3
        pos_of_I = 1
    else :
        v . append ( 2 )
        v . append ( 1 )
        min_avail = 3
        pos_of_I = 0
    for i in range ( 1 , len ( arr ) ) :
        if ( arr [ i ] == ' I ' ) :
            v . append ( min_avail )
            min_avail += 1
            pos_of_I = i + 1
        else :
            v . append ( v [ i ] )
            for j in range ( pos_of_I , i + 1 ) :
                v [ j ] += 1
            min_avail += 1
    print ( * v , sep = ' ▁ ' )
printLeast ( " IDID " )
printLeast ( " I " )
printLeast ( " DD " )
printLeast ( " II " )
printLeast ( " DIDI " )
printLeast ( " IIDDD " )
printLeast ( " DDIDDIID " )

Index/key variables: i, j
Accumulator variables: min_avail, v
Iterator variables: i, j
Python program:
def PrintMinNumberForPattern ( Strr ) :
    res = ' '
    stack = [ ]
    for i in range ( len ( Strr ) + 1 ) :
        stack . append ( i + 1 )
        if ( i == len ( Strr ) or Strr [ i ] == ' I ' ) :
            while len ( stack ) > 0 :
                res += str ( stack . pop ( ) )
                res += ' ▁ '
    print ( res )
PrintMinNumberForPattern ( " IDID " )
PrintMinNumberForPattern ( " I " )
PrintMinNumberForPattern ( " DD " )
PrintMinNumberForPattern ( " II " )
PrintMinNumberForPattern ( " DIDI " )
PrintMinNumberForPattern ( " IIDDD " )
PrintMinNumberForPattern ( " DDIDDIID " )

Index/key variables: i
Accumulator variables: res, stack
Iterator variables: i
Python program:
def getMinNumberForPattern ( seq ) :
    n = len ( seq )
    if ( n >= 9 ) :
        return " - 1"
    result = [ None ] * ( n + 1 )
    count = 1
    for i in range ( n + 1 ) :
        if ( i == n or seq [ i ] == ' I ' ) :
            for j in range ( i - 1 , - 2 , - 1 ) :
                result [ j + 1 ] = int ( '0' + str ( count ) )
                count += 1
                if ( j >= 0 and seq [ j ] == ' I ' ) :
                    break
    return result
if __name__ == ' _ _ main _ _ ' :
    inputs = [ " IDID " , " I " , " DD " , " II " , " DIDI " , " IIDDD " , " DDIDDIID " ]
    for Input in inputs :
        print ( * ( getMinNumberForPattern ( Input ) ) )

Index/key variables: i, j
Accumulator variables: count
Iterator variables: Input, i, j
Python program:
import math as mt
def isPrime ( n ) :
    i , c = 0 , 0
    for i in range ( 1 , n // 2 ) :
        if ( n % i == 0 ) :
            c += 1
    if ( c == 1 ) :
        return 1
    else :
        return 0
def findMinNum ( arr , n ) :
    first , last = 0 , 0
    Hash = [ 0 for i in range ( 10 ) ]
    for i in range ( n ) :
        Hash [ arr [ i ] ] += 1
    print ( " Minimum ▁ number : ▁ " , end = " " )
    for i in range ( 0 , 10 ) :
        for j in range ( Hash [ i ] ) :
            print ( i , end = " " )
    print ( )
    for i in range ( 10 ) :
        if ( Hash [ i ] != 0 ) :
            first = i
            break
    for i in range ( 9 , - 1 , - 1 ) :
        if ( Hash [ i ] != 0 ) :
            last = i
            break
    num = first * 10 + last
    rev = last * 10 + first
    print ( " Prime ▁ combinations : ▁ " , end = " " )
    if ( isPrime ( num ) and isPrime ( rev ) ) :
        print ( num , " ▁ " , rev )
    elif ( isPrime ( num ) ) :
        print ( num )
    elif ( isPrime ( rev ) ) :
        print ( rev )
    else :
        print ( " No ▁ combinations ▁ exist " )
arr = [ 1 , 2 , 4 , 7 , 8 ]
findMinNum ( arr , 5 )

Index/key variables: i
Accumulator variables: c
Iterator variables: i, j
Python program:
def gcd ( a , b ) :
    if ( a == 0 ) :
        return b ;
    return gcd ( b % a , a ) ;
def coprime ( a , b ) :
    return ( gcd ( a , b ) == 1 ) ;
def possibleTripletInRange ( L , R ) :
    flag = False ;
    possibleA = 0 ;
    possibleB = 0 ;
    possibleC = 0 ;
    for a in range ( L , R + 1 ) :
        for b in range ( a + 1 , R + 1 ) :
            for c in range ( b + 1 , R + 1 ) :
                if ( coprime ( a , b ) and coprime ( b , c ) and coprime ( a , c ) == False ) :
                    flag = True ;
                    possibleA = a ;
                    possibleB = b ;
                    possibleC = c ;
                    break ;
    if ( flag == True ) :
        print ( " ( " , possibleA , " , " , possibleB , " , " , possibleC , " ) ▁ is ▁ one ▁ such " , " possible ▁ triplet ▁ between " , L , " and " , R ) ;
    else :
        print ( " No ▁ Such ▁ Triplet ▁ exists ▁ between " , L , " and " , R ) ;
L = 2 ;
R = 10 ;
possibleTripletInRange ( L , R ) ;
L = 23 ;
R = 46 ;
possibleTripletInRange ( L , R ) ;

Iterator variables: a, b, c
Boolean variables: flag
Python program:
def isUndulating ( n ) :
    if ( len ( n ) <= 2 ) :
        return False
    for i in range ( 2 , len ( n ) ) :
        if ( n [ i - 2 ] != n [ i ] ) :
            return False
    return True
n = "1212121"
if ( isUndulating ( n ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def Series ( n ) :
    sums = 0
    for i in range ( 1 , n + 1 ) :
        sums += ( i * i ) ;
    return sums
n = 3
res = Series ( n )
print ( res )

Accumulator variables: sums
Iterator variables: i
Python program:
import sys
def prevNum ( string , n ) :
    index = - 1
    for i in range ( n - 2 , - 1 , - 1 ) :
        if int ( string [ i ] ) > int ( string [ i + 1 ] ) :
            index = i
            break
    smallGreatDgt = - 1
    for i in range ( n - 1 , index , - 1 ) :
        if ( smallGreatDgt == - 1 and int ( string [ i ] ) < int ( string [ index ] ) ) :
            smallGreatDgt = i
        elif ( index > - 1 and int ( string [ i ] ) >= int ( string [ smallGreatDgt ] ) and int ( string [ i ] ) < int ( string [ index ] ) ) :
            smallGreatDgt = i
    if index == - 1 :
        return " " . join ( " - 1" )
    else :
        ( string [ index ] , string [ smallGreatDgt ] ) = ( string [ smallGreatDgt ] , string [ index ] )
    return " " . join ( string )
if __name__ == ' _ _ main _ _ ' :
    n_str = "34125"
    ans = prevNum ( list ( n_str ) , len ( n_str ) )
    print ( ans )

Index/key variables: i, index, smallGreatDgt
Iterator variables: i
Python program:
def horner ( poly , n , x ) :
    result = poly [ 0 ] ;
    for i in range ( 1 , n ) :
        result = ( result * x + poly [ i ] ) ;
    return result ;
def findSign ( poly , n , x ) :
    result = horner ( poly , n , x ) ;
    if ( result > 0 ) :
        return 1 ;
    elif ( result < 0 ) :
        return - 1 ;
    return 0 ;
poly = [ 2 , - 6 , 2 , - 1 ] ;
x = 3 ;
n = len ( poly ) ;
print ( " Sign ▁ of ▁ polynomial ▁ is ▁ " , findSign ( poly , n , x ) ) ;

Index/key variables: i
Iterator variables: i
Python program:
isPrime = [ 1 ] * 100005
def sieveOfEratostheneses ( ) :
    isPrime [ 1 ] = False
    i = 2
    while i * i < 100005 :
        if ( isPrime [ i ] ) :
            j = 2 * i
            while j < 100005 :
                isPrime [ j ] = False
                j += i
        i += 1
    return
def findPrime ( n ) :
    num = n + 1
    while ( num ) :
        if isPrime [ num ] :
            return num
        num += 1
    return 0
def minNumber ( arr ) :
    sieveOfEratostheneses ( )
    s = 0
    for i in range ( 0 , len ( arr ) ) :
        s += arr [ i ]
    if isPrime [ s ] == True :
        return 0
    num = findPrime ( s )
    return num - s
arr = [ 2 , 4 , 6 , 8 , 12 ]
print ( minNumber ( arr ) )

Index/key variables: i, j, num, s
Iterator variables: i
Python program:
def SubArraySum ( arr , n ) :
    temp , result = 0 , 0
    for i in range ( 0 , n ) :
        temp = 0 ;
        for j in range ( i , n ) :
            temp += arr [ j ]
            result += temp
    return result
arr = [ 1 , 2 , 3 ]
n = len ( arr )
print ( " Sum ▁ of ▁ SubArray ▁ : " , SubArraySum ( arr , n ) )

Index/key variables: j
Accumulator variables: result, temp
Iterator variables: i, j
Python program:
class Data :
    def __init__ ( self , x , y ) :
        self . x = x
        self . y = y
def interpolate ( f : list , xi : int , n : int ) -> float :
    result = 0.0
    for i in range ( n ) :
        term = f [ i ] . y
        for j in range ( n ) :
            if j != i :
                term = term * ( xi - f [ j ] . x ) / ( f [ i ] . x - f [ j ] . x )
        result += term
    return result
if __name__ == " _ _ main _ _ " :
    f = [ Data ( 0 , 2 ) , Data ( 1 , 3 ) , Data ( 2 , 12 ) , Data ( 5 , 147 ) ]
    print ( " Value ▁ of ▁ f ( 3 ) ▁ is ▁ : " , interpolate ( f , 3 , 4 ) )

Index/key variables: i, j
Accumulator variables: result
Iterator variables: i, j
Class/struct names: Data
Python program:
def SieveOfSundaram ( n ) :
    nNew = int ( ( n - 1 ) / 2 ) ;
    marked = [ 0 ] * ( nNew + 1 ) ;
    for i in range ( 1 , nNew + 1 ) :
        j = i ;
        while ( ( i + j + 2 * i * j ) <= nNew ) :
            marked [ i + j + 2 * i * j ] = 1 ;
            j += 1 ;
    if ( n > 2 ) :
        print ( 2 , end = " ▁ " ) ;
    for i in range ( 1 , nNew + 1 ) :
        if ( marked [ i ] == 0 ) :
            print ( ( 2 * i + 1 ) , end = " ▁ " ) ;
n = 20 ;
SieveOfSundaram ( n ) ;

Index/key variables: i
Accumulator variables: j
Iterator variables: i
Python program:
def constructArray ( A , N , K ) :
    B = [ 0 ] * N ;
    totalXOR = A [ 0 ] ^ K ;
    for i in range ( N ) :
        B [ i ] = totalXOR ^ A [ i ] ;
    for i in range ( N ) :
        print ( B [ i ] , end = " ▁ " ) ;
if __name__ == ' _ _ main _ _ ' :
    A = [ 13 , 14 , 10 , 6 ] ;
    K = 2 ;
    N = len ( A ) ;
    constructArray ( A , N , K ) ;

Index/key variables: i
Iterator variables: i
Python program:
def extraElement ( A , B , n ) :
    ans = 0 ;
    for i in range ( n ) :
        ans ^= A [ i ] ;
    for i in range ( n + 1 ) :
        ans ^= B [ i ] ;
    return ans ;
A = [ 10 , 15 , 5 ] ;
B = [ 10 , 100 , 15 , 5 ] ;
n = len ( A ) ;
print ( extraElement ( A , B , n ) ) ;

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def hammingDistance ( n1 , n2 ) :
    x = n1 ^ n2
    setBits = 0
    while ( x > 0 ) :
        setBits += x & 1
        x >>= 1
    return setBits
if __name__ == ' _ _ main _ _ ' :
    n1 = 9
    n2 = 14
    print ( hammingDistance ( 9 , 14 ) )

Accumulator variables: setBits, x
Python program:
def printSubsets ( n ) :
    for i in range ( n + 1 ) :
        if ( ( n & i ) == i ) :
            print ( i , " ▁ " , end = " " )
n = 9
printSubsets ( n )

Iterator variables: i
Python program:
def subset ( ar , n ) :
    res = 0
    ar . sort ( )
    for i in range ( 0 , n ) :
        count = 1
        for i in range ( n - 1 ) :
            if ar [ i ] == ar [ i + 1 ] :
                count += 1
            else :
                break
        res = max ( res , count )
    return res
ar = [ 5 , 6 , 9 , 3 , 4 , 3 , 4 ]
n = len ( ar )
print ( subset ( ar , n ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def subset ( arr , n ) :
    mp = { i : 0 for i in range ( 10 ) }
    for i in range ( n ) :
        mp [ arr [ i ] ] += 1
    res = 0
    for key , value in mp . items ( ) :
        res = max ( res , value )
    return res
if __name__ == ' _ _ main _ _ ' :
    arr = [ 5 , 6 , 9 , 3 , 4 , 3 , 4 ]
    n = len ( arr )
    print ( subset ( arr , n ) )

Index/key variables: i
Iterator variables: i, key, value
Python program:
psquare = [ ]
def calcPsquare ( N ) :
    for i in range ( 1 , N ) :
        if i * i > N :
            break
        psquare . append ( i * i )
def countWays ( index , target ) :
    if ( target == 0 ) :
        return 1
    if ( index < 0 or target < 0 ) :
        return 0
    inc = countWays ( index , target - psquare [ index ] )
    exc = countWays ( index - 1 , target )
    return inc + exc
if __name__ == ' _ _ main _ _ ' :
    N = 9
    calcPsquare ( N )
    print ( countWays ( len ( psquare ) - 1 , N ) )

Index/key variables: index
Accumulator variables: psquare
Iterator variables: i
Python program:
sum = 0
class TreeNode :
    def __init__ ( self , data ) :
        self . data = data
        self . size = 0
        self . left = None
        self . right = None
def sumofsubtree ( root ) :
    p = [ 1 , 0 ]
    if ( root . left ) :
        ptemp = sumofsubtree ( root . left )
        p [ 1 ] += ptemp [ 0 ] + ptemp [ 1 ]
        p [ 0 ] += ptemp [ 0 ]
    if ( root . right ) :
        ptemp = sumofsubtree ( root . right )
        p [ 1 ] += ptemp [ 0 ] + ptemp [ 1 ]
        p [ 0 ] += ptemp [ 0 ]
    root . size = p [ 0 ]
    return p
def distance ( root , target , distancesum , n ) :
    global sum
    if ( root . data == target ) :
        sum = distancesum
    if ( root . left ) :
        tempsum = ( distancesum - root . left . size + ( n - root . left . size ) )
        distance ( root . left , target , tempsum , n )
    if ( root . right ) :
        tempsum = ( distancesum - root . right . size + ( n - root . right . size ) )
        distance ( root . right , target , tempsum , n )
if __name__ == ' _ _ main _ _ ' :
    root = TreeNode ( 1 )
    root . left = TreeNode ( 2 )
    root . right = TreeNode ( 3 )
    root . left . left = TreeNode ( 4 )
    root . left . right = TreeNode ( 5 )
    root . right . left = TreeNode ( 6 )
    root . right . right = TreeNode ( 7 )
    root . left . left . left = TreeNode ( 8 )
    root . left . left . right = TreeNode ( 9 )
    target = 3
    p = sumofsubtree ( root )
    totalnodes = p [ 0 ]
    distance ( root , target , p [ 1 ] , totalnodes )
    print ( sum )

Class/struct names: TreeNode