dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def LexicoLesserStrings ( s ) :
    count = 0
    length = len ( s )
    for i in range ( length ) :
        count += ( ( ord ( s [ i ] ) - ord ( ' a ' ) ) * pow ( 26 , length - i - 1 ) )
    return count
def countString ( S1 , S2 ) :
    countS1 = LexicoLesserStrings ( S1 )
    countS2 = LexicoLesserStrings ( S2 )
    totalString = countS2 - countS1 - 1 ;
    return ( 0 if totalString < 0 else totalString )
S1 = " cda " ;
S2 = " cef " ;
print ( countString ( S1 , S2 ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def isVowel ( x ) :
    return ( x == ' a ' or x == ' e ' or x == ' i ' or x == ' o ' or x == ' u ' )
def longestVowelSubsequence ( str ) :
    answer = " "
    n = len ( str )
    for i in range ( n ) :
        if ( isVowel ( str [ i ] ) ) :
            answer += str [ i ]
    return answer
str = " geeksforgeeks "
print ( longestVowelSubsequence ( str ) )

Index/key variables: i
Accumulator variables: answer
Iterator variables: i
Python program:
def findMaxFrequency ( s ) :
    arr = [ 0 ] * 26
    for i in range ( len ( s ) ) :
        arr [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
    hash = { }
    for i in range ( 26 ) :
        if ( arr [ i ] != 0 ) :
            if arr [ i ] not in hash :
                hash [ arr [ i ] ] = 0
            hash [ arr [ i ] ] += 1
    max_count = 0
    res = - 1
    for i in hash :
        if ( max_count < hash [ i ] ) :
            res = i
            max_count = hash [ i ]
    print ( " Frequency " , res , " is ▁ repeated " , max_count , " times " )
s = " geeksgeeks "
findMaxFrequency ( s )

Index/key variables: i
Iterator variables: i
Python program:
def findString ( A , B ) :
    dist = 0 ;
    for i in range ( len ( A ) ) :
        if ( A [ i ] != B [ i ] ) :
            dist += 1 ;
    if ( dist & 1 ) :
        print ( " Not ▁ Possible " ) ;
    else :
        res = " " ;
        K = dist // 2 ;
        for i in range ( len ( A ) ) :
            if ( A [ i ] != B [ i ] and K > 0 ) :
                res += B [ i ] ;
                K -= 1 ;
            elif ( A [ i ] != B [ i ] ) :
                res += A [ i ] ;
            else :
                res += A [ i ] ;
        print ( res ) ;
if __name__ == " _ _ main _ _ " :
    A = "1001010" ;
    B = "0101010" ;
    findString ( A , B ) ;

Index/key variables: i
Accumulator variables: K, dist, res
Iterator variables: i
Python program:
def maximumSuffix ( s , n , k ) :
    i = len ( s ) - 1
    arr = [ 0 for i in range ( 26 ) ]
    suffix = " "
    while ( i > - 1 ) :
        index = ord ( s [ i ] ) - ord ( ' a ' ) ;
        if ( arr [ index ] < n ) :
            arr [ index ] += 1
            suffix += s [ i ]
            i -= 1
            continue
        if ( k == 0 ) :
            break
        k -= 1
        i -= 1
    suffix = suffix [ : : - 1 ]
    print ( suffix )
if __name__ == ' _ _ main _ _ ' :
    str = " iahagafedcba "
    n = 1
    k = 2
    maximumSuffix ( str , n , k )

Index/key variables: i, index
Accumulator variables: k, suffix
Python program:
def xor ( a , b , n ) :
    ans = " "
    for i in range ( n ) :
        if ( a [ i ] == b [ i ] ) :
            ans += "0"
        else :
            ans += "1"
    return ans
if __name__ == " _ _ main _ _ " :
    a = "1010"
    b = "1101"
    n = len ( a )
    c = xor ( a , b , n )
    print ( c )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def kthString ( n , k ) :
    total = 0
    i = 1
    while ( total < k ) :
        total = total + n - i
        i += 1
    first_y_position = i - 1
    second_y_position = k - ( total - n + first_y_position )
    for j in range ( 1 , first_y_position , 1 ) :
        print ( " x " , end = " " )
    print ( " y " , end = " " )
    j = first_y_position + 1
    while ( second_y_position > 1 ) :
        print ( " x " , end = " " )
        second_y_position -= 1
        j += 1
    print ( " y " , end = " " )
    while ( j < n ) :
        print ( " x " )
        j += 1
if __name__ == ' _ _ main _ _ ' :
    n = 5
    k = 7
    kthString ( n , k )

Accumulator variables: i, second_y_position
Iterator variables: j
Python program:
def findLargest ( N ) :
    largest = strings ( N , '7' ) ;
    return largest ;
def findSmallest ( N ) :
    smallest = "1" + strings ( ( N - 1 ) , '0' ) ;
    return smallest ;
def strings ( N , c ) :
    temp = " " ;
    for i in range ( N ) :
        temp += c ;
    return temp ;
def printLargestSmallest ( N ) :
    print ( " Largest : ▁ " , findLargest ( N ) ) ;
    print ( " Smallest : ▁ " , findSmallest ( N ) ) ;
if __name__ == ' _ _ main _ _ ' :
    N = 4 ;
    printLargestSmallest ( N ) ;

Accumulator variables: temp
Iterator variables: i
Python program:
def countSubstr ( s , k ) :
    n = len ( s )
    l = n - 1
    r = n - 1
    arr = [ 0 ] * n
    last_indexof1 = - 1
    for i in range ( n ) :
        if ( s [ i ] == '1' ) :
            arr [ i ] = i
            last_indexof1 = i
        else :
            arr [ i ] = last_indexof1
    no_of_substr = 0
    for r in range ( n - 1 , - 1 , - 1 ) :
        l = r
        while ( l >= 0 and ( r - l + 1 ) <= 64 and int ( s [ l : r + 1 ] , 2 ) < k ) :
            l -= 1
        if ( r - l + 1 <= 64 ) :
            no_of_substr += l + 1
        else :
            no_of_substr += arr [ l + 1 ] + 1
    return no_of_substr
s = "11100"
k = 3
print ( countSubstr ( s , k ) )

Index/key variables: i
Accumulator variables: l, no_of_substr
Iterator variables: i, r
Python program:
from math import ceil
def isPerfectCubeString ( str1 ) :
    sum = 0
    for i in range ( len ( str1 ) ) :
        sum += ord ( str1 [ i ] )
    cr = ceil ( ( sum ) ** ( 1 / 3 ) )
    return ( cr * cr * cr == sum )
str1 = " ll "
if ( isPerfectCubeString ( str1 ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def XorAscii ( str1 , len1 ) :
    ans = ord ( str1 [ 0 ] )
    for i in range ( 1 , len1 ) :
        ans = ( ans ^ ( ord ( str1 [ i ] ) ) )
    return ans
str1 = " geeksforgeeks "
len1 = len ( str1 )
print ( XorAscii ( str1 , len1 ) )
str1 = " GfG "
len1 = len ( str1 )
print ( XorAscii ( str1 , len1 ) )

Index/key variables: i
Iterator variables: i
Python program:
from math import ceil , floor , sqrt
def encryption ( s ) :
    l = len ( s )
    b = ceil ( sqrt ( l ) )
    a = floor ( sqrt ( l ) )
    encrypted = " "
    if ( b * a < l ) :
        if ( min ( b , a ) == b ) :
            b = b + 1
        else :
            a = a + 1
    arr = [ [ ' ▁ ' for i in range ( a ) ] for j in range ( b ) ]
    k = 0
    for j in range ( a ) :
        for i in range ( b ) :
            if ( k < l ) :
                arr [ j ] [ i ] = s [ k ]
            k += 1
    for j in range ( b ) :
        for i in range ( a ) :
            encrypted = encrypted + arr [ i ] [ j ]
    return encrypted
def decryption ( s ) :
    l = len ( s )
    b = ceil ( sqrt ( l ) )
    a = floor ( sqrt ( l ) )
    decrypted = " "
    arr = [ [ ' ▁ ' for i in range ( a ) ] for j in range ( b ) ]
    k = 0
    for j in range ( b ) :
        for i in range ( a ) :
            if ( k < l ) :
                arr [ j ] [ i ] = s [ k ]
            k += 1
    for j in range ( a ) :
        for i in range ( b ) :
            decrypted = decrypted + arr [ i ] [ j ]
    return decrypted
s = " Geeks ▁ For ▁ Geeks "
encrypted = " "
decrypted = " "
encrypted = encryption ( s )
print ( encrypted )
decrypted = decryption ( encrypted )
print ( decrypted )

Index/key variables: i, j, k
Iterator variables: i, j
Python program:
def checkIfAllVowels ( string ) :
    hash = [ 0 ] * 5 ;
    for i in range ( len ( string ) ) :
        if ( string [ i ] == ' A ' or string [ i ] == ' a ' ) :
            hash [ 0 ] = 1 ;
        elif ( string [ i ] == ' E ' or string [ i ] == ' e ' ) :
            hash [ 1 ] = 1 ;
        elif ( string [ i ] == ' I ' or string [ i ] == ' i ' ) :
            hash [ 2 ] = 1 ;
        elif ( string [ i ] == ' O ' or string [ i ] == ' o ' ) :
            hash [ 3 ] = 1 ;
        elif ( string [ i ] == ' U ' or string [ i ] == ' u ' ) :
            hash [ 4 ] = 1 ;
    for i in range ( 5 ) :
        if ( hash [ i ] == 0 ) :
            return 1 ;
    return 0 ;
def checkIfAllVowelsArePresent ( string ) :
    if ( checkIfAllVowels ( string ) ) :
        print ( " Not ▁ Accepted " ) ;
    else :
        print ( " Accepted " ) ;
if __name__ == " _ _ main _ _ " :
    string = " aeioubc " ;
    checkIfAllVowelsArePresent ( string ) ;

Index/key variables: i
Iterator variables: i
Python program:
def smallest ( s ) :
    a = list ( s )
    b = [ ]
    for i in range ( len ( a ) ) :
        if ( int ( a [ i ] ) % 2 != 0 ) :
            b . append ( a [ i ] )
    b = sorted ( b )
    if ( len ( b ) > 1 ) :
        return int ( b [ 0 ] ) * 10 + int ( b [ 1 ] )
    return - 1
if __name__ == " _ _ main _ _ " :
    print ( smallest ( "15470" ) )

Index/key variables: i
Accumulator variables: b
Iterator variables: i
Python program:
def converthenumber ( n ) :
    s = str ( n ) ;
    res = " " ;
    for i in range ( len ( s ) ) :
        if ( s [ i ] == '1' or s [ i ] == '3' or s [ i ] == '5' or s [ i ] == '7' or s [ i ] == '9' ) :
            res += s [ i ] ;
        if ( len ( res ) == 2 ) :
            break ;
    if ( len ( res ) == 2 ) :
        print ( res ) ;
    else :
        print ( " - 1" ) ;
if __name__ == " _ _ main _ _ " :
    n = 18720 ;
    converthenumber ( n ) ;

Index/key variables: i
Accumulator variables: res
Iterator variables: i
Python program:
def longestPalindrome ( a , n ) :
    pair1 = [ 0 ] * n
    pair2 = [ 0 ] * n
    r = 0
    for i in range ( n ) :
        s = a [ i ]
        s = s [ : : - 1 ]
        for j in range ( i + 1 , n ) :
            if ( a [ i ] != " " and a [ j ] != " " ) :
                if ( s == a [ j ] ) :
                    pair1 [ r ] = a [ i ]
                    pair2 [ r ] = a [ j ]
                    r += 1
                    a [ i ] = " "
                    a [ j ] = " "
                    break
    s1 = " "
    for i in range ( n ) :
        s = a [ i ]
        a [ i ] = a [ i ] [ : : - 1 ]
        if ( a [ i ] != " " ) :
            if ( a [ i ] == s ) :
                s1 = a [ i ]
                break
    ans = " "
    for i in range ( r ) :
        ans = ans + pair1 [ i ]
    if ( s1 != " " ) :
        ans = ans + s1
    for j in range ( r - 1 , - 1 , - 1 ) :
        ans = ans + pair2 [ j ]
    print ( ans )
a1 = [ " aba " , " aba " ]
n1 = len ( a1 )
longestPalindrome ( a1 , n1 )
a2 = [ " abc " , " dba " , " kop " , " abd " , " cba " ]
n2 = len ( a2 )
longestPalindrome ( a2 , n2 )

Index/key variables: i, j, r
Iterator variables: i, j
Python program:
def printValue ( digit ) :
    if digit == '0' :
        print ( " Zero ▁ " , end = " ▁ " )
    elif digit == '1' :
        print ( " One ▁ " , end = " ▁ " )
    elif digit == '2' :
        print ( " Two ▁ " , end = " ▁ " )
    elif digit == '3' :
        print ( " Three " , end = " ▁ " )
    elif digit == '4' :
        print ( " Four ▁ " , end = " ▁ " )
    elif digit == '5' :
        print ( " Five ▁ " , end = " ▁ " )
    elif digit == '6' :
        print ( " Six ▁ " , end = " ▁ " )
    elif digit == '7' :
        print ( " Seven " , end = " ▁ " )
    elif digit == '8' :
        print ( " Eight " , end = " ▁ " )
    elif digit == '9' :
        print ( " Nine ▁ " , end = " ▁ " )
def printWord ( N ) :
    i = 0
    length = len ( N )
    while i < length :
        printValue ( N [ i ] )
        i += 1
N = "123"
printWord ( N )

Index/key variables: i
Python program:
from math import floor , ceil
def jaro_distance ( s1 , s2 ) :
    if ( s1 == s2 ) :
        return 1.0
    len1 = len ( s1 )
    len2 = len ( s2 )
    max_dist = floor ( max ( len1 , len2 ) / 2 ) - 1
    match = 0
    hash_s1 = [ 0 ] * len ( s1 )
    hash_s2 = [ 0 ] * len ( s2 )
    for i in range ( len1 ) :
        for j in range ( max ( 0 , i - max_dist ) , min ( len2 , i + max_dist + 1 ) ) :
            if ( s1 [ i ] == s2 [ j ] and hash_s2 [ j ] == 0 ) :
                hash_s1 [ i ] = 1
                hash_s2 [ j ] = 1
                match += 1
                break
    if ( match == 0 ) :
        return 0.0
    t = 0
    point = 0
    for i in range ( len1 ) :
        if ( hash_s1 [ i ] ) :
            while ( hash_s2 [ point ] == 0 ) :
                point += 1
            if ( s1 [ i ] != s2 [ point ] ) :
                point += 1
                t += 1
    t = t // 2
    return ( match / len1 + match / len2 + ( match - t + 1 ) / match ) / 3.0
s1 = " CRATE "
s2 = " TRACE "
print ( round ( jaro_distance ( s1 , s2 ) , 6 ) )

Index/key variables: i, j, point
Accumulator variables: match, t
Iterator variables: i, j
Python program:
def replaceRemove ( s , X , Y , Z ) :
    s = list ( s ) ;
    start = 0 ;
    end = len ( s ) - 1 ;
    while ( start <= end ) :
        if ( s [ start ] == Z ) :
            while ( end >= 0 and s [ end ] == Z ) :
                end -= 1 ;
            if ( end > start ) :
                s [ start ] , s [ end ] = s [ end ] , s [ start ]
                if ( s [ start ] == X ) :
                    s [ start ] = Y ;
                start += 1
        else :
            if ( s [ start ] == X ) :
                s [ start ] = Y ;
            start += 1 ;
    while ( len ( s ) > 0 and s [ len ( s ) - 1 ] == Z ) :
        s . pop ( ) ;
    return " " . join ( s )
if __name__ == " _ _ main _ _ " :
    string = " batman " ;
    X = ' a ' ; Y = ' d ' ; Z = ' b ' ;
    string = replaceRemove ( string , X , Y , Z ) ;
    if ( len ( string ) == 0 ) :
        print ( - 1 ) ;
    else :
        print ( string ) ;

Index/key variables: end, start
Python program:
def canMake ( s ) :
    o = 0 ; z = 0 ;
    for i in range ( len ( s ) ) :
        if ( ord ( s [ i ] ) - ord ( '0' ) == 1 ) :
            o += 1 ;
        else :
            z += 1 ;
    if ( o % 2 == 1 and z % 2 == 1 ) :
        return " NO " ;
    else :
        return " YES " ;
if __name__ == " _ _ main _ _ " :
    s = "01011" ;
    print ( canMake ( s ) ) ;

Index/key variables: i
Accumulator variables: o, z
Iterator variables: i
Python program:
count = 0
def countNumberOfStringsUtil ( freq , Count ) :
    global count
    count = Count
    for i in range ( 26 ) :
        if ( freq [ i ] > 0 ) :
            freq [ i ] -= 1
            count += 1
            countNumberOfStringsUtil ( freq , count ) ;
            freq [ i ] += 1
def countNumberOfStrings ( s ) :
    global count
    global freq
    freq = [ 0 for i in range ( 26 ) ]
    for i in range ( len ( s ) ) :
        freq [ ord ( s [ i ] ) - ord ( ' A ' ) ] += 1
    countNumberOfStringsUtil ( freq , count ) ;
    return count
s = " AAABBC "
print ( countNumberOfStrings ( s ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def findMinSwaps ( s , k ) :
    ans = 0 ;
    c_one = 0 ; c_zero = 0 ;
    for i in range ( len ( s ) - 1 , - 1 , - 1 ) :
        if ( s [ i ] == '1' ) :
            c_one += 1 ;
        if ( s [ i ] == '0' ) :
            c_zero += 1 ;
            ans += c_one ;
        if ( c_zero == k ) :
            break ;
    if ( c_zero < k ) :
        return - 1 ;
    return ans ;
if __name__ == " _ _ main _ _ " :
    s = "100111" ;
    k = 2 ;
    print ( findMinSwaps ( s , k ) ) ;

Index/key variables: i
Accumulator variables: ans, c_one, c_zero
Iterator variables: i
Python program:
class Node :
    def __init__ ( self , _val ) :
        self . data = _val
        self . left = self . right = None
def addinBT ( root , data ) :
    if ( root == None ) :
        root = Node ( data )
    else :
        Q = [ ]
        Q . append ( root )
        while ( len ( Q ) > 0 ) :
            temp = Q [ - 1 ]
            Q . pop ( )
            if ( temp . left == None ) :
                temp . left = Node ( data )
                break
            else :
                Q . append ( temp . left )
            if ( temp . right == None ) :
                temp . right = Node ( data )
                break
            else :
                Q . append ( temp . right )
    return root
def print_ ( root ) :
    Q = [ ]
    Q . append ( root )
    while ( len ( Q ) > 0 ) :
        temp = Q [ - 1 ]
        Q . pop ( )
        print ( temp . data , end = " ▁ " )
        if ( temp . left != None ) :
            Q . append ( temp . left )
        if ( temp . right != None ) :
            Q . append ( temp . right )
def checkvowel ( ch ) :
    ch = ch . lower ( )
    if ( ch == ' a ' or ch == ' e ' or ch == ' i ' or ch == ' o ' or ch == ' u ' ) :
        return True
    else :
        return False
def removevowels ( root ) :
    Q = [ ]
    Q . append ( root )
    root1 = None
    while ( len ( Q ) > 0 ) :
        temp = Q [ - 1 ]
        Q . pop ( )
        if ( not checkvowel ( temp . data ) ) :
            root1 = addinBT ( root1 , temp . data )
        if ( temp . left != None ) :
            Q . append ( temp . left )
        if ( temp . right != None ) :
            Q . append ( temp . right )
    return root1
s = " geeks "
root = None
for i in range ( len ( s ) ) :
    root = addinBT ( root , s [ i ] )
root = removevowels ( root )
print_ ( root )

Index/key variables: i
Accumulator variables: Q
Iterator variables: i
Class/struct names: Node
Python program:
def countSubStr ( strr , lenn ) :
    ans = 0
    for i in range ( lenn ) :
        if ( strr [ i ] == '0' ) :
            ans += ( i + 1 )
    return ans
strr = "10010"
lenn = len ( strr )
print ( countSubStr ( strr , lenn ) )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def findLength ( s , k ) :
    ans = 10 ** 9
    l = 0
    r = 0
    cnt_zero = 0
    cnt_one = 0
    while ( l < len ( s ) and r <= len ( s ) ) :
        if ( cnt_zero >= k and cnt_one >= 1 ) :
            ans = min ( ans , r - l )
            l += 1
            if ( s [ l - 1 ] == '0' ) :
                cnt_zero -= 1
            else :
                cnt_one -= 1
        else :
            if ( r == len ( s ) ) :
                break
            if ( s [ r ] == '0' ) :
                cnt_zero += 1
            else :
                cnt_one += 1
            r += 1
    if ( ans == 10 ** 9 ) :
        return - 1
    return ans
s = "100"
k = 2
print ( findLength ( s , k ) )

Index/key variables: r
Accumulator variables: cnt_one, cnt_zero, l
Python program:
MAX = 26
def areEqual ( a , b ) :
    for i in range ( MAX ) :
        if ( a [ i ] != b [ i ] ) :
            return False
    return True
def xExistsInY ( x , y ) :
    if ( len ( x ) > len ( y ) ) :
        return False
    cnt_x = [ 0 ] * MAX
    cnt = [ 0 ] * MAX
    for i in range ( len ( x ) ) :
        cnt_x [ ord ( x [ i ] ) - ord ( ' a ' ) ] += 1 ;
    for i in range ( len ( x ) ) :
        cnt [ ord ( y [ i ] ) - ord ( ' a ' ) ] += 1
    if ( areEqual ( cnt_x , cnt ) ) :
        return True
    for i in range ( 1 , len ( y ) - len ( x ) + 1 ) :
        cnt [ ord ( y [ i - 1 ] ) - ord ( ' a ' ) ] -= 1
        cnt [ ord ( y [ i + len ( x ) - 1 ] ) - ord ( ' a ' ) ] += 1
        if ( areEqual ( cnt , cnt_x ) ) :
            return True
    return False
if __name__ == ' _ _ main _ _ ' :
    x = " skege "
    y = " geeksforgeeks "
    if ( xExistsInY ( x , y ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def reverseParentheses ( strr , lenn ) :
    st = [ ]
    for i in range ( lenn ) :
        if ( strr [ i ] == ' ( ' ) :
            st . append ( i )
        elif ( strr [ i ] == ' ) ' ) :
            temp = strr [ st [ - 1 ] : i + 1 ]
            strr = strr [ : st [ - 1 ] ] + temp [ : : - 1 ] + strr [ i + 1 : ]
            del st [ - 1 ]
    res = " "
    for i in range ( lenn ) :
        if ( strr [ i ] != ' ) ' and strr [ i ] != ' ( ' ) :
            res += ( strr [ i ] )
    return res
if __name__ == ' _ _ main _ _ ' :
    strr = " ( skeeg ( for ) skeeg ) "
    lenn = len ( strr )
    st = [ i for i in strr ]
    print ( reverseParentheses ( strr , lenn ) )

Index/key variables: i
Accumulator variables: res, st
Iterator variables: i
Python program:
MAX = 26
def updateFreq ( strr , freq ) :
    lenn = len ( strr )
    for i in range ( lenn ) :
        freq [ ord ( strr [ i ] ) - ord ( ' a ' ) ] += 1
def maxCount ( strr , patt ) :
    strrFreq = [ 0 for i in range ( MAX ) ]
    updateFreq ( strr , strrFreq )
    pattFreq = [ 0 for i in range ( MAX ) ]
    updateFreq ( patt , pattFreq )
    ans = 10 ** 9
    for i in range ( MAX ) :
        if ( pattFreq [ i ] == 0 ) :
            continue
        ans = min ( ans , strrFreq [ i ] // pattFreq [ i ] )
    return ans
strr = " geeksforgeeks "
patt = " geeks "
print ( maxCount ( strr , patt ) )

Index/key variables: i
Iterator variables: i
Python program:
import sys
TEN = 10
def minNum ( str , len1 ) :
    res = sys . maxsize
    for i in range ( len1 ) :
        if ( str [ i ] == '4' or str [ i ] == '8' ) :
            res = min ( res , ord ( str [ i ] ) - ord ( '0' ) )
    for i in range ( len1 - 1 ) :
        for j in range ( i + 1 , len1 , 1 ) :
            num = ( ord ( str [ i ] ) - ord ( '0' ) ) * TEN + ( ord ( str [ j ] ) - ord ( '0' ) )
            if ( num % 4 == 0 ) :
                res = min ( res , num )
    if ( res == sys . maxsize ) :
        return - 1
    else :
        return res
if __name__ == ' _ _ main _ _ ' :
    str = "17"
    len1 = len ( str )
    print ( minNum ( str , len1 ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def canBeEqual ( a , b , n ) :
    A = [ ]
    B = [ ]
    for i in range ( n ) :
        if a [ i ] != b [ i ] :
            A . append ( a [ i ] )
            B . append ( b [ i ] )
    if len ( A ) == len ( B ) == 0 :
        return True
    if len ( A ) == len ( B ) == 2 :
        if A [ 0 ] == A [ 1 ] and B [ 0 ] == B [ 1 ] :
            return True
    return False
A = ' SEEKSFORGEEKS '
B = ' GEEKSFORGEEKG '
if ( canBeEqual ( A , B , len ( A ) ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Accumulator variables: A, B
Iterator variables: i
Python program:
def findMidAlphabet ( s1 , s2 , n ) :
    for i in range ( n ) :
        mid = ( ord ( s1 [ i ] ) + ord ( s2 [ i ] ) ) // 2
        print ( chr ( mid ) , end = " " )
s1 = " akzbqzgw "
s2 = " efhctcsz "
n = len ( s1 )
findMidAlphabet ( s1 , s2 , n )

Index/key variables: i
Iterator variables: i
Python program:
N = 2
def isVowel ( ch ) :
    return ( ch == ' a ' or ch == ' e ' or ch == ' i ' or ch == ' o ' or ch == ' u ' )
def performQueries ( str1 , len1 , queries , q ) :
    pre = [ 0 for i in range ( len1 ) ]
    if ( isVowel ( str1 [ 0 ] ) ) :
        pre [ 0 ] = 1
    else :
        pre [ 0 ] = 0
    for i in range ( 0 , len1 , 1 ) :
        if ( isVowel ( str1 [ i ] ) ) :
            pre [ i ] = 1 + pre [ i - 1 ]
        else :
            pre [ i ] = pre [ i - 1 ]
    for i in range ( q ) :
        if ( queries [ i ] [ 0 ] == 0 ) :
            print ( pre [ queries [ i ] [ 1 ] ] )
        else :
            print ( pre [ queries [ i ] [ 1 ] ] - pre [ queries [ i ] [ 0 ] - 1 ] )
if __name__ == ' _ _ main _ _ ' :
    str1 = " geeksforgeeks "
    len1 = len ( str1 )
    queries = [ [ 1 , 3 ] , [ 2 , 4 ] , [ 1 , 9 ] ]
    q = len ( queries )
    performQueries ( str1 , len1 , queries , q )

Index/key variables: i
Iterator variables: i
Python program:
def sumDigits ( n ) :
    sum = 0 ;
    while ( n > 0 ) :
        digit = n % 10 ;
        sum += digit ;
        n //= 10 ;
    return sum ;
def isDivBySix ( string , n ) :
    sum = 0 ;
    for i in range ( n ) :
        sum += ( ord ( string [ i ] ) - ord ( ' a ' ) + 1 ) ;
    if ( sum % 3 != 0 ) :
        return False ;
    lastDigit = ( ord ( string [ n - 1 ] ) - ord ( ' a ' ) + 1 ) % 10 ;
    if ( lastDigit % 2 != 0 ) :
        return False ;
    return True ;
if __name__ == " _ _ main _ _ " :
    string = " ab " ;
    n = len ( string ) ;
    if ( isDivBySix ( string , n ) ) :
        print ( " Yes " ) ;
    else :
        print ( " No " ) ;

Index/key variables: i
Accumulator variables: n, sum
Iterator variables: i