dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
import math
def substringConversions ( s , k , b ) :
    l = len ( s ) ;
    for i in range ( l ) :
        if ( ( i + k ) < l + 1 ) :
            sub = s [ i : i + k ] ;
            sum , counter = 0 , 0 ;
            for i in range ( len ( sub ) - 1 , - 1 , - 1 ) :
                sum = sum + ( ( ord ( sub [ i ] ) - ord ( '0' ) ) * pow ( b , counter ) ) ;
                counter += 1 ;
            print ( sum , end = " ▁ " ) ;
s = "12212" ;
b , k = 3 , 3 ;
substringConversions ( s , b , k ) ;

Index/key variables: i
Accumulator variables: counter
Iterator variables: i
Python program:
def LPCRec ( curr_str , count , leng , s ) :
    if not curr_str :
        return 0
    if len ( curr_str ) <= 1 :
        if count != 0 and len ( s ) - leng <= 1 :
            return ( count + 1 )
        else :
            return 1
    n = len ( curr_str )
    for i in range ( n // 2 ) :
        if ( curr_str [ 0 : i + 1 ] == curr_str [ n - 1 - i : n ] ) :
            return LPCRec ( curr_str [ i + 1 : n - 1 - i ] , count + 2 , leng + ( i + 1 ) * 2 , s )
    return count + 1
def LPC ( s ) :
    return LPCRec ( s , 0 , 0 , s )
print ( " V ▁ : " , LPC ( " V " ) )
print ( " VOLVO ▁ : " , LPC ( " VOLVO " ) )
print ( " VOLVOV ▁ : " , LPC ( " VOLVOV " ) )
print ( " ghiabcdefhelloadamhelloabcdefghi ▁ : " , LPC ( " ghiabcdefhelloadamhelloabcdefghi " ) )
print ( " ghiabcdefhelloadamhelloabcdefghik ▁ : " , LPC ( " ghiabcdefhelloadamhelloabcdefghik " ) )
print ( " antaprezatepzapreanta ▁ : " , LPC ( " antaprezatepzapreanta " ) )

Iterator variables: i
Python program:
MAX_CHAR = 256
def countBalance ( string ) :
    leftVisited = [ 0 ] * ( MAX_CHAR )
    rightVisited = [ 0 ] * ( MAX_CHAR )
    for i in range ( 0 , n ) :
        rightVisited [ ord ( string [ i ] ) ] += 1
    res = 0
    for i in range ( 0 , n ) :
        leftVisited [ ord ( string [ i ] ) ] += 1
        rightVisited [ ord ( string [ i ] ) ] -= 1
        j = 0
        while j < MAX_CHAR :
            if ( ( leftVisited [ j ] == 0 and rightVisited [ j ] != 0 ) or ( leftVisited [ j ] != 0 and rightVisited [ j ] == 0 ) ) :
                break
            j += 1
        if j == MAX_CHAR :
            res += 1
    return res
if __name__ == " _ _ main _ _ " :
    string = " abaababa "
    print ( countBalance ( string ) )

Index/key variables: i, j
Accumulator variables: res
Iterator variables: i
Python program:
def findFlips ( str , n ) :
    last = ' ▁ '
    res = 0
    for i in range ( n ) :
        if ( last != str [ i ] ) :
            res += 1
        last = str [ i ]
    return res // 2
if __name__ == " _ _ main _ _ " :
    str = "00011110001110"
    n = len ( str )
    print ( findFlips ( str , n ) )

Index/key variables: i
Accumulator variables: res
Iterator variables: i
Python program:
def findLen ( A , n , k , ch ) :
    maxlen = 1
    cnt = 0
    l = 0
    r = 0
    while r < n :
        if A [ r ] != ch :
            cnt += 1
        while cnt > k :
            if A [ l ] != ch :
                cnt -= 1
            l += 1
        maxlen = max ( maxlen , r - l + 1 )
        r += 1
    return maxlen
def answer ( A , n , k ) :
    maxlen = 1
    for i in range ( 26 ) :
        maxlen = max ( maxlen , findLen ( A , n , k , chr ( i + ord ( ' A ' ) ) ) )
        maxlen = max ( maxlen , findLen ( A , n , k , chr ( i + ord ( ' a ' ) ) ) )
    return maxlen
if __name__ == " _ _ main _ _ " :
    n = 5
    k = 2
    A = " ABABA "
    print ( " Maximum ▁ length ▁ = " , answer ( A , n , k ) )
    n = 6
    k = 4
    B = " HHHHHH "
    print ( " Maximum ▁ length ▁ = " , answer ( B , n , k ) )

Index/key variables: l, r
Accumulator variables: cnt
Iterator variables: i
Python program:
from collections import defaultdict
def printAnagram ( store : dict ) -> None :
    for ( k , v ) in store . items ( ) :
        temp_vec = v
        size = len ( temp_vec )
        if ( size > 1 ) :
            for i in range ( size ) :
                print ( temp_vec [ i ] , end = " ▁ " )
            print ( )
def storeInMap ( vec : list ) -> None :
    store = defaultdict ( lambda : list )
    for i in range ( len ( vec ) ) :
        tempString = vec [ i ]
        tempString = ' ' . join ( sorted ( tempString ) )
        if ( tempString not in store ) :
            temp_vec = [ ]
            temp_vec . append ( vec [ i ] )
            store [ tempString ] = temp_vec
        else :
            temp_vec = store [ tempString ]
            temp_vec . append ( vec [ i ] )
            store [ tempString ] = temp_vec
    printAnagram ( store )
if __name__ == " _ _ main _ _ " :
    arr = [ ]
    arr . append ( " geeksquiz " )
    arr . append ( " geeksforgeeks " )
    arr . append ( " abcd " )
    arr . append ( " forgeeksgeeks " )
    arr . append ( " zuiqkeegs " )
    arr . append ( " cat " )
    arr . append ( " act " )
    arr . append ( " tca " )
    storeInMap ( arr )

Index/key variables: i, tempString
Accumulator variables: temp_vec
Iterator variables: i, k, v
Python program:
def allCharactersSame ( s ) :
    s1 = [ ]
    for i in range ( len ( s ) ) :
        s1 . append ( s [ i ] )
    s1 = list ( set ( s1 ) )
    if ( len ( s1 ) == 1 ) :
        print ( " YES " )
    else :
        print ( " NO " )
Str = " nnnn "
allCharactersSame ( Str )

Index/key variables: i
Accumulator variables: s1
Iterator variables: i
Python program:
MAX_CHAR = 26
def checkCorrectOrNot ( s ) :
    global MAX_CHAR
    count1 = [ 0 ] * MAX_CHAR
    count2 = [ 0 ] * MAX_CHAR
    n = len ( s )
    if n == 1 :
        return true
    i = 0 ; j = n - 1
    while ( i < j ) :
        count1 [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
        count2 [ ord ( s [ j ] ) - ord ( ' a ' ) ] += 1
        i += 1 ; j -= 1
    for i in range ( MAX_CHAR ) :
        if count1 [ i ] != count2 [ i ] :
            return False
    return True
s = " ababc "
print ( " Yes " if checkCorrectOrNot ( s ) else " No " )

Index/key variables: i, j
Iterator variables: i
Python program:
def maximumNum ( curr_num , res ) :
    len1 = len ( curr_num ) ;
    len2 = len ( res ) ;
    if ( len1 == len2 ) :
        i = 0 ;
        while ( curr_num [ i ] == res [ i ] ) :
            i += 1 ;
        if ( curr_num [ i ] < res [ i ] ) :
            return res ;
        else :
            return curr_num ;
    return res if ( len1 < len2 ) else curr_num ;
def extractMaximum ( str ) :
    n = len ( str ) ;
    curr_num = " " ;
    res = " " ;
    for i in range ( n ) :
        while ( i < n and str [ i ] == '0' ) :
            i += 1 ;
        while ( i < n and str [ i ] >= '0' and str [ i ] <= '9' ) :
            curr_num += str [ i ] ;
            i += 1 ;
        if ( i == n ) :
            break ;
        if ( len ( curr_num ) > 0 ) :
            i -= 1 ;
        res = maximumNum ( curr_num , res ) ;
        curr_num = " " ;
    if ( len ( curr_num ) == 0 and len ( res ) == 0 ) :
        res += '0' ;
    return maximumNum ( curr_num , res ) ;
str = "100klh564abc365bg " ;
print ( extractMaximum ( str ) ) ;

Index/key variables: i
Accumulator variables: curr_num
Iterator variables: i
Python program:
def isDivisible999 ( num ) :
    n = len ( num ) ;
    if ( n == 0 or num [ 0 ] == '0' ) :
        return true
    if ( ( n % 3 ) == 1 ) :
        num = "00" + num
    if ( ( n % 3 ) == 2 ) :
        num = "0" + num
    gSum = 0
    for i in range ( 0 , n , 3 ) :
        group = 0
        group += ( ord ( num [ i ] ) - 48 ) * 100
        group += ( ord ( num [ i + 1 ] ) - 48 ) * 10
        group += ( ord ( num [ i + 2 ] ) - 48 )
        gSum += group
    if ( gSum > 1000 ) :
        num = str ( gSum )
        n = len ( num )
        gSum = isDivisible999 ( num )
    return ( gSum == 999 )
if __name__ == " _ _ main _ _ " :
    num = "1998"
    n = len ( num )
    if ( isDivisible999 ( num ) ) :
        print ( " Divisible " )
    else :
        print ( " Not ▁ divisible " )

Index/key variables: i
Accumulator variables: gSum, group
Iterator variables: i
Python program:
MAX_CHAR = 26
def arrangeString ( string ) :
    char_count = [ 0 ] * MAX_CHAR
    s = 0
    for i in range ( len ( string ) ) :
        if string [ i ] >= " A " and string [ i ] <= " Z " :
            char_count [ ord ( string [ i ] ) - ord ( " A " ) ] += 1
        else :
            s += ord ( string [ i ] ) - ord ( "0" )
    res = " "
    for i in range ( MAX_CHAR ) :
        ch = chr ( ord ( " A " ) + i )
        while char_count [ i ] :
            res += ch
            char_count [ i ] -= 1
    if s > 0 :
        res += str ( s )
    return res
if __name__ == " _ _ main _ _ " :
    string = " ACCBA10D2EW30"
    print ( arrangeString ( string ) )

Index/key variables: i
Accumulator variables: res, s
Iterator variables: i
Python program:
def subString ( Str , n ) :
    for Len in range ( 1 , n + 1 ) :
        for i in range ( n - Len + 1 ) :
            j = i + Len - 1
            for k in range ( i , j + 1 ) :
                print ( Str [ k ] , end = " " )
            print ( )
Str = " abc "
subString ( Str , len ( Str ) )

Index/key variables: k
Iterator variables: Len, i, k
Python program:
def reverses ( st ) :
    n = len ( st )
    result = [ 0 ] * n
    for i in range ( n ) :
        if ( st [ i ] == ' ▁ ' ) :
            result [ i ] = ' ▁ '
    j = n - 1
    for i in range ( len ( st ) ) :
        if ( st [ i ] != ' ▁ ' ) :
            if ( result [ j ] == ' ▁ ' ) :
                j -= 1
            result [ j ] = st [ i ]
            j -= 1
    return ' ' . join ( result )
if __name__ == " _ _ main _ _ " :
    st = " internship ▁ at ▁ geeks ▁ for ▁ geeks "
    print ( reverses ( st ) )

Index/key variables: i, j
Iterator variables: i
Python program:
def lengthOfLastWord ( a ) :
    l = 0
    x = a . strip ( )
    for i in range ( len ( x ) ) :
        if x [ i ] == " ▁ " :
            l = 0
        else :
            l += 1
    return l
if __name__ == " _ _ main _ _ " :
    inp = " Geeks ▁ For ▁ Geeks ▁ "
    print ( " The ▁ length ▁ of ▁ last ▁ word ▁ is " , lengthOfLastWord ( inp ) )

Index/key variables: i
Accumulator variables: l
Iterator variables: i
Python program:
def isVowel ( ch ) :
    return ch . upper ( ) in [ ' A ' , ' E ' , ' I ' , ' O ' , ' U ' ]
def countVowels ( str ) :
    count = 0
    for i in range ( len ( str ) ) :
        if isVowel ( str [ i ] ) :
            count += 1
    return count
str = ' abc ▁ de '
print ( countVowels ( str ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
x = 32 ;
def toggleCase ( a ) :
    for i in range ( len ( a ) ) :
        a = a [ : i ] + chr ( ord ( a [ i ] ) ^ 32 ) + a [ i + 1 : ] ;
    return a ;
str = " CheRrY " ;
print ( " Toggle ▁ case : ▁ " , end = " " ) ;
str = toggleCase ( str ) ;
print ( str ) ;
print ( " Original ▁ string : ▁ " , end = " " ) ;
str = toggleCase ( str ) ;
print ( str ) ;

Index/key variables: i
Iterator variables: i
Python program:
def concatenate ( a , b , c , n1 , n2 ) :
    i = - 1
    for i in range ( n1 ) :
        c [ i ] = a [ i ]
    for j in range ( n2 ) :
        c [ i ] = b [ j ]
        i += 1
if __name__ == " _ _ main _ _ " :
    a = " Hi ▁ This ▁ is ▁ geeksforgeeks . ▁ "
    n1 = len ( a )
    b = " You ▁ are ▁ welcome ▁ here . "
    n2 = len ( b )
    a = list ( a )
    b = list ( b )
    c = [ 0 ] * ( n1 + n2 - 1 )
    concatenate ( a , b , c , n1 , n2 )
    for i in c :
        print ( i , end = " " )

Index/key variables: i, j
Iterator variables: i, j
Python program:
from itertools import permutations
def printAll ( st ) :
    n = len ( st )
    opsize = pow ( 2 , n )
    for counter in range ( 1 , opsize ) :
        subs = " "
        for j in range ( n ) :
            if ( counter & ( 1 << j ) ) :
                subs += ( st [ j ] )
        perm = permutations ( subs )
        for i in perm :
            print ( ' ' . join ( i ) , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    st = " abc "
    printAll ( ( st ) )

Index/key variables: j
Accumulator variables: subs
Iterator variables: counter, i, j
Python program:
def isPalindrome ( str ) :
    n = len ( str )
    for i in range ( n // 2 ) :
        if ( str [ i ] != str [ n - i - 1 ] ) :
            return False
    return True
def maxLengthNonPalinSubstring ( str ) :
    n = len ( str )
    ch = str [ 0 ]
    i = 1
    for i in range ( 1 , n ) :
        if ( str [ i ] != ch ) :
            break
    if ( i == n ) :
        return 0
    if ( isPalindrome ( str ) ) :
        return n - 1
    return n
if __name__ == " _ _ main _ _ " :
    str = " abba "
    print ( " Maximum ▁ length ▁ = " , maxLengthNonPalinSubstring ( str ) )

Index/key variables: i
Iterator variables: i
Python program:
def moveSpaceInFront ( s ) :
    i = len ( s ) - 1 ;
    for j in range ( i , - 1 , - 1 ) :
        if ( s [ j ] != ' ▁ ' ) :
            s = swap ( s , i , j ) ;
            i -= 1 ;
    return s ;
def swap ( c , i , j ) :
    c = list ( c )
    c [ i ] , c [ j ] = c [ j ] , c [ i ]
    return ' ' . join ( c )
s = " Hey ▁ there , ▁ it ' s ▁ GeeksforGeeks " ;
s = moveSpaceInFront ( s ) ;
print ( s ) ;

Index/key variables: i, j
Iterator variables: j
Python program:
def moveSpaceInFront ( s ) :
    i = len ( s ) - 1 ;
    for j in range ( i , - 1 , - 1 ) :
        if ( s [ j ] != ' ▁ ' ) :
            s = s [ : i ] + s [ j ] + s [ i + 1 : ]
            i -= 1 ;
    while ( i >= 0 ) :
        s = s [ : i ] + ' ▁ ' + s [ i + 1 : ]
        i -= 1
    return s ;
s = " Hey ▁ there , ▁ it ' s ▁ GeeksforGeeks " ;
s = moveSpaceInFront ( s ) ;
print ( s ) ;

Index/key variables: j
Accumulator variables: i
Iterator variables: j
Python program:
def isPalindrome ( Str ) :
    Len = len ( Str )
    if ( Len == 1 ) :
        return True
    ptr1 = 0
    ptr2 = Len - 1
    while ( ptr2 > ptr1 ) :
        if ( Str [ ptr1 ] != Str [ ptr2 ] ) :
            return False
        ptr1 += 1
        ptr2 -= 1
    return True
def noOfAppends ( s ) :
    if ( isPalindrome ( s ) ) :
        return 0
    del s [ 0 ]
    return 1 + noOfAppends ( s )
se = " abede "
s = [ i for i in se ]
print ( noOfAppends ( s ) )

Index/key variables: ptr1, ptr2
Python program:
def titleToNumber ( s ) :
    result = 0 ;
    for B in range ( len ( s ) ) :
        result *= 26 ;
        result += ord ( s [ B ] ) - ord ( ' A ' ) + 1 ;
    return result ;
print ( titleToNumber ( " CDA " ) ) ;

Index/key variables: B
Accumulator variables: result
Iterator variables: B
Python program:
def reversingString ( str , start , end ) :
    while ( start < end ) :
        str = ( str [ : start ] + chr ( ord ( str [ start ] ) ^ ord ( str [ end ] ) ) + str [ start + 1 : ] ) ;
        str = ( str [ : end ] + chr ( ord ( str [ start ] ) ^ ord ( str [ end ] ) ) + str [ end + 1 : ] ) ;
        str = ( str [ : start ] + chr ( ord ( str [ start ] ) ^ ord ( str [ end ] ) ) + str [ start + 1 : ] ) ;
        start += 1 ;
        end -= 1 ;
    return str ;
s = " GeeksforGeeks " ;
print ( reversingString ( s , 0 , 12 ) ) ;

Index/key variables: end, start
Python program:
def f ( i , m , s , memoize ) :
    if ( i == len ( s ) ) :
        return 0
    if ( memoize [ i ] [ m ] != - 1 ) :
        return memoize [ i ] [ m ]
    x = ord ( s [ i ] ) - ord ( '0' )
    ans = ( ( ( x + m ) % 3 == 0 and x % 2 == 0 ) + f ( i + 1 , ( m + x ) % 3 , s , memoize ) )
    memoize [ i ] [ m ] = ans
    return memoize [ i ] [ m ]
def countDivBy6 ( s ) :
    n = len ( s )
    memoize = [ [ - 1 ] * 3 for i in range ( n + 1 ) ]
    ans = 0
    for i in range ( len ( s ) ) :
        if ( s [ i ] == '0' ) :
            ans += 1
        else :
            ans += f ( i , 0 , s , memoize )
    return ans
if __name__ == ' _ _ main _ _ ' :
    s = "4806"
    print ( countDivBy6 ( s ) )

Index/key variables: i, m
Accumulator variables: ans
Iterator variables: i
Python program:
def checkEquality ( s ) :
    return ( ord ( s [ 0 ] ) == ord ( s [ len ( s ) - 1 ] ) ) ;
def countSubstringWithEqualEnds ( s ) :
    result = 0 ;
    n = len ( s ) ;
    for i in range ( n ) :
        for j in range ( 1 , n - i + 1 ) :
            if ( checkEquality ( s [ i : i + j ] ) ) :
                result += 1 ;
    return result ;
s = " abcab " ;
print ( countSubstringWithEqualEnds ( s ) ) ;

Accumulator variables: result
Iterator variables: i, j
Python program:
def countSubstringWithEqualEnds ( s ) :
    result = 0 ;
    n = len ( s ) ;
    for i in range ( n ) :
        for j in range ( i , n ) :
            if ( s [ i ] == s [ j ] ) :
                result = result + 1
    return result
s = " abcab " ;
print ( countSubstringWithEqualEnds ( s ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
import math
MAX_DIGITS = 6
def getValue ( Str , i , m ) :
    if ( i + m > len ( Str ) ) :
        return - 1
    value = 0
    for j in range ( m ) :
        c = ( ord ( Str [ i + j ] ) - ord ( '0' ) )
        if ( c < 0 or c > 9 ) :
            return - 1
        value = value * 10 + c
    return value
def findMissingNumber ( Str ) :
    for m in range ( 1 , MAX_DIGITS + 1 ) :
        n = getValue ( Str , 0 , m )
        if ( n == - 1 ) :
            break
        missingNo = - 1
        fail = False
        i = m
        while ( i != len ( Str ) ) :
            if ( ( missingNo == - 1 ) and ( getValue ( Str , i , 1 + int ( math . log10 ( n + 2 ) ) ) == n + 2 ) ) :
                missingNo = n + 1
                n += 2
            elif ( ( getValue ( Str , i , 1 + int ( math . log10 ( n + 1 ) ) ) == n + 1 ) ) :
                n += 1
            else :
                fail = True
                break
            i += 1 + int ( math . log10 ( n ) )
        if ( not fail ) :
            return missingNo
    return - 1
print ( findMissingNumber ( "99101102" ) )

Accumulator variables: i, n
Iterator variables: j, m
Boolean variables: fail
Python program:
def maxRepeating ( str ) :
    l = len ( str )
    count = 0
    res = str [ 0 ]
    for i in range ( l ) :
        cur_count = 1
        for j in range ( i + 1 , l ) :
            if ( str [ i ] != str [ j ] ) :
                break
            cur_count += 1
        if cur_count > count :
            count = cur_count
            res = str [ i ]
    return res
if __name__ == " _ _ main _ _ " :
    str = " aaaabbaaccde "
    print ( maxRepeating ( str ) )

Index/key variables: i, j
Accumulator variables: cur_count
Iterator variables: i, j
Python program:
def findSum ( str1 , str2 ) :
    if ( len ( str1 ) > len ( str2 ) ) :
        t = str1 ;
        str1 = str2 ;
        str2 = t ;
    str = " " ;
    n1 = len ( str1 ) ;
    n2 = len ( str2 ) ;
    str1 = str1 [ : : - 1 ] ;
    str2 = str2 [ : : - 1 ] ;
    carry = 0 ;
    for i in range ( n1 ) :
        sum = ( ( ord ( str1 [ i ] ) - 48 ) + ( ( ord ( str2 [ i ] ) - 48 ) + carry ) ) ;
        str += chr ( sum % 10 + 48 ) ;
        carry = int ( sum / 10 ) ;
    for i in range ( n1 , n2 ) :
        sum = ( ( ord ( str2 [ i ] ) - 48 ) + carry ) ;
        str += chr ( sum % 10 + 48 ) ;
        carry = ( int ) ( sum / 10 ) ;
    if ( carry ) :
        str += chr ( carry + 48 ) ;
    str = str [ : : - 1 ] ;
    return str ;
str1 = "12" ;
str2 = "198111" ;
print ( findSum ( str1 , str2 ) ) ;

Index/key variables: i
Accumulator variables: str
Iterator variables: i
Python program:
def findSum ( str1 , str2 ) :
    if len ( str1 ) > len ( str2 ) :
        temp = str1
        str1 = str2
        str2 = temp
    str3 = " "
    n1 = len ( str1 )
    n2 = len ( str2 )
    diff = n2 - n1
    carry = 0
    for i in range ( n1 - 1 , - 1 , - 1 ) :
        sum = ( ( ord ( str1 [ i ] ) - ord ( '0' ) ) + int ( ( ord ( str2 [ i + diff ] ) - ord ( '0' ) ) ) + carry )
        str3 = str3 + str ( sum % 10 )
        carry = sum // 10
    for i in range ( n2 - n1 - 1 , - 1 , - 1 ) :
        sum = ( ( ord ( str2 [ i ] ) - ord ( '0' ) ) + carry )
        str3 = str3 + str ( sum % 10 )
        carry = sum // 10
    if ( carry ) :
        str3 + str ( carry + '0' )
    str3 = str3 [ : : - 1 ]
    return str3
if __name__ == " _ _ main _ _ " :
    str1 = "12"
    str2 = "198111"
    print ( findSum ( str1 , str2 ) )

Index/key variables: i
Iterator variables: i
Python program:
def isPalindrome ( st ) :
    length = len ( st )
    for i in range ( length // 2 ) :
        if ( st [ i ] != st [ length - i - 1 ] ) :
            return False
    return True
def checkPalindromePair ( vect ) :
    for i in range ( len ( vect ) - 1 ) :
        for j in range ( i + 1 , len ( vect ) ) :
            check_str = vect [ i ] + vect [ j ]
            if ( isPalindrome ( check_str ) ) :
                return True
            check_str = vect [ j ] + vect [ i ]
            if ( isPalindrome ( check_str ) ) :
                return True
    return False
if __name__ == " _ _ main _ _ " :
    vect = [ " geekf " , " geeks " , " or " , " keeg " , " abc " , " bc " ]
    if checkPalindromePair ( vect ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def _print ( string ) :
    print ( string [ 0 ] , end = " " )
    for i in range ( 1 , len ( string ) ) :
        if ( ord ( string [ i ] ) == ord ( string [ i - 1 ] ) + 1 or ord ( string [ i ] ) == ord ( string [ i - 1 ] ) - 1 ) :
            print ( string [ i ] , end = " " )
        else :
            print ( )
            print ( string [ i ] , end = " " )
if __name__ == " _ _ main _ _ " :
    string = " ABCXYZACCD "
    _print ( string )

Index/key variables: i
Iterator variables: i
Python program:
def areCharactersUnique ( s ) :
    checker = 0
    for i in range ( len ( s ) ) :
        val = ord ( s [ i ] ) - ord ( ' a ' )
        if ( checker & ( 1 << val ) ) > 0 :
            return False
        checker |= ( 1 << val )
    return True
s = " aaabbccdaa "
if areCharactersUnique ( s ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Accumulator variables: checker
Iterator variables: i
Python program:
def countWords ( str , l ) :
    count = 1 ;
    if ( l == 1 ) :
        return count
    if ( str [ 0 ] == str [ 1 ] ) :
        count *= 1
    else :
        count *= 2
    for j in range ( 1 , l - 1 ) :
        if ( str [ j ] == str [ j - 1 ] and str [ j ] == str [ j + 1 ] ) :
            count *= 1
        elif ( str [ j ] == str [ j - 1 ] or str [ j ] == str [ j + 1 ] or str [ j - 1 ] == str [ j + 1 ] ) :
            count *= 2
        else :
            count *= 3
    if ( str [ l - 1 ] == str [ l - 2 ] ) :
        count *= 1
    else :
        count *= 2
    return count
if __name__ == " _ _ main _ _ " :
    str = " abc "
    l = len ( str )
    print ( countWords ( str , l ) )

Index/key variables: j
Accumulator variables: count
Iterator variables: j
Python program:
def replaceDig ( x , from1 , to ) :
    result = 0
    multiply = 1
    while ( x > 0 ) :
        reminder = x % 10
        if ( reminder == from1 ) :
            result = result + to * multiply
        else :
            result = result + reminder * multiply
        multiply *= 10
        x = int ( x / 10 )
    return result
def calculateMinMaxSum ( x1 , x2 ) :
    minSum = replaceDig ( x1 , 6 , 5 ) + replaceDig ( x2 , 6 , 5 )
    maxSum = replaceDig ( x1 , 5 , 6 ) + replaceDig ( x2 , 5 , 6 )
    print ( " Minimum ▁ sum ▁ = " , minSum )
    print ( " Maximum ▁ sum ▁ = " , maxSum , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    x1 = 5466
    x2 = 4555
    calculateMinMaxSum ( x1 , x2 )

Accumulator variables: multiply
Python program:
def qType1 ( l , x , str1 ) :
    str1 [ l - 1 ] = x
def qType2 ( l , r , str1 ) :
    freq = [ 0 for i in range ( 27 ) ]
    for i in range ( l - 1 , r ) :
        freq [ ord ( str1 [ i ] ) - ord ( ' a ' ) ] += 1
    count = 0
    for j in range ( 26 ) :
        if ( freq [ j ] % 2 ) :
            count += 1
    if count <= 1 :
        print ( " Yes " )
    else :
        print ( " No " )
str1 = " geeksforgeeks "
str2 = [ i for i in str1 ]
n = len ( str2 )
qType1 ( 4 , ' g ' , str2 )
qType2 ( 1 , 4 , str2 )
qType2 ( 2 , 3 , str2 )
qType1 ( 10 , ' t ' , str2 )
qType2 ( 10 , 11 , str2 )

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