dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
class pair { constructor ( first , second ) { this . first = first ; this . second = second ; } } let n = 3 ; let dp = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { dp [ i ] = new Array ( n ) ; for ( let j = 0 ; j < n ; j ++ ) { dp [ i ] [ j ] = 0 ; } } function answerQueries ( queries , q ) { for ( let i = 0 ; i < q ; i ++ ) { let x = queries [ i ] . first ; x -- ; let y = queries [ i ] . second ; y -- ; document . write ( dp [ x ] [ y ] + " " ) ; } } function pre_compute ( a ) { if ( a [ 0 ] [ 0 ] == ' ' ) dp [ 0 ] [ 0 ] = 0 ; else dp [ 0 ] [ 0 ] = 1 ; for ( let row = 0 ; row < n ; row ++ ) { for ( let col = 0 ; col < n ; col ++ ) { if ( row != 0 col != 0 ) dp [ row ] [ col ] = Number . MAX_VALUE ; if ( row != 0 ) { dp [ row ] [ col ] = Math . min ( dp [ row ] [ col ] , dp [ row - 1 ] [ col ] ) ; } if ( col != 0 ) { dp [ row ] [ col ] = Math . min ( dp [ row ] [ col ] , dp [ row ] [ col - 1 ] ) ; } if ( a [ row ] [ col ] != ' ' && ( row != 0 col != 0 ) ) dp [ row ] [ col ] += 1 ; } } } let a = [ [ ' ' , ' ' , ' ' ] , [ ' ' , ' ' , ' ' ] , [ ' ' , ' ' , ' ' ] ] ; let queries = [ new pair ( 1 , 3 ) , new pair ( 3 , 3 ) ] ; let q = 2 ; pre_compute ( a ) ; answerQueries ( queries , q ) ;

Index/key variables: col, i, j, row, x, y
Accumulator variables: col, i, j, row, x, y
Iterator variables: col, i, j, row
Class/struct names: pair
Javascript program:
function squares ( i ) { if ( ( i & 1 ) == 1 ) return parseInt ( i / 4 , 10 ) * 2 + 1 ; else return parseInt ( ( i - 1 ) / 4 , 10 ) * 2 + 2 ; } function bishop_placements ( n , k ) { if ( k > 2 * n - 1 ) return 0 ; let dp = new Array ( n * 2 ) ; for ( let i = 0 ; i < n * 2 ; i ++ ) { dp [ i ] = new Array ( k + 1 ) ; for ( let j = 0 ; j < k + 1 ; j ++ ) { dp [ i ] [ j ] = 0 ; } dp [ i ] [ 0 ] = 1 ; } dp [ 1 ] [ 1 ] = 1 ; for ( let i = 2 ; i < n * 2 ; i ++ ) { for ( let j = 1 ; j <= k ; j ++ ) dp [ i ] [ j ] = dp [ i - 2 ] [ j ] + dp [ i - 2 ] [ j - 1 ] * ( squares ( i ) - j + 1 ) ; } let ans = 0 ; for ( let i = 0 ; i <= k ; i ++ ) { ans += dp [ n * 2 - 1 ] [ i ] * dp [ n * 2 - 2 ] [ k - i ] ; } return ans ; } let n = 2 ; let k = 2 ; let ans = bishop_placements ( n , k ) ; document . write ( ans ) ;

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Javascript program:
var MAX = 10 ; var F = Array . from ( Array ( MAX ) , ( ) => Array ( MAX ) . fill ( 0 ) ) ; var C = Array ( MAX ) . fill ( 0 ) ; function noOfAssignments ( S , n , i , c_x ) { if ( F [ i ] [ c_x ] != - 1 ) { return F [ i ] [ c_x ] ; } if ( i == n ) { if ( c_x == 1 ) { F [ i ] [ c_x ] = 0 ; } else { F [ i ] [ c_x ] = 1 ; } return F [ i ] [ c_x ] ; } var c_y = C [ i ] - c_x ; if ( S [ i ] == ' ' ) { F [ i ] [ c_x ] = noOfAssignments ( S , n , i + 1 , c_x + 1 ) + noOfAssignments ( S , n , i + 1 , c_x ) ; return F [ i ] [ c_x ] ; } F [ i ] [ c_x ] = 0 ; if ( c_x == 1 ) { F [ i ] [ c_x ] += noOfAssignments ( S , n , i + 1 , c_x - 1 ) ; } if ( c_y == 1 ) { F [ i ] [ c_x ] += noOfAssignments ( S , n , i + 1 , c_x ) ; } return F [ i ] [ c_x ] ; } var S = " " ; var n = S . length ; for ( var i = 0 ; i < MAX ; i ++ ) { for ( var j = 0 ; j < MAX ; j ++ ) { F [ i ] [ j ] = - 1 ; } } C [ 0 ] = 0 ; for ( var i = 0 ; i < n ; ++ i ) { if ( S [ i ] == ' ' ) { C [ i + 1 ] = C [ i ] + 1 ; } else { C [ i + 1 ] = C [ i ] - 1 ; } } document . write ( noOfAssignments ( S , n , 0 , 0 ) + " " ) ;

Index/key variables: c_x, i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
let n = 3 ; function minFallingPathSum ( A ) { for ( let R = n - 2 ; R >= 0 ; -- R ) { for ( let C = 0 ; C < n ; ++ C ) { let best = A [ R + 1 ] [ C ] ; if ( C > 0 ) best = Math . min ( best , A [ R + 1 ] [ C - 1 ] ) ; if ( C + 1 < n ) best = Math . min ( best , A [ R + 1 ] [ C + 1 ] ) ; A [ R ] [ C ] = A [ R ] [ C ] + best ; } } let ans = Number . MAX_VALUE ; for ( let i = 0 ; i < n ; ++ i ) ans = Math . min ( ans , A [ 0 ] [ i ] ) ; return ans ; } let A = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 7 , 8 , 9 ] ] ; document . write ( minFallingPathSum ( A ) ) ;

Index/key variables: C, R, i
Iterator variables: C, R, i
Javascript program:
let N = 100 ; let n = 3 , m = 4 ; function maxPlus ( arr ) { let ans = 0 ; let left = new Array ( N ) ; let right = new Array ( N ) ; let up = new Array ( N ) ; let down = new Array ( N ) ; for ( let i = 0 ; i < N ; i ++ ) { left [ i ] = new Array ( N ) ; right [ i ] = new Array ( N ) ; up [ i ] = new Array ( N ) ; down [ i ] = new Array ( N ) ; for ( let j = 0 ; j < N ; j ++ ) { left [ i ] [ j ] = 0 ; right [ i ] [ j ] = 0 ; up [ i ] [ j ] = 0 ; down [ i ] [ j ] = 0 ; } } for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < m ; j ++ ) { left [ i ] [ j ] = Math . max ( 0 , ( ( j != 0 ) ? left [ i ] [ j - 1 ] : 0 ) ) + arr [ i ] [ j ] ; up [ i ] [ j ] = Math . max ( 0 , ( ( i != 0 ) ? up [ i - 1 ] [ j ] : 0 ) ) + arr [ i ] [ j ] ; } } for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < m ; j ++ ) { right [ i ] [ j ] = Math . max ( 0 , ( j + 1 == m ? 0 : right [ i ] [ j + 1 ] ) ) + arr [ i ] [ j ] ; down [ i ] [ j ] = Math . max ( 0 , ( i + 1 == n ? 0 : down [ i + 1 ] [ j ] ) ) + arr [ i ] [ j ] ; } } for ( let i = 1 ; i < n - 1 ; ++ i ) for ( let j = 1 ; j < m - 1 ; ++ j ) { ans = Math . max ( ans , up [ i - 1 ] [ j ] + down [ i + 1 ] [ j ] + left [ i ] [ j - 1 ] + right [ i ] [ j + 1 ] + arr [ i ] [ j ] ) ; } return ans ; } let arr = [ [ 1 , 1 , 1 , 1 ] , [ - 6 , 1 , 1 , - 4 ] , [ 1 , 1 , 1 , 1 ] ] ; document . write ( maxPlus ( arr ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function countStaircases ( N ) { let memo = new Array ( N + 5 ) ; for ( let i = 0 ; i < N + 5 ; i ++ ) { memo [ i ] = new Array ( N + 5 ) ; for ( let j = 0 ; j < N + 5 ; j ++ ) { memo [ i ] [ j ] = 0 ; } } for ( let i = 0 ; i <= N ; i ++ ) { for ( let j = 0 ; j <= N ; j ++ ) { memo [ i ] [ j ] = 0 ; } } memo [ 3 ] [ 2 ] = memo [ 4 ] [ 2 ] = 1 ; for ( let i = 5 ; i <= N ; i ++ ) { for ( let j = 2 ; j <= i ; j ++ ) { if ( j == 2 ) { memo [ i ] [ j ] = memo [ i - j ] [ j ] + 1 ; } else { memo [ i ] [ j ] = memo [ i - j ] [ j ] + memo [ i - j ] [ j - 1 ] ; } } } let answer = 0 ; for ( let i = 1 ; i <= N ; i ++ ) answer = answer + memo [ N ] [ i ] ; return answer ; } let N = 7 ; document . write ( countStaircases ( N ) ) ;

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function maxCost ( a , n , l , r ) { var mx = 0 , k ; for ( var i = 0 ; i < n ; ++ i ) mx = Math . max ( mx , a [ i ] ) ; var count = new Array ( mx + 1 ) ; count . fill ( 0 ) ; for ( var i = 0 ; i < n ; i ++ ) count [ a [ i ] ] ++ ; var res = new Array ( mx + 1 ) ; res [ 0 ] = 0 ; l = Math . min ( l , r ) ; for ( var num = 1 ; num <= mx ; num ++ ) { k = Math . max ( num - l - 1 , 0 ) ; res [ num ] = Math . max ( res [ num - 1 ] , num * count [ num ] + res [ k ] ) ; } return res [ mx ] ; } var a = [ 2 , 1 , 2 , 3 , 2 , 2 , 1 ] ; var l = 1 , r = 1 ; var n = a . length ; document . write ( maxCost ( a , n , l , r ) ) ;

Index/key variables: i, k, mx, num
Accumulator variables: i, num
Iterator variables: i, num
Javascript program:
function countPaths ( m , n ) { let dp = new Array ( m + 1 ) ; for ( let i = 0 ; i <= m ; i ++ ) { dp [ i ] = new Array ( n + 1 ) ; for ( let j = 0 ; j <= n ; j ++ ) { dp [ i ] [ j ] = 0 ; } } for ( let i = 1 ; i <= m ; i ++ ) { for ( let j = 1 ; j <= n ; j ++ ) { if ( i == 1 j == 1 ) dp [ i ] [ j ] = 1 ; else dp [ i ] [ j ] = dp [ i - 1 ] [ j ] + dp [ i ] [ j - 1 ] ; } } return dp [ m ] [ n ] ; } let n = 5 ; let m = 5 ; document . write ( countPaths ( n , m ) ) ;

Index/key variables: i, j, m, n
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function binomialCoeff ( n , k ) { var res = 1 ; if ( k > n - k ) k = n - k ; for ( i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } function catalan ( n ) { var c = binomialCoeff ( 2 * n , n ) ; return c / ( n + 1 ) ; } var n = 3 ; document . write ( catalan ( n ) ) ;

Accumulator variables: res
Iterator variables: i
Javascript program:
function alternateFib ( n ) { if ( n < 0 ) return ; var f1 = 0 ; var f2 = 1 ; document . write ( f1 + " " ) ; for ( i = 2 ; i <= n ; i ++ ) { var f3 = f2 + f1 ; if ( i % 2 == 0 ) document . write ( f3 + " " ) ; f1 = f2 ; f2 = f3 ; } } var N = 15 ; alternateFib ( N ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function totalWays ( N , M , X ) { let dp = new Array ( N + 1 ) ; for ( let i = 0 ; i < N + 1 ; i ++ ) { dp [ i ] = new Array ( 2 ) ; for ( let j = 0 ; j < 2 ; j ++ ) { dp [ i ] [ j ] = 0 ; } } if ( X == 1 ) { dp [ 0 ] [ 0 ] = 1 ; } else { dp [ 0 ] [ 1 ] = 0 ; } if ( X == 1 ) { dp [ 1 ] [ 0 ] = 0 ; dp [ 1 ] [ 1 ] = M - 1 ; } else { dp [ 1 ] [ 0 ] = 1 ; dp [ 1 ] [ 1 ] = ( M - 2 ) ; } for ( let i = 2 ; i < N ; i ++ ) { dp [ i ] [ 0 ] = dp [ i - 1 ] [ 1 ] ; dp [ i ] [ 1 ] = dp [ i - 1 ] [ 0 ] * ( M - 1 ) + dp [ i - 1 ] [ 1 ] * ( M - 2 ) ; } return dp [ N - 1 ] [ 0 ] ; } let N = 4 , M = 3 , X = 2 ; document . write ( totalWays ( N , M , X ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function fib ( n ) { let term = new Array ( 1000 ) ; term . fill ( 0 ) ; if ( n <= 1 ) return n ; if ( term [ n ] != 0 ) return term [ n ] ; else { term [ n ] = fib ( n - 1 ) + fib ( n - 2 ) ; return term [ n ] ; } } let n = 6 ; document . write ( fib ( n ) ) ;

Index/key variables: n
Javascript program:
function minimumNumberOfDigits ( a , b ) { if ( a > b a < 0 b < 0 a > 900 b > 8100 ) return - 1 ; if ( a == 0 && b == 0 ) return 0 ; if ( dp [ a ] [ b ] != - 1 ) return dp [ a ] [ b ] ; var ans = 101 ; for ( var i = 9 ; i >= 1 ; i -- ) { var k = minimumNumberOfDigits ( a - i , b - ( i * i ) ) ; if ( k != - 1 ) ans = Math . min ( ans , k + 1 ) ; } return dp [ a ] [ b ] = ans ; } function printSmallestNumber ( a , b ) { dp = new Array ( 901 ) . fill ( - 1 ) . map ( ( ) => new Array ( 8101 ) . fill ( - 1 ) ) ; ; dp [ 0 ] [ 0 ] = 0 ; var k = minimumNumberOfDigits ( a , b ) ; if ( k == - 1 k > 100 ) document . write ( " " ) ; else { while ( a > 0 && b > 0 ) { for ( var i = 1 ; i <= 9 ; i ++ ) { if ( a >= i && b >= i * i && 1 + dp [ a - i ] [ b - i * i ] == dp [ a ] [ b ] ) { document . write ( i ) ; a -= i ; b -= i * i ; break ; } } } } } var a = 18 , b = 162 ; printSmallestNumber ( a , b ) ;

Index/key variables: a, b
Accumulator variables: a, b, i
Iterator variables: i
Javascript program:
let MAX = 100 ; function binomialCoeff ( 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 sumOfproduct ( n ) { return binomialCoeff ( 2 * n , n - 1 ) ; } let n = 3 ; document . write ( sumOfproduct ( n ) ) ;

Index/key variables: j, k
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
var MAX = 100 ; function check ( i , sum , n , k , a , dp ) { if ( sum <= 0 ) return false ; if ( i >= n ) { if ( sum == k ) return true ; return false ; } if ( dp [ i ] [ sum ] != - 1 ) return dp [ i ] [ sum ] ; dp [ i ] [ sum ] = check ( i + 1 , sum - 2 * a [ i ] , n , k , a , dp ) || check ( i + 1 , sum , n , k , a , dp ) ; dp [ i ] [ sum ] = check ( i + 1 , sum - ( i + 1 ) , n , k , a , dp ) || dp [ i ] [ sum ] ; dp [ i ] [ sum ] = check ( i + 1 , sum + i + 1 , n , k , a , dp ) || dp [ i ] [ sum ] ; return dp [ i ] [ sum ] ; } function wrapper ( n , k , a ) { var sum = 0 ; for ( var i = 0 ; i < n ; i ++ ) sum += a [ i ] ; var dp = Array . from ( Array ( MAX ) , ( ) => Array ( MAX ) . fill ( - 1 ) ) ; return check ( 0 , sum , n , k , a , dp ) ; } var a = [ 1 , 2 , 3 , 4 ] ; var n = 4 , k = 5 ; ( wrapper ( n , k , a ) ? ( document . write ( " " ) ) : ( document . write ( " " ) ) ) ;

Index/key variables: i, sum
Accumulator variables: i, sum
Iterator variables: i
Javascript program:
function fib ( n ) { let a = 0 , b = 1 , c ; if ( n >= 0 ) document . write ( a + " " ) ; if ( n >= 1 ) document . write ( b + " " ) ; for ( let i = 2 ; i <= n ; i ++ ) { c = a + b ; document . write ( c + " " ) ; a = b ; b = c ; } } fib ( 9 ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function pre_compute ( a , n , index , k ) { let dp = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { dp [ i ] = new Array ( n ) ; for ( let j = 0 ; j < n ; j ++ ) { dp [ i ] [ j ] = 0 ; } } for ( let i = 0 ; i < n ; i ++ ) { if ( a [ i ] > a [ 0 ] ) dp [ 0 ] [ i ] = a [ i ] + a [ 0 ] ; else dp [ 0 ] [ i ] = a [ i ] ; } for ( let i = 1 ; i < n ; i ++ ) { for ( let j = 0 ; j < n ; j ++ ) { if ( a [ j ] > a [ i ] && j > i ) { if ( dp [ i - 1 ] [ i ] + a [ j ] > dp [ i - 1 ] [ j ] ) dp [ i ] [ j ] = dp [ i - 1 ] [ i ] + a [ j ] ; else dp [ i ] [ j ] = dp [ i - 1 ] [ j ] ; } else dp [ i ] [ j ] = dp [ i - 1 ] [ j ] ; } } return dp [ index ] [ k ] ; } let a = [ 1 , 101 , 2 , 3 , 100 , 4 , 5 ] ; let n = a . length ; let index = 4 , k = 6 ; document . write ( pre_compute ( a , n , index , k ) ) ;

Index/key variables: i, index, j, k
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function gen ( n ) { let S = new Array ( n + 1 ) ; S . fill ( 0 ) ; S [ 0 ] = 0 ; if ( n != 0 ) S [ 1 ] = 1 ; for ( let i = 2 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) S [ i ] = 4 * S [ parseInt ( i / 2 , 10 ) ] ; else S [ i ] = 4 * S [ parseInt ( i / 2 , 10 ) ] + 1 ; } return S [ n ] ; } function moserDeBruijn ( n ) { for ( let i = 0 ; i < n ; i ++ ) document . write ( gen ( i ) + " " ) ; } let n = 15 ; document . write ( " " + n + " " + " " + " " ) ; moserDeBruijn ( n ) ;

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Javascript program:
function LCSubStr ( X , Y ) { var m = X . length ; var n = Y . length ; var result = 0 ; var len = Array . from ( Array ( 2 ) , ( ) => Array ( n ) ) ; var currRow = 0 ; for ( var i = 0 ; i <= m ; i ++ ) { for ( var j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) { len [ currRow ] [ j ] = 0 ; } else if ( X [ i - 1 ] == Y [ j - 1 ] ) { len [ currRow ] [ j ] = len [ 1 - currRow ] [ j - 1 ] + 1 ; result = Math . max ( result , len [ currRow ] [ j ] ) ; } else { len [ currRow ] [ j ] = 0 ; } } currRow = 1 - currRow ; } return result ; } var X = " " ; var Y = " " ; document . write ( LCSubStr ( X , Y ) ) ;

Index/key variables: currRow, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function func ( n , m , A ) { let ModArray = [ ] ; for ( let i = 0 ; i < n ; i ++ ) ModArray . push ( 0 ) ; let sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { ModArray [ i ] = A [ i ] % m ; sum += ModArray [ i ] ; } sum = sum % m ; if ( sum % m == 0 ) { document . write ( " " ) ; return ; } if ( sum % 2 != 0 ) { document . write ( " " ) ; } else { ModArray . shift ( ) ; let i = 0 ; let j = ModArray . length - 1 ; ModArray . sort ( function ( a , b ) { return a - b } ) ; sum = parseInt ( sum / 2 , 10 ) ; let i1 , i2 ; while ( i <= j ) { let s = ModArray [ i ] + ModArray [ j ] ; if ( s == sum ) { i1 = i ; i2 = j ; document . write ( " " ) ; break ; } else if ( s > sum ) j -- ; else i ++ ; } } } let m = 2 ; let a = [ 1 , 3 , 9 ] ; let n = a . length ; func ( n , m , a ) ;

Index/key variables: i, j
Accumulator variables: i, j, sum
Iterator variables: i
Javascript program:
function printGolomb ( n ) { let dp = Array ( n + 1 ) . fill ( 0 ) ; dp [ 1 ] = 1 ; document . write ( dp [ 1 ] + " " ) ; for ( i = 2 ; i <= n ; i ++ ) { dp [ i ] = 1 + dp [ i - dp [ dp [ i - 1 ] ] ] ; document . write ( dp [ i ] + " " ) ; } } let n = 9 ; printGolomb ( n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let N = 1000 ; function arrangeBraces ( n , pos , k ) { let h = new Array ( N ) ; h . fill ( false ) ; let dp = new Array ( N ) ; for ( let i = 0 ; i < N ; i ++ ) { dp [ i ] = new Array ( N ) ; for ( let j = 0 ; j < N ; j ++ ) { dp [ i ] [ j ] = 0 ; } } for ( let i = 0 ; i < k ; i ++ ) { h [ pos [ i ] ] = true ; } dp [ 0 ] [ 0 ] = 1 ; for ( let i = 1 ; i <= 2 * n ; i ++ ) { for ( let j = 0 ; j <= 2 * n ; j ++ ) { if ( h [ i ] ) { if ( j != 0 ) { dp [ i ] [ j ] = dp [ i - 1 ] [ j - 1 ] ; } else { dp [ i ] [ j ] = 0 ; } } else if ( j != 0 ) { dp [ i ] [ j ] = dp [ i - 1 ] [ j - 1 ] + dp [ i - 1 ] [ j + 1 ] ; } else { dp [ i ] [ j ] = dp [ i - 1 ] [ j + 1 ] ; } } } return dp [ 2 * n ] [ 0 ] ; } let n = 3 ; let pos = [ 2 ] ; let k = pos . length ; document . write ( arrangeBraces ( n , pos , k ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function findLength ( str , n ) { let current_sum = 0 ; let max_sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { current_sum += ( str [ i ] == ' ' ? 1 : - 1 ) ; if ( current_sum < 0 ) { current_sum = 0 ; } max_sum = Math . max ( current_sum , max_sum ) ; } return max_sum == 0 ? - 1 : max_sum ; } let str = " " ; let n = str . length ; document . write ( findLength ( str , n ) ) ;

Index/key variables: i
Accumulator variables: current_sum, i
Iterator variables: i
Javascript program:
function chordCnt ( A ) { var n = 2 * A ; var dpArray = Array ( n + 1 ) . fill ( 0 ) ; dpArray [ 0 ] = 1 ; dpArray [ 2 ] = 1 ; for ( var i = 4 ; i <= n ; i += 2 ) { for ( var j = 0 ; j < i - 1 ; j += 2 ) { dpArray [ i ] += ( dpArray [ j ] * dpArray [ i - 2 - j ] ) ; } } return dpArray [ n ] ; } var N ; N = 2 ; document . write ( chordCnt ( N ) + ' ' ) ; N = 1 ; document . write ( chordCnt ( N ) + ' ' ) ; N = 4 ; document . write ( chordCnt ( N ) + ' ' ) ;

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
var arr = [ [ 5 ] , [ 5 ] ] function isPath ( arr ) { arr [ 0 ] [ 0 ] = 1 ; for ( var i = 1 ; i < 5 ; i ++ ) if ( arr [ i ] [ 0 ] != - 1 ) arr [ i ] [ 0 ] = arr [ i - 1 ] [ 0 ] ; for ( var j = 1 ; j < 5 ; j ++ ) if ( arr [ 0 ] [ j ] != - 1 ) arr [ 0 ] [ j ] = arr [ 0 ] [ j - 1 ] ; for ( var i = 1 ; i < 5 ; i ++ ) for ( var j = 1 ; j < 5 ; j ++ ) if ( arr [ i ] [ j ] != - 1 ) arr [ i ] [ j ] = Math . max ( arr [ i ] [ j - 1 ] , arr [ i - 1 ] [ j ] ) ; return ( arr [ 5 - 1 ] [ 5 - 1 ] == 1 ) ; } var arr = [ [ 0 , 0 , 0 , - 1 , 0 ] , [ - 1 , 0 , 0 , - 1 , - 1 ] , [ 0 , 0 , 0 , - 1 , 0 ] , [ - 1 , 0 , - 1 , 0 , - 1 ] , [ 0 , 0 , - 1 , 0 , 0 ] ] ; if ( isPath ( arr ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function nswp ( n ) { let dp = new Array ( n + 1 ) ; dp [ 0 ] = dp [ 1 ] = 1 ; for ( let i = 2 ; i <= n ; i ++ ) dp [ i ] = 2 * dp [ i - 1 ] + dp [ i - 2 ] ; return dp [ n ] ; } let n = 3 ; document . write ( nswp ( n ) ) ;

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX = 256 ; function numberofways ( A , B , N , M ) { let pos = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) pos [ i ] = [ ] ; for ( let i = 0 ; i < M ; i ++ ) pos [ B [ i ] . charCodeAt ( 0 ) ] . push ( i + 1 ) ; let dpl = new Array ( N + 2 ) ; for ( let i = 0 ; i < N + 2 ; i ++ ) { dpl [ i ] = new Array ( M + 2 ) ; for ( let j = 0 ; j < M + 2 ; j ++ ) dpl [ i ] [ j ] = 0 ; } for ( let i = 1 ; i <= N ; i ++ ) { for ( let j = 1 ; j <= M ; j ++ ) { if ( A [ i - 1 ] == B [ j - 1 ] ) dpl [ i ] [ j ] = dpl [ i - 1 ] [ j - 1 ] + 1 ; else dpl [ i ] [ j ] = Math . max ( dpl [ i - 1 ] [ j ] , dpl [ i ] [ j - 1 ] ) ; } } let LCS = dpl [ N ] [ M ] ; let dpr = new Array ( N + 2 ) ; for ( let i = 0 ; i < N + 2 ; i ++ ) { dpr [ i ] = new Array ( M + 2 ) ; for ( let j = 0 ; j < M + 2 ; j ++ ) dpr [ i ] [ j ] = 0 ; } for ( let i = N ; i >= 1 ; i -- ) { for ( let j = M ; j >= 1 ; j -- ) { if ( A [ i - 1 ] == B [ j - 1 ] ) dpr [ i ] [ j ] = dpr [ i + 1 ] [ j + 1 ] + 1 ; else dpr [ i ] [ j ] = Math . max ( dpr [ i + 1 ] [ j ] , dpr [ i ] [ j + 1 ] ) ; } } let ans = 0 ; for ( let i = 0 ; i <= N ; i ++ ) { for ( let j = 0 ; j < MAX ; j ++ ) { for ( let x = 0 ; x < pos [ j ] . length ; x ++ ) { if ( dpl [ i ] [ pos [ j ] [ x ] - 1 ] + dpr [ i + 1 ] [ pos [ j ] [ x ] + 1 ] == LCS ) { ans ++ ; break ; } } } } return ans ; } let A = " " , B = " " ; let N = A . length , M = B . length ; document . write ( numberofways ( A , B , N , M ) ) ;

Index/key variables: M, N, i, j, x
Accumulator variables: ans, i, j, x
Iterator variables: i, j, x
Javascript program:
function lcs ( X , Y , m , n ) { let L = new Array ( m + 1 ) ; for ( let i = 0 ; i <= m ; ++ i ) { L [ i ] = new Array ( n + 1 ) ; for ( let j = 0 ; j <= n ; j ++ ) { L [ i ] [ j ] = 0 ; } } for ( let i = 0 ; i <= m ; ++ i ) { for ( let j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) L [ i ] [ j ] = 0 ; else if ( X [ i - 1 ] == Y [ j - 1 ] ) L [ i ] [ j ] = L [ i - 1 ] [ j - 1 ] + 2 * ( X [ i - 1 ] - ' ' ) ; else L [ i ] [ j ] = L [ i - 1 ] [ j ] > L [ i ] [ j - 1 ] ? L [ i - 1 ] [ j ] : L [ i ] [ j - 1 ] ; } } return L [ m ] [ n ] ; } function findMinCost ( X , Y ) { let m = X . length , n = Y . length ; let cost = 0 ; for ( let i = 0 ; i < m ; ++ i ) cost += X [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; for ( let i = 0 ; i < n ; ++ i ) cost += Y [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ; return cost - lcs ( X , Y , m , n ) ; } let X = ( " " ) . split ( ' ' ) ; let Y = ( " " ) . split ( ' ' ) ; document . write ( " " + " " + findMinCost ( X , Y ) ) ;

Index/key variables: i, j, m, n
Accumulator variables: cost, j
Iterator variables: i, j
Javascript program:
function isSubSeqDivisible ( str ) { let i , j , k , l = str . length ; let arr = [ ] ; for ( i = 0 ; i < l ; i ++ ) arr [ i ] = str [ i ] - ' ' ; for ( i = 0 ; i < l ; i ++ ) { for ( j = i ; j < l ; j ++ ) { for ( k = j ; k < l ; k ++ ) { if ( arr [ i ] % 8 == 0 ) return true ; else if ( ( arr [ i ] * 10 + arr [ j ] ) % 8 == 0 && i != j ) return true ; else if ( ( arr [ i ] * 100 + arr [ j ] * 10 + arr [ k ] ) % 8 == 0 && i != j && j != k && i != k ) return true ; } } } return false ; } let str = " " ; if ( isSubSeqDivisible ( str ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Javascript program:
function isSubSeqDivisible ( str ) { let n = str . length ; let dp = new Array ( n + 1 ) ; for ( let i = 0 ; i < 10 ; i ++ ) { dp [ i ] = new Array ( 10 ) ; for ( let j = 0 ; j < 10 ; j ++ ) { dp [ i ] [ j ] = 0 ; } } let arr = new Array ( n + 1 ) ; for ( let i = 1 ; i <= n ; i ++ ) arr [ i ] = ( str [ i - 1 ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) ; for ( let i = 1 ; i <= n ; i ++ ) { dp [ i ] [ arr [ i ] % 8 ] = 1 ; for ( let j = 0 ; j < 8 ; j ++ ) { if ( dp [ i - 1 ] [ j ] > dp [ i ] [ ( j * 10 + arr [ i ] ) % 8 ] ) dp [ i ] [ ( j * 10 + arr [ i ] ) % 8 ] = dp [ i - 1 ] [ j ] ; if ( dp [ i - 1 ] [ j ] > dp [ i ] [ j ] ) dp [ i ] [ j ] = dp [ i - 1 ] [ j ] ; } } for ( let i = 1 ; i <= n ; i ++ ) { if ( dp [ i ] [ 0 ] == 1 ) return true ; } return false ; } let str = " " ; if ( isSubSeqDivisible ( str ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
let str = " " ; let mp = new Map ( ) ; let no = 8 ; while ( no < 100 ) { no = no + 8 ; mp . set ( ( Math . floor ( no / 10 ) ) % 10 , no % 10 ) ; } let visited = new Array ( 10 ) ; for ( let i = 0 ; i < visited . length ; i ++ ) { visited [ i ] = false ; } let i ; for ( i = str . length - 1 ; i >= 0 ; i -- ) { if ( str [ i ] == ' ' ) { document . write ( " " ) ; break ; } if ( visited [ mp . get ( str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ] ) { document . write ( " " ) ; break ; } visited [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] = true ; } if ( i == - 1 ) document . write ( " " ) ;

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