dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def countCharacterType ( str ) :
    vowels = 0
    consonant = 0
    specialChar = 0
    digit = 0
    for i in range ( 0 , len ( str ) ) :
        ch = str [ i ]
        if ( ( ch >= ' a ' and ch <= ' z ' ) or ( ch >= ' A ' and ch <= ' Z ' ) ) :
            ch = ch . lower ( )
            if ( ch == ' a ' or ch == ' e ' or ch == ' i ' or ch == ' o ' or ch == ' u ' ) :
                vowels += 1
            else :
                consonant += 1
        elif ( ch >= '0' and ch <= '9' ) :
            digit += 1
        else :
            specialChar += 1
    print ( " Vowels : " , vowels )
    print ( " Consonant : " , consonant )
    print ( " Digit : " , digit )
    print ( " Special ▁ Character : " , specialChar )
str = " geeks ▁ for ▁ geeks121"
countCharacterType ( str )

Index/key variables: i
Accumulator variables: consonant, digit, specialChar, vowels
Iterator variables: i
Python program:
def findNextWord ( s , m ) :
    m += 97
    n = len ( s )
    i = len ( s ) - 1
    s [ i ] = chr ( ord ( s [ i ] ) + 1 )
    while i >= 0 and i <= n - 1 :
        if ord ( s [ i ] ) >= m :
            s [ i ] = ' a '
            i -= 1
            s [ i ] = chr ( ord ( s [ i ] ) + 1 )
        elif s [ i ] == s [ i - 1 ] or s [ i ] == s [ i - 2 ] :
            s [ i ] = chr ( ord ( s [ i ] ) + 1 )
        else :
            i += 1
    if i <= - 1 :
        print ( " - 1" )
    else :
        print ( ' ' . join ( s ) )
if __name__ == " _ _ main _ _ " :
    string = " abcd "
    k = 4
    findNextWord ( list ( string ) , k )

Index/key variables: i
Python program:
def replace ( s , c1 , c2 ) :
    l = len ( s )
    for i in range ( l ) :
        if ( s [ i ] == c1 ) :
            s = s [ 0 : i ] + c2 + s [ i + 1 : ]
        elif ( s [ i ] == c2 ) :
            s = s [ 0 : i ] + c1 + s [ i + 1 : ]
    return s
if __name__ == ' _ _ main _ _ ' :
    s = " grrksfoegrrks "
    c1 = ' e '
    c2 = ' r '
    print ( replace ( s , c1 , c2 ) )

Index/key variables: i
Iterator variables: i
Python program:
def fibWord ( n ) :
    Sn_1 = "0"
    Sn = "01"
    tmp = " "
    for i in range ( 2 , n + 1 ) :
        tmp = Sn
        Sn += Sn_1
        Sn_1 = tmp
    return Sn
n = 6
print ( fibWord ( n ) )

Accumulator variables: Sn
Iterator variables: i
Python program:
def conversion ( charSet , str1 ) :
    s2 = " "
    for i in str1 :
        s2 += alphabets [ charSet . index ( i ) ]
    return s2
if __name__ == ' _ _ main _ _ ' :
    alphabets = " abcdefghijklmnopqrstuvwxyz "
    charSet = " qwertyuiopasdfghjklzxcvbnm "
    str1 = " egrt "
    print ( conversion ( charSet , str1 ) )

Accumulator variables: s2
Iterator variables: i
Python program:
def numberOfDifferentSubstrings ( s , a , b ) :
    ans = 0
    ls = len ( s )
    la = len ( a )
    lb = len ( b )
    x = [ 0 ] * ls
    y = [ 0 ] * ls
    for i in range ( ls ) :
        if ( s [ i : la + i ] == a ) :
            x [ i ] = 1
        if ( s [ i : lb + i ] == b ) :
            y [ i ] = 1
    hash = [ ]
    curr_substr = " "
    for i in range ( ls ) :
        if ( x [ i ] ) :
            for j in range ( i , ls ) :
                if ( not y [ j ] ) :
                    curr_substr += s [ j ]
                if ( y [ j ] ) :
                    curr_substr += s [ j : lb + j ]
                    if curr_substr not in hash :
                        ans += 1
                    hash . append ( curr_substr )
            curr_substr = " "
    return ans
if __name__ == " _ _ main _ _ " :
    s = " codecppforfood "
    begin = " c "
    end = " d "
    print ( numberOfDifferentSubstrings ( s , begin , end ) )

Index/key variables: i, j
Accumulator variables: ans, curr_substr, hash
Iterator variables: i, j
Python program:
max = 100
def carveCross ( str ) :
    n = len ( str )
    if ( n % 2 == 0 ) :
        print ( " Not ▁ possible . ▁ Please ▁ enter ▁ " ,   " odd length string . " )
    else :
        arr = [ [ False for x in range ( max ) ] for y in range ( max ) ]
        m = n // 2
        for i in range ( n ) :
            for j in range ( n ) :
                arr [ i ] [ j ] = ' X '
        for i in range ( n ) :
            arr [ i ] [ m ] = str [ i ]
        for i in range ( n ) :
            arr [ m ] [ i ] = str [ i ]
        for i in range ( n ) :
            for j in range ( n ) :
                print ( arr [ i ] [ j ] , end = " ▁ " )
            print ( )
if __name__ == " _ _ main _ _ " :
    str = " PICTURE "
    carveCross ( str )

Index/key variables: i, j, m
Iterator variables: i, j
Python program:
def generateString ( n ) :
    s = " " ;
    for i in range ( n ) :
        if ( ( i & 2 ) > 1 ) :
            s += ' b ' ;
        else :
            s += ' a ' ;
    print ( s ) ;
if __name__ == ' _ _ main _ _ ' :
    n = 5 ;
    generateString ( n ) ;
    n = 8 ;
    generateString ( n ) ;
    n = 10 ;
    generateString ( n ) ;

Accumulator variables: s
Iterator variables: i
Python program:
def subsequence ( s , binary , length ) :
    sub = " "
    for j in range ( length ) :
        if ( binary & ( 1 << j ) ) :
            sub += s [ j ]
    return sub
def possibleSubsequences ( s ) :
    sorted_subsequence = { }
    length = len ( s )
    limit = 2 ** length
    for i in range ( 1 , limit ) :
        sub = subsequence ( s , i , length )
        if len ( sub ) in sorted_subsequence . keys ( ) :
            sorted_subsequence [ len ( sub ) ] = tuple ( list ( sorted_subsequence [ len ( sub ) ] ) + [ sub ] )
        else :
            sorted_subsequence [ len ( sub ) ] = [ sub ]
    for it in sorted_subsequence :
        print ( " Subsequences ▁ of ▁ length ▁ = " , it , " are : " )
        for ii in sorted ( set ( sorted_subsequence [ it ] ) ) :
            print ( ii , end = ' ▁ ' )
        print ( )
s = " aabc "
possibleSubsequences ( s )

Index/key variables: it, j
Accumulator variables: sub
Iterator variables: i, ii, it, j
Python program:
from math import log2 , floor
def subsequence ( s , binary ) :
    sub = " "
    while ( binary > 0 ) :
        pos = floor ( log2 ( binary & - binary ) + 1 )
        sub = s [ pos - 1 ] + sub
        binary = ( binary & ~ ( 1 << ( pos - 1 ) ) )
    sub = sub [ : : - 1 ]
    return sub
def possibleSubsequences ( s ) :
    sorted_subsequence = { }
    length = len ( s )
    limit = 2 ** length
    for i in range ( 1 , limit ) :
        sub = subsequence ( s , i )
        if len ( sub ) in sorted_subsequence . keys ( ) :
            sorted_subsequence [ len ( sub ) ] = tuple ( list ( sorted_subsequence [ len ( sub ) ] ) + [ sub ] )
        else :
            sorted_subsequence [ len ( sub ) ] = [ sub ]
    for it in sorted_subsequence :
        print ( " Subsequences ▁ of ▁ length ▁ = " , it , " are : " )
        for ii in sorted ( set ( sorted_subsequence [ it ] ) ) :
            print ( ii , end = ' ▁ ' )
        print ( )
s = " aabc "
possibleSubsequences ( s )

Index/key variables: it
Iterator variables: i, ii, it
Python program:
def remainder ( st ) :
    ln = len ( st )
    rem = 0
    for i in range ( 0 , ln ) :
        num = rem * 10 + ( int ) ( st [ i ] )
        rem = num % 11
    return rem
st = "3435346456547566345436457867978"
print ( remainder ( st ) )

Index/key variables: i
Iterator variables: i
Python program:
def longestSubseq ( s ) :
    n = len ( s )
    pre_count_0 = [ 0 for i in range ( n + 2 ) ]
    pre_count_1 = [ 0 for i in range ( n + 1 ) ]
    post_count_0 = [ 0 for i in range ( n + 2 ) ]
    pre_count_0 [ 0 ] = 0
    post_count_0 [ n + 1 ] = 0
    pre_count_1 [ 0 ] = 0
    for j in range ( 1 , n + 1 ) :
        pre_count_0 [ j ] = pre_count_0 [ j - 1 ]
        pre_count_1 [ j ] = pre_count_1 [ j - 1 ]
        post_count_0 [ n - j + 1 ] = post_count_0 [ n - j + 2 ]
        if ( s [ j - 1 ] == '0' ) :
            pre_count_0 [ j ] += 1
        else :
            pre_count_1 [ j ] += 1
        if ( s [ n - j ] == '0' ) :
            post_count_0 [ n - j + 1 ] += 1
    if ( pre_count_0 [ n ] == n or pre_count_0 [ n ] == 0 ) :
        return n
    ans = 0
    for i in range ( 1 , n + 1 ) :
        for j in range ( i , n + 1 , 1 ) :
            ans = max ( pre_count_0 [ i - 1 ] + pre_count_1 [ j ] - pre_count_1 [ i - 1 ] + post_count_0 [ j + 1 ] , ans )
    return ans
if __name__ == ' _ _ main _ _ ' :
    s = "000011100000"
    print ( longestSubseq ( s ) )

Index/key variables: j, n
Iterator variables: i, j
Python program:
def shouldSwap ( string , start , curr ) :
    for i in range ( start , curr ) :
        if string [ i ] == string [ curr ] :
            return 0
    return 1
def findPermutations ( string , index , n ) :
    if index >= n :
        print ( ' ' . join ( string ) )
        return
    for i in range ( index , n ) :
        check = shouldSwap ( string , index , i )
        if check :
            string [ index ] , string [ i ] = string [ i ] , string [ index ]
            findPermutations ( string , index + 1 , n )
            string [ index ] , string [ i ] = string [ i ] , string [ index ]
if __name__ == " _ _ main _ _ " :
    string = list ( " ABCA " )
    n = len ( string )
    findPermutations ( string , 0 , n )

Index/key variables: curr, i, index
Iterator variables: i
Python program:
def findPermutations ( string , index , n ) :
    if index >= n or ( index + 1 ) >= n :
        print ( ' ' . join ( string ) )
        return
    findPermutations ( string , index + 1 , n )
    string [ index ] , string [ index + 1 ] = string [ index + 1 ] , string [ index ]
    findPermutations ( string , index + 2 , n )
    string [ index ] , string [ index + 1 ] = string [ index + 1 ] , string [ index ]
if __name__ == " _ _ main _ _ " :
    string = list ( "12345" )
    n = len ( string )
    findPermutations ( string , 0 , n )

Index/key variables: index
Python program:
def decodeMedianString ( s ) :
    l = len ( s )
    s1 = " "
    if ( l % 2 == 0 ) :
        isEven = True
    else :
        isEven = False
    for i in range ( 0 , l , 2 ) :
        if ( isEven ) :
            s1 = s [ i ] + s1
            s1 += s [ i + 1 ]
        else :
            if ( l - i > 1 ) :
                s1 += s [ i ]
                s1 = s [ i + 1 ] + s1
            else :
                s1 += s [ i ]
    return s1
if __name__ == ' _ _ main _ _ ' :
    s = " eekgs "
    print ( decodeMedianString ( s ) )

Index/key variables: i
Accumulator variables: s1
Iterator variables: i
Boolean variables: isEven
Python program:
def maximumChars ( str ) :
    n = len ( str )
    res = - 1
    for i in range ( 0 , n - 1 ) :
        for j in range ( i + 1 , n ) :
            if ( str [ i ] == str [ j ] ) :
                res = max ( res , abs ( j - i - 1 ) )
    return res
if __name__ == ' _ _ main _ _ ' :
    str = " abba "
    print ( maximumChars ( str ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
MAX_CHAR = 256
def maximumChars ( str1 ) :
    n = len ( str1 )
    res = - 1
    firstInd = [ - 1 for i in range ( MAX_CHAR ) ]
    for i in range ( n ) :
        first_ind = firstInd [ ord ( str1 [ i ] ) ]
        if ( first_ind == - 1 ) :
            firstInd [ ord ( str1 [ i ] ) ] = i
        else :
            res = max ( res , abs ( i - first_ind - 1 ) )
    return res
str1 = " abba "
print ( maximumChars ( str1 ) )

Index/key variables: i
Iterator variables: i
Python program:
def isUnique ( a , n , k ) :
    sum = 0
    for i in range ( 0 , n , 1 ) :
        sum += a [ i ]
    sum += n - 1
    return ( sum == k )
if __name__ == ' _ _ main _ _ ' :
    a = [ 3 , 3 , 3 ]
    n = len ( a )
    k = 12
    if ( isUnique ( a , n , k ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def nextWord ( s ) :
    if ( s == " ▁ " ) :
        return " a "
    i = len ( s ) - 1
    while ( s [ i ] == ' z ' and i >= 0 ) :
        i -= 1
    if ( i == - 1 ) :
        s = s + ' a '
    else :
        s = s . replace ( s [ i ] , chr ( ord ( s [ i ] ) + 1 ) , 1 )
    return s
if __name__ == ' _ _ main _ _ ' :
    str = " samez "
    print ( nextWord ( str ) )

Index/key variables: i
Python program:
def isValid ( p ) :
    n = len ( p )
    c1 = 0
    c0 = 0
    for i in range ( n ) :
        if ( p [ i ] == '0' ) :
            c0 += 1
        if ( p [ i ] == '1' ) :
            c1 += 1
    if ( c0 == c1 ) :
        return True
    else :
        return False
def longestSub ( s ) :
    max_len = 0
    n = len ( s )
    for i in range ( n ) :
        for j in range ( i , n ) :
            if ( isValid ( s [ i : j - i + 1 ] ) and max_len < j - i + 1 ) :
                max_len = j - i + 1
    return max_len
if __name__ == ' _ _ main _ _ ' :
    s = "101001000"
    print ( longestSub ( s ) )

Index/key variables: i
Accumulator variables: c0, c1
Iterator variables: i, j
Python program:
MAX_CHAR = 26
def commonCharacters ( strings , n ) :
    prim = [ True ] * MAX_CHAR
    for i in range ( n ) :
        sec = [ False ] * MAX_CHAR
        for j in range ( len ( strings [ i ] ) ) :
            if ( prim [ ord ( strings [ i ] [ j ] ) - ord ( ' a ' ) ] ) :
                sec [ ord ( strings [ i ] [ j ] ) - ord ( ' a ' ) ] = True
        for i in range ( MAX_CHAR ) :
            prim [ i ] = sec [ i ]
    for i in range ( 26 ) :
        if ( prim [ i ] ) :
            print ( " % c ▁ " % ( i + ord ( ' a ' ) ) , end = " " )
strings = [ " geeksforgeeks " , " gemkstones " , " acknowledges " , " aguelikes " ]
n = len ( strings )
commonCharacters ( strings , n )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def countOfSubstringWithKOnes ( s , K ) :
    N = len ( s )
    res = 0
    countOfOne = 0
    freq = [ 0 for i in range ( N + 1 ) ]
    freq [ 0 ] = 1
    for i in range ( 0 , N , 1 ) :
        countOfOne += ord ( s [ i ] ) - ord ( '0' )
        if ( countOfOne >= K ) :
            res += freq [ countOfOne - K ]
        freq [ countOfOne ] += 1
    return res
if __name__ == ' _ _ main _ _ ' :
    s = "10010"
    K = 1
    print ( countOfSubstringWithKOnes ( s , K ) )

Index/key variables: countOfOne, i
Accumulator variables: res
Iterator variables: i
Python program:
MAX_CHAR = 256
def printDuo ( string ) :
    countChar = [ 0 for i in range ( MAX_CHAR ) ]
    n = len ( string )
    for i in range ( n ) :
        countChar [ ord ( string [ i ] ) - ord ( ' a ' ) ] += 1
    str1 = " "
    str2 = " "
    for i in range ( MAX_CHAR ) :
        if ( countChar [ i ] > 1 ) :
            str2 = str2 + chr ( i + ord ( ' a ' ) )
        elif ( countChar [ i ] == 1 ) :
            str1 = str1 + chr ( i + ord ( ' a ' ) )
    print ( " String ▁ with ▁ characters ▁ occurring ▁ once : " ,   " " , str1 )
    print ( " String ▁ with ▁ characters ▁ occurring " , " multiple ▁ times : " ,   " " , str2 )
string = " lovetocode "
printDuo ( string )

Index/key variables: i
Iterator variables: i
Python program:
def findstem ( arr ) :
    n = len ( arr )
    s = arr [ 0 ]
    l = len ( s )
    res = " "
    for i in range ( l ) :
        for j in range ( i + 1 , l + 1 ) :
            stem = s [ i : j ]
            k = 1
            for k in range ( 1 , n ) :
                if stem not in arr [ k ] :
                    break
            if ( k + 1 == n and len ( res ) < len ( stem ) ) :
                res = stem
    return res
if __name__ == " _ _ main _ _ " :
    arr = [ " grace " , " graceful " , " disgraceful " , " gracefully " ]
    stems = findstem ( arr )
    print ( stems )

Index/key variables: k
Iterator variables: i, j, k
Python program:
MAX_CHAR = 256
def isPossible ( s1 , s2 ) :
    count = [ 0 ] * MAX_CHAR
    for i in range ( len ( s2 ) ) :
        count [ ord ( s2 [ i ] ) ] += 1
    for i in range ( len ( s1 ) ) :
        if ( count [ ord ( s1 [ i ] ) ] == 0 ) :
            return False
        count [ ord ( s1 [ i ] ) ] -= 1
    return True
if __name__ == " _ _ main _ _ " :
    s1 = " GeeksforGeeks "
    s2 = " rteksfoGrdsskGeggehes "
    if ( isPossible ( s1 , s2 ) ) :
        print ( " Possible " )
    else :
        print ( " Not ▁ Possible " )

Index/key variables: i
Iterator variables: i
Python program:
def isVowel ( c ) :
    return ( c == ' a ' or c == ' e ' or c == ' i ' or c == ' o ' or c == ' u ' )
def longestVowel ( s ) :
    count , res = 0 , 0
    for i in range ( len ( s ) ) :
        if ( isVowel ( s [ i ] ) ) :
            count += 1
        else :
            res = max ( res , count )
            count = 0
    return max ( res , count )
if __name__ == " _ _ main _ _ " :
    s = " theeare "
    print ( longestVowel ( s ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
MAX_CHAR = 26
def check ( freq , k ) :
    for i in range ( 0 , MAX_CHAR ) :
        if ( freq [ i ] and freq [ i ] != k ) :
            return False
    return True
def substrings ( s , k ) :
    for i in range ( 0 , len ( s ) ) :
        freq = [ 0 ] * MAX_CHAR
        for j in range ( i , len ( s ) ) :
            index = ord ( s [ j ] ) - ord ( ' a ' )
            freq [ index ] += 1
            if ( freq [ index ] > k ) :
                break
            elif ( freq [ index ] == k and check ( freq , k ) == True ) :
                res += 1
    return res
if __name__ == " _ _ main _ _ " :
    s = " aabbcc "
    k = 2
    print ( substrings ( s , k ) )
    s = " aabbc " ;
    k = 2 ;
    print ( substrings ( s , k ) )

Index/key variables: i, index, j
Accumulator variables: res
Iterator variables: i, j
Python program:
from collections import defaultdict
def have_same_frequency ( freq : defaultdict , k : int ) :
    return all ( [ freq [ i ] == k or freq [ i ] == 0 for i in freq ] )
def count_substrings ( s : str , k : int ) -> int :
    count = 0
    distinct = len ( set ( [ i for i in s ] ) )
    for length in range ( 1 , distinct + 1 ) :
        window_length = length * k
        freq = defaultdict ( int )
        window_start = 0
        window_end = window_start + window_length - 1
        for i in range ( window_start , min ( window_end + 1 , len ( s ) ) ) :
            freq [ s [ i ] ] += 1
        while window_end < len ( s ) :
            if have_same_frequency ( freq , k ) :
                count += 1
            freq [ s [ window_start ] ] -= 1
            window_start += 1
            window_end += 1
            if window_end < len ( s ) :
                freq [ s [ window_end ] ] += 1
    return count
if __name__ == ' _ _ main _ _ ' :
    s = " aabbcc "
    k = 2
    print ( count_substrings ( s , k ) )
    s = " aabbc "
    k = 2
    print ( count_substrings ( s , k ) )

Index/key variables: i, window_end, window_start
Accumulator variables: count
Iterator variables: i, length
Python program:
MAX_CHAR = 26
class Trie :
    def __init__ ( self ) :
        self . cnt = 0
        self . node = [ None for i in range ( MAX_CHAR ) ]
def insert ( root , s ) :
    temp = root
    n = len ( s )
    for i in range ( n ) :
        index = ord ( s [ i ] ) - ord ( ' a ' )
        if ( not root . node [ index ] ) :
            root . node [ index ] = Trie ( )
        root = root . node [ index ]
    root . cnt += 1
    return temp
def search ( root , s ) :
    n = len ( s )
    for i in range ( n ) :
        index = ord ( s [ i ] ) - ord ( ' a ' )
        if ( not root . node [ index ] ) :
            return 0
        root = root . node [ index ]
    return root . cnt
def answerQueries ( arr , n , q , m ) :
    root = Trie ( )
    for i in range ( n ) :
        root = insert ( root , arr [ i ] )
    for i in range ( m ) :
        print ( search ( root , q [ i ] ) )
if __name__ == ' _ _ main _ _ ' :
    arr = [ " aba " , " baba " , " aba " , " xzxb " ]
    n = len ( arr )
    q = [ " aba " , " xzxb " , " ab " ]
    m = len ( q )
    answerQueries ( arr , n , q , m )

Index/key variables: i, index
Iterator variables: i
Class/struct names: Trie
Python program:
MAX_CHARS = 26
def longestSubseqWithK ( str , k ) :
    n = len ( str )
    freq = [ 0 ] * MAX_CHARS
    for i in range ( n ) :
        freq [ ord ( str [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( n ) :
        if ( freq [ ord ( str [ i ] ) - ord ( ' a ' ) ] >= k ) :
            print ( str [ i ] , end = " " )
if __name__ == " _ _ main _ _ " :
    str = " geeksforgeeks "
    k = 2
    longestSubseqWithK ( str , k )

Index/key variables: i
Iterator variables: i
Python program:
def generate ( st , s ) :
    if len ( s ) == 0 :
        return
    if s not in st :
        st . add ( s )
        for i in range ( len ( s ) ) :
            t = list ( s ) . copy ( )
            t . remove ( s [ i ] )
            t = ' ' . join ( t )
            generate ( st , t )
    return
if __name__ == " _ _ main _ _ " :
    s = " xyz "
    st = set ( )
    generate ( st , s )
    for i in st :
        print ( i )

Index/key variables: i
Iterator variables: i
Python program:
def countSubstrs ( str , i , j , n ) :
    if ( n == 1 ) :
        return 1
    if ( n <= 0 ) :
        return 0
    res = ( countSubstrs ( str , i + 1 , j , n - 1 ) + countSubstrs ( str , i , j - 1 , n - 1 ) - countSubstrs ( str , i + 1 , j - 1 , n - 2 ) )
    if ( str [ i ] == str [ j ] ) :
        res += 1
    return res
str = " abcab "
n = len ( str )
print ( countSubstrs ( str , 0 , n - 1 , n ) )

Index/key variables: i, j
Python program:
def countManipulations ( s1 , s2 ) :
    count = 0
    char_count = [ 0 ] * 26
    for i in range ( 26 ) :
        char_count [ i ] = 0
    for i in range ( len ( s1 ) ) :
        char_count [ ord ( s1 [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( len ( s2 ) ) :
        char_count [ ord ( s2 [ i ] ) - ord ( ' a ' ) ] -= 1
    for i in range ( 26 ) :
        if char_count [ i ] != 0 :
            count += abs ( char_count [ i ] )
    return count
if __name__ == " _ _ main _ _ " :
    s1 = " ddcf "
    s2 = " cedk "
    print ( countManipulations ( s1 , s2 ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
MAX_CHAR = 26
def leastCount ( s1 , s2 , n ) :
    count1 = [ 0 ] * MAX_CHAR
    count2 = [ 0 ] * MAX_CHAR
    for i in range ( n ) :
        count1 [ ord ( s1 [ i ] ) - ord ( ' a ' ) ] += 1
        count2 [ ord ( s2 [ i ] ) - ord ( ' a ' ) ] += 1
    res = 0
    for i in range ( MAX_CHAR ) :
        if ( count1 [ i ] != 0 ) :
            res += abs ( count1 [ i ] - count2 [ i ] )
    return res
if __name__ == " _ _ main _ _ " :
    s1 = " abc "
    s2 = " cdd "
    l = len ( s1 )
    res = leastCount ( s1 , s2 , l )
    print ( res )

Index/key variables: i
Accumulator variables: res
Iterator variables: i
Python program:
MAX_CHAR = 26
def stringPalindrome ( A , B ) :
    countA = [ 0 ] * MAX_CHAR
    countB = [ 0 ] * MAX_CHAR
    l1 = len ( A )
    l2 = len ( B )
    for i in range ( l1 ) :
        countA [ ord ( A [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( l2 ) :
        countB [ ord ( B [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( 26 ) :
        if ( ( countA [ i ] > 1 and countB [ i ] == 0 ) ) :
            return ' A '
    return ' B '
if __name__ == ' _ _ main _ _ ' :
    a = " abcdea "
    b = " bcdesg "
    print ( stringPalindrome ( a , b ) )

Index/key variables: i
Iterator variables: i
Python program:
def printLCSSubStr ( X : str , Y : str , m : int , n : int ) :
    LCSuff = [ [ 0 for i in range ( n + 1 ) ] for j in range ( m + 1 ) ]
    length = 0
    row , col = 0 , 0
    for i in range ( m + 1 ) :
        for j in range ( n + 1 ) :
            if i == 0 or j == 0 :
                LCSuff [ i ] [ j ] = 0
            elif X [ i - 1 ] == Y [ j - 1 ] :
                LCSuff [ i ] [ j ] = LCSuff [ i - 1 ] [ j - 1 ] + 1
                if length < LCSuff [ i ] [ j ] :
                    length = LCSuff [ i ] [ j ]
                    row = i
                    col = j
            else :
                LCSuff [ i ] [ j ] = 0
    if length == 0 :
        print ( " No ▁ Common ▁ Substring " )
        return
    resultStr = [ '0' ] * length
    while LCSuff [ row ] [ col ] != 0 :
        length -= 1
        row -= 1
        col -= 1
    print ( ' ' . join ( resultStr ) )
if __name__ == " _ _ main _ _ " :
    X = " OldSite : GeeksforGeeks . org "
    Y = " NewSite : GeeksQuiz . com "
    m = len ( X )
    n = len ( Y )
    printLCSSubStr ( X , Y , m , n )

Index/key variables: col, i, j, row
Accumulator variables: length
Iterator variables: i, j