dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
import sys
def strBitwiseXOR ( arr , n ) :
    result = " "
    max_len = - 1
    for i in range ( n ) :
        max_len = max ( max_len , len ( arr [ i ] ) )
        arr [ i ] = arr [ i ] [ : : - 1 ]
    for i in range ( n ) :
        s = " "
        for j in range ( max_len - len ( arr [ i ] ) ) :
            s += "0"
        arr [ i ] = arr [ i ] + s
    for i in range ( max_len ) :
        pres_bit = 0
        for j in range ( n ) :
            pres_bit = pres_bit ^ ( ord ( arr [ j ] [ i ] ) - ord ( '0' ) )
        result += chr ( ( pres_bit ) + ord ( '0' ) )
    result = result [ : : - 1 ]
    print ( result )
if ( __name__ == " _ _ main _ _ " ) :
    arr = [ "1000" , "10001" , "0011" ]
    n = len ( arr )
    strBitwiseXOR ( arr , n )

Index/key variables: i, j
Accumulator variables: result, s
Iterator variables: i, j
Python program:
sticks = [ 6 , 7 , 4 , 6 , 5 , 4 , 6 , 5 , 2 , 4 , 4 , 3 , 6 , 6 , 6 , 5 , 7 , 6 , 5 , 3 , 5 , 4 , 6 , 4 , 3 , 4 ] ;
number = [ 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] ;
def countSticks ( string ) :
    cnt = 0 ;
    for i in range ( len ( string ) ) :
        ch = string [ i ] ;
        if ( ch >= ' A ' and ch <= ' Z ' ) :
            cnt += sticks [ ord ( ch ) - ord ( ' A ' ) ] ;
        else :
            cnt += number [ ord ( ch ) - ord ( '0' ) ] ;
    return cnt ;
if __name__ == " _ _ main _ _ " :
    string = " GEEKSFORGEEKS " ;
    print ( countSticks ( string ) ) ;

Index/key variables: i
Accumulator variables: cnt
Iterator variables: i
Python program:
from collections import deque ;
def remainingDigit ( S , N ) :
    c = [ i for i in S ]
    de = [ 0 , 0 ]
    count = [ 0 , 0 ]
    q = deque ( )
    for i in c :
        x = 0
        if i == '1' :
            x = 1
        count [ x ] += 1
        q . append ( x )
    while ( count [ 0 ] > 0 and count [ 1 ] > 0 ) :
        t = q . popleft ( )
        if ( de [ t ] > 0 ) :
            de [ t ] -= 1
            count [ t ] -= 1
        else :
            de [ t ^ 1 ] += 1
            q . append ( t )
    if ( count [ 0 ] > 0 ) :
        return "0"
    return "1"
if __name__ == ' _ _ main _ _ ' :
    S = "1010100100000"
    N = len ( S )
    print ( remainingDigit ( S , N ) )

Index/key variables: t, x
Accumulator variables: q
Iterator variables: i
Python program:
class newNode :
    def __init__ ( self , key ) :
        self . key = key
        self . left = self . right = None
def findLeafDown ( root , lev , minDist ) :
    if ( root == None ) :
        return
    if ( root . left == None and root . right == None ) :
        if ( lev < ( minDist [ 0 ] ) ) :
            minDist [ 0 ] = lev
        return
    findLeafDown ( root . left , lev + 1 , minDist )
    findLeafDown ( root . right , lev + 1 , minDist )
def findThroughParent ( root , x , minDist ) :
    if ( root == None ) :
        return - 1
    if ( root == x ) :
        return 0
    l = findThroughParent ( root . left , x , minDist )
    if ( l != - 1 ) :
        findLeafDown ( root . right , l + 2 , minDist )
        return l + 1
    r = findThroughParent ( root . right , x , minDist )
    if ( r != - 1 ) :
        findLeafDown ( root . left , r + 2 , minDist )
        return r + 1
    return - 1
def minimumDistance ( root , x ) :
    minDist = [ 999999999999 ]
    findLeafDown ( x , 0 , minDist )
    findThroughParent ( root , x , minDist )
    return minDist [ 0 ]
if __name__ == ' _ _ main _ _ ' :
    root = newNode ( 1 )
    root . left = newNode ( 12 )
    root . right = newNode ( 13 )
    root . right . left = newNode ( 14 )
    root . right . right = newNode ( 15 )
    root . right . left . left = newNode ( 21 )
    root . right . left . right = newNode ( 22 )
    root . right . right . left = newNode ( 23 )
    root . right . right . right = newNode ( 24 )
    root . right . left . left . left = newNode ( 1 )
    root . right . left . left . right = newNode ( 2 )
    root . right . left . right . left = newNode ( 3 )
    root . right . left . right . right = newNode ( 4 )
    root . right . right . left . left = newNode ( 5 )
    root . right . right . left . right = newNode ( 6 )
    root . right . right . right . left = newNode ( 7 )
    root . right . right . right . right = newNode ( 8 )
    x = root . right
    print ( " The ▁ closest ▁ leaf ▁ to ▁ the ▁ node ▁ with ▁ value " , x . key , " is ▁ at ▁ a ▁ distance ▁ of " , minimumDistance ( root , x ) )

Class/struct names: newNode
Python program:
def CountSubString ( Str , n ) :
    ans = ( n * ( n + 1 ) ) // 2
    a_index = 0
    b_index = 0
    c_index = 0
    for i in range ( n ) :
        if ( Str [ i ] == ' a ' ) :
            a_index = i + 1
            ans -= min ( b_index , c_index )
        elif ( Str [ i ] == ' b ' ) :
            b_index = i + 1
            ans -= min ( a_index , c_index )
        else :
            c_index = i + 1
            ans -= min ( a_index , b_index )
    return ans
Str = " babac "
n = len ( Str )
print ( CountSubString ( Str , n ) )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
N = 2005
mod = 10 ** 9 + 7
n , q = 0 , 0
par = [ 0 for i in range ( N ) ]
Rank = [ 0 for i in range ( N ) ]
m = dict ( )
def initialize ( ) :
    for i in range ( n + 1 ) :
        Rank [ i ] , par [ i ] = 0 , i
def find ( x ) :
    if ( par [ x ] != x ) :
        par [ x ] = find ( par [ x ] )
    return par [ x ]
def Union ( x , y ) :
    xpar = find ( x )
    ypar = find ( y )
    if ( Rank [ xpar ] < Rank [ ypar ] ) :
        par [ xpar ] = ypar
    elif ( Rank [ xpar ] > Rank [ ypar ] ) :
        par [ ypar ] = xpar
    else :
        par [ ypar ] = xpar
        Rank [ xpar ] += 1
def power ( a , m1 ) :
    if ( m1 == 0 ) :
        return 1
    elif ( m1 == 1 ) :
        return a
    elif ( m1 == 2 ) :
        return ( a * a ) % mod
    elif ( m1 & 1 ) :
        return ( a * power ( power ( a , m1 // 2 ) , 2 ) ) % mod
    else :
        return power ( power ( a , m1 // 2 ) , 2 ) % mod
def query ( l , r ) :
    if l + r in m . keys ( ) :
        m [ l + r ] = max ( m [ l + r ] , r )
    else :
        m [ l + r ] = max ( 0 , r )
def possiblestrings ( ) :
    initialize ( )
    for i in m :
        x = i - m [ i ]
        y = m [ i ]
        while ( x < y ) :
            Union ( x , y )
            x += 1
            y -= 1
    ans = 0
    for i in range ( 1 , n + 1 ) :
        if ( par [ i ] == i ) :
            ans += 1
    return power ( 26 , ans ) % mod
n = 4
query ( 1 , 3 )
query ( 2 , 4 )
print ( possiblestrings ( ) )

Index/key variables: i, x, xpar, ypar
Accumulator variables: ans, y
Iterator variables: i
Python program:
from queue import Queue
class newNode :
    def __init__ ( self , data ) :
        self . data = data
        self . left = self . right = None
def iterativeSearch ( root , x ) :
    if ( root == None ) :
        return False
    q = Queue ( )
    q . put ( root )
    while ( q . empty ( ) == False ) :
        node = q . queue [ 0 ]
        if ( node . data == x ) :
            return True
        q . get ( )
        if ( node . left != None ) :
            q . put ( node . left )
        if ( node . right != None ) :
            q . put ( node . right )
    return False
if __name__ == ' _ _ main _ _ ' :
    root = newNode ( 2 )
    root . left = newNode ( 7 )
    root . right = newNode ( 5 )
    root . left . right = newNode ( 6 )
    root . left . right . left = newNode ( 1 )
    root . left . right . right = newNode ( 11 )
    root . right . right = newNode ( 9 )
    root . right . right . left = newNode ( 4 )
    if iterativeSearch ( root , 6 ) :
        print ( " Found " )
    else :
        print ( " Not ▁ Found " )
    if iterativeSearch ( root , 12 ) :
        print ( " Found " )
    else :
        print ( " Not ▁ Found " )

Class/struct names: newNode
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . left = None
        self . right = None
        self . next = None
next = None
def populateNext ( node ) :
    populateNextRecur ( node , next )
def populateNextRecur ( p , next_ref ) :
    if ( p != None ) :
        populateNextRecur ( p . right , next_ref )
        p . next = next_ref
        next_ref = p
        populateNextRecur ( p . left , next_ref )

Class/struct names: Node
Python program:
def isValid ( string , length ) :
    for i in range ( 1 , length ) :
        if string [ i ] == string [ i - 1 ] :
            return False
    return True
if __name__ == " _ _ main _ _ " :
    string = "0110"
    length = len ( string )
    if isValid ( string , length ) :
        print ( " Valid " )
    else :
        print ( " Invalid " )

Index/key variables: i
Iterator variables: i
Python program:
def check ( s , K ) :
    for ch in range ( 0 , 26 ) :
        c = chr ( 97 + ch )
        last = - 1
        found = True
        for i in range ( 0 , K ) :
            if s [ i ] == c :
                last = i
        if last == - 1 :
            continue
        for i in range ( K , len ( s ) ) :
            if s [ i ] == c :
                last = i
            if last <= ( i - K ) :
                found = False
                break
        if found :
            return 1
    return 0
def binarySearch ( s ) :
    low , high , ans = 1 , len ( s ) , None
    while low <= high :
        mid = ( high + low ) >> 1
        if check ( s , mid ) :
            ans , high = mid , mid - 1
        else :
            low = mid + 1
    return ans
if __name__ == " _ _ main _ _ " :
    s = " abcde "
    print ( binarySearch ( s ) )
    s = " aaaa "
    print ( binarySearch ( s ) )

Index/key variables: i
Iterator variables: ch, i
Boolean variables: found
Python program:
seg = [ 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ]
def LedRequired ( s , led ) :
    count = 0
    for i in range ( len ( s ) ) :
        count += seg [ ord ( s [ i ] ) - 48 ]
    if ( count <= led ) :
        return " YES "
    else :
        return " NO "
if __name__ == " _ _ main _ _ " :
    S = "123456789"
    led = 20
    print ( LedRequired ( S , led ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
class newNode :
    def __init__ ( self , key ) :
        self . data = key
        self . left = None
        self . right = None
def iterativeSearch ( root , x ) :
    if ( root == None ) :
        return False
    nodeStack = [ ]
    nodeStack . append ( root )
    while ( len ( nodeStack ) ) :
        node = nodeStack [ 0 ]
        if ( node . data == x ) :
            return True
        nodeStack . pop ( 0 )
        if ( node . right ) :
            nodeStack . append ( node . right )
        if ( node . left ) :
            nodeStack . append ( node . left )
    return False
root = newNode ( 2 )
root . left = newNode ( 7 )
root . right = newNode ( 5 )
root . left . right = newNode ( 6 )
root . left . right . left = newNode ( 1 )
root . left . right . right = newNode ( 11 )
root . right . right = newNode ( 9 )
root . right . right . left = newNode ( 4 )
if iterativeSearch ( root , 6 ) :
    print ( " Found " )
else :
    print ( " Not ▁ Found " )
if iterativeSearch ( root , 12 ) :
    print ( " Found " )
else :
    print ( " Not ▁ Found " )

Accumulator variables: nodeStack
Class/struct names: newNode
Python program:
def find ( s1 , s2 ) :
    len__ = len ( s1 )
    len_1 = len ( s2 )
    if ( len__ != len_1 ) :
        return False
    d = [ 0 for i in range ( len__ ) ]
    d [ 0 ] = ord ( s2 [ 0 ] ) - ord ( s1 [ 0 ] )
    for i in range ( 1 , len__ , 1 ) :
        if ( s1 [ i ] > s2 [ i ] ) :
            return False
        else :
            d [ i ] = ord ( s2 [ i ] ) - ord ( s1 [ i ] )
    for i in range ( len__ - 1 ) :
        if ( d [ i ] < d [ i + 1 ] ) :
            return False
    return True
if __name__ == ' _ _ main _ _ ' :
    s1 = " abcd "
    s2 = " bcdd "
    if ( find ( s1 , s2 ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def NthCharacter ( n ) :
    s = " "
    c = 1
    while ( True ) :
        if ( c < 10 ) :
            s += chr ( 48 + c )
        else :
            s1 = " "
            dup = c
            while ( dup > 0 ) :
                s1 += chr ( ( dup % 10 ) + 48 )
                dup //= 10
            s1 = " " . join ( reversed ( s1 ) )
            s += s1
        c += 1
        if ( len ( s ) >= n ) :
            return s [ n - 1 ]
if __name__ == " _ _ main _ _ " :
    n = 11
    print ( NthCharacter ( n ) )

Accumulator variables: c, dup, s, s1
Python program:
def solve ( s , k ) :
    count , length , pos = 0 , 0 , 0
    m = dict . fromkeys ( s , 0 )
    for i in range ( len ( s ) ) :
        m [ s [ i ] ] += 1
        length += 1
        if length > k :
            m [ s [ pos ] ] -= 1
            pos += 1
            length -= 1
        if length == k and m [ s [ i ] ] == length :
            count += 1
    print ( count )
if __name__ == " _ _ main _ _ " :
    s = " aaaabbbccdddd "
    k = 4
    solve ( s , k )

Index/key variables: i, pos
Accumulator variables: count, length
Iterator variables: i
Python program:
if __name__ == ' _ _ main _ _ ' :
    str = " A ▁ computer ▁ science ▁ portal ▁ for ▁ geeks "
    for i in range ( 0 , len ( str ) , 1 ) :
        if ( str [ i ] == ' ▁ ' ) :
            str = str . replace ( str [ i ] , ' - ' )
    print ( str )

Index/key variables: i
Iterator variables: i
Python program:
import sys
MAX = sys . maxsize
m = { }
Min = sys . maxsize
def minOperation ( s , i , j , count ) :
    global Min , MAX
    if ( ( i >= len ( s ) and j < 0 ) or ( i == j ) ) :
        return MAX
    if ( s [ i ] == s [ j ] or count >= Min ) :
        return count
    Str = str ( i ) + " | " + str ( j )
    if Str not in m :
        if ( i >= len ( s ) ) :
            m [ Str ] = minOperation ( s , i , j - 1 , count + 1 )
        elif ( j < 0 ) :
            m [ Str ] = minOperation ( s , i + 1 , j , count + 1 )
        else :
            m [ Str ] = min ( minOperation ( s , i , j - 1 , count + 1 ) , minOperation ( s , i + 1 , j , count + 1 ) )
    if ( m [ Str ] < Min ) :
        Min = m [ Str ]
    return m [ Str ]
s = " bacdefghipalop "
ans = minOperation ( s , 0 , len ( s ) - 1 , 0 )
if ( ans == MAX ) :
    print ( - 1 )
else :
    print ( ans )

Index/key variables: Str, i, j
Python program:
def solve ( n , l ) :
    if l < 3 :
        if int ( n ) % 8 == 0 :
            return True
        n = n [ : : - 1 ]
        if int ( n ) % 8 == 0 :
            return True
        return False
    hash = 10 * [ 0 ]
    for i in range ( 0 , l ) :
        hash [ int ( n [ i ] ) - 0 ] += 1 ;
    for i in range ( 104 , 1000 , 8 ) :
        dup = i
        freq = 10 * [ 0 ]
        freq [ int ( dup % 10 ) ] += 1 ;
        dup = dup / 10
        freq [ int ( dup % 10 ) ] += 1 ;
        dup = dup / 10
        freq [ int ( dup % 10 ) ] += 1 ;
        dup = i
        if ( freq [ int ( dup % 10 ) ] > hash [ int ( dup % 10 ) ] ) :
            continue ;
        dup = dup / 10 ;
        if ( freq [ int ( dup % 10 ) ] > hash [ int ( dup % 10 ) ] ) :
            continue ;
        dup = dup / 10
        if ( freq [ int ( dup % 10 ) ] > hash [ int ( dup % 10 ) ] ) :
            continue ;
        return True
    return False
if __name__ == " _ _ main _ _ " :
    number = "31462708"
    l = len ( number )
    if solve ( number , l ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def newString ( s , k ) :
    X = " "
    while ( len ( s ) > 0 ) :
        temp = s [ 0 ]
        i = 1
        while ( i < k and i < len ( s ) ) :
            if ( s [ i ] < temp ) :
                temp = s [ i ]
            i += 1
        X = X + temp
        for i in range ( k ) :
            if ( s [ i ] == temp ) :
                s = s [ 0 : i ] + s [ i + 1 : ]
                break
    return X
if __name__ == ' _ _ main _ _ ' :
    s = " gaurang "
    k = 3
    print ( newString ( s , k ) )

Index/key variables: i
Iterator variables: i
Python program:
def isPalindromePossible ( input : str ) -> bool :
    length = len ( input )
    diffCount = 0
    i = 0
    diff = [ [ '0' ] * 2 ] * 2
    while i < length // 2 :
        if input [ i ] != input [ length - i - 1 ] :
            if diffCount == 2 :
                return False
            diff [ diffCount ] [ 0 ] = input [ i ]
            diff [ diffCount ] [ 1 ] = input [ length - i - 1 ]
            diffCount += 1
        i += 1
    if diffCount == 0 :
        return True
    elif diffCount == 1 :
        midChar = input [ i ]
        if length % 2 != 0 and ( diff [ 0 ] [ 0 ] == midChar or diff [ 0 ] [ 1 ] == midChar ) :
            return True
    elif diffCount == 2 :
        if ( diff [ 0 ] [ 0 ] == diff [ 1 ] [ 0 ] and diff [ 0 ] [ 1 ] == diff [ 1 ] [ 1 ] ) or ( diff [ 0 ] [ 0 ] == diff [ 1 ] [ 1 ] and diff [ 0 ] [ 1 ] == diff [ 1 ] [ 0 ] ) :
            return True
    return False
if __name__ == " _ _ main _ _ " :
    print ( isPalindromePossible ( " bbg " ) )
    print ( isPalindromePossible ( " bdababd " ) )
    print ( isPalindromePossible ( " gcagac " ) )

Index/key variables: diffCount, i
Python program:
def strToBinary ( s ) :
    bin_conv = [ ]
    for c in s :
        ascii_val = ord ( c )
        binary_val = bin ( ascii_val )
        bin_conv . append ( binary_val [ 2 : ] )
    return ( ' ▁ ' . join ( bin_conv ) )
if __name__ == ' _ _ main _ _ ' :
    s = ' geeks '
print ( strToBinary ( s ) )

Accumulator variables: bin_conv
Iterator variables: c
Python program:
from collections import defaultdict
def factorial ( n ) :
    f = 1
    for i in range ( 1 , n + 1 ) :
        f = f * i
    return f
def calculateTotal ( temp , n ) :
    f = factorial ( n )
    hm = defaultdict ( int )
    for i in range ( len ( temp ) ) :
        hm [ temp [ i ] ] += 1
    for e in hm :
        x = hm [ e ]
        if ( x > 1 ) :
            temp5 = factorial ( x )
            f //= temp5
        return f
def nextPermutation ( temp ) :
    for i in range ( len ( temp ) - 1 , 0 , - 1 ) :
        if ( temp [ i ] > temp [ i - 1 ] ) :
            break
    min = i
    x = temp [ i - 1 ]
    for j in range ( i + 1 , len ( temp ) ) :
        if ( ( temp [ j ] < temp [ min ] ) and ( temp [ j ] > x ) ) :
            min = j
    temp [ i - 1 ] , temp [ min ] = ( temp [ min ] , temp [ i - 1 ] )
    temp [ i : ] . sort ( )
    print ( ' ' . join ( temp ) )
def printAllPermutations ( s ) :
    temp = list ( s )
    temp . sort ( )
    print ( ' ' . join ( temp ) )
    total = calculateTotal ( temp , len ( temp ) )
    for i in range ( 1 , total ) :
        nextPermutation ( temp )
if __name__ == " _ _ main _ _ " :
    s = " AAB "
    printAllPermutations ( s )

Index/key variables: e, i, j, min
Accumulator variables: f
Iterator variables: e, i, j
Python program:
def printSequence ( arr , input ) :
    n = len ( input )
    output = " "
    for i in range ( n ) :
        if ( input [ i ] == ' ▁ ' ) :
            output = output + "0"
        else :
            position = ord ( input [ i ] ) - ord ( ' A ' )
            output = output + arr [ position ]
    return output
str = [ "2" , "22" , "222" , "3" , "33" , "333" , "4" , "44" , "444" , "5" , "55" , "555" , "6" , "66" , "666" , "7" , "77" , "777" , "7777" , "8" , "88" , "888" , "9" , "99" , "999" , "9999" ]
input = " GEEKSFORGEEKS " ;
print ( printSequence ( str , input ) )

Index/key variables: i, position
Iterator variables: i
Python program:
def findLUSlength ( a , b ) :
    map = dict ( )
    strArr = [ ]
    strArr . append ( a )
    strArr . append ( b )
    for s in strArr :
        for i in range ( 1 << len ( s ) ) :
            t = " "
            for j in range ( len ( s ) ) :
                if ( ( ( i >> j ) & 1 ) != 0 ) :
                    t += s [ j ]
            if ( t in map . keys ( ) ) :
                map [ t ] += 1 ;
            else :
                map [ t ] = 1
    res = 0
    for a in map :
        if ( map [ a ] == 1 ) :
            res = max ( res , len ( a ) )
    return res
a = " abcdabcd "
b = " abcabc "
print ( findLUSlength ( a , b ) )

Index/key variables: a, j, t
Iterator variables: a, i, j, s
Python program:
def Round ( s , n ) :
    s = list ( s )
    c = s . copy ( )
    if ( c [ n - 1 ] == '0' ) :
        return ( " " . join ( s ) )
    elif ( c [ n - 1 ] == '1' or c [ n - 1 ] == '2' or c [ n - 1 ] == '3' or c [ n - 1 ] == '4' or c [ n - 1 ] == '5' ) :
        c [ n - 1 ] = '0'
        return ( " " . join ( c ) )
    else :
        c [ n - 1 ] = '0'
        for i in range ( n - 2 , - 1 , - 1 ) :
            if ( c [ i ] == '9' ) :
                c [ i ] = '0'
            else :
                t = ord ( c [ i ] ) - ord ( '0' ) + 1
                c [ i ] = chr ( 48 + t )
                break
    s1 = " " . join ( c )
    if ( s1 [ 0 ] == '0' ) :
        s1 = "1" + s1
    return s1
s = "5748965412485599999874589965999"
n = len ( s )
print ( Round ( s , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def isEven ( s ) :
    l = len ( s )
    dotSeen = False
    for i in range ( l - 1 , - 1 , - 1 ) :
        if ( s [ i ] == '0' and dotSeen == False ) :
            continue
        if ( s [ i ] == ' . ' ) :
            dotSeen = True
            continue
        if ( ( int ) ( s [ i ] ) % 2 == 0 ) :
            return True
        return False
s = "100.70"
if ( isEven ( s ) ) :
    print ( " Even " )
else :
    print ( " Odd " )

Index/key variables: i
Iterator variables: i
Boolean variables: dotSeen
Python program:
def minCost ( s ) :
    alphabets = [ False for i in range ( 26 ) ]
    for i in range ( len ( s ) ) :
        alphabets [ ord ( s [ i ] ) - 97 ] = True
    count = 0
    for i in range ( 26 ) :
        if ( alphabets [ i ] ) :
            count += 1
    return count
if __name__ == ' _ _ main _ _ ' :
    s = " geeksforgeeks "
    print ( " Total ▁ cost ▁ to ▁ construct " , s , " is " , minCost ( s ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
class newnode :
    def __init__ ( self , key ) :
        self . key = key
        self . left = None
        self . right = None
def pathCountUtil ( node , m , path_len ) :
    if ( node == None ) :
        return
    if ( node . left == None and node . right == None ) :
        if path_len [ 0 ] not in m :
            m [ path_len [ 0 ] ] = 0
        m [ path_len [ 0 ] ] += 1
        return
    pathCountUtil ( node . left , m , [ path_len [ 0 ] + 1 ] )
    pathCountUtil ( node . right , m , [ path_len [ 0 ] + 1 ] )
def pathCounts ( root ) :
    m = { }
    path_len = [ 1 ]
    pathCountUtil ( root , m , path_len )
    for itr in sorted ( m , reverse = True ) :
        print ( m [ itr ] , " ▁ paths ▁ have ▁ length ▁ " , itr )
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 . right . right = newnode ( 11 )
    root . right . right . left = newnode ( 3 )
    pathCounts ( root )

Index/key variables: itr
Iterator variables: itr
Class/struct names: newnode
Python program:
def removeDuplicates ( S ) :
    n = len ( S )
    if ( n < 2 ) :
        return
    j = 0
    for i in range ( n ) :
        if ( S [ j ] != S [ i ] ) :
            j += 1
            S [ j ] = S [ i ]
    j += 1
    S = S [ : j ]
    return S
if __name__ == ' _ _ main _ _ ' :
    S1 = " geeksforgeeks "
    S1 = list ( S1 . rstrip ( ) )
    S1 = removeDuplicates ( S1 )
    print ( * S1 , sep = " " )
    S2 = " aabcca "
    S2 = list ( S2 . rstrip ( ) )
    S2 = removeDuplicates ( S2 )
    print ( * S2 , sep = " " )

Index/key variables: i, j
Iterator variables: i