dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def prefix ( string ) :
    k = 1 ;
    n = len ( string ) ;
    g = [ ] ;
    flag = 0 ;
    for i in range ( 1 , n ) :
        if ( string [ i ] == string [ 0 ] ) :
            g . append ( i ) ;
            flag = 1 ;
    if ( flag == 0 ) :
        print ( string ) ;
    else :
        length = len ( g ) ;
        while ( k < g [ 0 ] ) :
            cnt = 0 ;
            for j in range ( length ) :
                if ( string [ g [ j ] + k ] == string [ k ] ) :
                    cnt += 1 ;
            if ( cnt == len ) :
                k += 1 ;
            else :
                break ;
        for i in range ( k + 1 ) :
            print ( string [ i ] , end = " " ) ;
        print ( )
if __name__ == " _ _ main _ _ " :
    string = " abcab " ;
    prefix ( string ) ;

Index/key variables: i, j, k
Accumulator variables: cnt, g
Iterator variables: i, j
Python program:
def printPermutation ( N , K ) :
    res = list ( ) ;
    l , r , flag = 1 , N , 0
    for i in range ( K ) :
        if flag == False :
            res . append ( l )
            l += 1
        else :
            res . append ( r ) ;
            r -= 1 ;
        flag = flag ^ 1 ;
    if flag == False :
        for i in range ( r , 2 , - 1 ) :
            res . append ( i )
    else :
        for i in range ( l , r ) :
            res . append ( i )
    for i in res :
        print ( i , end = " ▁ " )
N , K = 10 , 4
printPermutation ( N , K )

Accumulator variables: l, r, res
Iterator variables: i
Python program:
def fact ( N ) :
    product = 1
    for i in range ( 1 , N + 1 ) :
        product = product * i
    return product
def nthTerm ( N ) :
    return ( N * N ) * fact ( N )
if __name__ == " _ _ main _ _ " :
    N = 4
    print ( nthTerm ( N ) )

Iterator variables: i
Python program:
MAXN = 100001
spf = [ 0 ] * MAXN
def sieve ( ) :
    spf [ 1 ] = 1
    for i in range ( 2 , MAXN ) :
        spf [ i ] = i
    for i in range ( 4 , MAXN , 2 ) :
        spf [ i ] = 2
    i = 3
    while ( i * 8 < MAXN ) :
        i += 1
        if ( spf [ i ] == i ) :
            for j in range ( i * i , MAXN , i ) :
                if ( spf [ j ] == j ) :
                    spf [ j ] = i
def getFactorization ( x ) :
    ret = [ ]
    while ( x != 1 ) :
        ret . append ( spf [ x ] )
        value = spf [ x ]
        while ( x % value == 0 ) :
            x = x // value
    return ret
def flipString ( S , arr , M ) :
    sieve ( ) ;
    frequency = [ 0 ] * MAXN
    for i in range ( 0 , M ) :
        primeFactors = getFactorization ( arr [ i ] )
        for factors in primeFactors :
            frequency [ factors ] += 1
            frequency [ factors ] %= 2
    N = len ( S )
    for i in range ( 0 , MAXN ) :
        if ( frequency [ i ] & 1 ) :
            for j in range ( i , N + 1 , i ) :
                S [ j - 1 ] = ( '0' if S [ j - 1 ] == '1' else '1' )
    return S
S = "000000"
S = list ( S )
arr = [ 2 , 4 , 6 ]
M = len ( arr )
print ( " " . join ( flipString ( S , arr , M ) ) )

Index/key variables: factors, i, j, x
Accumulator variables: ret
Iterator variables: factors, i, j
Python program:
def isOnesGreater ( S , N ) :
    S = list ( S )
    cnt0 = 0
    cnt1 = 0
    for i in range ( N ) :
        if ( S [ i ] == '1' ) :
            cnt1 += 1
        else :
            cnt0 += 1
    for i in range ( N ) :
        if ( S [ i ] == '1' ) :
            if ( i > 0 and S [ i - 1 ] == '0' ) :
                S [ i - 1 ] = ' _ '
                cnt0 -= 1
            elif ( i < N and S [ i + 1 ] == '0' ) :
                S [ i + 1 ] = ' _ '
                cnt0 -= 1
    if ( cnt1 > cnt0 ) :
        print ( " Yes " )
    else :
        print ( " No " )
S = "01"
N = len ( S )
isOnesGreater ( S , N )

Index/key variables: i
Accumulator variables: cnt0, cnt1
Iterator variables: i
Python program:
def minOperation ( St , K , N ) :
    S = list ( St )
    min = 0
    i = 0
    for i in range ( 0 , N ) :
        if ( S [ i ] == '0' and i + K <= N ) :
            j = i
            while ( j < i + K ) :
                if ( S [ j ] == '1' ) :
                    S [ j ] = '0'
                else :
                    S [ j ] = '1'
                j += 1
            min += 1
    temp = 0
    for i in range ( 0 , N ) :
        temp += 1
        if ( S [ i ] == '0' ) :
            break
    if ( temp == N ) :
        print ( min )
    else :
        print ( - 1 )
S = "00010110"
K = 3
N = len ( S )
minOperation ( S , K , N )

Index/key variables: i, j
Accumulator variables: min, temp
Iterator variables: i
Python program:
def validInsertionstring ( S1 , S2 ) :
    N = len ( S1 )
    M = len ( S2 )
    st = [ ]
    for i in range ( N ) :
        st . append ( S1 [ i ] )
        if ( S1 [ i ] == S2 [ M - 1 ] ) :
            idx = M - 1
            while ( idx >= 0 ) :
                if ( len ( st ) == 0 ) :
                    return False
                c = st [ - 1 ]
                st . pop ( )
                if ( c != S2 [ idx ] ) :
                    return False
                idx -= 1
    if ( len ( st ) != 0 ) :
        return False
    else :
        return True
S1 = " aabb "
S2 = " ab "
if validInsertionstring ( S1 , S2 ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i, idx
Accumulator variables: st
Iterator variables: i
Python program:
def can_form_palindrome ( arr , n ) :
    MAX = 256
    s = " "
    for i in range ( n ) :
        s = s + str ( arr [ i ] )
    freq = [ 0 ] * MAX
    for i in range ( N ) :
        freq [ arr [ i ] ] = freq [ arr [ i ] ] + 1
    count = 0
    for i in range ( MAX ) :
        if ( freq [ i ] & 1 ) :
            count = count + 1
        if ( count > 1 ) :
            return False
    return True
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 3 , 1 , 2 ]
    N = len ( arr )
    if ( can_form_palindrome ( arr , N ) ) :
        print ( " YES " )
    else :
        print ( " NO " )

Index/key variables: i
Iterator variables: i
Python program:
def minimumFlips ( s ) :
    n = len ( s )
    cnt0 = s . count ( '0' )
    cnt1 = 0
    res = n - cnt0
    for i in range ( n ) :
        if s [ i ] == '0' :
            cnt0 -= 1
        elif s [ i ] == '1' :
            res = min ( res , cnt1 + cnt0 )
            cnt1 += 1
    return res
S = '000110'
print ( minimumFlips ( S ) )

Index/key variables: i
Accumulator variables: cnt0, cnt1
Iterator variables: i
Python program:
def maximumK ( S ) :
    N = len ( S )
    ans = N
    flag = 0
    for i in range ( N - 1 ) :
        if ( S [ i ] != S [ i + 1 ] ) :
            flag = 1
            ans = min ( ans , max ( i + 1 , N - i - 1 ) )
    if ( flag == 0 ) :
        return 0
    return ans
if __name__ == ' _ _ main _ _ ' :
    S = "010"
    print ( maximumK ( S ) )

Index/key variables: i
Iterator variables: i
Python program:
def checkhappy ( arr , K , N ) :
    visited = set ( )
    for s in arr :
        if ( s [ 0 ] == K ) :
            if s [ 1 : ] in visited :
                return ' Yes '
        else :
            if ( K + s ) in visited :
                return ' Yes '
        visited . add ( s )
    return " No "
if __name__ == ' _ _ main _ _ ' :
    arr = [ ' a ' , ' ! ▁ a ' , ' b ' , ' ! ▁ c ' , ' d ' , ' ! ▁ d ' ]
    K = ' ! '
    N = len ( arr )
    print ( checkhappy ( arr , K , N ) )

Accumulator variables: visited
Iterator variables: s
Python program:
def minimumTimeToConvertString ( S , N ) :
    S = [ i for i in S ]
    upper = 0
    lower = 0
    for i in range ( N ) :
        c = S [ i ]
        if ( c . isupper ( ) ) :
            upper += 1
        else :
            lower += 1
    moves = 0
    if ( upper > N // 2 ) :
        i = 0
        while ( upper > N // 2 and i < N ) :
            if ( S [ i ] . isupper ( ) ) :
                S [ i ] += 32
                moves += 1
                upper -= 1
                lower += 1
            i += 1
    elif ( lower > N // 2 ) :
        i = 0
        while ( lower > N // 2 and i < N ) :
            if ( S [ i ] . islower ( ) ) :
                S [ i ] = chr ( ord ( S [ i ] ) - 32 )
                moves += 1
                upper += 1
                lower -= 1
            i += 1
    print ( moves )
    print ( " " . join ( S ) )
if __name__ == ' _ _ main _ _ ' :
    S = " AbcdEf "
    N = len ( S )
    minimumTimeToConvertString ( S , N )

Index/key variables: i
Accumulator variables: lower, moves, upper
Iterator variables: i
Python program:
def subString ( s , n ) :
    hash = { 0 : 1 }
    pre = 0
    count = 0
    for i in s :
        pre ^= ( 1 << ord ( i ) - 97 )
        count += hash . get ( pre , 0 )
        hash [ pre ] = hash . get ( pre , 0 ) + 1
    return count
S = " abbaa "
N = len ( S )
print ( subString ( S , N ) )

Index/key variables: pre
Accumulator variables: count
Iterator variables: i
Python program:
from collections import defaultdict
def atleastkDistinctChars ( s , k ) :
    n = len ( s )
    mp = defaultdict ( int )
    begin = 0
    end = 0
    ans = 0
    while ( end < n ) :
        c = s [ end ]
        mp += 1
        end += 1
        while ( len ( mp ) >= k ) :
            pre = s [ begin ]
            mp [ pre ] -= 1
            if ( mp [ pre ] == 0 ) :
                del mp [ pre ]
            ans += len ( s ) - end + 1
            begin += 1
    print ( ans )
if __name__ == " _ _ main _ _ " :
    S = " abcca "
    K = 3
    atleastkDistinctChars ( S , K )

Index/key variables: begin, end, pre
Accumulator variables: ans, mp
Python program:
def canSplit ( S ) :
    frequency = [ 0 ] * 26
    cnt_singles = 0
    k = 0
    for i in range ( len ( S ) ) :
        frequency [ ord ( S [ i ] ) - ord ( ' a ' ) ] += 1
    odd = 0
    eve = 0
    for i in range ( 26 ) :
        if ( frequency [ i ] ) :
            odd += ( frequency [ i ] & 1 )
            eve += frequency [ i ] // 2
    if ( eve >= odd ) :
        print ( " Yes " )
    else :
        print ( " No " )
if __name__ == " _ _ main _ _ " :
    S = " aaabbbccc "
    canSplit ( S )

Index/key variables: i
Accumulator variables: eve, odd
Iterator variables: i
Python program:
def minDeletions ( str ) :
    fre = [ 0 ] * 26
    n = len ( str )
    for i in range ( n ) :
        fre [ ord ( str [ i ] ) - ord ( ' a ' ) ] += 1
    count = 0
    for i in range ( 26 ) :
        if ( fre [ i ] % 2 ) :
            count += 1
    if ( count == 0 or count == 1 ) :
        return 0
    else :
        return count - 1
if __name__ == ' _ _ main _ _ ' :
    str = " ababbccca "
    print ( minDeletions ( str ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def scoreOfParentheses ( s ) :
    stack = [ ]
    stack . append ( 0 )
    for c in s :
        if ( c == ' ( ' ) :
            stack . append ( 0 )
        else :
            tmp = stack [ len ( stack ) - 1 ]
            stack = stack [ : - 1 ]
            val = 0
            if ( tmp > 0 ) :
                val = tmp * 2
            else :
                val = 1
            stack [ len ( stack ) - 1 ] += val
    print ( stack [ len ( stack ) - 1 ] )
if __name__ == ' _ _ main _ _ ' :
    S = " ( ( ) ( ( ) ) ) "
    scoreOfParentheses ( S )

Accumulator variables: stack
Iterator variables: c
Python program:
def findSubstringInWraproundString ( p ) :
    ans = 0
    curLen = 0
    arr = [ 0 ] * 26
    for i in range ( 0 , len ( p ) ) :
        curr = ord ( p [ i ] ) - ord ( ' a ' )
        if ( i > 0 and ( ord ( p [ i - 1 ] ) != ( ( curr + 26 - 1 ) % 26 + ord ( ' a ' ) ) ) ) :
            curLen = 0
        curLen += 1
        if ( curLen > arr [ curr ] ) :
            ans += ( curLen - arr [ curr ] )
            arr [ curr ] = curLen
    print ( ans )
p = " zab "
findSubstringInWraproundString ( p )

Index/key variables: curr, i
Accumulator variables: ans, curLen
Iterator variables: i
Python program:
def remove ( N , digit ) :
    strN = str ( N )
    ans = ' '
    for i in strN :
        if int ( i ) == digit :
            continue
        ans += i
    return int ( ans )
def getMin ( arr ) :
    minSum = float ( ' inf ' )
    for i in range ( 10 ) :
        curSum = 0
        for num in arr :
            curSum += remove ( num , i )
        minSum = min ( minSum , curSum )
    print ( minSum )
arr = [ 34 , 23 , 85 , 93 ]
getMin ( arr )

Accumulator variables: ans, curSum
Iterator variables: i, num
Python program:
def minOperation ( arr , N ) :
    cntMinOP = 0 ;
    M = len ( arr [ 0 ] ) ;
    hash = [ [ 0 for i in range ( M ) ] for j in range ( 256 ) ] ;
    for i in range ( N ) :
        for j in range ( M ) :
            hash [ ord ( arr [ i ] [ j ] ) ] [ j ] += 1 ;
    for i in range ( M ) :
        Sum = 0 ;
        Max = 0 ;
        for j in range ( 256 ) :
            Sum += hash [ j ] [ i ] ;
            Max = max ( Max , hash [ j ] [ i ] ) ;
        cntMinOP += ( Sum - Max ) ;
    return cntMinOP ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ " abcd " , " bcde " , " cdef " ] ;
    N = len ( arr ) ;
    print ( minOperation ( arr , N ) ) ;

Index/key variables: i, j
Accumulator variables: Sum, cntMinOP
Iterator variables: i, j
Python program:
def find_num ( n ) :
    ans = 0
    digitsOfN = str ( n )
    sumOfDigitsN = 0
    for c in digitsOfN :
        sumOfDigitsN += int ( c )
    for x in range ( 11 , 50 ) :
        newNum = x * int ( n )
        tempSumDigits = 0
        temp = str ( newNum )
        for c in temp :
            tempSumDigits += int ( c )
        if ( tempSumDigits == sumOfDigitsN ) :
            ans = x
            break
    print ( ans )
if __name__ == ' _ _ main _ _ ' :
    N = "3029"
    find_num ( N )

Accumulator variables: sumOfDigitsN, tempSumDigits
Iterator variables: c, x
Python program:
def findDisStr ( arr , N ) :
    DistString = set ( )
    for i in range ( N ) :
        if ( arr [ i ] not in DistString ) :
            DistString . add ( arr [ i ] )
    for string in DistString :
        print ( string , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    arr = [ " Geeks " , " For " , " Geeks " , " Code " , " Coder " ]
    N = len ( arr )
    findDisStr ( arr , N )

Index/key variables: i
Accumulator variables: DistString
Iterator variables: i, string
Python program:
def modifyString ( A , str , K ) :
    N = len ( str )
    count = [ 0 ] * ( N + 1 )
    for i in range ( K ) :
        count [ A [ i ] ] += 1
    for i in range ( 1 , N // 2 + 1 ) :
        count [ i ] = count [ i ] + count [ i - 1 ]
        if ( count [ i ] & 1 ) :
            str [ i - 1 ] , str [ N - i ] = str [ N - i ] , str [ i - 1 ]
    return " " . join ( str )
if __name__ == ' _ _ main _ _ ' :
    str1 = " abcdef "
    str = [ i for i in str1 ]
    arr = [ 1 , 2 , 3 ]
    K = len ( arr )
    print ( modifyString ( arr , str , K ) )

Index/key variables: i
Iterator variables: i
Python program:
from math import gcd
def findFraction ( s ) :
    be_deci = " "
    af_deci = " "
    reccu = " "
    x = True
    y = False
    z = False
    for i in range ( len ( s ) ) :
        if ( s [ i ] == ' . ' ) :
            x = False
            y = True
            continue
        if ( s [ i ] == ' ( ' ) :
            z = True
            y = False
            continue
        if ( x ) :
            be_deci += s [ i ]
        if ( y ) :
            af_deci += s [ i ]
        if ( z ) :
            while i < len ( s ) and s [ i ] != ' ) ' :
                reccu += s [ i ]
                i += 1
            break
    num_be_deci = int ( be_deci )
    num_af_deci = 0
    if len ( af_deci ) != 0 :
        num_af_deci = int ( af_deci )
    numr = ( num_be_deci * pow ( 10 , len ( af_deci ) ) + num_af_deci )
    deno = pow ( 10 , len ( af_deci ) )
    if len ( reccu ) == 0 :
        gd = gcd ( numr , deno )
        print ( numr // gd , " / " , deno // gd )
    else :
        reccu_num = int ( reccu )
        numr1 = ( numr * pow ( 10 , len ( reccu ) ) + reccu_num )
        deno1 = deno * pow ( 10 , len ( reccu ) )
        res_numr = numr1 - numr
        res_deno = deno1 - deno
        gd = gcd ( res_numr , res_deno )
        print ( res_numr // gd , " ▁ / ▁ " , res_deno // gd )
if __name__ == ' _ _ main _ _ ' :
    str = "23.98(231 ) "
    findFraction ( str )

Index/key variables: i
Accumulator variables: af_deci, be_deci, reccu
Iterator variables: i
Boolean variables: x, y, z
Python program:
def lexi_largest_string ( a , i , sum , v ) :
    if ( sum < 0 ) :
        return False
    if ( sum == 0 ) :
        return True
    if ( i < 0 ) :
        return False
    v . append ( i )
    if ( lexi_largest_string ( a , i , sum - a [ i ] , v ) ) :
        return True
    v . pop ( - 1 )
    return lexi_largest_string ( a , i - 1 , sum , v )
def generateString ( a , sum ) :
    v = [ ]
    lexi_largest_string ( a , 25 , sum , v )
    s = " "
    for j in range ( len ( v ) ) :
        s += chr ( v [ j ] + ord ( ' a ' ) )
    print ( s )
if __name__ == ' _ _ main _ _ ' :
    a = [ 1 , 1 , 2 , 33 , 4 , 6 , 9 , 7 , 36 , 32 , 58 , 32 , 28 , 904 , 22 , 255 , 47 , 69 , 558 , 544 , 21 , 36 , 48 , 85 , 48 , 58 ]
    sum = 236
    generateString ( a , sum )

Index/key variables: i, j
Accumulator variables: s
Iterator variables: j
Python program:
def fact ( a ) :
    f = 1
    for i in range ( 2 , a + 1 ) :
        f = f * i
    return f
def permute ( n , r ) :
    ans = 0
    ans = fact ( n ) // fact ( n - r )
    return ans
def findPermutations ( n ) :
    sum = 0
    for r in range ( 1 , n + 1 ) :
        P = permute ( n , r )
        sum = sum + P
    return sum
str = " xz "
n = len ( str )
print ( findPermutations ( n ) )

Iterator variables: i, r
Python program:
V = 5
def DFS ( graph , marked , n , vert , start , count ) :
    marked [ vert ] = True
    if n == 0 :
        marked [ vert ] = False
        if graph [ vert ] [ start ] == 1 :
            count = count + 1
            return count
        else :
            return count
    for i in range ( V ) :
        if marked [ i ] == False and graph [ vert ] [ i ] == 1 :
            count = DFS ( graph , marked , n - 1 , i , start , count )
    marked [ vert ] = False
    return count
def countCycles ( graph , n ) :
    marked = [ False ] * V
    count = 0
    for i in range ( V - ( n - 1 ) ) :
        count = DFS ( graph , marked , n - 1 , i , i , count )
        marked [ i ] = True
    return int ( count / 2 )
graph = [ [ 0 , 1 , 0 , 1 , 0 ] , [ 1 , 0 , 1 , 0 , 1 ] , [ 0 , 1 , 0 , 1 , 0 ] , [ 1 , 0 , 1 , 0 , 1 ] , [ 0 , 1 , 0 , 1 , 0 ] ]
n = 4
print ( " Total ▁ cycles ▁ of ▁ length ▁ " , n , " ▁ are ▁ " , countCycles ( graph , n ) )

Index/key variables: i, start, vert
Iterator variables: i
Python program:
def polynomialRollingHash ( str ) :
    p = 31
    m = 1e9 + 9
    power_of_p = 1
    hash_val = 0
    for i in range ( len ( str ) ) :
        hash_val = ( ( hash_val + ( ord ( str [ i ] ) - ord ( ' a ' ) + 1 ) * power_of_p ) % m )
        power_of_p = ( power_of_p * p ) % m
    return int ( hash_val )
if __name__ == ' _ _ main _ _ ' :
    str1 = " geeksforgeeks "
    print ( " Hash ▁ of ▁ ' { } ' ▁ = ▁ { } " . format ( str1 , polynomialRollingHash ( str1 ) ) )

Index/key variables: i
Iterator variables: i
Python program:
import collections
def firstNonRepElement ( str ) :
    list . append ( str [ 0 ] )
    for i in range ( len ( str ) ) :
        if str [ i ] in list :
            list . remove ( str [ i ] )
        else :
            list . append ( str [ i ] )
    print ( list [ 0 ] )
if __name__ == ' _ _ main _ _ ' :
    str = " geeksforgeeks " ;
    firstNonRepElement ( str ) ;

Index/key variables: i
Accumulator variables: list
Iterator variables: i
Python program:
def countSubstrings ( str , K ) :
    N = len ( str )
    answer = 0
    map = { }
    for i in range ( K ) :
        map [ str [ i ] ] = map . get ( str [ i ] , 0 ) + 1
    if ( len ( map ) == K ) :
        answer += 1
    for i in range ( K , N ) :
        map [ str [ i ] ] = map . get ( str [ i ] , 0 ) + 1
        map [ str [ i - K ] ] -= 1
        if ( map [ str [ i - K ] ] == 0 ) :
            del map [ str [ i - K ] ]
        if ( len ( map ) == K ) :
            answer += 1
    return answer
if __name__ == ' _ _ main _ _ ' :
    str = " aabcdabbcdc "
    K = 3
    print ( countSubstrings ( str , K ) )

Index/key variables: i
Accumulator variables: answer
Iterator variables: i
Python program:
def LongestPalindromicPrefix ( string ) :
    n = len ( string )
    max_len = 0
    for length in range ( 0 , n + 1 ) :
        temp = string [ 0 : length ]
        temp2 = temp
        temp3 = temp2 [ : : - 1 ]
        if temp == temp3 :
            max_len = length
    print ( string [ 0 : max_len ] )
if __name__ == ' _ _ main _ _ ' :
    string = " abaac " ;
    LongestPalindromicPrefix ( string )

Iterator variables: length
Python program:
def find_kth_string_of_n ( n , k ) :
    d = [ 0 for i in range ( n ) ]
    for i in range ( n - 1 , - 1 , - 1 ) :
        d [ i ] = k % 26
        k //= 26
    if k > 0 :
        return - 1
    s = " "
    for i in range ( n ) :
        s += chr ( d [ i ] + ord ( ' a ' ) )
    return s
n = 3
k = 10
k -= 1
print ( find_kth_string_of_n ( n , k ) )

Index/key variables: i
Accumulator variables: k, s
Iterator variables: i
Python program:
from collections import defaultdict
def findMinLength ( s ) :
    n = len ( s )
    counts = defaultdict ( int )
    indices = [ ]
    for i in range ( n ) :
        if ( s [ i ] == ' a ' or s [ i ] == ' e ' or s [ i ] == ' o ' or s [ i ] == ' i ' or s [ i ] == ' u ' ) :
            counts [ s [ i ] ] += 1
            indices . append ( i )
    if len ( counts ) < 5 :
        return - 1
    flag1 = 0
    flag2 = 0
    i = 0
    j = len ( indices ) - 1
    while ( j - i ) >= 4 :
        if ( ~ flag1 and counts [ s [ indices [ i ] ] ] > 1 ) :
            counts [ s [ indices [ i ] ] ] -= 1
            i += 1
        else :
            flag1 = 1
        if ( ~ flag2 and counts [ s [ indices [ j ] ] ] > 1 ) :
            counts [ s [ indices [ j ] ] ] -= 1
            j -= 1
        else :
            flag2 = 1
        if ( flag1 and flag2 ) :
            break
    return ( indices [ j ] - indices [ i ] + 1 )
s = " aaeebbeaccaaoiuooooooooiuu "
print ( findMinLength ( s ) )

Index/key variables: i, j
Accumulator variables: indices
Iterator variables: i
Python program:
def isComsomamts ( x ) :
    x = x . lower ( )
    return not ( x == ' a ' or x == ' e ' or x == ' i ' or x == ' o ' or x == ' u ' )
def longestConsonantsSubsequence ( s ) :
    answer = ' '
    n = len ( s )
    for i in range ( n ) :
        if isComsomamts ( s [ i ] ) :
            answer += s [ i ]
    return answer
s = ' geeksforgeeks '
print ( longestConsonantsSubsequence ( s ) )

Index/key variables: i
Accumulator variables: answer
Iterator variables: i
Python program:
from collections import defaultdict
def lengthOfSubsequence ( st , K ) :
    mp = defaultdict ( int )
    for ch in st :
        mp [ ch ] += 1
    minimum = mp [ ' A ' ]
    for i in range ( 1 , K ) :
        minimum = min ( minimum , mp [ chr ( i + ord ( ' A ' ) ) ] )
    return ( minimum * K )
if __name__ == " _ _ main _ _ " :
    st = " ACAABCCAB "
    K = 3
    print ( lengthOfSubsequence ( st , K ) )

Index/key variables: ch
Iterator variables: ch, i
Python program:
V = 4
INF = 99999
def negCyclefloydWarshall ( graph ) :
    dist = [ [ 0 for i in range ( V + 1 ) ] for j in range ( V + 1 ) ]
    for i in range ( V ) :
        for j in range ( V ) :
            dist [ i ] [ j ] = graph [ i ] [ j ]
    for k in range ( V ) :
        for i in range ( V ) :
            for j in range ( V ) :
                if ( dist [ i ] [ k ] + dist [ k ] [ j ] < dist [ i ] [ j ] ) :
                    dist [ i ] [ j ] = dist [ i ] [ k ] + dist [ k ] [ j ]
    for i in range ( V ) :
        if ( dist [ i ] [ i ] < 0 ) :
            return True
    return False
graph = [ [ 0 , 1 , INF , INF ] , [ INF , 0 , - 1 , INF ] , [ INF , INF , 0 , - 1 ] , [ - 1 , INF , INF , 0 ] ]
if ( negCyclefloydWarshall ( graph ) ) :
    print ( " Yes " )
else :
    print ( " No " )

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