dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function countkDist ( str , k ) { var res = 0 ; var n = str . length ; var cnt = Array . from ( { length : 26 } , ( _ , i ) => 0 ) ; for ( i = 0 ; i < n ; i ++ ) { var dist_count = 0 ; for ( j = i ; j < n ; j ++ ) { if ( cnt [ str . charAt ( j ) . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] == 0 ) dist_count ++ ; cnt [ str . charAt ( j ) . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; if ( dist_count == k ) res ++ ; } } return res ; } var ch = " " ; var k = 3 ; document . write ( " " + k + " " + countkDist ( ch , k ) ) ;

Accumulator variables: dist_count, i, j, res
Iterator variables: i, j
Javascript program:
function to_upper ( input ) { var result = new Array ( input . length ) ; for ( var i = 0 ; i < input . length ; i ++ ) if ( " " . charCodeAt ( 0 ) <= input [ i ] . charCodeAt ( 0 ) <= " " . charCodeAt ( 0 ) ) result [ i ] = String . fromCharCode ( input [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) + " " . charCodeAt ( 0 ) ) ; return result . join ( " " ) . toString ( ) ; } var str = " " ; document . write ( to_upper ( str ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findMinLength ( arr , n ) { let min = arr [ 0 ] . length ; for ( let i = 1 ; i < n ; i ++ ) { if ( arr [ i ] . length < min ) { min = arr [ i ] . length ; } } return ( min ) ; } function commonPrefix ( arr , n ) { let minlen = findMinLength ( arr , n ) ; let result = " " ; for ( let i = 0 ; i < minlen ; i ++ ) { current = arr [ 0 ] [ i ] ; for ( let j = 1 ; j < n ; j ++ ) { if ( arr [ j ] [ i ] != current ) { return result ; } } result += ( current ) ; } return ( result ) ; } let arr = [ " " , " " , " " , " " ] let n = arr . length ; let ans = commonPrefix ( arr , n ) ; if ( ans . length > 0 ) { document . write ( " " + ans ) ; } else { document . write ( " " ) ; }

Index/key variables: i, j
Accumulator variables: i, j, result
Iterator variables: i, j
Javascript program:
function printZigZagConcat ( str , n ) { if ( n == 1 ) { document . write ( str ) ; return ; } let str1 = str . split ( " " ) ; let len = str . length ; let arr = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { arr [ i ] = " " ; } let row = 0 ; let down = true ; for ( let i = 0 ; i < len ; ++ i ) { arr [ row ] += ( str1 [ i ] ) ; if ( row == n - 1 ) { down = false ; } else if ( row == 0 ) { down = true ; } if ( down ) { row ++ ; } else { row -- ; } } for ( let i = 0 ; i < n ; ++ i ) { document . write ( arr [ i ] ) ; } } let str = " " ; let n = 3 ; printZigZagConcat ( str , n ) ;

Index/key variables: i, row
Accumulator variables: i, row
Iterator variables: i
Boolean variables: down
Javascript program:
function isPalin ( str , st , end ) { while ( st < end ) { if ( str [ st ] != str [ end ] ) return false ; st ++ ; end -- ; } return true ; } function findMinInsert ( str , n ) { for ( let i = n - 1 ; i >= 0 ; i -- ) { if ( isPalin ( str , 0 , i ) ) return ( n - i - 1 ) ; } } let Input = " " ; document . write ( findMinInsert ( Input , Input . length ) ) ;

Index/key variables: end, st
Accumulator variables: end, i, st
Iterator variables: i
Javascript program:
function removeRecur ( n ) { let prev_digit = n % 10 ; let pow = 10 ; let res = prev_digit ; while ( n > 0 ) { let curr_digit = n % 10 ; if ( curr_digit != prev_digit ) { res += curr_digit * pow ; prev_digit = curr_digit ; pow *= 10 ; } n = parseInt ( n / 10 , 10 ) ; } return res ; } let n = 12224 ; document . write ( removeRecur ( n ) ) ;

Accumulator variables: pow, res
Javascript program:
function myAtoi ( str ) { var sign = 1 , base = 0 , i = 0 ; while ( str [ i ] == ' ' ) { i ++ ; } if ( str [ i ] == ' ' str [ i ] == ' ' ) { sign = 1 - 2 * ( str [ i ++ ] == ' ' ) ; } while ( str [ i ] >= ' ' && str [ i ] <= ' ' ) { if ( base > Number . MAX_VALUE / 10 || ( base == Number . MAX_VALUE / 10 && str [ i ] - ' ' > 7 ) ) { if ( sign == 1 ) return Number . MAX_VALUE ; else return Number . MAX_VALUE ; } base = 10 * base + ( str [ i ++ ] - ' ' ) ; } return base * sign ; } var str = " " ; var val = myAtoi ( str ) ; document . write ( " " , val ) ;

Index/key variables: i
Accumulator variables: i
Javascript program:
let NO_OF_CHARS = 256 ; function areAnagram ( str1 , str2 ) { let count = new Array ( NO_OF_CHARS ) ; for ( let i = 0 ; i < NO_OF_CHARS ; i ++ ) { count [ i ] = 0 ; } let i ; for ( i = 0 ; i < str1 . length ; i ++ ) { count [ str1 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; count [ str2 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] -- ; } if ( str1 . length != str2 . length ) return false ; for ( i = 0 ; i < NO_OF_CHARS ; i ++ ) if ( count [ i ] != 0 ) { return false ; } return true ; } let str1 = " " . split ( " " ) ; let str2 = " " . split ( " " ) ; if ( areAnagram ( str1 , str2 ) ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function unique ( s ) { let str = " " ; let len = s . length ; for ( let i = 0 ; i < len ; i ++ ) { let c = s [ i ] ; if ( str . indexOf ( c ) < 0 ) { str += c ; } } return str ; } let s = " " ; document . write ( unique ( s ) ) ;

Index/key variables: i
Accumulator variables: i, str
Iterator variables: i
Javascript program:
function isPerfect ( x ) { var sum_div = 1 ; for ( i = 2 ; i <= x / 2 ; ++ i ) { if ( x % i == 0 ) { sum_div += i ; } } if ( sum_div == x ) { return 1 ; } else return 0 ; } function subsetSum ( arr , l , r , sum ) { if ( l > r ) { if ( isPerfect ( sum ) != 0 ) { document . write ( sum + " " ) ; } return ; } subsetSum ( arr , l + 1 , r , sum + arr [ l ] ) ; subsetSum ( arr , l + 1 , r , sum ) ; } var arr = [ 5 , 4 , 6 ] ; var N = arr . length ; subsetSum ( arr , 0 , N - 1 , 0 ) ;

Index/key variables: l
Accumulator variables: sum_div
Iterator variables: i
Javascript program:
function PartitionSub ( arr , i , N , K , nos , v ) { if ( i >= N ) { if ( nos == K ) { for ( let x = 0 ; x < v . length ; x ++ ) { document . write ( " " ) ; for ( let y = 0 ; y < v [ x ] . length ; y ++ ) { document . write ( v [ x ] [ y ] ) ; if ( y == v [ x ] . length - 1 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } if ( x == v . length - 1 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } document . write ( " " ) ; } return ; } for ( let j = 0 ; j < K ; j ++ ) { if ( v [ j ] . length > 0 ) { v [ j ] . push ( arr [ i ] ) ; PartitionSub ( arr , i + 1 , N , K , nos , v ) ; v [ j ] . pop ( ) ; } else { v [ j ] . push ( arr [ i ] ) ; PartitionSub ( arr , i + 1 , N , K , nos + 1 , v ) ; v [ j ] . pop ( ) ; break ; } } } function partKSubsets ( arr , N , K ) { let v = [ ] ; for ( let i = 0 ; i < K ; i ++ ) v . push ( [ ] ) ; if ( K == 0 K > N ) { document . write ( " " + " " ) ; } else { document . write ( " " + " " ) ; PartitionSub ( arr , 0 , N , K , 0 , v ) ; } } let arr = [ 1 , 2 , 3 , 4 ] ; let K = 2 ; let N = arr . length ; partKSubsets ( arr , N , K ) ;

Index/key variables: i, j, x, y
Accumulator variables: i, j, x, y
Iterator variables: i, j, x, y
Javascript program:
let MAX = 100 ; let store = new Array ( MAX ) ; store . fill ( 0 ) ; let n ; let graph = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) { graph [ i ] = new Array ( MAX ) ; } let d = new Array ( MAX ) ; d . fill ( 0 ) ; let ans ; function SieveOfEratosthenes ( prime , p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( let p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( let i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } function is_clique ( b ) { for ( let i = 1 ; i < b ; i ++ ) { for ( let j = i + 1 ; j < b ; j ++ ) if ( graph [ store [ i ] ] [ store [ j ] ] == 0 ) { return false ; } } return true ; } function primeCliques ( i , l , prime ) { for ( let j = i + 1 ; j <= n ; j ++ ) { store [ l ] = j ; if ( is_clique ( l + 1 ) ) { if ( prime [ l ] ) ans ++ ; else { ans -= 1.3 ; } primeCliques ( j , l + 1 , prime ) ; } } } let edges = [ [ 1 , 2 ] , [ 2 , 3 ] , [ 3 , 1 ] , [ 4 , 3 ] , [ 4 , 5 ] , [ 5 , 3 ] ] ; let size = edges . length ; n = 5 ; let prime = new Array ( n + 1 ) ; for ( let i = 0 ; i < prime . length ; i ++ ) prime [ i ] = true ; SieveOfEratosthenes ( prime , n ) ; for ( let i = 0 ; i < size ; i ++ ) { graph [ edges [ i ] [ 0 ] , edges [ i ] [ 1 ] ] = 1 ; graph [ edges [ i ] [ 1 ] , edges [ i ] [ 0 ] ] = 1 ; d [ edges [ i ] [ 0 ] ] ++ ; d [ edges [ i ] [ 1 ] ] ++ ; } ans = 0 ; primeCliques ( 0 , 1 , prime ) ; document . write ( ans ) ;

Index/key variables: i, j, l, p
Accumulator variables: ans, i, j, p
Iterator variables: i, j, p
Javascript program:
var dim = 3 ; class Node { constructor ( ) { this . data = 0 ; this . next = null ; this . prev = null ; this . up = null ; this . down = null ; } } function createNode ( data ) { temp = new Node ( ) ; temp . data = data ; temp . next = null ; temp . prev = null ; temp . up = null ; temp . down = null ; return temp ; } function constructDoublyListUtil ( mtrx , i , j , curr ) { if ( i >= dim j >= dim ) { return null ; } var temp = createNode ( mtrx [ i ] [ j ] ) ; temp . prev = curr ; temp . up = curr ; temp . next = constructDoublyListUtil ( mtrx , i , j + 1 , temp ) ; temp . down = constructDoublyListUtil ( mtrx , i + 1 , j , temp ) ; return temp ; } function constructDoublyList ( mtrx ) { return constructDoublyListUtil ( mtrx , 0 , 0 , null ) ; } function display ( head ) { rPtr = null ; dPtr = head ; while ( dPtr != null ) { rPtr = dPtr ; while ( rPtr != null ) { document . write ( rPtr . data + " " ) ; rPtr = rPtr . next ; } document . write ( " " ) ; dPtr = dPtr . down ; } } var mtrx = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 7 , 8 , 9 ] ] ; var list = constructDoublyList ( mtrx ) ; display ( list ) ;

Index/key variables: i, j
Class/struct names: Node
Javascript program:
class Node { constructor ( key ) { this . left = null ; this . right = null ; this . key = key ; } } function newNode ( key ) { let temp = new Node ( key ) ; return ( temp ) ; } function find_x ( n ) { if ( n == 1 ) return 1 ; let num , den , p ; num = Math . log10 ( n ) ; let x = 0 , no = 0 ; for ( let i = 2 ; i <= n ; i ++ ) { den = Math . log10 ( i ) ; p = num / den ; no = parseInt ( Math . pow ( i , parseInt ( p , 10 ) ) , 10 ) ; if ( Math . abs ( no - n ) < 1e-6 ) { x = i ; break ; } } return x ; } function is_key ( n , x ) { let p ; p = Math . log10 ( n ) / Math . log10 ( x ) ; let no = parseInt ( Math . pow ( x , parseInt ( p , 10 ) ) , 10 ) ; if ( n == no ) return true ; return false ; } function evenPaths ( node , count , x ) { if ( node == null || ! is_key ( node . key , x ) ) { return count ; } if ( node . left == null && node . right == null ) { count ++ ; } count = evenPaths ( node . left , count , x ) ; return evenPaths ( node . right , count , x ) ; } function countExpPaths ( node , x ) { return evenPaths ( node , 0 , x ) ; } let root = newNode ( 27 ) ; root . left = newNode ( 9 ) ; root . right = newNode ( 81 ) ; root . left . left = newNode ( 3 ) ; root . left . right = newNode ( 10 ) ; root . right . left = newNode ( 70 ) ; root . right . right = newNode ( 243 ) ; root . right . right . left = newNode ( 81 ) ; root . right . right . right = newNode ( 909 ) ; let x = find_x ( root . key ) ; document . write ( countExpPaths ( root , x ) ) ;

Accumulator variables: count, i
Iterator variables: i
Class/struct names: Node
Javascript program:
let N = 1000001 ; let c , n , m , a , b ; function dfs ( a , b , v , vis ) { vis [ a ] = 1 ; c ++ ; for ( let i of v [ a ] ) { if ( vis [ i ] == 0 && i != b ) dfs ( i , b , v , vis ) ; } } function Calculate ( v ) { let vis = new Array ( n + 1 ) ; for ( let i = 0 ; i < n + 1 ; i ++ ) vis [ i ] = 0 ; c = 0 ; dfs ( a , b , v , vis ) ; let ans1 = n - c - 1 ; for ( let i = 0 ; i < n + 1 ; i ++ ) vis [ i ] = 0 ; c = 0 ; dfs ( b , a , v , vis ) ; let ans2 = n - c - 1 ; document . write ( ( ans1 * ans2 ) + " " ) ; } n = 7 ; m = 7 ; a = 3 ; b = 5 ; let edges = [ [ 1 , 2 ] , [ 2 , 3 ] , [ 3 , 4 ] , [ 4 , 5 ] , [ 5 , 6 ] , [ 6 , 7 ] , [ 7 , 5 ] ] ; let v = new Array ( n + 1 ) ; for ( let i = 0 ; i <= n ; i ++ ) { v [ i ] = [ ] ; } for ( let i = 0 ; i < m ; i ++ ) { v [ edges [ i ] [ 0 ] ] . push ( edges [ i ] [ 1 ] ) ; v [ edges [ i ] [ 1 ] ] . push ( edges [ i ] [ 0 ] ) ; } Calculate ( v ) ;

Index/key variables: a, i
Accumulator variables: c, i
Iterator variables: i
Javascript program:
var V = 4 ; var ans = 1000000000 ; function tsp ( graph , currPos , n , count , cost ) { if ( count == n && graph [ currPos ] [ 0 ] ) { ans = Math . min ( ans , cost + graph [ currPos ] [ 0 ] ) ; return ; } for ( var i = 0 ; i < n ; i ++ ) { if ( ! v [ i ] && graph [ currPos ] [ i ] ) { v [ i ] = true ; tsp ( graph , i , n , count + 1 , cost + graph [ currPos ] [ i ] ) ; v [ i ] = false ; } } } ; var n = 4 ; var graph = [ [ 0 , 10 , 15 , 20 ] , [ 10 , 0 , 35 , 25 ] , [ 15 , 35 , 0 , 30 ] , [ 20 , 25 , 30 , 0 ] ] ; var v = Array ( n ) . fill ( false ) ; v [ 0 ] = true ; tsp ( graph , 0 , n , 1 , 0 ) ; document . write ( ans ) ;

Index/key variables: currPos, i
Accumulator variables: i
Iterator variables: i
Javascript program:
function printTheArray ( arr , n ) { for ( let i = 0 ; i < n ; i ++ ) { document . write ( arr [ i ] + " " ) ; } document . write ( " " ) ; } function generateAllBinaryStrings ( n , arr , i ) { if ( i == n ) { printTheArray ( arr , n ) ; return ; } arr [ i ] = 0 ; generateAllBinaryStrings ( n , arr , i + 1 ) ; arr [ i ] = 1 ; generateAllBinaryStrings ( n , arr , i + 1 ) ; } let n = 4 ; let arr = new Array ( n ) ; arr . fill ( 0 ) ; generateAllBinaryStrings ( n , arr , 0 ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function printResult ( result , len ) { for ( var i = 0 ; i <= len ; i ++ ) document . write ( result [ i ] ) ; document . write ( " " ) ; } function stringCombination ( result , str , count , level , size , len ) { if ( level === size ) return ; for ( var i = 0 ; i < len ; i ++ ) { if ( count [ i ] === 0 ) continue ; count [ i ] -- ; result [ level ] = str [ i ] ; printResult ( result , level ) ; stringCombination ( result , str , count , level + 1 , size , len ) ; count [ i ] ++ ; } } function combination ( str ) { var i ; var mp = { } ; for ( i = 0 ; i < str . length ; i ++ ) if ( mp . hasOwnProperty ( str [ i ] ) ) mp [ str [ i ] ] = mp [ str [ i ] ] + 1 ; else mp [ str [ i ] ] = 1 ; var input = new Array ( Object . keys ( mp ) . length ) . fill ( 0 ) ; var count = new Array ( Object . keys ( mp ) . length ) . fill ( 0 ) ; var result = new Array ( str . length ) . fill ( 0 ) ; i = 0 ; for ( const [ key , value ] of Object . entries ( mp ) ) { input [ i ] = key ; count [ i ] = value ; i ++ ; } var len = Object . keys ( mp ) . length ; var size = str . length ; stringCombination ( result , input , count , 0 , size , len ) ; } var str = " " ; combination ( str ) ;

Index/key variables: i, level
Accumulator variables: i
Iterator variables: i
Javascript program:
function fillUtil ( res , curr , n ) { if ( curr == 0 ) return true ; let i ; for ( i = 0 ; i < 2 * n - curr - 1 ; i ++ ) { if ( res [ i ] == 0 && res [ i + curr + 1 ] == 0 ) { res [ i ] = res [ i + curr + 1 ] = curr ; if ( fillUtil ( res , curr - 1 , n ) ) return true ; res [ i ] = res [ i + curr + 1 ] = 0 ; } } return false ; } function fill ( n ) { let res = new Array ( 2 * n ) ; let i ; for ( i = 0 ; i < ( 2 * n ) ; i ++ ) res [ i ] = 0 ; if ( fillUtil ( res , n , n ) ) { for ( i = 0 ; i < 2 * n ; i ++ ) document . write ( res [ i ] + " " ) ; } else document . write ( " " ) ; } fill ( 7 ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
class node { constructor ( ) { this . color = 1 ; this . edges = new Set ( ) ; } } ; function canPaint ( nodes , n , m ) { var visited = [ ] ; for ( var i = 0 ; i < n + 1 ; i ++ ) { visited . push ( 0 ) ; } var maxColors = 1 ; for ( var sv = 1 ; sv <= n ; sv ++ ) { if ( visited [ sv ] > 0 ) continue ; visited [ sv ] = 1 ; var q = [ ] ; q . push ( sv ) ; while ( q . length != 0 ) { var top = q [ 0 ] ; q . shift ( ) ; for ( var it of nodes [ top ] . edges ) { if ( nodes [ top ] . color == nodes [ it ] . color ) nodes [ it ] . color += 1 ; maxColors = Math . max ( maxColors , Math . max ( nodes [ top ] . color , nodes [ it ] . color ) ) ; if ( maxColors > m ) return 0 ; if ( visited [ it ] == 0 ) { visited [ it ] = 1 ; q . push ( it ) ; } } } } return 1 ; } var n = 4 ; var graph = [ [ 0 , 1 , 1 , 1 ] , [ 1 , 0 , 1 , 0 ] , [ 1 , 1 , 0 , 1 ] , [ 1 , 0 , 1 , 0 ] ] ; var m = 3 ; var nodes = [ ] ; for ( var i = 0 ; i < n + 1 ; i ++ ) { nodes . push ( new node ( ) ) ; } for ( var i = 0 ; i < n ; i ++ ) { for ( var j = 0 ; j < n ; j ++ ) { if ( graph [ i , j ] > 0 ) { nodes [ i ] . edges . push ( i ) ; nodes [ j ] . edges . push ( j ) ; } } } document . write ( canPaint ( nodes , n , m ) ) ;

Index/key variables: i, it, j, sv, top
Accumulator variables: color, i, j, sv
Iterator variables: i, it, j, sv
Class/struct names: node
Javascript program:
let a , b , c , d ; let MOD = 1000000007 ; function FastDoubling ( n , res ) { if ( n == 0 ) { res [ 0 ] = 0 ; res [ 1 ] = 1 ; return ; } FastDoubling ( parseInt ( n / 2 , 10 ) , res ) ; a = res [ 0 ] ; b = res [ 1 ] ; c = 2 * b - a ; if ( c < 0 ) c += MOD ; c = ( a * c ) % MOD ; d = ( a * a + b * b ) % MOD ; if ( n % 2 == 0 ) { res [ 0 ] = c ; res [ 1 ] = d ; } else { res [ 0 ] = d ; res [ 1 ] = c + d ; } } let N = 6 ; let res = new Array ( 2 ) ; res . fill ( 0 ) ; FastDoubling ( N , res ) ; document . write ( res [ 0 ] ) ;

Accumulator variables: c
Javascript program:
function count ( arr , low , high , x ) { if ( ( low > high ) || ( low == high && arr [ low ] != x ) ) return 0 ; if ( low == high && arr [ low ] == x ) return 1 ; return count ( arr , low , Math . floor ( ( low + high ) / 2 ) , x ) + count ( arr , 1 + Math . floor ( ( low + high ) / 2 ) , high , x ) ; } let arr = [ 30 , 1 , 42 , 5 , 56 , 3 , 56 , 9 ] ; let n = arr . length ; let x = 56 ; document . write ( count ( arr , 0 , n - 1 , x ) ) ;

Index/key variables: low
Javascript program:
function firstDigit ( n ) { while ( n >= 10 ) { n = parseInt ( n / 10 , 10 ) ; } return n ; } function getCount ( n ) { let count = 1 ; while ( n != 0 ) { let leadDigit = firstDigit ( n ) ; n -= leadDigit ; count ++ ; } return count ; } function getLargestNumber ( k ) { let left = k ; let right = k * 10 ; let mid = parseInt ( ( left + right ) / 2 , 10 ) ; let len = getCount ( mid ) ; while ( len != k ) { mid = parseInt ( ( left + right ) / 2 , 10 ) ; len = getCount ( mid ) ; if ( len > k ) { right = mid ; } else { left = mid ; } } while ( len == k ) { if ( len != getCount ( mid + 1 ) ) { break ; } mid ++ ; } return ( mid ) ; } let k = 3 ; document . write ( getLargestNumber ( k ) ) ;

Accumulator variables: count, mid, n
Javascript program:
function closestsAngle ( N , A ) { let mi = Number . MAX_VALUE ; let ans = 0 ; for ( let i = 1 ; i < N - 1 ; i ++ ) { let angle = 180.0 * i / N ; if ( Math . abs ( angle - A ) < Math . abs ( mi - A ) ) { mi = angle ; ans = i ; } } document . write ( 2 + ' ' + 1 + ' ' + parseInt ( 2 + ans ) ) ; } let N = 3 , A = 15 ; closestsAngle ( N , A ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function centralPoints ( arr , N ) { let count = 0 ; let c1 , c2 , c3 , c4 ; for ( let i = 0 ; i < N ; i ++ ) { c1 = 0 ; c2 = 0 ; c3 = 0 ; c4 = 0 ; let x = arr [ i ] [ 0 ] ; let y = arr [ i ] [ 1 ] ; for ( let j = 0 ; j < N ; j ++ ) { if ( arr [ j ] [ 0 ] > x && arr [ j ] [ 1 ] == y ) { c1 = 1 ; } if ( arr [ j ] [ 1 ] > y && arr [ j ] [ 0 ] == x ) { c2 = 1 ; } if ( arr [ j ] [ 0 ] < x && arr [ j ] [ 1 ] == y ) { c3 = 1 ; } if ( arr [ j ] [ 1 ] < y && arr [ j ] [ 0 ] == x ) { c4 = 1 ; } } if ( c1 + c2 + c3 + c4 == 4 ) { count ++ ; } } return count ; } let arr = [ [ 1 , 0 ] , [ 2 , 0 ] , [ 1 , 1 ] , [ 1 , - 1 ] ] ; let N = arr . length ; document . write ( centralPoints ( arr , N ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function finalPosition ( a , b , M ) { let n = 0 , s = 0 , e = 0 , w = 0 ; let p = ' ' ; for ( let i = 0 ; i < M ; i ++ ) { if ( p == ' ' ) { if ( a [ i ] == ' ' ) { p = ' ' ; n = n + b [ i ] ; } else if ( a [ i ] == ' ' ) { p = ' ' ; s = s + b [ i ] ; } else if ( a [ i ] == ' ' ) { p = ' ' ; e = e + b [ i ] ; } else if ( a [ i ] == ' ' ) { p = ' ' ; w = w + b [ i ] ; } } else if ( p == ' ' ) { if ( a [ i ] == ' ' ) { p = ' ' ; s = s + b [ i ] ; } else if ( a [ i ] == ' ' ) { p = ' ' ; n = n + b [ i ] ; } else if ( a [ i ] == ' ' ) { p = ' ' ; w = w + b [ i ] ; } else if ( a [ i ] == ' ' ) { p = ' ' ; e = e + b [ i ] ; } } else if ( p == ' ' ) { if ( a [ i ] == ' ' ) { p = ' ' ; e = e + b [ i ] ; } else if ( a [ i ] == ' ' ) { p = ' ' ; w = w + b [ i ] ; } else if ( a [ i ] == ' ' ) { p = ' ' ; s = s + b [ i ] ; } else if ( a [ i ] == ' ' ) { p = ' ' ; n = n + b [ i ] ; } } else if ( p == ' ' ) { if ( a [ i ] == ' ' ) { p = ' ' ; w = w + b [ i ] ; } else if ( a [ i ] == ' ' ) { p = ' ' ; e = e + b [ i ] ; } else if ( a [ i ] == ' ' ) { p = ' ' ; n = n + b [ i ] ; } else if ( a [ i ] == ' ' ) { p = ' ' ; s = s + b [ i ] ; } } } let ver_disp = n - s ; let hor_disp = e - w ; let displacement = Math . ceil ( Math . sqrt ( ( ver_disp * ver_disp ) + ( hor_disp * hor_disp ) ) ) ; document . write ( displacement + " " + p ) ; } let A = [ ' ' , ' ' , ' ' , ' ' , ' ' ] ; let B = [ 1 , 1 , 1 , 1 , 0 ] ; let N = 1 ; finalPosition ( A , B , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function createPrefixArray ( n , arr , prefSize , pref ) { for ( let i = 0 ; i < prefSize ; i ++ ) { pref [ i ] = 0 ; } for ( let i = 0 ; i < n ; i ++ ) { let x = arr [ i ] + 1000000 ; pref [ x ] ++ ; } for ( let i = 1 ; i < prefSize ; i ++ ) { pref [ i ] += pref [ i - 1 ] ; } } function poletsOfLetersection ( m , segments , size , pref ) { let ans = 0 ; for ( let i = 0 ; i < m ; i ++ ) { let x1 = segments [ i ] [ 0 ] ; let x2 = segments [ i ] [ 2 ] ; x1 = x1 + 1000000 ; x2 = x2 + 1000000 ; if ( x1 != x2 ) { if ( x1 > x2 ) { let temp = x1 ; x1 = x2 ; x2 = temp ; } let Occ_Till_Right = pref [ x2 - 1 ] ; let Occ_Till_Left = pref [ x1 ] ; ans = ans + ( Occ_Till_Right - Occ_Till_Left ) ; } } return ans ; } let N = 4 ; let M = 8 ; let size = 2000000 + 2 ; let pref = Array . from ( { length : size } , ( _ , i ) => 0 ) ; let lines = [ - 5 , - 3 , 2 , 3 ] ; let segments = [ [ - 2 , 5 , 5 , - 6 ] , [ - 5 , - 2 , - 3 , - 5 ] , [ - 2 , 3 , - 6 , 1 ] , [ - 1 , - 3 , 4 , 2 ] , [ 2 , 5 , 2 , 1 ] , [ 4 , 5 , 4 , - 5 ] , [ - 2 , - 4 , 5 , 3 ] , [ 1 , 2 , - 2 , 1 ] ] ; createPrefixArray ( N , lines , size , pref ) ; document . write ( poletsOfLetersection ( M , segments , size , pref ) + " " ) ;

Index/key variables: i, x, x1
Accumulator variables: i
Iterator variables: i
Javascript program:
var PI = 3.14 ; function calculateAngle ( x1 , y1 , z1 , x2 , y2 , z2 , x3 , y3 , z3 ) { var ABx = x1 - x2 ; var ABy = y1 - y2 ; var ABz = z1 - z2 ; var BCx = x3 - x2 ; var BCy = y3 - y2 ; var BCz = z3 - z2 ; var dotProduct = ABx * BCx + ABy * BCy + ABz * BCz ; var magnitudeAB = ABx * ABx + ABy * ABy + ABz * ABz ; var magnitudeBC = BCx * BCx + BCy * BCy + BCz * BCz ; var angle = dotProduct ; angle /= Math . sqrt ( magnitudeAB * magnitudeBC ) ; angle = ( angle * 180 ) / PI ; document . write ( Math . abs ( angle ) . toFixed ( 4 ) ) ; } var x1 = 1 , y1 = 3 , z1 = 3 ; var x2 = 3 , y2 = 4 , z2 = 5 ; var x3 = 5 , y3 = 6 , z3 = 9 ; calculateAngle ( x1 , y1 , z1 , x2 , y2 , z2 , x3 , y3 , z3 ) ;

Accumulator variables: angle
Javascript program:
function solve ( n , m , obstacles , range ) { var val = Math . min ( n , m ) ; range . sort ( ( a , b ) => a - b ) var c = 1 ; for ( var i = obstacles - 1 ; i >= 0 ; i -- ) { range [ i ] = 2 * range [ i ] ; val -= range [ i ] ; if ( val <= 0 ) { return c ; } else { c ++ ; } } if ( val > 0 ) { return - 1 ; } } var n = 4 , m = 5 , obstacles = 3 ; var range = [ 1.0 , 1.25 , 1.15 ] ; document . write ( solve ( n , m , obstacles , range ) + " " ) ;

Index/key variables: i
Accumulator variables: c, i, val
Iterator variables: i