dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def isBalanced ( exp ) :
    flag = True
    count = 0
    for i in range ( len ( exp ) ) :
        if ( exp [ i ] == ' ( ' ) :
            count += 1
        else :
            count -= 1
        if ( count < 0 ) :
            flag = False
            break
    if ( count != 0 ) :
        flag = False
    return flag
if __name__ == ' _ _ main _ _ ' :
    exp1 = " ( ( ( ) ) ) ( ) ( ) "
    if ( isBalanced ( exp1 ) ) :
        print ( " Balanced " )
    else :
        print ( " Not ▁ Balanced " )
    exp2 = " ( ) ) ( ( ( ) ) "
    if ( isBalanced ( exp2 ) ) :
        print ( " Balanced " )
    else :
        print ( " Not ▁ Balanced " )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Boolean variables: flag
Python program:
def count ( N , X , subStr , index , n ) :
    if ( index == n ) :
        return 0
    a = subStr + N [ index ]
    b = 0
    if ( int ( a ) % X == 0 ) :
        b = 1
    m1 = count ( N , X , a , index + 1 , n )
    m2 = b + count ( N , X , " " , index + 1 , n )
    return max ( m1 , m2 )
N = "00001242"
K = 3
l = len ( N )
print ( count ( N , K , " " , 0 , l ) )

Index/key variables: index
Python program:
def checkSuffix ( A , B ) :
    s1 = str ( A ) ;
    s2 = str ( B ) ;
    n1 = len ( s1 )
    n2 = len ( s2 )
    if ( n1 < n2 ) :
        return False ;
    for i in range ( n2 ) :
        if ( s1 [ n1 - i - 1 ] != s2 [ n2 - i - 1 ] ) :
            return False ;
    return True ;
A = 12345
B = 45 ;
result = checkSuffix ( A , B ) ;
if ( result ) :
    print ( " Yes " )
else :
    print ( " No " )

Iterator variables: i
Python program:
def build_binary_str ( p , q , r ) :
    ans = " "
    if ( q == 0 ) :
        if ( p != 0 and r != 0 ) :
            return " - 1"
        else :
            if ( p ) :
                temp = " "
                for i in range ( p + 1 ) :
                    temp += '0'
                ans = temp
            else :
                temp = " "
                for i in range ( r + 1 ) :
                    temp += '1'
                ans = temp
    else :
        for i in range ( 1 , q + 2 ) :
            if ( i % 2 == 0 ) :
                ans += '0'
            else :
                ans += '1'
        temp = " "
        for i in range ( p ) :
            temp += '0'
        st = " "
        st += ans [ 0 ]
        st += temp
        for i in range ( 1 , len ( ans ) ) :
            st += ans [ i ]
        ans = st
        temp = " "
        for i in range ( r ) :
            temp += '1'
        ans = temp + ans
    return ans
if __name__ == ' _ _ main _ _ ' :
    p = 1
    q = 2
    r = 2
    print ( build_binary_str ( p , q , r ) )

Index/key variables: i
Accumulator variables: ans, st, temp
Iterator variables: i
Python program:
def check ( s ) :
    ok = True
    for i in range ( 0 , len ( s ) - 1 , 1 ) :
        ok = ( ok & ( abs ( ord ( s [ i ] ) - ord ( s [ i + 1 ] ) ) != 1 ) )
    return ok
def monotonousString ( s ) :
    odd = " "
    even = " "
    for i in range ( len ( s ) ) :
        if ( ord ( s [ i ] ) % 2 == 0 ) :
            odd += s [ i ]
        else :
            even += s [ i ]
    odd = list ( odd )
    odd . sort ( reverse = False )
    odd = str ( odd )
    even = list ( even )
    even . sort ( reverse = False )
    even = str ( even )
    if ( check ( odd + even ) ) :
        return " Yes "
    elif ( check ( even + odd ) ) :
        return " Yes "
    return " No "
if __name__ == ' _ _ main _ _ ' :
    str1 = " abcd "
    ans = monotonousString ( str1 )
    print ( ans )

Index/key variables: i
Accumulator variables: even, odd
Iterator variables: i
Boolean variables: ok
Python program:
def get_index ( ch ) :
    if ( ch == ' a ' ) :
        return 0
    elif ( ch == ' e ' ) :
        return 1
    elif ( ch == ' i ' ) :
        return 2
    elif ( ch == ' o ' ) :
        return 3
    elif ( ch == ' u ' ) :
        return 4
    else :
        return - 1
def findMinLength ( s ) :
    n = len ( s )
    ans = n + 1
    start = 0
    count = [ 0 ] * 5
    for x in range ( n ) :
        idx = get_index ( s [ x ] )
        if ( idx != - 1 ) :
            count [ idx ] += 1
        idx_start = get_index ( s [ start ] )
        while ( idx_start == - 1 or count [ idx_start ] > 1 ) :
            if ( idx_start != - 1 ) :
                count [ idx_start ] -= 1
            start += 1
            if ( start < n ) :
                idx_start = get_index ( s [ start ] )
        if ( count [ 0 ] > 0 and count [ 1 ] > 0 and count [ 2 ] > 0 and count [ 3 ] > 0 and count [ 4 ] > 0 ) :
            ans = min ( ans , x - start + 1 )
    if ( ans == n + 1 ) :
        return - 1
    return ans
if __name__ == " _ _ main _ _ " :
    s = " aaeebbeaccaaoiuooooooooiuu "
    print ( findMinLength ( s ) )

Index/key variables: idx, idx_start, start, x
Iterator variables: x
Python program:
def countStrings ( s ) :
    cnt = 0 ;
    for i in range ( 1 , len ( s ) - 1 ) :
        if ( s [ i ] == s [ i + 1 ] ) :
            cnt += 1 ;
    return cnt ;
if __name__ == ' _ _ main _ _ ' :
    str = " aacbb " ;
    print ( countStrings ( str ) ) ;

Index/key variables: i
Accumulator variables: cnt
Iterator variables: i
Python program:
def checkValidString ( str ) :
    freq = [ 0 for i in range ( 26 ) ]
    for i in range ( len ( str ) ) :
        freq [ ord ( str [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( 26 ) :
        if ( freq [ i ] != 0 ) :
            if ( freq [ i ] != i + 1 ) :
                return False
    return True
str = " abbcccdddd "
if ( checkValidString ( str ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def removeRepeating ( s1 , s2 ) :
    s3 = s1 + " ▁ " + s2 + " ▁ "
    words = " "
    i = 0
    for x in s3 :
        if ( x == ' ▁ ' ) :
            if ( words not in s1 or words not in s2 ) :
                print ( words , end = " " )
            words = " ▁ "
        else :
            words = words + x
if __name__ == " _ _ main _ _ " :
    s1 = " I ▁ have ▁ go ▁ a ▁ pen "
    s2 = " I ▁ want ▁ to ▁ go ▁ park "
    removeRepeating ( s1 , s2 )

Iterator variables: x
Python program:
def convert ( input ) :
    Len = len ( input )
    i = 0
    while ( i < Len ) :
        if ( input [ i ] == " , " ) :
            input = input [ : i ] + input [ i + 1 : ]
            Len -= 1
            i -= 1
        elif ( input [ i ] == " ▁ " ) :
            input = input [ : i ] + input [ i + 1 : ]
            Len -= 1
            i -= 1
        else :
            i += 1
    input = input [ : : - 1 ]
    output = " "
    for i in range ( Len ) :
        if ( i == 2 ) :
            output += input [ i ]
            output += " ▁ , "
        elif ( i > 2 and i % 2 == 0 and i + 1 < Len ) :
            output += input [ i ]
            output += " ▁ , "
        else :
            output += input [ i ]
    output = output [ : : - 1 ]
    return output
input1 = "123 , ▁ 456 , ▁ 789"
input2 = "90 , ▁ 050 , ▁ 000 , ▁ 000"
print ( convert ( input1 ) )
print ( convert ( input2 ) )

Index/key variables: i
Accumulator variables: Len, output
Iterator variables: i
Python program:
def max_segments ( st , K ) :
    n = len ( st )
    s , sum , count = 0 , 0 , 0
    for i in range ( n - 1 , - 1 , - 1 ) :
        a = ord ( st [ i ] ) - 48
        sum += a * pow ( 2 , s )
        s += 1
        if ( sum != 0 and sum % K == 0 ) :
            count += 1
            sum = 0
            s = 0
    if ( sum != 0 ) :
        print ( " - 1" )
    else :
        print ( count )
if __name__ == " _ _ main _ _ " :
    st = "10111001"
    K = 5
    max_segments ( st , K )

Index/key variables: i
Accumulator variables: count, s, sum
Iterator variables: i
Python program:
def kth_string ( n , k ) :
    for i in range ( n - 2 , - 1 , - 1 ) :
        if k <= ( n - i - 1 ) :
            for j in range ( n ) :
                if ( j == i or j == n - k ) :
                    print ( ' Y ' , end = " " )
                else :
                    print ( ' X ' , end = " " )
            break
        k -= ( n - i - 1 )
n = 5
k = 7
kth_string ( n , k )

Accumulator variables: k
Iterator variables: i, j
Python program:
def convertString ( str1 , str2 , str3 ) :
    freq = { }
    for i in range ( len ( str3 ) ) :
        if ( freq . get ( str3 [ i ] ) == None ) :
            freq [ str3 [ i ] ] = 1
        else :
            freq . get ( str3 [ i ] , 1 )
    ptr1 = 0
    ptr2 = 0 ;
    flag = True
    while ( ptr1 < len ( str1 ) and ptr2 < len ( str2 ) ) :
        if ( str1 [ ptr1 ] == str2 [ ptr2 ] ) :
            ptr1 += 1
            ptr2 += 1
        else :
            if ( freq [ str3 [ ptr2 ] ] > 0 ) :
                freq [ str3 [ ptr2 ] ] -= 1
                ptr2 += 1
            else :
                flag = False
                break
    if ( flag and ptr1 == len ( str1 ) and ptr2 == len ( str2 ) ) :
        print ( " YES " )
    else :
        print ( " NO " )
if __name__ == ' _ _ main _ _ ' :
    str1 = " abyzfe "
    str2 = " abcdeyzf "
    str3 = " popode "
    convertString ( str1 , str2 , str3 )

Index/key variables: i, ptr1, ptr2
Iterator variables: i
Boolean variables: flag
Python program:
def maxOverlap ( S , T ) :
    str = T
    count = [ 0 for i in range ( len ( T ) ) ]
    overlap = 0
    max_overlap = 0
    for i in range ( 0 , len ( S ) ) :
        index = str . find ( S [ i ] )
        if ( index == 0 ) :
            overlap += 1
            if ( overlap >= 2 ) :
                max_overlap = max ( overlap , max_overlap )
            count [ index ] += 1
        else :
            if ( count [ index - 1 ] <= 0 ) :
                return - 1
            count [ index ] += 1
            count [ index - 1 ] -= 1
        if ( index == 4 ) :
            overlap -= 1
    if ( overlap == 0 ) :
        return max_overlap
    else :
        return - 1
S = " chcirphirp "
T = " chirp "
print ( maxOverlap ( S , T ) )

Index/key variables: i, index
Accumulator variables: overlap
Iterator variables: i
Python program:
MAX = 500001
parent = [ 0 ] * MAX
Rank = [ 0 ] * MAX
def find ( x ) :
    if parent [ x ] == x :
        return x
    else :
        return find ( parent [ x ] )
def merge ( r1 , r2 ) :
    if ( r1 != r2 ) :
        if ( Rank [ r1 ] > Rank [ r2 ] ) :
            parent [ r2 ] = r1
            Rank [ r1 ] += Rank [ r2 ]
        else :
            parent [ r1 ] = r2
            Rank [ r2 ] += Rank [ r1 ]
def minimumOperations ( s1 , s2 ) :
    for i in range ( 1 , 26 + 1 ) :
        parent [ i ] = i
        Rank [ i ] = 1
    ans = [ ]
    for i in range ( len ( s1 ) ) :
        if ( s1 [ i ] != s2 [ i ] ) :
            if ( find ( ord ( s1 [ i ] ) - 96 ) != find ( ord ( s2 [ i ] ) - 96 ) ) :
                x = find ( ord ( s1 [ i ] ) - 96 )
                y = find ( ord ( s2 [ i ] ) - 96 )
                merge ( x , y )
                ans . append ( [ s1 [ i ] , s2 [ i ] ] )
    print ( len ( ans ) )
    for i in ans :
        print ( i [ 0 ] , " - > " , i [ 1 ] )
if __name__ == ' _ _ main _ _ ' :
    s1 = " abb "
    s2 = " dad "
    minimumOperations ( s1 , s2 )

Index/key variables: i, r1, r2, x
Accumulator variables: ans
Iterator variables: i
Python program:
def string_permutation ( n , str ) :
    s = [ ]
    result = " "
    str = list ( str )
    n = n - 1
    for i in range ( 1 , len ( str ) + 1 ) :
        s . append ( n % i )
        n = int ( n / i )
    for i in range ( len ( str ) ) :
        a = s [ - 1 ]
        result += str [ a ]
        for j in range ( a , len ( str ) - 1 ) :
            str [ j ] = str [ j + 1 ]
        str [ j + 1 ] = ' \0'
        s . pop ( )
    print ( result )
str = " abcde "
n = 11
string_permutation ( n , str )

Index/key variables: a, j
Accumulator variables: result, s
Iterator variables: i, j
Python program:
def GeberateDefangIP ( str ) :
    defangIP = " " ;
    for c in str :
        if ( c == ' . ' ) :
            defangIP += " [ . ] "
        else :
            defangIP += c ;
    return defangIP ;
str = "255.100.50.0" ;
print ( GeberateDefangIP ( str ) ) ;

Accumulator variables: defangIP
Iterator variables: c
Python program:
def kmp ( s ) :
    lps = [ 0 ] * ( len ( s ) )
    for i in range ( 1 , len ( s ) ) :
        previous_index = lps [ i - 1 ]
        while ( previous_index > 0 and s [ i ] != s [ previous_index ] ) :
            previous_index = lps [ previous_index - 1 ]
        lps [ i ] = previous_index
        if ( s [ i ] == s [ previous_index ] ) :
            lps [ i ] += 1
    return lps [ - 1 ]
def remainingStringLongestPallindrome ( s ) :
    t = s + " ? "
    s = s [ : : - 1 ]
    t += s
    return kmp ( t )
def longestPrefixSuffixPallindrome ( s ) :
    length = 0
    n = len ( s )
    i = 0
    j = n - 1
    while i < j :
        if ( s [ i ] != s [ j ] ) :
            break
        i += 1
        j -= 1
        length += 1
    ans = s [ 0 : length ]
    remaining = s [ length : length + ( n - ( 2 * length ) ) ]
    if ( len ( remaining ) ) :
        longest_prefix = remainingStringLongestPallindrome ( remaining ) ;
        remaining = remaining [ : : - 1 ]
        longest_suffix = remainingStringLongestPallindrome ( remaining ) ;
        if ( longest_prefix > longest_suffix ) :
            remaining = remaining [ : : - 1 ]
            ans += remaining [ 0 : longest_prefix ]
        else :
            ans += remaining [ 0 : longest_suffix ]
    ans += s [ n - length : n ]
    return ans
if __name__ == " _ _ main _ _ " :
    st = " rombobinnimor "
    print ( longestPrefixSuffixPallindrome ( st ) )

Index/key variables: i, j, previous_index
Accumulator variables: length
Iterator variables: i
Python program:
def generateTheString ( n ) :
    ans = " "
    if ( n % 2 ) :
        for i in range ( min ( n , 24 ) ) :
            ans += chr ( ord ( ' b ' ) + i )
        if ( n > 24 ) :
            for i in range ( ( n - 24 ) ) :
                ans += ' a '
    else :
        for i in range ( min ( n , 25 ) ) :
            ans += chr ( ord ( ' b ' ) + i )
        if ( n > 25 ) :
            for i in range ( ( n - 25 ) ) :
                ans += ' a '
    return ans
if __name__ == " _ _ main _ _ " :
    n = 34
    print ( generateTheString ( n ) )

Accumulator variables: ans
Iterator variables: i
Python program:
def String ( l , x , y ) :
    p = 97
    for j in range ( l ) :
        ans = chr ( p + j % y )
        print ( ans , end = " " )
l = 6
x = 5
y = 3
String ( l , x , y )

Iterator variables: j
Python program:
def finalCoordinates ( SX , SY , D ) :
    for i in range ( len ( D ) ) :
        if ( D [ i ] == ' N ' ) :
            SY += 1
        elif ( D [ i ] == ' S ' ) :
            SY -= 1
        elif ( D [ i ] == ' E ' ) :
            SX += 1
        else :
            SX -= 1
    ans = ' ( ' + str ( SX ) + ' , ' + str ( SY ) + ' ) '
    print ( ans )
if __name__ == ' _ _ main _ _ ' :
    SX , SY = 2 , 2
    D = " NSSE "
    finalCoordinates ( SX , SY , D )

Index/key variables: i
Accumulator variables: SX, SY
Iterator variables: i
Python program:
from bisect import bisect_right as upper_bound
def countMinFreq ( s ) :
    s = sorted ( s )
    x = 0
    for i in s :
        if i == s [ 0 ] :
            x += 1
    return x
def countLessThan ( arr1 , arr2 ) :
    freq = [ ]
    for s in arr2 :
        f = countMinFreq ( s )
        freq . append ( f )
    feq = sorted ( freq )
    for s in arr1 :
        f = countMinFreq ( s ) ;
        it = upper_bound ( freq , f )
        cnt = len ( freq ) - it
        print ( cnt , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    arr1 = [ " yyy " , " zz " ]
    arr2 = [ " x " , " xx " , " xxx " , " xxxx " ]
    countLessThan ( arr1 , arr2 ) ;

Accumulator variables: freq, x
Iterator variables: i, s
Python program:
def shortestPalindrome ( s ) :
    abcd = [ 0 ] * 26
    for i in range ( len ( s ) ) :
        abcd [ ord ( s [ i ] ) - 97 ] = 1
    for i in range ( 26 ) :
        if abcd [ i ] == 1 :
            print ( chr ( i + 97 ) , end = ' ▁ ' )
s = " geeksforgeeks "
shortestPalindrome ( s )

Index/key variables: i
Iterator variables: i
Python program:
def removeDuplicates ( str ) :
    n = len ( str )
    res = " "
    for i in range ( n ) :
        j = i + 1
        while j < n :
            if ( str [ i ] == str [ j ] ) :
                break
            j += 1
        if ( j == n ) :
            res = res + str [ i ]
    return res
if __name__ == ' _ _ main _ _ ' :
    str = " geeksforgeeks "
    print ( removeDuplicates ( str ) )

Index/key variables: i, j
Iterator variables: i
Python program:
def removeDuplicates ( str ) :
    n = len ( str )
    s = set ( )
    res = " "
    for i in range ( n - 1 , - 1 , - 1 ) :
        if ( str [ i ] not in s ) :
            res = res + str [ i ]
            s . add ( str [ i ] )
    res = res [ : : - 1 ]
    return res
str = " geeksforgeeks "
print ( removeDuplicates ( str ) )

Index/key variables: i
Accumulator variables: s
Iterator variables: i
Python program:
max1 = 0
def MaxLength ( v , i , m ) :
    global max1
    if ( i >= m ) :
        return m - 1
    for k in range ( 26 ) :
        c = chr ( ord ( ' a ' ) + k )
        v1 = [ ]
        for j in range ( len ( v ) ) :
            if ( v [ j ] [ i ] == c ) :
                v1 . append ( v [ j ] )
        if ( len ( v1 ) >= 2 ) :
            max1 = max ( max1 , MaxLength ( v1 , i + 1 , m ) )
        else :
            max1 = max ( max1 , i - 1 )
    return max1
if __name__ == ' _ _ main _ _ ' :
    s1 = " abcde "
    s2 = " abcsd "
    s3 = " bcsdf "
    s4 = " abcda "
    s5 = " abced "
    v = [ ]
    v . append ( s1 )
    v . append ( s2 )
    v . append ( s3 )
    v . append ( s4 )
    v . append ( s5 )
    m = len ( v [ 0 ] )
    print ( MaxLength ( v , 0 , m ) + 1 )

Index/key variables: i, j
Accumulator variables: v1
Iterator variables: j, k
Python program:
def findPeriodicString ( S ) :
    l = 2 * len ( S )
    count = 0
    for i in range ( len ( S ) ) :
        if ( S [ i ] == '1' ) :
            count += 1
    if ( count == len ( S ) or count == 0 ) :
        print ( S )
    else :
        arr = [ '0' ] * l
        for i in range ( 0 , l , 2 ) :
            arr [ i ] = '1'
            arr [ i + 1 ] = '0'
        for i in range ( l ) :
            print ( arr [ i ] , end = " " )
if __name__ == ' _ _ main _ _ ' :
    S = "1111001"
    findPeriodicString ( S )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
CHILDREN = 26
MAX = 100
class trie :
    def __init__ ( self ) :
        self . child = [ 0 for i in range ( CHILDREN ) ]
        self . endOfWord = False ;
def createNode ( ) :
    temp = trie ( ) ;
    temp . endOfWord = False ;
    for i in range ( CHILDREN ) :
        temp . child [ i ] = None ;
    return temp ;
def insertRecursively ( itr , str , i ) :
    if ( i < len ( str ) ) :
        index = ord ( str [ i ] ) - ord ( ' a ' ) ;
        if ( itr . child [ index ] == None ) :
            itr . child [ index ] = createNode ( ) ;
        insertRecursively ( itr . child [ index ] , str , i + 1 ) ;
    else :
        itr . endOfWord = True ;
def insert ( itr , str ) :
    insertRecursively ( itr , str , 0 ) ;
def isLeafNode ( root ) :
    return root . endOfWord != False ;
def displayContent ( root , str , level ) :
    if ( isLeafNode ( root ) ) :
        print ( " " . join ( str [ : level ] ) )
    for i in range ( CHILDREN - 1 , - 1 , - 1 ) :
        if ( root . child [ i ] ) :
            str [ level ] = chr ( i + ord ( ' a ' ) ) ;
            displayContent ( root . child [ i ] , str , level + 1 ) ;
def display ( itr ) :
    level = 0 ;
    str = [ ' ' for i in range ( MAX ) ] ;
    displayContent ( itr , str , level ) ;
if __name__ == ' _ _ main _ _ ' :
    root = createNode ( ) ;
    insert ( root , " their " ) ;
    insert ( root , " there " ) ;
    insert ( root , " answer " ) ;
    insert ( root , " any " ) ;
    display ( root ) ;

Index/key variables: i, index, level
Iterator variables: i
Class/struct names: trie
Python program:
import bisect
v = [ [ ] for _ in range ( 26 ) ]
def calculate ( s : str ) -> None :
    for i in range ( len ( s ) ) :
        v [ ord ( s [ i ] ) - ord ( ' a ' ) ] . append ( i )
def query ( L : int , R : int ) -> None :
    duplicates = 0
    for i in range ( 26 ) :
        first = bisect . bisect_left ( v [ i ] , L - 1 )
        if ( first < len ( v [ i ] ) and v [ i ] [ first ] < R ) :
            first += 1
            if ( first < len ( v [ i ] ) and v [ i ] [ first ] < R ) :
                duplicates += 1
    print ( duplicates )
if __name__ == " _ _ main _ _ " :
    s = " geeksforgeeks "
    Q = 2
    l1 = 1
    r1 = 5
    l2 = 4
    r2 = 8
    calculate ( s )
    query ( l1 , r1 )
    query ( l2 , r2 )

Index/key variables: first, i
Accumulator variables: duplicates
Iterator variables: i
Python program:
def group_formed ( S ) :
    count = 1
    for i in range ( len ( S ) - 1 ) :
        a = S [ i ]
        b = S [ i + 1 ]
        if ( a != b ) :
            count += 1
    print ( count )
if __name__ == " _ _ main _ _ " :
    S = " TTWWW "
    group_formed ( S )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def value ( x ) :
    return ( ord ( x ) - ord ( ' a ' ) )
def maximumProduct ( strr , n ) :
    answer = " "
    curr = " "
    maxProduct = 0
    product = 1
    for i in range ( n ) :
        product *= value ( strr [ i ] )
        curr += strr [ i ]
        if ( product >= maxProduct ) :
            maxProduct = product
            answer = curr
        if ( product == 0 ) :
            product = 1
            curr = " "
    return answer
if __name__ == ' _ _ main _ _ ' :
    strr = " sdtfakdhdahdzz "
    n = len ( strr )
    print ( maximumProduct ( strr , n ) )

Index/key variables: i
Accumulator variables: curr, product
Iterator variables: i
Python program:
def solve ( a , b ) :
    l = len ( a )
    min = 0
    max = 0
    for i in range ( l ) :
        if ( a [ i ] == ' + ' or b [ i ] == ' + ' or a [ i ] != b [ i ] ) :
            max += 1
        if ( a [ i ] != ' + ' and b [ i ] != ' + ' and a [ i ] != b [ i ] ) :
            min += 1
    print ( min + max )
if __name__ == ' _ _ main _ _ ' :
    s1 = " a + c "
    s2 = " + + b "
    solve ( s1 , s2 )

Index/key variables: i
Accumulator variables: max, min
Iterator variables: i
Python program:
def noOfDeletions ( string , k ) :
    ans = 0 ; cnt = 0 ; pos = 0 ;
    while ( pos < len ( string ) and string [ pos ] != k ) :
        pos += 1 ;
    i = pos ;
    while ( i < len ( string ) ) :
        while ( i < len ( string ) and string [ i ] == k ) :
            i = i + 1 ;
        ans = ans + cnt ;
        cnt = 0 ;
        while ( i < len ( string ) and string [ i ] != k ) :
            i = i + 1 ;
            cnt = cnt + 1 ;
    return ans ;
if __name__ == " _ _ main _ _ " :
    str1 = " ababababa " ;
    k1 = ' a ' ;
    print ( noOfDeletions ( str1 , k1 ) ) ;
    str2 = " kprkkoinkopt " ;
    k2 = ' k ' ;
    print ( noOfDeletions ( str2 , k2 ) ) ;

Index/key variables: i, pos
Python program:
def val ( c ) :
    if ( c >= '0' and c <= '9' ) :
        return int ( c )
    else :
        return c - ' A ' + 10
def toDeci ( strr , base ) :
    lenn = len ( strr )
    power = 1
    num = 0
    for i in range ( lenn - 1 , - 1 , - 1 ) :
        if ( val ( strr [ i ] ) >= base ) :
            return - 1
        num += val ( strr [ i ] ) * power
        power = power * base
    return num
def checkCorrespond ( strr , x ) :
    counter = 0
    n = len ( strr )
    for i in range ( n ) :
        for j in range ( 2 , 37 ) :
            if ( toDeci ( strr [ i ] , j ) == x ) :
                counter += 1
                break
    if ( counter == n ) :
        print ( " YES " )
    else :
        print ( " NO " )
x = 16
strr = [ "10000" , "20" , "16" ]
checkCorrespond ( strr , x )

Index/key variables: i
Accumulator variables: counter, num
Iterator variables: i, j