dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Linq ; class GFG { static int N = 100000 + 5 ; static int [ ] visited = new int [ N ] ; static void construct_tree ( int [ ] weights , int n ) { int minimum = weights . Min ( ) ; int maximum = weights . Max ( ) ; if ( minimum == maximum ) { Console . WriteLine ( " No " ) ; return ; } else { Console . WriteLine ( " Yes " ) ; } int root = weights [ 0 ] ; visited [ 1 ] = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( weights [ i ] != root && visited [ i + 1 ] == 0 ) { Console . WriteLine ( 1 + " ▁ " + ( i + 1 ) + " ▁ " ) ; visited [ i + 1 ] = 1 ; } } int notroot = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( weights [ i ] != root ) { notroot = i + 1 ; break ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( weights [ i ] == root && visited [ i + 1 ] == 0 ) { Console . WriteLine ( notroot + " ▁ " + ( i + 1 ) ) ; visited [ i + 1 ] = 1 ; } } } public static void Main ( ) { int [ ] weights = { 1 , 2 , 1 , 2 , 5 } ; int N = weights . Length ; construct_tree ( weights , N ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minCost ( string s , int k ) { int n = s . Length ; int ans = 0 ; for ( int i = 0 ; i < k ; i ++ ) { int [ ] a = new int [ 26 ] ; for ( int j = i ; j < n ; j += k ) { a [ s [ j ] - ' a ' ] ++ ; } int min_cost = Int32 . MaxValue ; for ( int ch = 0 ; ch < 26 ; ch ++ ) { int cost = 0 ; for ( int tr = 0 ; tr < 26 ; tr ++ ) cost += Math . Abs ( ch - tr ) * a [ tr ] ; min_cost = Math . Min ( min_cost , cost ) ; } ans += min_cost ; } Console . WriteLine ( ans ) ; } public static void Main ( ) { string S = " abcdefabc " ; int K = 3 ; minCost ( S , K ) ; } }

Index/key variables: j, tr
Accumulator variables: ans, ch, cost, i, j, tr
Iterator variables: ch, i, j, tr
Class/struct names: GFG
C# program:
using System ; class GFG { static int minAbsDiff ( int N ) { if ( N % 4 == 0 N % 4 == 3 ) { return 0 ; } return 1 ; } public static void Main ( String [ ] args ) { int N = 6 ; Console . WriteLine ( minAbsDiff ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int N = 10000 ; static List < int > [ ] adj = new List < int > [ N ] ; static int [ ] used = new int [ N ] ; static int max_matching ; static void AddEdge ( int u , int v ) { adj [ u ] . Add ( v ) ; adj [ v ] . Add ( u ) ; } static void Matching_dfs ( int u , int p ) { for ( int i = 0 ; i < adj [ u ] . Count ; i ++ ) { if ( adj [ u ] [ i ] != p ) { Matching_dfs ( adj [ u ] [ i ] , u ) ; } } if ( used [ u ] == 0 && used [ p ] == 0 && p != 0 ) { max_matching ++ ; used [ u ] = used [ p ] = 1 ; } } static void maxMatching ( ) { Matching_dfs ( 1 , 0 ) ; Console . Write ( max_matching + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { for ( int i = 0 ; i < adj . Length ; i ++ ) adj [ i ] = new List < int > ( ) ; AddEdge ( 1 , 2 ) ; AddEdge ( 1 , 3 ) ; AddEdge ( 3 , 4 ) ; AddEdge ( 3 , 5 ) ; maxMatching ( ) ; } }

Index/key variables: N, i, p, u, v
Accumulator variables: i, max_matching
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getMinCost ( int [ ] A , int [ ] B , int N ) { int mini = int . MaxValue ; for ( int i = 0 ; i < N ; i ++ ) { mini = Math . Min ( mini , Math . Min ( A [ i ] , B [ i ] ) ) ; } return mini * ( 2 * N - 1 ) ; } public static void Main ( String [ ] args ) { int N = 3 ; int [ ] A = { 1 , 4 , 2 } ; int [ ] B = { 10 , 6 , 12 } ; Console . Write ( getMinCost ( A , B , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printList ( List < int > arr ) { if ( arr . Count != 1 ) { for ( int i = 0 ; i < arr . Count ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } static void findWays ( List < int > arr , int i , int n ) { if ( n == 0 ) printList ( arr ) ; for ( int j = i ; j <= n ; j ++ ) { arr . Add ( j ) ; findWays ( arr , j , n - j ) ; arr . RemoveAt ( arr . Count - 1 ) ; } } public static void Main ( String [ ] args ) { int n = 4 ; List < int > arr = new List < int > ( ) ; findWays ( arr , 1 , n ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void Maximum_subsequence ( int [ ] A , int N ) { Dictionary < int , int > frequency = new Dictionary < int , int > ( ) ; int max_freq = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( frequency . ContainsKey ( A [ i ] ) ) { frequency [ A [ i ] ] = frequency [ A [ i ] ] + 1 ; } else { frequency . Add ( A [ i ] , 1 ) ; } } foreach ( KeyValuePair < int , int > it in frequency ) { if ( ( int ) it . Value > max_freq ) { max_freq = ( int ) it . Value ; } } Console . WriteLine ( max_freq ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 2 , 6 , 5 , 2 , 4 , 5 , 2 } ; int N = arr . Length ; Maximum_subsequence ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void DivideString ( string s , int n , int k ) { int i , c = 0 , no = 1 ; int c1 = 0 , c2 = 0 ; int [ ] fr = new int [ 26 ] ; char [ ] ans = new char [ n ] ; for ( i = 0 ; i < n ; i ++ ) { fr [ s [ i ] - ' a ' ] ++ ; } char ch = ' a ' , ch1 = ' a ' ; for ( i = 0 ; i < 26 ; i ++ ) { if ( fr [ i ] == k ) { c ++ ; } if ( fr [ i ] > k && fr [ i ] != 2 * k ) { c1 ++ ; ch = ( char ) ( i + ' a ' ) ; } if ( fr [ i ] == 2 * k ) { c2 ++ ; ch1 = ( char ) ( i + ' a ' ) ; } } for ( i = 0 ; i < n ; i ++ ) ans [ i ] = '1' ; Dictionary < char , int > mp = new Dictionary < char , int > ( ) ; if ( c % 2 == 0 c1 > 0 c2 > 0 ) { for ( i = 0 ; i < n ; i ++ ) { if ( fr [ s [ i ] - ' a ' ] == k ) { if ( mp . ContainsKey ( s [ i ] ) ) { ans [ i ] = '2' ; } else { if ( no <= ( c / 2 ) ) { ans [ i ] = '2' ; no ++ ; mp [ s [ i ] ] = 1 ; } } } } if ( ( c % 2 == 1 ) && ( c1 > 0 ) ) { no = 1 ; for ( i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ch && no <= k ) { ans [ i ] = '2' ; no ++ ; } } } if ( c % 2 == 1 && c1 == 0 ) { no = 1 ; int flag = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ch1 && no <= k ) { ans [ i ] = '2' ; no ++ ; } if ( fr [ s [ i ] - ' a ' ] == k && flag == 0 && ans [ i ] == '1' ) { ans [ i ] = '2' ; flag = 1 ; } } } Console . Write ( ans ) ; } else { Console . Write ( " NO " ) ; } } public static void Main ( string [ ] args ) { string S = " abbbccc " ; int N = S . Length ; int K = 1 ; DivideString ( S , N , K ) ; } }

Index/key variables: i, n
Accumulator variables: c, c1, c2, i, no
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String check ( int S , int [ ] prices , int [ ] type , int n ) { for ( int j = 0 ; j < n ; j ++ ) { for ( int k = j + 1 ; k < n ; k ++ ) { if ( ( type [ j ] == 0 && type [ k ] == 1 ) || ( type [ j ] == 1 && type [ k ] == 0 ) ) { if ( prices [ j ] + prices [ k ] <= S ) { return " Yes " ; } } } } return " No " ; } public static void Main ( String [ ] args ) { int [ ] prices = { 3 , 8 , 6 , 5 } ; int [ ] type = { 0 , 1 , 1 , 0 } ; int S = 10 ; int n = 4 ; Console . Write ( check ( S , prices , type , n ) ) ; } }

Index/key variables: j, k
Accumulator variables: j, k
Iterator variables: j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int getLargestSum ( int N ) { int max_sum = 0 ; for ( int i = 1 ; i * i <= N ; i ++ ) { for ( int j = i + 1 ; j * j <= N ; j ++ ) { int k = N / j ; int a = k * i ; int b = k * j ; if ( a <= N && b <= N && a * b % ( a + b ) == 0 ) max_sum = Math . Max ( max_sum , a + b ) ; } } return max_sum ; } static public void Main ( String [ ] args ) { int N = 25 ; int max_sum = getLargestSum ( N ) ; Console . Write ( max_sum + " STRNEWLINE " ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static String encryptString ( String str , int n ) { int i = 0 , cnt = 0 ; String encryptedStr = " " ; while ( i < n ) { cnt = i + 1 ; while ( cnt -- > 0 ) encryptedStr += str [ i ] ; i ++ ; } return encryptedStr ; } static public void Main ( ) { String str = " geeks " ; int n = str . Length ; Console . WriteLine ( encryptString ( str , n ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, encryptedStr, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minDiff ( int n , int x , int [ ] A ) { int mn = A [ 0 ] , mx = A [ 0 ] ; for ( int i = 0 ; i < n ; ++ i ) { mn = Math . Min ( mn , A [ i ] ) ; mx = Math . Max ( mx , A [ i ] ) ; } return Math . Max ( 0 , mx - mn - 2 * x ) ; } public static void Main ( ) { int n = 3 , x = 3 ; int [ ] A = { 1 , 3 , 6 } ; Console . WriteLine ( minDiff ( n , x , A ) ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static long swapCount ( string s ) { char [ ] chars = s . ToCharArray ( ) ; int countLeft = 0 , countRight = 0 ; int swap = 0 , imbalance = 0 ; for ( int i = 0 ; i < chars . Length ; i ++ ) { if ( chars [ i ] == ' [ ' ) { countLeft ++ ; if ( imbalance > 0 ) { swap += imbalance ; imbalance -- ; } } else if ( chars [ i ] == ' ] ' ) { countRight ++ ; imbalance = ( countRight - countLeft ) ; } } return swap ; } public static void Main ( string [ ] args ) { string s = " [ ] ] [ ] [ " ; Console . WriteLine ( swapCount ( s ) ) ; s = " [ [ ] [ ] ] " ; Console . WriteLine ( swapCount ( s ) ) ; } }

Index/key variables: i
Accumulator variables: countLeft, countRight, i, imbalance, swap
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void longestSubSequence ( int [ , ] A , int N ) { int [ ] dp = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { dp [ i ] = 1 ; for ( int j = 0 ; j < i ; j ++ ) { if ( A [ j , 0 ] < A [ i , 0 ] && A [ j , 1 ] > A [ i , 1 ] ) { dp [ i ] = Math . Max ( dp [ i ] , dp [ j ] + 1 ) ; } } } Console . Write ( dp [ N - 1 ] ) ; } static void Main ( ) { int [ , ] A = { { 1 , 2 } , { 2 , 2 } , { 3 , 1 } } ; int N = A . GetLength ( 0 ) ; longestSubSequence ( A , N ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findWays ( int N , int [ ] dp ) { if ( N == 0 ) { return 1 ; } if ( dp [ N ] != - 1 ) { return dp [ N ] ; } int cnt = 0 ; for ( int i = 1 ; i <= 6 ; i ++ ) { if ( N - i >= 0 ) { cnt = cnt + findWays ( N - i , dp ) ; } } return dp [ N ] = cnt ; } public static void Main ( String [ ] args ) { int N = 4 ; int [ ] dp = new int [ N + 1 ] ; for ( int i = 0 ; i < dp . Length ; i ++ ) dp [ i ] = - 1 ; Console . Write ( findWays ( N , dp ) ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findWays ( int N ) { int [ ] dp = new int [ N + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { dp [ i ] = 0 ; for ( int j = 1 ; j <= 6 ; j ++ ) { if ( i - j >= 0 ) { dp [ i ] = dp [ i ] + dp [ i - j ] ; } } } Console . Write ( dp [ N ] ) ; } public static void Main ( String [ ] args ) { int N = 4 ; findWays ( N ) ; } }

Index/key variables: N, i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int INF = ( int ) ( 1e9 + 9 ) ; class TrieNode { public TrieNode [ ] child = new TrieNode [ 26 ] ; } ; static void insert ( int idx , String s , TrieNode root ) { TrieNode temp = root ; for ( int i = idx ; i < s . Length ; i ++ ) { if ( temp . child [ s [ i ] - ' a ' ] == null ) temp . child [ s [ i ] - ' a ' ] = new TrieNode ( ) ; temp = temp . child [ s [ i ] - ' a ' ] ; } } static int minCuts ( String S1 , String S2 ) { int n1 = S1 . Length ; int n2 = S2 . Length ; TrieNode root = new TrieNode ( ) ; for ( int i = 0 ; i < n2 ; i ++ ) { insert ( i , S2 , root ) ; } int [ ] dp = new int [ n1 + 1 ] ; for ( int i = 0 ; i <= n1 ; i ++ ) dp [ i ] = INF ; dp [ 0 ] = 0 ; for ( int i = 0 ; i < n1 ; i ++ ) { TrieNode temp = root ; for ( int j = i + 1 ; j <= n1 ; j ++ ) { if ( temp . child [ S1 [ j - 1 ] - ' a ' ] == null ) break ; dp [ j ] = Math . Min ( dp [ j ] , dp [ i ] + 1 ) ; temp = temp . child [ S1 [ j - 1 ] - ' a ' ] ; } } if ( dp [ n1 ] >= INF ) return - 1 ; else return dp [ n1 ] ; } public static void Main ( String [ ] args ) { String S1 = " abcdab " ; String S2 = " dabc " ; Console . Write ( minCuts ( S1 , S2 ) ) ; } }

Index/key variables: i, j, n1
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, TrieNode
C# program:
using System . Collections . Generic ; using System ; class GFG { static void largestSquare ( int [ , ] matrix , int R , int C , int [ ] q_i , int [ ] q_j , int K , int Q ) { int [ , ] countDP = new int [ R , C ] ; for ( int i = 0 ; i < R ; i ++ ) for ( int j = 0 ; j < C ; j ++ ) countDP [ i , j ] = 0 ; countDP [ 0 , 0 ] = matrix [ 0 , 0 ] ; for ( int i = 1 ; i < R ; i ++ ) countDP [ i , 0 ] = countDP [ i - 1 , 0 ] + matrix [ i , 0 ] ; for ( int j = 1 ; j < C ; j ++ ) countDP [ 0 , j ] = countDP [ 0 , j - 1 ] + matrix [ 0 , j ] ; for ( int i = 1 ; i < R ; i ++ ) for ( int j = 1 ; j < C ; j ++ ) countDP [ i , j ] = matrix [ i , j ] + countDP [ i - 1 , j ] + countDP [ i , j - 1 ] - countDP [ i - 1 , j - 1 ] ; for ( int q = 0 ; q < Q ; q ++ ) { int i = q_i [ q ] ; int j = q_j [ q ] ; int min_dist = Math . Min ( Math . Min ( i , j ) , Math . Min ( R - i - 1 , C - j - 1 ) ) ; int ans = - 1 , l = 0 , u = min_dist ; while ( l <= u ) { int mid = ( l + u ) / 2 ; int x1 = i - mid , x2 = i + mid ; int y1 = j - mid , y2 = j + mid ; int count = countDP [ x2 , y2 ] ; if ( x1 > 0 ) count -= countDP [ x1 - 1 , y2 ] ; if ( y1 > 0 ) count -= countDP [ x2 , y1 - 1 ] ; if ( x1 > 0 && y1 > 0 ) count += countDP [ x1 - 1 , y1 - 1 ] ; if ( count <= K ) { ans = 2 * mid + 1 ; l = mid + 1 ; } else u = mid - 1 ; } Console . WriteLine ( ans ) ; } } public static void Main ( ) { int [ , ] matrix = { { 1 , 0 , 1 , 0 , 0 } , { 1 , 0 , 1 , 1 , 1 } , { 1 , 1 , 1 , 1 , 1 } , { 1 , 0 , 0 , 1 , 0 } } ; int K = 9 , Q = 1 ; int [ ] q_i = { 1 } ; int [ ] q_j = { 2 } ; largestSquare ( matrix , 4 , 5 , q_i , q_j , K , Q ) ; } }

Index/key variables: q
Accumulator variables: count, i, j, q
Iterator variables: i, j, q
Class/struct names: GFG
Javascript program:
function minSum ( A , N ) { let mp = new Map ( ) ; let sum = 0 ; for ( let i = 0 ; i < N ; i ++ ) { sum += A [ i ] ; mp [ A [ i ] ] ++ ; if ( mp . has ( A [ i ] ) ) { mp . set ( A [ i ] , mp . get ( A [ i ] ) + 1 ) } else { mp . set ( A [ i ] , 1 ) } } let minSum = Number . MAX_SAFE_INTEGER ; for ( let it of mp ) { minSum = Math . min ( minSum , sum - ( it [ 0 ] * it [ 1 ] ) ) ; } return minSum ; } let arr = [ 4 , 5 , 6 , 6 ] ; let N = arr . length document . write ( minSum ( arr , N ) + " " ) ;

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i, it
Javascript program:
function maxAdjacent ( arr , N ) { var res = [ ] ; for ( var i = 1 ; i < N - 1 ; i ++ ) { var prev = arr [ 0 ] ; var maxi = Number . MIN_VALUE ; for ( var j = 1 ; j < N ; j ++ ) { if ( i == j ) continue ; maxi = Math . max ( maxi , Math . abs ( arr [ j ] - prev ) ) ; prev = arr [ j ] ; } res . push ( maxi ) ; } for ( var j = 0 ; j < res . length ; j ++ ) document . write ( res [ j ] + " " ) ; document . write ( " " ) ; } var arr = [ 1 , 3 , 4 , 7 , 8 ] ; var N = arr . length ; maxAdjacent ( arr , N ) ;

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function findSize ( N ) { if ( N == 0 ) return 1 ; if ( N == 1 ) return 1 ; let Size = 2 * findSize ( parseInt ( N / 2 , 10 ) ) + 1 ; return Size ; } function CountOnes ( N , L , R ) { if ( L > R ) { return 0 ; } if ( N <= 1 ) { return N ; } let ret = 0 ; let M = parseInt ( N / 2 , 10 ) ; let Siz_M = findSize ( M ) ; if ( L <= Siz_M ) { ret += CountOnes ( parseInt ( N / 2 , 10 ) , L , Math . min ( Siz_M , R ) ) ; } if ( L <= Siz_M + 1 && Siz_M + 1 <= R ) { ret += N % 2 ; } if ( Siz_M + 1 < R ) { ret += CountOnes ( parseInt ( N / 2 , 10 ) , Math . max ( 1 , L - Siz_M - 1 ) , R - Siz_M - 1 ) ; } return ret ; } let N = 7 , L = 2 , R = 5 ; document . write ( CountOnes ( N , L , R ) ) ;

Accumulator variables: ret
Javascript program:
function prime ( n ) { if ( n == 1 ) return false ; for ( i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } function minDivisior ( n ) { if ( prime ( n ) ) { document . write ( 1 + " " + ( n - 1 ) ) ; } else { for ( i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { document . write ( n / i + " " + ( n / i * ( i - 1 ) ) ) ; break ; } } } } var N = 4 ; minDivisior ( N ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
var Landau = - 1000000000 ; function gcd ( a , b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } function lcm ( a , b ) { return ( a * b ) / gcd ( a , b ) ; } function findLCM ( arr ) { var nth_lcm = arr [ 0 ] ; for ( var i = 1 ; i < arr . length ; i ++ ) nth_lcm = lcm ( nth_lcm , arr [ i ] ) ; Landau = Math . max ( Landau , nth_lcm ) ; } function findWays ( arr , i , n ) { if ( n == 0 ) findLCM ( arr ) ; for ( var j = i ; j <= n ; j ++ ) { arr . push ( j ) ; findWays ( arr , j , n - j ) ; arr . pop ( ) ; } } function Landau_function ( n ) { arr = [ ] ; findWays ( arr , 1 , n ) ; document . write ( Landau ) ; } var N = 4 ; Landau_function ( N ) ;

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isPrime ( n ) { if ( n == 1 ) return true ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( let i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } function checkExpression ( n ) { if ( isPrime ( n ) ) document . write ( " " ) ; else document . write ( " " ) ; } let N = 3 ; checkExpression ( N ) ;

Iterator variables: i
Javascript program:
function checkArray ( n , k , arr ) { var cnt = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] & 1 ) != 0 ) cnt += 1 ; } if ( cnt >= k && cnt % 2 == k % 2 ) return true ; else return false ; } var arr = [ 1 , 3 , 4 , 7 , 5 , 3 , 1 ] ; var n = arr . length ; var k = 4 ; if ( checkArray ( n , k , arr ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function func ( arr , n ) { let ans = 0 ; let maxx = 0 ; let freq = Array . from ( { length : 100005 } , ( _ , i ) => 0 ) ; let temp ; for ( let i = 0 ; i < n ; i ++ ) { temp = arr [ i ] ; freq [ temp ] ++ ; maxx = Math . max ( maxx , temp ) ; } for ( let i = 1 ; i <= maxx ; i ++ ) { freq [ i ] += freq [ i - 1 ] ; } for ( let i = 1 ; i <= maxx ; i ++ ) { if ( freq [ i ] != 0 ) { let j ; let cur = Math . ceil ( 0.5 * i ) - 1.0 ; for ( j = 1.5 ; ; j ++ ) { let val = Math . min ( maxx , ( Math . ceil ( i * j ) - 1.0 ) ) ; let times = ( freq [ i ] - freq [ i - 1 ] ) , con = ( j - 0.5 ) ; ans += times * con * ( freq [ val ] - freq [ cur ] ) ; cur = val ; if ( val == maxx ) break ; } } } return ans ; } let arr = [ 1 , 2 , 3 ] ; let n = arr . length ; document . write ( func ( arr , n ) ) ;

Index/key variables: cur, i, temp, val
Accumulator variables: ans, i, j
Iterator variables: i, j
Javascript program:
function insert_element ( a , n ) { let Xor = 0 ; let Sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { Xor ^= a [ i ] ; Sum += a [ i ] ; } if ( Sum == 2 * Xor ) { document . write ( " " + " " ) ; return ; } if ( Xor == 0 ) { document . write ( " " + " " ) ; document . write ( Sum + " " ) ; return ; } let num1 = Sum + Xor ; let num2 = Xor ; document . write ( " " + " " ) ; document . write ( num1 + " " + num2 + " " ) ; } let a = [ 1 , 2 , 3 ] ; let n = a . length ; insert_element ( a , n ) ;

Index/key variables: i
Accumulator variables: Sum, Xor, i
Iterator variables: i
Javascript program:
function countValues ( n ) { let answer = 0 ; for ( let i = 2 ; i <= n ; i ++ ) { let k = n ; while ( k >= i ) { if ( k % i == 0 ) k /= i ; else k -= i ; } if ( k == 1 ) answer ++ ; } return answer ; } let N = 6 ; document . write ( countValues ( N ) ) ;

Accumulator variables: answer, i, k
Iterator variables: i
Javascript program:
function printKNumbers ( N , K ) { for ( let i = 0 ; i < K - 1 ; i ++ ) document . write ( 1 + " " ) ; document . write ( N - K + 1 ) ; } let N = 10 , K = 3 ; printKNumbers ( N , K ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function NthSmallest ( K ) { var Q = [ ] ; var x ; for ( var i = 1 ; i < 10 ; i ++ ) Q . push ( i ) ; for ( var i = 1 ; i <= K ; i ++ ) { x = Q [ 0 ] ; Q . shift ( ) ; if ( x % 10 != 0 ) { Q . push ( x * 10 + x % 10 - 1 ) ; } Q . push ( x * 10 + x % 10 ) ; if ( x % 10 != 9 ) { Q . push ( x * 10 + x % 10 + 1 ) ; } } return x ; } var N = 16 ; document . write ( NthSmallest ( N ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function decBinary ( arr , n ) { let k = parseInt ( Math . log2 ( n ) , 10 ) ; while ( n > 0 ) { arr [ k -- ] = n % 2 ; n = parseInt ( n / 2 , 10 ) ; } } function binaryDec ( arr , n ) { let ans = 0 ; for ( let i = 0 ; i < n ; i ++ ) ans += arr [ i ] << ( n - i - 1 ) ; return ans ; } function getNum ( n , k ) { let l = parseInt ( Math . log2 ( n ) , 10 ) + 1 ; let a = new Array ( l ) ; a . fill ( 0 ) ; decBinary ( a , n ) ; if ( k > l ) return n ; a [ k - 1 ] = ( a [ k - 1 ] == 0 ) ? 1 : 0 ; return binaryDec ( a , l ) ; } let n = 56 , k = 2 ; document . write ( getNum ( n , k ) ) ;

Index/key variables: i
Accumulator variables: ans, i, k
Iterator variables: i
Javascript program:
let MAX = 1000000 ; let MOD = 10000007 ; let result = new Array ( MAX + 1 ) ; result . fill ( 0 ) ; let fact = new Array ( MAX + 1 ) ; fact . fill ( 0 ) ; function preCompute ( ) { fact [ 0 ] = 1 ; result [ 0 ] = 1 ; for ( let i = 1 ; i <= MAX ; i ++ ) { fact [ i ] = ( ( fact [ i - 1 ] % MOD ) * i ) % MOD ; result [ i ] = ( ( result [ i - 1 ] % MOD ) * ( fact [ i ] % MOD ) ) % MOD ; } } function performQueries ( q , n ) { preCompute ( ) ; for ( let i = 0 ; i < n ; i ++ ) document . write ( result [ q [ i ] ] + " " ) ; } let q = [ 4 , 5 ] ; let n = q . length ; performQueries ( q , n ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
let MAXN = 1000001 ; let spf = new Array ( MAXN ) ; let hash1 = new Array ( MAXN ) ; function sieve ( ) { spf [ 1 ] = 1 ; for ( let i = 2 ; i < MAXN ; i ++ ) spf [ i ] = i ; for ( let i = 4 ; i < MAXN ; i += 2 ) spf [ i ] = 2 ; for ( let i = 3 ; i * i < MAXN ; i ++ ) { if ( spf [ i ] == i ) { for ( let j = i * i ; j < MAXN ; j += i ) if ( spf [ j ] == j ) spf [ j ] = i ; } } } function getFactorization ( x ) { let temp ; while ( x != 1 ) { temp = spf [ x ] ; if ( x % temp == 0 ) { hash1 [ spf [ x ] ] ++ ; x = x / spf [ x ] ; } while ( x % temp == 0 ) x = x / temp ; } } function check ( x ) { let temp ; while ( x != 1 ) { temp = spf [ x ] ; if ( x % temp == 0 && hash1 [ temp ] > 1 ) return false ; while ( x % temp == 0 ) x = x / temp ; } return true ; } function hasValidNum ( arr , n ) { sieve ( ) ; for ( let i = 0 ; i < n ; i ++ ) getFactorization ( arr [ i ] ) ; for ( let i = 0 ; i < n ; i ++ ) if ( check ( arr [ i ] ) ) return true ; return false ; } let arr = [ 2 , 8 , 4 , 10 , 6 , 7 ] ; let n = arr . length ; if ( hasValidNum ( arr , n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j, temp, x
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
let l = new Array ( 1001 ) . fill ( 0 ) . map ( ( ) => new Array ( 1001 ) . fill ( 0 ) ) ; function initialize ( ) { l [ 0 ] [ 0 ] = 1 ; for ( let i = 1 ; i < 1001 ; i ++ ) { l [ i ] [ 0 ] = 1 ; for ( let j = 1 ; j < i + 1 ; j ++ ) { l [ i ] [ j ] = ( l [ i - 1 ] [ j - 1 ] + l [ i - 1 ] [ j ] ) ; } } } function nCr ( n , r ) { return l [ n ] [ r ] ; } initialize ( ) ; let n = 8 ; let r = 3 ; document . write ( nCr ( n , r ) ) ;

Index/key variables: i, j, n, r
Accumulator variables: i, j
Iterator variables: i, j