dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def restore ( arr , N ) :
    result = [ ]
    mp = { }
    for i in range ( N ) :
        if not arr [ i ] in mp :
            result . append ( arr [ i ] )
            mp [ arr [ i ] ] = 1
    return result
def print_result ( result ) :
    for i in range ( len ( result ) ) :
        print ( result [ i ] , end = " ▁ " )
def main ( ) :
    arr = [ 1 , 13 , 1 , 24 , 13 , 24 , 2 , 2 ]
    N = len ( arr )
    print_result ( restore ( arr , N ) )
main ( )

Index/key variables: i
Accumulator variables: result
Iterator variables: i
Python program:
def restore ( arr , N ) :
    result = [ ]
    count1 = 1
    s = set ( [ ] )
    for i in range ( N ) :
        s . add ( arr [ i ] )
        if ( len ( s ) == count1 ) :
            result . append ( arr [ i ] )
            count1 += 1
    return result
def print_result ( result ) :
    for i in range ( len ( result ) ) :
        print ( result [ i ] , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 13 , 1 , 24 , 13 , 24 , 2 , 2 ]
    N = len ( arr )
    print_result ( restore ( arr , N ) )

Index/key variables: i
Accumulator variables: count1, result, s
Iterator variables: i
Python program:
def sum ( n ) :
    return n * ( n - 1 ) // 2
def BSpattern ( N ) :
    Val = 0
    Pthree = 0 ,
    cnt = 0
    initial = - 1
    s = " * * "
    for i in range ( N ) :
        cnt = 0
        if ( i > 0 ) :
            print ( s , end = " " )
            s += " * * "
        for j in range ( i , N ) :
            if ( i > 0 ) :
                cnt += 1
            Val += 1
            print ( Val , end = " " )
            print ( 0 , end = " " )
        if ( i == 0 ) :
            Sumbeforelast = sum ( Val ) * 2
            Pthree = Val + Sumbeforelast + 1
            initial = Pthree
        initial = initial - cnt
        Pthree = initial
        for k in range ( i , N ) :
            print ( Pthree , end = " " )
            Pthree += 1
            if ( k != N - 1 ) :
                print ( 0 , end = " " )
        print ( )
N = 5
BSpattern ( N )

Accumulator variables: Pthree, Val, cnt, s
Iterator variables: i, j, k
Python program:
def checkprefix ( A , B ) :
    s1 = str ( A )
    s2 = str ( B )
    n1 = len ( s1 )
    n2 = len ( s2 )
    if n1 < n2 :
        return False
    for i in range ( 0 , n2 ) :
        if s1 [ i ] != s2 [ i ] :
            return False
    return True
if __name__ == ' _ _ main _ _ ' :
    A = 12345
    B = 12
    result = checkprefix ( A , B )
    if result :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
import math
a = [ 0 ] * 65
def Count ( i ) :
    if ( i == 0 ) :
        return 1
    elif ( i < 0 ) :
        return 0
    if ( a [ i ] == 0 ) :
        a [ i ] = ( i + 1 ) + 2 * Count ( i - 1 )
        return a [ i ]
    else :
        return a [ i ]
def solve ( n ) :
    sum = 0
    while ( n > 0 ) :
        i = int ( math . log2 ( n ) )
        n = n - pow ( 2 , i )
        sum = sum + ( i + 1 ) + Count ( i - 1 )
    return sum
n = 7
print ( solve ( n ) )

Index/key variables: i
Python program:
def findPalindrome ( C ) :
    S = C [ : : - 1 ]
    C = C [ : ] + ' & ' + S
    n = len ( C )
    longestPalindrome = [ 0 for i in range ( n ) ]
    longestPalindrome [ 0 ] = 0
    ll = 0
    i = 1
    while ( i < n ) :
        if ( C [ i ] == C [ ll ] ) :
            ll += 1
            longestPalindrome [ i ] = ll
            i += 1
        else :
            if ( ll != 0 ) :
                ll = longestPalindrome [ ll - 1 ]
            else :
                longestPalindrome [ i ] = 0
                i += 1
    ans = C [ 0 : longestPalindrome [ n - 1 ] ]
    return ans
def findAns ( s ) :
    A = " "
    B = " "
    F = " "
    i = 0
    j = len ( s ) - 1
    ll = len ( s )
    while ( i < j and s [ i ] == s [ j ] ) :
        i = i + 1
        j = j - 1
    if ( i > 0 ) :
        A = s [ 0 : i ]
        B = s [ ll - i : ll ]
    if ( ll > 2 * i ) :
        C = s [ i : i + ( len ( s ) - 2 * i ) ]
        D = findPalindrome ( C )
        C = C [ : : - 1 ]
        E = findPalindrome ( C )
        if ( len ( D ) > len ( E ) ) :
            F = D
        else :
            F = E
    answer = A + F + B
    return answer
if __name__ == " _ _ main _ _ " :
    str = " abcdefghiedcba "
    print ( findAns ( str ) )

Index/key variables: i, j, ll
Python program:
def nthTerm ( N ) :
    nth = 0 ; first_term = 4 ;
    pi = 1 ; po = 1 ;
    n = N ;
    while ( n > 1 ) :
        pi *= n - 1 ;
        n -= 1 ;
        po *= 2 ;
    nth = ( first_term * pi ) // po ;
    return nth ;
if __name__ == " _ _ main _ _ " :
    N = 5 ;
    print ( nthTerm ( N ) ) ;

Accumulator variables: n, pi, po
Python program:
from math import gcd as __gcd
def finalNum ( arr , n ) :
    result = arr [ 0 ]
    for i in arr :
        result = __gcd ( result , i )
    return result
arr = [ 3 , 9 , 6 , 36 ]
n = len ( arr )
print ( finalNum ( arr , n ) )

Iterator variables: i
Python program:
def isVowel ( ch ) :
    if ch in [ ' i ' , ' a ' , ' e ' , ' o ' , ' u ' ] :
        return True
    else :
        return False
def isSatisfied ( st , n ) :
    for i in range ( 1 , n ) :
        if ( isVowel ( st [ i ] ) == False and isVowel ( st [ i - 1 ] ) == False ) :
            return False
    for i in range ( 1 , n - 1 ) :
        if ( isVowel ( st [ i ] ) and isVowel ( st [ i - 1 ] ) == False and isVowel ( st [ i + 1 ] ) == False ) :
            return False
    return True
st = " acaba "
n = len ( st )
if ( isSatisfied ( st , n ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def LengthlongestPrefixSuffix ( s ) :
    n = len ( s )
    lps = [ 0 for i in range ( n ) ]
    len1 = 0
    i = 1
    while ( i < n ) :
        if ( s [ i ] == s [ len1 ] ) :
            len1 += 1
            lps [ i ] = len1
            i += 1
        else :
            if ( len1 != 0 ) :
                len1 = lps [ len1 - 1 ]
            else :
                lps [ i ] = 0
                i += 1
    res = lps [ n - 1 ]
    if ( res > int ( n / 2 ) ) :
        return int ( n / 2 )
    else :
        return res
def longestPrefixSuffix ( s ) :
    len1 = LengthlongestPrefixSuffix ( s )
    prefix = " "
    for i in range ( len1 ) :
        prefix += s [ i ]
    return prefix
if __name__ == ' _ _ main _ _ ' :
    s = " abcab "
    ans = longestPrefixSuffix ( s )
    if ( ans == " " ) :
        print ( " - 1" )
    else :
        print ( ans )

Index/key variables: i, len1
Accumulator variables: prefix
Iterator variables: i
Python program:
def updateString ( S , A , B ) :
    l = len ( A )
    i = 0
    while i + l <= len ( S ) :
        curr = S [ i : i + l ]
        if curr == A :
            new_string = S [ 0 : i ] + B + S [ i + l : len ( S ) ]
            S = new_string
            i += l - 1
        else :
            new_string = S [ 0 : i ] + A + S [ i + l : len ( S ) ]
            S = new_string
            i += l - 1
        i += 1
    return S
if __name__ == " _ _ main _ _ " :
    S = " aab "
    A = " aa "
    B = " bb "
    print ( updateString ( S , A , B ) )

Accumulator variables: i
Python program:
def printPattern ( n , m ) :
    if ( m > 2 * ( n + 1 ) or m < n - 1 ) :
        print ( " - 1" , end = " " )
    elif ( abs ( n - m ) <= 1 ) :
        while ( n > 0 and m > 0 ) :
            print ( "01" , end = " " ) ;
            n -= 1
            m -= 1
        if ( n != 0 ) :
            print ( "0" , end = " " )
        if ( m != 0 ) :
            print ( "1" , end = " " )
    else :
        while ( m - n > 1 and n > 0 ) :
            print ( "110" , end = " " )
            m = m - 2
            n = n - 1
        while ( n > 0 ) :
            print ( "10" , end = " " )
            n -= 1
            m -= 1
        while ( m > 0 ) :
            print ( "1" , end = " " )
            m -= 1
if __name__ == ' _ _ main _ _ ' :
    n = 4
    m = 8
    printPattern ( n , m )

Accumulator variables: m, n
Python program:
def countDecreasing ( A , n ) :
    len = 1
    for i in range ( n - 1 ) :
        if ( A [ i + 1 ] < A [ i ] ) :
            len += 1
        else :
            cnt += ( ( ( len - 1 ) * len ) // 2 ) ;
            len = 1
    if ( len > 1 ) :
        cnt += ( ( ( len - 1 ) * len ) // 2 )
    return cnt
if __name__ == " _ _ main _ _ " :
    A = [ 100 , 3 , 1 , 13 ]
    n = len ( A )
    print ( countDecreasing ( A , n ) )

Index/key variables: i
Accumulator variables: cnt, len
Iterator variables: i
Python program:
import sys
def minimumChar ( S1 , S2 ) :
    n , m = len ( S1 ) , len ( S2 )
    ans = sys . maxsize
    for i in range ( m - n + 1 ) :
        minRemovedChar = 0
        for j in range ( n ) :
            if ( S1 [ j ] != S2 [ i + j ] ) :
                minRemovedChar += 1
        ans = min ( minRemovedChar , ans )
    return ans
if __name__ == ' _ _ main _ _ ' :
    S1 = " abc "
    S2 = " paxzk "
    print ( minimumChar ( S1 , S2 ) )

Index/key variables: j
Accumulator variables: minRemovedChar
Iterator variables: i, j
Python program:
def countFreq ( pat , txt ) :
    M = len ( pat )
    N = len ( txt )
    res = 0
    for i in range ( N - M + 1 ) :
        j = 0
        while j < M :
            if ( txt [ i + j ] != pat [ j ] ) :
                break
            j += 1
        if ( j == M ) :
            res += 1
            j = 0
    return res
if __name__ == ' _ _ main _ _ ' :
    txt = " dhimanman "
    pat = " man "
    print ( countFreq ( pat , txt ) )

Index/key variables: j
Accumulator variables: res
Iterator variables: i
Python program:
def findMissingDigit ( a , b , c ) :
    w = 1
    a_mod_11 = 0
    for i in range ( len ( a ) - 1 , - 1 , - 1 ) :
        a_mod_11 = ( a_mod_11 + w * ( ord ( a [ i ] ) - ord ( '0' ) ) ) % 11
        w = w * - 1
    b_mod_11 = 0
    w = 1
    for i in range ( len ( b ) - 1 , - 1 , - 1 ) :
        b_mod_11 = ( b_mod_11 + w * ( ord ( b [ i ] ) - ord ( '0' ) ) ) % 11
        w = w * - 1
    c_mod_11 = 0
    xSignIsPositive = True
    w = 1
    for i in range ( len ( c ) - 1 , - 1 , - 1 ) :
        if ( c [ i ] == ' x ' ) :
            xSignIsPositive = ( w == 1 )
        else :
            c_mod_11 = ( c_mod_11 + w * ( ord ( c [ i ] ) - ord ( '0' ) ) ) % 11
        w = w * - 1
    x = ( ( a_mod_11 * b_mod_11 ) - c_mod_11 ) % 11
    if ( not xSignIsPositive ) :
        x = - x
    return ( x % 11 + 11 ) % 11
A = "123456789"
B = "987654321"
C = "12193263111x635269"
print ( findMissingDigit ( A , B , C ) )

Index/key variables: i
Iterator variables: i
Boolean variables: xSignIsPositive
Python program:
def findIfPossible ( N , str_ ) :
    countG = 0
    countF = 0
    for i in range ( N ) :
        if str_ [ i ] == ' G ' :
            countG += 1
        else :
            countF += 1
    if 2 * countF != countG :
        print ( " NO " )
    else :
        id = 0
        flag = True
        for i in range ( N ) :
            if str_ [ i ] == ' G ' :
                countG -= 1
                id += 1
            else :
                countF -= 1
                id -= 1
            if id < 0 :
                flag = False
                break
            if countG < countF :
                flag = False
                break
        if flag :
            print ( " YES " )
        else :
            print ( " NO " )
n = 6
str_ = " GFGFGG "
findIfPossible ( n , str_ )

Index/key variables: i
Accumulator variables: countF, countG, id
Iterator variables: i
Boolean variables: flag
Python program:
def isPossible ( str1 , str2 ) :
    arr = { }
    l1 = len ( str1 )
    l2 = len ( str2 )
    possible = True
    for i in range ( l1 ) :
        arr [ str1 [ i ] ] = 1
    for i in range ( l2 ) :
        if str2 [ i ] != ' ▁ ' :
            if arr [ str2 [ i ] ] == 1 :
                continue
            else :
                possible = False
                break
    if possible :
        print ( " Yes " )
    else :
        print ( " No " )
str1 = " we ▁ all ▁ love ▁ geeksforgeeks "
str2 = " we ▁ all ▁ love ▁ geeks "
isPossible ( str1 , str2 )

Index/key variables: i
Iterator variables: i
Boolean variables: possible
Python program:
def find_Min_Inversion ( n , s1 , s2 ) :
    count = 0
    s1 = list ( s1 )
    s2 = list ( s2 )
    for i in range ( n - 1 ) :
        if ( s1 [ i ] != s2 [ i ] ) :
            if ( s1 [ i ] == '1' ) :
                s1 [ i ] = '0'
            else :
                s1 [ i ] = '1'
            if ( s1 [ i + 1 ] == '1' ) :
                s1 [ i + 1 ] = '0'
            else :
                s1 [ i + 1 ] = '1'
            count += 1
    s1 = ' ' . join ( s1 )
    s2 = ' ' . join ( s2 )
    if ( s1 == s2 ) :
        return count
    return - 1
if __name__ == ' _ _ main _ _ ' :
    n = 4
    s1 = "0101"
    s2 = "1111"
    print ( find_Min_Inversion ( n , s1 , s2 ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def findSubsequence ( S , ch ) :
    N = len ( S )
    ans = 0
    for i in range ( N ) :
        if ( S [ i ] == ch ) :
            ans += 1
            ch = chr ( ord ( ch ) + 1 )
    return ans
def findMaxSubsequence ( S ) :
    ans = 0
    for ch in range ( ord ( ' a ' ) , ord ( ' z ' ) + 1 ) :
        ans = max ( ans , findSubsequence ( S , chr ( ch ) ) )
    return ans
if __name__ == ' _ _ main _ _ ' :
    S = " abcabefghijk "
    print ( findMaxSubsequence ( S ) )

Index/key variables: i
Accumulator variables: ans
Iterator variables: ch, i
Python program:
def minOpsToEmptyString ( s ) :
    ans = - 10 ** 9
    cn0 = 0
    cn1 = 0
    for i in range ( len ( s ) ) :
        if ( s [ i ] == '0' ) :
            if ( cn1 > 0 ) :
                cn1 -= 1
            cn0 += 1
        else :
            if ( cn0 > 0 ) :
                cn0 -= 1
            cn1 += 1
        ans = max ( [ ans , cn0 , cn1 ] )
    print ( ans )
if __name__ == ' _ _ main _ _ ' :
    S = "010101"
    minOpsToEmptyString ( S )

Index/key variables: i
Accumulator variables: cn0, cn1
Iterator variables: i
Python program:
def findLength ( str , n ) :
    pre = [ 0 ] * n
    post = [ 0 ] * n
    for i in range ( n ) :
        if ( i != 0 ) :
            pre [ i ] += pre [ i - 1 ]
        if ( str [ i ] == '1' ) :
            pre [ i ] += 1
    for i in range ( n - 1 , - 1 , - 1 ) :
        if ( i != ( n - 1 ) ) :
            post [ i ] += post [ i + 1 ]
        if ( str [ i ] == '0' ) :
            post [ i ] += 1
    ans = 0
    for i in range ( n ) :
        ans = max ( ans , pre [ i ] + post [ i ] )
    return ans
S = "0101110110100001011"
n = len ( S )
print ( findLength ( S , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def countSubstring ( S , N ) :
    prevSum = { }
    res = 0
    currentSum = 0
    for i in range ( N ) :
        if ( S [ i ] >= ' A ' and S [ i ] <= ' Z ' ) :
            currentSum += 1
        else :
            currentSum -= 1
        if ( currentSum == 0 ) :
            res += 1
        if ( currentSum in prevSum ) :
            res += ( prevSum [ currentSum ] )
        if currentSum in prevSum :
            prevSum [ currentSum ] += 1
        else :
            prevSum [ currentSum ] = 1
    return res
if __name__ == ' _ _ main _ _ ' :
    S = " gEEk "
    print ( countSubstring ( S , len ( S ) ) )

Index/key variables: currentSum, i
Accumulator variables: res
Iterator variables: i
Python program:
def subString ( s , n ) :
    count = 0
    for i in range ( n ) :
        for len in range ( i + 1 , n + 1 ) :
            test_str = ( s [ i : len ] )
            res = { }
            for keys in test_str :
                res [ keys ] = res . get ( keys , 0 ) + 1
            flag = 0
            for keys in res :
                if res [ keys ] % 2 != 0 :
                    flag = 1
                    break
            if flag == 0 :
                count += 1
    return count
S = " abbaa "
N = len ( S )
print ( subString ( S , N ) )

Index/key variables: keys
Accumulator variables: count
Iterator variables: i, keys, len
Python program:
def countStringPairs ( a , n ) :
    ans = 0
    for i in range ( n ) :
        for j in range ( i + 1 , n , 1 ) :
            p = a [ i ]
            q = a [ j ]
            if ( p [ 0 ] != q [ 0 ] ) :
                p = list ( p )
                q = list ( q )
                temp = p [ 0 ]
                p [ 0 ] = q [ 0 ]
                q [ 0 ] = temp
                p = ' ' . join ( p )
                q = ' ' . join ( q )
                flag1 = 0
                flag2 = 0
                for k in range ( n ) :
                    if ( a [ k ] == p ) :
                        flag1 = 1
                    if ( a [ k ] == q ) :
                        flag2 = 1
                if ( flag1 == 0 and flag2 == 0 ) :
                    ans = ans + 1
    print ( ans )
if __name__ == ' _ _ main _ _ ' :
    arr = [ " good " , " bad " , " food " ]
    N = len ( arr )
    countStringPairs ( arr , N )

Index/key variables: i, j, k
Iterator variables: i, j, k
Python program:
def addASCII ( S , N ) :
    for i in range ( len ( S ) ) :
        a = ord ( N [ i ] ) - ord ( '0' )
        b = ord ( S [ i ] ) + a
        if ( b > 122 ) :
            b -= 26
        S = S . replace ( S [ i ] , chr ( b ) )
    print ( S )
if __name__ == " _ _ main _ _ " :
    S = " sun "
    N = "966"
    addASCII ( S , N )

Index/key variables: i
Accumulator variables: b
Iterator variables: i
Python program:
def decHex ( n ) :
    alpha = [ ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' ]
    ans = ' '
    while n :
        if n % 16 < 10 :
            ans += str ( n % 16 )
        else :
            ans += alpha [ n % 16 - 10 ]
        n //= 16
    ans = ans [ : : - 1 ]
    return ans
def hexDec ( convertedHex ) :
    mp = { " A " : 10 , " B " : 11 , " C " : 12 , " D " : 13 , " E " : 14 , " F " : 15 }
    ans = 0
    pos = 0
    for i in convertedHex [ : : - 1 ] :
        if i . isdigit ( ) :
            ans += ( 16 ** pos ) * int ( i )
        else :
            ans += ( 16 ** pos ) * mp [ i ]
        pos += 1
    return ans
def removeChars ( hexaVal , S ) :
    setk = set ( )
    for i in S :
        setk . add ( i )
    ans = ' '
    for i in hexaVal :
        if i in setk :
            continue
        ans += i
    return ans
def convertArr ( arr , S ) :
    for i in range ( len ( arr ) ) :
        hexaVal = decHex ( arr [ i ] )
        convertedHex = removeChars ( hexaVal , S )
        decVal = hexDec ( convertedHex )
        arr [ i ] = decVal
    print ( arr )
arr = [ 74 , 91 , 31 , 122 ]
S = "1AB "
convertArr ( arr , S )

Index/key variables: i
Accumulator variables: ans, n, pos, setk
Iterator variables: i
Python program:
def fillString ( s , k ) :
    mp = { }
    for i in range ( len ( s ) ) :
        if ( s [ i ] != ' ? ' ) :
            mp [ i % k ] = s [ i ]
    s = list ( s )
    for i in range ( len ( s ) ) :
        if ( ( i % k ) not in mp ) :
            print ( - 1 )
            return
        s [ i ] = mp [ i % k ]
    s = ' ' . join ( s )
    print ( s )
if __name__ == ' _ _ main _ _ ' :
    S = " ? ? ? ? abcd "
    K = 4
    fillString ( S , K )

Index/key variables: i
Iterator variables: i
Python program:
def rearrangeString ( s1 , s2 ) :
    cnt = [ 0 ] * 26
    for i in range ( len ( s2 ) ) :
        cnt [ ord ( s2 [ i ] ) - ord ( ' a ' ) ] += 1
    unique = 0
    for i in range ( 26 ) :
        if ( cnt [ i ] != 0 ) :
            unique += 1
    if ( unique == 1 ) :
        count_in_s2 = len ( s2 )
        count_in_s1 = 0
        for i in range ( len ( s1 ) ) :
            if ( s1 [ i ] == s2 [ 0 ] ) :
                count_in_s1 += 1
        if ( count_in_s1 < count_in_s2 ) :
            print ( s1 , end = " " )
            return
        print ( - 1 , end = " " )
    else :
        inc = 1
        for i in range ( len ( s2 ) - 1 ) :
            if ( s2 [ i ] > s2 [ i + 1 ] ) :
                inc = 0
        if ( inc == 1 ) :
            s1 = sorted ( s1 ) [ : : - 1 ]
            print ( " " . join ( s1 ) , end = " " )
        else :
            s1 = sorted ( s1 )
            print ( " " . join ( s1 ) , end = " " )
if __name__ == ' _ _ main _ _ ' :
    s1 , s2 = " abcd " , " ab "
    rearrangeString ( s1 , s2 )

Index/key variables: i
Accumulator variables: count_in_s1, unique
Iterator variables: i
Python program:
def solution ( S ) :
    vowels = [ ]
    consonants = [ ]
    for i in S :
        if ( i == ' a ' or i == ' e ' or i == ' i ' or i == ' o ' or i == ' u ' ) :
            vowels . append ( i )
        else :
            consonants . append ( i )
    Nc = len ( consonants )
    Nv = len ( vowels )
    M = Nc // ( Nv - 1 )
    ans = " "
    consonant_till = 0
    for i in vowels :
        ans += i
        temp = 0
        for j in range ( consonant_till , min ( Nc , consonant_till + M ) ) :
            ans += consonants [ j ]
            temp += 1
        consonant_till += temp
    return ans
S = " aaaabbbcc "
print ( solution ( S ) )

Index/key variables: j
Accumulator variables: ans, consonant_till, consonants, temp, vowels
Iterator variables: i, j
Python program:
def maximum_pallindromic ( arr ) :
    res = 0
    c1 = 0
    c2 = 0
    for i in range ( 26 ) :
        res += arr [ i ] // 3
        arr [ i ] = arr [ i ] % 3
        if ( arr [ i ] == 1 ) :
            c1 += 1
        elif ( arr [ i ] == 2 ) :
            c2 += 1
    res += min ( c1 , c2 )
    t = min ( c1 , c2 )
    c1 -= t
    c2 -= t
    res += 2 * ( c2 // 3 )
    c2 %= 3
    res += c2 // 2
    print ( res )
if __name__ == " _ _ main _ _ " :
    arr = [ 4 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ]
    maximum_pallindromic ( arr )

Index/key variables: i
Accumulator variables: c1, c2, res
Iterator variables: i
Python program:
def find_Winner ( arr , N ) :
    Q = [ 0 ] * N
    for i in range ( N ) :
        Q [ i ] = [ ]
    M = len ( arr )
    for i in range ( M ) :
        Len = len ( arr [ i ] )
        for j in range ( Len ) :
            Q [ i ] . append ( ord ( arr [ i ] [ j ] ) - 1 )
    player = 0
    while ( len ( Q [ player ] ) > 0 ) :
        nextPlayer = Q [ player ] [ 0 ] - ord ( '0' )
        del Q [ player ] [ 0 ]
        player = nextPlayer
    print ( " Player " , ( player + 1 ) )
N = 3
arr = [ "323" , "2" , "2" ]
find_Winner ( arr , N )

Index/key variables: i, j, player
Iterator variables: i, j
Python program:
def longestSubstring ( s ) :
    dp = [ 1024 for i in range ( 1024 ) ]
    res , mask = 0 , 0
    dp [ 0 ] = - 1
    for i in range ( len ( s ) ) :
        mask ^= 1 << ( ord ( s [ i ] ) - ord ( '0' ) )
        res = max ( res , i - dp [ mask ] )
        for j in range ( 10 ) :
            res = max ( res , i - dp [ mask ^ ( 1 << j ) ] )
        dp [ mask ] = min ( dp [ mask ] , i )
    return res
if __name__ == ' _ _ main _ _ ' :
    s = "3242415"
    print ( longestSubstring ( s ) )

Index/key variables: i, mask
Iterator variables: i, j
Python program:
def Validate ( M ) :
    lenn = len ( M )
    temp = " "
    for i in range ( lenn ) :
        if ( M [ i ] . isdigit ( ) ) :
            temp += M [ i ]
    nwlenn = len ( temp )
    if ( nwlenn != 10 ) :
        print ( " Invalid " )
        return
    res = " "
    x = temp [ 0 : 3 ]
    res += " ( " + x + " ) - "
    x = temp [ 3 : 3 + 3 ]
    res += " ( " + x + " ) - "
    x = temp [ 6 : 3 + 6 ]
    res += " ( " + x + " ) - "
    x = temp [ 9 : 1 + 9 ]
    res += " ( " + x + " ) "
    print ( res )
if __name__ == ' _ _ main _ _ ' :
    M = "91 ▁ 234rt5%34*0 ▁ 3"
    Validate ( M )

Index/key variables: i
Accumulator variables: temp
Iterator variables: i
Python program:
def hexaModK ( s , k ) :
    mp = { } ;
    for i in range ( 1 , 10 ) :
        mp [ chr ( i + ord ( '0' ) ) ] = i ;
    mp [ ' A ' ] = 10 ;
    mp [ ' B ' ] = 11 ;
    mp [ ' C ' ] = 12 ;
    mp [ ' D ' ] = 13 ;
    mp [ ' E ' ] = 14 ;
    mp [ ' F ' ] = 15 ;
    m = int ( k ) ;
    base = 1 ;
    ans = 0 ;
    for i in range ( len ( s ) - 1 , - 1 , - 1 ) :
        n = mp [ s [ i ] ] % m ;
        ans = ( ans + ( base % m * n % m ) % m ) % m ;
        base = ( base % m * 16 % m ) % m ;
    ans = hex ( int ( ans ) ) [ - 1 ] . upper ( )
    print ( ans )
if __name__ == " _ _ main _ _ " :
    n = "3E8" ;
    k = "13" ;
    hexaModK ( n , k ) ;

Index/key variables: i
Iterator variables: i