dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def number_of_ways ( n ) :
    includes_3 = [ 0 ] * ( n + 1 )
    not_includes_3 = [ 0 ] * ( n + 1 )
    includes_3 [ 3 ] = 1
    not_includes_3 [ 1 ] = 1
    not_includes_3 [ 2 ] = 2
    not_includes_3 [ 3 ] = 3
    for i in range ( 4 , n + 1 ) :
        includes_3 [ i ] = includes_3 [ i - 1 ] + includes_3 [ i - 2 ] + not_includes_3 [ i - 3 ]
        not_includes_3 [ i ] = not_includes_3 [ i - 1 ] + not_includes_3 [ i - 2 ]
    return includes_3 [ n ]
n = 7
print ( number_of_ways ( n ) )

Index/key variables: i, n
Iterator variables: i
Python program:
from math import ceil , sqrt
MAX = 100000
divisors = [ 0 ] * MAX
def generateDivisors ( n ) :
    for i in range ( 1 , ceil ( sqrt ( n ) ) + 1 ) :
        if ( n % i == 0 ) :
            if ( n // i == i ) :
                divisors [ i ] += 1
            else :
                divisors [ i ] += 1
                divisors [ n // i ] += 1
def findMaxMultiples ( arr , n ) :
    ans = 0
    for i in range ( n ) :
        ans = max ( divisors [ arr [ i ] ] , ans )
        generateDivisors ( arr [ i ] )
    return ans
arr = [ 8 , 1 , 28 , 4 , 2 , 6 , 7 ]
n = len ( arr )
print ( findMaxMultiples ( arr , n ) )

Index/key variables: i
Iterator variables: i
Python program:
n = 3
maxV = 20
dp = [ [ [ 0 for i in range ( maxV ) ] for i in range ( n ) ] for i in range ( n ) ]
v = [ [ [ 0 for i in range ( maxV ) ] for i in range ( n ) ] for i in range ( n ) ]
def countWays ( i , j , x , arr ) :
    if ( i == n or j == n ) :
        return 0
    x = ( x & arr [ i ] [ j ] )
    if ( x == 0 ) :
        return 0
    if ( i == n - 1 and j == n - 1 ) :
        return 1
    if ( v [ i ] [ j ] [ x ] ) :
        return dp [ i ] [ j ] [ x ]
    v [ i ] [ j ] [ x ] = 1
    dp [ i ] [ j ] [ x ] = countWays ( i + 1 , j , x , arr ) + countWays ( i , j + 1 , x , arr ) ;
    return dp [ i ] [ j ] [ x ]
arr = [ [ 1 , 2 , 1 ] , [ 1 , 1 , 0 ] , [ 2 , 1 , 1 ] ]
print ( countWays ( 0 , 0 , arr [ 0 ] [ 0 ] , arr ) )

Index/key variables: i, j, x
Python program:
def FindMaximumSum ( ind , kon , a , b , c , n , dp ) :
    if ind == n :
        return 0
    if dp [ ind ] [ kon ] != - 1 :
        return dp [ ind ] [ kon ]
    ans = - 10 ** 9 + 5
    if kon == 0 :
        ans = max ( ans , b [ ind ] + FindMaximumSum ( ind + 1 , 1 , a , b , c , n , dp ) )
        ans = max ( ans , c [ ind ] + FindMaximumSum ( ind + 1 , 2 , a , b , c , n , dp ) )
    elif kon == 1 :
        ans = max ( ans , a [ ind ] + FindMaximumSum ( ind + 1 , 0 , a , b , c , n , dp ) )
        ans = max ( ans , c [ ind ] + FindMaximumSum ( ind + 1 , 2 , a , b , c , n , dp ) )
    elif kon == 2 :
        ans = max ( ans , a [ ind ] + FindMaximumSum ( ind + 1 , 1 , a , b , c , n , dp ) )
        ans = max ( ans , b [ ind ] + FindMaximumSum ( ind + 1 , 0 , a , b , c , n , dp ) )
    dp [ ind ] [ kon ] = ans
    return ans
if __name__ == " _ _ main _ _ " :
    N = 3
    a = [ 6 , 8 , 2 , 7 , 4 , 2 , 7 ]
    b = [ 7 , 8 , 5 , 8 , 6 , 3 , 5 ]
    c = [ 8 , 3 , 2 , 6 , 8 , 4 , 1 ]
    n = len ( a )
    dp = [ [ - 1 for i in range ( N ) ] for j in range ( n ) ]
    x = FindMaximumSum ( 0 , 0 , a , b , c , n , dp )
    y = FindMaximumSum ( 0 , 1 , a , b , c , n , dp )
    z = FindMaximumSum ( 0 , 2 , a , b , c , n , dp )
    print ( max ( x , y , z ) )

Index/key variables: ind, kon
Python program:
mod = 1000000007 ;
def noOfBinaryStrings ( N , k ) :
    dp = [ 0 ] * 100002 ;
    for i in range ( 1 , K ) :
        dp [ i ] = 1 ;
    dp [ k ] = 2 ;
    for i in range ( k + 1 , N + 1 ) :
        dp [ i ] = ( dp [ i - 1 ] + dp [ i - k ] ) % mod ;
    return dp [ N ] ;
if __name__ == " _ _ main _ _ " :
    N = 4 ;
    K = 2 ;
    print ( noOfBinaryStrings ( N , K ) ) ;

Index/key variables: N, i, k
Iterator variables: i
Python program:
def findWays ( p ) :
    dp = [ 0 ] * ( p + 1 )
    dp [ 1 ] = 1
    dp [ 2 ] = 2
    for i in range ( 3 , p + 1 ) :
        dp [ i ] = ( dp [ i - 1 ] + ( i - 1 ) * dp [ i - 2 ] )
    return dp [ p ]
p = 3
print ( findWays ( p ) )

Index/key variables: i, p
Iterator variables: i
Python program:
from math import sqrt
def factors ( n ) :
    v = [ ]
    v . append ( 1 )
    for i in range ( 2 , int ( sqrt ( n ) ) + 1 , 1 ) :
        if ( n % i == 0 ) :
            v . append ( i ) ;
            if ( int ( n / i ) != i ) :
                v . append ( int ( n / i ) )
    return v
def checkAbundant ( n ) :
    sum = 0
    v = factors ( n )
    for i in range ( len ( v ) ) :
        sum += v [ i ]
    if ( sum > n ) :
        return True
    else :
        return False
def checkSemiPerfect ( n ) :
    v = factors ( n )
    v . sort ( reverse = False )
    r = len ( v )
    subset = [ [ 0 for i in range ( n + 1 ) ] for j in range ( r + 1 ) ]
    for i in range ( r + 1 ) :
        subset [ i ] [ 0 ] = True
    for i in range ( 1 , n + 1 ) :
        subset [ 0 ] [ i ] = False
    for i in range ( 1 , r + 1 ) :
        for j in range ( 1 , n + 1 ) :
            if ( j < v [ i - 1 ] ) :
                subset [ i ] [ j ] = subset [ i - 1 ] [ j ]
            else :
                subset [ i ] [ j ] = ( subset [ i - 1 ] [ j ] or subset [ i - 1 ] [ j - v [ i - 1 ] ] )
    if ( ( subset [ r ] [ n ] ) == 0 ) :
        return False
    else :
        return True
def checkweird ( n ) :
    if ( checkAbundant ( n ) == True and checkSemiPerfect ( n ) == False ) :
        return True
    else :
        return False
if __name__ == ' _ _ main _ _ ' :
    n = 70
    if ( checkweird ( n ) ) :
        print ( " Weird ▁ Number " )
    else :
        print ( " Not ▁ Weird ▁ Number " )

Index/key variables: i, j, n, r
Accumulator variables: sum, v
Iterator variables: i, j
Python program:
def maxSubArraySumRepeated ( a , n , k ) :
    max_so_far = - 2147483648
    max_ending_here = 0
    for i in range ( n * k ) :
        max_ending_here = max_ending_here + a [ i % n ]
        if ( max_so_far < max_ending_here ) :
            max_so_far = max_ending_here
        if ( max_ending_here < 0 ) :
            max_ending_here = 0
    return max_so_far
a = [ 10 , 20 , - 30 , - 1 ]
n = len ( a )
k = 3
print ( " Maximum ▁ contiguous ▁ sum ▁ is ▁ " , maxSubArraySumRepeated ( a , n , k ) )

Iterator variables: i
Python program:
def longOddEvenIncSeq ( arr , n ) :
    lioes = list ( )
    maxLen = 0
    for i in range ( n ) :
        lioes . append ( 1 )
    i = 1
    for i in range ( n ) :
        for j in range ( i ) :
            if ( arr [ i ] > arr [ j ] and ( arr [ i ] + arr [ j ] ) % 2 != 0 and lioes [ i ] < lioes [ j ] + 1 ) :
                lioes [ i ] = lioes [ j ] + 1
    for i in range ( n ) :
        if maxLen < lioes [ i ] :
            maxLen = lioes [ i ]
    return maxLen
arr = [ 1 , 12 , 2 , 22 , 5 , 30 , 31 , 14 , 17 , 11 ]
n = len ( arr )
print ( " Longest ▁ Increasing ▁ Odd ▁ Even ▁ " + " Subsequence : ▁ " , longOddEvenIncSeq ( arr , n ) )

Index/key variables: i, j
Accumulator variables: lioes
Iterator variables: i, j
Python program:
def isOperator ( op ) :
    return ( op == ' + ' or op == ' * ' )
def printMinAndMaxValueOfExp ( exp ) :
    num = [ ]
    opr = [ ]
    tmp = " "
    for i in range ( len ( exp ) ) :
        if ( isOperator ( exp [ i ] ) ) :
            opr . append ( exp [ i ] )
            num . append ( int ( tmp ) )
            tmp = " "
        else :
            tmp += exp [ i ]
    num . append ( int ( tmp ) )
    llen = len ( num )
    minVal = [ [ 0 for i in range ( llen ) ] for i in range ( llen ) ]
    maxVal = [ [ 0 for i in range ( llen ) ] for i in range ( llen ) ]
    for i in range ( llen ) :
        for j in range ( llen ) :
            minVal [ i ] [ j ] = 10 ** 9
            maxVal [ i ] [ j ] = 0
            if ( i == j ) :
                minVal [ i ] [ j ] = maxVal [ i ] [ j ] = num [ i ]
    for L in range ( 2 , llen + 1 ) :
        for i in range ( llen - L + 1 ) :
            j = i + L - 1
            for k in range ( i , j ) :
                minTmp = 0
                maxTmp = 0
                if ( opr [ k ] == ' + ' ) :
                    minTmp = minVal [ i ] [ k ] + minVal [ k + 1 ] [ j ]
                    maxTmp = maxVal [ i ] [ k ] + maxVal [ k + 1 ] [ j ]
                elif ( opr [ k ] == ' * ' ) :
                    minTmp = minVal [ i ] [ k ] * minVal [ k + 1 ] [ j ]
                    maxTmp = maxVal [ i ] [ k ] * maxVal [ k + 1 ] [ j ]
                if ( minTmp < minVal [ i ] [ j ] ) :
                    minVal [ i ] [ j ] = minTmp
                if ( maxTmp > maxVal [ i ] [ j ] ) :
                    maxVal [ i ] [ j ] = maxTmp
    print ( " Minimum ▁ value ▁ : ▁ " , minVal [ 0 ] [ llen - 1 ] , " , ▁ \ ▁ Maximum ▁ value ▁ : ▁ " , maxVal [ 0 ] [ llen - 1 ] )
expression = "1 + 2*3 + 4*5"
printMinAndMaxValueOfExp ( expression )

Index/key variables: i, j, k
Accumulator variables: num, opr, tmp
Iterator variables: L, i, j, k
Python program:
import sys
def MatrixChainOrder ( p , i , j ) :
    if i == j :
        return 0
    _min = sys . maxsize
    for k in range ( i , j ) :
        count = ( MatrixChainOrder ( p , i , k ) + MatrixChainOrder ( p , k + 1 , j ) + p [ i - 1 ] * p [ k ] * p [ j ] )
        if count < _min :
            _min = count
    return _min
arr = [ 1 , 2 , 3 , 4 , 3 ]
n = len ( arr )
print ( " Minimum ▁ number ▁ of ▁ multiplications ▁ is ▁ " , MatrixChainOrder ( arr , 1 , n - 1 ) )

Index/key variables: j, k
Iterator variables: k
Python program:
import math
m = 1000000007
def solve ( n ) :
    s = 0 ;
    l = 1 ;
    while ( l < n + 1 ) :
        r = ( int ) ( n / math . floor ( n / l ) ) ;
        x = ( ( ( ( r % m ) * ( ( r + 1 ) % m ) ) / 2 ) % m ) ;
        y = ( ( ( ( l % m ) * ( ( l - 1 ) % m ) ) / 2 ) % m ) ;
        p = ( int ) ( ( n / l ) % m ) ;
        s = ( ( s + ( ( ( x - y ) % m ) * p ) % m + m ) % m ) ;
        s %= m ;
        l = r + 1 ;
    print ( int ( ( s + m ) % m ) ) ;
if __name__ == ' _ _ main _ _ ' :
    n = 12 ;
    solve ( n ) ;

Accumulator variables: s
Python program:
def findDistinctSums ( n ) :
    s = set ( )
    for i in range ( 1 , n + 1 ) :
        for j in range ( i , n + 1 ) :
            s . add ( i + j )
    return len ( s )
N = 3
print ( findDistinctSums ( N ) )

Accumulator variables: s
Iterator variables: i, j
Python program:
import sys ;
def zArray ( arr ) :
    n = len ( arr ) ;
    z = [ 0 ] * n ;
    r = 0 ;
    l = 0 ;
    for k in range ( 1 , n ) :
        if ( k > r ) :
            r = l = k ;
            while ( r < n and arr [ r ] == arr [ r - l ] ) :
                r += 1 ;
            z [ k ] = r - l ;
            r -= 1 ;
        else :
            k1 = k - l ;
            if ( z [ k1 ] < r - k + 1 ) :
                z [ k ] = z [ k1 ] ;
            else :
                l = k ;
                while ( r < n and arr [ r ] == arr [ r - l ] ) :
                    r += 1 ;
                z [ k ] = r - l ;
                r -= 1 ;
    return z ;
def mergeArray ( A , B ) :
    n = len ( A ) ;
    m = len ( B ) ;
    c = [ 0 ] * ( n + m + 1 ) ;
    for i in range ( m ) :
        c [ i ] = B [ i ] ;
    c [ m ] = sys . maxsize ;
    for i in range ( n ) :
        c [ m + i + 1 ] = A [ i ] ;
    z = zArray ( c ) ;
    return z ;
def findZArray ( A , B , n ) :
    flag = 0 ;
    z = mergeArray ( A , B ) ;
    for i in range ( len ( z ) ) :
        if ( z [ i ] == n ) :
            print ( i - n - 1 , end = " ▁ " ) ;
            flag = 1 ;
    if ( flag == 0 ) :
        print ( " Not ▁ Found " ) ;
if __name__ == " _ _ main _ _ " :
    A = [ 1 , 2 , 3 , 2 , 3 , 2 ] ;
    B = [ 2 , 3 ] ;
    n = len ( B ) ;
    findZArray ( A , B , n ) ;

Index/key variables: i, k, k1, m, r
Iterator variables: i, k
Python program:
from collections import defaultdict
def check ( S1 , S2 ) :
    n1 = len ( S1 )
    n2 = len ( S2 )
    mp = defaultdict ( lambda : 0 )
    for i in range ( 0 , n1 ) :
        mp [ S1 [ i ] ] += 1
    for i in range ( 0 , n2 ) :
        if mp [ S2 [ i ] ] :
            mp [ S2 [ i ] ] -= 1
        elif ( mp [ chr ( ord ( S2 [ i ] ) - 1 ) ] and mp [ chr ( ord ( S2 [ i ] ) - 2 ) ] ) :
            mp [ chr ( ord ( S2 [ i ] ) - 1 ) ] -= 1
            mp [ chr ( ord ( S2 [ i ] ) - 2 ) ] -= 1
        else :
            return False
    return True
if __name__ == " _ _ main _ _ " :
    S1 = " abbat "
    S2 = " cat "
    if check ( S1 , S2 ) :
        print ( " YES " )
    else :
        print ( " NO " )

Index/key variables: i
Iterator variables: i
Python program:
def checkIfPossible ( N , arr , T ) :
    freqS = [ 0 ] * 256
    freqT = [ 0 ] * 256
    for ch in T :
        freqT [ ord ( ch ) - ord ( ' a ' ) ] += 1
    for i in range ( N ) :
        for ch in arr [ i ] :
            freqS [ ord ( ch ) - ord ( ' a ' ) ] += 1
    for i in range ( 256 ) :
        if ( freqT [ i ] == 0 and freqS [ i ] != 0 ) :
            return " No "
        elif ( freqS [ i ] == 0 and freqT [ i ] != 0 ) :
            return " No "
        elif ( freqT [ i ] != 0 and freqS [ i ] != ( freqT [ i ] * N ) ) :
            return " No "
    return " Yes "
if __name__ == ' _ _ main _ _ ' :
    arr = [ " abc " , " abb " , " acc " ]
    T = " abc "
    N = len ( arr )
    print ( checkIfPossible ( N , arr , T ) )

Index/key variables: i
Iterator variables: ch, i
Python program:
def generatePalindrome ( S ) :
    Hash = { }
    for ch in S :
        Hash [ ch ] = Hash . get ( ch , 0 ) + 1
    st = { }
    for i in range ( ord ( ' a ' ) , ord ( ' z ' ) + 1 ) :
        if ( chr ( i ) in Hash and Hash [ chr ( i ) ] == 2 ) :
            for j in range ( ord ( ' a ' ) , ord ( ' z ' ) + 1 ) :
                s = " "
                if ( chr ( j ) in Hash and i != j ) :
                    s += chr ( i )
                    s += chr ( j )
                    s += chr ( i )
                    st [ s ] = 1
        if ( ( chr ( i ) in Hash ) and Hash [ chr ( i ) ] >= 3 ) :
            for j in range ( ord ( ' a ' ) , ord ( ' z ' ) + 1 ) :
                s = " "
                if ( chr ( j ) in Hash ) :
                    s += chr ( i )
                    s += chr ( j )
                    s += chr ( i )
                    st [ s ] = 1
    for ans in st :
        print ( ans )
if __name__ == ' _ _ main _ _ ' :
    S = " ddabdac "
    generatePalindrome ( S )

Index/key variables: ch, s
Iterator variables: ans, ch, i, j
Python program:
def countOccurrences ( S , X , Y ) :
    count = 0
    N = len ( S )
    A = len ( X )
    B = len ( Y )
    for i in range ( 0 , N ) :
        if ( S [ i : i + B ] == Y ) :
            count += 1
        if ( S [ i : i + A ] == X ) :
            print ( count , end = " ▁ " )
S = " abcdefdefabc "
X = " abc "
Y = " def "
countOccurrences ( S , X , Y )

Accumulator variables: count
Iterator variables: i
Python program:
def DFA ( str , N ) :
    if ( N <= 1 ) :
        print ( " No " )
        return
    count = 0
    if ( str [ 0 ] == ' C ' ) :
        count += 1
        for i in range ( 1 , N ) :
            if ( str [ i ] == ' A ' or str [ i ] == ' B ' ) :
                count += 1
            else :
                break
    else :
        print ( " No " )
        return
    if ( count == N ) :
        print ( " Yes " )
    else :
        print ( " No " )
if __name__ == ' _ _ main _ _ ' :
    str = " CAABBAAB "
    N = len ( str )
    DFA ( str , N )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def minMaxDigits ( str , N ) :
    arr = [ 0 ] * N
    for i in range ( N ) :
        arr [ i ] = ( ord ( str [ i ] ) - ord ( '0' ) ) % 3
    zero = 0
    one = 0
    two = 0
    for i in range ( N ) :
        if ( arr [ i ] == 0 ) :
            zero += 1
        if ( arr [ i ] == 1 ) :
            one += 1
        if ( arr [ i ] == 2 ) :
            two += 1
    sum = 0
    for i in range ( N ) :
        sum = ( sum + arr [ i ] ) % 3
    if ( sum == 0 ) :
        print ( "0" , end = " ▁ " )
    if ( sum == 1 ) :
        if ( one and N > 1 ) :
            print ( "1" , end = " ▁ " )
        elif ( two > 1 and N > 2 ) :
            print ( "2" , end = " ▁ " )
        else :
            print ( " - 1" , end = " ▁ " )
    if ( sum == 2 ) :
        if ( two and N > 1 ) :
            print ( "1" , end = " ▁ " )
        elif ( one > 1 and N > 2 ) :
            print ( "2" , end = " ▁ " )
        else :
            print ( " - 1" , end = " ▁ " )
    if ( zero > 0 ) :
        print ( N - 1 , end = " ▁ " )
    elif ( one > 0 and two > 0 ) :
        print ( N - 2 , end = " ▁ " )
    elif ( one > 2 or two > 2 ) :
        print ( N - 3 , end = " ▁ " )
    else :
        print ( " - 1" , end = " ▁ " )
str = "12345"
N = len ( str )
minMaxDigits ( str , N )

Index/key variables: i
Accumulator variables: one, two, zero
Iterator variables: i
Python program:
import sys
def findMinimumChanges ( N , K , S ) :
    ans = 0
    for i in range ( ( K + 1 ) // 2 ) :
        mp = { }
        for j in range ( i , N , K ) :
            mp [ S [ j ] ] = mp . get ( S [ j ] , 0 ) + 1
        j = N - i - 1
        while ( j >= 0 ) :
            if ( ( K & 1 ) and ( i == K // 2 ) ) :
                break
            mp [ S [ j ] ] = mp . get ( S [ j ] , 0 ) + 1
            j -= K
        curr_max = - sys . maxsize - 1
        for key , value in mp . items ( ) :
            curr_max = max ( curr_max , value )
        if ( ( K & 1 ) and ( i == K // 2 ) ) :
            ans += ( N // K - curr_max )
        else :
            ans += ( N // K * 2 - curr_max )
    return ans
if __name__ == ' _ _ main _ _ ' :
    S = " aabbcbbcb "
    N = len ( S )
    K = 3
    print ( findMinimumChanges ( N , K , S ) )

Index/key variables: j
Accumulator variables: ans
Iterator variables: i, j, key, value
Python program:
def checkString ( s , K ) :
    n = len ( s )
    dict = { }
    for i in range ( n ) :
        dict [ s [ i ] ] = i ;
    st = set ( )
    for i in range ( n ) :
        st . add ( s [ i ] )
        if len ( st ) > K :
            print ( " Yes " )
            return
        if dict [ s [ i ] ] == i :
            st . remove ( s [ i ] )
    print ( " No " )
s = " aabbcdca "
K = 2
checkString ( s , K )

Index/key variables: i
Accumulator variables: st
Iterator variables: i
Python program:
def distinct ( S , M ) :
    count = 0
    for i in range ( len ( S ) ) :
        c = len ( set ( [ d for d in S [ i ] ] ) )
        if ( c <= M ) :
            count += 1
    print ( count )
if __name__ == ' _ _ main _ _ ' :
    S = [ " HERBIVORES " , " AEROPLANE " , " GEEKSFORGEEKS " ]
    M = 7
    distinct ( S , M )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def removeOddFrequencyCharacters ( s ) :
    m = dict ( )
    for i in s :
        m [ i ] = m . get ( i , 0 ) + 1
    new_s = " "
    for i in s :
        if ( m [ i ] & 1 ) :
            continue
        new_s += i
    return new_s
if __name__ == ' _ _ main _ _ ' :
    str = " geeksforgeeks "
    str = removeOddFrequencyCharacters ( str )
    print ( str )

Index/key variables: i
Accumulator variables: new_s
Iterator variables: i
Python program:
def findMostOccurringChar ( string ) :
    hash = [ 0 ] * 26 ;
    for i in range ( len ( string ) ) :
        for j in range ( len ( string [ i ] ) ) :
            hash [ ord ( string [ i ] [ j ] ) - ord ( ' a ' ) ] += 1 ;
    max = 0 ;
    for i in range ( 26 ) :
        max = i if hash [ i ] > hash [ max ] else max ;
    print ( ( chr ) ( max + 97 ) ) ;
if __name__ == " _ _ main _ _ " :
    string = [ ] ;
    string . append ( " animal " ) ;
    string . append ( " zebra " ) ;
    string . append ( " lion " ) ;
    string . append ( " giraffe " ) ;
    findMostOccurringChar ( string ) ;

Index/key variables: i, j, max
Iterator variables: i, j
Python program:
def isPalindrome ( num ) :
    s = str ( num )
    low = 0
    high = len ( s ) - 1
    while ( low < high ) :
        if ( s [ low ] != s [ high ] ) :
            return False
        low += 1
        high -= 1
    return True
n = 123.321
if ( isPalindrome ( n ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: high, low
Python program:
import sys
MAX = 26 ;
def maxSubStr ( str1 , len1 , str2 , len2 ) :
    if ( len1 > len2 ) :
        return 0 ;
    freq1 = [ 0 ] * MAX ;
    for i in range ( len1 ) :
        freq1 [ ord ( str1 [ i ] ) - ord ( ' a ' ) ] += 1 ;
    freq2 = [ 0 ] * MAX ;
    for i in range ( len2 ) :
        freq2 [ ord ( str2 [ i ] ) - ord ( ' a ' ) ] += 1 ;
    minPoss = sys . maxsize ;
    for i in range ( MAX ) :
        if ( freq1 [ i ] == 0 ) :
            continue ;
        if ( freq1 [ i ] > freq2 [ i ] ) :
            return 0 ;
        minPoss = min ( minPoss , freq2 [ i ] / freq1 [ i ] ) ;
    return int ( minPoss ) ;
str1 = " geeks " ; str2 = " gskefrgoekees " ;
len1 = len ( str1 ) ;
len2 = len ( str2 ) ;
print ( maxSubStr ( str1 , len1 , str2 , len2 ) ) ;

Index/key variables: i
Iterator variables: i
Python program:
import sys
uSet = set ( ) ;
minCnt = sys . maxsize ;
def findSubStr ( string , cnt , start ) :
    global minCnt ;
    if ( start == len ( string ) ) :
        minCnt = min ( cnt , minCnt ) ;
    for length in range ( 1 , len ( string ) - start + 1 ) :
        subStr = string [ start : start + length ] ;
        if subStr in uSet :
            findSubStr ( string , cnt + 1 , start + length ) ;
def findMinSubStr ( arr , n , string ) :
    for i in range ( n ) :
        uSet . add ( arr [ i ] ) ;
    findSubStr ( string , 0 , 0 ) ;
if __name__ == " _ _ main _ _ " :
    string = "123456" ;
    arr = [ "1" , "12345" , "2345" , "56" , "23" , "456" ] ;
    n = len ( arr ) ;
    findMinSubStr ( arr , n , string ) ;
    print ( minCnt ) ;

Index/key variables: i
Accumulator variables: uSet
Iterator variables: i, length
Python program:
def countSubStr ( s , n ) :
    c1 = 0 ; c2 = 0 ;
    for i in range ( n ) :
        if ( s [ i : i + 5 ] == " geeks " ) :
            c1 += 1 ;
        if ( s [ i : i + 3 ] == " for " ) :
            c2 = c2 + c1 ;
    return c2 ;
if __name__ == " _ _ main _ _ " :
    s = " geeksforgeeksisforgeeks " ;
    n = len ( s ) ;
    print ( countSubStr ( s , n ) ) ;

Accumulator variables: c1
Iterator variables: i
Python program:
string = " { [ ( ) ] } [ ] "
lst1 = [ ' { ' , ' ( ' , ' [ ' ]
lst2 = [ ' } ' , ' ) ' , ' ] ' ]
lst = [ ]
Dict = { ' ) ' : ' ( ' , ' } ' : ' { ' , ' ] ' : ' [ ' }
a = b = c = 0
if string [ 0 ] in lst2 :
    print ( 1 )
else :
    for i in range ( 0 , len ( string ) ) :
        if string [ i ] in lst1 :
            lst . append ( string [ i ] )
            k = i + 2
        else :
            if len ( lst ) == 0 and ( string [ i ] in lst2 ) :
                print ( i + 1 )
                c = 1
                break
            else :
                if Dict [ string [ i ] ] == lst [ len ( lst ) - 1 ] :
                    lst . pop ( )
                else :
                    print ( i + 1 )
                    a = 1
                    break
    if len ( lst ) == 0 and c == 0 :
        print ( 0 )
        b = 1
    if a == 0 and b == 0 and c == 0 :
        print ( k )

Index/key variables: i
Accumulator variables: lst
Iterator variables: i
Python program:
MAX = 26
def encryptstrr ( strr , n , x ) :
    x = x % MAX
    arr = list ( strr )
    freq = [ 0 ] * MAX
    for i in range ( n ) :
        freq [ ord ( arr [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( n ) :
        if ( freq [ ord ( arr [ i ] ) - ord ( ' a ' ) ] % 2 == 0 ) :
            pos = ( ord ( arr [ i ] ) - ord ( ' a ' ) + x ) % MAX
            arr [ i ] = chr ( pos + ord ( ' a ' ) )
        else :
            pos = ( ord ( arr [ i ] ) - ord ( ' a ' ) - x )
            if ( pos < 0 ) :
                pos += MAX
            arr [ i ] = chr ( pos + ord ( ' a ' ) )
    return " " . join ( arr )
s = " abcda "
n = len ( s )
x = 3
print ( encryptstrr ( s , n , x ) )

Index/key variables: i
Accumulator variables: pos
Iterator variables: i
Python program:
def isPossible ( Str ) :
    freq = dict ( )
    max_freq = 0
    for j in range ( len ( Str ) ) :
        freq [ Str [ j ] ] = freq . get ( Str [ j ] , 0 ) + 1
        if ( freq [ Str [ j ] ] > max_freq ) :
            max_freq = freq [ Str [ j ] ]
    if ( max_freq <= ( len ( Str ) - max_freq + 1 ) ) :
        return True
    return False
Str = " geeksforgeeks "
if ( isPossible ( Str ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: j
Iterator variables: j