dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def helper ( d , s ) :
    ans = [ '0' ] * d
    for i in range ( d - 1 , - 1 , - 1 ) :
        if ( s >= 9 ) :
            ans [ i ] = '9'
            s -= 9
        else :
            c = chr ( s + ord ( '0' ) )
            ans [ i ] = c ;
            s = 0 ;
    return ' ' . join ( ans ) ;
def findMin ( x , Y ) :
    y = str ( Y ) ;
    n = len ( y )
    p = [ 0 ] * n
    for i in range ( n ) :
        p [ i ] = ( ord ( y [ i ] ) - ord ( '0' ) )
        if ( i > 0 ) :
            p [ i ] += p [ i - 1 ] ;
    n - 1
    k = 0
    while True :
        d = 0 ;
        if ( i >= 0 ) :
            d = ( ord ( y [ i ] ) - ord ( '0' ) )
        for j in range ( d + 1 , 10 ) :
            r = ( ( i > 0 ) * p [ i - 1 ] + j ) ;
            if ( x - r >= 0 and x - r <= 9 * k ) :
                suf = helper ( k , x - r ) ;
                pre = " " ;
                if ( i > 0 ) :
                    pre = y [ 0 : i ]
                cur = chr ( j + ord ( '0' ) )
                pre += cur ;
                return pre + suf ;
        i -= 1
        k += 1
if __name__ == " _ _ main _ _ " :
    x = 18 ;
    y = 99 ;
    print ( findMin ( x , y ) )

Index/key variables: i
Accumulator variables: k, pre, s
Iterator variables: i, j
Python program:
def largestNumber ( n , X , Y ) :
    maxm = max ( X , Y )
    Y = X + Y - maxm
    X = maxm
    Xs = 0
    Ys = 0
    while ( n > 0 ) :
        if ( n % Y == 0 ) :
            Xs += n
            n = 0
        else :
            n -= X
            Ys += X
    if ( n == 0 ) :
        while ( Xs > 0 ) :
            Xs -= 1
            print ( X , end = ' ' )
        while ( Ys > 0 ) :
            Ys -= 1
            print ( Y , end = ' ' )
    else :
        print ( " - 1" )
n = 19
X = 7
Y = 5
largestNumber ( n , X , Y )

Accumulator variables: Xs, Ys, n
Python program:
def minChanges ( str , N ) :
    count0 = 0
    count1 = 0
    for x in str :
        count0 += ( x == '0' )
    res = count0
    for x in str :
        count0 -= ( x == '0' )
        count1 += ( x == '1' )
        res = min ( res , count1 + count0 )
    return res
N = 9
str = "000101001"
print ( minChanges ( str , N ) )

Accumulator variables: count0, count1
Iterator variables: x
Python program:
import sys
def missingnumber ( n , arr ) -> int :
    mn = sys . maxsize ;
    mx = - sys . maxsize - 1 ;
    for i in range ( n ) :
        if ( i > 0 and arr [ i ] == - 1 and arr [ i - 1 ] != - 1 ) :
            mn = min ( mn , arr [ i - 1 ] ) ;
            mx = max ( mx , arr [ i - 1 ] ) ;
        if ( i < ( n - 1 ) and arr [ i ] == - 1 and arr [ i + 1 ] != - 1 ) :
            mn = min ( mn , arr [ i + 1 ] ) ;
            mx = max ( mx , arr [ i + 1 ] ) ;
    res = ( mx + mn ) / 2 ;
    return res ;
if __name__ == ' _ _ main _ _ ' :
    n = 5 ;
    arr = [ - 1 , 10 , - 1 , 12 , - 1 ] ;
    res = missingnumber ( n , arr ) ;
    print ( res ) ;

Index/key variables: i
Iterator variables: i
Python program:
def LCSubStr ( A , B , m , n ) :
    LCSuff = [ [ 0 for i in range ( n + 1 ) ] for j in range ( m + 1 ) ]
    result = 0
    for i in range ( m + 1 ) :
        for j in range ( n + 1 ) :
            if ( i == 0 or j == 0 ) :
                LCSuff [ i ] [ j ] = 0
            elif ( A [ i - 1 ] == B [ j - 1 ] ) :
                LCSuff [ i ] [ j ] = LCSuff [ i - 1 ] [ j - 1 ] + 1
                result = max ( result , LCSuff [ i ] [ j ] )
            else :
                LCSuff [ i ] [ j ] = 0
    return result
if __name__ == ' _ _ main _ _ ' :
    A = "0110"
    B = "1101"
    M = len ( A )
    N = len ( B )
    print ( LCSubStr ( A , B , M , N ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
maxN = 20 ;
maxSum = 50 ;
minSum = 50 ;
Base = 50 ;
dp = [ [ 0 for i in range ( maxSum + minSum ) ] for j in range ( maxN ) ] ;
v = [ [ False for i in range ( maxSum + minSum ) ] for j in range ( maxN ) ] ;
def findCnt ( arr , i , required_sum , n ) :
    if ( i == n ) :
        if ( required_sum == 0 ) :
            return 1 ;
        else :
            return 0 ;
    if ( v [ i ] [ required_sum + Base ] ) :
        return dp [ i ] [ required_sum + Base ] ;
    v [ i ] [ required_sum + Base ] = True ;
    dp [ i ] [ required_sum + Base ] = findCnt ( arr , i + 1 , required_sum , n ) + findCnt ( arr , i + 1 , required_sum - arr [ i ] , n ) ;
    return dp [ i ] [ required_sum + Base ] ;
def countSubsets ( arr , K , n ) :
    sum = 0 ;
    for i in range ( n ) :
        sum += arr [ i ] ;
    S1 = ( sum + K ) // 2 ;
    print ( findCnt ( arr , 0 , S1 , n ) ) ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 1 , 2 , 3 ] ;
    N = len ( arr ) ;
    K = 1 ;
    countSubsets ( arr , K , N ) ;

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def count ( n ) :
    dp = dict ( )
    dp [ 0 ] = 0
    dp [ 1 ] = 1
    if n not in dp :
        dp [ n ] = 1 + min ( n % 2 + count ( n // 2 ) , n % 3 + count ( n // 3 ) )
    return dp [ n ]
N = 6
print ( str ( count ( N ) ) )

Index/key variables: n
Python program:
def find_minimum_operations ( n , b , k ) :
    d = [ 0 for i in range ( n + 1 ) ]
    operations = 0
    for i in range ( n ) :
        d [ i ] += d [ i - 1 ]
        if b [ i ] > d [ i ] :
            operations += ( b [ i ] - d [ i ] )
            need = ( b [ i ] - d [ i ] )
            d [ i ] += need
            if i + k <= n :
                d [ i + k ] -= need
    return operations
if __name__ == " _ _ main _ _ " :
    n = 5
    b = [ 1 , 2 , 3 , 4 , 5 ]
    k = 2
    print ( find_minimum_operations ( n , b , k ) )

Index/key variables: i
Accumulator variables: operations
Iterator variables: i
Python program:
p = 1000000007
def power ( x , y , p ) :
    res = 1
    x = x % p
    while ( y > 0 ) :
        if ( y & 1 ) :
            res = ( res * x ) % p
        y = y >> 1
        x = ( x * x ) % p
    return res
def nCr ( n , p , f , m ) :
    for i in range ( n + 1 ) :
        for j in range ( m + 1 ) :
            if ( j > i ) :
                f [ i ] [ j ] = 0
            elif ( j == 0 or j == i ) :
                f [ i ] [ j ] = 1
            else :
                f [ i ] [ j ] = ( f [ i - 1 ] [ j ] + f [ i - 1 ] [ j - 1 ] ) % p
def ProductOfSubsets ( arr , n , m ) :
    f = [ [ 0 for i in range ( 100 ) ] for j in range ( n + 1 ) ]
    nCr ( n , p - 1 , f , m )
    arr . sort ( reverse = False )
    ans = 1
    for i in range ( n ) :
        x = 0
        for j in range ( 1 , m + 1 , 1 ) :
            if ( m % j == 0 ) :
                x = ( ( x + ( f [ n - i - 1 ] [ m - j ] * f [ i ] [ j - 1 ] ) % ( p - 1 ) ) % ( p - 1 ) )
        ans = ( ( ans * power ( arr [ i ] , x , p ) ) % p )
    print ( ans )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 4 , 5 , 7 , 9 , 3 ]
    K = 4
    N = len ( arr ) ;
    ProductOfSubsets ( arr , N , K )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def countWays ( n , m ) :
    dp = [ [ 0 for i in range ( n + 1 ) ] for i in range ( m + 1 ) ]
    for i in range ( n + 1 ) :
        dp [ 1 ] [ i ] = 1
    sum = 0
    for i in range ( 2 , m + 1 ) :
        for j in range ( n + 1 ) :
            sum = 0
            for k in range ( j + 1 ) :
                sum += dp [ i - 1 ] [ k ]
            dp [ i ] [ j ] = sum
    return dp [ m ] [ n ]
if __name__ == ' _ _ main _ _ ' :
    N = 2
    K = 3
    print ( countWays ( N , K ) )

Index/key variables: i, j, k, m, n
Accumulator variables: sum
Iterator variables: i, j, k
Python program:
def countWays ( n , m ) :
    dp = [ [ 0 for i in range ( n + 1 ) ] for j in range ( m + 1 ) ]
    for i in range ( n + 1 ) :
        dp [ 1 ] [ i ] = 1
        if ( i != 0 ) :
            dp [ 1 ] [ i ] += dp [ 1 ] [ i - 1 ]
    for i in range ( 2 , m + 1 ) :
        for j in range ( n + 1 ) :
            if ( j == 0 ) :
                dp [ i ] [ j ] = dp [ i - 1 ] [ j ]
            else :
                dp [ i ] [ j ] = dp [ i - 1 ] [ j ]
                if ( i == m and j == n ) :
                    return dp [ i ] [ j ]
                dp [ i ] [ j ] += dp [ i ] [ j - 1 ]
N = 2
K = 3
print ( countWays ( N , K ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
from math import sqrt
def SieveOfEratosthenes ( MAX , primes ) :
    prime = [ True ] * ( MAX + 1 ) ;
    for p in range ( 2 , int ( sqrt ( MAX ) ) + 1 ) :
        if ( prime [ p ] == True ) :
            for i in range ( p ** 2 , MAX + 1 , p ) :
                prime [ i ] = False ;
    for i in range ( 2 , MAX + 1 ) :
        if ( prime [ i ] ) :
            primes . append ( i ) ;
def findLongest ( A , n ) :
    mpp = { } ;
    primes = [ ] ;
    SieveOfEratosthenes ( A [ n - 1 ] , primes ) ;
    dp = [ 0 ] * n ;
    dp [ n - 1 ] = 1 ;
    mpp [ A [ n - 1 ] ] = n - 1 ;
    for i in range ( n - 2 , - 1 , - 1 ) :
        num = A [ i ] ;
        dp [ i ] = 1 ;
        maxi = 0 ;
        for it in primes :
            xx = num * it ;
            if ( xx > A [ n - 1 ] ) :
                break ;
            elif xx in mpp :
                dp [ i ] = max ( dp [ i ] , 1 + dp [ mpp [ xx ] ] ) ;
        mpp [ A [ i ] ] = i ;
    ans = 1 ;
    for i in range ( n ) :
        ans = max ( ans , dp [ i ] ) ;
    return ans ;
if __name__ == " _ _ main _ _ " :
    a = [ 1 , 2 , 5 , 6 , 12 , 35 , 60 , 385 ] ;
    n = len ( a ) ;
    print ( findLongest ( a , n ) ) ;

Index/key variables: i, p, xx
Accumulator variables: primes
Iterator variables: i, it, p
Python program:
def postfix ( a , n ) :
    for i in range ( n - 1 , 1 , - 1 ) :
        a [ i - 1 ] = a [ i - 1 ] + a [ i ]
def modify ( a , n ) :
    for i in range ( 1 , n ) :
        a [ i - 1 ] = i * a [ i ] ;
def allCombination ( a , n ) :
    sum = 0
    for i in range ( 1 , n + 1 ) :
        sum += i
    print ( " f ( 1 ) ▁ - - > ▁ " , sum )
    for i in range ( 1 , n ) :
        postfix ( a , n - i + 1 )
        sum = 0
        for j in range ( 1 , n - i + 1 ) :
            sum += ( j * a [ j ] )
        print ( " f ( " , i + 1 , " ) ▁ - - > ▁ " , sum )
        modify ( a , n )
if __name__ == " _ _ main _ _ " :
    n = 5
    a = [ 0 ] * n
    for i in range ( n ) :
        a [ i ] = i + 1
    allCombination ( a , n )

Index/key variables: i, j
Accumulator variables: sum
Iterator variables: i, j
Python program:
def isSubsetSum ( arr , n , sum ) :
    if sum == 0 :
        return True
    if n == 0 and sum != 0 :
        return False
    if arr [ n - 1 ] > sum :
        return isSubsetSum ( arr , n - 1 , sum )
    return isSubsetSum ( arr , n - 1 , sum ) or isSubsetSum ( arr , n - 1 , sum - arr [ n - 1 ] )
def findPartion ( arr , n ) :
    sum = 0
    for i in range ( 0 , n ) :
        sum += arr [ i ]
    if sum % 2 != 0 :
        return false
    return isSubsetSum ( arr , n , sum // 2 )
arr = [ 3 , 1 , 5 , 9 , 12 ]
n = len ( arr )
if findPartion ( arr , n ) == True :
    print ( " Can ▁ be ▁ divided ▁ into ▁ two ▁ subsets ▁ of ▁ equal ▁ sum " )
else :
    print ( " Can ▁ not ▁ be ▁ divided ▁ into ▁ two ▁ subsets ▁ of ▁ equal ▁ sum " )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def MinValue ( N , X ) :
    N = list ( N ) ;
    ln = len ( N )
    position = ln + 1
    if ( N [ 0 ] == ' - ' ) :
        for i in range ( ln - 1 , 0 , - 1 ) :
            if ( ( ord ( N [ i ] ) - ord ( '0' ) ) < X ) :
                position = i
    else :
        for i in range ( ln - 1 , - 1 , - 1 ) :
            if ( ( ord ( N [ i ] ) - ord ( '0' ) ) > X ) :
                position = i
    c = chr ( X + ord ( '0' ) )
    str = N . insert ( position , c ) ;
    return ' ' . join ( N )
N = "89"
X = 1
print ( MinValue ( N , X ) )

Index/key variables: i
Iterator variables: i
Python program:
def divisibleByk ( s , n , k ) :
    poweroftwo = [ 0 for i in range ( n ) ]
    poweroftwo [ 0 ] = 1 % k
    for i in range ( 1 , n , 1 ) :
        poweroftwo [ i ] = ( poweroftwo [ i - 1 ] * ( 2 % k ) ) % k
    rem = 0
    for i in range ( n ) :
        if ( s [ n - i - 1 ] == '1' ) :
            rem += ( poweroftwo [ i ] )
            rem %= k
    if ( rem == 0 ) :
        return " Yes "
    else :
        return " No "
if __name__ == ' _ _ main _ _ ' :
    s = "1010001"
    k = 9
    n = len ( s )
    print ( divisibleByk ( s , n , k ) )

Index/key variables: i
Accumulator variables: rem
Iterator variables: i
Python program:
def cntBalancedParenthesis ( s , N ) :
    cntPairs = 0 ;
    cntCurly = 0 ;
    cntSml = 0 ;
    cntSqr = 0 ;
    for i in range ( N ) :
        if ( ord ( s [ i ] ) == ord ( ' { ' ) ) :
            cntCurly += 1 ;
        elif ( ord ( s [ i ] ) == ord ( ' ( ' ) ) :
            cntSml += 1 ;
        elif ( ord ( s [ i ] ) == ord ( ' [ ' ) ) :
            cntSqr += 1 ;
        elif ( ord ( s [ i ] ) == ord ( ' } ' ) and cntCurly > 0 ) :
            cntCurly -= 1 ;
            cntPairs += 1 ;
        elif ( ord ( s [ i ] ) == ord ( ' ) ' ) and cntSml > 0 ) :
            cntSml -= 1 ;
            cntPairs += 1 ;
        elif ( ord ( s [ i ] ) == ord ( ' ] ' ) and cntSqr > 0 ) :
            cntSqr -= 1 ;
            cntPairs += 1 ;
    print ( cntPairs ) ;
if __name__ == ' _ _ main _ _ ' :
    s = " { ( } ) " ;
    N = len ( s ) ;
    cntBalancedParenthesis ( s , N ) ;

Index/key variables: i
Accumulator variables: cntCurly, cntPairs, cntSml, cntSqr
Iterator variables: i
Python program:
def arcIntersection ( S , lenn ) :
    stk = [ ]
    for i in range ( lenn ) :
        stk . append ( S [ i ] )
        if ( len ( stk ) >= 2 ) :
            temp = stk [ - 1 ]
            del stk [ - 1 ]
            if ( stk [ - 1 ] == temp ) :
                del stk [ - 1 ]
            else :
                stk . append ( temp )
    if ( len ( stk ) == 0 ) :
        return 1
    return 0
def countString ( arr , N ) :
    count = 0
    for i in range ( N ) :
        lenn = len ( arr [ i ] )
        count += arcIntersection ( arr [ i ] , lenn )
    print ( count )
if __name__ == ' _ _ main _ _ ' :
    arr = [ "0101" , "0011" , "0110" ]
    N = len ( arr )
    countString ( arr , N )

Index/key variables: i
Accumulator variables: count, stk
Iterator variables: i
Python program:
def min_cost ( S ) :
    cost = 0
    F = 0
    B = 0
    n = len ( S ) - S . count ( ' ▁ ' )
    if n == 1 :
        return cost
    for char in S :
        if char != ' ▁ ' :
            if B != 0 :
                cost += min ( n - F , F ) * B
                B = 0
            F += 1
        else :
            B += 1
    return cost
S = " ▁ @ TABSYMBOL $ "
print ( min_cost ( S ) )

Accumulator variables: B, F, cost
Iterator variables: char
Python program:
def isVowel ( ch ) :
    if ( ch == ' a ' or ch == ' e ' or ch == ' i ' or ch == ' o ' or ch == ' u ' ) :
        return True ;
    else :
        return False ;
def minCost ( S ) :
    cA = 0 ;
    cE = 0 ;
    cI = 0 ;
    cO = 0 ;
    cU = 0 ;
    for i in range ( len ( S ) ) :
        if ( isVowel ( S [ i ] ) ) :
            cA += abs ( ord ( S [ i ] ) - ord ( ' a ' ) ) ;
            cE += abs ( ord ( S [ i ] ) - ord ( ' e ' ) ) ;
            cI += abs ( ord ( S [ i ] ) - ord ( ' i ' ) ) ;
            cO += abs ( ord ( S [ i ] ) - ord ( ' o ' ) ) ;
            cU += abs ( ord ( S [ i ] ) - ord ( ' u ' ) ) ;
    return min ( min ( min ( min ( cA , cE ) , cI ) , cO ) , cU ) ;
S = " geeksforgeeks " ;
print ( minCost ( S ) )

Index/key variables: i
Accumulator variables: cA, cE, cI, cO, cU
Iterator variables: i
Python program:
def decode_String ( st , K ) :
    ans = " "
    for i in range ( 0 , len ( st ) , K ) :
        ans += st [ i ]
    for i in range ( len ( st ) - ( K - 1 ) , len ( st ) ) :
        ans += st [ i ]
    print ( ans )
if __name__ == " _ _ main _ _ " :
    K = 3
    st = " abcbcscsesesesd "
    decode_String ( st , K )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def maxVowelSubString ( str1 , K ) :
    N = len ( str1 )
    pref = [ 0 for i in range ( N ) ]
    for i in range ( N ) :
        if ( str1 [ i ] == ' a ' or str1 [ i ] == ' e ' or str1 [ i ] == ' i ' or str1 [ i ] == ' o ' or str1 [ i ] == ' u ' ) :
            pref [ i ] = 1
        else :
            pref [ i ] = 0
        if ( i ) :
            pref [ i ] += pref [ i - 1 ]
    maxCount = pref [ K - 1 ]
    res = str1 [ 0 : K ]
    for i in range ( K , N ) :
        currCount = pref [ i ] - pref [ i - K ]
        if ( currCount > maxCount ) :
            maxCount = currCount
            res = str1 [ i - K + 1 : i + 1 ]
        elif ( currCount == maxCount ) :
            temp = str1 [ i - K + 1 : i + 1 ]
            if ( temp < res ) :
                res = temp
    return res
if __name__ == ' _ _ main _ _ ' :
    str1 = " ceebbaceeffo "
    K = 3
    print ( maxVowelSubString ( str1 , K ) )

Index/key variables: i
Iterator variables: i
Python program:
def decodeStr ( str , len ) :
    c = [ " " for i in range ( len ) ]
    pos = 1
    if ( len % 2 == 1 ) :
        med = int ( len / 2 )
    else :
        med = int ( len / 2 - 1 )
    c [ med ] = str [ 0 ]
    if ( len % 2 == 0 ) :
        c [ med + 1 ] = str [ 1 ]
    if ( len & 1 ) :
        k = 1
    else :
        k = 2
    for i in range ( k , len , 2 ) :
        c [ med - pos ] = str [ i ]
        if ( len % 2 == 1 ) :
            c [ med + pos ] = str [ i + 1 ]
        else :
            c [ med + pos + 1 ] = str [ i + 1 ]
        pos += 1
    print ( * c , sep = " " )
str = " ofrsgkeeeekgs "
len = len ( str )
decodeStr ( str , len )

Index/key variables: i, med
Accumulator variables: pos
Iterator variables: i
Python program:
def findCount ( s , L , R ) :
    distinct = 0
    frequency = [ 0 for i in range ( 26 ) ]
    for i in range ( L , R + 1 , 1 ) :
        frequency [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( 26 ) :
        if ( frequency [ i ] > 0 ) :
            distinct += 1
    print ( distinct )
if __name__ == ' _ _ main _ _ ' :
    s = " geeksforgeeksisacomputerscienceportal "
    queries = 3
    Q = [ [ 0 , 10 ] , [ 15 , 18 ] , [ 12 , 20 ] ]
    for i in range ( queries ) :
        findCount ( s , Q [ i ] [ 0 ] , Q [ i ] [ 1 ] )

Index/key variables: i
Accumulator variables: distinct
Iterator variables: i
Python program:
def ReverseComplement ( s , n , k ) :
    rev = ( k + 1 ) // 2
    complement = k - rev
    if ( rev % 2 ) :
        s = s [ : : - 1 ]
    if ( complement % 2 ) :
        for i in range ( n ) :
            if ( s [ i ] == '0' ) :
                s [ i ] = '1'
            else :
                s [ i ] = '0'
    return s
if __name__ == ' _ _ main _ _ ' :
    str1 = "10011"
    k = 5
    n = len ( str1 )
    print ( ReverseComplement ( str1 , n , k ) )

Index/key variables: i
Iterator variables: i
Python program:
def repeatingString ( s , n , k ) :
    if ( n % k != 0 ) :
        return False
    frequency = [ 0 for i in range ( 123 ) ]
    for i in range ( 123 ) :
        frequency [ i ] = 0
    for i in range ( n ) :
        frequency [ s [ i ] ] += 1
    repeat = n // k
    for i in range ( 123 ) :
        if ( frequency [ i ] % repeat != 0 ) :
            return False
    return True
if __name__ == ' _ _ main _ _ ' :
    s = " abcdcba "
    n = len ( s )
    k = 3
    if ( repeatingString ( s , n , k ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def findPhoneNumber ( n ) :
    temp = n
    sum = 0
    while ( temp != 0 ) :
        sum += temp % 10
        temp = temp // 10
    if ( sum < 10 ) :
        print ( n , "0" , sum )
    else :
        n = str ( n )
        sum = str ( sum )
        n += sum
        print ( n )
if __name__ == ' _ _ main _ _ ' :
    n = 98765432
    findPhoneNumber ( n )

Accumulator variables: sum
Python program:
def cntSplits ( s ) :
    if ( s [ len ( s ) - 1 ] == '1' ) :
        return 0 ;
    c_zero = 0 ;
    for i in range ( len ( s ) ) :
        c_zero += ( s [ i ] == '0' ) ;
    return int ( pow ( 2 , c_zero - 1 ) ) ;
if __name__ == " _ _ main _ _ " :
    s = "10010" ;
    print ( cntSplits ( s ) ) ;

Index/key variables: i
Accumulator variables: c_zero
Iterator variables: i
Python program:
def findNumbers ( s ) :
    n = len ( s )
    count = 1
    result = 0
    left = 0
    right = 1
    while ( right < n ) :
        if ( s [ left ] == s [ right ] ) :
            count += 1
        else :
            result += count * ( count + 1 ) // 2
            left = right
            count = 1
        right += 1
    result += count * ( count + 1 ) // 2
    print ( result )
s = " bbbcbb "
findNumbers ( s )

Index/key variables: left, right
Accumulator variables: count, result
Python program:
def isVowel ( ch ) :
    ch = ch . upper ( )
    if ( ch == ' A ' or ch == ' E ' or ch == ' I ' or ch == ' O ' or ch == ' U ' ) :
        return True
    else :
        return False
def duplicateVowels ( S ) :
    t = len ( S )
    res = " "
    for i in range ( t ) :
        if ( isVowel ( S [ i ] ) ) :
            res += S [ i ]
        res += S [ i ]
    return res
S = " helloworld "
print ( " Original ▁ String : ▁ " , S )
res = duplicateVowels ( S )
print ( " String ▁ with ▁ Vowels ▁ duplicated : ▁ " , res )

Index/key variables: i
Accumulator variables: res
Iterator variables: i
Python program:
MAX = 26
def largestSubSeq ( arr , n ) :
    count = [ 0 ] * MAX
    for i in range ( n ) :
        string = arr [ i ]
        _hash = [ False ] * MAX
        for j in range ( len ( string ) ) :
            _hash [ ord ( string [ j ] ) - ord ( ' a ' ) ] = True
        for j in range ( MAX ) :
            if _hash [ j ] == True :
                count [ j ] += 1
    return max ( count )
if __name__ == " _ _ main _ _ " :
    arr = [ " ab " , " bc " , " de " ]
    n = len ( arr )
    print ( largestSubSeq ( arr , n ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def isPalindrome ( s ) :
    l = len ( s )
    for i in range ( l // 2 ) :
        if ( s [ i ] != s [ l - 1 - i ] ) :
            return False
    return True
def createStringAndCheckPalindrome ( N ) :
    sub = " " + chr ( N )
    res_str = " "
    sum = 0
    while ( N > 0 ) :
        digit = N % 10
        sum += digit
        N = N // 10
    while ( len ( res_str ) < sum ) :
        res_str += sub
    if ( len ( res_str ) > sum ) :
        res_str = res_str [ 0 : sum ]
    if ( isPalindrome ( res_str ) ) :
        return True
    return False
if __name__ == " _ _ main _ _ " :
    N = 10101
    if ( createStringAndCheckPalindrome ( N ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Accumulator variables: res_str, sum
Iterator variables: i
Python program:
def minimumLength ( s ) :
    maxOcc = 0
    n = len ( s )
    arr = [ 0 ] * 26
    for i in range ( n ) :
        arr [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( 26 ) :
        if arr [ i ] > maxOcc :
            maxOcc = arr [ i ]
    return n - maxOcc
if __name__ == " _ _ main _ _ " :
    str = " afddewqd "
    print ( minimumLength ( str ) )

Index/key variables: i
Iterator variables: i
Python program:
def removeSpecialCharacter ( s ) :
    i = 0
    while i < len ( s ) :
        if ( ord ( s [ i ] ) < ord ( ' A ' ) or ord ( s [ i ] ) > ord ( ' Z ' ) and ord ( s [ i ] ) < ord ( ' a ' ) or ord ( s [ i ] ) > ord ( ' z ' ) ) :
            del s [ i ]
            i -= 1
        i += 1
    print ( " " . join ( s ) )
if __name__ == ' _ _ main _ _ ' :
    s = " $ Gee * k ; s . . fo , ▁ r ' Ge ^ eks ? "
    s = [ i for i in s ]
    removeSpecialCharacter ( s )

Index/key variables: i
Python program:
def removeSpecialCharacter ( s ) :
    t = " "
    for i in s :
        if ( i >= ' A ' and i <= ' Z ' ) or ( i >= ' a ' and i <= ' z ' ) :
            t += i
    print ( t )
s = " $ Gee * k ; s . . fo , ▁ r ' Ge ^ eks ? "
removeSpecialCharacter ( s )

Accumulator variables: t
Iterator variables: i
Python program:
def findRepeatFirstN2 ( s ) :
    p = - 1
    for i in range ( len ( s ) ) :
        for j in range ( i + 1 , len ( s ) ) :
            if ( s [ i ] == s [ j ] ) :
                p = i
                break
        if ( p != - 1 ) :
            break
    return p
if __name__ == " _ _ main _ _ " :
    str = " geeksforgeeks "
    pos = findRepeatFirstN2 ( str )
    if ( pos == - 1 ) :
        print ( " Not ▁ found " )
    else :
        print ( str [ pos ] )

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