dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
MAX = 10000
sequence = [ 0 ] * ( MAX + 1 ) ;
def vanEckSequence ( ) :
    for i in range ( MAX ) :
        for j in range ( i - 1 , - 1 , - 1 ) :
            if ( sequence [ j ] == sequence [ i ] ) :
                sequence [ i + 1 ] = i - j ;
                break ;
def getCount ( n ) :
    nthTerm = sequence [ n - 1 ] ;
    count = 0 ;
    for i in range ( n ) :
        if ( sequence [ i ] == nthTerm ) :
            count += 1 ;
    return count ;
if __name__ == " _ _ main _ _ " :
    vanEckSequence ( ) ;
    n = 5 ;
    print ( getCount ( n ) ) ;
    n = 11 ;
    print ( getCount ( n ) ) ;

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j
Python program:
MAX = 10000
sequence = [ 0 ] * ( MAX + 1 ) ;
def vanEckSequence ( ) :
    for i in range ( MAX ) :
        for j in range ( i - 1 , - 1 , - 1 ) :
            if ( sequence [ j ] == sequence [ i ] ) :
                sequence [ i + 1 ] = i - j ;
                break ;
def getCount ( n ) :
    count = 1 ;
    i = n - 1 ;
    while ( sequence [ i + 1 ] != 0 ) :
        count += 1 ;
        i = i - sequence [ i + 1 ] ;
    return count ;
if __name__ == " _ _ main _ _ " :
    vanEckSequence ( ) ;
    n = 5 ;
    print ( getCount ( n ) ) ;
    n = 11 ;
    print ( getCount ( n ) ) ;

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j
Python program:
N = 1000005
mod = ( int ) ( 1e9 + 7 )
factorial = [ 0 ] * N ;
modinverse = [ 0 ] * N ;
def power ( a , m1 ) :
    if ( m1 == 0 ) :
        return 1 ;
    elif ( m1 == 1 ) :
        return a ;
    elif ( m1 == 2 ) :
        return ( a * a ) % mod ;
    elif ( m1 & 1 ) :
        return ( a * power ( power ( a , m1 // 2 ) , 2 ) ) % mod ;
    else :
        return power ( power ( a , m1 // 2 ) , 2 ) % mod ;
def factorialfun ( ) :
    factorial [ 0 ] = 1 ;
    for i in range ( 1 , N ) :
        factorial [ i ] = ( factorial [ i - 1 ] * i ) % mod ;
def modinversefun ( ) :
    modinverse [ N - 1 ] = power ( factorial [ N - 1 ] , mod - 2 ) % mod ;
    for i in range ( N - 2 , - 1 , - 1 ) :
        modinverse [ i ] = ( modinverse [ i + 1 ] * ( i + 1 ) ) % mod ;
def binomial ( n , r ) :
    if ( r > n ) :
        return 0 ;
    a = ( factorial [ n ] * modinverse [ n - r ] ) % mod ;
    a = ( a * modinverse [ r ] ) % mod ;
    return a ;
def ways ( x , y ) :
    factorialfun ( ) ;
    modinversefun ( ) ;
    if ( ( 2 * x - y ) % 3 == 0 and ( 2 * y - x ) % 3 == 0 ) :
        m = ( 2 * x - y ) // 3 ;
        n = ( 2 * y - x ) // 3 ;
        return binomial ( n + m , n ) ;
if __name__ == " _ _ main _ _ " :
    x = 3 ; y = 3 ;
    print ( ways ( x , y ) ) ;

Index/key variables: i, n, r
Iterator variables: i
Python program:
from math import ceil , log2
def solve ( n , x , y ) :
    length = ceil ( log2 ( n + 2 ) ) - 1 ;
    rank = n - ( 1 << length ) + 1 ;
    left = " " ; right = " " ;
    for i in range ( length - 1 , - 1 , - 1 ) :
        mask = ( 1 << i ) ;
        bit = ( mask & rank ) ;
        if ( bit ) :
            left += y ;
            right += y ;
        else :
            left += x ;
            right += x ;
    right = right [ : : - 1 ] ;
    res = left + right ;
    return res ;
if __name__ == " _ _ main _ _ " :
    n = 23 ;
    x = '4' ;
    y = '5' ;
    ans = solve ( n , x , y ) ;
    print ( ans ) ;

Accumulator variables: left, right
Iterator variables: i
Python program:
def binomialCoeff ( n , k ) :
    C = [ [ 0 for i in range ( k + 1 ) ] for i in range ( n + 1 ) ]
    for i in range ( n + 1 ) :
        for j in range ( min ( i , k ) + 1 ) :
            if ( j == 0 or j == i ) :
                C [ i ] [ j ] = 1
            else :
                C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ]
    return C [ n ] [ k ]
def findMax ( n ) :
    return binomialCoeff ( n , n // 2 )
n = 5
print ( findMax ( n ) )

Index/key variables: i, j, k, n
Iterator variables: i, j
Python program:
NO_OF_CHARS = 256
def max_distinct_char ( str , n ) :
    count = [ 0 ] * NO_OF_CHARS
    for i in range ( n ) :
        count [ ord ( str [ i ] ) ] += 1
    max_distinct = 0
    for i in range ( NO_OF_CHARS ) :
        if ( count [ i ] != 0 ) :
            max_distinct += 1
    return max_distinct
def smallesteSubstr_maxDistictChar ( str ) :
    n = len ( str )
    max_distinct = max_distinct_char ( str , n )
    minl = n
    for i in range ( n ) :
        for j in range ( n ) :
            subs = str [ i : j ]
            subs_lenght = len ( subs )
            sub_distinct_char = max_distinct_char ( subs , subs_lenght )
            if ( subs_lenght < minl and max_distinct == sub_distinct_char ) :
                minl = subs_lenght
    return minl
if __name__ == " _ _ main _ _ " :
    str = " AABBBCBB "
    l = smallesteSubstr_maxDistictChar ( str ) ;
    print ( " The ▁ length ▁ of ▁ the ▁ smallest ▁ substring " , " consisting ▁ of ▁ maximum ▁ distinct " , " characters ▁ : " , l )

Index/key variables: i
Accumulator variables: max_distinct
Iterator variables: i, j
Python program:
def min_visible_bottles ( arr , n ) :
    m = dict ( )
    ans = 0
    for i in range ( n ) :
        m [ arr [ i ] ] = m . get ( arr [ i ] , 0 ) + 1
        ans = max ( ans , m [ arr [ i ] ] )
    print ( " Minimum ▁ number ▁ of " , " Visible ▁ Bottles ▁ are : ▁ " , ans )
n = 8
arr = [ 1 , 1 , 2 , 3 , 4 , 5 , 5 , 4 ]
min_visible_bottles ( arr , n )

Index/key variables: i
Iterator variables: i
Python program:
def solveEven ( n , arr , b ) :
    left = n - 1
    for i in range ( ( n // 2 ) ) :
        b [ i ] = arr [ left ]
        left = left - 2
        if ( left < 0 ) :
            break
    right = 0
    for i in range ( n // 2 , n , 1 ) :
        b [ i ] = arr [ right ]
        right = right + 2
        if ( right > n - 2 ) :
            break
def solveOdd ( n , arr , b ) :
    left = n - 1
    for i in range ( n // 2 + 1 ) :
        b [ i ] = arr [ left ]
        left = left - 2
        if ( left < 0 ) :
            break
    right = 1
    for i in range ( n // 2 + 1 , n , 1 ) :
        b [ i ] = arr [ right ]
        right = right + 2
        if ( right > n - 2 ) :
            break
def solve ( n , arr ) :
    b = [ 0 for i in range ( n ) ]
    if ( n % 2 == 0 ) :
        solveEven ( n , arr , b )
    else :
        solveOdd ( n , arr , b )
    for i in range ( n ) :
        print ( b [ i ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 3 , 4 ]
    n = len ( arr )
    solve ( n , arr )

Index/key variables: i, left, right
Iterator variables: i
Python program:
def sum_of_elements ( arr , n ) :
    sumfirst = 0 ;
    sumsecond = 0 ;
    for i in range ( n ) :
        if ( i < n // 2 ) :
            sumfirst += arr [ i ] ;
        else :
            sumsecond += arr [ i ] ;
    print ( " Sum ▁ of ▁ first ▁ half ▁ elements ▁ is " , sumfirst , end =   " " ) ;
    print ( " Sum ▁ of ▁ second ▁ half ▁ elements ▁ is " , sumsecond , end =   " " ) ;
arr = [ 20 , 30 , 60 , 10 , 25 , 15 , 40 ] ;
n = len ( arr ) ;
sum_of_elements ( arr , n ) ;

Index/key variables: i
Accumulator variables: sumfirst, sumsecond
Iterator variables: i
Python program:
from math import sqrt , floor
def lowerWythoff ( n ) :
    phi = ( 1 + sqrt ( 5 ) ) / 2 ;
    for i in range ( 1 , n + 1 ) :
        ans = floor ( i * phi ) ;
        print ( ans , end = " " ) ;
        if ( i != n ) :
            print ( " , ▁ " , end = " " ) ;
if __name__ == " _ _ main _ _ " :
    n = 5 ;
    lowerWythoff ( n ) ;

Iterator variables: i
Python program:
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . next = None
def insert ( root , item ) :
    temp = Node ( 0 )
    temp . data = item
    temp . next = None
    if ( root == None ) :
        root = temp
    else :
        ptr = root
        while ( ptr . next != None ) :
            ptr = ptr . next
        ptr . next = temp
    return root
def newList ( root1 , root2 ) :
    ptr1 = root1
    ptr2 = root2
    root = None
    while ( ptr1 != None ) :
        temp = Node ( 0 )
        temp . next = None
        if ( ptr1 . data < ptr2 . data ) :
            temp . data = ptr2 . data
        else :
            temp . data = ptr1 . data
        if ( root == None ) :
            root = temp
        else :
            ptr = root
            while ( ptr . next != None ) :
                ptr = ptr . next
            ptr . next = temp
        ptr1 = ptr1 . next
        ptr2 = ptr2 . next
    return root
def display ( root ) :
    while ( root != None ) :
        print ( root . data , " - > " , end = " ▁ " )
        root = root . next
    print ( " ▁ " ) ;
if __name__ == ' _ _ main _ _ ' :
    root1 = None
    root2 = None
    root = None
    root1 = insert ( root1 , 5 )
    root1 = insert ( root1 , 2 )
    root1 = insert ( root1 , 3 )
    root1 = insert ( root1 , 8 )
    print ( " First ▁ List : ▁ " , end = " ▁ " )
    display ( root1 )
    root2 = insert ( root2 , 1 )
    root2 = insert ( root2 , 7 )
    root2 = insert ( root2 , 4 )
    root2 = insert ( root2 , 5 )
    print ( " Second ▁ List : ▁ " , end = " ▁ " )
    display ( root2 )
    root = newList ( root1 , root2 )
    print ( " New ▁ List : ▁ " , end = " ▁ " )
    display ( root )

Class/struct names: Node
Python program:
from math import gcd
def countQuadruplets ( l , r , k ) :
    count = 0
    for u in range ( l , r + 1 , 1 ) :
        for v in range ( l , r + 1 , 1 ) :
            for w in range ( l , r + 1 , 1 ) :
                for x in range ( l , r + 1 , 1 ) :
                    if ( gcd ( gcd ( u , v ) , gcd ( w , x ) ) == k ) :
                        count += 1
    return count
if __name__ == ' _ _ main _ _ ' :
    l = 1
    r = 10
    k = 2
    print ( countQuadruplets ( l , r , k ) )

Accumulator variables: count
Iterator variables: u, v, w, x
Python program:
def findIndex ( a , n ) :
    res , min_diff = None , float ( ' inf ' )
    prod = [ None ] * n
    prod [ 0 ] = a [ 0 ]
    for i in range ( 1 , n ) :
        prod [ i ] = prod [ i - 1 ] * a [ i ]
    for i in range ( 0 , n - 1 ) :
        curr_diff = abs ( ( prod [ n - 1 ] // prod [ i ] ) - prod [ i ] )
        if curr_diff < min_diff :
            min_diff = curr_diff
            res = i
    return res
if __name__ == " _ _ main _ _ " :
    arr = [ 3 , 2 , 5 , 7 , 2 , 9 ]
    N = len ( arr )
    print ( findIndex ( arr , N ) )

Index/key variables: i
Iterator variables: i
Python program:
from math import gcd
def printNumbers ( a , n , x ) :
    flag = False
    for i in range ( n ) :
        num = a [ i ]
        g = gcd ( num , x )
        while ( g != 1 ) :
            num //= g
            g = gcd ( num , x )
        if ( num == 1 ) :
            flag = True ;
            print ( a [ i ] , end = " ▁ " ) ;
    if ( not flag ) :
        print ( " There ▁ are ▁ no ▁ such ▁ numbers " )
if __name__ == " _ _ main _ _ " :
    x = 60
    a = [ 2 , 5 , 10 , 7 , 17 ]
    n = len ( a )
    printNumbers ( a , n , x )

Index/key variables: i
Accumulator variables: num
Iterator variables: i
Boolean variables: flag
Python program:
def findMaximumDiff ( a , n ) :
    ind1 = 0
    for i in range ( n - 1 , - 1 , - 1 ) :
        if ( a [ 0 ] != a [ i ] ) :
            ind1 = i
            break
    ind2 = 0
    for i in range ( n - 1 ) :
        if ( a [ n - 1 ] != a [ i ] ) :
            ind2 = ( n - 1 - i )
            break
    return max ( ind1 , ind2 )
a = [ 1 , 2 , 3 , 2 , 3 ]
n = len ( a )
print ( findMaximumDiff ( a , n ) )

Index/key variables: i
Iterator variables: i
Python program:
from collections import defaultdict
MAX = 100005
def partial_sum ( prefix_sum , arr , n ) :
    for i in range ( 1 , n + 1 ) :
        prefix_sum [ i ] = ( prefix_sum [ i - 1 ] + arr [ i - 1 ] )
    return prefix_sum
def countSubarrays ( arr , n , k ) :
    prefix_sum = [ 0 ] * MAX
    prefix_sum [ 0 ] = 0
    prefix_sum = partial_sum ( prefix_sum , arr , n )
    if ( k == 1 ) :
        sum = 0
        m = defaultdict ( int )
        for i in range ( n , - 1 , - 1 ) :
            if ( ( prefix_sum [ i ] + 1 ) in m ) :
                sum += m [ prefix_sum [ i ] + 1 ]
            m [ prefix_sum [ i ] ] += 1
        return sum
    if ( k == - 1 ) :
        sum = 0
        m = defaultdict ( int )
        for i in range ( n , - 1 , - 1 ) :
            if ( ( prefix_sum [ i ] + 1 ) in m ) :
                sum += m [ prefix_sum [ i ] + 1 ]
            if ( ( prefix_sum [ i ] - 1 ) in m ) :
                sum += m [ prefix_sum [ i ] - 1 ]
            m [ prefix_sum [ i ] ] += 1
        return sum
    sum = 0
    m = defaultdict ( int )
    for i in range ( n , - 1 , - 1 ) :
        b = 1
        while ( True ) :
            if ( b > 100000000000000 ) :
                break
            if ( ( prefix_sum [ i ] + b ) in m ) :
                sum += m [ prefix_sum [ i ] + b ]
            b *= k
        m [ prefix_sum [ i ] ] += 1
    return sum
if __name__ == " _ _ main _ _ " :
    arr = [ 2 , 2 , 2 , 2 ]
    n = len ( arr )
    k = 2
    print ( countSubarrays ( arr , n , k ) )

Index/key variables: i
Accumulator variables: b, sum
Iterator variables: i
Python program:
mod = 1000000007
def BitOperations ( a , n , b , m ) :
    a = a [ : : - 1 ]
    b = b [ : : - 1 ]
    c = 0
    for i in range ( m ) :
        if ( b [ i ] == '1' ) :
            c += 1
    power = [ None ] * n
    power [ 0 ] = 1
    for i in range ( 1 , n ) :
        power [ i ] = ( power [ i - 1 ] * 2 ) % mod
    ans = 0
    for i in range ( 0 , n ) :
        if ( a [ i ] == '1' ) :
            ans += c * power [ i ]
            if ( ans >= mod ) :
                ans %= mod
        if ( b [ i ] == '1' ) :
            c -= 1
        if ( c == 0 ) :
            break
    return ans
if __name__ == ' _ _ main _ _ ' :
    a = "1001"
    b = "10101"
    n = len ( a )
    m = len ( b )
    print ( BitOperations ( a , n , b , m ) )

Index/key variables: i
Accumulator variables: ans, c
Iterator variables: i
Python program:
from math import sqrt
def sieve ( maxEle , prime ) :
    prime [ 0 ] , prime [ 1 ] = 1 , 1
    for i in range ( 2 , int ( sqrt ( maxEle ) ) + 1 ) :
        if ( not prime [ i ] ) :
            for j in range ( 2 * i , maxEle + 1 , i ) :
                prime [ j ] = 1
def digitSum ( n ) :
    sum = 0
    while ( n ) :
        sum += n % 10
        n = n // 10
    return sum
def printAdditivePrime ( arr , n ) :
    maxEle = max ( arr )
    prime = [ 0 ] * ( maxEle + 1 )
    sieve ( maxEle , prime )
    for i in range ( n ) :
        if ( prime [ arr [ i ] ] == 0 ) :
            sum = digitSum ( arr [ i ] )
            if ( prime [ sum ] == 0 ) :
                print ( arr [ i ] , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    a = [ 2 , 4 , 6 , 11 , 12 , 18 , 7 ]
    n = len ( a )
    printAdditivePrime ( a , n )

Index/key variables: i, j, sum
Iterator variables: i, j
Python program:
def countDivisors ( n ) :
    x , ans = 0 , 1
    while ( n % 2 == 0 ) :
        x += 1
        n = n / 2
    ans = ans * ( x + 1 )
    for i in range ( 3 , int ( n ** 1 / 2 ) + 1 , 2 ) :
        x = 0
        while ( n % i == 0 ) :
            x += 1
            n = n / i
        ans = ans * ( x + 1 )
    if ( n > 2 ) :
        ans = ans * 2
    return ans
def getTotalCount ( n , k ) :
    k_count = countDivisors ( k )
    count = 0
    for i in range ( 1 , n ) :
        if ( k_count == countDivisors ( i ) ) :
            count += 1
    if ( k < n ) :
        count = count - 1
    return count
if __name__ == ' _ _ main _ _ ' :
    n , k = 500 , 6
    print ( getTotalCount ( n , k ) )

Accumulator variables: count, x
Iterator variables: i
Python program:
MAX_VAL = 200000
def countIntervals ( arr , V , N ) :
    minimum = float ( " inf " )
    maximum = 0
    freq = [ 0 ] * ( MAX_VAL )
    for i in range ( 0 , N ) :
        li = arr [ i ] [ 0 ]
        freq [ li ] = freq [ li ] + 1
        ri = arr [ i ] [ 1 ]
        freq [ ri + 1 ] = freq [ ri + 1 ] - 1
        if li < minimum :
            minimum = li
        if ri > maximum :
            maximum = ri
    for i in range ( minimum , maximum + 1 ) :
        freq [ i ] = freq [ i ] + freq [ i - 1 ]
    return freq [ V ]
if __name__ == " _ _ main _ _ " :
    arr = [ [ 1 , 10 ] , [ 5 , 10 ] , [ 15 , 25 ] , [ 7 , 12 ] , [ 20 , 25 ] ]
    V = 7
    N = len ( arr )
    print ( countIntervals ( arr , V , N ) )

Index/key variables: V, i, li
Iterator variables: i
Python program:
def printGroups ( n ) :
    x = 1
    y = n * n
    for i in range ( 1 , n + 1 ) :
        for j in range ( 1 , n // 2 + 1 ) :
            print ( " { " , x , " , " , y , " } " , end = " ▁ " )
            x += 1
            y -= 1
        print ( )
if __name__ == " _ _ main _ _ " :
    n = 4
    printGroups ( n )

Accumulator variables: x, y
Iterator variables: i, j
Python program:
def numbers ( n , arr , m ) :
    isZero = 0
    isFive = 0
    result = 0
    if ( m < n ) :
        return - 1
    for i in range ( m ) :
        if ( arr [ i ] == 0 ) :
            isZero = 1
        if ( arr [ i ] == 5 ) :
            isFive = 1
    if ( isZero and isFive ) :
        result = 2
        for i in range ( n - 1 ) :
            m -= 1
            result = result * ( m )
    elif ( isZero or isFive ) :
        result = 1
        for i in range ( n - 1 ) :
            m -= 1
            result = result * ( m )
    else :
        result = - 1
    return result
if __name__ == " _ _ main _ _ " :
    n = 3
    m = 6
    arr = [ 2 , 3 , 5 , 6 , 7 , 9 ]
    print ( numbers ( n , arr , m ) )

Index/key variables: i
Accumulator variables: m
Iterator variables: i
Python program:
def maxSum ( a , n ) :
    maxAnd = max ( a )
    maxOR = 0
    for i in range ( n ) :
        maxOR |= a [ i ]
    print ( maxAnd + maxOR )
n = 4
a = [ 3 , 5 , 6 , 1 ]
maxSum ( a , n )

Index/key variables: i
Accumulator variables: maxOR
Iterator variables: i
Python program:
R = 3
C = 4
def magic ( a , b , c , d , e , f , g , h , i ) :
    s1 = set ( [ a , b , c , d , e , f , g , h , i ] )
    s2 = set ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] )
    if ( s1 == s2 and ( a + b + c ) == 15 and ( d + e + f ) == 15 and ( g + h + i ) == 15 and ( a + d + g ) == 15 and ( b + e + h ) == 15 and ( c + f + i ) == 15 and ( a + e + i ) == 15 and ( c + e + g ) == 15 ) :
        return True
    return false
def CountMagicSquare ( Grid ) :
    ans = 0
    for i in range ( 0 , R - 2 ) :
        for j in range ( 0 , C - 2 ) :
            if Grid [ i + 1 ] [ j + 1 ] != 5 :
                continue
            if ( magic ( Grid [ i ] [ j ] , Grid [ i ] [ j + 1 ] , Grid [ i ] [ j + 2 ] , Grid [ i + 1 ] [ j ] , Grid [ i + 1 ] [ j + 1 ] , Grid [ i + 1 ] [ j + 2 ] , Grid [ i + 2 ] [ j ] , Grid [ i + 2 ] [ j + 1 ] , Grid [ i + 2 ] [ j + 2 ] ) == True ) :
                ans += 1
    return ans
if __name__ == " _ _ main _ _ " :
    G = [ [ 4 , 3 , 8 , 4 ] , [ 9 , 5 , 1 , 9 ] , [ 2 , 7 , 6 , 2 ] ]
    print ( CountMagicSquare ( G ) )

Index/key variables: i, j
Accumulator variables: ans
Iterator variables: i, j
Python program:
def sumSubarrayMins ( A , n ) :
    left , right = [ None ] * n , [ None ] * n
    s1 , s2 = [ ] , [ ]
    for i in range ( 0 , n ) :
        cnt = 1
        while len ( s1 ) > 0 and s1 [ - 1 ] [ 0 ] > A [ i ] :
            cnt += s1 [ - 1 ] [ 1 ]
            s1 . pop ( )
        s1 . append ( [ A [ i ] , cnt ] )
        left [ i ] = cnt
    for i in range ( n - 1 , - 1 , - 1 ) :
        cnt = 1
        while len ( s2 ) > 0 and s2 [ - 1 ] [ 0 ] >= A [ i ] :
            cnt += s2 [ - 1 ] [ 1 ]
            s2 . pop ( )
        s2 . append ( [ A [ i ] , cnt ] )
        right [ i ] = cnt
    result = 0
    for i in range ( 0 , n ) :
        result += A [ i ] * left [ i ] * right [ i ]
    return result
if __name__ == " _ _ main _ _ " :
    A = [ 3 , 1 , 2 , 4 ]
    n = len ( A )
    print ( sumSubarrayMins ( A , n ) )

Index/key variables: i
Accumulator variables: cnt, result, s1, s2
Iterator variables: i
Python program:
import sys
def getMin ( arr , n , k ) :
    res = sys . maxsize
    for i in range ( n ) :
        if ( arr [ i ] % k == 0 ) :
            res = min ( res , arr [ i ] )
    return res
def getMax ( arr , n , k ) :
    res = 0
    for i in range ( 1 , n ) :
        if ( arr [ i ] % k == 0 ) :
            res = max ( res , arr [ i ] )
    return res
if __name__ == " _ _ main _ _ " :
    arr = [ 10 , 1230 , 45 , 67 , 1 ]
    k = 10
    n = len ( arr )
    print ( " Minimum ▁ element ▁ of ▁ array ▁ which " , " is ▁ divisible ▁ by ▁ k : ▁ " , getMin ( arr , n , k ) )
    print ( " Maximum ▁ element ▁ of ▁ array ▁ which " , " is ▁ divisible ▁ by ▁ k : ▁ " , getMax ( arr , n , k ) )

Index/key variables: i
Iterator variables: i
Python program:
def printNumberWithDR ( k , d ) :
    if d == 0 and k != 1 :
        print ( - 1 , end = " " )
    else :
        print ( d , end = " " )
        k -= 1
        while k :
            print ( 0 , end = " " )
            k -= 1
if __name__ == " _ _ main _ _ " :
    k , d = 4 , 4
    printNumberWithDR ( k , d )

Accumulator variables: k
Python program:
def countNumbers ( n ) :
    c = 0
    limit = int ( n ** ( 0.5 ) )
    prime = [ i for i in range ( limit + 1 ) ]
    i = 2
    while i * i <= limit :
        if prime [ i ] == i :
            for j in range ( i * i , limit + 1 , i ) :
                if prime [ j ] == j :
                    prime [ j ] = i
        i += 1
    for i in range ( 2 , limit + 1 ) :
        p = prime [ i ]
        q = prime [ i // prime [ i ] ]
        if p * q == i and q != 1 and p != q :
            c += 1
        elif prime [ i ] == i :
            if i ** 8 <= n :
                c += 1
    return c
if __name__ == " _ _ main _ _ " :
    n = 1000
    print ( countNumbers ( n ) )

Index/key variables: i, j
Accumulator variables: c
Iterator variables: i, j
Python program:
def get_unit_digit ( N ) :
    if ( N == 0 or N == 1 ) :
        return 1
    elif ( N == 2 ) :
        return 3
    elif ( N == 3 ) :
        return 9
    else :
        return 3
N = 1
for N in range ( 11 ) :
    print ( " For ▁ N ▁ = ▁ " , N , " : " , get_unit_digit ( N ) , sep = ' ▁ ' )

Iterator variables: N
Python program:
MAX = 1000
f = [ 0 for i in range ( MAX ) ]
def fib ( n ) :
    if n == 0 :
        return 0
    if n == 1 or n == 2 :
        return 1
    if f [ n ] :
        return f [ n ]
    if n & 1 :
        k = ( n + 1 ) // 2
    else :
        k = n // 2
    if n & 1 :
        f [ n ] = ( fib ( k ) * fib ( k ) + fib ( k - 1 ) * fib ( k - 1 ) )
    else :
        f [ n ] = ( ( 2 * fib ( k - 1 ) + fib ( k ) ) * fib ( k ) )
    return f [ n ]
def calculateSumOfSquares ( n ) :
    return fib ( n ) * fib ( n + 1 )
n = 6
print ( " Sum ▁ of ▁ Squares ▁ of ▁ " " Fibonacci ▁ numbers ▁ is ▁ : " , calculateSumOfSquares ( n ) )

Index/key variables: n
Python program:
def NumberOfSolutions ( x , y , z , n ) :
    ans = 0
    for i in range ( x + 1 ) :
        for j in range ( y + 1 ) :
            temp = n - i - j
            if temp >= 0 :
                temp = min ( temp , z )
                ans += temp + 1
    return ans
if __name__ == " _ _ main _ _ " :
    x , y , z , n = 1 , 2 , 3 , 4
    print ( NumberOfSolutions ( x , y , z , n ) )

Accumulator variables: ans
Iterator variables: i, j
Python program:
import math
def isPerfectSquare ( x ) :
    sr = math . sqrt ( x )
    return ( ( sr - math . floor ( sr ) ) == 0 )
def isProduct ( num ) :
    cnt = 0
    i = 2
    while cnt < 2 and i * i <= num :
        while ( num % i == 0 ) :
            num //= i
            cnt += 1
        i += 1
    if ( num > 1 ) :
        cnt += 1
    return cnt == 2
def findNumbers ( N ) :
    vec = [ ]
    for i in range ( 1 , N + 1 ) :
        if ( isProduct ( i ) and not isPerfectSquare ( i ) ) :
            vec . append ( i )
    for i in range ( len ( vec ) ) :
        print ( vec [ i ] , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    N = 30
    findNumbers ( N )

Index/key variables: i
Accumulator variables: cnt, num, vec
Iterator variables: i