dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def findWinner ( A , n ) :
    res = 0
    for i in range ( n ) :
        res ^= A [ i ]
    if ( res == 0 or n % 2 == 0 ) :
        return " Alice "
    else :
        return " Bob "
A = [ 1 , 4 , 3 , 5 ]
n = len ( A )
print ( " Winner ▁ = ▁ " , findWinner ( A , n ) )

Index/key variables: i
Accumulator variables: res
Iterator variables: i
Python program:
def count ( n ) :
    c = 0
    while ( n != 0 ) :
        c += 1
        n = n >> 1
    return c
def XOR ( a , b ) :
    c = min ( a , b )
    d = max ( a , b )
    if ( count ( c ) < count ( d ) ) :
        c = c << ( count ( d ) - count ( c ) )
    return ( c ^ d )
a = 13 ; b = 5
print ( XOR ( a , b ) )

Accumulator variables: c
Python program:
def CheckDivisibilty ( A ) :
    oddbits = 0 ;
    evenbits = 0 ;
    for counter in range ( len ( A ) ) :
        if ( A [ counter ] == '1' ) :
            if ( counter % 2 == 0 ) :
                evenbits += 1 ;
            else :
                oddbits += 1 ;
    if ( abs ( oddbits - evenbits ) % 3 == 0 ) :
        print ( " Yes " + " " ) ;
    else :
        print ( " No " + " " ) ;
if __name__ == ' _ _ main _ _ ' :
    A = "10101" ;
    CheckDivisibilty ( A ) ;

Index/key variables: counter
Accumulator variables: evenbits, oddbits
Iterator variables: counter
Python program:
def evenbittogglenumber ( n ) :
    res = 0
    count = 0
    temp = n
    while ( temp > 0 ) :
        if ( count % 2 == 1 ) :
            res = res | ( 1 << count )
        count = count + 1
        temp >>= 1
    return n ^ res
n = 11
print ( evenbittogglenumber ( n ) )

Accumulator variables: temp
Python program:
def setleftmostunsetbit ( n ) :
    if not ( n & ( n + 1 ) ) :
        return n
    pos , temp , count = 0 , n , 0
    while temp :
        if not ( temp & 1 ) :
            pos = count
        count += 1 ; temp >>= 1
    return ( n | ( 1 << ( pos ) ) )
n = 10
print ( setleftmostunsetbit ( n ) )

Accumulator variables: count, temp
Python program:
def maxXorSum ( n , k ) :
    if k == 1 :
        return n
    res = 1
    while res <= n :
        res <<= 1
    return res - 1
n = 4
k = 3
print ( maxXorSum ( n , k ) )

Accumulator variables: res
Python program:
import math
def swap ( a , b ) :
    temp = a
    a = b
    b = temp
def xnor ( a , b ) :
    if ( a < b ) :
        swap ( a , b )
    if ( a == 0 and b == 0 ) :
        return 1 ;
    a_rem = 0
    b_rem = 0
    count = 0
    xnornum = 0
    while ( a != 0 ) :
        a_rem = a & 1
        b_rem = b & 1
        if ( a_rem == b_rem ) :
            xnornum |= ( 1 << count )
        count = count + 1
        a = a >> 1
        b = b >> 1
    return xnornum ;
a = 10
b = 50
print ( xnor ( a , b ) )

Accumulator variables: xnornum
Python program:
def MaximumSum ( a , b , n ) :
    sum1 = 0
    sum2 = 0
    for i in range ( 0 , n ) :
        sum1 |= a [ i ]
        sum2 |= b [ i ]
    print ( sum1 + sum2 )
A = [ 1 , 2 , 4 , 3 , 2 ]
B = [ 2 , 3 , 3 , 12 , 1 ]
n = len ( A )
MaximumSum ( A , B , n )

Index/key variables: i
Accumulator variables: sum1, sum2
Iterator variables: i
Python program:
def evenbittogglenumber ( n ) :
    res = 0 ; count = 0 ; temp = n
    while ( temp > 0 ) :
        if ( count % 2 == 0 ) :
            res = res | ( 1 << count )
        count = count + 1
        temp >>= 1
    return n ^ res
if __name__ == ' _ _ main _ _ ' :
    n = 11
    print ( evenbittogglenumber ( n ) )

Accumulator variables: temp
Python program:
def maxAND ( arr , n ) :
    res = 0
    for i in range ( 0 , n ) :
        for j in range ( i + 1 , n ) :
            res = max ( res , arr [ i ] & arr [ j ] )
    return res
arr = [ 4 , 8 , 6 , 2 ]
n = len ( arr )
print ( " Maximum ▁ AND ▁ Value ▁ = ▁ " , maxAND ( arr , n ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def index ( i ) :
    return 1 + ( i >> 31 ) - ( - i >> 31 )
def check ( n ) :
    s = " negative " , " zero " , " positive "
    val = index ( n )
    print ( n , " is " , s [ val ] )
check ( 30 )
check ( - 20 )
check ( 0 )

Index/key variables: val
Python program:
def checking ( s ) :
    c = 0
    n = len ( s )
    i = n - 1
    while ( i >= 0 ) :
        if ( s [ i ] == '0' ) :
            c += 1
        if ( c >= 6 and s [ i ] == '1' ) :
            return True
        i -= 1
    return False
if __name__ == ' _ _ main _ _ ' :
    s = "100010001"
    if ( checking ( s ) ) :
        print ( " Possible " )
    else :
        print ( " Not ▁ possible " )

Index/key variables: i
Accumulator variables: c
Python program:
import sys
def findUnique ( a , n , k ) :
    INT_SIZE = 8 * sys . getsizeof ( int )
    count = [ 0 ] * INT_SIZE
    for i in range ( INT_SIZE ) :
        for j in range ( n ) :
            if ( ( a [ j ] & ( 1 << i ) ) != 0 ) :
                count [ i ] += 1
    res = 0
    for i in range ( INT_SIZE ) :
        res += ( count [ i ] % k ) * ( 1 << i )
    return res
if __name__ == ' _ _ main _ _ ' :
    a = [ 6 , 2 , 5 , 2 , 2 , 6 , 6 ]
    n = len ( a )
    k = 3
    print ( findUnique ( a , n , k ) ) ;

Index/key variables: i, j
Accumulator variables: res
Iterator variables: i, j
Python program:
import math
def setBit ( xorValue ) :
    count = 0
    while ( xorValue ) :
        if ( xorValue % 2 ) :
            count += 1
        xorValue = int ( xorValue / 2 )
    return count
def minFlip ( n , k ) :
    size = int ( math . log ( n ) / math . log ( 2 ) + 1 )
    max = pow ( 2 , k ) - 1
    max = max << ( size - k )
    xorValue = ( n ^ max )
    return ( setBit ( xorValue ) )
n = 27
k = 3
print ( " Min ▁ Flips ▁ = ▁ " , minFlip ( n , k ) )

Accumulator variables: count
Python program:
def printNonConsecutive ( n ) :
    p = ( 1 << n )
    for i in range ( 1 , p ) :
        if ( ( i & ( i << 1 ) ) == 0 ) :
            print ( i , end = " ▁ " )
n = 3
printNonConsecutive ( n )

Iterator variables: i
Python program:
def shuffle ( N , key ) :
    NO_OF_BITS = N
    reverse_num = 0
    for i in range ( NO_OF_BITS ) :
        temp = ( key & ( 1 << i ) )
        if ( temp ) :
            reverse_num |= ( 1 << ( ( NO_OF_BITS - 1 ) - i ) )
    print ( reverse_num )
N = 3
key = 3
shuffle ( N , key )

Accumulator variables: reverse_num
Iterator variables: i
Python program:
def countSetBits ( n ) :
    count = 0
    while ( n ) :
        n = n & ( n - 1 )
        count = count + 1
    return count
def findSum ( n ) :
    sum = 0
    for i in range ( 1 , n + 1 ) :
        if ( countSetBits ( i ) == 2 ) :
            sum = sum + i
    return sum
n = 10
print ( findSum ( n ) )

Iterator variables: i
Python program:
def toggleAllExceptK ( n , k ) :
    temp = bin ( n ^ ( 1 << k ) ) [ 2 : ]
    ans = " "
    for i in temp :
        if i == '1' :
            ans += '0'
        else :
            ans += '1'
    return int ( ans , 2 )
if __name__ == ' _ _ main _ _ ' :
    n = 4294967295
    k = 0
    print ( toggleAllExceptK ( n , k ) )

Accumulator variables: ans
Iterator variables: i
Python program:
def CountZeroBit ( x ) :
    count = 0
    while ( x ) :
        if ( ( x & 1 ) == 0 ) :
            count += 1
        x >>= 1
    return count
def CountXORandSumEqual ( x ) :
    count = CountZeroBit ( x )
    return ( 1 << count )
if __name__ == ' _ _ main _ _ ' :
    x = 10
    print ( CountXORandSumEqual ( x ) )

Accumulator variables: count, x
Python program:
class BitArray :
    def __init__ ( self , n ) :
        self . arr = [ 0 ] * ( ( n >> 5 ) + 1 )
    def get ( self , pos ) :
        self . index = pos >> 5
        self . bitNo = pos & 0x1F
        return ( self . arr [ self . index ] & ( 1 << self . bitNo ) ) != 0
    def set ( self , pos ) :
        self . index = pos >> 5
        self . bitNo = pos & 0x1F
        self . arr [ self . index ] |= ( 1 << self . bitNo )
def checkDuplicates ( arr ) :
    ba = BitArray ( 320000 )
    for i in range ( len ( arr ) ) :
        num = arr [ i ]
        if ba . get ( num ) :
            print ( num , end = " ▁ " )
        else :
            ba . set ( num )
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 5 , 1 , 10 , 12 , 10 ]
    checkDuplicates ( arr )

Index/key variables: i
Iterator variables: i
Class/struct names: BitArray
Python program:
def countValues ( x ) :
    count = 0 ;
    n = 1 ;
    while ( x > 0 ) :
        if ( x % 2 == 0 ) :
            count += n ;
        n *= 2 ;
        x /= 2 ;
        x = int ( x ) ;
    return count ;
x = 10 ;
print ( countValues ( x ) ) ;

Accumulator variables: count, n, x
Python program:
def constructXOR ( A , n ) :
    XOR = 0
    for i in range ( 0 , n ) :
        XOR ^= A [ i ]
    for i in range ( 0 , n ) :
        A [ i ] = XOR ^ A [ i ]
A = [ 2 , 4 , 1 , 3 , 5 ]
n = len ( A )
constructXOR ( A , n )
for i in range ( 0 , n ) :
    print ( A [ i ] , end = " ▁ " )

Index/key variables: i
Accumulator variables: XOR
Iterator variables: i
Python program:
def bitCount ( n ) :
    count = 0
    while ( n ) :
        if ( n & 1 ) :
            count += 1
        n >>= 1
    return count
def countPairsWithKDiff ( arr , n , k ) :
    ans = 0
    for i in range ( 0 , n - 1 , 1 ) :
        for j in range ( i + 1 , n , 1 ) :
            xoredNum = arr [ i ] ^ arr [ j ]
            if ( k == bitCount ( xoredNum ) ) :
                ans += 1
    return ans
if __name__ == ' _ _ main _ _ ' :
    k = 2
    arr = [ 2 , 4 , 1 , 3 , 1 ]
    n = len ( arr )
    print ( " Total ▁ pairs ▁ for ▁ k ▁ = " , k , " are " , countPairsWithKDiff ( arr , n , k ) )

Index/key variables: i, j
Accumulator variables: ans, count, n
Iterator variables: i, j
Python program:
def kBitDifferencePairs ( arr , n , k ) :
    MAX = max ( arr )
    count = [ 0 for i in range ( MAX + 1 ) ]
    for i in range ( n ) :
        count [ arr [ i ] ] += 1
    ans = 0
    if ( k == 0 ) :
        for i in range ( MAX + 1 ) :
            ans += ( count [ i ] * ( count [ i ] - 1 ) ) // 2
        return ans
    for i in range ( MAX + 1 ) :
        if ( count [ i ] == 0 ) :
            continue
        for j in range ( i + 1 , MAX + 1 ) :
            if ( bin ( i ^ j ) . count ( '1' ) == k ) :
                ans += count [ i ] * count [ j ]
    return ans
k = 2
arr = [ 2 , 4 , 1 , 3 , 1 ]
n = len ( arr )
print ( " Total ▁ pairs ▁ for ▁ k ▁ = " , k , " are " , kBitDifferencePairs ( arr , n , k ) )
k = 3
print ( " Total ▁ pairs ▁ for ▁ k ▁ = " , k , " are " , kBitDifferencePairs ( arr , n , k ) )

Index/key variables: i, j
Accumulator variables: ans
Iterator variables: i, j
Python program:
def multiply ( n , m ) :
    ans = 0
    count = 0
    while ( m ) :
        if ( m % 2 == 1 ) :
            ans += n << count
        count += 1
        m = int ( m / 2 )
    return ans
if __name__ == ' _ _ main _ _ ' :
    n = 20
    m = 13
    print ( multiply ( n , m ) )

Accumulator variables: ans, count
Python program:
def findContinuous1 ( n ) :
    bp = list ( bin ( n ) )
    bits = len ( bp )
    prev_count = 0
    curr_count = 0
    i = 0
    while ( i < bits ) :
        if ( bp [ i ] == '1' ) :
            curr_count += 1
            i += 1
        elif ( bp [ i - 1 ] == '0' ) :
            i += 1
            curr_count = 0
            continue
        else :
            if ( curr_count < prev_count ) :
                return 0
            i += 1
            prev_count = curr_count
            curr_count = 0
    if ( prev_count > curr_count and ( curr_count != 0 ) ) :
        return 0
    return 1
n = 179
if ( findContinuous1 ( n ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Accumulator variables: curr_count
Python program:
import sys
def areSetBitsIncreasing ( n ) :
    prev_count = sys . maxsize
    while ( n > 0 ) :
        while ( n > 0 and n % 2 == 0 ) :
            n = int ( n / 2 )
        curr_count = 1
        while ( n > 0 and n % 2 == 1 ) :
            n = n / 2
            curr_count += 1
        if ( curr_count >= prev_count ) :
            return False
        prev_count = curr_count
    return True
n = 10
if ( areSetBitsIncreasing ( n ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Accumulator variables: curr_count
Python program:
def countXOR ( n ) :
    count0 , count1 = 0 , 0
    while ( n != 0 ) :
        if ( n % 2 == 0 ) :
            count0 += 1
        else :
            count1 += 1
        n //= 2
    return ( count0 ^ count1 )
n = 31
print ( countXOR ( n ) )

Accumulator variables: count0, count1, n
Python program:
def xorPairCount ( arr , n , x ) :
    m = dict ( )
    for i in range ( n ) :
        curr_xor = x ^ arr [ i ]
        if ( curr_xor in m . keys ( ) ) :
            result += m [ curr_xor ]
        if arr [ i ] in m . keys ( ) :
            m [ arr [ i ] ] += 1
        else :
            m [ arr [ i ] ] = 1
    return result
arr = [ 2 , 5 , 2 ]
n = len ( arr )
x = 0
print ( " Count ▁ of ▁ pairs ▁ with ▁ given ▁ XOR ▁ = ▁ " , xorPairCount ( arr , n , x ) )

Index/key variables: curr_xor, i
Accumulator variables: result
Iterator variables: i
Python program:
def msbPos ( n ) :
    msb_p = - 1
    while ( n > 0 ) :
        n = n >> 1
        msb_p += 1
    return msb_p
def andOperator ( x , y ) :
    while ( x > 0 and y > 0 ) :
        msb_p1 = msbPos ( x )
        msb_p2 = msbPos ( y )
        if ( msb_p1 != msb_p2 ) :
            break
        msb_val = ( 1 << msb_p1 )
        res = res + msb_val
        x = x - msb_val
        y = y - msb_val
    return res
x , y = 10 , 15
print ( andOperator ( x , y ) )

Accumulator variables: msb_p
Python program:
def countValues ( n ) :
    countV = 0 ;
    for i in range ( n + 1 ) :
        if ( ( n + i ) == ( n ^ i ) ) :
            countV += 1 ;
    return countV ;
n = 12 ;
print ( countValues ( n ) ) ;

Accumulator variables: countV
Iterator variables: i
Python program:
def countValues ( n ) :
    unset_bits = 0
    while ( n ) :
        if n & 1 == 0 :
            unset_bits += 1
        n = n >> 1
    return 1 << unset_bits
if __name__ == ' _ _ main _ _ ' :
    n = 12
    print ( countValues ( n ) )

Accumulator variables: unset_bits
Python program:
def printTwoSetBitNums ( n ) :
    x = 1
    while ( n > 0 ) :
        y = 0
        while ( y < x ) :
            print ( ( 1 << x ) + ( 1 << y ) , end = " ▁ " )
            n -= 1
            if ( n == 0 ) :
                return
            y += 1
        x += 1
printTwoSetBitNums ( 4 )

Accumulator variables: n, x, y
Python program:
def printRepeatingEven ( arr , n ) :
    axor = 0 ;
    for i in range ( 0 , n ) :
        pos = 1 << arr [ i ] ;
        axor ^= pos ;
    for i in range ( 0 , n - 1 ) :
        pos = 1 << arr [ i ] ;
        if ( not ( pos & axor ) ) :
            print ( arr [ i ] , end = " ▁ " ) ;
            axor ^= pos ;
arr = [ 9 , 12 , 23 , 10 , 12 , 12 , 15 , 23 , 14 , 12 , 15 ] ;
n = len ( arr ) ;
printRepeatingEven ( arr , n ) ;

Index/key variables: i
Accumulator variables: axor
Iterator variables: i
Python program:
def xor ( a , b ) :
    result = [ ]
    for i in range ( 1 , len ( b ) ) :
        if a [ i ] == b [ i ] :
            result . append ( '0' )
        else :
            result . append ( '1' )
    return ' ' . join ( result )
def mod2div ( divident , divisor ) :
    pick = len ( divisor )
    tmp = divident [ 0 : pick ]
    while pick < len ( divident ) :
        if tmp [ 0 ] == '1' :
            tmp = xor ( divisor , tmp ) + divident [ pick ]
            tmp = xor ( '0' * pick , tmp ) + divident [ pick ]
        pick += 1
    if tmp [ 0 ] == '1' :
        tmp = xor ( divisor , tmp )
    else :
        tmp = xor ( '0' * pick , tmp )
    checkword = tmp
    return checkword
def encodeData ( data , key ) :
    l_key = len ( key )
    appended_data = data + '0' * ( l_key - 1 )
    remainder = mod2div ( appended_data , key )
    codeword = data + remainder
    print ( " Remainder ▁ : ▁ " , remainder )
    print ( " Encoded ▁ Data ▁ ( Data ▁ + ▁ Remainder ) ▁ : ▁ " , codeword )
data = "100100"
key = "1101"
encodeData ( data , key )

Index/key variables: i, pick
Accumulator variables: result
Iterator variables: i
Python program:
def countSetBits ( x ) :
    count = 0
    while ( x ) :
        x = x & ( x - 1 )
        count = count + 1
    return count
def isBleak ( n ) :
    for x in range ( 1 , n ) :
        if ( x + countSetBits ( x ) == n ) :
            return False
    return True
if ( isBleak ( 3 ) ) :
    print ( " Yes " )
else :
    print ( " No " )
if ( isBleak ( 4 ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Iterator variables: x
Python program:
import random
N = 2
def freivald ( a , b , c ) :
    r = [ 0 ] * N
    for i in range ( 0 , N ) :
        r [ i ] = ( int ) ( random . randrange ( 509090009 ) % 2 )
    br = [ 0 ] * N
    for i in range ( 0 , N ) :
        for j in range ( 0 , N ) :
            br [ i ] = br [ i ] + b [ i ] [ j ] * r [ j ]
    cr = [ 0 ] * N
    for i in range ( 0 , N ) :
        for j in range ( 0 , N ) :
            cr [ i ] = cr [ i ] + c [ i ] [ j ] * r [ j ]
    axbr = [ 0 ] * N
    for i in range ( 0 , N ) :
        for j in range ( 0 , N ) :
            axbr [ i ] = axbr [ i ] + a [ i ] [ j ] * br [ j ]
    for i in range ( 0 , N ) :
        if ( axbr [ i ] - cr [ i ] != 0 ) :
            return False
    return True
def isProduct ( a , b , c , k ) :
    for i in range ( 0 , k ) :
        if ( freivald ( a , b , c ) == False ) :
            return False
    return True
a = [ [ 1 , 1 ] , [ 1 , 1 ] ]
b = [ [ 1 , 1 ] , [ 1 , 1 ] ]
c = [ [ 2 , 2 ] , [ 2 , 2 ] ]
k = 2
if ( isProduct ( a , b , c , k ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def calc_Expectation ( a , n ) :
    prb = 1 / n
    sum = 0
    for i in range ( 0 , n ) :
        sum += ( a [ i ] * prb )
    return float ( sum )
n = 6 ;
a = [ 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 ]
expect = calc_Expectation ( a , n )
print ( " Expectation ▁ of ▁ array ▁ E ( X ) ▁ is ▁ : ▁ " , expect )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
import random
def checkCaptcha ( captcha , user_captcha ) :
    if captcha == user_captcha :
        return True
    return False
def generateCaptcha ( n ) :
    chrs = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    captcha = " "
    while ( n ) :
        captcha += chrs [ random . randint ( 1 , 1000 ) % 62 ]
        n -= 1
    return captcha
captcha = generateCaptcha ( 9 )
print ( captcha )
print ( " Enter ▁ above ▁ CAPTCHA : " )
usr_captcha = input ( )
if ( checkCaptcha ( captcha , usr_captcha ) ) :
    print ( " CAPTCHA ▁ Matched " )
else :
    print ( " CAPTCHA ▁ Not ▁ Matched " )

Accumulator variables: captcha, n
Python program:
def LongestSubarray ( a , n , k ) :
    pre = [ 0 for i in range ( n ) ]
    for i in range ( n ) :
        if ( a [ i ] > k ) :
            pre [ i ] = 1
        else :
            pre [ i ] = - 1
    for i in range ( 1 , n ) :
        pre [ i ] = pre [ i - 1 ] + pre [ i ]
    Len = 0
    lo = 1
    hi = n
    while ( lo <= hi ) :
        mid = ( lo + hi ) // 2
        ok = False
        for i in range ( mid - 1 , n ) :
            x = pre [ i ]
            if ( i - mid >= 0 ) :
                x -= pre [ i - mid ]
            if ( x > 0 ) :
                ok = True
                break
        if ( ok == True ) :
            Len = mid
            lo = mid + 1
        else :
            hi = mid - 1
    return Len
a = [ 2 , 3 , 4 , 5 , 3 , 7 ]
k = 3
n = len ( a )
print ( LongestSubarray ( a , n , k ) )

Index/key variables: i
Accumulator variables: x
Iterator variables: i
Boolean variables: ok
Python program:
def minDays ( P , arr ) :
    for i in range ( 1 , len ( P ) ) :
        P [ i ] += P [ i ] + P [ i - 1 ]
    for i in range ( len ( arr ) ) :
        index = binarySeach ( P , arr [ i ] )
        if ( index != - 1 ) :
            print ( index + 1 , end = " ▁ " )
        else :
            print ( - 1 , end = " ▁ " )
def binarySeach ( P , N ) :
    i = 0
    j = len ( P ) - 1
    index = - 1
    while ( i <= j ) :
        mid = i + ( j - i ) // 2
        if ( P [ mid ] >= N ) :
            index = mid
            j = mid - 1
        else :
            i = mid + 1
    return index
if __name__ == ' _ _ main _ _ ' :
    arr = [ 400 , 200 , 700 , 900 , 1400 ]
    P = [ 100 , 300 , 400 , 500 , 600 ]
    minDays ( P , arr )

Index/key variables: i, mid
Iterator variables: i
Python program:
import sys
def maximumProfit ( arr , N ) :
    ans = - sys . maxsize - 1
    price = 0
    arr . sort ( )
    for i in range ( N ) :
        count = ( N - i )
        if ( ans < count * arr [ i ] ) :
            price = arr [ i ]
            ans = count * arr [ i ]
    return price
if __name__ == " _ _ main _ _ " :
    arr = [ 22 , 87 , 9 , 50 , 56 , 43 ]
    print ( maximumProfit ( arr , 6 ) )

Index/key variables: i
Iterator variables: i
Python program:
def mulsum ( arr , n , N ) :
    sums = 0
    for i in range ( 0 , n ) :
        if arr [ i ] % N == 0 :
            sums = sums + arr [ i ]
    print ( sums )
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 3 , 5 , 6 ]
    n = len ( arr )
    N = 3
    mulsum ( arr , n , N )

Index/key variables: i
Iterator variables: i
Python program:
def farthestHill ( arr , X , Y , N , K ) :
    pq = [ ]
    for i in range ( K , N - 1 , 1 ) :
        if ( arr [ i ] >= arr [ i + 1 ] ) :
            continue
        diff = arr [ i + 1 ] - arr [ i ]
        pq . append ( diff )
        if ( len ( pq ) > Y ) :
            X -= pq [ - 1 ]
            pq [ - 1 ]
        if ( X < 0 ) :
            print ( i )
            return
    print ( N - 1 )
arr = [ 4 , 2 , 7 , 6 , 9 , 14 , 12 ]
X = 5
Y = 1
K = 0
N = len ( arr )
farthestHill ( arr , X , Y , N , K )

Index/key variables: i
Accumulator variables: X, pq
Iterator variables: i
Python program:
def nextAvailableChar ( charset , start ) :
    for i in range ( start - 1 , - 1 , - 1 ) :
        if ( charset [ i ] > 0 ) :
            charset [ i ] -= 1
            return chr ( i + ord ( ' a ' ) )
    return ' \0'
def newString ( originalLabel , limit ) :
    n = len ( originalLabel )
    charset = [ 0 ] * ( 26 )
    newStrings = " "
    for i in originalLabel :
        charset [ ord ( i ) - ord ( ' a ' ) ] += 1
    for i in range ( 25 , - 1 , - 1 ) :
        count = 0
        while ( charset [ i ] > 0 ) :
            newStrings += chr ( i + ord ( ' a ' ) )
            charset [ i ] -= 1
            count += 1
            if ( charset [ i ] > 0 and count == limit ) :
                next = nextAvailableChar ( charset , i )
                if ( next == ' \0' ) :
                    return newStrings
                newStrings += next
                count = 0
    return newStrings
if __name__ == " _ _ main _ _ " :
    S = " ccbbb "
    K = 2
    print ( newString ( S , K ) )

Index/key variables: i
Accumulator variables: count, newStrings
Iterator variables: i
Python program:
def swapEvenOdd ( arr ) :
    n = len ( arr )
    o = - 1
    e = - 1
    for i in range ( n ) :
        if ( arr [ i ] < 0 ) :
            continue
        r = - 1
        if ( arr [ i ] % 2 == 0 ) :
            o += 1
            while ( arr [ o ] % 2 == 0 or arr [ o ] < 0 ) :
                o += 1
            r = o
        else :
            e += 1
            while ( arr [ e ] % 2 == 1 or arr [ e ] < 0 ) :
                e += 1
            r = e
        arr [ i ] *= - 1
        arr [ r ] *= - 1
        tmp = arr [ i ]
        arr [ i ] = arr [ r ]
        arr [ r ] = tmp
    for i in range ( n ) :
        print ( ( - 1 * arr [ i ] ) , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 3 , 2 , 4 ]
    swapEvenOdd ( arr )

Index/key variables: e, i, o, r
Iterator variables: i
Python program:
def check ( a , b , n ) :
    i , j = 0 , n - 1
    while ( i < n ) :
        if ( a [ i ] != b [ j ] ) :
            break
        i += 1
        j -= 1
        xa = a [ i : j + 1 ]
        xb = b [ i : j + 1 ]
        if ( xa == xa [ : : - 1 ] or xb == xb [ : : - 1 ] ) :
            return True
a = " xbdef "
b = " cabex "
if check ( a , b , len ( a ) ) == True or check ( b , a , len ( a ) ) == True :
    print ( True )
else :
    print ( False )

Index/key variables: i, j