dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
let total_xor ; function initialize_xor ( arr , n ) { for ( let i = 0 ; i < n ; i ++ ) { total_xor = total_xor ^ arr [ i ] ; } } function find_xor ( X , Y ) { total_xor = total_xor ^ X ; total_xor = total_xor ^ Y ; document . write ( total_xor + " " ) ; } let arr = [ 5 , 7 , 8 , 9 ] ; let n = arr . length ; initialize_xor ( arr , n ) ; let Q = [ [ 5 , 6 ] , [ 8 , 1 ] ] ; for ( let i = 0 ; i < Q . length ; i ++ ) { find_xor ( Q [ i ] [ 0 ] , Q [ i ] [ 1 ] ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function maxGCD ( N ) { for ( var i = 2 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) { return N / i ; } } return 1 ; } var N = 33 ; document . write ( " " + " " + maxGCD ( N ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function min_value ( arr , N ) { let x , X , K ; let S = [ ] ; for ( let i = 0 ; i < N ; i ++ ) { S . push ( arr [ i ] ) ; } let count = 0 ; for ( let i = 1 ; i <= 1024 ; i ++ ) { count = 0 ; for ( let it in S ) { X = ( ( i it ) - ( i & it ) ) ; for ( let j in S ) { if ( S [ j ] == X ) { count ++ ; } } } if ( count == S . length ) { K = i ; return K ; } } return - 1 ; } let arr = [ 1 , 0 , 3 , 3 , 0 , 2 ] ; let N = arr . length ; document . write ( min_value ( arr , N ) ) ;

Index/key variables: i, j
Accumulator variables: count, i
Iterator variables: i, it, j
Javascript program:
function sum ( n ) { let sum = 0 ; while ( n != 0 ) { let r = n % 10 ; sum = sum + r ; n = parseInt ( n / 10 ) ; } return sum ; } function isJunction ( n ) { let count = 0 ; for ( i = 1 ; i <= n ; i ++ ) { if ( i + sum ( i ) == n ) count ++ ; } return count >= 2 ; } let N = 111 ; if ( isJunction ( N ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function digProduct ( n ) { var product = 1 ; while ( n != 0 ) { product = product * ( n % 10 ) ; n = parseInt ( n / 10 ) ; } return product ; } function isPrime ( n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( var i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } function nextPrime ( N ) { if ( N <= 1 ) return 2 ; var prime = N ; var found = false ; while ( ! found ) { prime ++ ; if ( isPrime ( prime ) ) found = true ; } return prime ; } function isPointerPrime ( n ) { if ( isPrime ( n ) && ( n + digProduct ( n ) == nextPrime ( n ) ) ) return true ; else return false ; } var N = 23 ; if ( isPointerPrime ( N ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: prime
Iterator variables: i
Boolean variables: found
Javascript program:
function power ( x , y ) { if ( y == 0 ) { return 1 ; } if ( y % 2 == 0 ) { return ( power ( x , Math . floor ( y / 2 ) ) * power ( x , Math . floor ( y / 2 ) ) ) ; } return ( x * power ( x , Math . floor ( y / 2 ) ) * power ( x , Math . floor ( y / 2 ) ) ) ; } function isPerfectDigitalInvariant ( x ) { for ( var fixed_power = 1 ; ; fixed_power ++ ) { var temp = x , sum = 0 ; while ( temp ) { var r = temp % 10 ; sum += power ( r , fixed_power ) ; temp = Math . floor ( temp / 10 ) ; } if ( sum == x ) { return true ; } if ( sum > x ) { return false ; } } } var N = 4150 ; if ( isPerfectDigitalInvariant ( N ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: fixed_power, sum
Iterator variables: fixed_power
Javascript program:
function SieveOfEratosthenes ( n , isPrime ) { isPrime [ 0 ] = isPrime [ 1 ] = false ; for ( let i = 2 ; i <= n ; i ++ ) isPrime [ i ] = true ; for ( let p = 2 ; p * p <= n ; p ++ ) { if ( isPrime [ p ] == true ) { for ( let i = p * 2 ; i <= n ; i += p ) isPrime [ i ] = false ; } } } function countDigit ( n ) { let count = 0 ; while ( n != 0 ) { n = parseInt ( n / 10 ) ; ++ count ; } return count ; } function isBrilliant ( n ) { let flag = 0 ; let isPrime = Array ( n + 1 ) . fill ( true ) ; SieveOfEratosthenes ( n , isPrime ) ; for ( let i = 2 ; i < n ; i ++ ) { let x = n / i ; if ( isPrime [ i ] && isPrime [ x ] && ( x * i ) == n ) { if ( countDigit ( i ) == countDigit ( x ) ) return true ; } } return false ; } let n = 1711 ; if ( isBrilliant ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, p, x
Accumulator variables: i, p
Iterator variables: i, p
Javascript program:
let x = 0 , y = 0 , x1 = 0 , y1 = 0 ; let x0 = 0 , y0 = 0 , g = 0 ; function gcd ( a , b ) { if ( b == 0 ) { x = 1 ; y = 0 ; return a ; } let store_gcd = gcd ( b , a % b ) ; x = y1 ; y = x1 - y1 * parseInt ( a / b , 10 ) ; return store_gcd ; } function possible_solution ( a , b , c ) { g = gcd ( Math . abs ( a ) , Math . abs ( b ) ) ; if ( c % g != 0 ) { return 0 ; } x0 *= parseInt ( c / g , 10 ) ; y0 *= parseInt ( c / g , 10 ) ; if ( a < 0 ) x0 *= - 1 ; if ( b < 0 ) y0 *= - 1 ; return 1 ; } function shift_solution ( a , b , shift_var ) { x += shift_var * b ; y -= shift_var * a ; } function find_min_sum ( a , b , c ) { let x = 0 , y = 0 , g = 0 ; if ( possible_solution ( a , b , c ) == 0 ) return - 1 ; if ( g != 0 ) { a = parseInt ( a / g , 10 ) ; b = parseInt ( b / g , 10 ) ; } let sign_a = a > 0 ? + 1 : - 1 ; let sign_b = b > 0 ? + 1 : - 1 ; shift_solution ( a , b , parseInt ( - x / b , 10 ) ) ; if ( x < 0 ) shift_solution ( a , b , sign_b ) ; let minx1 = x ; shift_solution ( a , b , parseInt ( y / a , 10 ) ) ; if ( y < 0 ) shift_solution ( a , b , - sign_a ) ; let minx2 = x ; if ( minx2 > x ) { let temp = minx2 ; minx2 = x ; x = temp ; } let minx = Math . max ( minx1 , minx2 ) ; if ( minx > x ) return - 1 ; let miny = parseInt ( ( c - a * x ) / b , 10 ) ; return ( miny + minx ) ; } let a = 2 , b = 2 , c = 0 ; document . write ( find_min_sum ( a , b , c ) ) ;

Accumulator variables: x, x0, y, y0
Javascript program:
function gcd ( a , b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } function divSum ( n ) { let result = 0 ; for ( let i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i == ( n / i ) ) result += i ; else result += ( i + n / i ) ; } } return ( result + n + 1 ) ; } function isDuffinian ( n ) { let sumDivisors = divSum ( n ) ; if ( sumDivisors == n + 1 ) return false ; let hcf = gcd ( n , sumDivisors ) ; return hcf == 1 ; } let n = 36 ; if ( isDuffinian ( n ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Accumulator variables: i, result
Iterator variables: i
Javascript program:
let MAX = 1000000 ; let primes = [ ] ; function sieveSundaram ( ) { let marked = Array . from ( { length : MAX / 2 + 1 } , ( _ , i ) => 0 ) ; for ( let i = 1 ; i <= ( Math . sqrt ( MAX ) - 1 ) / 2 ; i ++ ) for ( let j = ( i * ( i + 1 ) ) << 1 ; j <= MAX / 2 ; j += 2 * i + 1 ) marked [ j ] = true ; primes . push ( 2 ) ; for ( let i = 1 ; i <= MAX / 2 ; i ++ ) if ( marked [ i ] == false ) primes . push ( 2 * i + 1 ) ; } function calculateKummer ( n ) { let result = 1 ; for ( let i = 0 ; i < n ; i ++ ) result = result * primes [ i ] ; return - 1 + result ; } let n = 5 ; sieveSundaram ( ) ; for ( let i = 1 ; i <= n ; i ++ ) document . write ( calculateKummer ( i ) + " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function check ( n ) { var digits = new Set ( ) ; var temp = n ; var sum = 0 ; var count = 0 ; while ( temp > 0 ) { sum += temp % 10 ; digits . add ( temp % 10 ) ; count ++ ; temp = parseInt ( temp / 10 ) ; } if ( sum % count == 0 && digits . has ( sum / count ) ) document . write ( " " ) ; else document . write ( " " ) ; } var n = 42644 ; check ( n ) ;

Accumulator variables: count, sum
Javascript program:
function countSmaller ( str ) { var n = str . length ; for ( var i = 0 ; i < n ; i ++ ) { var cnt = 0 ; for ( var j = i + 1 ; j < n ; j ++ ) { if ( str [ j ] < str [ i ] ) { cnt += 1 ; } } document . write ( cnt + " " ) ; } } var str = " " ; countSmaller ( str ) ;

Index/key variables: i, j
Accumulator variables: cnt, i, j
Iterator variables: i, j
Javascript program:
function smallestSumpair ( arr , n ) { let pair = [ ] ; let min_sum = Number . MAX_VALUE , i ; for ( i = 1 ; i < n ; i ++ ) { if ( min_sum > ( arr [ i ] + arr [ i - 1 ] ) ) { min_sum = arr [ i ] + arr [ i - 1 ] ; if ( pair . length == 0 ) { pair . push ( arr [ i - 1 ] ) ; pair . push ( arr [ i ] ) ; } else { pair [ 0 ] = arr [ i - 1 ] ; pair [ 1 ] = arr [ i ] ; } } } return pair ; } let arr = [ 4 , 9 , - 3 , 2 , 0 ] ; let N = arr . length ; let pair = smallestSumpair ( arr , N ) ; document . write ( pair [ 0 ] + " " + pair [ 1 ] ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function val ( c ) { if ( c >= ' ' && c <= ' ' ) return c . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; else return c . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + 10 ; } function convert ( num , bases ) { let len = ( num . length ) ; let power = 1 ; let res = 0 ; let i ; for ( i = len - 1 ; i >= 0 ; i -- ) { res += val ( num [ i ] ) * power ; power = power * bases ; } return res ; } function dec_to_base ( num , bases ) { let base_num = [ ] ; while ( num > 0 ) { let dig = ( num % bases ) ; if ( dig < 10 ) base_num . push ( ( dig ) . toString ( ) ) ; else base_num . append ( ( ' ' . charCodeAt ( 0 ) + dig - 10 ) . toString ( ) ) ; num = Math . floor ( num / bases ) ; } for ( let i = base_num . length - 1 ; i >= 0 ; i -- ) document . write ( base_num [ i ] ) ; } let a = " " ; let b = " " ; let base_a = 6 ; let base_b = 8 ; let a10 = convert ( a , base_a ) ; let b10 = convert ( b , base_b ) ; let summ = a10 + b10 ; let min_base = Math . min ( base_a , base_b ) ; dec_to_base ( summ , min_base ) ;

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Javascript program:
function sumOfProductOfDigits ( n1 , n2 ) { let sum = 0 ; while ( n1 > 0 && n2 > 0 ) { sum += ( ( n1 % 10 ) * ( n2 % 10 ) ) ; n1 = Math . floor ( n1 / 10 ) ; n2 = Math . floor ( n2 / 10 ) ; } return sum ; } let n1 = 25 ; let n2 = 1548 ; document . write ( sumOfProductOfDigits ( n1 , n2 ) ) ;

Accumulator variables: sum
Javascript program:
function printPermutation ( N ) { let temp = N , count = 0 ; while ( temp > 0 ) { count ++ ; temp = parseInt ( temp / 10 , 10 ) ; } let num = new Array ( count ) ; num . fill ( 0 ) ; while ( N > 0 ) { num [ count -- - 1 ] = N % 10 ; N = parseInt ( N / 10 , 10 ) ; } while ( next_permutation ( num ) ) { for ( let i = 0 ; i < num . length ; i ++ ) document . write ( num [ i ] ) ; document . write ( " " ) ; } } function next_permutation ( p ) { for ( let a = p . length - 2 ; a >= 0 ; -- a ) if ( p [ a ] < p [ a + 1 ] ) for ( let b = p . length - 1 ; ; -- b ) if ( p [ b ] > p [ a ] ) { let t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; for ( ++ a , b = p . length - 1 ; a < b ; ++ a , -- b ) { t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; } return true ; } return false ; } let N = 324 ; printPermutation ( N ) ;

Index/key variables: a, b, i
Accumulator variables: count, i
Iterator variables: a, b, i
Javascript program:
let n = 500000 - 2 ; let v = [ ] ; function sieveoferanthones ( ) { let prime = Array . from ( { length : n + 1 } , ( _ , i ) => true ) ; for ( let i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( prime [ i ] ) for ( let j = i * i ; j <= n ; j += i ) { prime [ j ] = false ; } } for ( let i = 2 ; i < n ; i ++ ) { if ( prime [ i ] ) v . push ( i ) ; } } function numberOfWays ( n ) { let count = 0 ; for ( let j = 1 ; 2 * ( Math . pow ( j , 2 ) ) < n ; j ++ ) { for ( let i = 1 ; v [ i ] + 2 <= n ; i ++ ) { if ( n == v [ i ] + ( 2 * ( Math . pow ( j , 2 ) ) ) ) count ++ ; } } document . write ( count + " " ) ; } sieveoferanthones ( ) ; let N = 9 ; numberOfWays ( N ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function bToHexaDecimal ( s ) { let len = s . length , check = 0 ; let num = 0 , sum = 0 , mul = 1 ; let ans = new Array ( ) ; for ( let i = len - 1 ; i >= 0 ; i -- ) { sum += ( s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) * mul ; mul *= 2 ; check ++ ; if ( check == 4 i == 0 ) { if ( sum <= 9 ) ans . push ( String . fromCharCode ( sum + ' ' . charCodeAt ( 0 ) ) ) ; else ans . push ( String . fromCharCode ( sum + 55 ) ) ; check = 0 ; sum = 0 ; mul = 1 ; } } len = ans . length ; for ( let i = len - 1 ; i >= 0 ; i -- ) document . write ( ans [ i ] ) ; } let s = " " ; bToHexaDecimal ( s ) ;

Index/key variables: i
Accumulator variables: check, i, mul, sum
Iterator variables: i
Javascript program:
function Dodecagonal_num ( n ) { return ( 5 * n * n - 4 * n ) ; } function sum_Dodecagonal_num ( n ) { let summ = 0 ; for ( let i = 1 ; i < n + 1 ; i ++ ) { summ += Dodecagonal_num ( i ) ; } return summ ; } let n = 5 ; document . write ( sum_Dodecagonal_num ( n ) ) ;

Accumulator variables: i, summ
Iterator variables: i
Javascript program:
function gcd ( a , b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } function countDistinctWays ( N , M ) { let ans = 0 ; for ( let i = 0 ; i < N ; i ++ ) { let K = gcd ( i , N ) ; ans += Math . pow ( M , K ) ; } ans /= N ; document . write ( ans ) ; } let N = 4 , M = 3 ; countDistinctWays ( N , M ) ;

Accumulator variables: ans, i
Iterator variables: i
Javascript program:
var ans = 0 ; var graph = Array . from ( Array ( 100 ) , ( ) => Array ( ) ) ; var weight = Array . from ( Array ( 100 ) , ( ) => Array ( ) ) ; function isPerfect ( n ) { var sum = 1 ; for ( var i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { if ( i * i != n ) sum = sum + i + n / i ; else sum = sum + i ; } } if ( sum == n && n != 1 ) return true ; return false ; } function dfs ( node , parent ) { if ( isPerfect ( weight [ node ] ) ) ans += 1 ; graph [ node ] . forEach ( to => { if ( to != parent ) dfs ( to , node ) ; } ) ; } weight [ 1 ] = 5 ; weight [ 2 ] = 10 ; weight [ 3 ] = 11 ; weight [ 4 ] = 8 ; weight [ 5 ] = 6 ; graph [ 1 ] . push ( 2 ) ; graph [ 2 ] . push ( 3 ) ; graph [ 2 ] . push ( 4 ) ; graph [ 1 ] . push ( 5 ) ; dfs ( 1 , 1 ) ; document . write ( ans ) ;

Index/key variables: node
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function GetMinCost ( N ) { let pq = [ ] ; for ( let i = 1 ; i <= N ; i ++ ) { pq . push ( i ) ; } pq . sort ( function ( a , b ) { return a - b } ) ; let cost = 0 ; while ( pq . length > 1 ) { let mini = pq [ 0 ] ; pq . shift ( ) ; let secondmini = pq [ 0 ] ; pq . shift ( ) ; let current = mini * secondmini ; cost += current ; pq . push ( current ) ; pq . sort ( function ( a , b ) { return a - b } ) ; } return cost ; } let N = 5 ; document . write ( GetMinCost ( N ) ) ;

Accumulator variables: cost, i
Iterator variables: i
Javascript program:
var MOD = parseInt ( 1e9 + 7 ) ; function numPrimeArrangements ( n ) { var prime = Array . from ( { length : n + 1 } , ( _ , i ) => true ) ; prime [ 0 ] = false ; prime [ 1 ] = false ; for ( var i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( prime [ i ] ) for ( factor = 2 ; factor * i <= n ; factor ++ ) prime [ factor * i ] = false ; } var primeIndices = 0 ; for ( var i = 1 ; i <= n ; i ++ ) if ( prime [ i ] ) primeIndices ++ ; var mod = parseInt ( ( 1e9 + 7 ) ) , res = 1 ; for ( var i = 1 ; i <= primeIndices ; i ++ ) res = ( ( 1 * res * i ) % mod ) ; for ( var i = 1 ; i <= ( n - primeIndices ) ; i ++ ) res = ( ( 1 * res * i ) % mod ) ; return res ; } var N = 5 ; document . write ( numPrimeArrangements ( N ) ) ;

Index/key variables: i
Accumulator variables: factor, i, primeIndices
Iterator variables: factor, i
Javascript program:
function fact ( n ) { var res = 1 ; for ( var i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } function count_heads ( n , r ) { var output ; output = fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; output = output / ( Math . pow ( 2 , n ) ) ; return output ; } var n = 4 , r = 3 ; document . write ( count_heads ( n , r ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function dfs ( u , adj , vis ) { vis [ u ] = 1 ; let componentSize = 1 ; for ( let it in adj [ u ] ) { if ( vis [ it ] == 0 ) { componentSize += dfs ( it , adj , vis ) ; } } return componentSize ; } function maximumComponentSize ( a , n ) { let adj = new Array ( n ) ; for ( var i = 0 ; i < adj . length ; i ++ ) { adj [ i ] = new Array ( 2 ) ; } for ( var i = 0 ; i < adj . length ; i ++ ) { for ( var j = 0 ; j < adj . length ; j ++ ) { adj [ i ] [ j ] = 0 ; } } for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { if ( __gcd ( a [ i ] , a [ j ] ) > 1 ) adj [ i ] . push ( j ) ; adj [ j ] . push ( i ) ; } } let answer = 0 ; let vis = Array . from ( { length : n } , ( _ , i ) => 0 ) ; for ( let k = 0 ; k < n ; k ++ ) { vis [ k ] = 0 ; } for ( let i = 0 ; i < n ; i ++ ) { if ( vis [ i ] == 0 ) { answer = Math . max ( answer , dfs ( i , adj , vis ) ) ; } } return answer ; } function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } let n = 8 ; let A = [ 2 , 3 , 6 , 7 , 4 , 12 , 21 , 39 ] ; document . write ( maximumComponentSize ( A , n ) ) ;

Index/key variables: i, it, j, k, u
Accumulator variables: componentSize, i, j, k
Iterator variables: i, it, j, k
Javascript program:
var spf = Array ( 100005 ) . fill ( 0 ) ; function sieve ( ) { for ( var i = 2 ; i < 100005 ; i ++ ) { if ( spf [ i ] == 0 ) { spf [ i ] = i ; for ( var j = 2 * i ; j < 100005 ; j += i ) { if ( spf [ j ] == 0 ) spf [ j ] = i ; } } } } function factorize ( n , s ) { while ( n > 1 ) { var z = spf [ n ] ; s . add ( z ) ; while ( n % z == 0 ) n = parseInt ( n / z ) ; } return s ; } var id = Array ( 100005 ) . fill ( 0 ) ; var par = Array ( 100005 ) . fill ( 0 ) ; var sizeContainer = Array ( 100005 ) . fill ( 0 ) ; function root ( i ) { if ( par [ i ] == i ) return i ; else return par [ i ] = root ( par [ i ] ) ; } function merge ( a , b ) { var p = root ( a ) ; var q = root ( b ) ; if ( p == q ) return ; if ( sizeContainer [ p ] > sizeContainer [ q ] ) { [ p , q ] = [ q , p ] } par [ p ] = q ; sizeContainer [ q ] += sizeContainer [ p ] ; } function maximumComponentsizeContainer ( a , n ) { for ( var i = 0 ; i < 100005 ; i ++ ) { par [ i ] = i ; sizeContainer [ i ] = 1 ; } sieve ( ) ; for ( var i = 0 ; i < n ; i ++ ) { var s = new Set ( ) ; s = factorize ( a [ i ] , s ) ; s . forEach ( it => { if ( id [ it ] == 0 ) id [ it ] = i + 1 ; else merge ( i + 1 , id [ it ] ) ; } ) ; } var answer = 0 ; for ( var i = 0 ; i < n ; i ++ ) answer = Math . max ( answer , sizeContainer [ i ] ) ; return answer ; } var n = 8 ; var A = [ 2 , 3 , 6 , 7 , 4 , 12 , 21 , 39 ] ; document . write ( maximumComponentsizeContainer ( A , n ) ) ;

Index/key variables: i, it, j, n, p, q
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
let N = 1000000 ; let prime = [ ] ; function SieveOfEratosthenes ( ) { let check = new Array ( N + 1 ) ; check . fill ( true ) ; for ( let p = 2 ; p * p <= N ; p ++ ) { if ( check [ p ] == true ) { prime . push ( p ) ; for ( let i = p * p ; i <= N ; i += p ) check [ i ] = false ; } } } class Node { constructor ( key ) { this . left = null ; this . right = null ; this . key = key ; } } function newNode ( key ) { let temp = new Node ( key ) ; return ( temp ) ; } function IsChilrenPrimeFactor ( parent , a ) { if ( prime [ a . key ] > 0 && ( parent . key % a . key == 0 ) ) return true ; else return false ; } function GetCount ( node ) { if ( node == null ) return 0 ; let q = [ ] ; let count = 0 ; q . push ( node ) ; while ( q . length > 0 ) { let temp = q [ 0 ] ; q . shift ( ) ; if ( temp . left == null && temp . right != null ) { if ( IsChilrenPrimeFactor ( temp , temp . right ) ) count ++ ; } else { if ( temp . right == null && temp . left != null ) { if ( IsChilrenPrimeFactor ( temp , temp . left ) ) count ++ ; } else { if ( temp . left != null && temp . right != null ) { if ( IsChilrenPrimeFactor ( temp , temp . right ) && IsChilrenPrimeFactor ( temp , temp . left ) ) count ++ ; } } } if ( temp . left != null ) q . push ( temp . left ) ; if ( temp . right != null ) q . push ( temp . right ) ; } return count ; } let root = newNode ( 10 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 5 ) ; root . right . left = newNode ( 18 ) ; root . right . right = newNode ( 12 ) ; root . right . left . left = newNode ( 2 ) ; root . right . left . right = newNode ( 3 ) ; root . right . right . left = newNode ( 3 ) ; root . right . right . right = newNode ( 14 ) ; root . right . right . right . left = newNode ( 7 ) ; SieveOfEratosthenes ( ) ; document . write ( GetCount ( root ) + " " ) ;

Index/key variables: i, p
Accumulator variables: count, i, p
Iterator variables: i, p
Class/struct names: Node
Javascript program:
function check ( Arr , n , M , K ) { let flag = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( Arr [ i ] == 0 ) flag = 1 ; } if ( K % 2 != 0 && flag == 0 ) return " " ; else return " " ; } let Arr = [ 1 , 1 , 2 , 4 , 7 , 8 ] ; let M = 5 ; let K = 6 ; let n = Arr . length ; document . write ( check ( Arr , n , M , K ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let pref = new Array ( 100001 ) ; pref . fill ( 0 ) ; function checkArmstrong ( x ) { let n = ( x . toString ( ) ) . length ; let sum1 = 0 ; let temp = x ; while ( temp > 0 ) { let digit = temp % 10 ; sum1 += Math . pow ( digit , n ) ; temp = parseInt ( temp / 10 , 10 ) ; } if ( sum1 == x ) return x ; return 0 ; } function preCompute ( ) { for ( let i = 1 ; i < 100001 ; i ++ ) { pref [ i ] = pref [ i - 1 ] + checkArmstrong ( i ) ; } } function printSum ( L , R ) { document . write ( ( pref [ R ] - pref [ L - 1 ] ) + " " ) ; } function printSumarmstrong ( arr , Q ) { preCompute ( ) ; for ( let i = 0 ; i < Q ; i ++ ) { printSum ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ; } } let Q = 2 ; let arr = [ [ 1 , 13 ] , [ 121 , 211 ] ] ; printSumarmstrong ( arr , Q ) ;

Index/key variables: R, i
Accumulator variables: i, sum1
Iterator variables: i
Javascript program:
let prime = new Array ( 100001 ) . fill ( 0 ) ; let k = new Array ( 100001 ) . fill ( 0 ) ; function Sieve ( ) { for ( let i = 1 ; i < 100001 ; i ++ ) k [ i ] = i ; for ( let i = 2 ; i < 100001 ; i ++ ) { if ( prime [ i ] == 0 ) for ( let j = i ; j < 100001 ; j += i ) { prime [ j ] = 1 ; while ( k [ j ] % ( i * i ) == 0 ) k [ j ] /= ( i * i ) ; } } } function countPairs ( arr , n ) { let freq = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( freq . has ( k [ arr [ i ] ] ) ) { freq . set ( k [ arr [ i ] ] , freq . get ( k [ arr [ i ] ] ) + 1 ) ; } else freq . set ( k [ arr [ i ] ] , 1 ) ; } let sum = 0 ; for ( let i of freq ) { sum += ( ( i [ 1 ] - 1 ) * i [ 1 ] ) / 2 ; } return sum ; } let arr = [ 1 , 2 , 4 , 8 , 5 , 6 ] ; let n = arr . length ; Sieve ( ) ; document . write ( countPairs ( arr , n ) + " " ) ;

Index/key variables: i, j
Accumulator variables: i, j, sum
Iterator variables: i, j
Javascript program:
var pref = Array ( 100010 ) . fill ( 0 ) ; function isPerfectCube ( x ) { var cr = Math . round ( Math . cbrt ( x ) ) ; return ( cr * cr * cr == x ) ? x : 0 ; } function compute ( ) { for ( var i = 1 ; i <= 100000 ; ++ i ) { pref [ i ] = pref [ i - 1 ] + isPerfectCube ( i ) ; } } function printSum ( L , R ) { var sum = pref [ R ] - pref [ L - 1 ] ; document . write ( sum + " " ) ; } compute ( ) ; var Q = 4 ; var arr = [ [ 1 , 10 ] , [ 1 , 100 ] , [ 2 , 25 ] , [ 4 , 50 ] ] ; for ( var i = 0 ; i < Q ; i ++ ) { printSum ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ; }

Index/key variables: R, i
Accumulator variables: i
Iterator variables: i
Javascript program:
function binomialCoeff ( n , k ) { var C = new Array ( n + 1 ) ; for ( var i = 0 ; i < C . length ; i ++ ) { C [ i ] = new Array ( k + 1 ) ; } var i , j ; for ( i = 0 ; i <= n ; i ++ ) { for ( j = 0 ; j <= Math . min ( i , k ) ; j ++ ) { if ( j == 0 j == i ) C [ i ] [ j ] = 1 ; else C [ i ] [ j ] = C [ i - 1 ] [ j - 1 ] + C [ i - 1 ] [ j ] ; } } return C [ n ] [ k ] ; } function count ( n , k ) { var sum = 0 ; for ( var j = 1 ; j <= k ; j ++ ) { sum = sum + binomialCoeff ( n , j ) ; } return sum ; } var n = 3 ; var k = 2 ; document . write ( count ( n , k ) ) ; var n = 5 ; var k = 2 ; document . write ( count ( n , k ) ) ;

Index/key variables: i, j, k, n
Accumulator variables: i, j
Iterator variables: i, j