dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function countFrequency ( S , N ) { var freq = new Array ( 26 ) . fill ( 0 ) ; for ( var i = 0 ; i < N ; i ++ ) { freq [ S [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] ++ ; } for ( var i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] === 0 ) continue ; var lg = parseInt ( Math . log2 ( freq [ i ] ) ) ; var a = Math . pow ( 2 , lg ) ; if ( a === freq [ i ] ) { while ( freq [ i ] -- ) document . write ( String . fromCharCode ( i + " " . charCodeAt ( 0 ) ) ) ; } } } var S = " " ; var N = S . length ; countFrequency ( S , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
class treeNode { constructor ( square_sum ) { this . square_sum = square_sum ; } } function buildTree ( s , tree , start , end , treenode ) { if ( start == end ) { tree [ treenode ] . square_sum = Math . pow ( s [ start ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + 1 , 2 ) ; return ; } let mid = start + Math . floor ( ( end - start ) / 2 ) ; buildTree ( s , tree , start , mid , 2 * treenode ) ; buildTree ( s , tree , mid + 1 , end , 1 + 2 * treenode ) ; tree [ treenode ] . square_sum = tree [ ( 2 * treenode ) ] . square_sum + tree [ ( 2 * treenode ) + 1 ] . square_sum ; } function querySquareSum ( tree , start , end , treenode , l , r ) { if ( ( l > end ) || ( r < start ) ) { return 0 ; } if ( ( l <= start ) && ( r >= end ) ) { return tree [ treenode ] . square_sum ; } let mid = start + Math . floor ( ( end - start ) / 2 ) ; let X = querySquareSum ( tree , start , mid , 2 * treenode , l , r ) ; let Y = + querySquareSum ( tree , mid + 1 , end , 1 + 2 * treenode , l , r ) ; return X + Y ; } function updateTree ( s , tree , start , end , treenode , idx , X ) { if ( ( start == end ) && ( idx == start ) ) { s [ idx ] = X ; tree [ treenode ] . square_sum = Math . pow ( X . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + 1 , 2 ) ; return ; } let mid = start + Math . floor ( ( end - start ) / 2 ) ; if ( idx <= mid ) { updateTree ( s , tree , start , mid , ( 2 * treenode ) , idx , X ) ; } else { updateTree ( s , tree , mid + 1 , end , ( 2 * treenode ) + 1 , idx , X ) ; } tree [ treenode ] . square_sum = tree [ ( 2 * treenode ) ] . square_sum + tree [ ( 2 * treenode ) + 1 ] . square_sum ; } function PerformQuery ( S , Q ) { let n = S . length ; let tree = new Array ( ( 4 * n ) + 1 ) ; for ( let i = 0 ; i <= ( 4 * n ) ; i = i + 1 ) { tree [ i ] = new treeNode ( 0 ) ; } let s = S . split ( " " ) ; buildTree ( s , tree , 0 , n - 1 , 1 ) ; for ( let i = 0 ; i < Q . length ; i ++ ) { if ( Q [ i ] [ 0 ] == " " ) { let L = parseInt ( Q [ i ] [ 1 ] ) ; let R = parseInt ( Q [ i ] [ 2 ] ) ; document . write ( querySquareSum ( tree , 0 , n - 1 , 1 , L , R ) + " " ) ; } else if ( Q [ i ] [ 0 ] == " " ) { let I = parseInt ( Q [ i ] [ 1 ] ) ; updateTree ( s , tree , 0 , n - 1 , 1 , I , Q [ i ] [ 2 ] [ 0 ] ) ; } } } let S = " " ; let Q = [ [ " " , " " , " " ] , [ " " , " " , " " ] , [ " " , " " , " " ] , [ " " , " " , " " ] , [ " " , " " , " " ] ] PerformQuery ( S , Q ) ;

Index/key variables: i, idx, start, treenode
Accumulator variables: i
Iterator variables: i
Class/struct names: treeNode
Javascript program:
function maximumLengthSubsequence ( str ) { var mp = { } ; var temp = str . split ( " " ) ; for ( const ch of temp ) { if ( mp . hasOwnProperty ( ch ) ) mp [ ch ] = mp [ ch ] + 1 ; else mp [ ch ] = 1 ; } var ans = 0 ; for ( const ch of temp ) { if ( mp . hasOwnProperty ( String . fromCharCode ( ch . charCodeAt ( 0 ) - 1 ) ) ) { var curr_max = mp [ ch ] + mp [ String . fromCharCode ( ch . charCodeAt ( 0 ) - 1 ) ] ; ans = Math . max ( ans , curr_max ) ; } } document . write ( ans ) ; } var S = " " ; maximumLengthSubsequence ( S ) ;

Index/key variables: ch
Iterator variables: ch
Javascript program:
function countOperations ( X , Y , K ) { var count = 0 ; for ( var i = 0 ; i < X . length ; i ++ ) { var c = 0 ; if ( X [ i ] === Y [ i ] ) continue ; else if ( X [ i ] . charCodeAt ( 0 ) < Y [ i ] . charCodeAt ( 0 ) ) { if ( Y [ i ] . charCodeAt ( 0 ) - X [ i ] . charCodeAt ( 0 ) >= K ) { c = ( Y [ i ] . charCodeAt ( 0 ) - X [ i ] . charCodeAt ( 0 ) ) / K ; } c += ( Y [ i ] . charCodeAt ( 0 ) - X [ i ] . charCodeAt ( 0 ) ) % K ; } else { var t = 90 - X [ i ] . charCodeAt ( 0 ) ; t += Y [ i ] . charCodeAt ( 0 ) - 65 + 1 ; if ( t >= K ) { c = parseInt ( t / K ) ; } c += parseInt ( t % K ) ; } count = parseInt ( count + c ) ; } document . write ( count + " " ) ; } var X = " " , Y = " " ; var K = 6 ; countOperations ( X , Y , K ) ;

Index/key variables: i
Accumulator variables: c, i, t
Iterator variables: i
Javascript program:
function minimumSwaps ( s , l , r , k ) { var n = s . length ; var tot_ones = 0 , tot_zeros = 0 ; for ( i = 0 ; i < s . length ; i ++ ) { if ( s . charAt ( i ) == ' ' ) tot_ones ++ ; else tot_zeros ++ ; } var ones = 0 , zeros = 0 , sum = 0 ; for ( var i = l - 1 ; i < r ; i ++ ) { if ( s . charAt ( i ) == ' ' ) { ones ++ ; sum ++ ; } else zeros ++ ; } var rem_ones = tot_ones - ones ; var rem_zeros = tot_zeros - zeros ; if ( k >= sum ) { var rem = k - sum ; if ( zeros >= rem && rem_ones >= rem ) return rem ; } else if ( k < sum ) { var rem = sum - k ; if ( ones >= rem && rem_zeros >= rem ) return rem ; } return - 1 ; } var S = " " ; var L = 5 , R = 8 , K = 2 ; document . write ( minimumSwaps ( S , L , R , K ) ) ;

Accumulator variables: i, ones, sum, tot_ones, tot_zeros, zeros
Iterator variables: i
Javascript program:
var N = 200000 ; var Ans = Array . from ( { length : N } , ( _ , i ) => 0 ) ; var index = 0 ; function populateNumber ( ) { Ans [ index ++ ] = ( 2 ) ; Ans [ index ++ ] = ( 5 ) ; var x = 5 ; var inf = 1000000000001 ; while ( x < inf ) { x *= 2 ; Ans [ index ++ ] = ( x ) ; x = x * 2 + 1 ; Ans [ index ++ ] = ( x ) ; } } function checkString ( N ) { populateNumber ( ) ; for ( i = 0 ; i < index ; i ++ ) { if ( Ans [ i ] == N ) { document . write ( " " ) ; return ; } } document . write ( " " ) ; } N = 5 ; checkString ( N ) ;

Index/key variables: i
Accumulator variables: i, index, x
Iterator variables: i
Javascript program:
function deleteSubseq ( s ) { var N = s . length ; var roundStk = [ ] ; var squareStk = [ ] ; var roundCount = 0 ; var squareCount = 0 ; for ( var i = 0 ; i < N ; i ++ ) { if ( s [ i ] == ' ' ) { squareStk . push ( s [ i ] ) ; } else if ( s [ i ] == ' ' ) { if ( squareStk . length != 0 && squareStk [ squareStk . length - 1 ] == ' ' ) { squareStk . pop ( ) ; squareCount += 1 ; } } else if ( s [ i ] == ' ' ) { roundStk . push ( s [ i ] ) ; } else { if ( roundStk . length != 0 && squareStk [ squareStk . length - 1 ] == ' ' ) { squareStk . pop ( ) ; roundCount += 1 ; } } } document . write ( N - ( 2 * squareCount + 2 * roundCount ) ) ; } var s = " " ; deleteSubseq ( s ) ;

Index/key variables: i
Accumulator variables: i, roundCount, squareCount
Iterator variables: i
Javascript program:
function minimumOperations ( s , n ) { var mp = { } ; for ( var i = 0 ; i < n ; i ++ ) { if ( mp . hasOwnProperty ( s [ i ] ) ) { mp [ s [ i ] ] . push ( i ) ; } else { mp [ s [ i ] ] = [ ] ; mp [ s [ i ] ] . push ( i ) ; } } var ans = 2147483647 ; for ( const [ key , value ] of Object . entries ( mp ) ) { var curr = 0 ; var prev = 0 ; var first = true ; for ( const index of value ) { if ( first ) { if ( index > 0 ) { curr ++ ; } prev = index ; first = false ; } else { if ( index !== prev + 1 ) { curr ++ ; } prev = index ; } } if ( prev !== n - 1 ) { curr ++ ; } ans = Math . min ( ans , curr ) ; } document . write ( ans ) ; } var s = " " ; var N = s . length ; minimumOperations ( s , N ) ;

Index/key variables: i
Accumulator variables: curr, i
Iterator variables: i, index
Boolean variables: first
Javascript program:
function checkValidDFA ( s ) { var final_state = 0 ; var previous_state = 0 ; for ( var i = 0 ; i < s . length ; i ++ ) { if ( ( s [ i ] === " " && previous_state === 0 ) || ( s [ i ] === " " && previous_state === 3 ) ) { final_state = 1 ; } else if ( ( s [ i ] === " " && previous_state === 3 ) || ( s [ i ] === " " && previous_state === 0 ) ) { final_state = 2 ; } else if ( ( s [ i ] === " " && previous_state === 1 ) || ( s [ i ] === " " && previous_state === 2 ) ) { final_state = 0 ; } else if ( ( s [ i ] === " " && previous_state === 2 ) || ( s [ i ] === " " && previous_state === 1 ) ) { final_state = 3 ; } previous_state = final_state ; } if ( final_state === 3 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } var s = " " ; checkValidDFA ( s ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
const findRoot = ( nodeList ) => { let root = 0 ; nodeList . forEach ( element => root += ( Number ( element [ 0 ] ) - Number ( element [ 1 ] ) ) ) ; return root ; } let nodeList = [ [ 1 , 5 ] , [ 2 , 0 ] , [ 3 , 0 ] , [ 4 , 0 ] , [ 5 , 5 ] , [ 6 , 5 ] ] ; let root = findRoot ( nodeList ) ; document . write ( root ) ;

Accumulator variables: root
Javascript program:
class Node { constructor ( item ) { this . key = item ; this . left = this . right = null ; } }

Class/struct names: Node
Javascript program:
class Node { constructor ( key ) { this . key = key ; this . left = this . right = null ; } } class Res { constructor ( ) { this . r = Number . MIN_VALUE ; } } var root ; function maxDiffUtil ( t , res ) { if ( t == null ) return Number . MAX_VALUE ; if ( t . left == null && t . right == null ) return t . key ; var val = Math . min ( maxDiffUtil ( t . left , res ) , maxDiffUtil ( t . right , res ) ) ; res . r = Math . max ( res . r , t . key - val ) ; return Math . min ( val , t . key ) ; } function maxDiff ( root ) { res = new Res ( ) ; maxDiffUtil ( root , res ) ; return res . r ; } function inorder ( root ) { if ( root != null ) { inorder ( root . left ) ; document . write ( root . key + " " ) ; inorder ( root . right ) ; } } root = new Node ( 8 ) ; root . left = new Node ( 3 ) ; root . left . left = new Node ( 1 ) ; root . left . right = new Node ( 6 ) ; root . left . right . left = new Node ( 4 ) ; root . left . right . right = new Node ( 7 ) ; root . right = new Node ( 10 ) ; root . right . right = new Node ( 14 ) ; root . right . right . left = new Node ( 13 ) ; document . write ( " " + " " + maxDiff ( root ) ) ;

Class/struct names: Node, Res
Javascript program:
let preIndex = 0 ; function printPost ( In , pre , inStrt , inEnd , hm ) { if ( inStrt > inEnd ) return ; let inIndex = hm . get ( pre [ preIndex ++ ] ) ; printPost ( In , pre , inStrt , inIndex - 1 , hm ) ; printPost ( In , pre , inIndex + 1 , inEnd , hm ) ; document . write ( In [ inIndex ] + " " ) ; } function printPostMain ( In , pre ) { let n = pre . length ; let hm = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) hm . set ( In [ i ] , i ) ; printPost ( In , pre , 0 , n - 1 , hm ) ; } let In = [ 4 , 2 , 5 , 1 , 3 , 6 ] ; let pre = [ 1 , 2 , 4 , 5 , 3 , 6 ] ; printPostMain ( In , pre ) ;

Index/key variables: i, inIndex
Accumulator variables: i, preIndex
Iterator variables: i
Javascript program:
function issafe ( m , n , i , j ) { if ( i < 0 ) return false ; if ( j < 0 ) return false ; if ( i >= m ) return false ; if ( j >= n ) return false ; return true ; } function endpoints ( arr , m , n ) { let i = 0 ; let j = 0 ; let current_i = 0 ; let current_j = 0 ; let current_d = ' ' ; let rcd = new Map ( ) ; rcd . set ( ' ' , ' ' ) ; rcd . set ( ' ' , ' ' ) ; rcd . set ( ' ' , ' ' ) ; rcd . set ( ' ' , ' ' ) ; while ( issafe ( m , n , i , j ) ) { current_i = i ; current_j = j ; if ( arr [ i ] [ j ] == 1 ) { let move_in = rcd . get ( current_d ) ; arr [ i ] [ j ] = 0 ; if ( move_in == ' ' ) i -= 1 ; else if ( move_in == ' ' ) i += 1 ; else if ( move_in == ' ' ) j -= 1 ; else if ( move_in == ' ' ) j += 1 ; current_d = move_in ; } else { if ( current_d == ' ' ) i -= 1 ; else if ( current_d == ' ' ) i += 1 ; else if ( current_d == ' ' ) j -= 1 ; else if ( current_d == ' ' ) j += 1 ; } } return [ current_i , current_j ] ; } let M = 3 ; let N = 5 ; let arr = [ [ 0 , 1 , 1 , 1 , 0 ] , [ 1 , 0 , 1 , 0 , 1 ] , [ 1 , 1 , 1 , 0 , 0 ] ] ; let p = endpoints ( arr , M , N ) ; document . write ( " " + p [ 0 ] + " " + p [ 1 ] + " " + " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Javascript program:
function sumOfTwoPerfectCubes ( N ) { var cubes = new Map ( ) ; for ( var i = 1 ; i * i * i <= N ; i ++ ) cubes . set ( i * i * i , i ) ; var ans = false ; cubes . forEach ( ( value , key ) => { var firstNumber = key ; var secondNumber = N - value ; if ( cubes . has ( secondNumber ) ) { document . write ( " " ) ; ans = true ; return ; } } ) ; if ( ans ) { return ; } document . write ( " " ) ; } var N = 28 ; sumOfTwoPerfectCubes ( N ) ;

Accumulator variables: i
Iterator variables: i
Boolean variables: ans
Javascript program:
let mod = 1000000007 ; function countSets ( arr , n ) { let cnt = 0 ; let maxE = - 1 ; for ( let i = 0 ; i < n ; i ++ ) { if ( maxE < arr [ i ] ) maxE = arr [ i ] ; } let sieve = new Array ( maxE + 1 ) ; for ( let i = 0 ; i < maxE + 1 ; i ++ ) { sieve [ i ] = 0 ; } for ( let i = 0 ; i < n ; i ++ ) sieve [ arr [ i ] ] = 1 ; for ( let i = 1 ; i <= maxE ; i ++ ) { if ( sieve [ i ] != 0 ) { for ( let j = i * 2 ; j <= maxE ; j += i ) { if ( sieve [ j ] != 0 ) sieve [ j ] = ( sieve [ j ] + sieve [ i ] ) % mod ; } } } for ( let i = 0 ; i <= maxE ; i ++ ) cnt = ( cnt % mod + sieve [ i ] % mod ) % mod ; document . write ( cnt % mod + " " ) ; } let arr = [ 16 , 18 , 6 , 7 , 2 , 19 , 20 , 9 ] ; let N = arr . length ; countSets ( arr , N ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
let MAX = 100001 ; let spf ; let v ; function sieve ( ) { for ( let i = 1 ; i < MAX ; i ++ ) spf [ i ] = i ; for ( let i = 4 ; i < MAX ; i = i + 2 ) spf [ i ] = 2 ; for ( let i = 3 ; i * i < MAX ; i ++ ) if ( spf [ i ] == i ) { for ( let j = i * i ; j < MAX ; j = j + i ) { if ( spf [ j ] == j ) spf [ j ] = i ; } } } function DistPrime ( ) { for ( let i = 1 ; i < MAX ; i ++ ) { let idx = 1 ; let x = i ; if ( x != 1 ) v [ i ] . push ( spf [ x ] ) ; x = parseInt ( x / spf [ x ] , 10 ) ; while ( x != 1 ) { if ( v [ i ] [ idx - 1 ] != spf [ x ] ) { v [ i ] . push ( spf [ x ] ) ; idx += 1 ; } x = parseInt ( x / spf [ x ] , 10 ) ; } } } function getFactorCount ( arr , N ) { spf = new Array ( MAX ) ; v = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) v [ i ] = [ ] ; sieve ( ) ; DistPrime ( ) ; for ( let i = 0 ; i < N ; i ++ ) { document . write ( v [ arr [ i ] ] . length + " " ) ; } } let arr = [ 6 , 9 , 12 ] ; let N = arr . length ; getFactorCount ( arr , N ) ;

Index/key variables: i, j, x
Accumulator variables: i, idx
Iterator variables: i, j
Javascript program:
function prletArray ( arr , N ) { for ( let i = 0 ; i < N ; i ++ ) { document . write ( arr [ i ] + " " ) ; } } function modifyArray ( arr , N , Q , cntQuery ) { let arr1 = new Array ( N + 2 ) . fill ( 0 ) ; let arr2 = new Array ( N + 2 ) . fill ( 0 ) ; for ( let i = 0 ; i < cntQuery ; i ++ ) { let L = Q [ i ] [ 0 ] + 1 , R = Q [ i ] [ 1 ] + 1 ; arr1 [ L ] ++ ; arr1 [ R + 1 ] -- ; arr2 [ R + 1 ] -= R - L + 1 ; } for ( let i = 1 ; i <= N ; i ++ ) arr1 [ i ] += arr1 [ i - 1 ] ; for ( let i = 1 ; i <= N ; i ++ ) arr2 [ i ] += arr2 [ i - 1 ] + arr1 [ i ] ; for ( let i = 1 ; i <= N ; i ++ ) arr [ i - 1 ] = arr2 [ i ] ; prletArray ( arr , N ) ; } let arr = [ 0 , 0 , 0 , 0 ] ; let N = arr . length ; let Q = [ [ 1 , 3 ] , [ 0 , 1 ] ] ; let cntQuery = Q . length ; modifyArray ( arr , N , Q , cntQuery ) ;

Index/key variables: L, i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findProduct ( number_1 , number_2 ) { if ( number_1 == Number . MIN_VALUE number_2 == Number . MIN_VALUE ) { return 0 ; } else return number_1 * number_2 ; } function calculateProduct ( List , index ) { let highest = Math . max ( ... List [ index ] ) ; let lowest = Math . min ( ... List [ index ] ) ; if ( index + 1 == List . length ) { if ( lowest < 0 && highest >= 0 ) { return ( [ highest , lowest ] ) ; } else if ( lowest <= 0 && highest <= 0 ) { return ( [ Number . MIN_VALUE , lowest ] ) ; } else if ( lowest >= 0 && highest >= 0 ) { return ( [ highest , Number . MIN_VALUE ] ) ; } } let temp = calculateProduct ( List , index + 1 ) ; let positive = temp [ 0 ] ; let negative = temp [ 1 ] ; let highPos = findProduct ( highest , positive ) ; let highNeg = findProduct ( highest , negative ) ; let lowPos = findProduct ( lowest , positive ) ; let lowNeg = findProduct ( lowest , negative ) ; if ( lowest < 0 && highest >= 0 ) { return ( [ Math . max ( highPos , lowNeg ) , Math . min ( highNeg , lowPos ) ] ) ; } else if ( lowest <= 0 && highest <= 0 ) { return ( [ lowNeg , lowPos ] ) ; } else if ( lowest >= 0 && highest >= 0 ) { return ( [ Math . max ( lowPos , highPos ) , Math . min ( lowNeg , highNeg ) ] ) ; } return ( [ 0 , 0 ] ) ; } let N = 2 ; let arr = [ [ - 3 , - 4 ] , [ 1 , 2 , - 3 ] ] ; let ans = calculateProduct ( arr , 0 ) ; document . write ( ans [ 0 ] ) ;

Index/key variables: index
Javascript program:
function maxNumTrailNine ( n , d ) { let res = n ; let cntDigits = parseInt ( Math . log ( n ) / Math . log ( 10 ) ) + 1 ; let p10 = 10 ; for ( let i = 1 ; i <= cntDigits ; i ++ ) { if ( n % p10 >= d ) { break ; } else { res = n - n % p10 - 1 ; } p10 = p10 * 10 ; } document . write ( res ) ; } let n = 1025 , d = 6 ; maxNumTrailNine ( n , d ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function minChocolates ( a , n ) { let i = 0 , j = 0 ; let res = 0 , val = 1 ; while ( j < n - 1 ) { if ( a [ j ] > a [ j + 1 ] ) { j += 1 ; continue ; } if ( i == j ) res += val ; else { res += get_sum ( val , i , j ) ; } if ( a [ j ] < a [ j + 1 ] ) val += 1 ; else val = 1 ; j += 1 ; i = j ; } if ( i == j ) res += val ; else res += get_sum ( val , i , j ) ; return res ; } function get_sum ( peak , start , end ) { let count = end - start + 1 ; peak = ( peak > count ) ? peak : count ; let s = peak + ( ( ( count - 1 ) * count ) >> 1 ) ; return s ; } let a = [ 5 , 5 , 4 , 3 , 2 , 1 ] ; let n = a . length ; document . write ( " " + minChocolates ( a , n ) ) ;

Index/key variables: j
Accumulator variables: j, res, val
Javascript program:
function RemoveElemArr ( arr , n , k ) { if ( n == 0 n == 1 ) return arr ; var j = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( j < k arr [ i ] > arr [ j - k ] ) { arr [ j ++ ] = arr [ i ] ; } } while ( arr . length > j ) { arr . pop ( ) ; } return arr ; } function printArray ( arr ) { for ( var i = 0 ; i < arr . length ; i ++ ) { document . write ( arr [ i ] + " " ) ; } } function UtilRemov ( arr , n , k ) { arr = RemoveElemArr ( arr , n , k ) ; printArray ( arr ) ; } var arr = [ 1 , 2 , 2 , 3 , 4 , 4 , 4 , 5 , 5 ] ; var k = 2 ; var n = arr . length ; UtilRemov ( arr , n , k ) ;

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i
Javascript program:
function pairs_after_removing ( arr , N ) { var cntPairs = 0 ; var mp = new Map ( ) ; for ( var i = 0 ; i < N ; i ++ ) { if ( mp . has ( arr [ i ] ) ) { mp . set ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } else { mp . set ( arr [ i ] , 1 ) ; } } mp . forEach ( ( value , key ) => { var i = key ; cntPairs += mp . get ( i ) * ( mp . get ( i ) - 1 ) / 2 ; } ) ; for ( var i = 0 ; i < N ; i ++ ) { var pairs_after_arr_i_removed = cntPairs + 1 - mp . get ( arr [ i ] ) ; document . write ( pairs_after_arr_i_removed + ' ' ) ; } return ; } var arr = [ 2 , 3 , 4 , 3 , 2 ] ; var N = arr . length ; pairs_after_removing ( arr , N ) ;

Index/key variables: i
Accumulator variables: cntPairs, i
Iterator variables: i
Javascript program:
function smallestDivisorGr1 ( N ) { for ( var i = 2 ; i <= Math . sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) { return i ; } } return N ; } function findValOfNWithOperat ( N , K ) { if ( N % 2 == 0 ) { N += K * 2 ; } else { N += smallestDivisorGr1 ( N ) + ( K - 1 ) * 2 ; } return N ; } var N = 6 , K = 4 ; document . write ( findValOfNWithOperat ( N , K ) ) ;

Accumulator variables: N, i
Iterator variables: i
Javascript program:
function CntOfSubsetsByPartitioning ( arr , N ) { var freq = { } ; for ( var i = 0 ; i < N ; i ++ ) { if ( freq . hasOwnProperty ( arr [ i ] ) ) { freq [ arr [ i ] ] = freq [ arr [ i ] ] + 1 ; } else { freq [ arr [ i ] ] = 1 ; } } var freqGCD = 0 ; for ( const [ key , value ] of Object . entries ( freq ) ) { freqGCD = __gcd ( freqGCD , value ) ; } return parseInt ( N / freqGCD ) ; } function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } var arr = [ 1 , 2 , 3 , 4 , 4 , 3 , 2 , 1 ] ; var N = arr . length ; document . write ( CntOfSubsetsByPartitioning ( arr , N ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let r , c ; let dir = [ [ 1 , 0 ] , [ - 1 , 0 ] , [ 0 , 1 ] , [ 0 , - 1 ] , [ - 1 , - 1 ] , [ - 1 , 1 ] , [ 1 , 1 ] , [ 1 , - 1 ] ] ; function valid ( i , j ) { if ( i >= 0 && j >= 0 && i < r && j < c ) return true ; return false ; } function find ( i , j , v ) { let s = 0 ; for ( let k = 0 ; k < 8 ; k ++ ) { let ni = i + dir [ k ] [ 0 ] , nj = j + dir [ k ] [ 1 ] ; if ( valid ( ni , nj ) ) s += v [ ni ] [ nj ] ; } return s ; } function findsumofneighbors ( M ) { let v = new Array ( r ) ; for ( var i = 0 ; i < v . length ; i ++ ) { v [ i ] = new Array ( 2 ) ; } for ( let i = 0 ; i < r ; i ++ ) { for ( let j = 0 ; j < c ; j ++ ) { v [ i ] [ j ] = find ( i , j , M ) ; document . write ( v [ i ] [ j ] + " " ) ; } document . write ( " " ) ; } } let M = [ [ 1 , 4 , 1 ] , [ 2 , 4 , 5 ] , [ 3 , 1 , 2 ] ] ; r = M . length ; c = M [ 0 ] . length ; findsumofneighbors ( M ) ;

Index/key variables: i, j, k, ni, nj
Accumulator variables: i, j, k, s
Iterator variables: i, j, k
Javascript program:
let mod = ( 1e9 + 7 ) ; let T = new Array ( 2000 ) ; let result = new Array ( 2000 ) ; for ( let i = 0 ; i < 2000 ; i ++ ) { T [ i ] = new Array ( 2000 ) ; result [ i ] = new Array ( 2000 ) ; for ( let j = 0 ; j < 2000 ; j ++ ) { T [ i ] [ j ] = 0 ; result [ i ] [ j ] = 0 ; } } function mul_2 ( K ) { let temp = new Array ( K + 1 ) ; for ( let i = 0 ; i <= K ; i ++ ) { temp [ i ] = new Array ( K + 1 ) ; for ( let j = 0 ; j <= K ; j ++ ) { temp [ i ] [ j ] = 0 ; } } for ( let i = 1 ; i <= K ; i ++ ) { for ( let j = 1 ; j <= K ; j ++ ) { for ( let k = 1 ; k <= K ; k ++ ) { temp [ i ] [ j ] = ( temp [ i ] [ j ] + ( T [ i ] [ k ] * T [ k ] [ j ] ) % mod ) % mod ; } } } for ( let i = 1 ; i <= K ; i ++ ) { for ( let j = 1 ; j <= K ; j ++ ) { T [ i ] [ j ] = temp [ i ] [ j ] ; } } } function mul_1 ( K ) { let temp = new Array ( K + 1 ) ; for ( let i = 0 ; i <= K ; i ++ ) { temp [ i ] = new Array ( K + 1 ) ; for ( let j = 0 ; j <= K ; j ++ ) { temp [ i ] [ j ] = 0 ; } } for ( let i = 1 ; i <= K ; i ++ ) { for ( let j = 1 ; j <= K ; j ++ ) { for ( let k = 1 ; k <= K ; k ++ ) { temp [ i ] [ j ] = ( temp [ i ] [ j ] + ( result [ i ] [ k ] * T [ k ] [ j ] ) % mod ) % mod ; } } } for ( let i = 1 ; i <= K ; i ++ ) { for ( let j = 1 ; j <= K ; j ++ ) { result [ i ] [ j ] = temp [ i ] [ j ] ; } } } function matrix_pow ( K , n ) { for ( let i = 1 ; i <= K ; i ++ ) { for ( let j = 1 ; j <= K ; j ++ ) { if ( i == j ) result [ i ] [ j ] = 1 ; } } while ( n > 0 ) { if ( n % 2 == 1 ) mul_1 ( K ) ; mul_2 ( K ) ; n = parseInt ( n / 2 , 10 ) ; } } function NthTerm ( F , C , K , n ) { for ( let i = 1 ; i <= K ; i ++ ) T [ i ] [ K ] = C [ K - i ] ; for ( let i = 1 ; i <= K ; i ++ ) T [ i + 1 ] [ i ] = 1 ; matrix_pow ( K , n ) ; let answer = 0 ; for ( let i = 1 ; i <= K ; i ++ ) { answer += F [ i - 1 ] * result [ i ] [ 1 ] ; } document . write ( answer + " " ) ; return 0 ; } let F = [ 1 , 2 , 3 ] ; let C = [ 1 , 1 , 1 ] ; let K = 3 ; let N = 10 ; NthTerm ( F , C , K , N ) ;

Index/key variables: K, i, j, k
Accumulator variables: answer, i, j, k
Iterator variables: i, j, k
Javascript program:
function nthRoot ( A , N ) { var xPre = ( Math . random ( ) * 10 ) % 10 ; var eps = 1e-3 ; var delX = Number . MAX_VALUE ; var xK = 0 ; while ( delX > eps ) { xK = ( ( N - 1.0 ) * xPre + A / Math . pow ( xPre , N - 1 ) ) / N ; delX = Math . abs ( xK - xPre ) ; xPre = xK ; } return xK ; } function RMNValue ( arr , n , k ) { var Nth = 0 ; var mean = 0 , root = 0 ; for ( var i = 0 ; i < n ; i ++ ) { Nth += Math . pow ( arr [ i ] , k ) ; } mean = ( Nth / ( n ) ) ; root = nthRoot ( mean , k ) ; return root ; } var arr = [ 10 , 4 , 6 , 8 ] ; var N = arr . length ; var K = 3 ; document . write ( RMNValue ( arr , N , K ) ) ;

Index/key variables: i
Accumulator variables: Nth, i
Iterator variables: i