dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
from math import floor , pow
import sys
def digitSum ( n ) :
    ans = 0 ;
    while ( n ) :
        ans += n % 10 ;
        n = int ( n / 10 ) ;
    return ans
def findInt ( n , m ) :
    minDigit = floor ( m / 9 )
    start = ( int ( pow ( 10 , minDigit ) ) - int ( pow ( 10 , minDigit ) ) % n )
    while ( start < sys . maxsize ) :
        if ( digitSum ( start ) == m ) :
            return start
        else :
            start += n
    return - 1
if __name__ == ' _ _ main _ _ ' :
    n = 13
    m = 32
    print ( findInt ( n , m ) )

Accumulator variables: ans, start
Python program:
from math import sqrt
def smallestDivisor ( n ) :
    mx = int ( sqrt ( n ) )
    for i in range ( 2 , mx + 1 , 1 ) :
        if ( n % i == 0 ) :
            return i
    return n
def maxSum ( n ) :
    res = n
    while ( n > 1 ) :
        divi = smallestDivisor ( n )
        n = int ( n / divi )
        res += n
    return res
if __name__ == ' _ _ main _ _ ' :
    n = 34
    print ( maxSum ( n ) )

Accumulator variables: res
Iterator variables: i
Python program:
def isPossible ( n , k , arr ) :
    sum = arr [ 0 ]
    maxVal = arr [ 0 ] ;
    for i in range ( 1 , n ) :
        sum += arr [ i ]
        maxVal = max ( maxVal , arr [ i ] )
    if ( int ( maxVal ) > int ( ( sum + k ) / n ) ) :
        return False
    return True
if __name__ == ' _ _ main _ _ ' :
    k = 8
    arr = [ 1 , 2 , 3 , 4 ]
    n = len ( arr )
    if ( isPossible ( n , k , arr ) ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
from math import *
def maxResult ( n , a , b , c ) :
    maxVal = 0
    for i in range ( 0 , n + 1 , a ) :
        for j in range ( 0 , n - i + 1 , b ) :
            z = ( n - ( i + j ) ) / c
            if ( floor ( z ) == ceil ( z ) ) :
                x = i // a
                y = j // b
                maxVal = max ( maxVal , x + y + int ( z ) )
    return maxVal
if __name__ == " _ _ main _ _ " :
    n = 10
    a = 5
    b = 3
    c = 4
    print ( maxResult ( n , a , b , c ) )

Iterator variables: i, j
Python program:
def EqualNumbers ( a , n ) :
    for i in range ( 0 , n ) :
        while a [ i ] % 2 == 0 :
            a [ i ] //= 2
        while a [ i ] % 3 == 0 :
            a [ i ] //= 3
        if a [ i ] != a [ 0 ] :
            return False
    return True
if __name__ == " _ _ main _ _ " :
    a = [ 50 , 75 , 150 ]
    n = len ( a )
    if EqualNumbers ( a , n ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
import math
def max_gcd ( n , p ) :
    count = 0 ;
    gcd = 1 ;
    while ( p % 2 == 0 ) :
        p >>= 1 ;
        count = count + 1 ;
    if ( count > 0 ) :
        gcd = gcd * pow ( 2 , count // n ) ;
    for i in range ( 3 , ( int ) ( math . sqrt ( p ) ) , 2 ) :
        count = 0 ;
        while ( p % i == 0 ) :
            count = count + 1 ;
            p = p // i ;
        if ( count > 0 ) :
            gcd = gcd * pow ( i , count // n ) ;
    if ( p > 2 ) :
        gcd = gcd * pow ( p , 1 // n ) ;
    return gcd ;
n = 3 ;
p = 80 ;
print ( max_gcd ( n , p ) ) ;

Accumulator variables: p
Iterator variables: i
Python program:
import math as mt
def checkSub ( sub , s ) :
    j = 0
    for i in range ( len ( s ) ) :
        if ( sub [ j ] == s [ i ] ) :
            j += 1
    if j == int ( len ( sub ) ) :
        return True
    else :
        return False
def getMultiple ( s ) :
    for i in range ( 0 , 10 ** 3 , 8 ) :
        if ( checkSub ( str ( i ) , s ) ) :
            return i
    return - 1
s = "3454"
print ( getMultiple ( s ) )

Index/key variables: i, j
Iterator variables: i
Python program:
def getResult ( n ) :
    st = str ( n )
    for i in st :
        if ( n % int ( i ) == 0 ) :
            return ' Yes '
    return ' No '
n = 9876543
print ( getResult ( n ) )

Iterator variables: i
Python program:
def powerfulIntegers ( x , y , bound ) :
    s = set ( )
    powersOfY = [ ]
    powersOfY . append ( 1 )
    i = y
    while i < bound and y != 1 :
        powersOfY . append ( i )
        i *= y
    i = 0
    while ( True ) :
        xPowI = pow ( x , i )
        for j in powersOfY :
            num = xPowI + j
            if ( num <= bound ) :
                s . add ( num )
            else :
                break
        if ( xPowI >= bound or x == 1 ) :
            break
        i += 1
    for itr in s :
        print ( itr , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    x = 2
    y = 3
    bound = 10
    powerfulIntegers ( x , y , bound )

Accumulator variables: i, powersOfY, s
Iterator variables: itr, j
Python program:
import math as mt
def candies ( n , k ) :
    count = 0
    ind = 1
    arr = [ 0 for i in range ( k ) ]
    while n > 0 :
        f1 = ( ind - 1 ) * k
        f2 = ind * k
        sum1 = ( f1 * ( f1 + 1 ) ) // 2
        sum2 = ( f2 * ( f2 + 1 ) ) // 2
        res = sum2 - sum1
        if ( res <= n ) :
            count += 1
            n -= res
            ind += 1
            i = 0
            term = ( ( ind - 1 ) * k ) + 1
            while ( n > 0 ) :
                if ( term <= n ) :
                    arr [ i ] = term
                    i += 1
                    n -= term
                    term += 1
                else :
                    arr [ i ] = n
                    i += 1
                    n = 0
    for i in range ( k ) :
        arr [ i ] += ( ( count * ( i + 1 ) ) + ( k * ( count * ( count - 1 ) ) // 2 ) )
    for i in range ( k ) :
        print ( arr [ i ] , end = " ▁ " )
n , k = 10 , 3
candies ( n , k )

Index/key variables: i
Accumulator variables: count, ind, n, term
Iterator variables: i
Python program:
def candies ( n , k ) :
    count = 0 ;
    ind = 1 ;
    arr = [ 0 ] * k ;
    low = 0 ;
    high = n ;
    while ( low <= high ) :
        mid = ( low + high ) >> 1 ;
        sum = ( mid * ( mid + 1 ) ) >> 1 ;
        if ( sum <= n ) :
            count = int ( mid / k ) ;
            low = mid + 1 ;
        else :
            high = mid - 1 ;
    last = ( count * k ) ;
    n -= int ( ( last * ( last + 1 ) ) / 2 ) ;
    i = 0 ;
    term = ( count * k ) + 1 ;
    while ( n ) :
        if ( term <= n ) :
            arr [ i ] = term ;
            i += 1 ;
            n -= term ;
            term += 1 ;
        else :
            arr [ i ] += n ;
            n = 0 ;
    for i in range ( k ) :
        arr [ i ] += ( ( count * ( i + 1 ) ) + int ( k * ( count * ( count - 1 ) ) / 2 ) ) ;
    for i in range ( k ) :
        print ( arr [ i ] , end = " ▁ " ) ;
n = 7 ;
k = 4 ;
candies ( n , k ) ;

Index/key variables: i
Accumulator variables: n, term
Iterator variables: i
Python program:
def printSmallest ( a , n ) :
    sum0 , sum1 = 0 , 0
    a = sorted ( a )
    for i in range ( n ) :
        if ( a [ i ] % 3 == 0 ) :
            return a [ i ]
    for i in range ( n ) :
        for j in range ( n ) :
            num = ( a [ i ] * 10 ) + a [ j ]
            if ( num % 3 == 0 ) :
                return num
    return a [ 0 ] * 100 + a [ 0 ] * 10 + a [ 0 ]
arr = [ 7 , 7 , 1 ]
n = len ( arr )
print ( printSmallest ( arr , n ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def updateMatrix ( n , q , mat ) :
    for i in range ( 0 , len ( q ) ) :
        X1 = q [ i ] [ 0 ] ;
        Y1 = q [ i ] [ 1 ] ;
        X2 = q [ i ] [ 2 ] ;
        Y2 = q [ i ] [ 3 ] ;
        mat [ X1 ] [ Y1 ] = mat [ X1 ] [ Y1 ] + 1 ;
        if ( Y2 + 1 < n ) :
            mat [ X2 ] [ Y2 + 1 ] = mat [ X2 ] [ Y2 + 1 ] - 1 ;
        elif ( X2 + 1 < n ) :
            mat [ X2 + 1 ] [ 0 ] = mat [ X2 + 1 ] [ 0 ] - 1 ;
    sum = 0 ;
    for i in range ( 0 , n ) :
        for j in range ( 0 , n ) :
            sum = sum + mat [ i ] [ j ] ;
            print ( sum , end = ' ▁ ' ) ;
        print ( " ▁ " ) ;
n = 5 ;
mat = [ [ 0 for i in range ( n ) ] for i in range ( n ) ] ;
q = [ [ 0 , 0 , 1 , 2 ] , [ 1 , 2 , 3 , 4 ] , [ 1 , 4 , 3 , 4 ] ] ;
updateMatrix ( n , q , mat ) ;

Index/key variables: X1, X2, Y1, i, j
Iterator variables: i, j
Python program:
def printArr ( arr , n ) :
    for i in range ( n ) :
        print ( arr [ i ] , end = " ▁ " )
def replaceMax ( arr , n ) :
    max_element = max ( arr )
    min_element = min ( arr )
    ranges = max_element - min_element
    coeffOfRange = ranges / ( max_element + min_element )
    for i in range ( n ) :
        if ( arr [ i ] == max_element ) :
            arr [ i ] = coeffOfRange
            break
    printArr ( arr , n )
if __name__ == " _ _ main _ _ " :
    arr = [ 15 , 16 , 10 , 9 , 6 , 7 , 17 ]
    n = len ( arr )
    replaceMax ( arr , n )

Index/key variables: i
Iterator variables: i
Python program:
def divide ( a , b ) :
    for i in range ( 2 , min ( a , b ) + 1 ) :
        while ( a % i == 0 and b % i == 0 ) :
            a = a // i
            b = b // i
    print ( " A ▁ = " , a , " , ▁ B ▁ = " , b )
if __name__ == " _ _ main _ _ " :
    A , B = 10 , 15
    divide ( A , B )

Iterator variables: i
Python program:
def FindAllElements ( n , k ) :
    sum = k
    A = [ 1 for i in range ( k ) ]
    i = k - 1
    while ( i >= 0 ) :
        while ( sum + A [ i ] <= n ) :
            sum += A [ i ]
            A [ i ] *= 2
        i -= 1
    if ( sum != n ) :
        print ( " Impossible " )
    else :
        for i in range ( 0 , k , 1 ) :
            print ( A [ i ] , end = ' ▁ ' )
if __name__ == ' _ _ main _ _ ' :
    n = 12
    k = 6
    FindAllElements ( n , k )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def removeZero ( n ) :
    res = 0
    d = 1
    while ( n > 0 ) :
        if ( n % 10 != 0 ) :
            res += ( n % 10 ) * d
            d *= 10
        n //= 10
    return res
def isEqual ( a , b ) :
    if ( removeZero ( a ) + removeZero ( b ) == removeZero ( a + b ) ) :
        return True
    return False
a = 105
b = 106
if ( isEqual ( a , b ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Accumulator variables: d, n, res
Python program:
def sumArray ( arr , n ) :
    leftSum = [ 0 for i in range ( n ) ]
    rightSum = [ 0 for i in range ( n ) ]
    Sum = [ 0 for i in range ( n ) ]
    i , j = 0 , 0
    leftSum [ 0 ] = 0
    rightSum [ n - 1 ] = 0
    for i in range ( 1 , n ) :
        leftSum [ i ] = arr [ i - 1 ] + leftSum [ i - 1 ]
    for j in range ( n - 2 , - 1 , - 1 ) :
        rightSum [ j ] = arr [ j + 1 ] + rightSum [ j + 1 ]
    for i in range ( 0 , n ) :
        Sum [ i ] = leftSum [ i ] + rightSum [ i ]
    for i in range ( n ) :
        print ( Sum [ i ] , end = " ▁ " )
arr = [ 3 , 6 , 4 , 8 , 9 ]
n = len ( arr )
sumArray ( arr , n )

Index/key variables: i, j
Iterator variables: i, j
Python program:
import sys
def minimumX ( n , k ) :
    mini = sys . maxsize
    i = 1
    while i * i <= n :
        if ( n % i == 0 ) :
            fir = i
            sec = n // i
            num1 = fir * k + sec
            res = ( num1 // k ) * ( num1 % k )
            if ( res == n ) :
                mini = min ( num1 , mini )
            num2 = sec * k + fir
            res = ( num2 // k ) * ( num2 % k )
            if ( res == n ) :
                mini = min ( num2 , mini )
        i += 1
    return mini
if __name__ == " _ _ main _ _ " :
    n = 4
    k = 6
    print ( minimumX ( n , k ) )
    n = 5
    k = 5
    print ( minimumX ( n , k ) )

Accumulator variables: i
Python program:
def minimumX ( n , k ) :
    ans = 10 ** 18
    for i in range ( k - 1 , 0 , - 1 ) :
        if n % i == 0 :
            ans = min ( ans , i + ( n / i ) * k )
    return ans
n , k = 4 , 6
print ( minimumX ( n , k ) )
n , k = 5 , 5
print ( minimumX ( n , k ) )

Iterator variables: i
Python program:
from math import sqrt , floor
def isPerfect ( N ) :
    if ( sqrt ( N ) - floor ( sqrt ( N ) ) != 0 ) :
        return False
    return True
def getClosestPerfectSquare ( N ) :
    if ( isPerfect ( N ) ) :
        print ( N , "0" )
        return
    aboveN = - 1
    belowN = - 1
    n1 = 0
    n1 = N + 1
    while ( True ) :
        if ( isPerfect ( n1 ) ) :
            aboveN = n1
            break
        else :
            n1 += 1
    n1 = N - 1
    while ( True ) :
        if ( isPerfect ( n1 ) ) :
            belowN = n1
            break
        else :
            n1 -= 1
    diff1 = aboveN - N
    diff2 = N - belowN
    if ( diff1 > diff2 ) :
        print ( belowN , diff2 )
    else :
        print ( aboveN , diff1 )
N = 1500
getClosestPerfectSquare ( N )

Accumulator variables: n1
Python program:
import math
def findLargestDivisor ( n ) :
    for i in range ( 2 , int ( math . sqrt ( n ) ) + 1 ) :
        while ( n % ( i * i ) == 0 ) :
            n = n // i
    return n
if __name__ == " _ _ main _ _ " :
    n = 12
    print ( findLargestDivisor ( n ) )
    n = 97
    print ( findLargestDivisor ( n ) )

Iterator variables: i
Python program:
def isTriPerfect ( n ) :
    sum = 1 + n
    i = 2
    while i * i <= n :
        if n % i == 0 :
            if n / i == i :
                sum = sum + i
            else :
                sum = sum + i + n / i
        i += 1
    return ( True if sum == 3 * n and n != 1 else False )
n = 120
if isTriPerfect ( n ) :
    print ( n , " is ▁ a ▁ Triperfect ▁ number " )

Accumulator variables: i
Python program:
def findTwoThreePrime ( l , r ) :
    if ( l == 1 ) :
        l += 1
    count = 0
    for i in range ( l , r + 1 ) :
        num = i
        while ( num % 2 == 0 ) :
            num //= 2 ;
        while ( num % 3 == 0 ) :
            num //= 3
        if ( num == 1 ) :
            count += 1
    return count
if __name__ == " _ _ main _ _ " :
    l = 1
    r = 10
    print ( findTwoThreePrime ( l , r ) )

Accumulator variables: count, num
Iterator variables: i
Python program:
def getNumber ( s ) :
    number_of_digits = len ( s ) ;
    freq = [ 0 ] * 10 ;
    for i in range ( number_of_digits ) :
        if ( s [ i ] == '1' or s [ i ] == '2' or s [ i ] == '3' or s [ i ] == '5' or s [ i ] == '7' ) :
            freq [ ord ( s [ i ] ) - 48 ] += 1 ;
        if ( s [ i ] == '4' ) :
            freq [ 2 ] += 2 ;
            freq [ 3 ] += 1 ;
        if ( s [ i ] == '6' ) :
            freq [ 5 ] += 1 ;
            freq [ 3 ] += 1 ;
        if ( s [ i ] == '8' ) :
            freq [ 7 ] += 1 ;
            freq [ 2 ] += 3 ;
        if ( s [ i ] == '9' ) :
            freq [ 7 ] += 1 ;
            freq [ 3 ] += 2 ;
            freq [ 2 ] += 1 ;
    t = " " ;
    if ( freq [ 1 ] == number_of_digits or freq [ 0 ] == number_of_digits or ( freq [ 0 ] + freq [ 1 ] ) == number_of_digits ) :
        return s ;
    else :
        for i in range ( 9 , 1 , - 1 ) :
            ctr = freq [ i ] ;
            while ( ctr > 0 ) :
                t += chr ( i + 48 ) ;
                ctr -= 1 ;
        return t ;
s = "1280" ;
print ( getNumber ( s ) ) ;

Index/key variables: i
Accumulator variables: ctr, t
Iterator variables: i
Python program:
def reversedigit ( num ) :
    rev_num = 0
    while num > 0 :
        rev_num = rev_num * 10 + num % 10
        num = num // 10
    return rev_num
def icanobifNumbers ( N ) :
    first = 0
    second = 1
    if N == 1 :
        print ( first )
    elif N == 2 :
        print ( first , second )
    else :
        print ( first , second , end = " ▁ " )
        for i in range ( 3 , N + 1 ) :
            x = reversedigit ( first )
            y = reversedigit ( second )
            print ( x + y , end = " ▁ " )
            temp = second
            second = x + y
            first = temp
N = 12
icanobifNumbers ( N )

Iterator variables: i
Python program:
def addNDigits ( a , b , n ) :
    num = a
    for i in range ( 10 ) :
        tmp = a * 10 + i
        if ( tmp % b == 0 ) :
            a = tmp
            break
    if ( num == a ) :
        return - 1
    for j in range ( n - 1 ) :
        a *= 10
    return a
if __name__ == " _ _ main _ _ " :
    a = 5
    b = 3
    n = 3
    print ( addNDigits ( a , b , n ) )

Accumulator variables: a
Iterator variables: i, j
Python program:
import math
def Triplets ( n ) :
    ans = 0
    for i in range ( 1 , n + 1 ) :
        for j in range ( i , n + 1 ) :
            x = i * i + j * j
            y = int ( math . sqrt ( x ) )
            if ( y * y == x and y <= n ) :
                ans += 1
    return ans
if __name__ == " _ _ main _ _ " :
    n = 10
    print ( Triplets ( n ) )

Accumulator variables: ans
Iterator variables: i, j
Python program:
from math import floor
def solve ( n , base ) :
    sum = 0
    while ( n > 0 ) :
        remainder = n % base
        sum = sum + remainder
        n = int ( n / base )
    return sum
def SumsOfDigits ( n ) :
    sum = 0
    N = floor ( n / 2 )
    for base in range ( 2 , N + 1 , 1 ) :
        sum = sum + solve ( n , base )
    print ( sum )
if __name__ == ' _ _ main _ _ ' :
    n = 8
    SumsOfDigits ( n )

Iterator variables: base
Python program:
import math
def checkPerfectcube ( n ) :
    cube_root = n ** ( 1. / 3. )
    if round ( cube_root ) ** 3 == n :
        return True
    else :
        return False
def largestNonPerfectcubeNumber ( a , n ) :
    maxi = - 1
    for i in range ( 0 , n , 1 ) :
        if ( checkPerfectcube ( a [ i ] ) == False ) :
            maxi = max ( a [ i ] , maxi )
    return maxi
if __name__ == ' _ _ main _ _ ' :
    a = [ 16 , 64 , 25 , 2 , 3 , 10 ]
    n = len ( a )
    print ( largestNonPerfectcubeNumber ( a , n ) )

Index/key variables: i
Iterator variables: i
Python program:
def checkIfPossibleRec ( x , a , b , isPossible , n ) :
    if x > n :
        return
    if isPossible [ x ] :
        return
    isPossible [ x ] = True
    checkIfPossibleRec ( x + a , a , b , isPossible , n )
    checkIfPossibleRec ( x + b , a , b , isPossible , n )
def checkPossible ( n , a , b ) :
    isPossible = [ False ] * ( n + 1 )
    checkIfPossibleRec ( 0 , a , b , isPossible , n )
    return isPossible [ n ]
if __name__ == " _ _ main _ _ " :
    a , b , n = 3 , 7 , 8
    if checkPossible ( a , b , n ) :
        print ( " Yes " )
    else :
        print ( " No " )

Index/key variables: n, x
Python program:
from math import gcd , sqrt
def sumcommDiv ( a , b ) :
    n = gcd ( a , b )
    sum = 0
    N = int ( sqrt ( n ) ) + 1
    for i in range ( 1 , N , 1 ) :
        if ( n % i == 0 ) :
            if ( n / i == i ) :
                sum += i
            else :
                sum += ( n / i ) + i
    return sum
if __name__ == ' _ _ main _ _ ' :
    a = 10
    b = 15
    print ( " Sum ▁ = " , int ( sumcommDiv ( a , b ) ) )

Accumulator variables: sum
Iterator variables: i
Python program:
def checkNumber ( N ) :
    temp = N
    while ( temp > 0 ) :
        if ( temp % 1000 == 144 ) :
            temp /= 1000
        elif ( temp % 100 == 14 ) :
            temp /= 100
        elif ( temp % 10 == 1 ) :
            temp /= 10
        else :
            return " YES "
    return " NO "
N = 1414 ;
print ( checkNumber ( N ) ) ;

Accumulator variables: temp
Python program:
def minOperations ( A , n ) :
    if n & 1 :
        return - 1
    zeros , consZeros , ones = 0 , 0 , 0
    for i in range ( n ) :
        if A [ i ] :
            zeros += 1
        else :
            ones += 1
        if ( i + 1 < n ) :
            if A [ i ] == 0 and A [ i + 1 ] == 0 :
                consZeros += 1
    if A [ 0 ] == A [ n - 1 ] and A [ 0 ] == 0 :
        consZeros += 1
    if zeros == ones :
        return consZeros
    else :
        return - 1
if __name__ == " _ _ main _ _ " :
    A = [ 1 , 1 , 0 , 0 ]
    n = len ( A )
    print ( minOperations ( A , n ) )

Index/key variables: i
Accumulator variables: consZeros, ones, zeros
Iterator variables: i
Python program:
def countdig ( m ) :
    if ( m == 0 ) :
        return 0
    else :
        return 1 + countdig ( m // 10 )
def countSteps ( x ) :
    c = 0
    last = x
    while ( last ) :
        digits = countdig ( last )
        digits -= 1
        divisor = pow ( 10 , digits )
        first = last // divisor
        lastnumber = first * divisor
        skipped = ( last - lastnumber ) // first
        skipped += 1
        c += skipped
        last = last - ( first * skipped )
    return c
n = 14
print ( countSteps ( n ) )

Accumulator variables: c, digits, skipped
Python program:
def allOddDigits ( n ) :
    while ( n ) :
        if ( ( n % 10 ) % 2 == 0 ) :
            return False
        n = int ( n / 10 )
    return True
def largestNumber ( n ) :
    if ( n % 2 == 0 ) :
        n -= 1
    i = n
    while ( 1 ) :
        if ( allOddDigits ( i ) ) :
            return i
        i -= 2
if __name__ == ' _ _ main _ _ ' :
    N = 23
    print ( largestNumber ( N ) )

Accumulator variables: i
Python program:
def largestNumber ( n ) :
    s = " "
    duplicate = n
    while ( n ) :
        s = chr ( n % 10 + 48 ) + s
        n //= 10
    index = - 1
    for i in range ( len ( s ) ) :
        if ( ( ( ord ( s [ i ] ) - ord ( '0' ) ) % 2 & 1 ) == 0 ) :
            index = i
            break
    if ( index == - 1 ) :
        return duplicate
    num = 0
    for i in range ( index ) :
        num = num * 10 + ( ord ( s [ i ] ) - ord ( '0' ) )
    num = num * 10 + ( ord ( s [ index ] ) - ord ( '0' ) - 1 )
    for i in range ( index + 1 , len ( s ) ) :
        num = num * 10 + 9
    return num
N = 24578
print ( largestNumber ( N ) )

Index/key variables: i, index
Accumulator variables: n
Iterator variables: i
Python program:
from math import sqrt
def countOrderedPairs ( N ) :
    count_pairs = 0
    p = int ( sqrt ( N - 1 ) ) + 1
    q = int ( sqrt ( N ) ) + 2
    for i in range ( 1 , p , 1 ) :
        for j in range ( i , q , 1 ) :
            count_pairs += 1
    count_pairs *= 2
    count_pairs -= int ( sqrt ( N - 1 ) )
    return count_pairs
if __name__ == ' _ _ main _ _ ' :
    N = 5
    print ( countOrderedPairs ( N ) )

Accumulator variables: count_pairs
Iterator variables: i, j
Python program:
def pairwiseDifference ( arr , n ) :
    for i in range ( n - 1 ) :
        diff = abs ( arr [ i ] - arr [ i + 1 ] )
        print ( diff , end = " ▁ " )
if __name__ == " _ _ main _ _ " :
    arr = [ 4 , 10 , 15 , 5 , 6 ]
    n = len ( arr )
    pairwiseDifference ( arr , n )

Index/key variables: i
Iterator variables: i
Python program:
def markingScheme ( N , answerKey , studentAnswer ) :
    positive = 0
    negative = 0
    notattempt = 0
    for i in range ( 0 , N ) :
        if ( studentAnswer [ i ] == 0 ) :
            notattempt += 1
        elif ( answerKey [ i ] == studentAnswer [ i ] ) :
            positive += 1
        elif ( answerKey [ i ] != studentAnswer [ i ] ) :
            negative += 1
    return ( positive * 3 ) + ( negative * - 1 )
def main ( ) :
    answerKey = [ 1 , 2 , 3 , 4 , 1 ]
    studentAnswer = [ 1 , 2 , 3 , 4 , 0 ]
    N = 5
    print ( markingScheme ( N , answerKey , studentAnswer ) )

Index/key variables: i
Accumulator variables: negative, notattempt, positive
Iterator variables: i
Python program:
import math as mt
MAX = 10000
prime = [ True for i in range ( MAX + 1 ) ]
def SieveOfErastosthenes ( ) :
    prime [ 1 ] = False
    for p in range ( 2 , mt . ceil ( mt . sqrt ( MAX ) ) ) :
        if prime [ p ] :
            for i in range ( 2 * p , MAX + 1 , p ) :
                prime [ i ] = False
def solve ( n ) :
    count , num = 0 , 1
    prod = 1
    while count < n :
        if prime [ num ] :
            prod *= num
            count += 1
        num += 1
    return prod
SieveOfErastosthenes ( )
n = 5
print ( solve ( n ) )

Index/key variables: i, num, p
Accumulator variables: count, prod
Iterator variables: i, p
Python program:
def divisor ( a ) :
    div = 1 ;
    count = 0 ;
    for i in range ( 2 , int ( pow ( a , 1 / 2 ) ) + 1 ) :
        while ( a % i == 0 ) :
            count += 1 ;
            a = a / i ;
        div = div * ( count + 1 ) ;
        count = 0 ;
    if ( a > 1 ) :
        div = div * ( 2 ) ;
    return div ;
def OddDivCount ( a , b ) :
    res = 0 ;
    for i in range ( a , b + 1 ) :
        divCount = divisor ( i ) ;
        if ( divCount % 2 ) :
            res += 1 ;
    return res ;
if __name__ == ' _ _ main _ _ ' :
    a , b = 1 , 10 ;
    print ( OddDivCount ( a , b ) ) ;

Accumulator variables: count, res
Iterator variables: i