dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def rotateArray ( arr , N ) :
    v = arr
    v . sort ( reverse = False )
    for i in range ( 1 , N + 1 , 1 ) :
        x = arr [ N - 1 ]
        i = N - 1
        while ( i > 0 ) :
            arr [ i ] = arr [ i - 1 ]
            arr [ 0 ] = x
            i -= 1
        if ( arr == v ) :
            print ( " YES " )
            return
    print ( " NO " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 3 , 4 , 5 , 1 , 2 ]
    N = len ( arr )
    rotateArray ( arr , N )

Index/key variables: i
Iterator variables: i
Python program:
def findLargestRotation ( num ) :
    ans = num
    length = len ( str ( num ) )
    x = 10 ** ( length - 1 )
    for i in range ( 1 , length ) :
        lastDigit = num % 10
        num = num // 10
        num += ( lastDigit * x )
        if ( num > ans ) :
            ans = num
    print ( ans )
N = 657
findLargestRotation ( N )

Accumulator variables: num
Iterator variables: i
Python program:
def numberOfDigit ( N ) :
    digit = 0
    while ( N > 0 ) :
        digit += 1
        N //= 10
    return digit
def rotateNumberByK ( N , K ) :
    X = numberOfDigit ( N )
    K = ( ( K % X ) + X ) % X
    left_no = N // pow ( 10 , X - K )
    N = N % pow ( 10 , X - K )
    left_digit = numberOfDigit ( left_no )
    N = N * pow ( 10 , left_digit ) + left_no
    print ( N )
if __name__ == ' _ _ main _ _ ' :
    N , K = 12345 , 7
    rotateNumberByK ( N , K )

Accumulator variables: N, digit
Python program:
def minMovesToSort ( arr , N ) :
    count = 0
    index = 0
    for i in range ( N - 1 ) :
        if ( arr [ i ] < arr [ i + 1 ] ) :
            count += 1
            index = i
    if ( count == 0 ) :
        print ( "0" )
    elif ( count == N - 1 ) :
        print ( N - 1 )
    elif ( count == 1 and arr [ 0 ] <= arr [ N - 1 ] ) :
        print ( index + 1 )
    else :
        print ( " - 1" )
arr = [ 2 , 1 , 5 , 4 , 2 ]
N = len ( arr )
minMovesToSort ( arr , N )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
import sys
N = 3
def findMaximumDiagonalSumOMatrixf ( A ) :
    maxDiagonalSum = - sys . maxsize - 1
    for i in range ( N ) :
        curr = 0
        for j in range ( N ) :
            curr += A [ j ] [ ( i + j ) % N ]
        maxDiagonalSum = max ( maxDiagonalSum , curr )
    for i in range ( N ) :
        curr = 0
        for j in range ( N ) :
            curr += A [ ( i + j ) % N ] [ j ]
        maxDiagonalSum = max ( maxDiagonalSum , curr )
    return maxDiagonalSum
if __name__ == " _ _ main _ _ " :
    mat = [ [ 1 , 1 , 2 ] , [ 2 , 1 , 2 ] , [ 1 , 2 , 2 ] ]
    print ( findMaximumDiagonalSumOMatrixf ( mat ) )

Index/key variables: j
Accumulator variables: curr
Iterator variables: i, j
Python program:
def MaxSum ( arr , n , k ) :
    i , max_sum = 0 , 0
    sum = 0
    while i < k :
        sum += arr [ i ]
        i += 1
    max_sum = sum
    while ( i < n ) :
        sum = sum - arr [ i - k ] + arr [ i ]
        if ( max_sum < sum ) :
            max_sum = sum
        i += 1
    return max_sum
def gcd ( n1 , n2 ) :
    if ( n2 == 0 ) :
        return n1
    else :
        return gcd ( n2 , n1 % n2 )
def RotateArr ( arr , n , d ) :
    i = 0
    j = 0
    d = d % n
    no_of_sets = gcd ( d , n )
    for i in range ( no_of_sets ) :
        temp = arr [ i ]
        j = i
        while ( True ) :
            k = j + d
            if ( k >= n ) :
                k = k - n
            if ( k == i ) :
                break
            arr [ j ] = arr [ k ]
            j = k
        arr [ j ] = temp
    return arr
def performQuery ( arr , Q , q ) :
    N = len ( arr )
    for i in range ( q ) :
        if ( Q [ i ] [ 0 ] == 1 ) :
            arr = RotateArr ( arr , N , Q [ i ] [ 1 ] )
            for t in arr :
                print ( t , end = " ▁ " )
            print ( )
        else :
            print ( MaxSum ( arr , N , Q [ i ] [ 1 ] ) )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 , 4 , 5 ]
    q = 5
    Q = [ [ 1 , 2 ] , [ 2 , 3 ] , [ 1 , 3 ] , [ 1 , 1 ] , [ 2 , 4 ] ]
    performQuery ( arr , Q , q )

Index/key variables: i, j, k
Accumulator variables: sum
Iterator variables: i, t
Python program:
def getMinimumRemoval ( str ) :
    n = len ( str )
    ans = n
    if ( n % 2 == 0 ) :
        freqEven = { }
        freqOdd = { }
        for ch in range ( ord ( ' a ' ) , ord ( ' z ' ) + 1 ) :
            freqEven [ chr ( ch ) ] = 0
            freqOdd [ chr ( ch ) ] = 0
        for i in range ( n ) :
            if ( i % 2 == 0 ) :
                if str [ i ] in freqEven :
                    freqEven [ str [ i ] ] += 1
            else :
                if str [ i ] in freqOdd :
                    freqOdd [ str [ i ] ] += 1
        evenMax = 0
        oddMax = 0
        for ch in range ( ord ( ' a ' ) , ord ( ' z ' ) + 1 ) :
            evenMax = max ( evenMax , freqEven [ chr ( ch ) ] )
            oddMax = max ( oddMax , freqOdd [ chr ( ch ) ] )
        ans = ans - evenMax - oddMax
    else :
        freq = { }
        for ch in range ( ' a ' , ' z ' ) :
            freq [ chr ( ch ) ] = 0
        for i in range ( n ) :
            if str [ i ] in freq :
                freq [ str [ i ] ] += 1
        strMax = 0
        for ch in range ( ' a ' , ' z ' ) :
            strMax = max ( strMax , freq [ chr ( ch ) ] )
        ans = ans - strMax
    return ans
str = " geeksgeeks "
print ( getMinimumRemoval ( str ) )

Index/key variables: i
Iterator variables: ch, i
Python program:
import sys
def findAltSubSeq ( s ) :
    n = len ( s )
    ans = - sys . maxsize - 1
    for i in range ( 10 ) :
        for j in range ( 10 ) :
            cur , f = 0 , 0
            for k in range ( n ) :
                if ( f == 0 and ord ( s [ k ] ) - ord ( '0' ) == i ) :
                    f = 1
                    cur += 1
                elif ( f == 1 and ord ( s [ k ] ) - ord ( '0' ) == j ) :
                    f = 0
                    cur += 1
            if i != j and cur % 2 == 1 :
                cur -= 1
            ans = max ( cur , ans )
    return ans
s = "100210601"
print ( findAltSubSeq ( s ) )

Index/key variables: k
Accumulator variables: cur
Iterator variables: i, j, k
Python program:
def matrix ( n , m , li ) :
    ctr = 0
    while ( ctr < 2 * n - 1 ) :
        print ( " ▁ " * abs ( n - ctr - 1 ) , end = " " )
        lst = [ ]
        for i in range ( m ) :
            for j in range ( n ) :
                if i + j == ctr :
                    lst . append ( li [ i ] [ j ] )
        lst . reverse ( )
        print ( * lst )
        ctr += 1
n = 8
m = n
li = [ [ 4 , 5 , 6 , 9 , 8 , 7 , 1 , 4 ] , [ 1 , 5 , 9 , 7 , 5 , 3 , 1 , 6 ] , [ 7 , 5 , 3 , 1 , 5 , 9 , 8 , 0 ] , [ 6 , 5 , 4 , 7 , 8 , 9 , 3 , 7 ] , [ 3 , 5 , 6 , 4 , 8 , 9 , 2 , 1 ] , [ 3 , 1 , 6 , 4 , 7 , 9 , 5 , 0 ] , [ 8 , 0 , 7 , 2 , 3 , 1 , 0 , 8 ] , [ 7 , 5 , 3 , 1 , 5 , 9 , 8 , 5 ] ]
matrix ( n , m , li )

Index/key variables: i, j
Accumulator variables: ctr, lst
Iterator variables: i, j
Python program:
def getFirstElement ( a , N , K , M ) :
    K %= N
    if ( K >= M ) :
        index = ( N - K ) + ( M - 1 )
    else :
        index = ( M - K - 1 )
    result = a [ index ]
    return result
if __name__ == " _ _ main _ _ " :
    a = [ 1 , 2 , 3 , 4 , 5 ]
    N = len ( a )
    K , M = 3 , 2
    print ( getFirstElement ( a , N , K , M ) )

Index/key variables: index
Python program:
def getFirstElement ( a , N , K , M ) :
    K %= N
    index = ( K + M - 1 ) % N
    result = a [ index ]
    return result
if __name__ == ' _ _ main _ _ ' :
    a = [ 3 , 4 , 5 , 23 ]
    N = len ( a )
    K = 2
    M = 1
    print ( getFirstElement ( a , N , K , M ) )

Index/key variables: index
Python program:
def left_rotate ( arr ) :
    last = arr [ 1 ] ;
    for i in range ( 3 , len ( arr ) , 2 ) :
        arr [ i - 2 ] = arr [ i ]
    arr [ len ( arr ) - 1 ] = last
def right_rotate ( arr ) :
    start = arr [ len ( arr ) - 2 ]
    for i in range ( len ( arr ) - 4 , - 1 , - 2 ) :
        arr [ i + 2 ] = arr [ i ]
    arr [ 0 ] = start
def rotate ( arr ) :
    left_rotate ( arr )
    right_rotate ( arr )
    for i in range ( len ( arr ) ) :
        print ( arr [ i ] , end = " ▁ " )
arr = [ 1 , 2 , 3 , 4 , 5 , 6 ]
rotate ( arr ) ;

Index/key variables: i
Iterator variables: i
Python program:
from collections import defaultdict
def maximumMatchingPairs ( perm1 , perm2 , n ) :
    left = [ 0 ] * n
    right = [ 0 ] * n
    mp1 = { }
    mp2 = { }
    for i in range ( n ) :
        mp1 [ perm1 [ i ] ] = i
    for j in range ( n ) :
        mp2 [ perm2 [ j ] ] = j
    for i in range ( n ) :
        idx2 = mp2 [ perm1 [ i ] ]
        idx1 = i
        if ( idx1 == idx2 ) :
            left [ i ] = 0
            right [ i ] = 0
        elif ( idx1 < idx2 ) :
            left [ i ] = ( n - ( idx2 - idx1 ) )
            right [ i ] = ( idx2 - idx1 )
        else :
            left [ i ] = ( idx1 - idx2 )
            right [ i ] = ( n - ( idx1 - idx2 ) )
    freq1 = defaultdict ( int )
    freq2 = defaultdict ( int )
    for i in range ( n ) :
        freq1 [ left [ i ] ] += 1
        freq2 [ right [ i ] ] += 1
    ans = 0
    for i in range ( n ) :
        ans = max ( ans , max ( freq1 [ left [ i ] ] , freq2 [ right [ i ] ] ) )
    return ans
if __name__ == " _ _ main _ _ " :
    P1 = [ 5 , 4 , 3 , 2 , 1 ]
    P2 = [ 1 , 2 , 3 , 4 , 5 ]
    n = len ( P1 )
    print ( maximumMatchingPairs ( P1 , P2 , n ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def countRotation ( arr , n ) :
    for i in range ( 1 , n ) :
        if ( arr [ i ] < arr [ i - 1 ] ) :
            return i
    return 0
if __name__ == " _ _ main _ _ " :
    arr1 = [ 4 , 5 , 1 , 2 , 3 ]
    n = len ( arr1 )
    print ( countRotation ( arr1 , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def countRotation ( arr , low , high ) :
    if ( low > high ) :
        return 0
    mid = low + ( high - low ) // 2
    if ( mid < high and arr [ mid ] > arr [ mid + 1 ] ) :
        return mid + 1
    if ( mid > low and arr [ mid ] < arr [ mid - 1 ] ) :
        return mid
    if ( arr [ mid ] > arr [ low ] ) :
        return countRotation ( arr , mid + 1 , high )
    if ( arr [ mid ] < arr [ high ] ) :
        return countRotation ( arr , low , mid - 1 )
    else :
        rightIndex = countRotation ( arr , mid + 1 , high )
        leftIndex = countRotation ( arr , low , mid - 1 )
        if ( rightIndex == 0 ) :
            return leftIndex
        return rightIndex
if __name__ == ' _ _ main _ _ ' :
    arr1 = [ 4 , 5 , 1 , 2 , 3 ]
    N = len ( arr1 )
    print ( countRotation ( arr1 , 0 , N - 1 ) )

Index/key variables: high, low, mid
Python program:
def rotatedSumQuery ( arr , n , query , Q ) :
    prefix = [ 0 ] * ( 2 * n )
    for i in range ( n ) :
        prefix [ i ] = arr [ i ]
        prefix [ i + n ] = arr [ i ]
    for i in range ( 1 , 2 * n ) :
        prefix [ i ] += prefix [ i - 1 ] ;
    start = 0 ;
    for q in range ( Q ) :
        if ( query [ q ] [ 0 ] == 1 ) :
            k = query [ q ] [ 1 ]
            start = ( start + k ) % n ;
        elif ( query [ q ] [ 0 ] == 2 ) :
            L = query [ q ] [ 1 ]
            R = query [ q ] [ 2 ]
            if ( start + L == 0 ) :
                print ( prefix [ start + R ] )
            else :
                print ( prefix [ start + R ] - prefix [ start + L - 1 ] )
arr = [ 1 , 2 , 3 , 4 , 5 , 6 ] ;
Q = 5
query = [ [ 2 , 1 , 3 ] , [ 1 , 3 ] , [ 2 , 0 , 3 ] , [ 1 , 4 ] , [ 2 , 3 , 5 ] ]
n = len ( arr ) ;
rotatedSumQuery ( arr , n , query , Q ) ;

Index/key variables: i, q
Iterator variables: i, q
Python program:
def isConversionPossible ( s1 , s2 , x ) :
    n = len ( s1 )
    s1 = list ( s1 )
    s2 = list ( s2 )
    for i in range ( n ) :
        diff = ord ( s2 [ i ] ) - ord ( s1 [ i ] )
        if diff == 0 :
            continue
        if diff < 0 :
            diff = diff + 26
        if diff > x :
            return False
    return True
if __name__ == " _ _ main _ _ " :
    s1 = " you "
    s2 = " ara "
    x = 6
    result = isConversionPossible ( s1 , s2 , x )
    if result :
        print ( " YES " )
    else :
        print ( " NO " )

Index/key variables: i
Iterator variables: i
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def push ( head_ref , new_data ) :
    new_node = Node ( new_data )
    new_node . data = new_data
    new_node . next = ( head_ref )
    ( head_ref ) = new_node
    return head_ref
def printList ( node ) :
    while ( node != None ) :
        print ( node . data , end = ' ▁ - > ▁ ' )
        node = node . next
    print ( " NULL " )
def rightRotate ( head , k ) :
    if ( not head ) :
        return head
    tmp = head
    len = 1
    while ( tmp . next != None ) :
        tmp = tmp . next
        len += 1
    if ( k > len ) :
        k = k % len
    k = len - k
    if ( k == 0 or k == len ) :
        return head
    current = head
    cnt = 1
    while ( cnt < k and current != None ) :
        current = current . next
        cnt += 1
    if ( current == None ) :
        return head
    kthnode = current
    tmp . next = head
    head = kthnode . next
    kthnode . next = None
    return head
if __name__ == ' _ _ main _ _ ' :
    head = None
    head = push ( head , 5 )
    head = push ( head , 4 )
    head = push ( head , 3 )
    head = push ( head , 2 )
    head = push ( head , 1 )
    k = 2
    updated_head = rightRotate ( head , k )
    printList ( updated_head )

Accumulator variables: cnt, len
Class/struct names: Node
Python program:
import sys
def isPossible ( a , n ) :
    if ( n <= 2 ) :
        return True ;
    flag = 0 ;
    for i in range ( n - 2 ) :
        if ( not ( a [ i ] > a [ i + 1 ] and a [ i + 1 ] > a [ i + 2 ] ) ) :
            flag = 1 ;
            break ;
    if ( flag == 0 ) :
        return True ;
    flag = 0 ;
    for i in range ( n - 2 ) :
        if ( not ( a [ i ] < a [ i + 1 ] and a [ i + 1 ] < a [ i + 2 ] ) ) :
            flag = 1 ;
            break ;
    if ( flag == 0 ) :
        return True ;
    val1 = sys . maxsize ; mini = - 1 ;
    val2 = - sys . maxsize ; maxi = - 1 ;
    for i in range ( n ) :
        if ( a [ i ] < val1 ) :
            mini = i ;
            val1 = a [ i ] ;
        if ( a [ i ] > val2 ) :
            maxi = i ;
            val2 = a [ i ] ;
    flag = 1 ;
    for i in range ( maxi ) :
        if ( a [ i ] > a [ i + 1 ] ) :
            flag = 0 ;
            break ;
    if ( flag == 1 and maxi + 1 == mini ) :
        flag = 1 ;
        for i in range ( mini , n - 1 ) :
            if ( a [ i ] > a [ i + 1 ] ) :
                flag = 0 ;
                break ;
        if ( flag == 1 ) :
            return True ;
    flag = 1 ;
    for i in range ( mini ) :
        if ( a [ i ] < a [ i + 1 ] ) :
            flag = 0 ;
            break ;
    if ( flag == 1 and maxi - 1 == mini ) :
        flag = 1 ;
        for i in range ( maxi , n - 1 ) :
            if ( a [ i ] < a [ i + 1 ] ) :
                flag = 0 ;
                break ;
        if ( flag == 1 ) :
            return True ;
    return False ;
a = [ 4 , 5 , 6 , 2 , 3 ] ;
n = len ( a ) ;
if ( isPossible ( a , n ) ) :
    print ( " Yes " ) ;
else :
    print ( " No " ) ;

Index/key variables: i
Iterator variables: i
Python program:
def cntRotations ( s , n ) :
    str = s + s ;
    pre = [ 0 ] * ( 2 * n ) ;
    for i in range ( 2 * n ) :
        if ( i != 0 ) :
            pre [ i ] += pre [ i - 1 ] ;
        if ( str [ i ] == ' a ' or str [ i ] == ' e ' or str [ i ] == ' i ' or str [ i ] == ' o ' or str [ i ] == ' u ' ) :
            pre [ i ] += 1 ;
    ans = 0 ;
    for i in range ( n - 1 , 2 * n - 1 , 1 ) :
        r = i ; l = i - n ;
        x1 = pre [ r ] ;
        if ( l >= 0 ) :
            x1 -= pre [ l ] ;
        r = ( int ) ( i - n / 2 ) ;
        left = pre [ r ] ;
        if ( l >= 0 ) :
            left -= pre [ l ] ;
        right = x1 - left ;
        if ( left > right ) :
            ans += 1 ;
    return ans ;
s = " abecidft " ;
n = len ( s ) ;
print ( cntRotations ( s , n ) ) ;

Index/key variables: i, l, r
Accumulator variables: ans, left, x1
Iterator variables: i
Python program:
def cntRotations ( s , n ) :
    lh , rh , ans = 0 , 0 , 0
    for i in range ( n // 2 ) :
        if ( s [ i ] == ' a ' or s [ i ] == ' e ' or s [ i ] == ' i ' or s [ i ] == ' o ' or s [ i ] == ' u ' ) :
            lh += 1
    for i in range ( n // 2 , n ) :
        if ( s [ i ] == ' a ' or s [ i ] == ' e ' or s [ i ] == ' i ' or s [ i ] == ' o ' or s [ i ] == ' u ' ) :
            rh += 1
    if ( lh > rh ) :
        ans += 1
    for i in range ( 1 , n ) :
        if ( s [ i - 1 ] == ' a ' or s [ i - 1 ] == ' e ' or s [ i - 1 ] == ' i ' or s [ i - 1 ] == ' o ' or s [ i - 1 ] == ' u ' ) :
            rh += 1
            lh -= 1
        if ( s [ ( i - 1 + n // 2 ) % n ] == ' a ' or s [ ( i - 1 + n // 2 ) % n ] == ' e ' or s [ ( i - 1 + n // 2 ) % n ] == ' i ' or s [ ( i - 1 + n // 2 ) % n ] == ' o ' or s [ ( i - 1 + n // 2 ) % n ] == ' u ' ) :
            rh -= 1
            lh += 1
        if ( lh > rh ) :
            ans += 1
    return ans
if __name__ == " _ _ main _ _ " :
    s = " abecidft "
    n = len ( s )
    print ( cntRotations ( s , n ) )

Index/key variables: i
Accumulator variables: ans, lh, rh
Iterator variables: i
Python program:
size = 2
def performQueries ( string , n , queries , q ) :
    ptr = 0 ;
    for i in range ( q ) :
        if ( queries [ i ] [ 0 ] == 1 ) :
            ptr = ( ptr + queries [ i ] [ 1 ] ) % n ;
        else :
            k = queries [ i ] [ 1 ] ;
            index = ( ptr + k - 1 ) % n ;
            print ( string [ index ] ) ;
if __name__ == " _ _ main _ _ " :
    string = " abcdefgh " ;
    n = len ( string ) ;
    queries = [ [ 1 , 2 ] , [ 2 , 2 ] , [ 1 , 4 ] , [ 2 , 7 ] ] ;
    q = len ( queries ) ;
    performQueries ( string , n , queries , q ) ;

Index/key variables: i, index
Iterator variables: i
Python program:
def ReverseArray ( arr , left , right ) :
    while ( left < right ) :
        temp = arr [ left ] ;
        arr [ left ] = arr [ right ] ;
        arr [ right ] = temp ;
        left += 1 ;
        right -= 1 ;
def RotateAndCheck ( str1 , str2 , d ) :
    if ( len ( str1 ) != len ( str2 ) ) :
        return False ;
    left_rot_str1 = [ ] ; right_rot_str1 = [ ] ;
    left_flag = True ; right_flag = True ;
    str1_size = len ( str1 ) ;
    for i in range ( str1_size ) :
        left_rot_str1 . append ( str1 [ i ] ) ;
        right_rot_str1 . append ( str1 [ i ] ) ;
    ReverseArray ( left_rot_str1 , 0 , d - 1 ) ;
    ReverseArray ( left_rot_str1 , d , str1_size - 1 ) ;
    ReverseArray ( left_rot_str1 , 0 , str1_size - 1 ) ;
    ReverseArray ( right_rot_str1 , 0 , str1_size - d - 1 ) ;
    ReverseArray ( right_rot_str1 , str1_size - d , str1_size - 1 ) ;
    ReverseArray ( right_rot_str1 , 0 , str1_size - 1 ) ;
    for i in range ( str1_size ) :
        if ( left_rot_str1 [ i ] != str2 [ i ] ) :
            left_flag = False ;
        if ( right_rot_str1 [ i ] != str2 [ i ] ) :
            right_flag = False ;
    if ( left_flag or right_flag ) :
        return True ;
    return False ;
if __name__ == " _ _ main _ _ " :
    str1 = list ( " abcdefg " ) ;
    str2 = list ( " cdefgab " ) ;
    d = 2 ;
    d = d % len ( str1 ) ;
    if ( RotateAndCheck ( str1 , str2 , d ) ) :
        print ( " Yes " ) ;
    else :
        print ( " No " ) ;

Index/key variables: i, left, right
Accumulator variables: left_rot_str1, right_rot_str1
Iterator variables: i
Boolean variables: left_flag, right_flag
Python program:
def countOddRotations ( n ) :
    odd_count = 0 ; even_count = 0
    while n != 0 :
        digit = n % 10
        if digit % 2 == 0 :
            odd_count += 1
        else :
            even_count += 1
        n = n // 10
    print ( " Odd ▁ = " , odd_count )
    print ( " Even ▁ = " , even_count )
n = 1234
countOddRotations ( n )

Accumulator variables: even_count, odd_count
Python program:
def numberofDigits ( n ) :
    cnt = 0
    while n > 0 :
        cnt += 1
        n //= 10
    return cnt
def cal ( num ) :
    digit = numberofDigits ( num )
    powTen = pow ( 10 , digit - 1 )
    for i in range ( digit - 1 ) :
        firstDigit = num // powTen
        left = ( num * 10 + firstDigit - ( firstDigit * powTen * 10 ) )
        print ( left , end = " ▁ " )
        num = left
num = 1445
cal ( num )

Accumulator variables: cnt, n
Iterator variables: i
Python program:
n = 2
S = [ '0' , '1' , '2' ]
k = len ( S )
S . sort ( )
w = [ - 1 ]
while w :
    w [ - 1 ] += 1
    m = len ( w )
    if m == n :
        print ( ' ' . join ( S [ i ] for i in w ) )
    while len ( w ) < n :
        w . append ( w [ - m ] )
    while w and w [ - 1 ] == k - 1 :
        w . pop ( )

Index/key variables: i
Accumulator variables: w
Python program:
def CheckKCycles ( n , s ) :
    ff = True
    for i in range ( 1 , n ) :
        x = int ( s [ i : ] + s [ 0 : i ] )
        if ( x >= int ( s ) ) :
            continue
        ff = False
        break
    if ( ff ) :
        print ( " Yes " )
    else :
        print ( " No " )
n = 3
s = "123"
CheckKCycles ( n , s )

Iterator variables: i
Boolean variables: ff
Python program:
import math
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def rotateSubList ( A , m , n , k ) :
    size = n - m + 1
    if ( k > size ) :
        k = k % size
    if ( k == 0 or k == size ) :
        head = A
        while ( head != None ) :
            print ( head . data )
            head = head . next
        return
    link = None
    if ( m == 1 ) :
        link = A
    c = A
    count = 0
    end = None
    pre = None
    while ( c != None ) :
        count = count + 1
        if ( count == m - 1 ) :
            pre = c
            link = c . next
        if ( count == n - k ) :
            if ( m == 1 ) :
                end = c
                A = c . next
            else :
                end = c
                pre . next = c . next
        if ( count == n ) :
            d = c . next
            c . next = link
            end . next = d
            head = A
            while ( head != None ) :
                print ( head . data , end = " ▁ " )
                head = head . next
            return
        c = c . next
def push ( head , val ) :
    new_node = Node ( val )
    new_node . data = val
    new_node . next = head
    head = new_node
    return head
if __name__ == ' _ _ main _ _ ' :
    head = None
    head = push ( head , 70 )
    head = push ( head , 60 )
    head = push ( head , 50 )
    head = push ( head , 40 )
    head = push ( head , 30 )
    head = push ( head , 20 )
    head = push ( head , 10 )
    tmp = head
    print ( " Given ▁ List : ▁ " , end = " " )
    while ( tmp != None ) :
        print ( tmp . data , end = " ▁ " )
        tmp = tmp . next
    print ( )
    m = 3
    n = 6
    k = 2
    print ( " After ▁ rotation ▁ of ▁ sublist : ▁ " , end = " " )
    rotateSubList ( head , m , n , k )

Class/struct names: Node
Python program:
from math import log10
def rightRotationDivisor ( N ) :
    lastDigit = N % 10
    rightRotation = ( lastDigit * 10 ** int ( log10 ( N ) ) + N // 10 )
    return rightRotation % N == 0
def generateNumbers ( m ) :
    for i in range ( 10 ** ( m - 1 ) , 10 ** m ) :
        if rightRotationDivisor ( i ) :
            print ( i )
m = 3
generateNumbers ( m )

Iterator variables: i
Python program:
from math import log10
def generateNumbers ( m ) :
    numbers = [ ]
    for y in range ( 1 , 10 ) :
        k_max = ( ( 10 ** ( m - 2 ) * ( 10 * y + 1 ) ) // ( 10 ** ( m - 1 ) + y ) )
        for k in range ( 1 , k_max + 1 ) :
            x = ( ( y * ( 10 ** ( m - 1 ) - k ) ) // ( 10 * k - 1 ) )
            if ( ( y * ( 10 ** ( m - 1 ) - k ) ) % ( 10 * k - 1 ) == 0 ) :
                numbers . append ( 10 * x + y )
    for n in sorted ( numbers ) :
        print ( n )
m = 3
generateNumbers ( m )

Accumulator variables: numbers
Iterator variables: k, n, y