dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function make_palindrome ( S1 , S2 , S3 ) { let maskA = 0 , maskC = 0 ; for ( let i = 0 ; i < S1 . length ; i ++ ) maskA |= ( 1 << ( S1 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ) ; for ( let i = 0 ; i < S3 . length ; i ++ ) maskC |= ( 1 << ( S3 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ) ; if ( ( maskA & maskC ) > 0 ) return " " ; return " " ; } let S1 = " " , S2 = " " , S3 = " " ; document . write ( make_palindrome ( S1 , S2 , S3 ) ) ;

Index/key variables: i
Accumulator variables: i, maskA, maskC
Iterator variables: i
Javascript program:
let SIZE = 26 ; function longHelper ( freq1 , freq2 ) { for ( let i = 0 ; i < SIZE ; ++ i ) { if ( freq1 [ i ] != freq2 [ i ] ) { return false ; } } return true ; } function longCommomPrefixAnagram ( s1 , s2 , n1 , n2 ) { let freq1 = new Array ( 26 ) ; freq1 . fill ( 0 ) ; let freq2 = new Array ( 26 ) ; freq2 . fill ( 0 ) ; let ans = 0 ; let mini_len = Math . min ( n1 , n2 ) ; for ( let i = 0 ; i < mini_len ; ++ i ) { freq1 [ s1 [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; freq2 [ s2 [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; if ( longHelper ( freq1 , freq2 ) ) { ans = i + 1 ; } } document . write ( ans ) ; } let str1 = " " ; let str2 = " " ; let N = str1 . length ; let M = str2 . length ; longCommomPrefixAnagram ( str1 , str2 , N , M ) ;

Index/key variables: i
Iterator variables: i
Javascript program:
function findRank ( s ) { var N = s . length ; var bin = " " ; for ( var i = 0 ; i < N ; i ++ ) { if ( s [ i ] == ' ' ) bin += " " ; else bin += " " ; } var X = 1 << N ; var res = 0 , val = 1 ; for ( var i = N - 1 ; i >= 0 ; i -- ) { if ( bin [ i ] == ' ' ) res += ( val ) ; val *= 2 ; } var Y = res ; var ans = X + Y - 1 ; document . write ( ans ) ; } var S = " " ; findRank ( S ) ;

Index/key variables: i
Accumulator variables: bin, i, res, val
Iterator variables: i
Javascript program:
function GCD ( lena , lenb ) { if ( lena == 0 ) return lenb ; if ( lenb == 0 ) return lena ; if ( lena == lenb ) return lena ; if ( lena > lenb ) return GCD ( lena - lenb , lenb ) ; return GCD ( lena , lenb - lena ) ; } function StringGCD ( a , b ) { let gcd = GCD ( a . length , b . length ) ; if ( a . substring ( 0 , gcd ) == ( b . substring ( 0 , gcd ) ) ) { let x = Math . floor ( b . length / gcd ) ; let y = Math . floor ( a . length / gcd ) ; let r = " " , s = " " ; while ( x -- > 0 ) s += a ; while ( y -- > 0 ) r += b ; if ( s == ( r ) ) return a . substring ( 0 , gcd ) ; } return " " ; } let a = " " ; let b = " " ; document . write ( StringGCD ( a , b ) ) ;

Accumulator variables: r, s, x, y
Javascript program:
function scoreOfParentheses ( S ) { var s = [ ] ; var i = 0 ; var ans = 0 ; while ( i < S . length ) { if ( S [ i ] == ' ' ) s . push ( " " ) ; else { if ( s [ s . length - 1 ] == " " ) { s . pop ( ) ; s . push ( " " ) ; } else { var count = 0 ; while ( s [ s . length - 1 ] != " " ) { count += parseInt ( s [ s . length - 1 ] ) ; s . pop ( ) ; } s . pop ( ) ; s . push ( ( 2 * count ) . toString ( ) ) ; } } i ++ ; } while ( s . length != 0 ) { ans += parseInt ( s [ s . length - 1 ] ) ; s . pop ( ) ; } return ans ; } var S1 = " " ; document . write ( scoreOfParentheses ( S1 ) ) ;

Index/key variables: i
Accumulator variables: ans, count, i
Javascript program:
function countMinMoves ( str ) { var n = str . length ; var a = Array ( n ) . fill ( 0 ) ; var j , ans = 0 , i , sum = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ' ) { a [ i ] += sum - 1 ; } else { a [ i ] += sum + 1 ; } sum = a [ i ] ; } if ( sum == 0 ) { i = 1 ; while ( i < n ) { j = i - 1 ; while ( i < n && a [ i ] != 0 ) i ++ ; if ( i < n && a [ i - 1 ] < 0 ) { ans += i - j ; if ( j == 0 ) ans ++ ; } i ++ ; } document . write ( ans + " " ) ; } else document . write ( " " ) ; } var str = " " ; countMinMoves ( str ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function canBeBalanced ( sequence ) { if ( sequence . length % 2 == 1 ) return false ; let stack_ = [ ] ; let stack2_ = [ ] ; let countOpen = 0 , countClosed = 0 ; let countSymbol = 0 ; for ( let i = 0 ; i < sequence . length ; i ++ ) { if ( sequence [ i ] == ' ' ) { countClosed ++ ; if ( stack_ . length == 0 ) { return false ; } else { stack_ . pop ( ) ; } } else { if ( sequence [ i ] == ' ' ) { countSymbol ++ ; } else { countOpen ++ ; } stack_ . push ( sequence [ i ] ) ; } } for ( let i = sequence . length - 1 ; i >= 0 ; i -- ) { if ( sequence [ i ] == ' ' ) { if ( stack2_ . length == 0 ) { return false ; } else { stack2_ . pop ( ) ; } } else { stack2_ . push ( sequence [ i ] ) ; } } let extra = Math . abs ( countClosed - countOpen ) ; if ( countSymbol < extra ) { return false ; } else { countSymbol -= extra ; if ( countSymbol % 2 == 0 ) { return true ; } } return false ; } let S = " " ; if ( canBeBalanced ( S ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Index/key variables: i
Accumulator variables: countClosed, countOpen, countSymbol, i
Iterator variables: i
Javascript program:
function maxDiffFreq ( queries , S ) { let N = S . length ; let Q = queries . length ; for ( let i = 0 ; i < Q ; ++ i ) { let l = queries [ i ] [ 0 ] - 1 ; let r = queries [ i ] [ 1 ] - 1 ; let freq = new Array ( 26 ) . fill ( 0 ) ; for ( let j = l ; j <= r ; j ++ ) { freq [ S [ j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } let mx = 0 ; let mn = 99999999 ; for ( let j = 0 ; j < 26 ; j ++ ) { mx = Math . max ( mx , freq [ j ] ) ; if ( freq [ j ] ) mn = Math . min ( mn , freq [ j ] ) ; } document . write ( mx - mn + " " ) ; } } let S = " " ; let queries = [ [ 2 , 6 ] , [ 1 , 7 ] ] ; maxDiffFreq ( queries , S ) ;

Index/key variables: i, j
Accumulator variables: j
Iterator variables: i, j
Javascript program:
function countStrings ( S , list ) { let valid = new Set ( ) ; for ( let x of S ) { valid . add ( x ) ; } let cnt = 0 ; for ( let i = 0 ; i < list . length ; i ++ ) { let j = 0 ; for ( j = 0 ; j < list [ i ] . length ; j ++ ) { if ( valid . has ( list [ i ] [ j ] ) ) continue ; else break ; } if ( j == list [ i ] . length ) cnt ++ ; } return cnt ; } let arr = [ " " , " " , " " , " " ] ; let S = " " ; document . write ( countStrings ( S , arr ) + " " ) ;

Index/key variables: i, j
Accumulator variables: cnt, i, j
Iterator variables: i, j, x
Javascript program:
function minLength ( str , N , K , M ) { var stackOfChar = [ ] ; for ( var i = 0 ; i < N ; i ++ ) { stackOfChar . push ( str [ i ] ) ; if ( stackOfChar . length >= M ) { var l = " " ; for ( var j = M - 1 ; j >= 0 ; j -- ) { if ( K [ j ] != stackOfChar [ stackOfChar . length - 1 ] ) { var f = 0 ; while ( f != l . length ) { stackOfChar . push ( l [ f ] ) ; f ++ ; } break ; } else { l = stackOfChar [ stackOfChar . length - 1 ] + l ; stackOfChar . pop ( ) ; } } } } return stackOfChar . length ; } var S1 = " " ; var S2 = " " ; var N = S1 . length ; var M = S2 . length ; document . write ( minLength ( S1 , N , S2 , M ) ) ;

Index/key variables: f, i, j
Accumulator variables: f, i, j
Iterator variables: i, j
Javascript program:
function palindrome_prod ( N ) { var palindrome_list = [ ] ; var i , j ; for ( i = 101 ; i < 1000 ; i ++ ) { for ( j = 121 ; j < 1000 ; j += ( i % 11 == 0 ) ? 1 : 11 ) { var n = i * j ; var x = n . toString ( ) ; var y = x ; y = y . split ( " " ) . reverse ( ) . join ( " " ) ; if ( x == y ) { if ( n < Number ( N ) ) { palindrome_list . push ( i * j ) ; } } } } document . write ( Math . max . apply ( null , palindrome_list ) ) ; } var N = " " ; palindrome_prod ( N ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isEqualStrings ( arr , N ) { let M = arr [ 0 ] . length ; let cntFreq = new Array ( 256 ) . fill ( 0 ) ; for ( let i = 0 ; i < N ; i ++ ) { cntFreq [ i ] = 0 ; } for ( let i = 0 ; i < N ; i ++ ) { for ( let j = 0 ; j < M ; j ++ ) { cntFreq [ arr [ i ] [ j ] - ' ' ] += 1 ; } } for ( let i = 0 ; i < 256 ; i ++ ) { if ( cntFreq [ i ] % N != 0 ) { return false ; } } return true ; } let arr = [ " " , " " , " " ] ; let N = arr . length ; if ( isEqualStrings ( arr , N ) ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function PrintStack ( s ) { if ( s . length == 0 ) return ; let x = s [ s . length - 1 ] ; s . pop ( ) ; PrintStack ( s ) ; document . write ( x ) ; s . push ( x ) ; } function minString ( s ) { let Stack = [ ] ; Stack . push ( s [ 0 ] ) ; for ( let i = 1 ; i < s . length ; i ++ ) { if ( Stack . length == 0 ) { Stack . push ( s [ i ] ) ; } else { if ( Stack [ Stack . length - 1 ] == s [ i ] ) { Stack . pop ( ) ; } else { Stack . push ( s [ i ] ) ; } } } PrintStack ( Stack ) ; } let str = " " ; minString ( str ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function count_of_accident ( a , b ) { let n = a . length , m = b . length ; if ( n > m ) return ( m * ( m + 1 ) ) / 2 ; else return ( n * ( n + 1 ) ) / 2 + ( m - n ) * n ; } function count_of_collision ( a , b ) { let n = a . length , m = b . length ; let answer = 0 ; let count_of_truck_in_lane_b = 0 ; for ( let i = 0 ; i < m ; i ++ ) if ( b [ i ] == ' ' ) count_of_truck_in_lane_b ++ ; for ( let i = 0 ; i < n && i < m ; i ++ ) { if ( a [ i ] == ' ' ) answer += count_of_truck_in_lane_b ; if ( b [ i ] == ' ' ) count_of_truck_in_lane_b -- ; } return answer ; } function findProbability ( a , b ) { let total_outcome = count_of_accident ( a , b ) ; let favourable_outcome = count_of_collision ( a , b ) ; document . write ( favourable_outcome / total_outcome ) ; } let S = " " , T = " " ; findProbability ( S , T ) ;

Index/key variables: i
Accumulator variables: answer, count_of_truck_in_lane_b, i
Iterator variables: i
Javascript program:
function lenOfLongestReqSubstr ( s , N ) { var ind = new Map ( ) ; var mask = 0 ; ind [ 0 ] = - 1 ; var ans = 0 ; for ( var i = 0 ; i < N ; i ++ ) { var val = s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; mask ^= ( 1 << val ) ; if ( ind . has ( mask ) ) { ans = Math . max ( ans , i - ind . get ( mask ) ) ; } else ind . set ( mask , i ) ; } return ans ; } var s = " " ; var N = s . length ; document . write ( lenOfLongestReqSubstr ( s , N ) ) ;

Index/key variables: i
Accumulator variables: i, mask
Iterator variables: i
Javascript program:
function uniqueMorseRep ( arr ) { var morseCode = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ] ; var st = new Set ( ) ; var N = arr . length ; for ( var i = 0 ; i < N ; i ++ ) { var temp = " " ; var M = arr [ i ] . length ; for ( var j = 0 ; j < M ; j ++ ) { temp += morseCode [ arr [ i ] [ j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ; } st . add ( temp ) ; } return st . size ; } var arr = [ " " , " " , " " , " " ] ; document . write ( uniqueMorseRep ( arr ) ) ;

Index/key variables: i, j
Accumulator variables: i, j, temp
Iterator variables: i, j
Javascript program:
function findFreq ( str , N ) { let freq = new Array ( 256 ) . fill ( 0 ) ; let max = 0 ; let charMax = ' ' ; for ( let i = 0 ; i < N ; i ++ ) { let ch = str [ i ] . charCodeAt ( 0 ) ; freq [ ch ] ++ ; if ( freq [ ch ] >= max ) { max = freq [ ch ] ; charMax = ch ; } document . write ( String . fromCharCode ( charMax ) + " " + max + " " ) ; } } let str = " " ; let N = str . length ; findFreq ( str , N ) ;

Index/key variables: ch, i
Accumulator variables: i
Iterator variables: i
Javascript program:
function findMinCost ( str , pos ) { var n = str . length ; if ( pos >= n / 2 ) { str . split ( ' ' ) . reverse ( ) . fill ( ' ' ) ; pos = n - pos - 1 ; } var left , right ; left = right = pos ; for ( var i = pos ; i >= 0 ; -- i ) { if ( str [ i ] != str [ n - i - 1 ] ) { left = i ; } } for ( var i = pos ; i < n / 2 ; ++ i ) { if ( str [ i ] != str [ n - i - 1 ] ) { right = i ; } } var ans = 0 ; for ( var i = left ; i <= right ; ++ i ) { if ( str [ i ] != str [ n - i - 1 ] ) ans += 1 ; } var dis = Math . min ( ( 2 * ( pos - left ) + ( right - pos ) ) , ( 2 * ( right - pos ) + ( pos - left ) ) ) ; ans = ans + dis ; return ans ; } var S = " " ; var P = 3 ; document . write ( findMinCost ( S , P ) ) ;

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Javascript program:
function minCost ( s , n ) { var minValue = 100000000 ; for ( var i = 0 ; i <= 25 ; i ++ ) { var cnt = 0 ; for ( var j = 0 ; j < n ; j ++ ) { cnt += Math . min ( Math . abs ( i - ( s [ j ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ) ) , 26 - Math . abs ( i - ( s [ j ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ) ) ) ; } minValue = Math . min ( minValue , cnt ) ; } return minValue ; } var str = " " ; var N = str . length ; document . write ( minCost ( str , N ) ) ;

Index/key variables: j
Accumulator variables: cnt, i, j
Iterator variables: i, j
Javascript program:
function reverse ( input ) { let a = input . split ( " " ) ; a . reverse ( ) ; return a . join ( " " ) ; } function max_len ( s , N , M ) { let set_str = new Set ( ) ; for ( let i = 0 ; i < N ; i ++ ) { set_str . add ( s [ i ] ) ; } let left_ans = [ ] ; let right_ans = [ ] ; let mid = " " ; for ( let i = 0 ; i < N ; i ++ ) { let t = s [ i ] ; t = reverse ( t ) ; if ( t == s [ i ] ) { mid = t ; } else if ( set_str . has ( t ) ) { left_ans . push ( s [ i ] ) ; right_ans . push ( t ) ; set_str . delete ( s [ i ] ) ; set_str . delete ( t ) ; } } for ( let x = 0 ; x < left_ans . length ; x ++ ) { document . write ( left_ans [ x ] ) ; } document . write ( mid ) ; ( right_ans ) . reverse ( ) ; for ( let x = 0 ; x < right_ans . length ; x ++ ) { document . write ( right_ans [ x ] ) ; } } let N = 4 , M = 3 ; let s = [ " " , " " , " " , " " ] ; max_len ( s , N , M ) ;

Index/key variables: i, x
Accumulator variables: i, x
Iterator variables: i, x
Javascript program:
function minimum_length ( x1 , y1 , x2 , y2 , str ) { var n = str . length ; var pos1 , pos2 , pos3 , pos4 ; pos1 = - 1 ; pos2 = - 1 ; pos3 = - 1 ; pos4 = - 1 ; if ( x1 == x2 && y1 == y2 ) { document . write ( 0 + " " ) ; } else { for ( var i = 0 ; i < n ; i ++ ) { if ( x2 > x1 ) { if ( str [ i ] == ' ' ) { x1 = x1 + 1 ; if ( x1 == x2 ) { pos1 = i ; } } } if ( x2 < x1 ) { if ( str [ i ] == ' ' ) { x1 = x1 - 1 ; if ( x1 == x2 ) { pos2 = i ; } } } if ( y2 > y1 ) { if ( str [ i ] == ' ' ) { y1 = y1 + 1 ; if ( y1 == y2 ) { pos3 = i ; } } } if ( y2 < y1 ) { if ( str [ i ] == ' ' ) { y1 = y1 - 1 ; if ( y1 == y2 ) { pos4 = i ; } } } } var z ; z = Math . max ( Math . max ( Math . max ( pos1 , pos2 ) , pos3 ) , pos4 ) ; if ( x1 == x2 && y1 == y2 ) { document . write ( z + 1 + " " ) ; } else { document . write ( " " ) ; ; } } } var str = " " ; var x1 = 0 , x2 = 1 , y1 = 0 , y2 = 1 ; minimum_length ( x1 , y1 , x2 , y2 , str ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function ShortenString ( str1 ) { var st = [ ] ; var i = 0 ; while ( i < str1 . length ) { if ( st . length == 0 str1 [ i ] != st [ st . length - 1 ] ) { st . push ( str1 [ i ] ) ; i ++ ; } else { st . pop ( ) ; i ++ ; } } if ( st . length == 0 ) { return ( " " ) ; } else { var short_string = " " ; while ( st . length != 0 ) { short_string = st [ st . length - 1 ] + short_string ; st . pop ( ) ; } return ( short_string ) ; } } var str1 = " " ; document . write ( ShortenString ( str1 ) ) ;

Index/key variables: i
Accumulator variables: i
Javascript program:
function fact ( n ) { var res = 1 ; for ( i = 1 ; i <= n ; i ++ ) { res = res * i ; } return res ; } function distinctWays ( str1 , str2 ) { var n = str1 . length ; var m = str2 . length ; if ( n == m ) { return 2 * fact ( n ) * fact ( m ) ; } return fact ( n ) * fact ( m ) ; } var str1 = " " ; var str2 = " " ; document . write ( distinctWays ( str1 , str2 ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function len ( A , B ) { let res = " " ; let Log = 0 ; do { Log = Math . floor ( Math . log ( B ) / Math . log ( 2 ) ) ; if ( Log != 0 ) { res = res + String ( A ) + " " + String ( Log ) ; } else { res += A ; break ; } B = B - Math . pow ( 2 , Log ) ; if ( B != 0 ) { res += " " ; } else break ; } while ( Log != 0 ) ; return res ; } function minimumString ( A , B ) { let res1 = len ( A , B ) ; let res2 = len ( B , A ) ; if ( res1 . length > res2 . length ) { document . write ( res2 + " " ) ; } else { document . write ( res1 + " " ) ; } } let A = 6 ; let B = 10 ; minimumString ( A , B ) ;

Accumulator variables: res
Javascript program:
function countSubString ( s ) { let res = 0 ; for ( let i = 0 ; i < s . length ; i ++ ) { let x = 0 ; for ( let j = i ; j < s . length ; j ++ ) { let temp = 1 << s [ j ] - ' ' ; x ^= temp ; if ( ( x & ( x - 1 ) ) == 0 ) res ++ ; } } document . write ( res ) ; } let str = " " ; countSubString ( str ) ;

Index/key variables: j
Accumulator variables: i, j, res, x
Iterator variables: i, j
Javascript program:
function countSubstring ( s ) { var answer = 0 ; var m = new Map ( ) ; m . set ( 0 , 1 ) ; var x = 0 ; for ( var j = 0 ; j < s . length ; j ++ ) { x ^= 1 << ( s [ j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ; answer += m . has ( x ) ? m . get ( x ) : 0 ; for ( var i = 0 ; i < 26 ; ++ i ) { answer += m . has ( x ^ ( 1 << i ) ) ? m . get ( x ^ ( 1 << i ) ) : 0 ; } if ( m . has ( x ) ) m . set ( x , m . get ( x ) + 1 ) else m . set ( x , 1 ) } document . write ( answer ) ; } var str = " " ; countSubstring ( str ) ;

Index/key variables: j
Accumulator variables: answer, j, x
Iterator variables: i, j
Javascript program:
function printResult ( result ) { result . reverse ( ) ; let i = 0 ; while ( i < result . length ) { document . write ( result [ i ] ) ; i ++ ; } } function sumOfLargeNumbers ( v , k , N ) { let x = [ ] ; for ( let i = 0 ; i < k ; i ++ ) x . push ( [ ] ) ; for ( let i = 0 ; i < k ; i ++ ) { for ( let j = 0 ; j < N ; j ++ ) { x [ i ] . push ( v [ i ] [ j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ; } } let carry = 0 ; let result = [ ] ; for ( let i = N - 1 ; i >= 0 ; i -- ) { let sum = 0 ; for ( let j = 0 ; j < k ; j ++ ) sum += x [ j ] [ i ] ; sum += carry ; let temp = sum ; let count = 0 ; while ( temp > 9 ) { temp = temp % 10 ; count ++ ; } let l = Math . pow ( 10 , count ) ; if ( l != 1 ) carry = Math . floor ( sum / l ) ; sum = sum % 10 ; result . push ( sum ) ; } while ( carry != 0 ) { let a = carry % 10 ; result . push ( a ) ; carry = Math . floor ( carry / 10 ) ; } printResult ( result ) ; } let K = 10 ; let N = 5 ; let arr = [ " " , " " , " " , " " , " " ] ; sumOfLargeNumbers ( arr , N , K ) ;

Index/key variables: i, j
Accumulator variables: count, i, j, sum
Iterator variables: i, j
Javascript program:
function printRev ( str ) { let st = [ ] ; let ss = str . split ( " " ) ; for ( let temp = 0 ; temp < ss . length ; temp ++ ) { st . push ( ss [ temp ] ) ; } while ( st . length != 0 ) { document . write ( st . pop ( ) + " " ) ; } } let str ; str = " " ; printRev ( str ) ;

Index/key variables: temp
Accumulator variables: temp
Iterator variables: temp
Javascript program:
function countOfSubstringWithOnlyOnes ( s ) { var res = 0 , count = 0 ; for ( var i = 0 ; i < s . length ; i ++ ) { count = s [ i ] == ' ' ? count + 1 : 0 ; res = ( res + count ) ; } return res ; } var s = " " ; document . write ( countOfSubstringWithOnlyOnes ( s ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
var mod = 10007 ; function binExp ( base , power ) { var x = 1 ; while ( power != 0 ) { if ( power % 2 == 1 ) x = ( ( ( x % mod ) * ( base % mod ) ) % mod ) ; base = ( ( ( base % mod ) * ( base % mod ) ) % mod ) ; power = parseInt ( power / 2 ) ; } return x ; } function fact ( num ) { var result = 1 ; for ( var i = 1 ; i <= num ; ++ i ) { result = ( ( ( result % mod ) * ( i % mod ) ) % mod ) ; } return result ; } function calculate_nCi ( N , i ) { var nfact = fact ( N ) ; var ifact = fact ( i ) ; var dfact = fact ( N - i ) ; var inv_ifact = binExp ( ifact , mod - 2 ) ; var inv_dfact = binExp ( dfact , mod - 2 ) ; var denm = ( ( ( inv_ifact % mod ) * ( inv_dfact % mod ) ) % mod ) ; var answer = ( ( ( nfact % mod ) * ( denm % mod ) ) % mod ) ; return answer ; } function countSubstring ( N , s , k ) { var allWays = binExp ( 26 , N ) ; var noWays = 0 ; for ( var i = 0 ; i < s ; ++ i ) { var nCi = calculate_nCi ( N , i ) ; var remaining = binExp ( 25 , N - i ) ; var multiply = ( ( ( nCi % mod ) * ( remaining % mod ) ) % mod ) ; noWays = ( ( ( noWays % mod ) + ( multiply % mod ) ) % mod ) ; } var answer = ( ( ( allWays % mod ) - ( noWays % mod ) ) % mod ) ; if ( answer < 0 ) answer += mod ; document . write ( answer ) ; } var str = " " ; var k = 2 ; var s = str . length ; var N = s + k ; countSubstring ( N , s , k ) ;

Accumulator variables: answer
Iterator variables: i
Javascript program:
var N = 1000005 ; var prefix = Array ( N ) . fill ( 0 ) ; var sum = Array ( N ) . fill ( 0 ) ; function isSpecial ( c , special ) { var ans = false ; special . forEach ( i => { if ( i == c ) ans = true ; } ) ; return ans ; } function countRatio ( s , special ) { var n = s . length ; for ( var i = 0 ; i < n ; i ++ ) { prefix [ i ] = ( isSpecial ( s [ i ] , special ) ) ; if ( i > 0 ) prefix [ i ] += prefix [ i - 1 ] ; } for ( var i = 0 ; i < n ; i ++ ) { sum [ i ] = prefix [ i ] ; if ( i > 0 ) sum [ i ] += sum [ i - 1 ] ; } var ans = 0 ; for ( var i = 1 ; i <= n ; i ++ ) { var count = sum [ n - 1 ] - ( ( i > 1 ) ? sum [ i - 2 ] : 0 ) ; count -= ( ( i < n ) ? sum [ n - i - 1 ] : 0 ) ; ans += ( ( count ) / ( i ) ) ; } return ans ; } var s = " " ; var special = [ ' ' , ' ' ] ; var ans = countRatio ( s . split ( ' ' ) , special ) ; document . write ( ans . toFixed ( 6 ) ) ;

Index/key variables: i
Accumulator variables: ans, count, i
Iterator variables: i
Boolean variables: ans
Javascript program:
function count_minimum ( s ) { var n = s . length ; var ans = 0 ; var i = 0 ; while ( i < n ) { var j = i ; while ( s [ j ] === s [ i ] && j < n ) { j ++ ; } var diff = j - i ; ans += parseInt ( diff / 2 ) ; i = j ; } document . write ( ans + " " ) ; } var str = " " ; count_minimum ( str ) ;

Index/key variables: i, j
Accumulator variables: ans, j
Javascript program:
function isPalindrome ( str ) { var l = 0 ; var h = str . length - 1 ; while ( h > l ) { if ( str . charAt ( l ++ ) != str . charAt ( h -- ) ) return false ; } return true ; } function makeOddString ( str ) { var odd = " " ; for ( var i = 1 ; i < str . length ; i += 2 ) { odd += str . charAt ( i ) ; } return odd ; } function makeevenString ( str ) { var even = " " ; for ( var i = 0 ; i < str . length ; i += 2 ) { even += str . charAt ( i ) ; } return even ; } function checkevenOddPalindrome ( str ) { var odd = makeOddString ( str ) ; var even = makeevenString ( str ) ; if ( isPalindrome ( odd ) && isPalindrome ( even ) ) document . write ( " " ) ; else document . write ( " " ) ; } var str = " " ; checkevenOddPalindrome ( str ) ;

Accumulator variables: even, h, i, l, odd
Iterator variables: i
Javascript program:
function count_Strings ( n ) { var x = 1 ; for ( i = 1 ; i < n ; i ++ ) { x = ( 1 << x ) ; } return x - 1 ; } var n = 3 ; document . write ( count_Strings ( n ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function decrypt ( Str , Start , End ) { if ( Start > End ) { return ; } let mid = ( Start + End ) >> 1 ; document . write ( Str [ mid ] ) ; decrypt ( Str , mid + 1 , End ) ; decrypt ( Str , Start , mid - 1 ) ; } let N = 4 ; let Str = " " ; decrypt ( Str , 0 , N - 1 ) ; document . write ( " " ) ; N = 6 ; Str = " " ; decrypt ( Str , 0 , N - 1 ) ;

Index/key variables: mid
Javascript program:
function isSuffix ( s1 , s2 ) { var n1 = s1 . length ; var n2 = s2 . length ; if ( n1 > n2 ) return false ; for ( var i = 0 ; i < n1 ; i ++ ) if ( s1 [ n1 - i - 1 ] != s2 [ n2 - i - 1 ] ) return false ; return true ; } function CheckBinaryEquivalent ( N , str ) { var B_Number = 0 ; var cnt = 0 ; while ( N != 0 ) { var rem = N % 2 ; var c = Math . pow ( 10 , cnt ) ; B_Number += rem * c ; N = parseInt ( N / 2 ) ; cnt ++ ; } var bin = B_Number . toString ( ) ; return isSuffix ( str , bin ) ; } var N = 23 ; var str = " " ; if ( CheckBinaryEquivalent ( N , str ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: B_Number, cnt, i
Iterator variables: i