dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def largeProduct ( A , B , N ) :
    if ( N == 0 ) :
        return 0
    pq = [ ]
    for i in range ( N ) :
        pq . append ( A [ i ] )
    B . sort ( )
    pq . sort ( reverse = True )
    for i in range ( N ) :
        minn = pq . pop ( )
        maximized_element = max ( minn * B [ i ] , minn + B [ i ] )
        pq . append ( maximized_element )
        pq . sort ( reverse = True )
    max_product = 1
    while ( len ( pq ) > 0 ) :
        max_product *= pq . pop ( ) ;
    return max_product
A = [ 1 , 1 , 10 ]
B = [ 1 , 1 , 1 ]
N = 3
print ( largeProduct ( A , B , N ) )

Index/key variables: i
Accumulator variables: max_product, pq
Iterator variables: i
Python program:
MAX_PATH_SIZE = 1000
class Node :
    def __init__ ( self , x ) :
        self . data = x
        self . left = None
        self . right = None
def printPath ( size ) :
    minimum_Hd = 10 ** 19
    p = [ ]
    global Allpaths
    for it in range ( size ) :
        p = Allpaths [ it ]
        minimum_Hd = min ( minimum_Hd , p [ 0 ] )
    for it in range ( size ) :
        p = Allpaths [ it ]
        noOfUnderScores = abs ( p [ 0 ] - minimum_Hd )
        for i in range ( noOfUnderScores ) :
            print ( end = " _ ▁ " )
        print ( p [ 1 ] )
    print ( " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = " )
def printAllPathsUtil ( root , HD , order ) :
    global Allpaths
    if ( root == None ) :
        return
    if ( root . left == None and root . right == None ) :
        Allpaths [ order ] = [ HD , root . data ]
        printPath ( order + 1 )
        return
    Allpaths [ order ] = [ HD , root . data ]
    printAllPathsUtil ( root . left , HD - 1 , order + 1 )
    printAllPathsUtil ( root . right , HD + 1 , order + 1 )
def printAllPaths ( root ) :
    global Allpaths
    if ( root == None ) :
        return
    printAllPathsUtil ( root , 0 , 0 )
if __name__ == ' _ _ main _ _ ' :
    Allpaths = [ [ 0 , 0 ] for i in range ( MAX_PATH_SIZE ) ]
    root = Node ( ' A ' )
    root . left = Node ( ' B ' )
    root . right = Node ( ' C ' )
    root . left . left = Node ( ' D ' )
    root . left . right = Node ( ' E ' )
    root . right . left = Node ( ' F ' )
    root . right . right = Node ( ' G ' )
    printAllPaths ( root )

Index/key variables: it, order
Iterator variables: i, it
Class/struct names: Node
Python program:
def minsteps ( arr , n ) :
    arr . sort ( )
    ans = 0
    for i in range ( n ) :
        ans += abs ( arr [ i ] - pow ( 2 , i ) )
    return ans
arr = [ 1 , 8 , 2 , 10 , 6 ]
n = len ( arr )
print ( minsteps ( arr , n ) )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def leftRotate ( arr , d , n ) :
    leftRotateRec ( arr , 0 , d , n ) ;
def leftRotateRec ( arr , i , d , n ) :
    if ( d == 0 or d == n ) :
        return ;
    if ( n - d == d ) :
        swap ( arr , i , n - d + i , d ) ;
        return ;
    if ( d < n - d ) :
        swap ( arr , i , n - d + i , d ) ;
        leftRotateRec ( arr , i , d , n - d ) ;
    else :
        swap ( arr , i , d , n - d ) ;
        leftRotateRec ( arr , n - d + i , 2 * d - n , d ) ;
def printArray ( arr , size ) :
    for i in range ( size ) :
        print ( arr [ i ] , end = " ▁ " ) ;
    print ( ) ;
def swap ( arr , fi , si , d ) :
    for i in range ( d ) :
        temp = arr [ fi + i ] ;
        arr [ fi + i ] = arr [ si + i ] ;
        arr [ si + i ] = temp ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 ] ;
    leftRotate ( arr , 2 , 7 ) ;
    printArray ( arr , 7 ) ;

Index/key variables: i
Iterator variables: i
Python program:
def findCost ( a , n ) :
    a . sort ( reverse = True )
    count = 0
    for j in range ( n ) :
        p = a [ j ] - j
        a [ j ] = 0
        if ( p < 0 ) :
            p = 0
            continue
        count += p
    return count
arr = [ 1 , 6 , 7 , 4 , 2 , 5 , 3 ]
N = len ( arr )
print ( findCost ( arr , N ) )

Index/key variables: j
Accumulator variables: count
Iterator variables: j
Python program:
def leftRotate ( arr , d , n ) :
    if ( d == 0 or d == n ) :
        return ;
    i = d
    j = n - d
    while ( i != j ) :
        if ( i < j ) :
            swap ( arr , d - i , d + j - i , i )
            j -= i
        else :
            swap ( arr , d - i , d , j )
            i -= j
    swap ( arr , d - i , d , i )

Accumulator variables: i, j
Python program:
def countPairs ( arr , n ) :
    ans = 0
    count = { }
    for i in range ( n ) :
        if arr [ i ] in count :
            ans += count [ arr [ i ] ]
        if arr [ i ] in count :
            count [ arr [ i ] ] += 1
        else :
            count [ arr [ i ] ] = 1
    return ans
arr = [ 1 , 2 , 1 , 1 ]
N = len ( arr )
print ( countPairs ( arr , N ) )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def bfs ( x , s ) :
    global edges , dist
    q = [ 0 for i in range ( 200000 ) ]
    qh , qt = 0 , 0
    q [ qh ] = s
    qh += 1
    dist [ x ] [ s ] = 0
    while ( qt < qh ) :
        xx = q [ qt ]
        qt += 1
        for y in edges [ xx ] :
            if ( dist [ x ] [ y ] == 10 ** 18 ) :
                dist [ x ] [ y ] = dist [ x ] [ xx ] + 1
                q [ qh ] = y
                qh += 1
def shortestPathCost ( selected , K ) :
    global dist , edges
    data = [ ]
    bfs ( 0 , 0 )
    bfs ( 1 , N - 1 )
    for i in range ( K ) :
        data . append ( [ dist [ 0 ] [ selected [ i ] ] - dist [ 1 ] [ selected [ i ] ] , selected [ i ] ] )
    data = sorted ( data )
    best = 0
    MAX = - 10 ** 18
    for it in data :
        a = it [ 1 ]
        best = max ( best , MAX + dist [ 1 ] [ a ] )
        MAX = max ( MAX , dist [ 0 ] [ a ] )
    print ( min ( dist [ 0 ] [ N - 1 ] , best + 1 ) )
if __name__ == ' _ _ main _ _ ' :
    edges = [ [ ] for i in range ( 5 ) ]
    dist = [ [ 10 ** 18 for i in range ( 1000005 ) ] for i in range ( 2 ) ]
    N , M = 5 , 4
    K = 2
    selected = [ 1 , 3 ]
    selected = sorted ( selected )
    edges [ 0 ] . append ( 1 )
    edges [ 1 ] . append ( 0 )
    edges [ 1 ] . append ( 2 )
    edges [ 2 ] . append ( 1 )
    edges [ 2 ] . append ( 3 )
    edges [ 3 ] . append ( 2 )
    edges [ 3 ] . append ( 4 )
    edges [ 4 ] . append ( 3 )
    shortestPathCost ( selected , K )

Index/key variables: a, i, qh, qt, s, x, xx, y
Accumulator variables: data
Iterator variables: i, it, y
Python program:
def removeElements ( arr , n ) :
    arr . sort ( reverse = True )
    ans = 0
    for i in range ( n ) :
        ans += arr [ i ] * pow ( 2 , i )
    return ans
if __name__ == " _ _ main _ _ " :
    n = 4
    arr = [ 3 , 1 , 2 , 3 ]
    print ( removeElements ( arr , n ) )

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def printMatrix ( grid , m , n ) :
    A = [ ]
    for i in range ( m ) :
        for j in range ( n ) :
            if j == n - 1 or ( i == m - 1 ) or j == 0 or i == 0 :
                A . append ( grid [ i ] [ j ] )
    A . sort ( )
    print ( * A [ : n ] )
    for i in range ( m - 2 ) :
        print ( A [ len ( A ) - i - 1 ] , end = " ▁ " )
        for j in range ( 1 , n - 1 ) :
            print ( grid [ i + 1 ] [ j ] , end = " ▁ " )
        print ( A [ n + i ] )
    print ( * reversed ( A [ n + m - 2 : n + m - 2 + n ] ) )
m , n = 4 , 5
grid = [ [ 1 , 2 , 3 , 4 , 0 ] , [ 1 , 1 , 1 , 1 , 2 ] , [ 1 , 2 , 2 , 2 , 4 ] , [ 1 , 9 , 3 , 1 , 7 ] ]
printMatrix ( grid , m , n )

Index/key variables: i, j
Accumulator variables: A
Iterator variables: i, j
Python program:
def findLargest ( s ) :
    Len = len ( s )
    loccur = [ - 1 for i in range ( 26 ) ]
    for i in range ( Len - 1 , - 1 , - 1 ) :
        chI = ord ( s [ i ] ) - ord ( ' a ' )
        if ( loccur [ chI ] == - 1 ) :
            loccur [ chI ] = i
    sorted_s = sorted ( s , reverse = True )
    for i in range ( Len ) :
        if ( s [ i ] != sorted_s [ i ] ) :
            chI = ( ord ( sorted_s [ i ] ) - ord ( ' a ' ) )
            last_occ = loccur [ chI ]
            temp = list ( s )
            temp [ i ] , temp [ last_occ ] = ( temp [ last_occ ] , temp [ i ] )
            s = " " . join ( temp )
            break
    return s
s = " yrstvw "
print ( findLargest ( s ) )

Index/key variables: chI, i, last_occ
Iterator variables: i
Python program:
def pairInSortedRotated ( arr , n , x ) :
    for i in range ( 0 , n - 1 ) :
        if ( arr [ i ] > arr [ i + 1 ] ) :
            break ;
    l = ( i + 1 ) % n
    r = i
    while ( l != r ) :
        if ( arr [ l ] + arr [ r ] == x ) :
            return True ;
        if ( arr [ l ] + arr [ r ] < x ) :
            l = ( l + 1 ) % n ;
        else :
            r = ( n + r - 1 ) % n ;
    return False ;
arr = [ 11 , 15 , 6 , 8 , 9 , 10 ]
sum = 16
n = len ( arr )
if ( pairInSortedRotated ( arr , n , sum ) ) :
    print ( " Array ▁ has ▁ two ▁ elements ▁ with ▁ sum ▁ 16" )
else :
    print ( " Array ▁ doesn ' t ▁ have ▁ two ▁ elements ▁ with ▁ sum ▁ 16 ▁ " )

Index/key variables: i, l, r
Iterator variables: i
Python program:
def pairsInSortedRotated ( arr , n , x ) :
    for i in range ( n ) :
        if arr [ i ] > arr [ i + 1 ] :
            break
    l = ( i + 1 ) % n
    r = i
    cnt = 0
    while ( l != r ) :
        if arr [ l ] + arr [ r ] == x :
            cnt += 1
            if l == ( r - 1 + n ) % n :
                return cnt
            l = ( l + 1 ) % n
            r = ( r - 1 + n ) % n
        elif arr [ l ] + arr [ r ] < x :
            l = ( l + 1 ) % n
        else :
            r = ( n + r - 1 ) % n
    return cnt
arr = [ 11 , 15 , 6 , 7 , 9 , 10 ]
s = 16
print ( pairsInSortedRotated ( arr , 6 , s ) )

Index/key variables: i, l, r
Accumulator variables: cnt
Iterator variables: i
Python program:
class newNode :
    def __init__ ( self , data ) :
        self . data = data
        self . left = self . right = None
def printOddNodes ( root , isOdd = True ) :
    if ( root == None ) :
        return
    if ( isOdd ) :
        print ( root . data , end = " ▁ " )
    printOddNodes ( root . left , not isOdd )
    printOddNodes ( root . right , not isOdd )
if __name__ == ' _ _ main _ _ ' :
    root = newNode ( 1 )
    root . left = newNode ( 2 )
    root . right = newNode ( 3 )
    root . left . left = newNode ( 4 )
    root . left . right = newNode ( 5 )
    printOddNodes ( root )

Class/struct names: newNode
Python program:
import sys
def maxSum ( arr , n ) :
    res = - sys . maxsize
    for i in range ( 0 , n ) :
        curr_sum = 0
        for j in range ( 0 , n ) :
            index = int ( ( i + j ) % n )
            curr_sum += j * arr [ index ]
        res = max ( res , curr_sum )
    return res
arr = [ 8 , 3 , 1 , 2 ]
n = len ( arr )
print ( maxSum ( arr , n ) )

Index/key variables: index
Accumulator variables: curr_sum
Iterator variables: i, j
Python program:
def maxSum ( arr , n ) :
    cum_sum = 0
    for i in range ( 0 , n ) :
        cum_sum += arr [ i ]
    curr_val = 0
    for i in range ( 0 , n ) :
        curr_val += i * arr [ i ]
    res = curr_val
    for i in range ( 1 , n ) :
        next_val = ( curr_val - ( cum_sum - arr [ i - 1 ] ) + arr [ i - 1 ] * ( n - 1 ) )
        curr_val = next_val
        res = max ( res , next_val )
    return res
arr = [ 8 , 3 , 1 , 2 ]
n = len ( arr )
print ( maxSum ( arr , n ) )

Index/key variables: i
Accumulator variables: cum_sum, curr_val
Iterator variables: i
Python program:
def countRotations ( arr , n ) :
    min = arr [ 0 ]
    for i in range ( 0 , n ) :
        if ( min > arr [ i ] ) :
            min = arr [ i ]
            min_index = i
    return min_index ;
arr = [ 15 , 18 , 2 , 3 , 6 , 12 ]
n = len ( arr )
print ( countRotations ( arr , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def countRotations ( arr , low , high ) :
    if ( high < low ) :
        return 0
    if ( high == low ) :
        return low
    mid = low + ( high - low ) / 2 ;
    mid = int ( mid )
    if ( mid < high and arr [ mid + 1 ] < arr [ mid ] ) :
        return ( mid + 1 )
    if ( mid > low and arr [ mid ] < arr [ mid - 1 ] ) :
        return mid
    if ( arr [ high ] > arr [ mid ] ) :
        return countRotations ( arr , low , mid - 1 ) ;
    return countRotations ( arr , mid + 1 , high )
arr = [ 15 , 18 , 2 , 3 , 6 , 12 ]
n = len ( arr )
print ( countRotations ( arr , 0 , n - 1 ) )

Index/key variables: high, mid
Python program:
def preprocess ( arr , n ) :
    temp = [ None ] * ( 2 * n )
    for i in range ( n ) :
        temp [ i ] = temp [ i + n ] = arr [ i ]
    return temp
def leftRotate ( arr , n , k , temp ) :
    start = k % n
    for i in range ( start , start + n ) :
        print ( temp [ i ] , end = " ▁ " )
    print ( " " )
arr = [ 1 , 3 , 5 , 7 , 9 ]
n = len ( arr )
temp = preprocess ( arr , n )
k = 2
leftRotate ( arr , n , k , temp )
k = 3
leftRotate ( arr , n , k , temp )
k = 4
leftRotate ( arr , n , k , temp )

Index/key variables: i
Iterator variables: i
Python program:
def Desired_Array ( v ) :
    n = len ( v )
    v . sort ( )
    i = n - 1
    while ( i > 0 ) :
        p = v [ n - 1 ]
        for j in range ( n - 1 , i - 1 , - 1 ) :
            v [ j ] = v [ j - 1 ]
        v [ i ] = p
        i -= 1
    for x in v :
        print ( x , end = " ▁ " )
    print ( )
v = [ 1 , 2 , 3 , 4 , 5 ]
Desired_Array ( v )
v1 = [ 1 , 12 , 2 , 10 , 4 , 16 , 6 ]
Desired_Array ( v1 )

Index/key variables: i, j
Iterator variables: j, x
Python program:
def leftRotate ( arr , n , k ) :
    for i in range ( k , k + n ) :
        print ( str ( arr [ i % n ] ) , end = " ▁ " )
arr = [ 1 , 3 , 5 , 7 , 9 ]
n = len ( arr )
k = 2 ;
leftRotate ( arr , n , k )
print ( )
k = 3 ;
leftRotate ( arr , n , k )
print ( )
k = 4
leftRotate ( arr , n , k )
print ( )

Iterator variables: i
Python program:
from sys import maxsize
from collections import deque
INT_MIN = - maxsize
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . left = None
        self . right = None
def findLevel ( root : Node , data : int ) -> int :
    if ( data < root . data ) :
        return - 1
    if ( data == root . data ) :
        return 0
    cur_level = 0
    while True :
        cur_level += 1
        root = root . left
        if ( root . data == data ) :
            return - 2
        if ( root . data < data and ( root . left == None or root . left . data > data ) ) :
            break
    return cur_level
def traversePath ( root : Node , path : list ) -> int :
    for i in range ( len ( path ) ) :
        direction = path [ i ]
        if ( direction == 0 ) :
            if ( root . left == None ) :
                return - 1
            root = root . left
        else :
            if ( root . right == None ) :
                return - 1
            root = root . right
    return root . data
def generateGray ( n : int , x : int ) -> list :
    gray = [ ]
    i = 0
    while ( x > 0 ) :
        gray . append ( x % 2 )
        x = x / 2
        i += 1
    gray . reverse ( )
    for j in range ( n - i ) :
        gray . insert ( 0 , gray [ 0 ] )
    return gray
def binarySearch ( root : Node , start : int , end : int , data : int , level : int ) -> bool :
    if ( end >= start ) :
        mid = ( start + end ) / 2
        encoding = generateGray ( level , mid )
        element_found = traversePath ( root , encoding )
        if ( element_found == - 1 ) :
            return binarySearch ( root , start , mid - 1 , data , level )
        if ( element_found == data ) :
            return True
        if ( element_found < data ) :
            return binarySearch ( root , mid + 1 , end , data , level )
        else :
            return binarySearch ( root , start , mid - 1 , data , level )
    return False
def findKey ( root : Node , data : int ) -> bool :
    level = findLevel ( root , data )
    if ( level == - 1 ) :
        return False
    if ( level == - 2 ) :
        return True
    return binarySearch ( root , 0 , int ( pow ( 2 , level ) - 1 ) , data , level )
if __name__ == " _ _ main _ _ " :
    root = Node ( 5 )
    root . left = Node ( 8 )
    root . right = Node ( 10 )
    root . left . left = Node ( 13 )
    root . left . right = Node ( 23 )
    root . right . left = Node ( 25 )
    root . right . right = Node ( 30 )
    root . left . left . left = Node ( 32 )
    root . left . left . right = Node ( 40 )
    root . left . right . left = Node ( 50 )
    arr = [ 5 , 8 , 9 ]
    n = len ( arr )
    for i in range ( n ) :
        if ( findKey ( root , arr [ i ] ) ) :
            print ( " Yes " )
        else :
            print ( " No " )

Index/key variables: i
Accumulator variables: cur_level, gray
Iterator variables: i, j
Class/struct names: Node
Python program:
MAX = 1000
def ToSpiral ( m , n , Sorted , a ) :
    index = 0
    k = 0
    l = 0
    while ( k < m and l < n ) :
        for i in range ( l , n , 1 ) :
            a [ k ] [ i ] = Sorted [ index ]
            index += 1
        k += 1
        for i in range ( k , m , 1 ) :
            a [ i ] [ n - 1 ] = Sorted [ index ]
            index += 1
        n -= 1
        if ( k < m ) :
            i = n - 1
            while ( i >= l ) :
                a [ m - 1 ] [ i ] = Sorted [ index ]
                index += 1
                i -= 1
            m -= 1
        if ( l < n ) :
            i = m - 1
            while ( i >= k ) :
                a [ i ] [ l ] = Sorted [ index ]
                index += 1
                i -= 1
            l += 1
def convert2Dto1D ( y , m , n ) :
    index = 0
    x = [ 0 for i in range ( m * n ) ]
    for i in range ( m ) :
        for j in range ( n ) :
            x [ index ] = y [ i ] [ j ]
            index += 1
    return x
def PrintMatrix ( a , m , n ) :
    for i in range ( m ) :
        for j in range ( n ) :
            print ( a [ i ] [ j ] , end = " ▁ " )
        print ( ' ' , end = " " )
def SortArray ( x ) :
    x . sort ( reverse = False )
    return x
def convertMatrixToSortedSpiral ( y , m , n ) :
    a = [ [ 0 for i in range ( MAX ) ] for j in range ( MAX ) ]
    x = [ 0 for i in range ( 15 ) ]
    x = convert2Dto1D ( y , m , n )
    x = SortArray ( x )
    ToSpiral ( m , n , x , a )
    PrintMatrix ( a , m , n )
if __name__ == ' _ _ main _ _ ' :
    m = 4
    n = 3
    y = [ [ 2 , 5 , 12 ] , [ 22 , 45 , 55 ] , [ 1 , 6 , 8 ] , [ 13 , 56 , 10 ] ]
    convertMatrixToSortedSpiral ( y , m , n )

Index/key variables: i, index, j, k, l
Accumulator variables: m, n
Iterator variables: i, j
Python program:
def reverseArray ( arr , start , end ) :
    while ( start < end ) :
        arr [ start ] , arr [ end ] = arr [ end ] , arr [ start ]
        start = start + 1
        end = end - 1
def rightRotate ( arr , d , n ) :
    reverseArray ( arr , 0 , n - 1 ) ;
    reverseArray ( arr , 0 , d - 1 ) ;
    reverseArray ( arr , d , n - 1 ) ;
def prArray ( arr , size ) :
    for i in range ( 0 , size ) :
        print ( arr [ i ] , end = ' ▁ ' )
arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]
n = len ( arr )
k = 3
rightRotate ( arr , k , n )
prArray ( arr , n )

Index/key variables: end, i, start
Iterator variables: i
Python program:
class newNode :
    def __init__ ( self , data ) :
        self . data = data
        self . left = self . right = None
def printOddNodes ( root ) :
    if ( root == None ) :
        return
    q = [ ]
    q . append ( root )
    isOdd = True
    while ( 1 ) :
        nodeCount = len ( q )
        if ( nodeCount == 0 ) :
            break
        while ( nodeCount > 0 ) :
            node = q [ 0 ]
            if ( isOdd ) :
                print ( node . data , end = " ▁ " )
            q . pop ( 0 )
            if ( node . left != None ) :
                q . append ( node . left )
            if ( node . right != None ) :
                q . append ( node . right )
            nodeCount -= 1
        isOdd = not isOdd
if __name__ == ' _ _ main _ _ ' :
    root = newNode ( 1 )
    root . left = newNode ( 2 )
    root . right = newNode ( 3 )
    root . left . left = newNode ( 4 )
    root . left . right = newNode ( 5 )
    printOddNodes ( root )

Accumulator variables: nodeCount, q
Boolean variables: isOdd
Class/struct names: newNode
Python program:
def maxHamming ( arr , n ) :
    brr = [ 0 ] * ( 2 * n + 1 )
    for i in range ( n ) :
        brr [ i ] = arr [ i ]
    for i in range ( n ) :
        brr [ n + i ] = arr [ i ]
    maxHam = 0
    for i in range ( 1 , n ) :
        currHam = 0
        k = 0
        for j in range ( i , i + n ) :
            if brr [ j ] != arr [ k ] :
                currHam += 1
                k = k + 1
        if currHam == n :
            return n
        maxHam = max ( maxHam , currHam )
    return maxHam
arr = [ 2 , 4 , 6 , 8 ]
n = len ( arr )
print ( maxHamming ( arr , n ) )

Index/key variables: i, j, k
Accumulator variables: currHam
Iterator variables: i, j
Python program:
def CountCircles ( c , r , n ) :
    diameter = [ ]
    for i in range ( n ) :
        obj = [ ]
        obj . append ( c [ i ] - r [ i ] )
        obj . append ( c [ i ] + r [ i ] )
        diameter . append ( obj )
    diameter . sort ( )
    count = 0
    cur = diameter [ 0 ] [ 1 ]
    for i in range ( 1 , n ) :
        if ( diameter [ i ] [ 0 ] > cur ) :
            cur = diameter [ i ] [ 1 ]
        else :
            count += 1
    print ( count )
c = [ 1 , 2 , 3 , 4 ]
r = [ 1 , 1 , 1 , 1 ]
n = len ( c )
CountCircles ( c , r , n )

Index/key variables: i
Accumulator variables: count, diameter, obj
Iterator variables: i
Python program:
from collections import deque
def leftRotate ( arr , k , n ) :
    arr = deque ( arr )
    arr . rotate ( - k )
    arr = list ( arr )
    for i in range ( n ) :
        print ( arr [ i ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 3 , 5 , 7 , 9 ]
    n = len ( arr )
    k = 2
    leftRotate ( arr , k , n )

Index/key variables: i
Iterator variables: i
Python program:
def findElement ( arr , ranges , rotations , index ) :
    for i in range ( rotations - 1 , - 1 , - 1 ) :
        left = ranges [ i ] [ 0 ]
        right = ranges [ i ] [ 1 ]
        if ( left <= index and right >= index ) :
            if ( index == left ) :
                index = right
            else :
                index = index - 1
    return arr [ index ]
arr = [ 1 , 2 , 3 , 4 , 5 ]
rotations = 2
ranges = [ [ 0 , 2 ] , [ 0 , 3 ] ]
index = 1
print ( findElement ( arr , ranges , rotations , index ) )

Index/key variables: i, index
Iterator variables: i
Python program:
def sort ( s ) :
    c , s = list ( s ) , list ( s )
    c . sort ( )
    al_c = 0
    nu_c = 0
    while ord ( c [ al_c ] ) < 97 :
        al_c += 1
    for i in range ( len ( s ) ) :
        if s [ i ] < ' a ' :
            s [ i ] = c [ nu_c ]
            nu_c += 1
        else :
            s [ i ] = c [ al_c ]
            al_c += 1
    return ' ' . join ( s )
if __name__ == " _ _ main _ _ " :
    s = " d4c3b2a1"
    print ( sort ( s ) )

Index/key variables: al_c, i, nu_c
Iterator variables: i
Python program:
def splitArr ( arr , n , k ) :
    for i in range ( 0 , k ) :
        x = arr [ 0 ]
        for j in range ( 0 , n - 1 ) :
            arr [ j ] = arr [ j + 1 ]
        arr [ n - 1 ] = x
arr = [ 12 , 10 , 5 , 6 , 52 , 36 ]
n = len ( arr )
position = 2
splitArr ( arr , n , position )
for i in range ( 0 , n ) :
    print ( arr [ i ] , end = ' ▁ ' )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def SplitAndAdd ( A , length , rotation ) :
    tmp = [ 0 for i in range ( length * 2 ) ]
    for i in range ( length ) :
        tmp [ i ] = A [ i ]
        tmp [ i + length ] = A [ i ]
    for i in range ( rotation , rotation + length , 1 ) :
        A [ i - rotation ] = tmp [ i ] ;
arr = [ 12 , 10 , 5 , 6 , 52 , 36 ]
n = len ( arr )
position = 2
SplitAndAdd ( arr , n , position ) ;
for i in range ( n ) :
    print ( arr [ i ] , end = " ▁ " )
print ( )

Index/key variables: i
Iterator variables: i