dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def findElementsCrossed ( arr , a , b , n ) :
    aa = a
    ans = 0
    for i in range ( n ) :
        if ( a == 0 and b == 0 ) :
            break
        elif ( a == 0 ) :
            if ( arr [ i ] == 1 ) :
                b -= 1
                a = min ( aa , a + 1 )
            else :
                b -= 1
        elif ( b == 0 ) :
            a -= 1
        elif ( arr [ i ] == 1 and a < aa ) :
            b -= 1
            a = min ( aa , a + 1 )
        else :
            a -= 1
        ans += 1
    return ans
arr = [ 1 , 0 , 0 , 1 , 0 , 1 ]
n = len ( arr )
a = 1
b = 2
print ( findElementsCrossed ( arr , a , b , n ) )

Index/key variables: i
Accumulator variables: a, ans, b
Iterator variables: i
Python program:
def printArr ( arr , n ) :
    for i in range ( n ) :
        print ( arr [ i ] , end = " ▁ " )
def pushBinaryToBorder ( arr , n ) :
    count1 = 0
    for i in range ( n ) :
        if ( arr [ i ] != 1 ) :
            arr [ count1 ] = arr [ i ]
            count1 += 1
    while ( count1 < n ) :
        arr [ count1 ] = 1
        count1 += 1
    lastNonOne = 0
    for i in range ( n - 1 , - 1 , - 1 ) :
        if ( arr [ i ] == 1 ) :
            continue
        if ( not lastNonOne ) :
            lastNonOne = i
        if ( arr [ i ] != 0 ) :
            arr [ lastNonOne ] = arr [ i ]
            lastNonOne -= 1
    while ( lastNonOne >= 0 ) :
        arr [ lastNonOne ] = 0
        lastNonOne -= 1
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 0 , 0 , 0 , 3 , 6 ] ;
    n = len ( arr ) ;
    pushBinaryToBorder ( arr , n )
    printArr ( arr , n )

Index/key variables: count1, i, lastNonOne
Iterator variables: i
Python program:
def isVowel ( ch ) :
    if ch in [ ' a ' , ' e ' , ' i ' , ' o ' , ' u ' ] :
        return True
    else :
        return False
def vowelPairs ( s , n ) :
    cnt = 0
    for i in range ( n - 1 ) :
        if ( isVowel ( s [ i ] ) and isVowel ( s [ i + 1 ] ) ) :
            cnt += 1
    return cnt
s = " abaebio "
n = len ( s )
print ( vowelPairs ( s , n ) )

Index/key variables: i
Accumulator variables: cnt
Iterator variables: i
Python program:
def gcd ( a , b ) :
    if ( a == 0 ) :
        return b
    return gcd ( b % a , a )
def solve ( health , n ) :
    currentgcd = gcd ( health [ 0 ] , health [ 1 ] )
    for i in range ( 2 , n ) :
        currentgcd = gcd ( currentgcd , health [ i ] )
    return currentgcd
health = [ 4 , 6 , 8 , 12 ]
n = len ( health )
print ( solve ( health , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def Find_Sequence ( array , n ) :
    inc_arr , dec_arr = [ ] , [ ]
    inc , dec = - 1 , 1e7
    for i in range ( n ) :
        if inc < array [ i ] < dec :
            if array [ i ] < array [ i + 1 ] :
                inc = array [ i ]
                inc_arr . append ( array [ i ] )
            else :
                dec = array [ i ]
                dec_arr . append ( array [ i ] )
        elif inc < array [ i ] :
            inc = array [ i ]
            inc_arr . append ( array [ i ] )
        elif dec > array [ i ] :
            dec = array [ i ]
            dec_arr . append ( array [ i ] )
        else :
            print ( ' - 1' )
            break
    else :
        print ( inc_arr , dec_arr )
arr = [ 5 , 1 , 3 , 6 , 8 , 2 , 9 , 0 , 10 ]
n = len ( arr )
Find_Sequence ( arr , n )

Index/key variables: i
Accumulator variables: dec_arr, inc_arr
Iterator variables: i
Python program:
def reverse ( n ) :
    rev = 0
    while ( n != 0 ) :
        rev = ( rev * 10 ) + ( n % 10 )
        n //= 10
    return rev
def getSum ( n ) :
    n = reverse ( n )
    sumOdd = 0
    sumEven = 0
    c = 1
    while ( n != 0 ) :
        if ( c % 2 == 0 ) :
            sumEven += n % 10
        else :
            sumOdd += n % 10
        n //= 10
        c += 1
    print ( " Sum ▁ odd ▁ = " , sumOdd )
    print ( " Sum ▁ even ▁ = " , sumEven )
n = 457892
getSum ( n )

Accumulator variables: c, n, sumEven, sumOdd
Python program:
def getSum ( n ) :
    if ( n % 2 == 1 ) :
        isOdd = True
    else :
        isOdd = False
    sumOdd = 0
    sumEven = 0
    while ( n != 0 ) :
        if ( isOdd ) :
            sumOdd += n % 10
        else :
            sumEven += n % 10
        isOdd = not isOdd
        n //= 10
    print ( " Sum ▁ odd ▁ = ▁ " , sumOdd )
    print ( " Sum ▁ even ▁ = ▁ " , sumEven )
if __name__ == " _ _ main _ _ " :
    n = 457892
    getSum ( n )

Accumulator variables: n, sumEven, sumOdd
Boolean variables: isOdd
Python program:
def longestSubstring ( s ) :
    cnt = 1 ;
    maxi = 1 ;
    n = len ( s ) ;
    for i in range ( 1 , n ) :
        if ( s [ i ] != s [ i - 1 ] ) :
            cnt += 1 ;
        else :
            maxi = max ( cnt , maxi ) ;
            cnt = 1 ;
    maxi = max ( cnt , maxi ) ;
    return maxi ;
if __name__ == " _ _ main _ _ " :
    s = " ccccdeededff " ;
    print ( longestSubstring ( s ) ) ;

Index/key variables: i
Accumulator variables: cnt
Iterator variables: i
Python program:
def Minimum_Operations ( a , n ) :
    np = [ 0 for i in range ( n + 1 ) ]
    for i in range ( n - 1 , - 1 , - 1 ) :
        np [ i ] = np [ i + 1 ]
        if ( a [ i ] <= 0 ) :
            np [ i ] += 1
    pos = 0
    ans = n
    for i in range ( n - 1 ) :
        if ( a [ i ] >= 0 ) :
            pos += 1
        ans = min ( ans , pos + np [ i + 1 ] )
    return ans
a = [ - 1 , 0 , 1 , 2 ]
n = len ( a )
print ( Minimum_Operations ( a , n ) )

Index/key variables: i
Accumulator variables: pos
Iterator variables: i
Python program:
def findSumofEle ( arr1 , m , arr2 , n , k ) :
    arraySum = 0
    for i in range ( n ) :
        arraySum += arr2 [ i ]
    mean = arraySum / n
    sumOfElements = 0
    difference = 0
    for i in range ( m ) :
        difference = arr1 [ i ] - mean
        if ( ( difference < 0 ) and ( k > ( - 1 ) * difference ) ) :
            sumOfElements += arr1 [ i ]
        if ( ( difference >= 0 ) and ( k > difference ) ) :
            sumOfElements += arr1 [ i ]
    return sumOfElements
arr1 = [ 1 , 2 , 3 , 4 , 7 , 9 ]
arr2 = [ 0 , 1 , 2 , 1 , 1 , 4 ]
k = 2
m = len ( arr1 )
n = len ( arr2 )
print ( findSumofEle ( arr1 , m , arr2 , n , k ) )

Index/key variables: i
Accumulator variables: arraySum, sumOfElements
Iterator variables: i
Python program:
def findIntegers ( n , x , y ) :
    ans = [ ]
    for i in range ( n - 1 ) :
        ans . append ( 1 )
    if ( y - ( n - 1 ) <= 0 ) :
        print ( " - 1" , end = " " )
        return
    ans . append ( y - ( n - 1 ) )
    store = 0
    for i in range ( n ) :
        store += ans [ i ] * ans [ i ]
    if ( store < x ) :
        print ( " - 1" , end = " " )
        return ;
    for i in range ( n ) :
        print ( ans [ i ] , end = " ▁ " )
n , x , y = 3 , 254 , 18
findIntegers ( n , x , y )

Index/key variables: i
Accumulator variables: ans, store
Iterator variables: i
Python program:
def Minsteps ( n , m ) :
    ans = 0
    while ( m > n ) :
        if ( m & 1 ) :
            m += 1
            ans += 1
        m //= 2
        ans += 1
    return ans + n - m
n = 4
m = 6
print ( Minsteps ( n , m ) )

Accumulator variables: ans, m
Python program:
def getsum ( x ) :
    return int ( ( x * ( x + 1 ) ) / 2 )
def countJumps ( n ) :
    n = abs ( n )
    ans = 0
    while ( getsum ( ans ) < n or ( getsum ( ans ) - n ) & 1 ) :
        ans += 1
    return ans
if __name__ == ' _ _ main _ _ ' :
    n = 9
    print ( countJumps ( n ) )

Accumulator variables: ans
Python program:
def maxCandies ( arr , n ) :
    prevBought = arr [ n - 1 ] ;
    candies = prevBought ;
    for i in range ( n - 2 , - 1 , - 1 ) :
        x = min ( prevBought - 1 , arr [ i ] ) ;
        if ( x >= 0 ) :
            candies += x ;
            prevBought = x ;
    return candies ;
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 1 , 3 , 6 ] ;
    n = len ( arr )
    print ( maxCandies ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: candies
Iterator variables: i
Python program:
def isPalindrome ( s ) :
    for i in range ( len ( s ) ) :
        if ( s [ i ] != s [ len ( s ) - i - 1 ] ) :
            return False
    return true
def ans ( s ) :
    s2 = s
    for i in range ( len ( s ) ) :
        s2 = s2 [ len ( s2 ) - 1 ] + s2
        s2 = s2 [ 0 : len ( s2 ) - 1 ]
        if ( s != s2 and isPalindrome ( s2 ) ) :
            return True
    return False
def solve ( s ) :
    if ( len ( s ) <= 3 ) :
        return - 1
    cnt = [ 0 for i in range ( 26 ) ]
    for i in range ( len ( s ) ) :
        cnt [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
    max = cnt [ 0 ]
    for i in range ( len ( cnt ) ) :
        if cnt [ i ] > max :
            max = cnt [ i ]
    if ( max >= len ( s ) - 1 ) :
        return - 1
    else :
        if ans ( s ) == True :
            return 1
        else :
            return 2
if __name__ == ' _ _ main _ _ ' :
    s = " nolon "
    print ( solve ( s ) )

Index/key variables: i
Iterator variables: i
Python program:
def solveEven ( s ) :
    if len ( s ) % 2 == 1 :
        return 2
    ls = s [ 0 : len ( s ) // 2 ]
    rs = s [ len ( s ) // 2 : len ( s ) ]
    if ls != rs :
        return 1
    return solveEven ( ls )
def solveOdd ( s ) :
    return 2
def solve ( s ) :
    if len ( s ) <= 3 :
        return - 1
    cnt = [ 0 ] * 25
    for i in range ( 0 , len ( s ) ) :
        cnt [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
    if max ( cnt ) >= len ( s ) - 1 :
        return - 1
    if len ( s ) % 2 == 0 :
        return solveEven ( s )
    if len ( s ) % 2 == 1 :
        return solveOdd ( s )
if __name__ == " _ _ main _ _ " :
    s = " nolon "
    print ( solve ( s ) )

Index/key variables: i
Iterator variables: i
Python program:
def steps ( cur , x , n ) :
    if x == 0 :
        return float ( ' inf ' )
    elif x > 0 :
        return abs ( ( n - cur ) // x )
    else :
        return abs ( int ( ( cur - 1 ) / x ) )
def countSteps ( curx , cury , n , m , moves ) :
    count = 0
    k = len ( moves )
    for i in range ( 0 , k ) :
        x = moves [ i ] [ 0 ]
        y = moves [ i ] [ 1 ]
        stepct = min ( steps ( curx , x , n ) , steps ( cury , y , m ) )
        count += stepct
        curx += stepct * x
        cury += stepct * y
    return count
if __name__ == " _ _ main _ _ " :
    n , m , x , y = 4 , 5 , 1 , 1
    moves = [ [ 1 , 1 ] , [ 1 , 1 ] , [ 0 , - 2 ] ]
    print ( countSteps ( x , y , n , m , moves ) )

Index/key variables: i
Accumulator variables: count, curx, cury
Iterator variables: i
Python program:
def minimumRemoval ( n , a ) :
    c = dict . fromkeys ( a , 0 ) ;
    for i in range ( n ) :
        c [ a [ i ] ] += 1 ;
    ans = 0 ;
    for i in range ( n ) :
        ok = False ;
        for j in range ( 31 ) :
            x = ( 1 << j ) - a [ i ] ;
            if ( x in c and ( c [ x ] > 1 or ( c [ x ] == 1 and x != a [ i ] ) ) ) :
                ok = True ;
                break ;
        if ( not ok ) :
            ans += 1 ;
    return ans ;
if __name__ == " _ _ main _ _ " :
    a = [ 4 , 7 , 1 , 5 , 4 , 9 ] ;
    n = len ( a ) ;
    print ( minimumRemoval ( n , a ) ) ;

Index/key variables: i, x
Accumulator variables: ans
Iterator variables: i, j
Boolean variables: ok
Python program:
def min_elimination ( n , arr ) :
    count = 0
    prev_val = arr [ 0 ]
    for i in range ( 1 , n ) :
        curr_val = arr [ i ] ;
        if ( curr_val % 2 == prev_val % 2 ) :
            count = count + 1
        prev_val = curr_val
    return count
arr = [ 1 , 2 , 3 , 7 , 9 ]
n = len ( arr )
print ( min_elimination ( n , arr ) ) ;

Index/key variables: i
Iterator variables: i
Python program:
def getCount ( N ) :
    if ( N % 2 == 1 ) :
        return "0"
    result = "9"
    for i in range ( 1 , N // 2 ) :
        result = result + "0"
    return result
N = 4
print ( getCount ( N ) )

Iterator variables: i
Python program:
def canFormTeam ( n , m ) :
    if ( n >= 1 and m >= 2 ) :
        return True
    if ( m >= 1 and n >= 2 ) :
        return True
    return False
def maxTeams ( n , m ) :
    count = 0
    while ( canFormTeam ( n , m ) ) :
        if ( n > m ) :
            n -= 2
            m -= 1
        else :
            m -= 2
            n -= 1
        count += 1
    return count
if __name__ == ' _ _ main _ _ ' :
    n = 4
    m = 5
    print ( maxTeams ( n , m ) )

Accumulator variables: count, m, n
Python program:
import math as mt
def find_rectangle ( area ) :
    l , b = 0 , 0
    M = mt . ceil ( mt . sqrt ( area ) )
    ans = 0
    for i in range ( M , 0 , - 1 ) :
        if ( area % i == 0 ) :
            l = ( area // i )
            b = i
            break
    print ( " l ▁ = " , l , " , ▁ b ▁ = " , b )
area = 99
find_rectangle ( area )

Iterator variables: i
Python program:
import math
def find_rectangle ( area ) :
    for i in range ( int ( math . ceil ( math . sqrt ( area ) ) ) , area + 1 ) :
        if ( ( int ( area / i ) * i ) == area ) :
            print ( i , int ( area / i ) )
            return
area = 99
find_rectangle ( area )

Iterator variables: i
Python program:
import math as mt
def sizeSubSet ( a , k , n ) :
    a . sort ( )
    s = set ( )
    for i in range ( n ) :
        if ( a [ i ] % k != 0 or a [ i ] // k not in s ) :
            s . add ( a [ i ] )
    return len ( s )
a = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]
n = len ( a )
k = 2
print ( sizeSubSet ( a , k , n ) )

Index/key variables: i
Accumulator variables: s
Iterator variables: i
Python program:
import math as mt
def minimumSets ( s , y ) :
    cnt = 0
    num = 0
    l = len ( s )
    f = 0
    for i in range ( l ) :
        num = num * 10 + ( ord ( s [ i ] ) - ord ( '0' ) )
        if ( num <= y ) :
            f = 1
            if ( f ) :
                cnt += 1
            num = ord ( s [ i ] ) - ord ( '0' )
            f = 0
            if ( num <= y ) :
                f = 1
            else :
                num = 0
    if ( f ) :
        cnt += 1
    return cnt
s = "1234"
y = 30
print ( minimumSets ( s , y ) )

Index/key variables: i
Accumulator variables: cnt
Iterator variables: i
Python program:
import sys
def printArr ( b , n ) :
    for i in range ( 0 , n , 1 ) :
        print ( b [ i ] , end = " ▁ " )
def ModifiedArray ( a , n ) :
    l = 0
    r = sys . maxsize
    b = [ 0 for i in range ( n ) ]
    for i in range ( 0 , int ( n / 2 ) , 1 ) :
        b [ i ] = max ( l , a [ i ] - r )
        b [ n - i - 1 ] = a [ i ] - b [ i ]
        l = b [ i ]
        r = b [ n - i - 1 ]
    printArr ( b , n )
if __name__ == ' _ _ main _ _ ' :
    a = [ 5 , 6 ]
    n = len ( a )
    ModifiedArray ( a , 2 * n )

Index/key variables: i
Iterator variables: i
Python program:
def numberOfLines ( S , widths ) :
    if ( S == " " ) :
        return 0 , 0
    lines , width = 1 , 0
    for c in S :
        w = widths [ ord ( c ) - ord ( ' a ' ) ]
        width += w
        if width > 10 :
            lines += 1
            width = w
    return lines , width
S = " bbbcccdddaa "
Widths = [ 4 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ]
print ( numberOfLines ( S , Widths ) )

Accumulator variables: lines, width
Iterator variables: c
Python program:
import collections
def canReorder ( A ) :
    count = collections . Counter ( A )
    for x in sorted ( A , key = abs ) :
        if count [ x ] == 0 :
            continue
        if count [ 2 * x ] == 0 :
            return False
        count [ x ] -= 1
        count [ 2 * x ] -= 1
    return True
A = [ 4 , - 2 , 2 , - 4 ]
print ( canReorder ( A ) )

Index/key variables: x
Iterator variables: x
Python program:
import sys
def maxSubArraySum ( a , size ) :
    max_so_far = - ( sys . maxsize - 1 )
    max_ending_here = 0
    for i in range ( size ) :
        max_ending_here = max_ending_here + a [ i ]
        if ( max_so_far < max_ending_here ) :
            max_so_far = max_ending_here
        if ( max_ending_here < 0 ) :
            max_ending_here = 0
    return max_so_far
def maxSum ( a , n ) :
    S = 0 ;
    S1 = maxSubArraySum ( a , n )
    for i in range ( n ) :
        S += a [ i ]
    return ( 2 * S1 - S )
if __name__ == " _ _ main _ _ " :
    a = [ - 35 , 32 , - 24 , 0 , 27 , - 10 , 0 , - 19 ]
    n = len ( a )
    print ( maxSum ( a , n ) )

Index/key variables: i
Accumulator variables: S
Iterator variables: i
Python program:
def minimizeDiff ( arr , n , k ) :
    max_element = max ( arr )
    min_element = min ( arr )
    if ( ( max_element - min_element ) <= k ) :
        return ( max_element - min_element )
    avg = ( max_element + min_element ) // 2
    for i in range ( n ) :
        if ( arr [ i ] > avg ) :
            arr [ i ] -= k
        else :
            arr [ i ] += k
    max_element = max ( arr )
    min_element = min ( arr )
    return ( max_element - min_element ) ;
if __name__ == " _ _ main _ _ " :
    arr = [ 3 , 16 , 12 , 9 , 20 ]
    n = 5
    k = 3
    print ( " Max ▁ height ▁ difference ▁ = " , minimizeDiff ( arr , n , k ) )

Index/key variables: i
Iterator variables: i
Python program:
def leastValue ( P , A , N , a ) :
    ans = - 1
    tmp = float ( ' inf ' )
    for i in range ( N ) :
        t = P - a [ i ] * 0.006
        if abs ( t - A ) < tmp :
            tmp = abs ( t - A )
            ans = i
    return a [ ans ]
N , P , A = 2 , 12 , 5
a = [ 1000 , 2000 ]
print ( leastValue ( P , A , N , a ) )

Index/key variables: ans, i
Iterator variables: i
Python program:
from math import log10 , ceil , pow
def findPermutation ( n ) :
    len = ceil ( log10 ( n ) )
    for i in range ( 0 , len , 1 ) :
        if n % 2 != 0 :
            return n
        else :
            n = ( ( n / 10 ) + ( n % 10 ) * pow ( 10 , len - i - 1 ) )
            continue
    return - 1
if __name__ == ' _ _ main _ _ ' :
    n = 132
    print ( int ( findPermutation ( n ) ) )

Iterator variables: i
Python program:
n = 3
m = 4
def maxMatrixScore ( A , K ) :
    update = { }
    for i in range ( 0 , n ) :
        if A [ i ] [ 0 ] == 0 :
            ans = 0
            for j in range ( 1 , m ) :
                ans = ans + A [ i ] [ j ] * 2 ** ( m - j - 1 )
            update [ ans ] = i
    for idx in update . values ( ) :
        for j in range ( 0 , m ) :
            A [ idx ] [ j ] = ( A [ idx ] [ j ] + 1 ) % 2
        K -= 1
        if K <= 0 :
            break
    ans = 0
    for j in range ( 0 , m ) :
        zero , one = 0 , 0
        for i in range ( 0 , n ) :
            if A [ i ] [ j ] == 0 : zero += 1
            else : one += 1
        if K > 0 and zero > one :
            ans += zero * 2 ** ( m - j - 1 )
            K -= 1
        else :
            ans += one * 2 ** ( m - j - 1 )
    return ans
if __name__ == " _ _ main _ _ " :
    A = [ [ 0 , 0 , 1 , 1 ] , [ 1 , 0 , 1 , 0 ] , [ 1 , 1 , 0 , 0 ] ]
    K = 2
    print ( maxMatrixScore ( A , K ) )

Index/key variables: ans, i, idx, j
Accumulator variables: K, one, zero
Iterator variables: i, idx, j
Python program:
def isSellingPossible ( n , a ) :
    c25 = 0 ;
    c50 = 0 ;
    i = 0 ;
    while ( i < n ) :
        if ( a [ i ] == 25 ) :
            c25 += 1 ;
        elif ( a [ i ] == 50 ) :
            c50 += 1 ;
            if ( c25 == 0 ) :
                break ;
            c25 -= 1 ;
        else :
            if ( c50 > 0 and c25 > 0 ) :
                c50 -= 1 ;
                c25 -= 1 ;
            elif ( c25 >= 3 ) :
                c25 -= 3 ;
            else :
                break ;
        i += 1 ;
    if ( i == n ) :
        return True ;
    else :
        return False ;
a = [ 25 , 25 , 50 , 100 ] ;
n = len ( a ) ;
if ( isSellingPossible ( n , a ) ) :
    print ( " YES " ) ;
else :
    print ( " NO " ) ;

Index/key variables: i
Accumulator variables: c25, c50
Python program:
def checkIfOverlap ( str ) :
    length = len ( str )
    visited = [ 0 ] * ( length + 1 )
    for i in range ( length ) :
        if str [ i ] == " . " :
            continue
        for j in range ( max ( 0 , i - ord ( str [ i ] ) , min ( length , i + ord ( str [ i ] ) ) + 1 ) ) :
            visited [ j ] += 1
    for i in range ( length ) :
        if visited [ i ] > 1 :
            return True
    return False
if __name__ == " _ _ main _ _ " :
    str = " . 2 . . 2 . "
    if checkIfOverlap ( str ) :
        print ( " YES " )
    else :
        print ( " NO " )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def isCorrectOrder ( n ) :
    flag = True ;
    prev = - 1 ;
    type = - 1 ;
    while ( n != 0 ) :
        if ( type == - 1 ) :
            if ( prev == - 1 ) :
                prev = n % 10 ;
                n = int ( n / 10 ) ;
                continue ;
            if ( prev == n % 10 ) :
                flag = False ;
                break ;
            if ( prev > n % 10 ) :
                type = 1 ;
                prev = n % 10 ;
                n = int ( n / 10 ) ;
                continue ;
            prev = n % 10 ;
            n = int ( n / 10 ) ;
        else :
            if ( prev == n % 10 ) :
                flag = False ;
                break ;
            if ( prev < n % 10 ) :
                flag = False ;
                break ;
            prev = n % 10 ;
            n = int ( n / 10 ) ;
    return flag ;
n = 123454321 ;
if ( isCorrectOrder ( n ) ) :
    print ( " YES " ) ;
else :
    print ( " NO " ) ;

Boolean variables: flag
Python program:
def printCoins ( arr , n ) :
    oddSum = 0
    for i in range ( 0 , n , 2 ) :
        oddSum += arr [ i ]
    evenSum = 0
    for i in range ( 1 , n , 2 ) :
        evenSum += arr [ i ]
    if oddSum > evenSum :
        start = 0
    else :
        start = 1
    for i in range ( start , n , 2 ) :
        print ( arr [ i ] , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    arr1 = [ 8 , 15 , 3 , 7 ]
    n = len ( arr1 )
    printCoins ( arr1 , n )
    print ( )
    arr2 = [ 2 , 2 , 2 , 2 ]
    n = len ( arr2 )
    printCoins ( arr2 , n )
    print ( )
    arr3 = [ 20 , 30 , 2 , 2 , 2 , 10 ]
    n = len ( arr3 )
    printCoins ( arr3 , n )

Index/key variables: i
Accumulator variables: evenSum, oddSum
Iterator variables: i
Python program:
from sys import maxsize
INT_MAX = maxsize
V = 5
def isValidEdge ( u , v , inMST ) :
    if u == v :
        return False
    if inMST [ u ] == False and inMST [ v ] == False :
        return False
    elif inMST [ u ] == True and inMST [ v ] == True :
        return False
    return True
def primMST ( cost ) :
    inMST = [ False ] * V
    inMST [ 0 ] = True
    edge_count = 0
    mincost = 0
    while edge_count < V - 1 :
        minn = INT_MAX
        a = - 1
        b = - 1
        for i in range ( V ) :
            for j in range ( V ) :
                if cost [ i ] [ j ] < minn :
                    if isValidEdge ( i , j , inMST ) :
                        minn = cost [ i ] [ j ]
                        a = i
                        b = j
        if a != - 1 and b != - 1 :
            print ( " Edge ▁ % d : ▁ ( % d , ▁ % d ) ▁ cost : ▁ % d " % ( edge_count , a , b , minn ) )
            edge_count += 1
            mincost += minn
            inMST [ b ] = inMST [ a ] = True
    print ( " Minimum ▁ cost ▁ = ▁ % d " % mincost )
if __name__ == " _ _ main _ _ " :
    cost = [ [ INT_MAX , 2 , INT_MAX , 6 , INT_MAX ] , [ 2 , INT_MAX , 3 , 8 , 5 ] , [ INT_MAX , 3 , INT_MAX , INT_MAX , 7 ] , [ 6 , 8 , INT_MAX , INT_MAX , 9 ] , [ INT_MAX , 5 , 7 , 9 , INT_MAX ] ]
    primMST ( cost )

Index/key variables: a, b, i, j, u, v
Accumulator variables: edge_count, mincost
Iterator variables: i, j
Python program:
def findLandB ( arr , n ) :
    arr . sort ( reverse = False )
    arr_pairs = [ ]
    for i in range ( n - 1 ) :
        if ( arr [ i ] == arr [ i + 1 ] ) :
            arr_pairs . append ( arr [ i ] )
            i += 1
    length = arr_pairs [ 0 ]
    breadth = arr_pairs [ 1 ]
    size = len ( arr_pairs )
    for i in range ( 1 , size - 1 ) :
        if ( ( int ( length / breadth ) + int ( breadth / length ) ) > ( int ( arr_pairs [ i ] / arr_pairs [ i - 1 ] ) + int ( arr_pairs [ i - 1 ] / arr_pairs [ i ] ) ) ) :
            length = arr_pairs [ i ]
            breadth = arr_pairs [ i - 1 ]
    print ( length , " , " , breadth )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 4 , 2 , 2 , 2 , 5 , 6 , 5 , 6 , 7 , 2 ]
    n = len ( arr )
    findLandB ( arr , n )

Index/key variables: i
Accumulator variables: arr_pairs
Iterator variables: i