dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
dim = 3
class Node :
    def __init__ ( self , data ) :
        self . data = data
        self . prev = None
        self . up = None
        self . down = None
        self . next = None
def createNode ( data ) :
    temp = Node ( data ) ;
    return temp ;
def constructDoublyListUtil ( mtrx , i , j , curr ) :
    if ( i >= dim or j >= dim ) :
        return None ;
    temp = createNode ( mtrx [ i ] [ j ] ) ;
    temp . prev = curr ;
    temp . up = curr ;
    temp . next = constructDoublyListUtil ( mtrx , i , j + 1 , temp ) ;
    temp . down = constructDoublyListUtil ( mtrx , i + 1 , j , temp ) ;
    return temp ;
def constructDoublyList ( mtrx ) :
    return constructDoublyListUtil ( mtrx , 0 , 0 , None ) ;
def display ( head ) :
    rPtr = None
    dPtr = head ;
    while ( dPtr != None ) :
        rPtr = dPtr ;
        while ( rPtr != None ) :
            print ( rPtr . data , end = ' ▁ ' )
            rPtr = rPtr . next ;
        print ( )
        dPtr = dPtr . down ;
if __name__ == " _ _ main _ _ " :
    mtrx = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 7 , 8 , 9 ] ]
    list = constructDoublyList ( mtrx ) ;
    display ( list ) ;

Index/key variables: i, j
Class/struct names: Node
Python program:
import math
class Node :
    def __init__ ( self , key ) :
        self . key = key
        self . left = None
        self . right = None
def newNode ( key ) :
    temp = Node ( key )
    return temp
def find_x ( n ) :
    if n == 1 :
        return 1
    num = math . log10 ( n )
    x , no = 0 , 0
    for i in range ( 2 , n + 1 ) :
        den = math . log10 ( i )
        p = num / den
        no = int ( pow ( i , int ( p ) ) )
        if abs ( no - n ) < 1e-6 :
            x = i
            break
    return x
def is_key ( n , x ) :
    p = math . log10 ( n ) / math . log10 ( x )
    no = int ( pow ( x , int ( p ) ) )
    if n == no :
        return True
    return False
def evenPaths ( node , count , x ) :
    if node == None or not is_key ( node . key , x ) :
        return count
    if node . left == None and node . right == None :
        count += 1
    count = evenPaths ( node . left , count , x )
    return evenPaths ( node . right , count , x )
def countExpPaths ( node , x ) :
    return evenPaths ( node , 0 , x )
root = newNode ( 27 )
root . left = newNode ( 9 )
root . right = newNode ( 81 )
root . left . left = newNode ( 3 )
root . left . right = newNode ( 10 )
root . right . left = newNode ( 70 )
root . right . right = newNode ( 243 )
root . right . right . left = newNode ( 81 )
root . right . right . right = newNode ( 909 )
x = find_x ( root . key )
print ( countExpPaths ( root , x ) )

Iterator variables: i
Class/struct names: Node
Python program:
N = 1000001
c = 0
n = 0
m = 0
a = 0
b = 0
def dfs ( a , b , v , vis ) :
    global c
    vis [ a ] = 1
    c += 1
    for i in v [ a ] :
        if ( vis [ i ] == 0 and i != b ) :
            dfs ( i , b , v , vis )
def Calculate ( v ) :
    global c
    vis = [ 0 for i in range ( n + 1 ) ]
    c = 0
    dfs ( a , b , v , vis )
    ans1 = n - c - 1
    vis = [ 0 for i in range ( len ( vis ) ) ]
    c = 0
    dfs ( b , a , v , vis )
    ans2 = n - c - 1
    print ( ans1 * ans2 )
if __name__ == ' _ _ main _ _ ' :
    n = 7
    m = 7
    a = 3
    b = 5
    edges = [ [ 1 , 2 ] , [ 2 , 3 ] , [ 3 , 4 ] , [ 4 , 5 ] , [ 5 , 6 ] , [ 6 , 7 ] , [ 7 , 5 ] ]
    v = [ [ ] for i in range ( n + 1 ) ]
    for i in range ( m ) :
        v [ edges [ i ] [ 0 ] ] . append ( edges [ i ] [ 1 ] )
        v [ edges [ i ] [ 1 ] ] . append ( edges [ i ] [ 0 ] )
    Calculate ( v )

Index/key variables: a, i
Iterator variables: i
Python program:
V = 4
answer = [ ]
def tsp ( graph , v , currPos , n , count , cost ) :
    if ( count == n and graph [ currPos ] [ 0 ] ) :
        answer . append ( cost + graph [ currPos ] [ 0 ] )
        return
    for i in range ( n ) :
        if ( v [ i ] == False and graph [ currPos ] [ i ] ) :
            v [ i ] = True
            tsp ( graph , v , i , n , count + 1 , cost + graph [ currPos ] [ i ] )
            v [ i ] = False
if __name__ == ' _ _ main _ _ ' :
    n = 4
    graph = [ [ 0 , 10 , 15 , 20 ] , [ 10 , 0 , 35 , 25 ] , [ 15 , 35 , 0 , 30 ] , [ 20 , 25 , 30 , 0 ] ]
    v = [ False for i in range ( n ) ]
    v [ 0 ] = True
    tsp ( graph , v , 0 , n , 1 , 0 )
    print ( min ( answer ) )

Index/key variables: currPos, i
Iterator variables: i
Python program:
def printTheArray ( arr , n ) :
    for i in range ( 0 , n ) :
        print ( arr [ i ] , end = " ▁ " )
    print ( )
def generateAllBinaryStrings ( n , arr , i ) :
    if i == n :
        printTheArray ( arr , n )
        return
    arr [ i ] = 0
    generateAllBinaryStrings ( n , arr , i + 1 )
    arr [ i ] = 1
    generateAllBinaryStrings ( n , arr , i + 1 )
if __name__ == " _ _ main _ _ " :
    n = 4
    arr = [ None ] * n
    generateAllBinaryStrings ( n , arr , 0 )

Index/key variables: i
Iterator variables: i
Python program:
def allCombinationsRec ( arr , elem , n ) :
    if ( elem > n ) :
        for i in ( arr ) :
            print ( i , end = " ▁ " )
        print ( " " )
        return
    for i in range ( 0 , 2 * n ) :
        if ( arr [ i ] == - 1 and ( i + elem + 1 ) < 2 * n and arr [ i + elem + 1 ] == - 1 ) :
            arr [ i ] = elem
            arr [ i + elem + 1 ] = elem
            allCombinationsRec ( arr , elem + 1 , n )
            arr [ i ] = - 1
            arr [ i + elem + 1 ] = - 1
def allCombinations ( n ) :
    arr = [ - 1 ] * ( 2 * n )
    elem = 1
    allCombinationsRec ( arr , elem , n )
n = 3
allCombinations ( n )

Index/key variables: i
Iterator variables: i
Python program:
def printPowerSet ( arr , n ) :
    _list = [ ]
    for i in range ( 2 ** n ) :
        subset = " "
        for j in range ( n ) :
            if ( i & ( 1 << j ) ) != 0 :
                subset += str ( arr [ j ] ) + " | "
        if subset not in _list and len ( subset ) > 0 :
            _list . append ( subset )
    for subset in _list :
        arr = subset . split ( ' ▁ ' )
        for string in arr :
            print ( string , end = " ▁ " )
        print ( )
if __name__ == ' _ _ main _ _ ' :
    arr = [ 10 , 12 , 12 ]
    n = len ( arr )
    printPowerSet ( arr , n )

Index/key variables: j
Accumulator variables: _list
Iterator variables: i, j, string, subset
Python program:
from queue import Queue
class node :
    color = 1
    edges = set ( )
def canPaint ( nodes , n , m ) :
    visited = [ 0 for _ in range ( n + 1 ) ]
    maxColors = 1
    for _ in range ( 1 , n + 1 ) :
        if visited [ _ ] :
            continue
        visited [ _ ] = 1
        q = Queue ( )
        q . put ( _ )
        while not q . empty ( ) :
            top = q . get ( )
            for _ in nodes [ top ] . edges :
                if nodes [ top ] . color == nodes [ _ ] . color :
                    nodes [ _ ] . color += 1
                maxColors = max ( maxColors , max ( nodes [ top ] . color , nodes [ _ ] . color ) )
                if maxColors > m :
                    print ( maxColors )
                    return 0
                if not visited [ _ ] :
                    visited [ _ ] = 1
                    q . put ( _ )
    return 1
if __name__ == " _ _ main _ _ " :
    n = 4
    graph = [ [ 0 , 1 , 1 , 1 ] , [ 1 , 0 , 1 , 0 ] , [ 1 , 1 , 0 , 1 ] , [ 1 , 0 , 1 , 0 ] ]
    m = 3
    nodes = [ ]
    for _ in range ( n + 1 ) :
        nodes . append ( node ( ) )
    for _ in range ( n ) :
        for __ in range ( n ) :
            if graph [ _ ] [ __ ] :
                nodes [ _ ] . edges . add ( _ )
                nodes [ __ ] . edges . add ( __ )
    print ( canPaint ( nodes , n , m ) )

Index/key variables: _, __, top
Accumulator variables: nodes
Iterator variables: __
Class/struct names: node
Python program:
def count ( arr , low , high , x ) :
    if ( ( low > high ) or ( low == high and arr [ low ] != x ) ) :
        return 0 ;
    if ( low == high and arr [ low ] == x ) :
        return 1 ;
    return count ( arr , low , ( low + high ) // 2 , x ) + count ( arr , 1 + ( low + high ) // 2 , high , x ) ;
if __name__ == ' _ _ main _ _ ' :
    arr = [ 30 , 1 , 42 , 5 , 56 , 3 , 56 , 9 ] ;
    n = len ( arr ) ;
    x = 56 ;
    print ( count ( arr , 0 , n - 1 , x ) ) ;

Index/key variables: low
Python program:
import random
a , b = None , None ;
def Partition ( arr , l , r ) :
    lst = arr [ r ] ; i = l ; j = l ;
    while ( j < r ) :
        if ( arr [ j ] < lst ) :
            arr [ i ] , arr [ j ] = arr [ j ] , arr [ i ] ;
            i += 1 ;
        j += 1 ;
    arr [ i ] , arr [ r ] = arr [ r ] , arr [ i ] ;
    return i ;
def randomPartition ( arr , l , r ) :
    n = r - l + 1 ;
    pivot = random . randrange ( 1 , 100 ) % n ;
    arr [ l + pivot ] , arr [ r ] = arr [ r ] , arr [ l + pivot ] ;
    return Partition ( arr , l , r ) ;
def MedianUtil ( arr , l , r , k , a1 , b1 ) :
    global a , b ;
    if ( l <= r ) :
        partitionIndex = randomPartition ( arr , l , r ) ;
        if ( partitionIndex == k ) :
            b = arr [ partitionIndex ] ;
            if ( a1 != - 1 ) :
                return ;
        elif ( partitionIndex == k - 1 ) :
            a = arr [ partitionIndex ] ;
            if ( b1 != - 1 ) :
                return ;
        if ( partitionIndex >= k ) :
            return MedianUtil ( arr , l , partitionIndex - 1 , k , a , b ) ;
        else :
            return MedianUtil ( arr , partitionIndex + 1 , r , k , a , b ) ;
    return ;
def findMedian ( arr , n ) :
    global a ;
    global b ;
    a = - 1 ;
    b = - 1 ;
    if ( n % 2 == 1 ) :
        MedianUtil ( arr , 0 , n - 1 , n // 2 , a , b ) ;
        ans = b ;
    else :
        MedianUtil ( arr , 0 , n - 1 , n // 2 , a , b ) ;
        ans = ( a + b ) // 2 ;
    print ( " Median ▁ = ▁ " , ans ) ;
arr = [ 12 , 3 , 5 , 7 , 4 , 19 , 26 ] ;
n = len ( arr ) ;
findMedian ( arr , n ) ;

Index/key variables: i, j, partitionIndex, r
Python program:
def firstDigit ( n ) :
    while ( n >= 10 ) :
        n //= 10 ;
    return n ;
def getCount ( n ) :
    count = 1 ;
    while ( n != 0 ) :
        leadDigit = firstDigit ( n ) ;
        n -= leadDigit ;
        count += 1 ;
    return count ;
def getLargestNumber ( k ) :
    left = k ;
    right = k * 10 ;
    mid = ( left + right ) // 2 ;
    length = getCount ( mid ) ;
    while ( length != k ) :
        mid = ( left + right ) // 2 ;
        length = getCount ( mid ) ;
        if ( length > k ) :
            right = mid ;
        else :
            left = mid ;
    while ( length == k ) :
        if ( length != getCount ( mid + 1 ) ) :
            break ;
        mid += 1 ;
    return mid ;
if __name__ == " _ _ main _ _ " :
    k = 3 ;
    print ( getLargestNumber ( k ) ) ;

Accumulator variables: count, mid, n
Python program:
import math
import sys
def closestsAngle ( N , A ) :
    mi = sys . maxsize
    ans = 0
    for i in range ( N ) :
        angle = 180.0 * i / N
        if ( math . fabs ( angle - A ) < math . fabs ( mi - A ) ) :
            mi = angle
            i += 1
            ans = i
    print ( 2 , 1 , 2 + ans )
if __name__ == ' _ _ main _ _ ' :
    N = 3
    A = 15
    closestsAngle ( N , A )

Iterator variables: i
Python program:
def centralPoints ( arr , N ) :
    count = 0
    for i in range ( N ) :
        c1 = 0
        c2 = 0
        c3 = 0
        c4 = 0
        x = arr [ i ] [ 0 ]
        y = arr [ i ] [ 1 ]
        for j in range ( N ) :
            if ( arr [ j ] [ 0 ] > x and arr [ j ] [ 1 ] == y ) :
                c1 = 1
            if ( arr [ j ] [ 1 ] > y and arr [ j ] [ 0 ] == x ) :
                c2 = 1
            if ( arr [ j ] [ 0 ] < x and arr [ j ] [ 1 ] == y ) :
                c3 = 1
            if ( arr [ j ] [ 1 ] < y and arr [ j ] [ 0 ] == x ) :
                c4 = 1
        if ( c1 + c2 + c3 + c4 == 4 ) :
            count += 1
    return count
if __name__ == ' _ _ main _ _ ' :
    arr = [ [ 1 , 0 ] , [ 2 , 0 ] , [ 1 , 1 ] , [ 1 , - 1 ] ]
    N = len ( arr )
    print ( centralPoints ( arr , N ) ) ;

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j
Python program:
from math import sqrt , floor
def finalPosition ( a , b , M ) :
    n = 0
    s = 0
    e = 0
    w = 0
    p = ' N '
    for i in range ( M ) :
        if ( p == ' N ' ) :
            if ( a [ i ] == ' U ' ) :
                p = ' N '
                n = n + b [ i ]
            elif ( a [ i ] == ' D ' ) :
                p = ' S '
                s = s + b [ i ]
            elif ( a [ i ] == ' R ' ) :
                p = ' E '
                e = e + b [ i ]
            elif ( a [ i ] == ' L ' ) :
                p = ' W '
                w = w + b [ i ]
        elif ( p == ' S ' ) :
            if ( a [ i ] == ' U ' ) :
                p = ' S '
                s = s + b [ i ]
            elif ( a [ i ] == ' D ' ) :
                p = ' N '
                n = n + b [ i ]
            elif ( a [ i ] == ' R ' ) :
                p = ' W '
                w = w + b [ i ]
            elif ( a [ i ] == ' L ' ) :
                p = ' E '
                e = e + b [ i ]
        elif ( p == ' E ' ) :
            if ( a [ i ] == ' U ' ) :
                p = ' E '
                e = e + b [ i ]
            elif ( a [ i ] == ' D ' ) :
                p = ' W '
                w = w + b [ i ]
            elif ( a [ i ] == ' R ' ) :
                p = ' S '
                s = s + b [ i ]
            elif ( a [ i ] == ' L ' ) :
                p = ' N '
                n = n + b [ i ]
        elif ( p == ' W ' ) :
            if ( a [ i ] == ' U ' ) :
                p = ' W '
                w = w + b [ i ]
            elif ( a [ i ] == ' D ' ) :
                p = ' E '
                e = e + b [ i ]
            elif ( a [ i ] == ' R ' ) :
                p = ' N '
                n = n + b [ i ]
            elif ( a [ i ] == ' L ' ) :
                p = ' S '
                s = s + b [ i ]
    ver_disp = n - s
    hor_disp = e - w
    displacement = floor ( sqrt ( ( ver_disp * ver_disp ) + ( hor_disp * hor_disp ) ) + 1 )
    print ( displacement , p )
if __name__ == ' _ _ main _ _ ' :
    A = [ ' U ' , ' R ' , ' R ' , ' R ' , ' R ' ]
    B = [ 1 , 1 , 1 , 1 , 0 ]
    N = len ( A )
    finalPosition ( A , B , N )

Index/key variables: i
Iterator variables: i
Python program:
import time
import random
random . seed ( time . time ( ) )
def generatePoints ( L , W ) :
    hash = { }
    total = ( L * W )
    for i in range ( total ) :
        X = random . randint ( 0 , L ) % L
        Y = random . randint ( 0 , W ) % W
        while ( ( X , Y ) in hash ) :
            X = random . randint ( 0 , L ) % L
            Y = random . randint ( 0 , W ) % W
        hash [ ( X , Y ) ] = 1
    for points in sorted ( hash ) :
        print ( " ( " , points [ 0 ] , " , ▁ " , points [ 1 ] , " ) ▁ " , end = " " )
if __name__ == ' _ _ main _ _ ' :
    L , W = 3 , 2
    generatePoints ( L , W )

Iterator variables: i, points
Python program:
def createPrefixArray ( n , arr , prefSize , pref ) :
    for i in range ( prefSize ) :
        pref [ i ] = 0
    for i in range ( n ) :
        x = arr [ i ] + 1000000
        pref [ x ] += 1
    for i in range ( 1 , prefSize ) :
        pref [ i ] += pref [ i - 1 ]
def pointOfIntersection ( m , segments , size , pref ) :
    ans = 0
    for i in range ( m ) :
        x1 = segments [ i ] [ 0 ]
        x2 = segments [ i ] [ 2 ]
        x1 = x1 + 1000000
        x2 = x2 + 1000000
        if ( x1 != x2 ) :
            if ( x1 > x2 ) :
                x1 , x2 = x2 , x1
            Occ_Till_Right = pref [ x2 - 1 ]
            Occ_Till_Left = pref [ x1 ]
            ans += ( Occ_Till_Right - Occ_Till_Left )
    return ans
N = 4
M = 8
size = 2000000 + 2
pref = [ 0 ] * size
lines = [ - 5 , - 3 , 2 , 3 ]
segments = [ [ - 2 , 5 , 5 , - 6 ] , [ - 5 , - 2 , - 3 , - 5 ] , [ - 2 , 3 , - 6 , 1 ] , [ - 1 , - 3 , 4 , 2 ] , [ 2 , 5 , 2 , 1 ] , [ 4 , 5 , 4 , - 5 ] , [ - 2 , - 4 , 5 , 3 ] , [ 1 , 2 , - 2 , 1 ] ]
createPrefixArray ( N , lines , size , pref )
print ( pointOfIntersection ( M , segments , size , pref ) )

Index/key variables: i, x, x1
Accumulator variables: ans
Iterator variables: i
Python program:
def solve ( n , m , obstacles , rangee ) :
    val = min ( n , m )
    rangee = sorted ( rangee )
    c = 1
    for i in range ( obstacles - 1 , - 1 , - 1 ) :
        rangee [ i ] = 2 * rangee [ i ]
        val -= rangee [ i ]
        if ( val <= 0 ) :
            return c
        else :
            c += 1
    if ( val > 0 ) :
        return - 1
n = 4
m = 5
obstacles = 3
rangee = [ 1.0 , 1.25 , 1.15 ]
print ( solve ( n , m , obstacles , rangee ) )

Index/key variables: i
Accumulator variables: c, val
Iterator variables: i
Python program:
def countRectangles ( radius ) :
    rectangles = 0
    diameter = 2 * radius
    diameterSquare = diameter * diameter
    for a in range ( 1 , 2 * radius ) :
        for b in range ( 1 , 2 * radius ) :
            diagonalLengthSquare = ( a * a + b * b )
            if ( diagonalLengthSquare <= diameterSquare ) :
                rectangles += 1
    return rectangles
radius = 2
totalRectangles = countRectangles ( radius )
print ( totalRectangles , " rectangles ▁ can ▁ be " , " cut ▁ from ▁ a ▁ circle ▁ of ▁ Radius " , radius )

Accumulator variables: rectangles
Iterator variables: a, b
Python program:
def isValid ( arr , i , j , m , c ) :
    if ( i == j ) :
        return False
    lhs = arr [ j ] ;
    rhs = m * arr [ i ] + c
    return ( lhs == rhs )
def findOrderedPoints ( arr , n , m , c ) :
    counter = 0
    for i in range ( 0 , n ) :
        for j in range ( 0 , n ) :
            firstIndex = i
            secondIndex = j
            if ( isValid ( arr , firstIndex , secondIndex , m , c ) ) :
                counter = counter + 1
    return counter
arr = [ 1 , 2 , 3 , 4 , 2 ]
n = len ( arr )
m = 1
c = 1
print ( findOrderedPoints ( arr , n , m , c ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def nCk ( n , k ) :
    C = [ 0 ] * ( k + 1 )
    for i in range ( 1 , n + 1 ) :
        j = min ( i , k )
        while ( j > 0 ) :
            C [ j ] = C [ j ] + C [ j - 1 ]
            j = j - 1
    return C [ k ]
def count_Straightlines ( n , m ) :
    return ( nCk ( n , 2 ) - nCk ( m , 2 ) + 1 )
n = 4
m = 3
print ( count_Straightlines ( n , m ) ) ;

Index/key variables: j, k
Iterator variables: i
Python program:
from math import sqrt
def checkPolygonWithMidpoints ( arr , N , midpoints ) :
    for j in range ( midpoints ) :
        val = 1
        for k in range ( j , N , midpoints ) :
            val &= arr [ k ]
        if ( val and N // midpoints > 2 ) :
            print ( " Polygon ▁ possible ▁ with ▁ side ▁ length " , ( N // midpoints ) )
            return True
    return False
def isPolygonPossible ( arr , N ) :
    limit = sqrt ( N )
    for i in range ( 1 , int ( limit ) + 1 ) :
        if ( N % i == 0 ) :
            if ( checkPolygonWithMidpoints ( arr , N , i ) or checkPolygonWithMidpoints ( arr , N , ( N // i ) ) ) :
                return
    print ( " Not ▁ possiblen " )
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 1 ]
    N = len ( arr )
    isPolygonPossible ( arr , N )

Index/key variables: k
Accumulator variables: val
Iterator variables: i, j, k
Python program:
def gcd ( a , b ) :
    if ( b == 0 ) :
        return a
    return gcd ( b , a % b )
def getReducedForm ( dy , dx ) :
    g = gcd ( abs ( dy ) , abs ( dx ) )
    sign = ( dy < 0 ) ^ ( dx < 0 )
    if ( sign ) :
        return ( - abs ( dy ) // g , abs ( dx ) // g )
    else :
        return ( abs ( dy ) // g , abs ( dx ) // g )
def minLinesToCoverPoints ( points , N , xO , yO ) :
    st = dict ( )
    minLines = 0
    for i in range ( N ) :
        curX = points [ i ] [ 0 ]
        curY = points [ i ] [ 1 ]
        temp = getReducedForm ( curY - yO , curX - xO )
        if ( temp not in st ) :
            st [ temp ] = 1
            minLines += 1
    return minLines
xO = 1
yO = 0
points = [ [ - 1 , 3 ] , [ 4 , 3 ] , [ 2 , 1 ] , [ - 1 , - 2 ] , [ 3 , - 3 ] ]
N = len ( points )
print ( minLinesToCoverPoints ( points , N , xO , yO ) )

Index/key variables: i, temp
Accumulator variables: minLines
Iterator variables: i
Python program:
class Point :
    def __init__ ( self , a , b ) :
        self . x = a
        self . y = b
def gcd ( a , b ) :
    if b == 0 :
        return a
    return gcd ( b , a % b )
def getCount ( p , q ) :
    if p . x == q . x :
        return abs ( p . y - q . y ) - 1
    if p . y == q . y :
        return abs ( p . x - q . x ) - 1
    return gcd ( abs ( p . x - q . x ) , abs ( p . y - q . y ) ) - 1
if __name__ == " _ _ main _ _ " :
    p = Point ( 1 , 9 )
    q = Point ( 8 , 16 )
    print ( " The ▁ number ▁ of ▁ integral ▁ points " , " between ▁ ( { } , ▁ { } ) ▁ and ▁ ( { } , ▁ { } ) ▁ is ▁ { } " . format ( p . x , p . y , q . x , q . y , getCount ( p , q ) ) )

Class/struct names: Point
Python program:
import math
def countDivisors ( n ) :
    divisors = 0
    for i in range ( 1 , math . ceil ( math . sqrt ( n ) ) + 1 ) :
        if n % i == 0 :
            divisors = divisors + 1
        if ( i - ( n / i ) == 1 ) :
            i = i - 1
    for i in range ( math . ceil ( math . sqrt ( n ) ) + 1 , 1 , - 1 ) :
        if ( n % i == 0 ) :
            divisors = divisors + 1
    return divisors
def possibleTriplets ( N ) :
    count = 0
    for i in range ( 1 , N ) :
        count = count + countDivisors ( N - i )
    return count
if __name__ == " _ _ main _ _ " :
    N = 10
    print ( possibleTriplets ( N ) )

Iterator variables: i
Python program:
def maxPlanes ( A , B , N ) :
    St = set ( )
    for i in range ( N ) :
        t = 1 if ( A [ i ] % B [ i ] > 0 ) else 0
        t += ( A [ i ] // B [ i ] ) + t
        St . add ( t )
    return len ( St )
A = [ 1 , 3 , 5 , 4 , 8 ]
B = [ 1 , 2 , 2 , 1 , 2 ]
N = len ( A )
print ( maxPlanes ( A , B , N ) )

Index/key variables: i
Accumulator variables: St, t
Iterator variables: i
Python program:
def maxRightmostElement ( N , k , arr ) :
    ans = arr [ N - 1 ]
    i = N - 2
    while ( i >= 0 ) :
        d = min ( arr [ i ] // 2 , k // ( N - 1 - i ) )
        k -= d * ( N - 1 - i )
        ans += d * 2
        i -= 1
    print ( ans , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
    N = 4
    k = 5
    arr = [ 3 , 8 , 1 , 4 ]
    maxRightmostElement ( N , k , arr )

Index/key variables: i
Accumulator variables: ans, k
Python program:
import sys
def isPossible ( arr , n ) :
    mini = sys . maxsize
    for i in range ( n ) :
        mini = min ( mini , arr [ i ] )
    for i in range ( n ) :
        if ( arr [ i ] == mini ) :
            continue
        Max = ( arr [ i ] + 1 ) // 2 - 1
        if ( mini < 0 or mini > Max ) :
            return " No "
    return " Yes "
if __name__ == ' _ _ main _ _ ' :
    arr = [ 1 , 1 , 3 , 4 ]
    N = len ( arr )
    print ( isPossible ( arr , N ) )

Index/key variables: i
Iterator variables: i
Python program:
def gcd1OfTwoNos ( num1 , num2 ) :
    if ( num1 == 0 ) :
        return num2
    if ( num2 == 0 ) :
        return num1
    if ( num1 == num2 ) :
        return num1
    if ( num1 > num2 ) :
        return gcd1OfTwoNos ( num1 - num2 , num2 )
    return gcd1OfTwoNos ( num1 , num2 - num1 )
def Min_sum ( arr , N ) :
    min_sum = 1000000
    maxgcd1 = 1
    for i in range ( N ) :
        gcd1 = 1
        if ( i == 0 ) :
            gcd1 = arr [ 1 ]
        else :
            gcd1 = arr [ i - 1 ]
        for j in range ( N ) :
            if ( j != i ) :
                gcd1 = gcd1OfTwoNos ( gcd1 , arr [ j ] )
        c = arr [ i ]
        if ( gcd1 > maxgcd1 ) :
            maxgcd1 = gcd1
    return maxgcd1
if __name__ == ' _ _ main _ _ ' :
    arr = [ 16 , 5 , 10 , 25 ]
    N = len ( arr )
    print ( Min_sum ( arr , N ) )

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