dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
TEN = 10
def digitSum ( n ) :
    sum = 0
    while ( n > 0 ) :
        sum += n % TEN
        n //= TEN
    return sum
def getNthTerm ( n ) :
    sum = digitSum ( n )
    if ( sum % TEN == 0 ) :
        return ( n * TEN )
    extra = TEN - ( sum % TEN )
    return ( ( n * TEN ) + extra )
def firstNTerms ( n ) :
    for i in range ( 1 , n + 1 ) :
        print ( getNthTerm ( i ) , end = " ▁ " )
n = 10
firstNTerms ( n )

Accumulator variables: n, sum
Iterator variables: i
Python program:
min1 = 10 ** 9
_count = 0
def permutation ( str1 , i , n , p ) :
    global min1 , _count
    if ( i == n ) :
        str1 = " " . join ( str1 )
        q = int ( str1 )
        if ( q - p > 0 and q < min1 ) :
            min1 = q
            _count = 1
    else :
        for j in range ( i , n + 1 ) :
            str1 [ i ] , str1 [ j ] = str1 [ j ] , str1 [ i ]
            permutation ( str1 , i + 1 , n , p )
            str1 [ i ] , str1 [ j ] = str1 [ j ] , str1 [ i ]
    return min1
A = 213
B = 111
str2 = str ( A )
str1 = [ i for i in str2 ]
le = len ( str1 )
h = permutation ( str1 , 0 , le - 1 , B )
if _count == 1 :
    print ( h )
else :
    print ( - 1 )

Index/key variables: i, j
Iterator variables: j
Python program:
from math import ceil , floor
def Alcuin ( n ) :
    _n = n
    ans = 0
    ans = ( round ( ( _n * _n ) / 12 ) - floor ( _n / 4 ) * floor ( ( _n + 2 ) / 4 ) )
    return ans
def solve ( n ) :
    for i in range ( 1 , n + 1 ) :
        print ( Alcuin ( i ) , end = " , ▁ " )
n = 15
solve ( n )

Iterator variables: i
Python program:
def solve ( arr , n ) :
    b = [ 0 for i in range ( n ) ]
    p = 0
    i = n - 1
    while i >= 0 :
        b [ p ] = arr [ i ]
        i -= 1
        if ( i >= 0 ) :
            b [ n - 1 - p ] = arr [ i ]
        p += 1
        i -= 1
    return b
arr = [ 1 , 2 , 3 , 4 ]
n = len ( arr )
b = solve ( arr , n )
print ( b )

Index/key variables: i, p
Python program:
def productsDistinct ( N ) :
    s = " "
    while ( N ) :
        s += chr ( N % 10 + ord ( '0' ) )
        N //= 10
    s = s [ : : - 1 ]
    sz = len ( s )
    se = [ ]
    for i in range ( sz ) :
        product = 1
        for j in range ( i , sz , 1 ) :
            product *= ord ( s [ j ] ) - ord ( '0' )
            for p in range ( len ( se ) ) :
                if se [ p ] == product :
                    return False
                else :
                    se . append ( product )
    return True
if __name__ == ' _ _ main _ _ ' :
    N = 2345
    if ( productsDistinct ( N ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: j, p
Accumulator variables: N, product, s, se
Iterator variables: i, j, p
Python program:
def findSmallestNonZeroY ( A_num ) :
    A_binary = bin ( A_num )
    B = 1
    length = len ( A_binary ) ;
    no_ones = ( A_binary ) . count ( '1' ) ;
    if length == no_ones :
        return A_num + 1 ;
    for i in range ( length ) :
        ch = A_binary [ length - i - 1 ] ;
        if ( ch == '0' ) :
            B = pow ( 2.0 , i ) ;
            break ;
    return B ;
if __name__ == " _ _ main _ _ " :
    X = findSmallestNonZeroY ( 10 ) ;
    print ( X )

Iterator variables: i
Python program:
N = 32
def binStrToInt ( binary_str ) :
    length = len ( binary_str )
    num = 0
    for i in range ( length ) :
        num = num + int ( binary_str [ i ] )
        num = num * 2
    return num / 2
def GetOne ( s , L , R ) :
    length = len ( s ) ;
    bit = s . zfill ( 32 - len ( s ) ) ;
    bit = int ( binStrToInt ( bit ) )
    bit <<= ( N - length + L - 1 ) ;
    bit >>= ( N - length + L - 1 ) ;
    bit >>= ( length - R ) ;
    return bin ( bit ) . count ( '1' ) ;
if __name__ == " _ _ main _ _ " :
    s = "01010001011" ;
    L = 2 ; R = 4 ;
    print ( GetOne ( s , L , R ) ) ;

Index/key variables: i
Iterator variables: i
Python program:
def specialSieve ( n ) :
    cnt = 0 ;
    prime = [ 0 ] * ( n + 1 ) ;
    for i in range ( 2 , n + 1 ) :
        if ( not prime [ i ] ) :
            cnt += 1 ;
            for j in range ( i , n + 1 , i ) :
                prime [ j ] = cnt ;
    for i in range ( 2 , n + 1 ) :
        print ( prime [ i ] , end = " ▁ " ) ;
if __name__ == " _ _ main _ _ " :
    n = 6 ;
    specialSieve ( n ) ;

Index/key variables: i, j
Accumulator variables: cnt
Iterator variables: i, j
Python program:
from sys import maxsize
maximum , x , ans = - maxsize , None , maxsize
graph = [ [ ] for i in range ( 100 ) ]
weight = [ 0 ] * 100
def dfs ( node , parent ) :
    global x , ans , graph , weight , maximum
    a = bin ( weight [ node ] + x ) . count ( '1' )
    if maximum < a :
        maximum = a
        ans = node
    elif maximum == a :
        ans = min ( ans , node )
    for to in graph [ node ] :
        if to == parent :
            continue
        dfs ( to , node )
if __name__ == " _ _ main _ _ " :
    x = 15
    weight [ 1 ] = 5
    weight [ 2 ] = 10
    weight [ 3 ] = 11
    weight [ 4 ] = 8
    weight [ 5 ] = 6
    graph [ 1 ] . append ( 2 )
    graph [ 2 ] . append ( 3 )
    graph [ 2 ] . append ( 4 )
    graph [ 1 ] . append ( 5 )
    dfs ( 1 , 1 )
    print ( ans )

Index/key variables: node
Iterator variables: to
Python program:
def count_pairs ( a , b , n , m ) :
    odd1 = 0
    even1 = 0
    odd2 = 0
    even2 = 0
    for i in range ( n ) :
        if ( a [ i ] % 2 == 1 ) :
            odd1 += 1
        else :
            even1 += 1
    for i in range ( m ) :
        if ( b [ i ] % 2 == 1 ) :
            odd2 += 1
        else :
            even2 += 1
    pairs = min ( odd1 , odd2 ) + min ( even1 , even2 )
    return pairs
if __name__ == ' _ _ main _ _ ' :
    a = [ 9 , 14 , 6 , 2 , 11 ]
    b = [ 8 , 4 , 7 , 20 ]
    n = len ( a )
    m = len ( b )
    print ( count_pairs ( a , b , n , m ) )

Index/key variables: i
Accumulator variables: even1, even2, odd1, odd2
Iterator variables: i
Python program:
import math
def solve ( Array , N ) :
    Arraynew = [ 0 ] * N
    for i in range ( N ) :
        Arraynew [ i ] = math . log ( Array [ i ] )
    prefixsum = [ 0 ] * N
    prefixsum [ 0 ] = Arraynew [ 0 ]
    for i in range ( 1 , N ) :
        prefixsum [ i ] = prefixsum [ i - 1 ] + Arraynew [ i ]
    answer = 0
    minabs = abs ( prefixsum [ N - 1 ] - 2 * prefixsum [ 0 ] )
    for i in range ( 1 , N - 1 ) :
        ans1 = abs ( prefixsum [ N - 1 ] - 2 * prefixsum [ i ] )
        if ( ans1 < minabs ) :
            minabs = ans1
            answer = i
    print ( " Index ▁ is : ▁ " , answer )
if __name__ == " _ _ main _ _ " :
    Array = [ 1 , 4 , 12 , 2 , 6 ]
    N = 5
    solve ( Array , N )

Index/key variables: i
Iterator variables: i
Python program:
def getValueOfF ( n ) :
    if ( n == 1 ) :
        return 0
    if ( n == 2 ) :
        return 1
    cnt = 0
    while ( n % 2 == 0 ) :
        cnt += 1
        n /= 2
    return 2 * cnt
n = 20
print ( getValueOfF ( n ) )

Accumulator variables: cnt, n
Python program:
N = 100005
mod = 1000000007
cnt = [ 0 ] * N ;
def Divisors ( ) :
    for i in range ( 1 , N ) :
        for j in range ( 1 , N // i ) :
            cnt [ i * j ] += 1 ;
def Sumofdivisors ( A , B , C ) :
    sum = 0 ;
    Divisors ( ) ;
    for i in range ( 1 , A + 1 ) :
        for j in range ( 1 , B + 1 ) :
            for k in range ( 1 , C + 1 ) :
                x = i * j * k ;
                sum += cnt [ x ] ;
                if ( sum >= mod ) :
                    sum -= mod ;
    return sum ;
if __name__ == " _ _ main _ _ " :
    A = 5 ; B = 6 ; C = 7 ;
    print ( Sumofdivisors ( A , B , C ) ) ;

Index/key variables: x
Accumulator variables: sum
Iterator variables: i, j, k
Python program:
def A_mod_B ( N , a ) :
    Len = len ( N )
    ans = 0
    for i in range ( Len ) :
        ans = ( ans * 10 + int ( N [ i ] ) ) % a
    return ans % a
def findMod ( N ) :
    mod = A_mod_B ( N , 4 )
    ans = ( 1 + pow ( 2 , mod ) + pow ( 3 , mod ) + pow ( 4 , mod ) )
    return ans % 5
N = "4"
print ( findMod ( N ) )

Index/key variables: i
Iterator variables: i
Python program:
def printElements ( arr , n ) :
    for i in range ( 1 , n - 1 , 1 ) :
        if ( arr [ i ] > arr [ i - 1 ] and arr [ i ] > arr [ i + 1 ] ) :
            print ( arr [ i ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 2 , 3 , 1 , 5 , 4 , 9 , 8 , 7 , 5 ]
    n = len ( arr )
    printElements ( arr , n )

Index/key variables: i
Iterator variables: i
Python program:
from math import sqrt
def isPrime ( x ) :
    for i in range ( 2 , int ( sqrt ( x ) ) + 1 ) :
        if ( x % i == 0 ) :
            return 0 ;
    return 1 ;
def minimumCost ( n ) :
    if ( isPrime ( n ) ) :
        return 1 ;
    if ( n % 2 == 1 and isPrime ( n - 2 ) ) :
        return 2 ;
    if ( n % 2 == 0 ) :
        return 2 ;
    return 3 ;
if __name__ == " _ _ main _ _ " :
    n = 6 ;
    print ( minimumCost ( n ) ) ;

Iterator variables: i
Python program:
MAX = 100001 ;
prefix = [ 0 ] * MAX ;
def sieve_modified ( ) :
    for i in range ( 1 , MAX , 2 ) :
        for j in range ( i , MAX , i ) :
            prefix [ j ] += i ;
    for i in range ( 1 , MAX ) :
        prefix [ i ] += prefix [ i - 1 ] ;
def sumOddFactors ( L , R ) :
    return ( prefix [ R ] - prefix [ L - 1 ] ) ;
sieve_modified ( ) ;
l = 6 ;
r = 10 ;
print ( sumOddFactors ( l , r ) ) ;

Index/key variables: R, i, j
Iterator variables: i, j
Python program:
n = 3
def preComputeXor ( arr , prefix_xor ) :
    for i in range ( n ) :
        for j in range ( n ) :
            if ( j == 0 ) :
                prefix_xor [ i ] [ j ] = arr [ i ] [ j ]
            else :
                prefix_xor [ i ] [ j ] = ( prefix_xor [ i ] [ j - 1 ] ^ arr [ i ] [ j ] )
    for i in range ( n ) :
        for j in range ( 1 , n ) :
            prefix_xor [ j ] [ i ] = ( prefix_xor [ j - 1 ] [ i ] ^ prefix_xor [ j ] [ i ] )
def ansQuerie ( prefix_xor , x1 , y1 , x2 , y2 ) :
    xor_1 , xor_2 , xor_3 = 0 , 0 , 0
    if ( x1 != 0 ) :
        xor_1 = prefix_xor [ x1 - 1 ] [ y2 ]
    if ( y1 != 0 ) :
        xor_2 = prefix_xor [ x2 ] [ y1 - 1 ]
    if ( x1 != 0 and y1 != 0 ) :
        xor_3 = prefix_xor [ x1 - 1 ] [ y1 - 1 ]
    return ( ( prefix_xor [ x2 ] [ y2 ] ^ xor_1 ) ^ ( xor_2 ^ xor_3 ) )
arr = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 7 , 8 , 9 ] ]
prefix_xor = [ [ 0 for i in range ( n ) ] for i in range ( n ) ]
preComputeXor ( arr , prefix_xor )
print ( ansQuerie ( prefix_xor , 1 , 1 , 2 , 2 ) )
print ( ansQuerie ( prefix_xor , 1 , 2 , 2 , 2 ) )

Index/key variables: i, j, x2, y2
Iterator variables: i, j
Python program:
import math
def isDigitSumOne ( nm ) :
    if ( nm % 9 == 1 ) :
        return True
    else :
        return False
def printValidNums ( n ) :
    cbrt_n = math . ceil ( n ** ( 1. / 3. ) )
    for i in range ( 1 , cbrt_n + 1 ) :
        cube = i * i * i
        if ( cube >= 1 and cube <= n and isDigitSumOne ( cube ) ) :
            print ( cube , end = " ▁ " )
n = 1000
printValidNums ( n )

Iterator variables: i
Python program:
def countRhombi ( h , w ) :
    ct = 0 ;
    for i in range ( 2 , h + 1 , 2 ) :
        for j in range ( 2 , w + 1 , 2 ) :
            ct += ( h - i + 1 ) * ( w - j + 1 )
    return ct
if __name__ == " _ _ main _ _ " :
    h = 2
    w = 2
    print ( countRhombi ( h , w ) )

Accumulator variables: ct
Iterator variables: i, j
Python program:
from math import gcd
def getWinner ( arr , n ) :
    __gcd = arr [ 0 ] ;
    maxEle = arr [ 0 ] ;
    for i in range ( 1 , n ) :
        __gcd = gcd ( __gcd , arr [ i ] ) ;
        maxEle = max ( maxEle , arr [ i ] ) ;
    totalMoves = ( maxEle / __gcd ) - n ;
    if ( totalMoves % 2 == 1 ) :
        return ' A ' ;
    return ' B ' ;
if __name__ == " _ _ main _ _ " :
    arr = [ 5 , 6 , 7 ] ;
    n = len ( arr )
    print ( getWinner ( arr , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def countPairs ( n ) :
    num = ( ( n // 2 ) + 1 )
    Max = n % num
    count = 0
    for i in range ( 1 , n + 1 ) :
        for j in range ( 1 , n + 1 ) :
            val = ( ( n % i ) % j ) % n
            if ( val == Max ) :
                count += 1
    return count
n = 5
print ( countPairs ( n ) )

Accumulator variables: count
Iterator variables: i, j
Python program:
def isDivisible ( n ) :
    temp = n
    while ( n ) :
        k = n % 10
        if ( temp % k == 0 ) :
            return " YES "
        n /= 10 ;
    return " NO "
n = 9876543
print ( isDivisible ( n ) )

Accumulator variables: n
Python program:
def sum ( n ) :
    i = 1
    s = 0.0
    for i in range ( 1 , n + 1 ) :
        s = s + 1 / i ;
    return s ;
n = 5
print ( " Sum ▁ is " , round ( sum ( n ) , 6 ) )

Iterator variables: i
Python program:
from math import sqrt
N = 100005
def ABUNDANT ( ) :
    v = set ( ) ;
    for i in range ( 1 , N ) :
        sum = 1
        for j in range ( 2 , int ( sqrt ( i ) ) + 1 ) :
            if ( i % j == 0 ) :
                sum += j
            if ( i / j != j ) :
                sum += i // j
        if ( sum > i ) :
            v . add ( i )
    return v
def SumOfAbundant ( n ) :
    v = ABUNDANT ( )
    for i in range ( 1 , n + 1 ) :
        if ( list ( v ) . count ( i ) and list ( v ) . count ( n - i ) ) :
            print ( i , " ▁ " , n - i )
            return
    print ( - 1 )
if __name__ == " _ _ main _ _ " :
    n = 24
    SumOfAbundant ( n )

Accumulator variables: sum, v
Iterator variables: i, j
Python program:
from math import log2
def obtain_str ( n ) :
    length = int ( log2 ( n + 1 ) )
    rel_ind = n + 1 - pow ( 2 , length )
    i = 0
    string = " "
    for i in range ( length ) :
        string += ' a '
    i = 0
    string_list = list ( string )
    while ( rel_ind > 0 ) :
        if ( rel_ind % 2 == 1 ) :
            string_list [ i ] = ' b '
        rel_ind //= 2
        i += 1
    string_list . reverse ( )
    string = " " . join ( string_list )
    return string
if __name__ == " _ _ main _ _ " :
    n = 11
    print ( obtain_str ( n ) )

Index/key variables: i
Accumulator variables: rel_ind, string
Iterator variables: i
Python program:
def SquareCube ( N ) :
    cnt , i = 0 , 1
    while ( i ** 6 <= N ) :
        cnt += 1
        i += 1
    return cnt
N = 100000
print ( SquareCube ( N ) )

Accumulator variables: cnt, i
Python program:
def getSum ( n , d ) :
    sum = 0
    while ( d <= n ) :
        sum += d
        d += 10
    return sum
n = 30
d = 3
print ( getSum ( n , d ) )

Accumulator variables: d, sum
Python program:
def printMode ( a , n ) :
    max_element = max ( a )
    t = max_element + 1
    count = [ 0 ] * t
    for i in range ( t ) :
        count [ i ] = 0
    for i in range ( n ) :
        count [ a [ i ] ] += 1
    mode = 0
    k = count [ 0 ]
    for i in range ( 1 , t ) :
        if ( count [ i ] > k ) :
            k = count [ i ]
            mode = i
    print ( " mode ▁ = ▁ " , mode )
if __name__ == " _ _ main _ _ " :
    a = [ 1 , 4 , 1 , 2 , 7 , 1 , 2 , 5 , 3 , 6 ]
    n = len ( a )
    printMode ( a , n )

Index/key variables: i
Iterator variables: i
Python program:
def checkIsHP ( arr ) :
    n = len ( arr )
    if ( n == 1 ) :
        return True
    rec = [ ]
    for i in range ( 0 , len ( arr ) ) :
        a = 1 / arr [ i ]
        rec . append ( a )
    return ( rec )
    rec . sort ( )
    d = rec [ 1 ] - rec [ 0 ]
    for i in range ( 2 , n ) :
        if ( rec [ i ] - rec [ i - 1 ] != d ) :
            return False
    return True
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 / 5 , 1 / 10 , 1 / 15 , 1 / 20 , 1 / 25 ]
    if ( checkIsHP ( arr ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Accumulator variables: rec
Iterator variables: i
Python program:
def printAMeans ( A , B , N ) :
    d = ( B - A ) / ( N + 1 )
    for i in range ( 1 , N + 1 ) :
        print ( int ( A + i * d ) , end = " ▁ " )
A = 20 ; B = 32 ; N = 5
printAMeans ( A , B , N )

Iterator variables: i
Python program:
def CheckArray ( arr , n ) :
    prod = 1
    for i in range ( 0 , n , 1 ) :
        prod *= arr [ i ]
    for i in range ( 0 , n , 1 ) :
        if ( arr [ i ] == prod / arr [ i ] ) :
            return True
    return False
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 2 , 12 , 3 , 2 ]
    n = len ( arr )
    if ( CheckArray ( arr , n ) ) :
        print ( " YES " )
    else :
        print ( " NO " )

Index/key variables: i
Accumulator variables: prod
Iterator variables: i
Python program:
def sum ( a , b ) :
    sum = 0
    for i in range ( 1 , min ( a , b ) ) :
        if ( a % i == 0 and b % i == 0 ) :
            sum += i
    return sum
A = 10
B = 15
print ( " Sum ▁ = " , sum ( A , B ) )

Accumulator variables: sum
Iterator variables: i
Python program:
import math
def minimumCuts ( a , n ) :
    a . sort ( )
    gcd = a [ 1 ] - a [ 0 ]
    s = gcd
    for i in range ( 2 , n ) :
        gcd = math . gcd ( gcd , a [ i ] - a [ i - 1 ] )
        s += a [ i ] - a [ i - 1 ]
    if ( 360 - s > 0 ) :
        gcd = math . gcd ( gcd , 360 - s )
    return ( 360 // gcd ) - n
if __name__ == " _ _ main _ _ " :
    arr = [ 30 , 60 , 180 ]
    n = len ( arr )
    print ( minimumCuts ( arr , n ) )

Index/key variables: i
Accumulator variables: s
Iterator variables: i
Python program:
import math as mt
MAXN = 100001
spf = [ 0 for i in range ( MAXN ) ]
def sieve ( ) :
    spf [ 1 ] = 1
    for i in range ( 2 , MAXN ) :
        spf [ i ] = i
    for i in range ( 4 , MAXN , 2 ) :
        spf [ i ] = 2
    for i in range ( 3 , mt . ceil ( mt . sqrt ( MAXN + 1 ) ) ) :
        if ( spf [ i ] == i ) :
            for j in range ( 2 * i , MAXN , i ) :
                if ( spf [ j ] == j ) :
                    spf [ j ] = i
def getFactorization ( x ) :
    ret = list ( )
    while ( x != 1 ) :
        temp = spf [ x ]
        ret . append ( temp )
        while ( x % temp == 0 ) :
            x = x // temp
    return ret
def maxElement ( A , n ) :
    sieve ( )
    m = dict ( )
    for i in range ( n ) :
        p = getFactorization ( A [ i ] )
        for i in range ( len ( p ) ) :
            if p [ i ] in m . keys ( ) :
                m [ p [ i ] ] += 1
            else :
                m [ p [ i ] ] = 1
    cnt = 0
    ans = 10 ** 9 + 7
    for i in m :
        if ( m [ i ] >= cnt ) :
            cnt = m [ i ]
            if ans > i :
                ans = i
            else :
                ans = ans
    return ans
A = [ 2 , 5 , 10 ]
n = len ( A )
print ( maxElement ( A , n ) )

Index/key variables: i, j, x
Accumulator variables: ret
Iterator variables: i, j
Python program:
import math as mt
def compositeProduct ( arr , n ) :
    max_val = max ( arr )
    prime = [ True for i in range ( max_val + 1 ) ]
    prime [ 0 ] = True
    prime [ 1 ] = True
    for p in range ( 2 , mt . ceil ( mt . sqrt ( max_val ) ) ) :
        if prime [ p ] :
            for i in range ( p * 2 , max_val + 1 , p ) :
                prime [ i ] = False
    product = 1
    for i in range ( n ) :
        if prime [ arr [ i ] ] == False :
            product *= arr [ i ]
    return product
arr = [ 2 , 3 , 4 , 5 , 6 , 7 ]
n = len ( arr )
print ( compositeProduct ( arr , n ) )

Index/key variables: i, p
Accumulator variables: product
Iterator variables: i, p
Python program:
def sum_odd ( n ) :
    sums = 0
    pos = 1
    while ( n != 0 ) :
        if ( pos % 2 == 1 ) :
            sums += n % 10
        n = n // 10
        pos += 1
    return sums
def check_prime ( n ) :
    if ( n <= 1 ) :
        return False
    if ( n <= 3 ) :
        return True
    if ( n % 2 == 0 or n % 3 == 0 ) :
        return False
    for i in range ( 5 , n , 6 ) :
        if ( n % i == 0 or n % ( i + 2 ) == 0 ) :
            return False
    return True
n = 223
sums = sum_odd ( n )
if ( check_prime ( sums ) ) :
    print ( " YES " )
else :
    print ( " NO " )

Accumulator variables: pos, sums
Iterator variables: i
Python program:
def reverseNum ( x ) :
    s = str ( x )
    s = s [ : : - 1 ]
    return int ( s )
def isMysteryNumber ( n ) :
    for i in range ( 1 , n // 2 + 1 ) :
        j = reverseNum ( i )
        if i + j == n :
            print ( i , j )
            return True
    print ( " Not ▁ a ▁ Mystery ▁ Number " )
    return False
n = 121
isMysteryNumber ( n )

Iterator variables: i
Python program:
def ReplaceElements ( arr , n ) :
    prod = 1
    for i in range ( n ) :
        prod *= arr [ i ]
    for i in range ( n ) :
        arr [ i ] = prod // arr [ i ]
if __name__ == " _ _ main _ _ " :
    arr = [ 2 , 3 , 3 , 5 , 7 ]
    n = len ( arr )
    ReplaceElements ( arr , n )
    for i in range ( n ) :
        print ( arr [ i ] , end = " ▁ " )

Index/key variables: i
Accumulator variables: prod
Iterator variables: i
Python program:
def Check_is_possible ( l , r , k ) :
    count = 0 ;
    for i in range ( l , r + 1 ) :
        if ( i % k == 0 ) :
            count += 1 ;
    return ( count > 1 ) ;
l = 4 ;
r = 12 ;
k = 5 ;
if ( Check_is_possible ( l , r , k ) ) :
    print ( " YES " ) ;
else :
    print ( " NO " ) ;

Accumulator variables: count
Iterator variables: i
Python program:
def isValid ( N , K ) :
    m1 = [ ]
    m2 = [ ]
    while ( N > 0 ) :
        m1 . append ( N % 10 )
        N //= 10
    while ( K > 0 ) :
        m2 . append ( K % 10 )
        K //= 10
    if ( m1 == m2 ) :
        return True
    return False
def anyPermutation ( N , K ) :
    powK = [ 0 ] * 100
    Limit = pow ( 10 , 18 )
    powK [ 0 ] = K
    i = 1
    while ( powK [ i - 1 ] * K < Limit ) :
        powK [ i ] = powK [ i - 1 ] * K
        i += 1
    for j in range ( i ) :
        if ( isValid ( N , powK [ j ] ) ) :
            return " True "
    return " False "
if __name__ == " _ _ main _ _ " :
    N = 96889010407
    K = 7
    print ( anyPermutation ( N , K ) )

Index/key variables: i, j
Accumulator variables: K, N, m1, m2
Iterator variables: j
Python program:
def sumNth ( A , B , m , n ) :
    res = 0 ;
    if ( n == 1 ) :
        for i in range ( m ) :
            res = res + A [ i ] ;
    elif ( n == 2 ) :
        for i in range ( m ) :
            res = res + B [ i ] * m ;
    else :
        f = [ 0 ] * n ;
        f [ 0 ] = 0 ;
        f [ 1 ] = 1 ;
        for i in range ( 2 , n ) :
            f [ i ] = f [ i - 1 ] + f [ i - 2 ] ;
        for i in range ( m ) :
            res = ( res + ( m * ( B [ i ] * f [ n - 1 ] ) ) + ( m * ( A [ i ] * f [ n - 2 ] ) ) ) ;
    return res ;
A = [ 1 , 2 , 3 ] ;
B = [ 4 , 5 , 6 ] ;
n = 3 ;
m = len ( A ) ;
print ( sumNth ( A , B , m , n ) ) ;

Index/key variables: i
Iterator variables: i
Python program:
import math
def isPrime ( n ) :
    if n <= 1 :
        return False
    if n <= 3 :
        return True
    if n % 2 == 0 or n % 3 == 0 :
        return False
    for i in range ( 5 , int ( math . sqrt ( n ) + 1 ) , 6 ) :
        if n % i == 0 or n % ( i + 2 ) == 0 :
            return False
    return True
def isCousinPrime ( n1 , n2 ) :
    if ( not ( abs ( n1 - n2 ) == 4 ) ) :
        return False
    else :
        return ( isPrime ( n1 ) and isPrime ( n2 ) )
n1 = 7
n2 = 11
if ( isCousinPrime ( n1 , n2 ) ) :
    print ( " YES " )
else :
    print ( " NO " )

Iterator variables: i
Python program:
N = 1000
dp = [ 0 ] * ( N + 1 )
def sieve ( ) :
    array = [ 0 ] * ( N + 1 )
    array [ 0 ] = 1
    array [ 1 ] = 1
    for i in range ( 2 , math . ceil ( math . sqrt ( N ) + 1 ) ) :
        if array [ i ] == 0 :
            for j in range ( i * i , N + 1 , i ) :
                array [ j ] = 1
    runningPrimeSum = 0
    for i in range ( 1 , N + 1 ) :
        if array [ i ] == 0 :
            runningPrimeSum += i
        dp [ i ] = runningPrimeSum
l = 4
r = 13
sieve ( )
print ( dp [ r ] - dp [ l - 1 ] )

Index/key variables: i, j, r
Accumulator variables: runningPrimeSum
Iterator variables: i, j
Python program:
import sys
def findMinEqualSums ( a , N ) :
    sum = 0
    for i in range ( 0 , N ) :
        sum = sum + a [ i ]
    sum1 = 0
    sum2 = 0
    min = sys . maxsize
    for i in range ( 0 , N - 1 ) :
        sum1 += a [ i ]
        sum2 = sum - sum1
        if ( abs ( sum1 - sum2 ) < min ) :
            min = abs ( sum1 - sum2 )
        if ( min == 0 ) :
            break
    return min
if __name__ == ' _ _ main _ _ ' :
    a = [ 3 , 2 , 1 , 5 , 7 , 8 ]
    N = len ( a )
    print ( findMinEqualSums ( a , N ) )

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