dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
import sys
def maxProductSum ( string , m ) :
    n = len ( string )
    maxProd , maxSum = ( - ( sys . maxsize ) - 1 , - ( sys . maxsize ) - 1 )
    for i in range ( n - m + 1 ) :
        product , sum = 1 , 0
        for j in range ( i , m + i ) :
            product = product * ( ord ( string [ j ] ) - ord ( '0' ) )
            sum = sum + ( ord ( string [ j ] ) - ord ( '0' ) )
        maxProd = max ( maxProd , product )
        maxSum = max ( maxSum , sum )
    print ( " Maximum ▁ Product ▁ = " , maxProd )
    print ( " Maximum ▁ sum ▁ = " , maxSum )
if __name__ == " _ _ main _ _ " :
    string = "3605356297"
    m = 3
    maxProductSum ( string , m )

Index/key variables: j
Iterator variables: i, j
Python program:
import sys
import math
def maxLength ( s , n ) :
    right = 0
    left = 0
    coun = 0
    max_length = - ( sys . maxsize - 1 )
    s = s + '1'
    for i in range ( 0 , n + 1 ) :
        if s [ i ] == ' o ' :
            coun += 1
        else :
            if coun > max_length :
                right = 0
                left = 0
                if s [ i ] == ' x ' :
                    right = 1
                if i - coun > 0 and s [ i - coun - 1 ] == ' x ' :
                    left = 1
                coun = math . ceil ( float ( coun / ( right + left ) ) )
                max_length = max ( max_length , coun )
            coun = 0
    return max_length
if __name__ == ' _ _ main _ _ ' :
    s = " oooxoooooooooxooo "
    n = len ( s )
    print ( maxLength ( s , n ) )

Index/key variables: i
Accumulator variables: coun
Iterator variables: i
Python program:
def printLargestString ( s , l , r ) :
    freq = [ 0 ] * 26
    l -= 1
    r -= 1
    for i in range ( min ( l , r ) , max ( l , r ) + 1 ) :
        freq [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
    ans = " "
    for i in range ( 25 , - 1 , - 1 ) :
        while ( freq [ i ] ) :
            ans += chr ( ord ( ' a ' ) + i )
            freq [ i ] -= 1
    return ans
if __name__ == " _ _ main _ _ " :
    s = " striver "
    l = 3
    r = 5
    print ( printLargestString ( s , l , r ) )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def arrange ( s ) :
    cc = 0
    for i in range ( len ( s ) ) :
        if ( s [ i ] == "1" ) :
            cc += 1
    a = [ 0 ] * ( len ( s ) + 1 )
    qq = [ ( 2 , 3 ) , ( 5 , 5 ) ]
    n = len ( qq )
    for i in range ( n ) :
        l , r = qq [ i ] [ 0 ] , qq [ i ] [ 1 ]
        l -= 1
        r -= 1
        a [ l ] += 1
        a [ r + 1 ] -= 1
    for i in range ( 1 , len ( a ) ) :
        a [ i ] = a [ i ] + a [ i - 1 ]
    zz = [ 0 ] * len ( s )
    for i in range ( len ( a ) - 1 ) :
        if ( a [ i ] > 0 ) :
            if ( cc > 0 ) :
                zz [ i ] = 1
                cc -= 1
            else :
                break
        if ( cc == 0 ) :
            break
    if ( cc > 0 ) :
        for i in range ( len ( s ) ) :
            if ( zz [ i ] == 0 ) :
                zz [ i ] = 1
                cc -= 1
            if ( cc == 0 ) :
                break
    print ( * zz , sep = " " )
str = "11100"
arrange ( str )

Index/key variables: i, l
Accumulator variables: cc, r
Iterator variables: i
Python program:
def areVowelsInOrder ( s ) :
    n = len ( s )
    c = chr ( 64 )
    for i in range ( 0 , n ) :
        if ( s [ i ] == ' a ' or s [ i ] == ' e ' or s [ i ] == ' i ' or s [ i ] == ' o ' or s [ i ] == ' u ' ) :
            if s [ i ] < c :
                return False
            else :
                c = s [ i ]
    return True
if __name__ == " _ _ main _ _ " :
    s = " aabbbddeecc "
    if areVowelsInOrder ( s ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def newString ( s ) :
    l = len ( s )
    freq = [ 0 ] * ( 26 )
    for i in range ( 0 , l ) :
        freq [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
    ans = " "
    for i in range ( 0 , 26 ) :
        for j in range ( 0 , freq [ i ] ) :
            ans += chr ( 97 + i )
    return ans
if __name__ == " _ _ main _ _ " :
    s = " aabab "
    print ( newString ( s ) )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i, j
Python program:
def Remainder ( str , R ) :
    l = len ( str )
    Rem = 0
    for i in range ( l ) :
        Num = Rem * 10 + ( ord ( str [ i ] ) - ord ( '0' ) )
        Rem = Num % R
    return Rem
if __name__ == " _ _ main _ _ " :
    str = "13589234356546756"
    R = 13
    print ( Remainder ( str , R ) )

Index/key variables: i
Iterator variables: i
Python program:
def countWays ( a , n ) :
    suff = [ 0 ] * n
    if ( a [ n - 1 ] == 2 ) :
        suff [ n - 1 ] = 1
    for i in range ( n - 2 , - 1 , - 1 ) :
        if ( a [ i ] == 2 ) :
            suff [ i ] = suff [ i + 1 ] + 1
        else :
            suff [ i ] = suff [ i + 1 ]
    ss = 0
    for i in range ( n ) :
        if ( a [ i ] == 1 ) :
            ss += suff [ i ]
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            if ( a [ i ] == 1 and a [ j ] == 1 and suff [ j ] >= 2 ) :
                ss += ( suff [ j ] ) * ( suff [ j ] - 1 ) // 2
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            if ( a [ i ] == 1 and a [ j ] == 1 and ( suff [ i ] - suff [ j ] ) >= 1 and suff [ j ] >= 1 ) :
                ss += ( suff [ i ] - suff [ j ] ) * suff [ j ]
    print ( ss )
if __name__ == " _ _ main _ _ " :
    a = [ 1 , 2 , 1 , 1 , 2 , 2 ]
    n = 6
    countWays ( a , n )

Index/key variables: i, j
Accumulator variables: ss
Iterator variables: i, j
Python program:
def count_carry ( a , b ) :
    carry = 0 ;
    count = 0 ;
    len_a = len ( a ) ;
    len_b = len ( b ) ;
    while ( len_a != 0 or len_b != 0 ) :
        x = 0 ;
        y = 0 ;
        if ( len_a > 0 ) :
            x = int ( a [ len_a - 1 ] ) + int ( '0' ) ;
            len_a -= 1 ;
        if ( len_b > 0 ) :
            y = int ( b [ len_b - 1 ] ) + int ( '0' ) ;
            len_b -= 1 ;
        sum = x + y + carry ;
        if ( sum >= 10 ) :
            carry = 1 ;
            count += 1 ;
        else :
            carry = 0 ;
    return count ;
a = "9555" ;
b = "555" ;
count = count_carry ( a , b ) ;
if ( count == 0 ) :
    print ( "0" ) ;
elif ( count == 1 ) :
    print ( "1" ) ;
else :
    print ( count ) ;

Accumulator variables: count, len_a, len_b
Python program:
def printIndex ( str , s ) :
    flag = False ;
    for i in range ( len ( str ) ) :
        if ( str [ i : i + len ( s ) ] == s ) :
            print ( i , end = " ▁ " ) ;
            flag = True ;
    if ( flag == False ) :
        print ( " NONE " ) ;
str1 = " GeeksforGeeks " ;
str2 = " Geeks " ;
printIndex ( str1 , str2 ) ;

Iterator variables: i
Boolean variables: flag
Python program:
def merge ( s1 , s2 ) :
    result = " "
    i = 0
    while ( i < len ( s1 ) ) or ( i < len ( s2 ) ) :
        if ( i < len ( s1 ) ) :
            result += s1 [ i ]
        if ( i < len ( s2 ) ) :
            result += s2 [ i ]
        i += 1
    return result
s1 = " geeks "
s2 = " forgeeks "
print ( merge ( s1 , s2 ) )

Index/key variables: i
Accumulator variables: result
Python program:
ALPHABET_SIZE = 26 ;
class trieNode :
    def __init__ ( self ) :
        self . t = [ None for i in range ( ALPHABET_SIZE ) ]
        self . isEnd = 0
def getNode ( ) :
    temp = trieNode ( )
    return temp ;
def insert ( root , key ) :
    trail = None
    trail = root ;
    for i in range ( len ( key ) ) :
        if ( trail . t [ ord ( key [ i ] ) - ord ( ' a ' ) ] == None ) :
            temp = None
            temp = getNode ( ) ;
            trail . t [ ord ( key [ i ] ) - ord ( ' a ' ) ] = temp ;
        trail = trail . t [ ord ( key [ i ] ) - ord ( ' a ' ) ] ;
    ( trail . isEnd ) += 1
def search_mod ( root , word ) :
    trail = root ;
    for i in range ( len ( word ) ) :
        if ( trail . t [ ord ( word [ i ] ) - ord ( ' a ' ) ] == None ) :
            return False ;
        trail = trail . t [ ord ( word [ i ] ) - ord ( ' a ' ) ] ;
    if ( ( trail . isEnd ) > 0 and trail != None ) :
        ( trail . isEnd ) -= 1
        return True ;
    else :
        return False ;
def checkPossibility ( sentence , m , root ) :
    flag = 1 ;
    for i in range ( m ) :
        if ( search_mod ( root , sentence [ i ] ) == False ) :
            print ( ' NO ' , end = ' ' )
            return ;
    print ( ' YES ' )
def insertToTrie ( dictionary , n , root ) :
    for i in range ( n ) :
        insert ( root , dictionary [ i ] ) ;
if __name__ == ' _ _ main _ _ ' :
    root = getNode ( ) ;
    dictionary = [ " find " , " a " , " geeks " , " all " , " for " , " on " , " geeks " , " answers " , " inter " ]
    N = len ( dictionary )
    insertToTrie ( dictionary , N , root ) ;
    sentence = [ " find " , " all " , " answers " , " on " , " geeks " , " for " , " geeks " ]
    M = len ( sentence )
    checkPossibility ( sentence , M , root ) ;

Index/key variables: i
Iterator variables: i
Class/struct names: trieNode
Python program:
def isGreaterThanEqualTo ( s1 , s2 ) :
    if len ( s1 ) > len ( s2 ) :
        return True
    return s1 == s2
def multiply ( s1 , s2 ) :
    n , m = len ( s1 ) , len ( s2 )
    result = [ 0 ] * ( n + m )
    for i in range ( n - 1 , - 1 , - 1 ) :
        for j in range ( m - 1 , - 1 , - 1 ) :
            result [ i + j + 1 ] += ( int ( s1 [ i ] ) * int ( s2 [ j ] ) )
    size = len ( result )
    for i in range ( size - 1 , 0 , - 1 ) :
        if result [ i ] >= 10 :
            result [ i - 1 ] += result [ i ] // 10
            result [ i ] = result [ i ] % 10
    i = 0
    while i < size and result [ i ] == 0 :
        i += 1
    if i == size :
        return "0"
    temp = " "
    while i < size :
        temp += str ( result [ i ] )
        i += 1
    return temp
def removeLeadingZeores ( s ) :
    n , i = len ( s ) , 0
    while i < n and s [ i ] == '0' :
        i += 1
    if i == n :
        return "0"
    temp = " "
    while i < n :
        temp += s [ i ]
        i += 1
    return temp
def isPower ( s1 , s2 ) :
    s1 = removeLeadingZeores ( s1 )
    s2 = removeLeadingZeores ( s2 )
    if s1 == "0" or s2 == "0" :
        return False
    if s1 == "1" and s2 == "1" :
        return True
    if s1 == "1" and s2 == "1" :
        return True
    if len ( s1 ) > len ( s2 ) :
        return isPower ( s2 , s1 )
    temp = s1
    while not isGreaterThanEqualTo ( s1 , s2 ) :
        s1 = multiply ( s1 , temp )
    return s1 == s2
if __name__ == " _ _ main _ _ " :
    s1 , s2 = "374747" , "52627712618930723"
    if isPower ( s1 , s2 ) :
        print ( " YES " )
    else :
        print ( " NO " )
    s1 , s2 = "4099" , "2"
    if isPower ( s1 , s2 ) :
        print ( " YES " )
    else :
        print ( " NO " )

Index/key variables: i, j
Accumulator variables: temp
Iterator variables: i, j
Python program:
def matchClosing ( X , start , end , open , close ) :
    c = 1
    i = start + 1
    while ( i <= end ) :
        if ( X [ i ] == open ) :
            c += 1
        elif ( X [ i ] == close ) :
            c -= 1
        if ( c == 0 ) :
            return i
        i += 1
    return i
def matchingOpening ( X , start , end , open , close ) :
    c = - 1
    i = end - 1
    while ( i >= start ) :
        if ( X [ i ] == open ) :
            c += 1
        elif ( X [ i ] == close ) :
            c -= 1
        if ( c == 0 ) :
            return i
        i -= 1
    return - 1
def isBalanced ( X , n ) :
    for i in range ( n ) :
        if ( X [ i ] == ' ( ' ) :
            j = matchClosing ( X , i , n - 1 , ' ( ' , ' ) ' )
        elif ( X [ i ] == ' { ' ) :
            j = matchClosing ( X , i , n - 1 , ' { ' , ' } ' )
        elif ( X [ i ] == ' [ ' ) :
            j = matchClosing ( X , i , n - 1 , ' [ ' , ' ] ' )
        else :
            if ( X [ i ] == ' ) ' ) :
                j = matchingOpening ( X , 0 , i , ' ( ' , ' ) ' )
            elif ( X [ i ] == ' } ' ) :
                j = matchingOpening ( X , 0 , i , ' { ' , ' } ' )
            elif ( X [ i ] == ' ] ' ) :
                j = matchingOpening ( X , 0 , i , ' [ ' , ' ] ' )
            if ( j < 0 or j >= i ) :
                return False
            continue
        if ( j >= n or j < 0 ) :
            return False
        start = i
        end = j
        for k in range ( start + 1 , end ) :
            if ( X [ k ] == ' ( ' ) :
                x = matchClosing ( X , k , end , ' ( ' , ' ) ' )
                if ( not ( k < x and x < end ) ) :
                    return False
            elif ( X [ k ] == ' ) ' ) :
                x = matchingOpening ( X , start , k , ' ( ' , ' ) ' )
                if ( not ( start < x and x < k ) ) :
                    return False
            if ( X [ k ] == ' { ' ) :
                x = matchClosing ( X , k , end , ' { ' , ' } ' )
                if ( not ( k < x and x < end ) ) :
                    return False
            elif ( X [ k ] == ' } ' ) :
                x = matchingOpening ( X , start , k , ' { ' , ' } ' )
                if ( not ( start < x and x < k ) ) :
                    return False
            if ( X [ k ] == ' [ ' ) :
                x = matchClosing ( X , k , end , ' [ ' , ' ] ' )
                if ( not ( k < x and x < end ) ) :
                    return False
            elif ( X [ k ] == ' ] ' ) :
                x = matchingOpening ( X , start , k , ' [ ' , ' ] ' )
                if ( not ( start < x and x < k ) ) :
                    return False
    return True
if __name__ == " _ _ main _ _ " :
    X = " [ ( ) ] ( ) "
    n = 6
    if ( isBalanced ( X , n ) ) :
        print ( " Yes " )
    else :
        print ( " No " )
    Y = " [ [ ( ) ] ] ) "
    n = 7
    if ( isBalanced ( Y , n ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i, k
Accumulator variables: c
Iterator variables: i, k
Python program:
def possibleToSort ( arr , n , str ) :
    max_element = - 1
    for i in range ( len ( str ) ) :
        max_element = max ( max_element , arr [ i ] )
        if ( str [ i ] == '0' ) :
            if ( max_element > i + 1 ) :
                return " No "
    return " Yes "
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 5 , 3 , 4 , 6 ]
    n = len ( arr )
    str = "01110"
    print ( possibleToSort ( arr , n , str ) )

Index/key variables: i
Iterator variables: i
Python program:
def isPrimeString ( str1 ) :
    len1 = len ( str1 )
    n = 0
    for i in range ( len1 ) :
        n += ord ( str1 [ i ] )
    if n <= 1 :
        return False
    if n <= 3 :
        return True
    if n % 2 == 0 or n % 3 == 0 :
        return False
    while ( i * i <= n ) :
        if n % i == 0 or n % ( i + 2 ) == 0 :
            return False
        i += 6
    return True
str1 = " geekRam "
if ( isPrimeString ( str1 ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Accumulator variables: n
Iterator variables: i
Python program:
def countWays ( s ) :
    count = [ 0 ] * 26 ;
    for x in s :
        count [ ord ( x ) - ord ( ' a ' ) ] = ( count [ ord ( x ) - ord ( ' a ' ) ] ) + 1 ;
    count [ ord ( s [ 0 ] ) - ord ( ' a ' ) ] = 1 ;
    ans = 1 ;
    for i in range ( 26 ) :
        if ( count [ i ] != 0 ) :
            ans *= count [ i ] ;
    return ans ;
if __name__ == ' _ _ main _ _ ' :
    s = " acbbcc " ;
    print ( countWays ( s ) ) ;

Index/key variables: i
Accumulator variables: ans
Iterator variables: i, x
Python program:
def lexoString ( s , k ) :
    n = len ( s )
    v = [ ]
    mp = { s [ i ] : 0 for i in range ( len ( s ) ) }
    for i in range ( len ( s ) ) :
        if ( mp [ s [ i ] ] == 0 ) :
            mp [ s [ i ] ] = 1
            v . append ( s [ i ] )
    v . sort ( reverse = False )
    if ( k > n ) :
        print ( s , end = " " )
        for i in range ( n , k , 1 ) :
            print ( v [ 0 ] , end = " " )
        return ;
    i = k - 1
    while ( i >= 0 ) :
        if ( s [ i ] != v [ len ( v ) - 1 ] ) :
            for j in range ( 0 , i , 1 ) :
                print ( s [ j ] , end = " ▁ " )
            for j in range ( 0 , len ( v ) , 1 ) :
                if ( v [ j ] > s [ i ] ) :
                    print ( v [ j ] , end = " ▁ " )
                    break
            for j in range ( i + 1 , k , 1 ) :
                print ( v [ 0 ] , end = " ▁ " )
            re1turn
        i -= 1
    print ( " No ▁ lexicographically ▁ greater " , " string ▁ of ▁ length " , k , " possible ▁ here . " )
if __name__ == ' _ _ main _ _ ' :
    s = " gi "
    k = 3
    lexoString ( s , k )

Index/key variables: i, j
Accumulator variables: v
Iterator variables: i, j
Python program:
MAX = 256
def fact ( n ) :
    res = 1
    for i in range ( 2 , n + 1 ) :
        res = res * i
    return res
def countPalinPermutations ( str ) :
    global MAX
    n = len ( str )
    freq = [ 0 ] * MAX ;
    for i in range ( 0 , n ) :
        freq [ ord ( str [ i ] ) ] = freq [ ord ( str [ i ] ) ] + 1 ;
    res = fact ( int ( n / 2 ) )
    oddFreq = False
    for i in range ( 0 , MAX ) :
        half = int ( freq [ i ] / 2 )
        if ( freq [ i ] % 2 != 0 ) :
            if ( oddFreq == True ) :
                return 0
            oddFreq = True
        res = int ( res / fact ( half ) )
    return res
str = " gffg "
print ( countPalinPermutations ( str ) )

Index/key variables: i
Iterator variables: i
Boolean variables: oddFreq
Python program:
from collections import defaultdict
def getPalindrome ( st ) :
    hmap = defaultdict ( int )
    for i in range ( len ( st ) ) :
        hmap [ st [ i ] ] += 1
    oddCount = 0
    for x in hmap :
        if ( hmap [ x ] % 2 != 0 ) :
            oddCount += 1
            oddChar = x
    if ( oddCount > 1 or oddCount == 1 and len ( st ) % 2 == 0 ) :
        return " NO ▁ PALINDROME "
    firstHalf = " "
    secondHalf = " "
    for x in sorted ( hmap . keys ( ) ) :
        s = ( hmap [ x ] // 2 ) * x
        firstHalf = firstHalf + s
        secondHalf = s + secondHalf
    if ( oddCount == 1 ) :
        return ( firstHalf + oddChar + secondHalf )
    else :
        return ( firstHalf + secondHalf )
if __name__ == " _ _ main _ _ " :
    s = " mdaam "
    print ( getPalindrome ( s ) )

Index/key variables: i, x
Accumulator variables: oddCount
Iterator variables: i, x
Python program:
def checkPalindrome ( str ) :
    n = len ( str )
    count = 0
    for i in range ( 0 , int ( n / 2 ) ) :
        if ( str [ i ] != str [ n - i - 1 ] ) :
            count = count + 1
    if ( count <= 1 ) :
        return True
    else :
        return False
str = " abccaa "
if ( checkPalindrome ( str ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def findSubStringIndices ( s , L ) :
    size_word = len ( L [ 0 ] )
    word_count = len ( L )
    size_L = size_word * word_count
    res = [ ]
    if size_L > len ( s ) :
        return res
    hash_map = dict ( )
    for i in range ( word_count ) :
        if L [ i ] in hash_map :
            hash_map [ L [ i ] ] += 1
        else :
            hash_map [ L [ i ] ] = 1
    for i in range ( 0 , len ( s ) - size_L + 1 , 1 ) :
        temp_hash_map = hash_map . copy ( )
        j = i
        count = word_count
        while j < i + size_L :
            word = s [ j : j + size_word ]
            if ( word not in hash_map or temp_hash_map [ word ] == 0 ) :
                break
            else :
                temp_hash_map [ word ] -= 1
                count -= 1
            j += size_word
        if count == 0 :
            res . append ( i )
    return res
if __name__ == " _ _ main _ _ " :
    s = " barfoothefoobarman "
    L = [ " foo " , " bar " ]
    indices = findSubStringIndices ( s , L )
    print ( * indices )

Index/key variables: i, word
Accumulator variables: count, j, res
Iterator variables: i
Python program:
def canMakeStr2 ( s1 , s2 ) :
    count = { s1 [ i ] : 0 for i in range ( len ( s1 ) ) }
    for i in range ( len ( s1 ) ) :
        count [ s1 [ i ] ] += 1
    for i in range ( len ( s2 ) ) :
        if ( count . get ( s2 [ i ] ) == None or count [ s2 [ i ] ] == 0 ) :
            return False
        count [ s2 [ i ] ] -= 1
    return True
s1 = " geekforgeeks "
s2 = " for "
if canMakeStr2 ( s1 , s2 ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def maxbalancedprefix ( str , n ) :
    _sum = 0
    maxi = 0
    for i in range ( n ) :
        if str [ i ] == ' ( ' :
            _sum += 1
        else :
            _sum -= 1
        if _sum < 0 :
            break
        if _sum == 0 :
            maxi = i + 1
    return maxi
str = ' ( ( ( ) ( ) ) ( ) ) ( ( '
n = len ( str )
print ( maxbalancedprefix ( str , n ) )

Index/key variables: i
Accumulator variables: _sum
Iterator variables: i
Python program:
def cost ( st ) :
    l = len ( st )
    res = 0
    j = l - 1
    i = 0
    while ( i < j ) :
        if ( st [ i ] != st [ j ] ) :
            res += ( min ( ord ( st [ i ] ) , ord ( st [ j ] ) ) - ord ( ' a ' ) + 1 )
        i = i + 1
        j = j - 1
    return res
st = " abcdef " ;
print ( cost ( st ) )

Index/key variables: i, j
Accumulator variables: res
Python program:
def isVowel ( c ) :
    return ( c == ' A ' or c == ' E ' or c == ' I ' or c == ' O ' or c == ' U ' or c == ' a ' or c == ' e ' or c == ' i ' or c == ' o ' or c == ' u ' ) ;
def pigLatin ( s ) :
    length = len ( s ) ;
    index = - 1 ;
    for i in range ( length ) :
        if ( isVowel ( s [ i ] ) ) :
            index = i ;
            break ;
    if ( index == - 1 ) :
        return " - 1" ;
    return s [ index : ] + s [ 0 : index ] + " ay " ;
str = pigLatin ( " graphic " ) ;
if ( str == " - 1" ) :
    print ( " No ▁ vowels ▁ found . ▁ Pig ▁ Latin ▁ not ▁ possible " ) ;
else :
    print ( str ) ;

Index/key variables: i
Iterator variables: i
Python program:
MAX_CHAR = 256
def isPresent ( s , q ) :
    freq = [ 0 ] * MAX_CHAR
    for i in range ( 0 , len ( s ) ) :
        freq [ ord ( s [ i ] ) ] += 1
    for i in range ( 0 , len ( q ) ) :
        freq [ ord ( q [ i ] ) ] -= 1
        if ( freq [ ord ( q [ i ] ) ] < 0 ) :
            return False
    return True
s = " abctd "
q = " cat "
if ( isPresent ( s , q ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def countReduce ( str ) :
    n = len ( str )
    res = 0
    for i in range ( 0 , int ( n / 2 ) ) :
        res += abs ( int ( ord ( str [ i ] ) ) - int ( ord ( str [ n - i - 1 ] ) ) )
    return res
str = " abcd "
print ( countReduce ( str ) )

Index/key variables: i
Accumulator variables: res
Iterator variables: i
Python program:
def calculate ( s ) :
    ans = 6
    for i in range ( 10 ) :
        for j in range ( 10 ) :
            for k in range ( 10 ) :
                for l in range ( 10 ) :
                    for m in range ( 10 ) :
                        for n in range ( 10 ) :
                            if ( i + j + k == l + m + n ) :
                                c = 0
                                if ( i != ord ( s [ 0 ] ) - ord ( '0' ) ) :
                                    c += 1
                                if ( j != ord ( s [ 1 ] ) - ord ( '0' ) ) :
                                    c += 1
                                if ( k != ord ( s [ 2 ] ) - ord ( '0' ) ) :
                                    c += 1
                                if ( l != ord ( s [ 3 ] ) - ord ( '0' ) ) :
                                    c += 1
                                if ( m != ord ( s [ 4 ] ) - ord ( '0' ) ) :
                                    c += 1
                                if ( n != ord ( s [ 5 ] ) - ord ( '0' ) ) :
                                    c += 1
                                if ( c < ans ) :
                                    ans = c
    return ans
if __name__ == " _ _ main _ _ " :
    s = "123456"
    print ( calculate ( s ) )

Accumulator variables: c
Iterator variables: i, j, k, l, m, n