dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
let size = 1000001 ; let prime = new Array ( size , 0 ) ; function seiveOfEratosthenes ( ) { prime [ 0 ] = 1 ; prime [ 1 ] = 0 ; for ( let i = 2 ; i * i < 1000001 ; i ++ ) { if ( prime [ i ] == 0 ) { for ( let j = i * i ; j < 1000001 ; j += i ) { prime [ j ] = 1 ; } } } } function probabiltyEuler ( L , R , M ) { let arr = new Array ( size , 0 ) ; let eulerTotient = new Array ( size , 0 ) ; let count = 0 ; for ( let i = L ; i <= R ; i ++ ) { eulerTotient [ i - L ] = i ; arr [ i - L ] = i ; } for ( let i = 2 ; i < 1000001 ; i ++ ) { if ( prime [ i ] == 0 ) { for ( let j = ( L / i ) * i ; j <= R ; j += i ) { if ( j - L >= 0 ) { eulerTotient [ j - L ] = eulerTotient [ j - L ] / i * ( i - 1 ) ; while ( arr [ j - L ] % i == 0 ) { arr [ j - L ] /= i ; } } } } } for ( let i = L ; i <= R ; i ++ ) { if ( arr [ i - L ] > 1 ) { eulerTotient [ i - L ] = ( eulerTotient [ i - L ] / arr [ i - L ] ) * ( arr [ i - L ] - 1 ) ; } } for ( let i = L ; i <= R ; i ++ ) { if ( ( eulerTotient [ i - L ] % M ) == 0 ) { count ++ ; } } count /= 2 ; return 1.0 * count / ( R + 1 - L ) ; } seiveOfEratosthenes ( ) ; let L = 1 ; let R = 7 ; let M = 3 ; document . write ( probabiltyEuler ( L , R , M ) . toFixed ( 7 ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function findWinner ( n , k ) { let cnt = 0 ; if ( n == 1 ) document . write ( " " ) ; else if ( ( n & 1 ) != 0 n == 2 ) document . write ( " " ) ; else { let tmp = n ; let val = 1 ; while ( tmp > k && tmp % 2 == 0 ) { tmp /= 2 ; val *= 2 ; } for ( let i = 3 ; i <= Math . sqrt ( tmp ) ; i ++ ) { while ( tmp % i == 0 ) { cnt ++ ; tmp /= i ; } } if ( tmp > 1 ) cnt ++ ; if ( val == n ) document . write ( " " ) ; else if ( n / tmp == 2 && cnt == 1 ) document . write ( " " ) ; else document . write ( " " ) ; } } let n = 1 , k = 1 ; findWinner ( n , k ) ;

Accumulator variables: cnt, i, tmp, val
Iterator variables: i
Javascript program:
function pen_hex ( n ) { var pn = 1 ; for ( i = 1 ; i < n ; i ++ ) { pn = parseInt ( i * ( 3 * i - 1 ) / 2 ) ; if ( pn > n ) break ; var seqNum = ( 1 + Math . sqrt ( 8 * pn + 1 ) ) / 4 ; if ( seqNum == parseInt ( seqNum ) ) document . write ( pn + " " ) ; } } var N = 1000000 ; pen_hex ( N ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function isPal ( a , n , m ) { for ( let i = 0 ; i < n / 2 ; i ++ ) { for ( let j = 0 ; j < m - 1 ; j ++ ) { if ( a [ i ] [ j ] != a [ n - 1 - i ] [ m - 1 - j ] ) return false ; } } return true ; } let n = 3 , m = 3 ; let a = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 4 ] , [ 3 , 2 , 1 ] ] ; if ( isPal ( a , n , m ) ) { document . write ( " " + " " ) ; } else { document . write ( " " + " " ) ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function getSum ( n ) { let sum = 0 ; while ( n != 0 ) { sum = sum + n % 10 ; n = Math . floor ( n / 10 ) ; } return sum ; } function smallestNumber ( N ) { let i = 1 ; while ( 1 ) { if ( getSum ( i ) == N ) { document . write ( i ) ; break ; } i ++ ; } } let N = 10 ; smallestNumber ( N ) ;

Accumulator variables: i
Javascript program:
function calc_ans ( l , r ) { var power2 = [ ] , power3 = [ ] ; var mul2 = 1 ; while ( mul2 <= r ) { power2 . push ( mul2 ) ; mul2 *= 2 ; } var mul3 = 1 ; while ( mul3 <= r ) { power3 . push ( mul3 ) ; mul3 *= 3 ; } var power23 = [ ] ; for ( var x = 0 ; x < power2 . length ; x ++ ) { for ( var y = 0 ; y < power3 . length ; y ++ ) { var mul = power2 [ x ] * power3 [ y ] ; if ( mul == 1 ) continue ; if ( mul <= r ) power23 . push ( mul ) ; } } var ans = 0 ; power23 . forEach ( x => { if ( x >= l && x <= r ) ans ++ ; } ) ; document . write ( ans ) ; } var l = 1 , r = 10 ; calc_ans ( l , r ) ;

Index/key variables: x, y
Accumulator variables: ans, mul2, mul3, x, y
Iterator variables: x, y
Javascript program:
function nCr ( n , r ) { if ( r > n ) return 0 ; return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } function fact ( n ) { var res = 1 ; for ( var i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } function countSubsequences ( arr , n , k ) { var countOdd = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( arr [ i ] & 1 ) countOdd ++ ; } var ans = nCr ( n , k ) - nCr ( countOdd , k ) ; return ans ; } var arr = [ 2 , 4 ] ; var K = 1 ; var N = arr . length ; document . write ( countSubsequences ( arr , N , K ) ) ;

Index/key variables: i
Accumulator variables: countOdd, i
Iterator variables: i
Javascript program:
function modifiedBinaryPattern ( n ) { for ( let i = 1 ; i <= n ; i ++ ) { for ( let j = 1 ; j <= i ; j ++ ) { if ( j == 1 j == i ) document . write ( 1 ) ; else document . write ( 0 ) ; } document . write ( " " ) ; } } let n = 7 ; modifiedBinaryPattern ( n ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function highestPower ( n , k ) { let i = 0 ; let a = Math . pow ( n , i ) ; while ( a <= k ) { i += 1 ; a = Math . pow ( n , i ) ; } return i - 1 ; } let b = Array . from ( { length : 50 } , ( _ , i ) => 0 ) ; function PowerArray ( n , k ) { while ( k > 0 ) { let t = highestPower ( n , k ) ; if ( b [ t ] > 0 ) { document . write ( - 1 ) ; return 0 ; } else b [ t ] = 1 ; k -= Math . pow ( n , t ) ; } for ( let i = 0 ; i < 50 ; i ++ ) { if ( b [ i ] > 0 ) { document . write ( i + " " ) ; } } return 0 ; } let N = 3 ; let K = 40 ; PowerArray ( N , K ) ;

Index/key variables: i, t
Accumulator variables: i, k
Iterator variables: i
Javascript program:
let N = 100005 function SieveOfEratosthenes ( composite ) { for ( let i = 0 ; i < N ; i ++ ) composite [ i ] = false ; for ( let p = 2 ; p * p < N ; p ++ ) { if ( ! composite [ p ] ) { for ( let i = p * 2 ; i < N ; i += p ) composite [ i ] = true ; } } } function sumOfElements ( arr , n ) { let composite = new Array ( N ) ; SieveOfEratosthenes ( composite ) ; let m = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) if ( m . has ( arr [ i ] ) ) { m [ arr [ i ] ] = m [ arr [ i ] ] + 1 ; } else { m . set ( arr [ i ] , 1 ) ; } let sum = 0 ; m . forEach ( ( value , key ) => { if ( composite [ key ] ) { sum += value ; } } ) return sum ; } let arr = [ 1 , 2 , 1 , 1 , 1 , 3 , 3 , 2 , 4 ] ; let n = arr . length ; document . write ( sumOfElements ( arr , n ) ) ;

Index/key variables: i, key, p
Accumulator variables: i, p, sum
Iterator variables: i, p
Javascript program:
function remove ( arr , n ) { let mp = new Map ( ) ; for ( let 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 ) ; } } for ( let i = 0 ; i < n ; i ++ ) { if ( ( mp . has ( arr [ i ] ) && mp . get ( arr [ i ] ) % 2 == 1 ) ) continue ; document . write ( arr [ i ] + " " ) ; } } let arr = [ 3 , 3 , 3 , 2 , 2 , 4 , 7 , 7 ] ; let n = arr . length ; remove ( arr , n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function getmax ( arr , n , x ) { let s = 0 ; for ( let i = 0 ; i < n ; i ++ ) { s = s + arr [ i ] ; } document . write ( Math . min ( s , x ) ) ; } let arr = [ 1 , 2 , 3 , 4 ] ; let x = 5 ; let arr_size = arr . length ; getmax ( arr , arr_size , x ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function shortestLength ( n , x , y ) { let answer = 0 ; let i = 0 ; while ( n != 0 && i < x . length ) { if ( x [ i ] + y [ i ] > answer ) answer = x [ i ] + y [ i ] ; i ++ ; } document . write ( " " + answer + " " ) ; document . write ( " " + " " + answer + " " + " " + answer + " " ) ; } let n = 4 ; let x = [ 1 , 4 , 2 , 1 ] ; let y = [ 4 , 1 , 1 , 2 ] ; shortestLength ( n , x , y ) ;

Index/key variables: i
Accumulator variables: i
Javascript program:
class Point { constructor ( a , b ) { this . x = a ; this . y = b ; } } function printCorners ( p , q , l ) { let a = new Point ( ) , b = new Point ( ) , c = new Point ( ) , d = new Point ( ) ; if ( p . x == q . x ) { a . x = ( p . x - ( l / 2.0 ) ) ; a . y = p . y ; d . x = ( p . x + ( l / 2.0 ) ) ; d . y = p . y ; b . x = ( q . x - ( l / 2.0 ) ) ; b . y = q . y ; c . x = ( q . x + ( l / 2.0 ) ) ; c . y = q . y ; } else if ( p . y == q . y ) { a . y = ( p . y - ( l / 2.0 ) ) ; a . x = p . x ; d . y = ( p . y + ( l / 2.0 ) ) ; d . x = p . x ; b . y = ( q . y - ( l / 2.0 ) ) ; b . x = q . x ; c . y = ( q . y + ( l / 2.0 ) ) ; c . x = q . x ; } else { let m = ( p . x - q . x ) / ( q . y - p . y ) ; let dx = ( ( l / Math . sqrt ( 1 + ( m * m ) ) ) * 0.5 ) ; let dy = m * dx ; a . x = p . x - dx ; a . y = p . y - dy ; d . x = p . x + dx ; d . y = p . y + dy ; b . x = q . x - dx ; b . y = q . y - dy ; c . x = q . x + dx ; c . y = q . y + dy ; } document . write ( a . x + " " + a . y + " " + b . x + " " + b . y + " " + c . x + " " + c . y + " " + d . x + " " + d . y + " " ) ; } let p1 = new Point ( 1 , 0 ) , q1 = new Point ( 1 , 2 ) ; printCorners ( p1 , q1 , 2 ) ; let p = new Point ( 1 , 1 ) , q = new Point ( - 1 , - 1 ) ; printCorners ( p , q , ( 2 * Math . sqrt ( 2 ) ) ) ;

Class/struct names: Point
Javascript program:
function minimumCost ( arr , N , X , Y ) { let even_count = 0 , odd_count = 0 ; for ( let i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] & 1 ) && ( i % 2 == 0 ) ) { odd_count ++ ; } if ( ( arr [ i ] % 2 ) == 0 && ( i & 1 ) ) { even_count ++ ; } } let cost1 = X * Math . min ( odd_count , even_count ) ; let cost2 = Y * ( Math . max ( odd_count , even_count ) - Math . min ( odd_count , even_count ) ) ; let cost3 = ( odd_count + even_count ) * Y ; return Math . min ( cost1 + cost2 , cost3 ) ; } let arr = [ 5 , 3 , 7 , 2 , 1 ] , X = 10 , Y = 2 ; let N = arr . length ; document . write ( minimumCost ( arr , N , X , Y ) ) ;

Index/key variables: i
Accumulator variables: even_count, i, odd_count
Iterator variables: i
Javascript program:
function findMinMax ( a ) { let min_val = 1000000000 ; for ( let i = 1 ; i < a . length ; ++ i ) { min_val = Math . min ( min_val , a [ i ] * a [ i - 1 ] ) ; } return min_val ; } let arr = [ 6 , 4 , 5 , 6 , 2 , 4 , 1 ] ; document . write ( findMinMax ( arr ) )

Index/key variables: i
Iterator variables: i
Javascript program:
let sum = 0 ; class TreeNode { constructor ( data = " " , left = null , right = null ) { this . data = data ; this . left = left ; this . right = right ; } } function kDistanceDownSum ( root , k ) { if ( root == null k < 0 ) { return } if ( k == 0 ) { sum += root . data ; return ; } kDistanceDownSum ( root . left , k - 1 ) ; kDistanceDownSum ( root . right , k - 1 ) ; } function kDistanceSum ( root , target , k ) { if ( root == null ) return - 1 ; if ( root . data == target ) { kDistanceDownSum ( root . left , k - 1 ) ; return 0 ; } let dl = - 1 ; if ( target < root . data ) { dl = kDistanceSum ( root . left , target , k ) ; } if ( dl != - 1 ) { if ( dl + 1 == k ) sum += root . data ; return - 1 ; } let dr = - 1 ; if ( target > root . data ) { dr = kDistanceSum ( root . right , target , k ) ; } if ( dr != - 1 ) { if ( dr + 1 == k ) sum += root . data ; else kDistanceDownSum ( root . left , k - dr - 2 ) ; return 1 + dr ; } return - 1 ; } function insertNode ( data , root ) { if ( root == null ) { let node = new TreeNode ( data ) ; return node ; } else if ( data > root . data ) { root . right = insertNode ( data , root . right ) ; } else if ( data <= root . data ) { root . left = insertNode ( data , root . left ) ; } return root ; } function findSum ( root , target , K ) { kDistanceSum ( root , target , K , sum ) ; document . write ( sum ) ; } let root = null ; let N = 11 ; let tree = [ 3 , 1 , 7 , 0 , 2 , 5 , 10 , 4 , 6 , 9 , 8 ] ; for ( let i = 0 ; i < N ; i ++ ) { root = insertNode ( tree [ i ] , root ) ; } let target = 7 ; let K = 2 ; findSum ( root , target , K ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: TreeNode
Javascript program:
function itemType ( n ) { let count = 0 ; for ( let day = 1 ; ; day ++ ) { for ( let type = day ; type > 0 ; type -- ) { count += type ; if ( count >= n ) return type ; } } } let N = 10 ; document . write ( itemType ( N ) ) ;

Accumulator variables: count, day, type
Iterator variables: day, type
Javascript program:
function FindSum ( arr , N ) { let res = 0 ; for ( let i = 0 ; i < N ; i ++ ) { let power = Math . floor ( Math . log2 ( arr [ i ] ) ) ; let LesserValue = Math . pow ( 2 , power ) ; let LargerValue = Math . pow ( 2 , power + 1 ) ; if ( ( arr [ i ] - LesserValue ) == ( LargerValue - arr [ i ] ) ) { res += arr [ i ] ; } } return res ; } let arr = [ 10 , 24 , 17 , 3 , 8 ] ; let N = arr . length ; document . write ( FindSum ( arr , N ) ) ;

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Javascript program:
function findLast ( mat ) { let m = mat . length ; let n = mat [ 0 ] . length ; let rows = new Set ( ) ; let cols = new Set ( ) ; for ( let i = 0 ; i < m ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) { if ( mat [ i ] [ j ] ) { rows . add ( i ) ; cols . add ( j ) ; } } } let avRows = m - rows . size ; let avCols = n - cols . size ; let choices = Math . min ( avRows , avCols ) ; if ( choices & 1 ) document . write ( " " ) else document . write ( " " ) } let mat = [ [ 1 , 0 , 0 ] , [ 0 , 0 , 0 ] , [ 0 , 0 , 1 ] ] findLast ( mat ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
let MOD = 1000000007 ; function sumOfBinaryNumbers ( n ) { let ans = 0 ; let one = 1 ; while ( true ) { if ( n <= 1 ) { ans = ( ans + n ) % MOD ; break ; } let x = Math . floor ( Math . log ( n ) / Math . log ( 2 ) ) ; let cur = 0 ; let add = Math . floor ( Math . pow ( 2 , ( x - 1 ) ) ) ; for ( let i = 1 ; i <= x ; i ++ ) { cur = ( cur + add ) % MOD ; add = ( add * 10 % MOD ) ; } ans = ( ans + cur ) % MOD ; let rem = n - Math . floor ( Math . pow ( 2 , x ) ) + 1 ; let p = Math . floor ( Math . pow ( 10 , x ) ) ; p = ( p * ( rem % MOD ) ) % MOD ; ans = ( ans + p ) % MOD ; n = rem - 1 ; } document . write ( ans ) ; } let N = 3 ; sumOfBinaryNumbers ( N ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function checkPermutation ( ans , a , n ) { let Max = Number . MIN_VALUE ; for ( let i = 0 ; i < n ; i ++ ) { Max = Math . max ( Max , ans [ i ] ) ; if ( Max != a [ i ] ) return false ; } return true ; } function findPermutation ( a , n ) { let ans = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { ans [ i ] = 0 ; } let um = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( ! um . has ( a [ i ] ) ) { ans [ i ] = a [ i ] ; um . set ( a [ i ] , i ) ; } } let v = [ ] ; let j = 0 ; for ( let i = 1 ; i <= n ; i ++ ) { if ( ! um . has ( i ) ) { v . push ( i ) ; } } for ( let i = 0 ; i < n ; i ++ ) { if ( ans [ i ] == 0 ) { ans [ i ] = v [ j ] ; j ++ ; } } if ( checkPermutation ( ans , a , n ) ) { for ( let i = 0 ; i < n ; i ++ ) { document . write ( ans [ i ] + " " ) ; } } else document . write ( " " ) ; } let arr = [ 1 , 3 , 4 , 5 , 5 ] ; let N = arr . length ; findPermutation ( arr , N ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Javascript program:
function countEqualElementPairs ( arr , N ) { 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 ) ; } } var total = 0 ; mp . forEach ( ( value , key ) => { total += ( value * ( value - 1 ) ) / 2 ; } ) ; for ( var i = 0 ; i < N ; i ++ ) { document . write ( total - ( mp . get ( arr [ i ] ) - 1 ) + " " ) ; } } var arr = [ 1 , 1 , 2 , 1 , 2 ] ; var N = arr . length ; countEqualElementPairs ( arr , N ) ;

Index/key variables: i
Accumulator variables: i, total
Iterator variables: i
Javascript program:
function count ( N ) { var sum = 0 ; for ( var i = 1 ; i <= N ; i ++ ) { sum += 7 * Math . pow ( 8 , i - 1 ) ; } return sum ; } var N = 4 ; document . write ( count ( N ) ) ;

Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function isPalindrome ( n ) { var str = ( n . toString ( ) ) ; var s = 0 , e = str . length - 1 ; while ( s < e ) { if ( str [ s ] != str [ e ] ) { return false ; } s ++ ; e -- ; } return true ; } function palindromicDivisors ( n ) { var PalindromDivisors = [ ] ; for ( var i = 1 ; i <= parseInt ( Math . sqrt ( n ) ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) { if ( isPalindrome ( i ) ) { PalindromDivisors . push ( i ) ; } } else { if ( isPalindrome ( i ) ) { PalindromDivisors . push ( i ) ; } if ( isPalindrome ( n / i ) ) { PalindromDivisors . push ( n / i ) ; } } } } PalindromDivisors . sort ( ( a , b ) => a - b ) for ( var i = 0 ; i < PalindromDivisors . length ; i ++ ) { document . write ( PalindromDivisors [ i ] + " " ) ; } } var n = 66 ; palindromicDivisors ( n ) ;

Index/key variables: e, i, s
Accumulator variables: e, i, s
Iterator variables: i
Javascript program:
function findMinDel ( arr , n ) { var min_num = 1000000000 ; for ( var i = 0 ; i < n ; i ++ ) min_num = Math . min ( arr [ i ] , min_num ) ; var cnt = 0 ; for ( var i = 0 ; i < n ; i ++ ) if ( arr [ i ] == min_num ) cnt ++ ; return n - cnt ; } var arr = [ 3 , 3 , 2 ] ; var n = arr . length ; document . write ( findMinDel ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function __gcd ( a , b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } function cntSubArr ( arr , n ) { var ans = 0 ; for ( var i = 0 ; i < n ; i ++ ) { var curr_gcd = 0 ; for ( var j = i ; j < n ; j ++ ) { curr_gcd = __gcd ( curr_gcd , arr [ j ] ) ; ans += ( curr_gcd == 1 ) ; } } return ans ; } var arr = [ 1 , 1 , 1 ] ; var n = arr . length ; document . write ( cntSubArr ( arr , n ) ) ;

Index/key variables: j
Accumulator variables: ans, i, j
Iterator variables: i, j
Javascript program:
function print_primes_till_N ( N ) { let i , j , flag ; document . write ( " " + N + " " ) ; for ( i = 1 ; i <= N ; i ++ ) { if ( i == 1 i == 0 ) continue ; flag = 1 ; for ( j = 2 ; j <= i / 2 ; ++ j ) { if ( i % j == 0 ) { flag = 0 ; break ; } } if ( flag == 1 ) document . write ( i + " " ) ; } } let N = 100 ; print_primes_till_N ( N ) ;

Accumulator variables: i
Iterator variables: i, j
Javascript program:
function findX ( A , B ) { var X = 0 ; var MAX = 32 ; for ( var bit = 0 ; bit < MAX ; bit ++ ) { var tempBit = 1 << bit ; var bitOfX = A & B & tempBit ; X += bitOfX ; } return X ; } var A = 11 , B = 13 ; document . write ( findX ( A , B ) ) ;

Accumulator variables: X, bit
Iterator variables: bit
Javascript program:
function cntSubSets ( arr , n ) { var maxVal = arr . reduce ( function ( a , b ) { return Math . max ( a , b ) ; } ) ; var cnt = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == maxVal ) cnt ++ ; } return ( Math . pow ( 2 , cnt ) - 1 ) ; } var arr = [ 1 , 2 , 1 , 2 ] var n = arr . length ; document . write ( cntSubSets ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function findProb ( arr , n ) { var maxSum = - 100000000 , maxCount = 0 , totalPairs = 0 ; for ( var i = 0 ; i < n - 1 ; i ++ ) { for ( var j = i + 1 ; j < n ; j ++ ) { var sum = arr [ i ] + arr [ j ] ; if ( sum == maxSum ) { maxCount ++ ; } else if ( sum > maxSum ) { maxSum = sum ; maxCount = 1 ; } totalPairs ++ ; } } var prob = maxCount / totalPairs ; return prob ; } var arr = [ 1 , 1 , 1 , 2 , 2 , 2 ] var n = arr . length ; document . write ( findProb ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: i, j, maxCount, totalPairs
Iterator variables: i, j
Javascript program:
function GCD ( a , b ) { if ( b == 0 ) return a ; return GCD ( b , a % b ) ; } function maxCommonFactors ( a , b ) { let gcd = GCD ( a , b ) ; let ans = 1 ; for ( let i = 2 ; i * i <= gcd ; i ++ ) { if ( gcd % i == 0 ) { ans ++ ; while ( gcd % i == 0 ) gcd = parseInt ( gcd / i ) ; } } if ( gcd != 1 ) ans ++ ; return ans ; } let a = 12 , b = 18 ; document . write ( maxCommonFactors ( a , b ) ) ;

Accumulator variables: ans, i
Iterator variables: i
Javascript program:
var days = [ 31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ] ; function dayOfYear ( date ) { var year = parseInt ( date . substring ( 0 , 4 ) ) ; var month = parseInt ( date . substring ( 5 , 6 ) ) ; var day = parseInt ( date . substring ( 8 ) ) ; if ( month > 2 && year % 4 == 0 && ( year % 100 != 0 year % 400 == 0 ) ) { ++ day ; } while ( month -- > 0 ) { day = day + days [ month - 1 ] ; } return day ; } var date = " " ; document . write ( dayOfYear ( date ) ) ;

Accumulator variables: month
Javascript program:
function Cells ( n , x ) { let ans = 0 ; for ( let i = 1 ; i <= n ; i ++ ) if ( x % i == 0 && parseInt ( x / i ) <= n ) ans ++ ; return ans ; } let n = 6 , x = 12 ; document . write ( Cells ( n , x ) ) ;

Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function minOperations ( x , y , p , q ) { if ( y % x != 0 ) return - 1 var d = Math . floor ( y / x ) var a = 0 while ( d % p == 0 ) { d = Math . floor ( d / p ) a += 1 } var b = 0 while ( d % q == 0 ) { d = Math . floor ( d / q ) b += 1 } if ( d != 1 ) return - 1 return ( a + b ) } var x = 12 var y = 2592 var p = 2 var q = 3 document . write ( minOperations ( x , y , p , q ) )

Accumulator variables: a, b
Javascript program:
function nCr ( n ) { if ( n < 4 ) return 0 ; let answer = n * ( n - 1 ) * ( n - 2 ) * ( n - 3 ) ; answer = parseInt ( answer / 24 ) ; return answer ; } function countQuadruples ( N , K ) { let M = parseInt ( N / K ) ; let answer = nCr ( M ) ; for ( let i = 2 ; i < M ; i ++ ) { let j = i ; let temp2 = parseInt ( M / i ) ; let count = 0 ; let check = 0 ; let temp = j ; while ( j % 2 == 0 ) { count ++ ; j = parseInt ( j / 2 ) ; if ( count >= 2 ) break ; } if ( count >= 2 ) { check = 1 ; } for ( let k = 3 ; k <= Math . sqrt ( temp ) ; k += 2 ) { let cnt = 0 ; while ( j % k == 0 ) { cnt ++ ; j = parseInt ( j / k ) ; if ( cnt >= 2 ) break ; } if ( cnt >= 2 ) { check = 1 ; break ; } else if ( cnt == 1 ) count ++ ; } if ( j > 2 ) { count ++ ; } if ( check ) continue ; else { if ( count % 2 == 1 ) { answer -= nCr ( temp2 ) ; } else { answer += nCr ( temp2 ) ; } } } return answer ; } let N = 10 , K = 2 ; document . write ( countQuadruples ( N , K ) ) ;

Accumulator variables: answer, cnt, count, i, k
Iterator variables: i, k
Javascript program:
function isVowel ( ch ) { if ( ch == ' ' ch == ' ' ch == ' ' ch == ' ' ch == ' ' ) return true ; else return false ; } function fact ( n ) { if ( n < 2 ) { return 1 ; } return n * fact ( n - 1 ) ; } function only_vowels ( freq ) { let denom = 1 ; let cnt_vwl = 0 ; for ( let [ key , value ] of freq . entries ( ) ) { if ( isVowel ( key ) ) { denom *= fact ( value ) ; cnt_vwl += value ; } } return Math . floor ( fact ( cnt_vwl ) / denom ) ; } function all_vowels_together ( freq ) { let vow = only_vowels ( freq ) ; let denom = 1 ; let cnt_cnst = 0 ; for ( let [ key , value ] of freq . entries ( ) ) { if ( ! isVowel ( key ) ) { denom *= fact ( value ) ; cnt_cnst += value ; } } let ans = Math . floor ( fact ( cnt_cnst + 1 ) / denom ) ; return ( ans * vow ) ; } function total_permutations ( freq ) { let cnt = 0 ; let denom = 1 ; for ( let [ key , value ] of freq . entries ( ) ) { denom *= fact ( value ) ; cnt += value ; } return Math . floor ( fact ( cnt ) / denom ) ; } function no_vowels_together ( word ) { let freq = new Map ( ) ; for ( let i = 0 ; i < word . length ; i ++ ) { let ch = word [ i ] . toLowerCase ( ) ; if ( freq . has ( ch ) ) { freq . set ( ch , freq . get ( ch ) + 1 ) ; } else { freq . set ( ch , 1 ) ; } } let total = total_permutations ( freq ) ; let vwl_tgthr = all_vowels_together ( freq ) ; let res = total - vwl_tgthr ; return res ; } let word = " " ; let ans = no_vowels_together ( word ) ; document . write ( ans + " " ) ; word = " " ; ans = no_vowels_together ( word ) ; document . write ( ans + " " ) ; word = " " ; ans = no_vowels_together ( word ) ; document . write ( ans + " " ) ;

Index/key variables: i
Accumulator variables: cnt, cnt_cnst, cnt_vwl, denom, i
Iterator variables: i