dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def ispalin ( num ) :
    s = str ( num ) ;
    st = 0 ;
    ed = len ( s ) - 1 ;
    while ( st <= ed ) :
        if ( s [ st ] != s [ ed ] ) :
            return False ;
        st += 1 ;
        ed -= 1 ;
    return True ;
def CalculateXORandOR ( n ) :
    CalculateXOR = 0 ;
    CalculateOR = 0 ;
    start = 10 ** ( n - 1 ) ;
    end = ( 10 ** n ) - 1 ;
    for i in range ( start , end + 1 ) :
        if ( ispalin ( i ) ) :
            CalculateXOR = CalculateXOR ^ i ;
            CalculateOR = CalculateOR | i ;
    print ( " XOR ▁ = " , CalculateXOR , end = " ▁ " ) ;
    print ( " OR ▁ = ▁ " , CalculateOR ) ;
if __name__ == " _ _ main _ _ " :
    n = 4 ;
    CalculateXORandOR ( n ) ;

Index/key variables: ed, st
Iterator variables: i
Python program:
pref = [ 0 ] * 100001
def checkPalindrome ( num ) :
    strr = str ( num )
    l = 0
    r = len ( strr ) - 1
    while ( l < r ) :
        if ( strr [ l ] != strr [ r ] ) :
            return 0
        l += 1
        r -= 1
    return num
def preCompute ( ) :
    for i in range ( 1 , 100001 ) :
        pref [ i ] = pref [ i - 1 ] + checkPalindrome ( i )
def printSum ( L , R ) :
    print ( pref [ R ] - pref [ L - 1 ] )
def printSumPalindromic ( arr , Q ) :
    preCompute ( )
    for i in range ( Q ) :
        printSum ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] )
Q = 2
arr = [ [ 10 , 13 ] , [ 12 , 21 ] ]
printSumPalindromic ( arr , Q )

Index/key variables: R, i, l, r
Iterator variables: i
Python program:
def summation ( n ) :
    sum = 0 ;
    for i in range ( 1 , n + 1 ) :
        if ( i % 2 == 1 ) :
            sum += ( i * i ) ;
        else :
            sum -= ( i * i ) ;
    return sum ;
if __name__ == " _ _ main _ _ " :
    N = 2 ;
    print ( summation ( N ) ) ;

Accumulator variables: sum
Iterator variables: i
Python program:
def countPairs ( n ) :
    count = 0 ;
    for x in range ( 1 , n ) :
        for y in range ( x + 1 , n + 1 ) :
            if ( ( y + x ) % ( y ^ x ) == 0 ) :
                count += 1 ;
    return count ;
if __name__ == " _ _ main _ _ " :
    n = 6 ;
    print ( countPairs ( n ) ) ;

Accumulator variables: count
Iterator variables: x, y
Python program:
from math import log
def isPower ( x , y ) :
    res1 = log ( y ) // log ( x ) ;
    res2 = log ( y ) / log ( x ) ;
    return ( res1 == res2 ) ;
def countPower ( arr , n ) :
    res = 0 ;
    for i in range ( n ) :
        for j in range ( i + 1 , n ) :
            if isPower ( arr [ i ] , arr [ j ] ) or isPower ( arr [ j ] , arr [ i ] ) :
                res += 1 ;
    return res ;
if __name__ == " _ _ main _ _ " :
    a = [ 16 , 2 , 3 , 9 ] ;
    n = len ( a ) ;
    print ( countPower ( a , n ) ) ;

Index/key variables: i, j
Accumulator variables: res
Iterator variables: i, j
Python program:
def xor_all_elements ( n ) :
    if n & 3 == 0 :
        return n
    elif n & 3 == 1 :
        return 1
    elif n & 3 == 2 :
        return n + 1
    else :
        return 0
def findArray ( xorr , n ) :
    arr = [ ]
    xor_all = xor_all_elements ( n )
    xor_adjacent = 0
    for i in range ( 0 , n - 1 , 2 ) :
        xor_adjacent = xor_adjacent ^ xorr [ i ]
    last_element = xor_all ^ xor_adjacent
    arr . append ( last_element )
    for i in range ( n - 2 , - 1 , - 1 ) :
        last_element = xorr [ i ] ^ last_element
        arr . append ( last_element )
    return arr
xorr = [ 7 , 5 , 3 , 7 ]
n = 5
arr = findArray ( xorr , n )
for i in range ( n - 1 , - 1 , - 1 ) :
    print ( arr [ i ] , end = " ▁ " )

Index/key variables: i
Accumulator variables: arr
Iterator variables: i
Python program:
def sumOfParts ( arr , N ) :
    sum_part1 , sum_part2 , sum_part3 , sum_part4 = 0 , 0 , 0 , 0
    totalsum = 0
    for i in range ( N ) :
        for j in range ( N ) :
            if i + j < N - 1 :
                if ( i < j and i != j and i + j ) :
                    sum_part1 += arr [ i ] [ j ]
                elif i != j :
                    sum_part2 += arr [ i ] [ j ]
            else :
                if i > j and i + j != N - 1 :
                    sum_part3 += arr [ i ] [ j ]
                else :
                    if i + j != N - 1 and i != j :
                        sum_part4 += arr [ i ] [ j ]
    return sum_part1 + sum_part2 + sum_part3 + sum_part4
N = 4
arr = [ [ 1 , 2 , 3 , 4 ] , [ 5 , 6 , 7 , 8 ] , [ 9 , 10 , 11 , 12 ] , [ 13 , 14 , 15 , 16 ] ]
print ( sumOfParts ( arr , N ) )

Index/key variables: i, j
Accumulator variables: sum_part1, sum_part2, sum_part3, sum_part4
Iterator variables: i, j
Python program:
def canMake ( n , ar ) :
    sum = 0 ; maxx = - 1 ;
    for i in range ( n ) :
        sum += ar [ i ] ;
        maxx = max ( maxx , ar [ i ] ) ;
    if ( n == 1 or sum % 2 == 1 or sum - maxx < maxx ) :
        print ( " No " ) ;
    else :
        print ( " Yes " ) ;
if __name__ == " _ _ main _ _ " :
    n = 6 ;
    arr = [ 1 , 1 , 2 , 3 , 6 , 11 ] ;
    canMake ( n , arr ) ;

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
from math import sqrt , floor
pref = [ 0 ] * 100010 ;
def isPerfectSquare ( x ) :
    sr = sqrt ( x ) ;
    rslt = x if ( sr - floor ( sr ) == 0 ) else 0 ;
    return rslt ;
def compute ( ) :
    for i in range ( 1 , 100001 ) :
        pref [ i ] = pref [ i - 1 ] + isPerfectSquare ( i ) ;
def printSum ( L , R ) :
    sum = pref [ R ] - pref [ L - 1 ] ;
    print ( sum , end = " ▁ " ) ;
if __name__ == " _ _ main _ _ " :
    compute ( ) ;
    Q = 4 ;
    arr = [ [ 1 , 10 ] , [ 1 , 100 ] , [ 2 , 25 ] , [ 4 , 50 ] ] ;
    for i in range ( Q ) :
        printSum ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ;

Index/key variables: R, i
Iterator variables: i
Python program:
def prMultiples ( N ) :
    for i in range ( 1 , N + 1 ) :
        for j in range ( 1 , i + 1 ) :
            print ( ( i * j ) , end = " ▁ " )
        print ( )
if __name__ == ' _ _ main _ _ ' :
    N = 5
    prMultiples ( N )

Iterator variables: i, j
Python program:
def nature_of_roots ( a , b , c ) :
    if ( a == 0 ) :
        print ( " Not ▁ a ▁ Quadratic ▁ Equation " ) ;
        return ;
    D = b * b - 4 * a * c ;
    if ( D > 0 ) :
        print ( " Real ▁ Roots " ) ;
    elif ( D == 0 ) :
        print ( " Equal ▁ Roots " ) ;
    else :
        print ( " Imaginary ▁ Roots " ) ;
def checkForAllTestCase ( ) :
    print ( " Testcase TABSYMBOL a TABSYMBOL b TABSYMBOL c TABSYMBOL Actual ▁ Output " ) ;
    print ( ) ;
    a = b = c = 0 ;
    testcase = 1 ;
    while ( testcase <= 13 ) :
        if ( testcase == 1 ) :
            a = 0 ;
            b = 50 ;
            c = 50 ;
        elif ( testcase == 2 ) :
            a = 1 ;
            b = 50 ;
            c = 50 ;
        elif ( testcase == 3 ) :
            a = 50 ;
            b = 50 ;
            c = 50 ;
        elif ( testcase == 4 ) :
            a = 99 ;
            b = 50 ;
            c = 50 ;
        elif ( testcase == 5 ) :
            a = 100 ;
            b = 50 ;
            c = 50 ;
        elif ( testcase == 6 ) :
            a = 50 ;
            b = 0 ;
            c = 50 ;
        elif ( testcase == 7 ) :
            a = 50 ;
            b = 1 ;
            c = 50 ;
        elif ( testcase == 8 ) :
            a = 50 ;
            b = 99 ;
            c = 50 ;
        elif ( testcase == 9 ) :
            a = 50 ;
            b = 100 ;
            c = 50 ;
        elif ( testcase == 10 ) :
            a = 50 ;
            b = 50 ;
            c = 0 ;
        elif ( testcase == 11 ) :
            a = 50 ;
            b = 50 ;
            c = 1 ;
        elif ( testcase == 12 ) :
            a = 50 ;
            b = 50 ;
            c = 99 ;
        elif ( testcase == 13 ) :
            a = 50 ;
            b = 50 ;
            c = 100 ;
        print ( " TABSYMBOL " , testcase , " TABSYMBOL " , a , " TABSYMBOL " , b , " TABSYMBOL " , c , " TABSYMBOL " , end = " " ) ;
        nature_of_roots ( a , b , c ) ;
        print ( ) ;
        testcase += 1 ;
if __name__ == ' _ _ main _ _ ' :
    checkForAllTestCase ( ) ;

Accumulator variables: testcase
Python program:
def SubarraysWithSumS ( n , k , s ) :
    for i in range ( k ) :
        print ( s , end = " ▁ " )
    for i in range ( k , n ) :
        print ( s + 1 , end = " ▁ " )
n = 4
k = 2
s = 3
SubarraysWithSumS ( n , k , s )

Iterator variables: i
Python program:
MAX = 100000
max_prime = [ 0 ] * ( MAX + 1 )
min_prime = [ 0 ] * ( MAX + 1 )
def sieve ( n ) :
    for i in range ( 2 , n + 1 ) :
        if ( min_prime [ i ] > 0 ) :
            continue
        min_prime [ i ] = i
        max_prime [ i ] = i
        j = i + i
        while ( j <= n ) :
            if ( min_prime [ j ] == 0 ) :
                min_prime [ j ] = i
            max_prime [ j ] = i
            j += i
def findSum ( arr , n ) :
    sieve ( MAX )
    for i in range ( n ) :
        sum = min_prime [ arr [ i ] ] + max_prime [ arr [ i ] ]
        print ( sum , end = " ▁ " )
arr = [ 5 , 10 , 15 , 20 , 25 , 30 ]
n = len ( arr )
findSum ( arr , n )

Index/key variables: i, j
Iterator variables: i
Python program:
def pairCount ( n , m ) :
    cnt = 0 ;
    for b in range ( int ( pow ( m , 1 / 2 ) ) ) :
        a = m - b * b ;
        if ( a * a + b == n ) :
            cnt += 1 ;
    return cnt ;
if __name__ == ' _ _ main _ _ ' :
    n = 9 ;
    m = 3 ;
    print ( pairCount ( n , m ) ) ;

Accumulator variables: cnt
Iterator variables: b
Python program:
maxin = 100001 ;
divisors = [ 0 ] * ( maxin + 1 ) ;
def Calc_Max_Div ( arr , n ) :
    vis = [ 1 ] * ( maxin + 1 ) ;
    vis [ 0 ] = vis [ 1 ] = 0 ;
    for i in range ( 1 , maxin + 1 ) :
        divisors [ i ] = i ;
    for i in range ( 4 , maxin + 1 , 2 ) :
        vis [ i ] = 0 ;
        divisors [ i ] = i // 2 ;
    for i in range ( 3 , maxin + 1 , 2 ) :
        if ( divisors [ i ] != i ) :
            divisors [ i ] = i // divisors [ i ] ;
        if ( vis [ i ] == 1 ) :
            for j in range ( i * i , maxin , i ) :
                vis [ j ] = 0 ;
                if ( divisors [ j ] == j ) :
                    divisors [ j ] = i ;
    for i in range ( n ) :
        if ( divisors [ arr [ i ] ] == arr [ i ] ) :
            print ( " - 1 ▁ " , end = " " ) ;
        else :
            print ( divisors [ arr [ i ] ] , end = " ▁ " ) ;
if __name__ == " _ _ main _ _ " :
    arr = [ 5 , 6 , 7 , 8 , 9 , 10 ] ;
    n = len ( arr ) ;
    Calc_Max_Div ( arr , n ) ;

Index/key variables: i, j
Iterator variables: i, j
Python program:
def sumOfDigit ( n , b ) :
    unitDigit = 0
    sum = 0
    while ( n > 0 ) :
        unitDigit = n % b
        sum += unitDigit
        n = n // b
    return sum
n = 50
b = 2
print ( sumOfDigit ( n , b ) )

Accumulator variables: sum
Python program:
def nthDigit ( a , n , b ) :
    for i in range ( 1 , n ) :
        a = a // b
    return a % b
a = 100
n = 3
b = 4
print ( nthDigit ( a , n , b ) )

Iterator variables: i
Python program:
from math import sqrt
MAX = 100001 ;
primes = [ ] ;
def initialize ( ) :
    numbers = [ 0 ] * ( MAX + 1 ) ;
    n = MAX ;
    for i in range ( 2 , int ( sqrt ( n ) ) + 1 ) :
        if ( not numbers [ i ] ) :
            for j in range ( i * i , n + 1 , i ) :
                numbers [ j ] = True ;
    for i in range ( 2 , n + 1 ) :
        if ( numbers [ i ] == False ) :
            primes . append ( i ) ;
def findNums ( num ) :
    ans = False ;
    first = - 1 ;
    second = - 1 ;
    third = - 1 ;
    for i in range ( num ) :
        first = primes [ i ] ;
        for j in range ( num ) :
            second = primes [ j ] ;
            third = num - first - second ;
            if ( third in primes ) :
                ans = True ;
                break ;
        if ( ans ) :
            break ;
    if ( ans ) :
        print ( first , second , third ) ;
    else :
        print ( - 1 ) ;
if __name__ == " _ _ main _ _ " :
    n = 101 ;
    initialize ( ) ;
    findNums ( n ) ;

Index/key variables: i, j
Accumulator variables: primes
Iterator variables: i, j
Boolean variables: ans
Python program:
def printmaxSubseq ( arr , n ) :
    for i in range ( n - 1 ) :
        if ( arr [ i ] < arr [ i + 1 ] ) :
            print ( arr [ i ] , end = " ▁ " ) ;
        else :
            print ( arr [ i ] ) ;
    print ( arr [ n - 1 ] ) ;
if __name__ == " _ _ main _ _ " :
    arr = [ 9 , 8 , 11 , 13 , 10 , 15 , 14 , 16 , 20 , 5 ] ;
    n = len ( arr ) ;
    printmaxSubseq ( arr , n ) ;

Index/key variables: i
Iterator variables: i
Python program:
import sys
def solve ( arr , n , k ) :
    minx = sys . maxsize ;
    for i in range ( n ) :
        minx = min ( minx , arr [ i ] ) ;
    decrements = 0 ;
    for i in range ( n ) :
        if ( ( arr [ i ] - minx ) % k != 0 ) :
            return - 1 ;
        else :
            decrements += ( ( arr [ i ] - minx ) // k ) ;
    return decrements ;
if __name__ == " _ _ main _ _ " :
    n = 3 ;
    k = 3 ;
    arr = [ 12 , 9 , 15 ] ;
    print ( solve ( arr , n , k ) ) ;

Index/key variables: i
Accumulator variables: decrements
Iterator variables: i
Python program:
def binomialCoeff ( n , k ) :
    C = [ 0 ] * ( k + 1 ) ;
    C [ 0 ] = 1 ;
    for i in range ( 1 , n + 1 ) :
        for j in range ( min ( i , k ) , 0 , - 1 ) :
            C [ j ] = C [ j ] + C [ j - 1 ] ;
    return C [ k ] ;
def count_of_subarrays ( N ) :
    count = binomialCoeff ( 2 * N - 1 , N ) ;
    return count ;
if __name__ == " _ _ main _ _ " :
    N = 3 ;
    print ( count_of_subarrays ( N ) ) ;

Index/key variables: j, k
Iterator variables: i, j
Python program:
def distribution ( n , k , l , r , S , Sk ) :
    a = [ 0 ] * n ;
    len = k ;
    temp , rem , s = 0 , 0 , 0 ;
    diff = S - Sk ;
    for i in range ( len ) :
        temp = Sk / k ;
        rem = Sk % k ;
        if ( temp + rem >= l and temp + rem <= r ) :
            a [ i ] = temp ;
        elif ( temp + rem > r ) :
            a [ i ] = r ;
        elif ( temp + rem < r ) :
            print ( " - 1" ) ;
            return ;
        Sk = Sk - a [ i ] ;
        k = k - 1 ;
    if ( Sk > 0 ) :
        print ( " - 1" ) ;
        return ;
    if ( len != 0 ) :
        k = n - len ;
        for i in range ( len , n ) :
            temp = diff / k ;
            rem = diff % k ;
            if ( temp + rem >= l and temp + rem <= r ) :
                a [ i ] = temp ;
            elif ( temp + rem > r ) :
                a [ i ] = r ;
            elif ( temp + rem < r ) :
                print ( " - 1" ) ;
                return ;
            diff = diff - a [ i ] ;
            k = k - 1 ;
        if ( diff != 0 ) :
            print ( " - 1" ) ;
            return ;
    for i in range ( n ) :
        print ( int ( a [ i ] ) , end = " ▁ " ) ;
if __name__ == ' _ _ main _ _ ' :
    n , k , l , r , S , Sk = 5 , 3 , 1 , 5 , 13 , 9 ;
    distribution ( n , k , l , r , S , Sk ) ;

Index/key variables: i
Iterator variables: i
Python program:
import sys
INT_MAX = sys . maxsize
def min_index ( p , n ) :
    ans = 0 ;
    mini = INT_MAX ;
    for i in range ( n ) :
        if ( p [ i ] <= mini ) :
            mini = p [ i ] ;
        if ( mini == p [ i ] ) :
            ans += 1 ;
    return ans ;
if __name__ == " _ _ main _ _ " :
    P = [ 4 , 2 , 5 , 1 , 3 ] ;
    n = len ( P ) ;
    print ( min_index ( P , n ) ) ;

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Python program:
def equal_xor_sum ( arr , n ) :
    Sum = 0 ;
    Xor = 0 ;
    for i in range ( n ) :
        Sum = Sum + arr [ i ] ;
        Xor = Xor ^ arr [ i ] ;
    if ( Sum == Xor ) :
        print ( " YES " ) ;
    else :
        print ( " NO " ) ;
if __name__ == " _ _ main _ _ " :
    arr = [ 6 , 3 , 7 , 10 ] ;
    n = len ( arr ) ;
    equal_xor_sum ( arr , n ) ;

Index/key variables: i
Iterator variables: i
Python program:
MAX = 10 ;
def countPalindromes ( n , m , matrix ) :
    count = n * m ;
    length_of_sequence_row = 0 ;
    length_of_sequence_column = 0 ;
    for i in range ( n ) :
        for j in range ( m ) :
            length_of_sequence_row = min ( j , m - 1 - j ) ;
            length_of_sequence_column = min ( i , n - i - 1 ) ;
            for k in range ( 1 , length_of_sequence_row + 1 ) :
                if ( matrix [ i ] [ j - k ] == matrix [ i ] [ j + k ] ) :
                    count += 1 ;
                else :
                    break ;
            for k in range ( 1 , length_of_sequence_column + 1 ) :
                if ( matrix [ i - k ] [ j ] == matrix [ i + k ] [ j ] ) :
                    count += 1 ;
                else :
                    break ;
    return count ;
if __name__ == ' _ _ main _ _ ' :
    m = 3 ;
    n = 3 ;
    matrix = [ 2 , 1 , 2 ] , [ 1 , 1 , 1 ] , [ 2 , 1 , 2 ] ;
    print ( countPalindromes ( n , m , matrix ) ) ;

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j, k
Python program:
def set_bits ( n ) :
    count = 0
    while ( n ) :
        count += n % 2
        n //= 2
    return count
def minSteps ( n ) :
    ans = 0
    while ( n != 1 ) :
        if ( n % 2 == 0 ) :
            n //= 2
        elif ( n == 3 or set_bits ( n - 1 ) < set_bits ( n + 1 ) ) :
            n -= 1
        else :
            n += 1
        ans += 1
    return ans
n = 15
print ( minSteps ( n ) )

Accumulator variables: ans, count, n
Python program:
def minimumNo ( n ) :
    ans = 0
    stack1 = [ ]
    stack2 = [ ]
    while ( n != 0 ) :
        r = n % 10
        if ( r % 2 == 0 ) :
            stack1 . append ( r )
        else :
            stack2 . append ( r )
        n = n // 10
    while ( len ( stack1 ) > 0 and len ( stack2 ) > 0 ) :
        if ( stack1 [ - 1 ] < stack2 [ - 1 ] ) :
            ans = ans * 10 + stack1 [ - 1 ]
            del stack1 [ - 1 ]
        else :
            ans = ans * 10 + stack2 [ - 1 ]
            del stack2 [ - 1 ]
    while ( len ( stack1 ) > 0 ) :
        ans = ans * 10 + stack1 [ - 1 ]
        del stack1 [ - 1 ]
    while ( len ( stack2 ) > 0 ) :
        ans = ans * 10 + stack2 [ - 1 ]
        del stack2 [ - 1 ]
    return ans
n1 = 64432
print ( minimumNo ( n1 ) )
n2 = 3137
print ( minimumNo ( n2 ) )

Accumulator variables: stack1, stack2
Python program:
def power ( a , b ) :
    result = 1 ;
    while ( b > 0 ) :
        if ( b % 2 == 1 ) :
            result = result * a ;
        a = a * a ;
        b = b // 2 ;
    return result ;
def factorial ( n ) :
    fact = 1 ;
    for i in range ( 1 , n + 1 ) :
        fact = fact * i ;
    return fact ;
def findNoOfArrays ( a , n ) :
    sum = 0 ; c = 0 ;
    mp = dict . fromkeys ( a , 0 ) ;
    for i in range ( 2 * n ) :
        mp [ a [ i ] ] += 1 ;
        sum = sum + a [ i ] ;
    isArrayPossible = True ;
    ans = factorial ( n - 1 ) ;
    s1 = sum // ( n + 1 ) ;
    if ( mp [ s1 ] >= 2 ) :
        mp [ s1 ] = mp [ s1 ] - 2 ;
    else :
        isArrayPossible = False ;
    if ( isArrayPossible ) :
        for first , second in mp . items ( ) :
            if ( first == s1 - first ) :
                if ( mp [ first ] % 2 != 0 ) :
                    isArrayPossible = False ;
                    break ;
            if ( first != s1 - first ) :
                if s1 - first in mp :
                    if ( mp [ first ] != mp [ s1 - first ] ) :
                        isArrayPossible = False ;
                        break ;
            if ( second > 0 ) :
                if ( first != s1 - first ) :
                    c = c + second ;
                    ans = ans * power ( 2 , second ) ;
                    ans = ans / factorial ( second ) ;
                    mp [ first ] = 0 ;
                    mp [ s1 - first ] = 0 ;
                if ( first == s1 - first ) :
                    c = c + second // 2 ;
                    ans = ans // factorial ( second // 2 ) ;
                    mp [ first ] = 0 ;
    if ( c < n - 1 or isArrayPossible == False ) :
        print ( "0" ) ;
    else :
        print ( ans ) ;
if __name__ == " _ _ main _ _ " :
    arr1 = [ 5 , 2 , 3 , 5 ] ;
    n1 = len ( arr1 ) ;
    findNoOfArrays ( arr1 , n1 // 2 ) ;
    arr2 = [ - 1 , - 1 , - 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 ] ;
    n2 = len ( arr2 ) ;
    findNoOfArrays ( arr2 , n2 // 2 ) ;

Index/key variables: first, i, s1
Iterator variables: first, i, second
Boolean variables: isArrayPossible
Python program:
from math import gcd as __gcd , sqrt , ceil
def lcm ( a , b ) :
    return ( a // __gcd ( a , b ) * b )
def findNums ( x ) :
    ans = 0
    for i in range ( 1 , ceil ( sqrt ( x ) ) ) :
        if ( x % i == 0 and lcm ( i , x // i ) == x ) :
            ans = i
    print ( ans , ( x // ans ) )
x = 12
findNums ( x )

Iterator variables: i
Python program:
MAXN = 1000000
def maxCommonElement ( A , D , N ) :
    cnt = [ 0 ] * MAXN
    for i in range ( N ) :
        for j in range ( A [ i ] , MAXN , D [ i ] ) :
            cnt [ j ] += 1
    ans = 0
    com = 0
    for i in range ( MAXN ) :
        if cnt [ i ] > ans :
            ans = cnt [ i ]
            com = i
    return com
A = [ 13 , 1 , 2 , 5 ]
D = [ 5 , 10 , 1 , 12 ]
N = len ( A )
print ( maxCommonElement ( A , D , N ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def findTrailingZeros ( n ) :
    if ( n & 1 ) :
        return 0
    else :
        ans = 0
        n //= 2
        while ( n ) :
            ans += n // 5
            n //= 5
        return ans
n = 12
print ( findTrailingZeros ( n ) )

Accumulator variables: ans, n
Python program:
from math import sqrt , ceil , floor
def maxGCD ( N , K ) :
    minSum = ( K * ( K + 1 ) ) / 2
    if ( N < minSum ) :
        return - 1
    i = ceil ( sqrt ( N ) )
    res = 1
    while ( i >= 1 ) :
        if ( N % i == 0 ) :
            if ( i >= minSum ) :
                res = max ( res , N / i )
            if ( N / i >= minSum ) :
                res = max ( res , i )
        i -= 1
    return res
N = 18
K = 3
print ( maxGCD ( N , K ) )

Accumulator variables: i
Python program:
def checkZeroArray ( arr , n ) :
    sum = 0
    maximum = - 10 ** 9
    for i in range ( n ) :
        sum = sum + arr [ i ]
        maximum = max ( maximum , arr [ i ] )
    if ( sum % 2 == 0 and maximum <= sum // 2 ) :
        return True
    return False
arr = [ 1 , 2 , 1 , 2 , 2 ]
n = len ( arr )
if ( checkZeroArray ( arr , n ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def subArray ( arr , n , m ) :
    i = 0
    mp = dict ( )
    for i in range ( n ) :
        mp [ arr [ i ] ] = i + 1
    sumcur = 0
    p = 10 ** 9
    ans = [ ]
    for i in range ( 1 , m + 1 ) :
        sumcur += mp [ i ]
        p = min ( p , mp [ i ] )
        val = p * i - i + ( i * ( i + 1 ) ) / 2
        if ( i == m ) :
            if ( val == sumcur ) :
                return True
            else :
                return False
arr = [ 4 , 5 , 1 , 3 , 2 , 6 ]
n = len ( arr )
m = 3
if ( subArray ( arr , n , m ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Accumulator variables: sumcur
Iterator variables: i
Python program:
import math
def isPalindrome ( s ) :
    left = 0
    right = len ( s ) - 1
    while ( left <= right ) :
        if ( s [ left ] != s [ right ] ) :
            return False
        left = left + 1
        right = right - 1
    return True
def getSum ( n ) :
    start = int ( math . pow ( 10 , n - 1 ) )
    end = int ( math . pow ( 10 , n ) ) - 1
    sum = 0
    for i in range ( start , end + 1 ) :
        s = str ( i )
        if ( isPalindrome ( s ) ) :
            sum = sum + i
    return sum
n = 1
ans = getSum ( n )
print ( ans )

Index/key variables: left, right
Iterator variables: i
Python program:
def countPairs ( arr , n ) :
    count = 0 ;
    for i in range ( n - 1 ) :
        for j in range ( i + 1 , n ) :
            if ( arr [ i ] * arr [ j ] == arr [ i ] + arr [ j ] ) :
                count += 1 ;
    return count ;
if __name__ == " _ _ main _ _ " :
    arr = [ 2 , 0 , 3 , 2 , 0 ] ;
    n = len ( arr ) ;
    print ( countPairs ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j