dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function largestString ( s , k ) { for ( let i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] != ' ' && k > 0 ) { s = s . substring ( 0 , i ) + ' ' + s . substring ( i + 1 ) ; k -- ; } } return s ; } var s = " " ; var k = 1 ; document . write ( largestString ( s , k ) ) ;

Index/key variables: i
Accumulator variables: i, k
Iterator variables: i
Javascript program:
function RemoveOneChar ( A , B , N , M ) { var X = 0 ; var Y = N - 1 ; var i ; for ( i = 0 ; i < M ; i ++ ) { if ( A [ X ] != B [ i ] ) break ; X ++ ; } for ( i = M - 1 ; i >= 0 ; i -- ) { if ( A [ Y ] != B [ i ] ) break ; Y -- ; } if ( N - M == 1 && Y < X ) { document . write ( X - Y + 1 + " " ) ; for ( i = Y ; i <= X ; i ++ ) document . write ( i + 1 + " " ) ; document . write ( " " ) ; } else document . write ( - 1 ) ; } var A = " " ; var B = " " ; var N = A . length ; var M = B . length ; RemoveOneChar ( A , B , N , M ) ;

Index/key variables: X, Y, i
Accumulator variables: X, Y, i
Iterator variables: i
Javascript program:
function minimumOperation ( a , b ) { var n = a . length ; var i = 0 ; var minoperation = 0 ; while ( i < n ) { if ( a [ i ] == b [ i ] ) { i = i + 1 ; continue ; } else if ( a [ i ] == b [ i + 1 ] && a [ i + 1 ] == b [ i ] && i < n - 1 ) { minoperation ++ ; i = i + 2 ; } else if ( a [ i ] != b [ i ] ) { minoperation ++ ; i = i + 1 ; } else { ++ i ; } } document . write ( minoperation ) ; } var a = " " , b = " " ; minimumOperation ( a , b ) ;

Index/key variables: i
Accumulator variables: minoperation
Javascript program:
function findMinOperations ( arr , N , K ) { var operations = 0 ; var i , j ; for ( i = 0 ; i < K ; i ++ ) { var freq = new Map ( ) ; for ( j = i ; j < N ; j += K ) { if ( freq . has ( arr [ j ] ) ) freq . set ( arr [ j ] , freq . get ( arr [ j ] ) + 1 ) ; else freq . set ( arr [ j ] , 1 ) ; } var max1 = 0 , num ; for ( const [ key , value ] of freq . entries ( ) ) { if ( value > max1 ) { max1 = value ; num = key ; } } for ( const [ key , value ] of freq . entries ( ) ) { if ( key != num ) operations += value ; } } document . write ( operations ) ; } var arr = [ 3 , 4 , 3 , 5 , 6 ] ; var K = 2 ; var N = arr . length ; findMinOperations ( arr , N , K ) ;

Index/key variables: j
Accumulator variables: i, j, operations
Iterator variables: i, j
Javascript program:
function countOfPairs ( x , y ) { var count = 0 ; var k ; for ( k = 1 ; k * k <= x ; ++ k ) { count += Math . max ( 0 , Math . min ( y , x / k - 1 ) - k ) ; } document . write ( count + " " ) ; } var x = 4 ; var y = 5 ; countOfPairs ( x , y ) ;

Accumulator variables: count
Iterator variables: k
Javascript program:
function countPermutations ( N ) { let adj = [ ] ; for ( let i = 0 ; i < 105 ; i ++ ) adj . push ( [ ] ) ; let indeg = 0 ; for ( let i = 1 ; i <= N ; i ++ ) { for ( let j = 1 ; j <= N ; j ++ ) { if ( i == j ) continue ; let sum = i + j ; if ( Math . ceil ( Math . sqrt ( sum ) ) == Math . floor ( Math . sqrt ( sum ) ) ) { adj [ i ] . push ( j ) ; } } if ( adj [ i ] . length == 1 ) indeg ++ ; } if ( indeg == 0 ) return N ; else if ( indeg <= 2 ) return 2 ; else return 0 ; } let N = 17 ; document . write ( countPermutations ( N ) ) ;

Index/key variables: i
Accumulator variables: i, indeg, j
Iterator variables: i, j
Javascript program:
function makeList ( N , K ) { var list = new Array ( N ) ; var left = 1 ; var right = N ; for ( var i = 0 ; i < N ; i ++ ) { if ( K % 2 == 0 ) { list [ i ] = left ; left = left + 1 ; } else { list [ i ] = right ; right = right - 1 ; } if ( K > 1 ) K -- ; } for ( var i = 0 ; i < N ; i ++ ) { document . write ( list [ i ] + " " ) ; } } var N = 6 ; var K = 3 ; makeList ( N , K ) ;

Index/key variables: i
Accumulator variables: K, i
Iterator variables: i
Javascript program:
function getDate ( d , m ) { let days = [ 31 , 29 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 ] ; let month = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ] ; let cnt = 183 ; let cur_month = 0 ; for ( let i = 0 ; i < 12 ; i ++ ) if ( m == month [ i ] ) cur_month = i ; let cur_date = d ; while ( true ) { while ( cnt > 0 && cur_date <= days [ cur_month ] ) { cnt -= 1 ; cur_date += 1 ; } if ( cnt == 0 ) break ; cur_month = ( cur_month + 1 ) % 12 ; cur_date = 1 ; } document . write ( cur_date + " " + month [ cur_month ] ) ; } let D = 15 ; let M = " " ; getDate ( D , M ) ;

Index/key variables: cur_month, i
Accumulator variables: cnt, cur_date, i
Iterator variables: i
Javascript program:
function largestNumber ( N ) { if ( N > 45 ) return - 1 ; let num = 0 , digit = 9 ; while ( N > 0 && digit > 0 ) { if ( digit <= N ) { num *= 10 ; num += digit ; N -= digit ; } digit -= 1 ; } return num * 10 ; } let N = 25 ; document . write ( largestNumber ( N ) ) ;

Accumulator variables: N, digit, num
Javascript program:
function minimumSum ( A , N , S ) { let mul = 0 ; for ( let i = 0 ; i < S . length ; i ++ ) { if ( S [ i ] == " " ) mul += 1 ; } let ans = 1000000 ; for ( let i = 0 ; i < 1 << ( N - 1 ) ; i ++ ) { let cnt = 0 ; let v = [ ] ; for ( let j = 0 ; j < N - 1 ; j ++ ) { if ( ( 1 << j ) & i ) { cnt += 1 ; v . push ( " " ) ; } else { v . push ( " " ) ; } } if ( cnt == mul ) { let d = [ ] ; d . push ( A [ 0 ] ) ; for ( let j = 0 ; j < N - 1 ; j ++ ) { if ( v [ j ] == " " ) { let x = d [ d . length - 1 ] ; d . pop ( ) ; x = x * A [ j + 1 ] ; d . push ( x ) ; } else { d . push ( A [ j + 1 ] ) ; } } let sum = 0 ; while ( d . length > 0 ) { let x = d [ 0 ] ; sum += x ; d . shift ( ) ; } ans = Math . min ( ans , sum ) ; } } return ans ; } let A = [ 2 , 2 , 2 , 2 ] ; let S = " " ; let N = A . length ; document . write ( minimumSum ( A , N , S ) ) ;

Index/key variables: i, j
Accumulator variables: cnt, i, j, mul, sum
Iterator variables: i, j
Javascript program:
function sumOfMedians ( arr , N , K ) { let selectMedian = Math . floor ( ( K + 1 ) / 2 ) ; let totalArrays = Math . floor ( N / K ) ; let minSum = 0 ; let i = selectMedian - 1 ; while ( i < N && totalArrays != 0 ) { minSum = minSum + arr [ i ] ; i = i + selectMedian ; totalArrays -- ; } document . write ( minSum ) ; } let arr = [ 1 , 2 , 3 , 4 , 5 , 6 ] ; let N = arr . length ; let K = 2 ; sumOfMedians ( arr , N , K ) ;

Index/key variables: i
Accumulator variables: totalArrays
Javascript program:
function solve ( S , K , N ) { if ( K > N ) { document . write ( " " ) ; return ; } let max_sum = 0 , min_sum = 0 ; for ( let i = 1 ; i <= K ; i ++ ) { min_sum += i ; max_sum += N - i + 1 ; } if ( S < min_sum S > max_sum ) { document . write ( " " ) ; return ; } let s1 = 0 ; let nums = [ ] ; for ( let i = 1 ; i <= N ; i ++ ) { if ( s1 > S ) break ; s1 += i ; nums . push ( i ) ; } let answer = [ ] ; let s2 = 0 ; for ( let i = 0 ; i < K - 1 ; i ++ ) { answer . push ( nums [ i ] ) ; s2 += nums [ i ] ; } answer . push ( S - s2 ) ; let Max = N ; for ( let i = answer . length - 1 ; i >= 0 ; i -- ) { if ( answer [ i ] > Max ) { let extra = answer [ i ] - Max ; if ( i - 1 >= 0 ) answer [ i - 1 ] += extra ; answer [ i ] = Max ; Max -- ; } else break ; } for ( let x in answer ) document . write ( answer [ x ] + " " ) ; document . write ( " " ) ; } let S = 15 , K = 4 , N = 8 ; solve ( S , K , N ) ;

Index/key variables: i, x
Accumulator variables: Max, i, max_sum, min_sum, s1, s2
Iterator variables: i, x
Javascript program:
function minSizeArr ( A , N , K ) { let leftTaken = N , rightTaken = N ; let leftSum = 0 , rightSum = 0 ; for ( let left = - 1 ; left < N ; left ++ ) { if ( left != - 1 ) leftSum += A [ left ] ; rightSum = 0 ; for ( let right = N - 1 ; right > left ; right -- ) { rightSum += A [ right ] ; if ( leftSum + rightSum == K ) { if ( leftTaken + rightTaken > ( left + 1 ) + ( N - right ) ) { leftTaken = left + 1 ; rightTaken = N - right ; } break ; } if ( leftSum + rightSum > K ) break ; } } if ( leftTaken + rightTaken <= N ) { for ( let i = 0 ; i < leftTaken ; i ++ ) document . write ( A [ i ] + " " ) ; for ( let i = 0 ; i < rightTaken ; i ++ ) document . write ( A [ N - i - 1 ] + " " ) ; } else document . write ( - 1 ) ; } let N = 7 ; let A = [ 3 , 2 , 1 , 1 , 1 , 1 , 3 ] ; let K = 10 ; minSizeArr ( A , N , K ) ;

Index/key variables: i, left, right
Accumulator variables: i, left, leftSum, right, rightSum
Iterator variables: i, left, right
Javascript program:
function minSizeArr ( A , N , K ) { var sum = 0 ; var i ; for ( i = 0 ; i < N ; i ++ ) sum += A [ i ] ; if ( K > sum ) { cout << - 1 ; return ; } if ( K == sum ) { for ( i = 0 ; i < N ; i ++ ) { document . write ( A [ i ] + ' ' ) ; } return ; } var tar = sum - K ; var um = new Map ( ) ; um [ 0 ] = - 1 ; var left , right ; var cur = 0 , maxi = - 1 ; for ( i = 0 ; i < N ; i ++ ) { cur += A [ i ] ; if ( um . has ( cur - tar ) && i - um . get ( cur - tar ) > maxi ) { maxi = i - um . get ( cur - tar ) ; right = i ; left = um . get ( cur - tar ) ; } if ( ! um . has ( cur ) ) um . set ( cur , i ) ; } if ( maxi == - 1 ) cout << - 1 ; else { for ( i = 0 ; i <= left ; i ++ ) document . write ( A [ i ] + ' ' ) ; for ( i = 0 ; i < right ; i ++ ) document . write ( A [ N - i - 1 ] + ' ' ) ; } } var N = 7 ; var A = [ 3 , 2 , 1 , 1 , 1 , 1 , 3 ] ; var K = 10 ; minSizeArr ( A , N , K ) ;

Index/key variables: i
Accumulator variables: cur, i, sum
Iterator variables: i
Javascript program:
function minModulo ( L , R , N ) { if ( R - L < N ) { let ans = Number . MAX_VALUE ; for ( let i = L ; i <= R ; i ++ ) for ( let j = L ; j <= R ; j ++ ) if ( i != j ) ans = Math . min ( ans , ( i * j ) % N ) ; document . write ( ans ) ; } else { document . write ( 0 ) ; } } let L = 6 , R = 10 , N = 2019 ; minModulo ( L , R , N ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function countNumbers ( N ) { var count = 0 ; for ( i = 1 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) { count ++ ; if ( parseInt ( N / i ) != i ) { count ++ ; } } } return count ; } var N = 10 ; document . write ( countNumbers ( N ) ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function maximumSize ( a , k ) { let low = 1 ; let high = Math . max . apply ( Math , a ) ; let ans = - 1 ; while ( low <= high ) { let mid = Math . floor ( low + ( high - low ) / 2 ) ; let count = 0 ; for ( let c = 0 ; c < a . length ; c ++ ) { count += Math . floor ( a / mid ) ; } if ( count >= k ) { ans = mid ; low = mid + 1 ; } else { high = mid - 1 ; } } return ans ; } let arr = [ 1 , 2 , 3 , 4 , 9 ] ; let K = 6 ; document . write ( maximumSize ( arr , K ) )

Accumulator variables: c, count
Iterator variables: c
Javascript program:
function findMaxValueOfEquation ( arr , K ) { let pq = [ ] ; let res = Number . MIN_VALUE ; for ( let point = 0 ; point < arr . length ; point ++ ) { while ( pq . length != 0 && arr [ point ] [ 0 ] - pq [ 0 ] [ 1 ] > K ) { pq . shift ( ) ; } if ( pq . length != 0 ) { res = Math . max ( res , pq [ 0 ] [ 0 ] + arr [ point ] [ 0 ] + arr [ point ] [ 1 ] ) ; } pq . push ( [ arr [ point ] [ 1 ] - arr [ point ] [ 0 ] , arr [ point ] [ 0 ] ] ) ; pq . sort ( function ( a , b ) { if ( a [ 0 ] != b [ 0 ] ) return b [ 0 ] - a [ 0 ] ; return b [ 1 ] - a [ 1 ] ; } ) } document . write ( res ) ; } let arr = [ [ 1 , 3 ] , [ 2 , 0 ] , [ 5 , 10 ] , [ 6 , - 10 ] ] ; let K = 1 ; findMaxValueOfEquation ( arr , K ) ;

Index/key variables: point
Accumulator variables: point
Iterator variables: point
Javascript program:
function minOperations ( arr , n ) { var oddcount = 0 , evencount = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 1 ) oddcount ++ ; else evencount ++ ; } return Math . min ( oddcount , evencount ) ; } var arr = [ 2 , 4 , 3 , 1 , 8 ] ; var N = arr . length ; document . write ( minOperations ( arr , N ) ) ;

Index/key variables: i
Accumulator variables: evencount, i, oddcount
Iterator variables: i
Javascript program:
function printLastElement ( arr , N ) { var leftTurn = true ; var remainElements = N ; var step = 1 ; var head = 1 ; while ( remainElements > 1 ) { if ( leftTurn ) { head = head + step ; } else { if ( remainElements % 2 == 1 ) head = head + step ; } remainElements = remainElements / 2 ; step = step * 2 ; leftTurn = ! leftTurn ; } document . write ( arr [ head - 1 ] ) ; } var arr = [ 2 , 3 , 5 , 6 ] ; var N = arr . length ; printLastElement ( arr , N ) ;

Boolean variables: leftTurn
Javascript program:
function max_min ( N , C , K ) { let maximum , minimum ; if ( N == 1 ) { maximum = minimum = C ; } else if ( K >= C ) { maximum = C ; minimum = 0 ; } else { maximum = K ; minimum = 0 ; let remain_candy = C - K ; maximum += Math . floor ( remain_candy / N ) ; minimum = Math . floor ( remain_candy / N ) ; if ( remain_candy % N == N - 1 ) { minimum ++ ; } } document . write ( " " + maximum + " " ) ; document . write ( " " + minimum ) ; } let N = 4 ; let C = 12 ; let K = 3 ; max_min ( N , C , K ) ;

Accumulator variables: maximum, minimum
Javascript program:
function shortestSubarray ( A , N ) { let i ; let left_index ; for ( i = 0 ; i < N - 1 ; i ++ ) { if ( A [ i ] + 1 != A [ i + 1 ] ) break ; } left_index = i ; let right_index ; for ( i = N - 1 ; i >= 1 ; i -- ) { if ( A [ i ] != A [ i - 1 ] + 1 ) break ; } right_index = i ; let updated_right ; let minLength = Math . min ( N - left_index - 1 , right_index ) ; if ( A [ right_index ] <= A [ left_index ] + 1 ) { updated_right = right_index + A [ left_index ] - A [ right_index ] + 1 ; if ( updated_right < N ) minLength = Math . min ( minLength , updated_right - left_index - 1 ) ; } document . write ( minLength ) ; } let arr = [ 1 , 2 , 3 , 7 , 4 , 3 , 5 ] ; let N = arr . length ; shortestSubarray ( arr , N ) ;

Index/key variables: i, left_index, right_index
Accumulator variables: i
Iterator variables: i
Javascript program:
function freqCheck ( S , N ) { let hash = new Array ( 26 ) . fill ( 0 ) for ( let i = 0 ; i < N ; i ++ ) { hash [ S . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ] += 1 } for ( let i = 0 ; i < 26 ; i ++ ) { if ( hash [ i ] > 2 ) { return " " } } return " " } let S = " " let N = S . length document . write ( freqCheck ( S , N ) )

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function minLength ( s ) { i = 0 ; j = s . length - 1 while ( i < j && s [ i ] == s [ j ] ) { d = s [ i ] while ( i <= j && s [ i ] == d ) i += 1 while ( i <= j && s [ j ] == d ) j -= 1 } return j - i + 1 } S = " " document . write ( minLength ( S ) )

Index/key variables: i, j
Accumulator variables: i, j
Javascript program:
function rotateString ( n , m , s ) { var v = [ ] ; var cnt = 0 ; var i ; for ( i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' ' ) { v . push ( i ) ; } } for ( i = 1 ; i < v . length ; i ++ ) { if ( ( v [ i ] - v [ i - 1 ] - 1 ) > m ) { cnt ++ ; } } if ( v . length >= 2 && ( n - ( v [ v . length - 1 ] - v [ 0 ] ) - 1 ) > m ) { cnt ++ ; } if ( cnt <= 1 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } var S = " " ; var M = 1 ; var N = S . length ; rotateString ( N , M , S ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function maximumIndex ( N , B ) { let i = 0 , j = 1 ; let cnt = 0 ; let sum = Math . floor ( N * ( N + 1 ) / 2 ) ; let flag = false ; while ( cnt < N ) { i += j ; j ++ ; cnt ++ ; if ( i == B ) { flag = true ; break ; } } if ( ! flag ) { document . write ( sum ) ; } else document . write ( sum - 1 ) ; } let N = 4 , B = 6 ; maximumIndex ( N , B ) ;

Accumulator variables: cnt, i, j
Boolean variables: flag
Javascript program:
function findLongestArray ( K ) { let primefactors = [ ] ; let K_temp = K ; for ( let i = 2 ; i * i <= K ; i ++ ) { let count = 0 ; while ( K_temp % i == 0 ) { K_temp = Math . floor ( K_temp / i ) ; count ++ ; } if ( count > 0 ) primefactors . push ( [ count , i ] ) ; } if ( K_temp != 1 ) primefactors . push ( [ 1 , K_temp ] ) ; primefactors . sort ( function ( x , y ) { if ( x [ 0 ] != y [ 0 ] ) return y [ 0 ] - x [ 0 ] ; return y [ 1 ] - x [ 1 ] ; } ) ; let n = primefactors [ 0 ] [ 0 ] ; let val = primefactors [ 0 ] [ 1 ] ; let answer = new Array ( n ) ; for ( let i = 0 ; i < n ; i ++ ) { answer [ i ] = val ; } answer [ n - 1 ] *= K ; for ( let i = 0 ; i < n ; i ++ ) { answer [ n - 1 ] = Math . floor ( answer [ n - 1 ] / val ) ; } document . write ( " " ) ; for ( let i = 0 ; i < answer . length ; i ++ ) { if ( i == answer . length - 1 ) document . write ( answer [ i ] + " " ) ; else document . write ( answer [ i ] + " " ) ; } } let K = 4 ; findLongestArray ( K ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function minsteps ( A ) { let n = A . length ; let left = Array . from ( { length : n } , ( _ , i ) => 0 ) ; let right = Array . from ( { length : n } , ( _ , i ) => 0 ) ; let res = Array . from ( { length : n } , ( _ , i ) => 0 ) ; let count = A [ 0 ] ; for ( let i = 1 ; i < n ; i ++ ) { left [ i ] = left [ i - 1 ] + count ; count += A [ i ] ; } count = A [ n - 1 ] ; for ( let i = n - 2 ; i >= 0 ; i -- ) { right [ i ] = right [ i + 1 ] + count ; count += A [ i ] ; } for ( let i = 0 ; i < n ; i ++ ) { res [ i ] = left [ i ] + right [ i ] ; document . write ( res [ i ] + " " ) ; } document . write ( " " ) ; } let A = [ 1 , 0 , 1 , 0 ] ; minsteps ( A ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function minimumOperations ( A , K ) { let isflipped = [ ] ; for ( let i = 0 ; i < A . length + 1 ; i ++ ) { isflipped [ i ] = 0 ; } let ans = 0 ; for ( let i = 0 ; i < A . length ; i ++ ) { if ( i > 0 ) { isflipped [ i ] += isflipped [ i - 1 ] ; isflipped [ i ] %= 2 ; } if ( A [ i ] == 0 && isflipped [ i ] == 0 ) { if ( ( A . length - i + 1 ) <= K ) { document . write ( - 1 ) ; return ; } ans ++ ; isflipped [ i ] ++ ; isflipped [ i + K ] -- ; } else if ( A [ i ] == 1 && isflipped [ i ] != 0 ) { if ( ( A . length - i + 1 ) <= K ) { document . write ( - 1 ) ; return ; } ans ++ ; isflipped [ i ] ++ ; isflipped [ i + K ] -- ; } } document . write ( ans ) ; } let arr = [ 0 , 1 , 0 ] ; let K = 1 ; minimumOperations ( arr , K ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function findScoreSum ( n ) { let total = 0 ; let prev_monday = 0 , curr_day = 0 ; for ( let day = 1 ; day <= n ; day ++ ) { if ( day % 7 == 1 ) { prev_monday ++ ; curr_day = prev_monday ; } total += curr_day ++ ; } document . write ( total ) ; } let N = 8 ; findScoreSum ( N ) ;

Accumulator variables: curr_day, day, prev_monday, total
Iterator variables: day
Javascript program:
function getArea ( x1 , y1 , x2 , y2 , x3 , y3 ) { return Math . abs ( ( x1 * ( y2 - y3 ) + x2 * ( y3 - y1 ) + x3 * ( y1 - y2 ) ) / 2 ) ; } function isInside ( triangle , point ) { let A = triangle [ 0 ] ; let B = triangle [ 1 ] ; let C = triangle [ 2 ] ; let x = point [ 0 ] ; let y = point [ 1 ] ; let ABC = getArea ( A [ 0 ] , A [ 1 ] , B [ 0 ] , B [ 1 ] , C [ 0 ] , C [ 1 ] ) ; let BPC = getArea ( x , y , B [ 0 ] , B [ 1 ] , C [ 0 ] , C [ 1 ] ) ; let APC = getArea ( A [ 0 ] , A [ 1 ] , x , y , C [ 0 ] , C [ 1 ] ) ; let APB = getArea ( A [ 0 ] , A [ 1 ] , B [ 0 ] , B [ 1 ] , x , y ) ; return ABC == ( APC + APB + BPC ) ? 1 : 0 ; } function countPoints ( rectangle , triangle , points ) { let n = rectangle . length ; let triangle1 = [ ] ; for ( let i = 1 ; i < n ; i ++ ) triangle1 . push ( rectangle [ i ] ) ; let triangle2 = [ ] ; for ( let i = 0 ; i < 3 ; i ++ ) { triangle2 . push ( rectangle [ i ] ) ; } let triangle3 = [ ] ; for ( let i = 0 ; i < 2 ; i ++ ) { triangle3 . push ( rectangle [ i ] ) ; } triangle3 . push ( rectangle [ 3 ] ) ; let triangle4 = [ ] ; for ( let i = n - 2 ; i < n ; i ++ ) { triangle4 . push ( rectangle [ i ] ) ; } triangle4 . push ( rectangle [ 0 ] ) ; let ans = 0 ; for ( let point = 0 ; point < points . length ; point ++ ) { let condOne = isInside ( triangle1 , points [ point ] ) ; let condTwo = isInside ( triangle2 , points [ point ] ) ; let condThree = isInside ( triangle3 , points [ point ] ) ; let condFour = isInside ( triangle4 , points [ point ] ) ; let condFive = isInside ( triangle , points [ point ] ) ; if ( ( condOne != 0 condTwo != 0 condThree != 0 condFour != 0 ) && condFive != 0 ) ans += 1 ; } document . write ( ans + " " ) ; } let rectangle = [ ] ; let points = [ ] ; let triangle = [ ] ; rectangle . push ( [ 6 , 5 ] ) ; rectangle . push ( [ 2 , 2 ] ) ; rectangle . push ( [ 2 , 1 ] ) ; rectangle . push ( [ 5 , 5 ] ) ; points . push ( [ 1 , 1 ] ) ; points . push ( [ 6 , 1 ] ) ; points . push ( [ 6 , 6 ] ) ; points . push ( [ 1 , 6 ] ) ; triangle . push ( [ 4 , 4 ] ) ; triangle . push ( [ 0 , 4 ] ) ; triangle . push ( [ 0 , - 2 ] ) ; countPoints ( points , triangle , rectangle ) ;

Index/key variables: i, point
Accumulator variables: ans, i, point
Iterator variables: i, point
Javascript program:
function minimumOperations ( A , n ) { var cnt = 0 ; for ( i = n - 1 ; i >= 0 ; i -- ) { if ( A [ i ] != ( i + 1 ) ) { if ( ( ( i - 1 ) >= 0 ) && A [ i - 1 ] == ( i + 1 ) ) { cnt ++ ; var t = A [ i ] ; A [ i ] = A [ i - 1 ] ; A [ i - 1 ] = t ; } else if ( ( ( i - 2 ) >= 0 ) && A [ i - 2 ] == ( i + 1 ) ) { cnt += 2 ; A [ i - 2 ] = A [ i - 1 ] ; A [ i - 1 ] = A [ i ] ; A [ i ] = i + 1 ; } else { document . write ( - 1 ) ; return ; } } } document . write ( cnt ) ; } var A = [ 7 , 3 , 2 , 1 , 4 ] ; var n = A . length ; minimumOperations ( A , n ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function countOccurrences ( n , x ) { var count = 0 ; for ( var i = 1 ; i <= n ; i ++ ) { if ( x % i == 0 ) { if ( x / i <= n ) count ++ ; } } document . write ( count ) ; } var N = 7 , X = 12 ; countOccurrences ( N , X ) ;

Accumulator variables: count, i
Iterator variables: i
Javascript program:
function ConvertArray ( arr , N ) { if ( N == 1 ) { document . write ( " " + 1 + " " + 1 + " " ) ; document . write ( " " + - 1 * arr [ 0 ] + " " ) ; document . write ( " " ) ; document . write ( " " + 1 + " " + 1 + " " ) ; document . write ( " " + 1 * arr [ 0 ] + " " ) ; document . write ( " " ) ; document . write ( " " + 1 + " " + 1 + " " ) ; document . write ( " " + - 1 * arr [ 0 ] + " " ) ; } else { document . write ( " " + 1 + " " + N + " " ) ; document . write ( " " ) ; for ( i = 0 ; i < N ; i ++ ) { document . write ( - 1 * arr [ i ] * N + " " ) ; } document . write ( " " ) ; document . write ( " " ) ; document . write ( " " + 1 + " " + ( N - 1 ) + " " ) ; document . write ( " " ) ; for ( i = 0 ; i < N - 1 ; i ++ ) { document . write ( arr [ i ] * ( N - 1 ) + " " ) ; } document . write ( " " ) ; document . write ( " " ) ; document . write ( " " + N + " " + N + " " ) ; document . write ( " " ) ; document . write ( arr [ N - 1 ] * ( N - 1 ) + " " ) ; } } var arr = [ 1 , 3 , 2 , 4 ] ; var N = arr . length ; ConvertArray ( arr , N ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let countDistinct = Array ( 1000000 + 1 ) ; function countOfPrimefactors ( CountDistinct ) { let MAX = 1000000 ; let prime = Array ( MAX + 1 ) ; for ( let i = 0 ; i <= MAX ; i ++ ) { CountDistinct [ i ] = 0 ; prime [ i ] = true ; } for ( let i = 2 ; i <= MAX ; i ++ ) { if ( prime [ i ] == true ) { CountDistinct [ i ] = 1 ; for ( let j = i * 2 ; j <= MAX ; j += i ) { CountDistinct [ j ] ++ ; prime [ j ] = false ; } } } } function CountEvenPair ( A , B , N , M ) { let MAX = 1000000 ; countOfPrimefactors ( countDistinct ) ; let evenCount = 0 ; let oddCount = 0 ; let evenPairs = 0 ; for ( let i = 0 ; i < M ; i ++ ) { if ( countDistinct [ B [ i ] ] == 0 ) continue ; if ( ( countDistinct [ B [ i ] ] & 1 ) != 0 ) { oddCount ++ ; } else { evenCount ++ ; } } for ( let i = 0 ; i < N ; i ++ ) { if ( countDistinct [ A [ i ] ] == 0 ) continue ; if ( ( countDistinct [ A [ i ] ] & 1 ) != 0 ) { evenPairs += ( evenCount ) ; } else { evenPairs += evenCount + oddCount ; } } return evenPairs ; } let A = [ 1 , 2 , 3 ] ; let B = [ 4 , 5 , 6 ] ; let N = A . length ; let M = B . length ; document . write ( CountEvenPair ( A , B , N , M ) ) ;

Index/key variables: i, j
Accumulator variables: evenCount, evenPairs, i, j, oddCount
Iterator variables: i, j