dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function printArr ( arr , n ) { for ( var i = 0 ; i < n ; i ++ ) document . write ( arr [ i ] + " " ) ; } function pushBinaryToBorder ( arr , n ) { var count1 = 0 ; for ( var i = 0 ; i < n ; i ++ ) if ( arr [ i ] != 1 ) arr [ count1 ++ ] = arr [ i ] ; while ( count1 < n ) arr [ count1 ++ ] = 1 ; var lastNonOne = 0 ; for ( var i = n - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] == 1 ) continue ; if ( ! lastNonOne ) { lastNonOne = i ; } if ( arr [ i ] != 0 ) arr [ lastNonOne -- ] = arr [ i ] ; } while ( lastNonOne >= 0 ) arr [ lastNonOne -- ] = 0 ; } var arr = [ 1 , 2 , 0 , 0 , 0 , 3 , 6 ] ; var n = arr . length ; pushBinaryToBorder ( arr , n ) ; printArr ( arr , n ) ;

Index/key variables: i
Accumulator variables: count1, i, lastNonOne
Iterator variables: i
Javascript program:
function isVowel ( ch ) { switch ( ch ) { case ' ' : case ' ' : case ' ' : case ' ' : case ' ' : return true ; default : return false ; } } function vowelPairs ( s , n ) { let cnt = 0 ; for ( let i = 0 ; i < n - 1 ; i ++ ) { if ( isVowel ( s [ i ] ) && isVowel ( s [ i + 1 ] ) ) cnt ++ ; } return cnt ; } let s = " " ; let n = s . length ; document . write ( vowelPairs ( s , n ) ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function gcd ( a , b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } function solve ( health , n ) { let currentgcd = gcd ( health [ 0 ] , health [ 1 ] ) ; for ( let i = 2 ; i < n ; ++ i ) { currentgcd = gcd ( currentgcd , health [ i ] ) ; } return currentgcd ; } let health = [ 4 , 6 , 8 , 12 ] ; let n = health . length ; document . write ( solve ( health , n ) ) ;

Index/key variables: i
Iterator variables: i
Javascript program:
function Find_Sequence ( arr , n ) { let inc_arr = [ ] , dec_arr = [ ] ; let flag = 0 ; let inc = - 1 , dec = 1e7 ; for ( let i = 0 ; i < n ; i ++ ) { if ( inc < arr [ i ] && arr [ i ] < dec ) { if ( arr [ i ] < arr [ i + 1 ] ) { inc = arr [ i ] ; inc_arr . push ( arr [ i ] ) ; } else { dec = arr [ i ] ; dec_arr . push ( arr [ i ] ) ; } } else if ( inc < arr [ i ] ) { inc = arr [ i ] ; inc_arr . push ( arr [ i ] ) ; } else if ( dec > arr [ i ] ) { dec = arr [ i ] ; dec_arr . push ( arr [ i ] ) ; } else { document . write ( - 1 ) ; flag = 1 ; break ; } } if ( flag == 0 ) { document . write ( " " ) ; for ( let i in inc_arr ) document . write ( inc_arr [ i ] + " " ) ; document . write ( " " ) ; document . write ( " " ) ; for ( let i in dec_arr ) document . write ( dec_arr [ i ] + " " ) ; document . write ( " " ) ; } } let arr = [ 5 , 1 , 3 , 6 , 8 , 2 , 9 , 0 , 10 ] ; let n = arr . length ; Find_Sequence ( arr , n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function reverse ( n ) { let rev = 0 ; while ( n != 0 ) { rev = ( rev * 10 ) + ( n % 10 ) ; n = Math . floor ( n / 10 ) ; } return rev ; } function getSum ( n ) { n = reverse ( n ) ; let sumOdd = 0 , sumEven = 0 , c = 1 ; while ( n != 0 ) { if ( c % 2 == 0 ) sumEven += n % 10 ; else sumOdd += n % 10 ; n = Math . floor ( n / 10 ) ; c ++ ; } document . write ( " " + sumOdd ) ; document . write ( " " ) ; document . write ( " " + sumEven ) ; } let n = 457892 ; getSum ( n ) ;

Accumulator variables: c, sumEven, sumOdd
Javascript program:
function getSum ( n ) { let isOdd = ( n % 2 == 1 ) ? true : false ; let sumOdd = 0 , sumEven = 0 ; while ( n != 0 ) { if ( isOdd ) sumOdd += n % 10 ; else sumEven += n % 10 ; isOdd = ! isOdd ; n = Math . floor ( n / 10 ) ; } document . write ( " " + sumOdd + " " ) ; document . write ( " " + sumEven ) ; } let n = 457892 ; getSum ( n ) ;

Accumulator variables: sumEven, sumOdd
Javascript program:
function twoParts ( str ) { var flag = 0 ; var a = " " ; var gfg = str . split ( ' ' ) ; for ( var i = 0 ; i < str . length ; i ++ ) { if ( gfg [ i ] == ' ' ) { gfg [ i ] = ' ' ; a += ' ' ; flag = 1 ; } else if ( flag != 0 ) a += ' ' ; } document . write ( gfg . join ( ' ' ) + " " + a ) ; } var str = " " ; twoParts ( str ) ;

Index/key variables: i
Accumulator variables: a, i
Iterator variables: i
Javascript program:
function longestSubstring ( s ) { var cnt = 1 , maxi = 1 ; var n = s . length ; for ( i = 1 ; i < n ; i ++ ) { if ( s . charAt ( i ) != s . charAt ( i - 1 ) ) cnt ++ ; else { maxi = Math . max ( cnt , maxi ) ; cnt = 1 ; } } maxi = Math . max ( cnt , maxi ) ; return maxi ; } var s = " " ; document . write ( longestSubstring ( s ) ) ;

Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function Minimum_Operations ( a , n ) { let np = Array ( n + 1 ) . fill ( 0 ) ; np [ n ] = 0 ; for ( let i = n - 1 ; i >= 0 ; i -- ) { np [ i ] = np [ i + 1 ] ; if ( a [ i ] <= 0 ) np [ i ] ++ ; } let pos = 0 ; let ans = n ; for ( let i = 0 ; i < n - 1 ; i ++ ) { if ( a [ i ] >= 0 ) pos ++ ; ans = Math . min ( ans , pos + np [ i + 1 ] ) ; } return ans ; } let a = [ - 1 , 0 , 1 , 2 ] ; let n = a . length ; document . write ( Minimum_Operations ( a , n ) ) ;

Index/key variables: i, n
Accumulator variables: i, pos
Iterator variables: i
Javascript program:
function findSumofEle ( arr1 , m , arr2 , n , k ) { var arraySum = 0 ; for ( var i = 0 ; i < n ; i ++ ) arraySum += arr2 [ i ] ; var mean = ( arraySum / n ) ; var sumOfElements = 0 ; var difference ; for ( var i = 0 ; i < m ; i ++ ) { difference = arr1 [ i ] - mean ; if ( ( difference < 0 ) && ( k > ( - 1 ) * difference ) ) { sumOfElements += arr1 [ i ] ; } if ( ( difference >= 0 ) && ( k > difference ) ) { sumOfElements += arr1 [ i ] ; } } return sumOfElements ; } var arr1 = [ 1 , 2 , 3 , 4 , 7 , 9 ] ; var arr2 = [ 0 , 1 , 2 , 1 , 1 , 4 ] ; var k = 2 ; var m , n ; m = arr1 . length ; n = arr2 . length ; document . write ( findSumofEle ( arr1 , m , arr2 , n , k ) ) ;

Index/key variables: i
Accumulator variables: arraySum, i, sumOfElements
Iterator variables: i
Javascript program:
function findIntegers ( n , x , y ) { let ans = [ ] ; for ( let i = 0 ; i < n - 1 ; i ++ ) ans . push ( 1 ) ; if ( y - ( n - 1 ) <= 0 ) { document . write ( " " ) ; return ; } ans . push ( y - ( n - 1 ) ) ; let store = 0 ; for ( let i = 0 ; i < n ; i ++ ) store += ans [ i ] * ans [ i ] ; if ( store < x ) { document . write ( " " ) ; return ; } for ( let i = 0 ; i < n ; i ++ ) document . write ( ans [ ( i ) ] + " " ) ; } let n = 3 , x = 254 , y = 18 ; findIntegers ( n , x , y ) ;

Index/key variables: i
Accumulator variables: i, store
Iterator variables: i
Javascript program:
function Minsteps ( n , m ) { let ans = 0 ; while ( m > n ) { if ( m & 1 ) { m ++ ; ans ++ ; } m = Math . floor ( m / 2 ) ; ans ++ ; } return ans + n - m ; } let n = 4 , m = 6 ; document . write ( Minsteps ( n , m ) ) ;

Accumulator variables: ans, m
Javascript program:
function getsum ( x ) { return ( x * ( x + 1 ) ) / 2 ; } function countJumps ( n ) { n = Math . abs ( n ) ; let ans = 0 ; while ( getsum ( ans ) < n || ( ( getsum ( ans ) - n ) & 1 ) > 0 ) ans ++ ; return ans ; } let n = 9 ; document . write ( countJumps ( n ) ) ;

Accumulator variables: ans
Javascript program:
function maxCandies ( arr , n ) { let prevBought = arr [ n - 1 ] ; let candies = prevBought ; for ( let i = n - 2 ; i >= 0 ; i -- ) { let x = Math . min ( prevBought - 1 , arr [ i ] ) ; if ( x >= 0 ) { candies += x ; prevBought = x ; } } return candies ; } let arr = [ 1 , 2 , 1 , 3 , 6 ] ; let n = arr . length ; document . write ( maxCandies ( arr , n ) ) ;

Index/key variables: i
Accumulator variables: candies, i
Iterator variables: i
Javascript program:
function printArray ( N , arr ) { for ( i = 0 ; i < N ; i ++ ) document . write ( arr [ i ] + " " ) ; document . write ( " " ) ; } function replacedArray ( N , arr ) { var pos_sum , neg_sum , i , j , diff ; for ( i = 0 ; i < N ; i ++ ) { pos_sum = 0 ; neg_sum = 0 ; for ( j = i + 1 ; j < N ; j ++ ) { if ( arr [ j ] > 0 ) pos_sum += arr [ j ] ; else neg_sum += arr [ j ] ; } diff = Math . abs ( pos_sum ) - Math . abs ( neg_sum ) ; arr [ i ] = Math . abs ( diff ) ; } } var N = 5 ; var arr = [ 1 , - 1 , 2 , 3 , - 2 ] ; replacedArray ( N , arr ) ; printArray ( N , arr ) ; N = 6 ; var arr1 = [ - 3 , - 4 , - 2 , 5 , 1 , - 2 ] ; replacedArray ( N , arr1 ) ; printArray ( N , arr1 ) ;

Index/key variables: i, j
Accumulator variables: i, j, neg_sum, pos_sum
Iterator variables: i, j
Javascript program:
function isPalindrome ( s ) { for ( let i = 0 ; i < s . length ; ++ i ) { if ( s [ i ] != s [ s . length - i - 1 ] ) { return false ; } } return true ; } function ans ( s ) { let s2 = s ; for ( let i = 0 ; i < s . length ; ++ i ) { s2 = s2 [ s2 . length - 1 ] + s2 ; s2 = s2 . substring ( 0 , s2 . length - 1 ) ; if ( ( s == null ? s2 != null : ! s == ( s2 ) ) && isPalindrome ( s2 ) ) { return true ; } } return false ; } function solve ( s ) { if ( s . length <= 3 ) { return - 1 ; } let cnt = new Array ( 25 ) ; for ( let i = 0 ; i < 25 ; i ++ ) cnt [ i ] = 0 ; for ( let i = 0 ; i < s . length ; i ++ ) { cnt [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } if ( Math . max ( ... cnt ) >= ( s . length - 1 ) ) { return - 1 ; } else { return ( ans ( s ) ? 1 : 2 ) ; } } let s = " " ; document . write ( solve ( s ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function solveEven ( s ) { if ( s . length % 2 == 1 ) { return 2 ; } let ls = s . substring ( 0 , s . length / 2 ) ; let rs = s . substring ( s . length / 2 , s . length ) ; if ( ls != rs ) { return 1 ; } return solveEven ( ls ) ; } function solveOdd ( s ) { return 2 ; } function solve ( s ) { if ( s . length <= 3 ) { return - 1 ; } let cnt = new Array ( 25 ) ; for ( let i = 0 ; i < 25 ; i ++ ) cnt [ i ] = 0 ; for ( let i = 0 ; i < s . length ; i ++ ) { cnt [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } if ( Math . max ( ... cnt ) >= s . length - 1 ) { return - 1 ; } if ( s . length % 2 == 0 ) { return solveEven ( s ) ; } if ( s . length % 2 == 1 ) { return solveOdd ( s ) ; } return Number . MIN_VALUE ; } let s = " " ; document . write ( solve ( s ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function minChanges ( str , n ) { let count = 0 , zeros = 0 , ones = 0 ; if ( str [ 0 ] != ' ' ) { count ++ ; ones ++ ; } for ( let i = 1 ; i < n ; i ++ ) { if ( str [ i ] == ' ' ) zeros ++ ; else ones ++ ; if ( zeros > ones ) { zeros -- ; ones ++ ; count ++ ; } } return count ; } let str = " " . split ( ' ' ) ; let n = str . length ; document . write ( minChanges ( str , n ) ) ;

Index/key variables: i
Accumulator variables: count, i, ones, zeros
Iterator variables: i
Javascript program:
function steps ( cur , x , n ) { if ( x == 0 ) return Number . MAX_VALUE ; if ( x > 0 ) return Math . abs ( ( n - cur ) / x ) ; else return Math . abs ( ( cur - 1 ) / x ) ; } function countSteps ( curx , cury , n , m , moves ) { let count = 0 ; let k = moves . length ; for ( let i = 0 ; i < k ; i ++ ) { let x = moves [ i ] [ 0 ] ; let y = moves [ i ] [ 1 ] ; let stepct = Math . min ( steps ( curx , x , n ) , steps ( cury , y , m ) ) ; count += stepct ; curx += stepct * x ; cury += stepct * y ; } return Math . floor ( count ) ; } let n = 4 , m = 5 , x = 1 , y = 1 ; let moves = [ [ 1 , 1 ] , [ 1 , 1 ] , [ 0 , - 2 ] ] ; document . write ( countSteps ( x , y , n , m , moves ) ) ;

Index/key variables: i
Accumulator variables: count, curx, cury, i
Iterator variables: i
Javascript program:
function min_elimination ( n , arr ) { let count = 0 ; let prev_val = arr [ 0 ] ; for ( let i = 1 ; i < n ; i ++ ) { let curr_val = arr [ i ] ; if ( curr_val % 2 == prev_val % 2 ) count ++ ; prev_val = curr_val ; } return count ; } let arr = [ 1 , 2 , 3 , 7 , 9 ] ; let n = arr . length ; document . write ( min_elimination ( n , arr ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function getCount ( N ) { if ( N % 2 == 1 ) return " " ; let result = " " ; for ( let i = 1 ; i <= N / 2 - 1 ; i ++ ) result += " " ; return result ; } let N = 4 ; document . write ( getCount ( N ) ) ;

Accumulator variables: i, result
Iterator variables: i
Javascript program:
function canFormTeam ( n , m ) { if ( n >= 1 && m >= 2 ) return true ; if ( m >= 1 && n >= 2 ) return true ; return false ; } function maxTeams ( n , m ) { var count = 0 ; while ( canFormTeam ( n , m ) ) { if ( n > m ) { n -= 2 ; m -= 1 ; } else { m -= 2 ; n -= 1 ; } count ++ ; } return count ; } var n = 4 , m = 5 ; document . write ( maxTeams ( n , m ) ) ;

Accumulator variables: count, m, n
Javascript program:
function find_rectangle ( area ) { let l = 0 , b = 0 ; let M = Math . floor ( Math . sqrt ( area ) ) , ans ; for ( let i = M ; i >= 1 ; i -- ) { if ( area % i == 0 ) { l = Math . floor ( area / i ) ; b = i ; break ; } } document . write ( " " + l + " " + b ) ; } let area = 99 ; find_rectangle ( area ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function find_rectangle ( are ) { for ( let i = Math . floor ( Math . ceil ( Math . sqrt ( area ) ) ) ; i <= area ; i ++ ) { if ( Math . floor ( area / i ) * i == area ) { document . write ( i + " " + Math . floor ( area / i ) ) ; return ; } } } let area = 99 ; find_rectangle ( area ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function sizeSubSet ( a , k , n ) { a . sort ( function ( a , b ) { return a - b ; } ) ; let s = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( a [ i ] % k != 0 || s . get ( a [ i ] / k ) == null ) s . set ( a [ i ] , s . get ( a [ i ] ) == null ? 1 : s . get ( a [ i ] ) + 1 ) ; } return s . size ; } let a = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ; let n = a . length ; let k = 2 ; document . write ( sizeSubSet ( a , k , n ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function minimumSets ( s , y ) { let cnt = 0 ; let num = 0 ; let l = s . length ; let f = false ; for ( let i = 0 ; i < l ; i ++ ) { num = num * 10 + ( s [ i ] - ' ' ) ; if ( num <= y ) f = true ; { if ( f ) cnt += 1 ; num = s [ i ] - ' ' ; f = false ; if ( num <= y ) f = true ; else num = 0 ; } } if ( f == true ) cnt += 1 ; return cnt ; } let s = " " ; let y = 30 ; document . write ( minimumSets ( s , y ) ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Boolean variables: f
Javascript program:
function printArr ( b , n ) { for ( let i = 0 ; i < n ; i ++ ) { document . write ( " " + b [ i ] + " " ) ; } } function ModifiedArray ( a , n ) { let l = 0 , r = Number . MAX_VALUE ; let b = Array ( n ) . fill ( 0 ) ; for ( let i = 0 ; i < n / 2 ; i ++ ) { b [ i ] = Math . max ( l , a [ i ] - r ) ; b [ n - i - 1 ] = a [ i ] - b [ i ] ; l = b [ i ] ; r = b [ n - i - 1 ] ; } printArr ( b , n ) ; } let a = [ 5 , 6 ] ; let n = a . length ; ModifiedArray ( a , 2 * n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function numberOfLines ( S , widths ) { if ( S . length == 0 ) return [ 0 , 0 ] ; let lines = 1 , width = 0 ; for ( let character of S . split ( " " ) ) { let w = widths [ character . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ; width += w ; if ( width >= 10 ) { lines ++ ; width = w ; } } return [ lines , width ] ; } let S = " " ; let widths = [ 4 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ] ; let ans = numberOfLines ( S , widths ) ; document . write ( ans [ 0 ] + " " + ans [ 1 ] + " " ) ;

Accumulator variables: lines, width
Iterator variables: character
Javascript program:
function canReorder ( A , n ) { let m = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( m . has ( A [ i ] ) ) { m . set ( A [ i ] , m . get ( A [ i ] ) + 1 ) } else { m . set ( A [ i ] , 1 ) } } A . sort ( ( a , b ) => a - b ) ; let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( m . get ( A [ i ] ) == 0 ) continue ; if ( m . get ( 2 * A [ i ] ) ) { count += 2 ; m . set ( A [ i ] , m . get ( A [ i ] ) - 1 ) ; m . set ( 2 * A [ i ] , m . get ( 2 * A [ i ] ) - 1 ) ; } } if ( count == n ) return " " ; else return " " ; } let A = [ 4 , - 2 , 2 , - 4 ] ; let n = A . length ; document . write ( ( canReorder ( A , n ) ) ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function maxSubArraySum ( a , size ) { var max_so_far = Number . MIN_VALUE , max_ending_here = 0 ; for ( i = 0 ; i < size ; i ++ ) { max_ending_here = max_ending_here + a [ i ] ; if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; if ( max_ending_here < 0 ) max_ending_here = 0 ; } return max_so_far ; } function maxSum ( a , n ) { var S = 0 ; var S1 = maxSubArraySum ( a , n ) ; for ( i = 0 ; i < n ; i ++ ) S += a [ i ] ; return ( 2 * S1 - S ) ; } var a = [ - 35 , 32 , - 24 , 0 , 27 , - 10 , 0 , - 19 ] ; var n = a . length ; document . write ( maxSum ( a , n ) ) ;

Index/key variables: i
Accumulator variables: S, i
Iterator variables: i
Javascript program:
function minimizeDiff ( arr , n , k ) { let max = Math . max ( ... arr ) ; let min = Math . min ( ... arr ) ; if ( ( max - min ) <= k ) { return ( max - min ) ; } let avg = Math . floor ( ( max + min ) / 2 ) ; for ( let i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > avg ) { arr [ i ] -= k ; } else { arr [ i ] += k ; } } max = Math . max ( ... arr ) ; min = Math . min ( ... arr ) ; return ( max - min ) ; } let arr = [ 3 , 16 , 12 , 9 , 20 ] ; let n = 5 ; let k = 3 ; document . write ( " " + minimizeDiff ( arr , n , k ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function maxLitres ( budget , plastic , glass , refund ) { if ( glass - refund < plastic ) { let ans = Math . max ( ( budget - refund ) / ( glass - refund ) , 0 ) ; budget -= ans * ( glass - refund ) ; ans += Math . floor ( budget / plastic ) ; document . write ( ans ) ; } else { document . write ( Math . floor ( budget / plastic ) ) ; } } let budget = 10 , plastic = 11 , glass = 9 , refund = 8 ; maxLitres ( budget , plastic , glass , refund ) ;

Accumulator variables: ans, budget
Javascript program:
function leastValue ( P , A , N , a ) { let ans = - 1 ; let tmp = Number . MAX_VALUE ; for ( let i = 0 ; i < N ; i ++ ) { let t = ( P - a [ i ] * 0.006 ) ; if ( Math . abs ( t - A ) < tmp ) { tmp = Math . abs ( t - A ) ; ans = i ; } } return a [ ans ] ; } let N = 2 , P = 12 , A = 2005 ; let a = [ 1000 , 2000 ] ; document . write ( leastValue ( P , A , N , a ) )

Index/key variables: ans, i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findPermutation ( n ) { let len = Math . ceil ( Math . log10 ( n ) ) ; for ( let i = 0 ; i < len ; i ++ ) { if ( n % 2 != 0 ) { return parseInt ( n ) ; } else { n = ( n / 10 ) + ( n % 10 ) * Math . pow ( 10 , len - i - 1 ) ; continue ; } } return - 1 ; } let n = 132 ; document . write ( findPermutation ( n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
var n = 3 ; var m = 4 ; function maxMatrixScore ( A , K ) { var update = new Map ( ) ; for ( var i = 0 ; i < n ; ++ i ) { if ( A [ i ] [ 0 ] == 0 ) { var ans = 0 ; for ( var j = 1 ; j < m ; ++ j ) ans = ans + A [ i ] [ j ] * Math . pow ( 2 , m - j - 1 ) ; update . set ( ans , i ) ; } } update . forEach ( ( value , key ) => { if ( K > 0 ) { var idx = value ; for ( var j = 0 ; j < m ; ++ j ) A [ idx ] [ j ] = ( A [ idx ] [ j ] + 1 ) % 2 ; K -- ; } } ) ; var ans = 0 ; for ( var j = 0 ; j < m ; ++ j ) { var zero = 0 , one = 0 ; for ( var i = 0 ; i < n ; ++ i ) { A [ i ] [ j ] == 0 ? zero ++ : one ++ ; } if ( K > 0 && zero > one ) { ans += zero * Math . pow ( 2 , m - j - 1 ) ; K -- ; } else ans += one * Math . pow ( 2 , m - j - 1 ) ; } return ans ; } var A = [ [ 0 , 0 , 1 , 1 ] , [ 1 , 0 , 1 , 0 ] , [ 1 , 1 , 0 , 0 ] ] ; var K = 2 ; document . write ( maxMatrixScore ( A , K ) ) ;

Index/key variables: i, idx, j
Accumulator variables: K, ans, one, zero
Iterator variables: i, j
Javascript program:
function isSellingPossible ( n , a ) { let i , c25 = 0 , c50 = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 25 ) c25 ++ ; else if ( a [ i ] == 50 ) { c50 ++ ; if ( c25 == 0 ) break ; c25 -- ; } else { if ( c50 > 0 && c25 > 0 ) { c50 -- ; c25 -- ; } else if ( c25 >= 3 ) c25 -= 3 ; else break ; } } if ( i == n ) return true ; else return false ; } let a = [ 25 , 25 , 50 , 100 ] ; let n = a . length ; if ( isSellingPossible ( n , a ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Index/key variables: i
Accumulator variables: c25, c50, i
Iterator variables: i
Javascript program:
function checkIfOverlap ( str ) { let len = str . length ; let visited = new Array ( len + 1 ) ; for ( let i = 0 ; i < visited . length ; i ++ ) { visited [ i ] = 0 ; } for ( let i = 0 ; i < len ; i ++ ) { if ( str [ i ] == ' ' ) continue ; for ( let j = Math . max ( 0 , i - str [ i ] ) ; j <= Math . min ( len , i + str [ i ] ) ; j ++ ) visited [ j ] ++ ; } for ( let i = 0 ; i < len ; i ++ ) { if ( visited [ i ] > 1 ) { return true ; } } return false ; } let str = " " ; if ( checkIfOverlap ( str ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isCorrectOrder ( n ) { let flag = true ; let prev = - 1 ; let type = - 1 ; while ( n != 0 ) { if ( type === - 1 ) { if ( prev === - 1 ) { prev = n % 10 ; n = Math . floor ( n / 10 ) ; continue ; } if ( prev == n % 10 ) { flag = false ; break ; } if ( prev > n % 10 ) { type = 1 ; prev = n % 10 ; n = Math . floor ( n / 10 ) ; continue ; } prev = n % 10 ; n = Math . floor ( n / 10 ) ; } else { if ( prev == n % 10 ) { flag = false ; break ; } if ( prev < n % 10 ) { flag = false ; break ; } prev = n % 10 ; n = Math . floor ( n / 10 ) ; } } return flag ; } let n = 123454321 ; if ( isCorrectOrder ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Boolean variables: flag
Javascript program:
function printCoins ( arr , n ) { var oddSum = 0 ; for ( var i = 0 ; i < n ; i += 2 ) oddSum += arr [ i ] ; var evenSum = 0 ; for ( var i = 1 ; i < n ; i += 2 ) evenSum += arr [ i ] ; var start = ( ( oddSum > evenSum ) ? 0 : 1 ) ; for ( var i = start ; i < n ; i += 2 ) document . write ( arr [ i ] + " " ) ; } var arr1 = [ 8 , 15 , 3 , 7 ] var n = arr1 . length ; printCoins ( arr1 , n ) ; document . write ( " " ) ; var arr2 = [ 2 , 2 , 2 , 2 ] var n = arr2 . length ; printCoins ( arr2 , n ) ; document . write ( " " ) ; var arr3 = [ 20 , 30 , 2 , 2 , 2 , 10 ] n = arr3 . length ; printCoins ( arr3 , n ) ;

Index/key variables: i
Accumulator variables: evenSum, i, oddSum
Iterator variables: i
Javascript program:
function finalPos ( command , n , x , y ) { let cup , cdown , cleft , cright ; let final_x , final_y ; cup = cdown = cleft = cright = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( command [ i ] == ' ' ) cup ++ ; else if ( command [ i ] == ' ' ) cdown ++ ; else if ( command [ i ] == ' ' ) cleft ++ ; else if ( command [ i ] == ' ' ) cright ++ ; } final_x = x + ( cright - cleft ) ; final_y = y + ( cdown - cup ) ; document . write ( " " + " " + final_x + " " + final_y + " " ) ; } let command = " " ; let n = command . length ; let x = 3 , y = 4 ; finalPos ( command , n , x , y ) ;

Index/key variables: i
Accumulator variables: cdown, cleft, cright, cup, i
Iterator variables: i