dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function countRectangles ( radius ) { let rectangles = 0 ; let diameter = 2 * radius ; let diameterSquare = diameter * diameter ; for ( let a = 1 ; a < 2 * radius ; a ++ ) { for ( let b = 1 ; b < 2 * radius ; b ++ ) { let diagonalLengthSquare = ( a * a + b * b ) ; if ( diagonalLengthSquare <= diameterSquare ) { rectangles ++ ; } } } return rectangles ; } let radius = 2 ; let totalRectangles ; totalRectangles = countRectangles ( radius ) ; document . write ( totalRectangles + " " + radius ) ;

Accumulator variables: a, b, rectangles
Iterator variables: a, b
Javascript program:
function isValid ( arr , i , j , m , c ) { if ( i == j ) return false ; var lhs = arr [ j ] ; var rhs = m * arr [ i ] + c ; return lhs == rhs ; } function findOrderedPoints ( arr , n , m , c ) { var counter = 0 ; for ( var i = 0 ; i < n ; i ++ ) { for ( var j = 0 ; j < n ; j ++ ) { var firstIndex = i , secondIndex = j ; if ( isValid ( arr , firstIndex , secondIndex , m , c ) ) counter ++ ; } } return counter ; } var arr = [ 1 , 2 , 3 , 4 , 2 ] ; var n = arr . length ; var m = 1 , c = 1 ; document . write ( findOrderedPoints ( arr , n , m , c ) ) ;

Index/key variables: i, j
Accumulator variables: counter, i, j
Iterator variables: i, j
Javascript program:
function nCk ( n , k ) { let C = new Array ( k + 1 ) ; C . fill ( 0 ) ; for ( let i = 1 ; i <= n ; i ++ ) { for ( let j = Math . min ( i , k ) ; j > 0 ; j -- ) C [ j ] = C [ j ] + C [ j - 1 ] ; } return C [ k ] ; } function count_Straightlines ( n , m ) { return ( nCk ( n , 2 ) - nCk ( m , 2 ) + 1 ) ; } let n = 4 , m = 3 ; document . write ( count_Straightlines ( n , m ) ) ;

Index/key variables: j, k
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
const EPSILON = 1.0842e-19 ; function compareDoubles ( A , B ) { var diff = A - B ; return diff < EPSILON && - diff < EPSILON ; } function numberOfTringles ( a , b , c , n ) { var slope = [ ] ; for ( var i = 0 ; i < n ; i ++ ) slope . push ( parseFloat ( a [ i ] * 1.0 ) / b [ i ] ) ; slope . sort ( ) ; var count = new Array ( n ) . fill ( 0 ) ; var k = 0 ; var this_count = 1 ; for ( var i = 1 ; i < n ; i ++ ) { if ( compareDoubles ( parseFloat ( slope [ i ] ) , parseFloat ( slope [ i - 1 ] ) ) ) this_count ++ ; else { count [ k ++ ] = this_count ; this_count = 1 ; } } count [ k ++ ] = this_count ; var sum1 = 0 ; for ( var i = 0 ; i < k ; i ++ ) sum1 += count [ i ] ; var sum2 = 0 ; var temp = new Array ( n ) . fill ( 0 ) ; for ( var i = 0 ; i < k ; i ++ ) { temp [ i ] = count [ i ] * ( sum1 - count [ i ] ) ; sum2 += temp [ i ] ; } sum2 /= 2 ; var sum3 = 0 ; for ( var i = 0 ; i < k ; i ++ ) sum3 += count [ i ] * ( sum2 - temp [ i ] ) ; sum3 /= 3 ; return sum3 ; } var a = [ 1 , 2 , 3 , 4 ] ; var b = [ 2 , 4 , 5 , 5 ] ; var c = [ 5 , 7 , 8 , 6 ] ; var n = a . length ; document . write ( " " + " " + numberOfTringles ( a , b , c , n ) ) ;

Index/key variables: i
Accumulator variables: i, k, sum1, sum2, sum3, this_count
Iterator variables: i
Javascript program:
function checkPolygonWithMidpoints ( arr , N , midpoints ) { for ( let j = 0 ; j < midpoints ; j ++ ) { let val = 1 ; for ( let k = j ; k < N ; k += midpoints ) { val &= arr [ k ] ; } if ( val && parseInt ( N / midpoints ) > 2 ) { document . write ( " " + parseInt ( N / midpoints ) + " " ) ; return true ; } } return false ; } function isPolygonPossible ( arr , N ) { let limit = Math . sqrt ( N ) ; for ( let i = 1 ; i <= limit ; i ++ ) { if ( N % i == 0 ) { if ( checkPolygonWithMidpoints ( arr , N , i ) || checkPolygonWithMidpoints ( arr , N , parseInt ( N / i ) ) ) return ; } } document . write ( " " ) ; } let arr = [ 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 , 1 ] ; let N = arr . length ; isPolygonPossible ( arr , N ) ;

Index/key variables: k
Accumulator variables: i, j, k, val
Iterator variables: i, j, k
Javascript program:
function gcd ( a , b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } function getReducedForm ( dy , dx ) { let g = gcd ( Math . abs ( dy ) , Math . abs ( dx ) ) ; let sign = ( dy < 0 ) ^ ( dx < 0 ) ; if ( sign ) { return [ Math . floor ( - Math . abs ( dy ) / g ) , Math . floor ( Math . abs ( dx ) / g ) ] ; } else return [ Math . floor ( Math . abs ( dy ) / g ) , Math . floor ( Math . abs ( dx ) / g ) ] ; } function minLinesToCoverPoints ( points , N , x0 , y0 ) { let st = new Set ( ) ; let temp ; let minLines = 0 ; for ( let i = 0 ; i < N ; i ++ ) { let curX = points [ i ] [ 0 ] ; let curY = points [ i ] [ 1 ] ; temp = getReducedForm ( curY - yO , curX - xO ) ; if ( ! st . has ( temp . join ( " " ) ) ) { st . add ( temp . join ( " " ) ) ; minLines ++ ; } } return minLines ; } let xO , yO ; xO = 1 ; yO = 0 ; let points = [ [ - 1 , 3 ] , [ 4 , 3 ] , [ 2 , 1 ] , [ - 1 , - 2 ] , [ 3 , - 3 ] ] ; let N = points . length ; document . write ( minLinesToCoverPoints ( points , N , xO , yO ) )

Index/key variables: i
Accumulator variables: i, minLines
Iterator variables: i
Javascript program:
class Point { constructor ( a , b ) { this . x = a ; this . y = b ; } } function gcd ( a , b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } function getCount ( p , q ) { if ( p . x == q . x ) return Math . abs ( p . y - q . y ) - 1 ; if ( p . y == q . y ) return Math . abs ( p . x - q . x ) - 1 ; return gcd ( Math . abs ( p . x - q . x ) , Math . abs ( p . y - q . y ) ) - 1 ; } p = new Point ( 1 , 9 ) ; q = new Point ( 8 , 16 ) ; document . write ( " " + " " + p . x + " " + p . y + " " + q . x + " " + q . y + " " + getCount ( p , q ) ) ;

Class/struct names: Point
Javascript program:
function countDivisors ( n ) { var divisors = 0 ; var i ; for ( i = 1 ; i * i < n ; i ++ ) { if ( n % i == 0 ) { divisors ++ ; } } if ( i - ( n / i ) == 1 ) { i -- ; } for ( ; i >= 1 ; i -- ) { if ( n % i == 0 ) { divisors ++ ; } } return divisors ; } function possibleTriplets ( N ) { var count = 0 ; for ( var i = 1 ; i < N ; i ++ ) { count += countDivisors ( N - i ) ; } return count ; } var N = 10 ; document . write ( possibleTriplets ( N ) ) ;

Accumulator variables: count, divisors, i
Iterator variables: i
Javascript program:
function maxPlanes ( A , B ) { let St = new Set ( ) ; for ( let i = 0 ; i < A . length ; i ++ ) { let t = ( A [ i ] % B [ i ] > 0 ) ? 1 : 0 ; t += Math . floor ( A [ i ] / B [ i ] ) + t ; St . add ( t ) ; } return St . size ; } let A = [ 1 , 3 , 5 , 4 , 8 ] ; let B = [ 1 , 2 , 2 , 1 , 2 ] ; document . write ( maxPlanes ( A , B ) ) ;

Index/key variables: i
Accumulator variables: i, t
Iterator variables: i
Javascript program:
function maxRightmostElement ( N , k , p , arr ) { var ans = arr [ N - 1 ] ; for ( var i = N - 2 ; i >= 0 ; i -- ) { var d = Math . min ( arr [ i ] / p , k / ( N - 1 - i ) ) ; k -= d * ( N - 1 - i ) ; ans += d * p ; } return ans ; } var N = 4 , k = 3.5 , p = 2 ; var arr = [ 3 , 8 , 1 , 4 ] ; document . write ( maxRightmostElement ( N , k , p , arr ) ) ;

Index/key variables: i
Accumulator variables: ans, i, k
Iterator variables: i
Javascript program:
function isPossible ( arr , n ) { var mini = Number . MAX_VALUE ; for ( var i = 0 ; i < n ; i ++ ) mini = Math . min ( mini , arr [ i ] ) ; for ( var i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == mini ) continue ; var Max = ( arr [ i ] + 1 ) / 2 - 1 ; if ( mini < 0 mini > Max ) return " " ; } return " " ; } var arr = [ 1 , 1 , 3 , 4 ] ; var N = arr . length ; document . write ( isPossible ( arr , N ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function gcdOfTwoNos ( num1 , num2 ) { if ( num1 == 0 ) return num2 ; if ( num2 == 0 ) return num1 ; if ( num1 == num2 ) return num1 ; if ( num1 > num2 ) return gcdOfTwoNos ( num1 - num2 , num2 ) ; return gcdOfTwoNos ( num1 , num2 - num1 ) ; } function Min_sum ( arr , N ) { let min_sum = 1000000 , maxGcd = 1 ; for ( let i = 0 ; i < N ; i ++ ) { let gcd ; if ( i == 0 ) gcd = arr [ 1 ] ; else { gcd = arr [ i - 1 ] ; } for ( let j = 0 ; j < N ; j ++ ) { if ( j != i ) gcd = gcdOfTwoNos ( gcd , arr [ j ] ) ; } let c = arr [ i ] ; if ( gcd > maxGcd ) maxGcd = gcd ; } return maxGcd ; } let arr = [ 16 , 5 , 10 , 25 ] ; let N = arr . length ; document . write ( Min_sum ( arr , N ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function countOddIntegers ( arr , N ) { let Fact = new Array ( N ) ; Fact [ 0 ] = 1 ; for ( let i = 1 ; i < N ; i ++ ) { Fact [ i ] = i * Fact [ i - 1 ] ; } let freq = new Array ( 10 ) . fill ( 0 ) ; for ( let i = 0 ; i < N ; i ++ ) { freq [ arr [ i ] ] ++ ; } let ans = 0 ; for ( let i = 1 ; i <= 9 ; i += 2 ) { if ( ! freq [ i ] ) { continue ; } freq [ i ] -- ; for ( let j = 1 ; j <= 9 ; j ++ ) { let cur_ans = 0 ; if ( freq [ j ] == 0 ) { continue ; } freq [ j ] -- ; cur_ans = Fact [ N - 2 ] ; for ( let k = 0 ; k <= 9 ; k ++ ) { cur_ans = Math . floor ( cur_ans / Fact [ freq [ k ] ] ) ; } ans = ans + cur_ans ; freq [ j ] ++ ; } freq [ i ] ++ ; } return ans ; } let A = [ 2 , 3 , 4 , 1 , 2 , 3 ] ; let N = A . length ; document . write ( countOddIntegers ( A , N ) ) ;

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Javascript program:
function sumOfDigits ( N ) { let sum = 0 ; while ( N != 0 ) { sum = sum + ( N % 10 ) ; N = Math . floor ( N / 10 ) ; } return sum ; } function CountPair ( arr , n ) { let mp = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) { let val = arr [ i ] + sumOfDigits ( arr [ i ] ) ; if ( mp . has ( val ) ) { mp . set ( val , mp . get ( val ) + 1 ) ; } else { mp . set ( val , 1 ) ; } } let count = 0 ; for ( let [ key , value ] of mp ) { count = count + ( value * ( value - 1 ) ) / 2 ; } return count ; } let arr = [ 105 , 96 , 20 , 2 , 87 , 96 ] ; let N = arr . length ; document . write ( CountPair ( arr , N ) )

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function __gcd ( a , b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } function build_tree ( b , seg_tree , l , r , vertex ) { if ( l == r ) { seg_tree [ vertex ] = b [ l ] ; return ; } let mid = Math . floor ( ( l + r ) / 2 ) ; build_tree ( b , seg_tree , l , mid , 2 * vertex ) ; build_tree ( b , seg_tree , mid + 1 , r , 2 * vertex + 1 ) ; seg_tree [ vertex ] = __gcd ( seg_tree [ 2 * vertex ] , seg_tree [ 2 * vertex + 1 ] ) ; } function range_gcd ( seg_tree , v , tl , tr , l , r ) { if ( l > r ) return 0 ; if ( l == tl && r == tr ) return seg_tree [ v ] ; let tm = Math . floor ( ( tl + tr ) / 2 ) ; return __gcd ( range_gcd ( seg_tree , 2 * v , tl , tm , l , Math . min ( tm , r ) ) , range_gcd ( seg_tree , 2 * v + 1 , tm + 1 , tr , Math . max ( tm + 1 , l ) , r ) ) ; } function maxSubarrayLen ( arr , n ) { let seg_tree = new Array ( 4 * n + 1 ) . fill ( 0 ) ; build_tree ( arr , seg_tree , 0 , n - 1 , 1 ) ; let maxLen = 0 ; let l = 0 , r = 0 ; while ( r < n && l < n ) { if ( range_gcd ( seg_tree , 1 , 0 , n - 1 , l , r ) == 1 ) { l ++ ; } maxLen = Math . max ( maxLen , r - l + 1 ) ; r ++ ; } document . write ( maxLen ) ; } let arr = [ 410 , 52 , 51 , 180 , 222 , 33 , 33 ] ; let N = arr . length ; maxSubarrayLen ( arr , N ) ;

Index/key variables: l, v, vertex
Accumulator variables: l, r
Javascript program:
function findValuesOfK ( g ) { var count = 0 ; for ( var i = 1 ; i * i <= g ; i ++ ) { if ( g % i == 0 ) { if ( i != g / i ) { if ( i % 2 == 1 ) { count ++ ; } if ( ( g / i ) % 2 == 1 ) { count ++ ; } } else if ( i % 2 == 1 ) { count ++ ; } } } document . write ( count ) ; } var G = 125 ; findValuesOfK ( G ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function Avgdifference ( arr , N , K ) { let sum = 0 ; for ( let i = 0 ; i < K ; i ++ ) sum += arr [ i ] ; let min = sum ; let max = sum ; for ( let i = K ; i <= N - K + 1 ; i ++ ) { sum += arr [ i ] - arr [ i - K ] ; if ( min > sum ) min = sum ; if ( max < sum ) max = sum ; } return ( max - min ) / K ; } let arr = [ 3 , 8 , 9 , 15 ] ; let N = arr . length ; let K = 2 ; document . write ( Avgdifference ( arr , N , K ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function findSet ( N , K ) { let a = [ ] ; for ( let i = 1 ; i <= N ; i ++ ) { if ( i != K ) a . push ( i ) ; } let MaxDistinct = ( N - K ) + parseInt ( K / 2 ) ; a . reverse ( ) ; for ( let i = 0 ; i < MaxDistinct ; i ++ ) document . write ( a [ i ] + " " ) ; } let N = 5 , K = 3 ; findSet ( N , K ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function ExtendedEuclidAlgo ( a , b ) { if ( a == 0 ) { return [ b , 0 , 1 ] ; } else { let x1 = 1 , y1 = 1 ; let gcdy = ExtendedEuclidAlgo ( b % a , a ) ; let gcd = gcdy [ 0 ] ; x1 = gcdy [ 1 ] ; y1 = gcdy [ 2 ] ; let y = x1 ; let x = y1 - Math . floor ( b / a ) * x1 ; return [ gcd , x , y ] ; } } function linearCongruence ( A , B , N ) { A = A % N ; B = B % N ; let u = 0 , v = 0 ; let person = ExtendedEuclidAlgo ( A , N ) ; let d = person [ 0 ] ; u = person [ 1 ] ; v = person [ 2 ] ; if ( B % d != 0 ) { document . write ( - 1 ) ; return ; } let x0 = ( u * ( B / d ) ) % N ; if ( x0 < 0 ) x0 += N ; for ( let i = 0 ; i <= d - 1 ; i ++ ) { let an = ( x0 + i * ( N / d ) ) % N ; document . write ( an + " " ) ; } } let A = 15 ; let B = 9 ; let N = 18 ; linearCongruence ( A , B , N ) ;

Accumulator variables: i, x0
Iterator variables: i
Javascript program:
function factorialWithoutMul ( N ) { let ans = N ; for ( let i = N - 1 ; i > 0 ; i -- ) { let sum = 0 ; for ( let j = 0 ; j < i ; j ++ ) sum += ans ; ans = sum ; } return ans ; } let N = 5 ; document . write ( factorialWithoutMul ( N ) ) ;

Accumulator variables: i, j, sum
Iterator variables: i, j
Javascript program:
function tripletAndSum ( arr , n ) { let ans = 0 ; for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { for ( let k = j + 1 ; k < n ; k ++ ) { ans += arr [ i ] & arr [ j ] & arr [ k ] ; } } } document . write ( ans ) ; } let arr = [ 3 , 5 , 4 , 7 ] ; let N = arr . length tripletAndSum ( arr , N ) ;

Index/key variables: i, j, k
Accumulator variables: ans, i, j, k
Iterator variables: i, j, k
Javascript program:
function tripletAndSum ( arr , n ) { let ans = 0 ; for ( let bit = 0 ; bit < 32 ; bit ++ ) { let cnt = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( arr [ i ] & ( 1 << bit ) ) cnt ++ ; } ans += ( 1 << bit ) * cnt * ( cnt - 1 ) * ( cnt - 2 ) / 6 ; } return ans ; } let arr = [ 3 , 5 , 4 , 7 ] ; let N = arr . length ; document . write ( tripletAndSum ( arr , N ) ) ;

Index/key variables: i
Accumulator variables: ans, bit, cnt, i
Iterator variables: bit, i
Javascript program:
function smallestPermutation ( arr , N ) { let w = new Array ( 2 * N + 1 ) ; for ( let i = 0 ; i < N ; i ++ ) { w [ arr [ i ] ] = true ; } let S = new Set ( ) ; for ( let i = 1 ; i <= 2 * N ; i ++ ) { if ( ! w [ i ] ) S . add ( i ) ; } let found = true ; let P = [ ] ; let p = [ 4 , 5 , 1 , 2 , 3 , 6 ] ; for ( let i = 0 ; i < N ; i ++ ) { if ( S . has ( arr [ i ] ) ) { found = false ; break ; } P . push ( arr [ i ] ) ; P . push ( arr [ i ] ) ; S . delete ( arr [ i ] ) ; } if ( ! found ) { document . write ( " " ) ; } else { for ( let i = 0 ; i < 2 * N ; i ++ ) document . write ( p [ i ] + " " ) ; } } let arr = [ 4 , 1 , 3 ] ; let N = arr . length ; smallestPermutation ( arr , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: found
Javascript program:
function maximumSubsequenceSum ( A , N ) { var ans = 0 ; var mp = new Map ( ) ; var i ; for ( i = 0 ; i < N ; i ++ ) { if ( mp . has ( A [ i ] - i ) ) mp . set ( A [ i ] - i , mp . get ( A [ i ] - i ) + A [ i ] ) ; else mp . set ( A [ i ] - i , A [ i ] ) ; ans = Math . max ( ans , mp . get ( A [ i ] - i ) ) ; } document . write ( ans ) ; } var A = [ 10 , 7 , 1 , 9 , 10 , 1 ] ; var N = A . length ; maximumSubsequenceSum ( A , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function nearestPerfectSquare ( arr , N ) { for ( let i = 0 ; i < N ; i ++ ) { let sr = parseInt ( Math . sqrt ( arr [ i ] ) ) ; let a = sr * sr ; let b = ( sr + 1 ) * ( sr + 1 ) ; if ( ( arr [ i ] - a ) < ( b - arr [ i ] ) ) document . write ( a + " " ) ; else document . write ( b + " " ) ; } } let arr = [ 5 , 2 , 7 , 13 ] ; let N = arr . length ; nearestPerfectSquare ( arr , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let prime = new Array ( 100001 ) ; function SieveOfEratosthenes ( n ) { for ( let i = 0 ; i < prime . length ; i ++ ) { prime [ i ] = true ; } for ( let p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( let i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } } function NumberofSets ( N ) { SieveOfEratosthenes ( N ) ; if ( N == 2 ) { document . write ( 1 ) ; } else if ( N == 3 ) { document . write ( 2 ) ; } else { let ans = 1 ; for ( let i = Math . floor ( N / 2 ) + 1 ; i <= N ; i ++ ) { if ( prime [ i ] ) { ans += 1 ; } } document . write ( ans ) ; } } let N = 9 ; NumberofSets ( N ) ;

Index/key variables: i, p
Accumulator variables: ans, i, p
Iterator variables: i, p
Javascript program:
function floorDifference ( A , N , X ) { let totalSum = 0 ; let perElementSum = 0 ; for ( let i = 0 ; i < N ; i ++ ) { totalSum += A [ i ] ; perElementSum += Math . floor ( A [ i ] / X ) ; } let totalFloorSum = Math . floor ( totalSum / X ) ; return Math . abs ( totalFloorSum - perElementSum ) ; } let A = [ 1 , 2 , 3 , 4 , 5 , 6 ] ; let X = 4 ; let N = A . length ; document . write ( floorDifference ( A , N , X ) ) ;

Index/key variables: i
Accumulator variables: i, perElementSum, totalSum
Iterator variables: i
Javascript program:
function val ( c ) { if ( c >= ' ' && c <= ' ' ) return c . charCodeAt ( 0 ) - 48 ; else return c . charCodeAt ( 0 ) - 65 + 10 ; } function toDeci ( str , base ) { var len = str . length ; var power = 1 ; var num = 0 ; for ( var i = len - 1 ; i >= 0 ; i -- ) { if ( val ( str [ i ] ) >= base ) { document . write ( " " ) ; return - 1 ; } num += val ( str [ i ] ) * power ; power = power * base ; } return num ; } function reVal ( num ) { if ( num >= 0 && num <= 9 ) return String . fromCharCode ( num + 48 ) ; else return String . fromCharCode ( num - 10 + 65 ) ; } function fromDeci ( base , inputNum ) { var res = " " ; while ( inputNum > 0 ) { res += reVal ( inputNum % base ) ; inputNum = Math . floor ( inputNum / base ) ; } res = res . split ( " " ) . reverse ( ) . join ( " " ) ; return res ; } function convertBase ( s , a , b ) { var num = toDeci ( s , a ) ; var ans = fromDeci ( b , num ) ; document . write ( ans ) ; } var s = " " ; var a = 16 var b = 10 ; convertBase ( s , a , b ) ;

Index/key variables: i
Accumulator variables: i, num, res
Iterator variables: i
Javascript program:
function fact ( N ) { if ( N == 1 N == 0 ) return 1 ; return N * fact ( N - 1 ) ; } function prefixFactorialArray ( arr , N ) { for ( let i = 1 ; i < N ; i ++ ) { arr [ i ] += arr [ i - 1 ] ; } for ( let i = 0 ; i < N ; i ++ ) { arr [ i ] = fact ( arr [ i ] ) ; } for ( let i = 0 ; i < N ; i ++ ) { document . write ( arr [ i ] + " " ) ; } } let arr = [ 1 , 2 , 3 , 4 ] ; let N = arr . length ; prefixFactorialArray ( arr , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function removeEveryKth ( l , k ) { for ( let i = 0 ; i < l . length ; i ++ ) { if ( i % k == 0 ) l [ i ] = 0 ; } let arr = [ 0 ] ; for ( let i = 1 ; i < l . length ; i ++ ) { if ( l [ i ] != 0 ) arr . push ( l [ i ] ) ; } return arr ; } function printArray ( l ) { for ( let i = 1 ; i < l . length ; i ++ ) document . write ( l [ i ] + " " ) ; } function printSequence ( n , k ) { let l = [ 0 ] ; for ( let i = 0 ; i < n + 1 ; i ++ ) l [ i ] = i ; let x = 1 ; for ( let i = 0 ; i < k ; i ++ ) { let p = l [ x ] + l [ x + 1 ] ; l = removeEveryKth ( l , p ) ; x += 1 ; } printArray ( l ) ; } let N = 8 ; let K = 2 ; printSequence ( N , K ) ;

Index/key variables: i, x
Accumulator variables: i, x
Iterator variables: i
Javascript program:
function makeEqual ( arr , n ) { var fre0 = Array ( 33 ) . fill ( 0 ) ; var fre1 = Array ( 33 ) . fill ( 0 ) ; for ( i = 0 ; i < n ; i ++ ) { var x = arr [ i ] ; for ( j = 0 ; j < 33 ; j ++ ) { if ( ( x & 1 ) != 0 ) { fre1 [ j ] += 1 ; } else { fre0 [ j ] += 1 ; } x = x >> 1 ; } } var ans = 0 ; for ( i = 0 ; i < 33 ; i ++ ) { ans += Math . min ( fre0 [ i ] , fre1 [ i ] ) ; } return ans ; } var arr = [ 3 , 5 ] ; var N = arr . length ; document . write ( makeEqual ( arr , N ) ) ;

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Javascript program:
function sum ( arr , N , K ) { var sum = 0 ; var v = [ ] ; for ( var i = 0 ; i < N ; i ++ ) { v . push ( arr [ i ] ) ; } for ( var i = 0 ; i < v . length ; i ++ ) { if ( v [ i ] % K == 0 ) { var x = v [ i ] / K ; for ( var j = 0 ; j < K ; j ++ ) { v . push ( x ) ; } } else break ; } for ( var i = 0 ; i < v . length ; i ++ ) sum = sum + v [ i ] ; return sum ; } var arr = [ 4 , 6 , 8 , 2 ] ; var K = 2 ; var N = arr . length ; document . write ( sum ( arr , N , K ) ) ;

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function check ( arr , N ) { var sum = 0 ; for ( i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; if ( sum == 0 ) document . write ( " " ) ; else document . write ( " " ) ; } var arr = [ 1 , - 1 , 3 , - 2 , - 1 ] ; var N = arr . length ; check ( arr , N ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function startingPoint ( A , N ) { var sum = 0 ; var it = 0 ; var min = Number . MAX_VALUE ; for ( i = 0 ; i < N ; i ++ ) { sum += A [ i ] ; if ( sum < min ) { min = sum ; it = i + 1 ; } } if ( sum < 0 ) { return - 1 ; } return it % N ; } var arr = [ 3 , - 6 , 7 , - 4 , - 4 , 6 , - 1 ] ; var N = arr . length ; document . write ( startingPoint ( arr , N ) ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
class node { constructor ( ) { this . data = 0 ; this . next = null ; } } ; function EvalNearestMult ( N , K ) { var temp = N ; var t ; while ( N != null ) { if ( N . data < K ) N . data = 0 ; else { if ( N . data == K ) N . data = K ; else { N . data = parseInt ( N . data / K ) * K ; } } N = N . next ; } return temp ; } function printList ( N ) { while ( N != null ) { document . write ( N . data + " " ) ; N = N . next ; } } var head = null ; var second = null ; var third = null ; head = new node ( ) ; second = new node ( ) ; third = new node ( ) ; head . data = 3 ; head . next = second ; second . data = 4 ; second . next = third ; third . data = 8 ; third . next = null ; var t = EvalNearestMult ( head , 3 ) ; printList ( t ) ;

Class/struct names: node
Javascript program:
function nearestPow ( x , y ) { if ( y == 1 ) return 1 var k = Math . floor ( Math . log ( x ) / Math . log ( y ) ) if ( Math . abs ( Math . pow ( y , k ) - x ) < Math . abs ( Math . pow ( y , ( k + 1 ) ) - x ) ) return Math . pow ( y , k ) return Math . pow ( y , ( k + 1 ) ) } function replacebyNearestPower ( arr ) { var prev = arr [ arr . length - 1 ] var lastNext = arr [ 0 ] for ( var i = 0 ; i < arr . length ; i ++ ) { var temp = arr [ i ] if ( i == arr . length - 1 ) var next = lastNext else var next = arr [ ( i + 1 ) % arr . length ] var prevPow = nearestPow ( arr [ i ] , prev ) var nextPow = nearestPow ( arr [ i ] , next ) if ( Math . abs ( arr [ i ] - prevPow ) < Math . abs ( arr [ i ] - nextPow ) ) arr [ i ] = prevPow else arr [ i ] = nextPow prev = temp } document . write ( arr ) } var arr = [ 2 , 3 , 4 , 1 , 2 ] replacebyNearestPower ( arr )

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function makeSumX ( arr , X , S , i , N ) { if ( i === N ) { return S === X } let a = ( arr [ i ] ) . toString ( ) let l = parseInt ( ( a . substr ( 0 , a . length - 1 ) ) ) let r = parseInt ( ( a . substr ( 1 ) ) ) let x = makeSumX ( arr , X , S + l , i + 1 , N ) ; let y = makeSumX ( arr , X , S + r , i + 1 , N ) ; return ( x y ) ; } function Check ( arr , X , N ) { if ( makeSumX ( arr , X , 0 , 0 , N ) ) { document . write ( " " ) } else { document . write ( " " ) } } let arr = [ 545 , 433 , 654 , 23 ] ; let N = arr . length ; let X = 134 ; Check ( arr , X , N ) ;

Index/key variables: i