dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minSum ( int [ ] a , int n , int k ) { List < int > q = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { q . Add ( a [ i ] ) ; } q . Sort ( ) ; while ( q . Count != 0 && k > 0 ) { int top = q [ q . Count - 1 ] / 2 ; q [ q . Count - 1 ] = top ; k -- ; q . Sort ( ) ; } int sum = 0 ; while ( q . Count != 0 ) { sum += q [ 0 ] ; q . RemoveAt ( 0 ) ; } return sum ; } static public void Main ( ) { int n = 4 ; int k = 3 ; int [ ] a = { 20 , 7 , 5 , 4 } ; Console . WriteLine ( minSum ( a , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, k, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static void add_seg ( int [ ] seg , int start , int end , int current , int index ) { if ( index > end index < start ) return ; if ( start == end ) { seg [ current ] = 1 ; return ; } int mid = ( start + end ) / 2 ; add_seg ( seg , start , mid , 2 * current + 1 , index ) ; add_seg ( seg , mid + 1 , end , 2 * current + 2 , index ) ; seg [ current ] = seg [ 2 * current + 1 ] + seg [ 2 * current + 2 ] ; } static int deleted ( int [ ] seg , int l , int r , int start , int end , int current ) { if ( end < l start > r ) return 0 ; if ( start >= l && end <= r ) return seg [ current ] ; int mid = ( start + end ) / 2 ; return deleted ( seg , l , r , start , mid , 2 * current + 1 ) + deleted ( seg , l , r , mid + 1 , end , 2 * current + 2 ) ; } static void sumOfIndices ( string s ) { int N = s . Length ; int x = ( int ) ( Math . Ceiling ( Math . Log ( N ) / Math . Log ( 2 ) ) ) ; int seg_size = 2 * ( int ) Math . Pow ( 2 , x ) - 1 ; int [ ] segment = new int [ seg_size ] ; int count = 4 ; Dictionary < int , List < int > > fre = new Dictionary < int , List < int > > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int key = ( int ) ( s [ i ] ) ; List < int > que = new List < int > ( ) ; if ( fre . ContainsKey ( key ) ) { que = fre [ key ] ; } que . Add ( i ) ; fre [ key ] = que ; } while ( fre . Count > 0 ) { int it = fre . Keys . First ( ) ; if ( fre [ it ] . Count == 0 ) fre . Remove ( it ) ; else { List < int > que = fre [ it ] ; int original_index = que [ 0 ] ; int curr_index = deleted ( segment , 0 , original_index - 1 , 0 , N - 1 , 0 ) ; int new_index = original_index - curr_index ; count += new_index + 1 ; add_seg ( segment , 0 , N - 1 , 0 , original_index ) ; que . RemoveAt ( 0 ) ; fre [ it ] = que ; } } Console . Write ( count ) ; } static void Main ( ) { string s = " geeksforgeeks " ; sumOfIndices ( s ) ; } }

Index/key variables: current, i, it, key, seg_size
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] spf = new int [ 100005 ] ; static bool [ ] prime = new bool [ 100005 ] ; static int [ ] dp = new int [ 100005 ] ; static void sieve ( ) { prime [ 0 ] = prime [ 1 ] = false ; for ( int i = 2 ; i < 100005 ; i ++ ) prime [ i ] = true ; for ( int i = 2 ; i * i < 100005 ; i ++ ) { if ( prime [ i ] ) { for ( int j = i * i ; j < 100005 ; j += i ) { prime [ j ] = false ; } } } } static void smallestPrimeFactors ( ) { for ( int i = 0 ; i < 100005 ; i ++ ) spf [ i ] = - 1 ; for ( int i = 2 ; i * i < 100005 ; i ++ ) { for ( int j = i ; j < 100005 ; j += i ) { if ( spf [ j ] == - 1 ) { spf [ j ] = i ; } } } } static int sumOfPrimeFactors ( int n ) { int ans = 0 ; while ( n > 1 ) { ans += spf [ n ] ; n /= spf [ n ] ; } return ans ; } static int findLength ( int n ) { if ( prime [ n ] ) { return 1 ; } if ( dp [ n ] != 0 ) { return dp [ n ] ; } int sum = sumOfPrimeFactors ( n ) ; return dp [ n ] = 1 + findLength ( sum ) ; } static int maxLength ( int n , int m ) { sieve ( ) ; smallestPrimeFactors ( ) ; int ans = int . MinValue ; for ( int i = n ; i <= m ; i ++ ) { if ( i == 4 ) { continue ; } ans = Math . Max ( ans , findLength ( i ) ) ; } return ans ; } public static void Main ( String [ ] args ) { int n = 2 , m = 14 ; Console . Write ( maxLength ( n , m ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: ans, i, j, n
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int largest_subarray ( int [ ] a , int n ) { Dictionary < int , int > index = new Dictionary < int , int > ( ) ; int ans = 0 ; for ( int i = 0 , j = 0 ; i < n ; i ++ ) { j = Math . Max ( index . ContainsKey ( a [ i ] ) ? index [ a [ i ] ] : 0 , j ) ; ans = Math . Max ( ans , i - j + 1 ) ; if ( index . ContainsKey ( a [ i ] ) ) index [ a [ i ] ] = i + 1 ; else index . Add ( a [ i ] , i + 1 ) ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 1 , 2 , 3 } ; int n = arr . Length ; Console . Write ( largest_subarray ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findWays ( int [ ] nums , int S ) { return dfs ( nums , S , 0 , 0 ) ; } static int dfs ( int [ ] nums , int S , int curr_sum , int index ) { if ( index == nums . Length ) { if ( S == curr_sum ) return 1 ; else return 0 ; } return dfs ( nums , S , curr_sum + nums [ index ] , index + 1 ) + dfs ( nums , S , curr_sum - nums [ index ] , index + 1 ) ; } public static void Main ( String [ ] args ) { int S = 3 ; int [ ] arr = new int [ ] { 1 , 2 , 3 , 4 , 5 } ; int answer = findWays ( arr , S ) ; Console . WriteLine ( answer ) ; } }

Index/key variables: index
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public int key ; public Node left , right ; } ; static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = temp . right = null ; return ( temp ) ; } static void frequencyCounts ( Dictionary < int , int > map , Node root ) { if ( root == null ) return ; if ( map . ContainsKey ( root . key ) ) map [ root . key ] = map [ root . key ] + 1 ; else map [ root . key ] = 1 ; frequencyCounts ( map , root . left ) ; frequencyCounts ( map , root . right ) ; } static int computeDistance ( Node root , int value ) { if ( root == null ) { return - 1 ; } int left = computeDistance ( root . left , value ) ; int right = computeDistance ( root . right , value ) ; if ( left == - 1 && right == - 1 ) { if ( root . key == value ) { return 1 ; } else return - 1 ; } if ( left == - 1 ) { return right + 1 ; } if ( right == - 1 ) { return left + 1 ; } else { return 1 + Math . Max ( left , right ) ; } } static void solve ( Node root , int dist ) { Dictionary < int , int > map = new Dictionary < int , int > ( ) ; frequencyCounts ( map , root ) ; int flag = 0 ; foreach ( KeyValuePair < int , int > it in map ) { if ( it . Value > 1 ) { int result = computeDistance ( root , it . Key ) ; if ( result > dist result == - 1 ) { flag = 1 ; break ; } } } if ( flag == 0 ) Console . Write ( " Yes STRNEWLINE " ) ; else Console . Write ( " No STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 3 ) ; root . right . right = newNode ( 4 ) ; root . right . left = newNode ( 4 ) ; int dist = 7 ; solve ( root , dist ) ; } }

Iterator variables: it
Class/struct names: GFG, Node
C# program:
using System ; class GFG { public static void findMinSum ( int [ ] A , int K ) { int n = A . Length ; int minimum_sum = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { int min = int . MaxValue ; for ( int j = i + K ; j < n ; j ++ ) min = Math . Min ( min , A [ j ] ) ; if ( min == int . MaxValue ) continue ; minimum_sum = Math . Min ( minimum_sum , A [ i ] + min ) ; } Console . WriteLine ( minimum_sum ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 4 , 2 , 5 , 4 , 3 , 2 , 5 } ; int K = 3 ; findMinSum ( A , K ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class Node { public int data ; public Node next ; } ; static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = ( head_ref ) ; ( head_ref ) = new_node ; return head_ref ; } static int distinctCount ( Node head_ref1 ) { HashSet < int > s = new HashSet < int > ( ) ; Node ptr1 = head_ref1 ; while ( ptr1 != null ) { s . Add ( Math . Abs ( ptr1 . data ) ) ; ptr1 = ptr1 . next ; } return s . Count ; } public static void Main ( String [ ] args ) { Node head1 = null ; head1 = push ( head1 , - 1 ) ; head1 = push ( head1 , - 2 ) ; head1 = push ( head1 , 0 ) ; head1 = push ( head1 , 4 ) ; head1 = push ( head1 , 5 ) ; head1 = push ( head1 , 8 ) ; int ans = distinctCount ( head1 ) ; Console . WriteLine ( ans ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } static int lcm ( int a , int b ) { return ( a * b ) / __gcd ( a , b ) ; } static int countPair ( int N ) { int count = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { if ( __gcd ( i , j ) + lcm ( i , j ) == N ) { count ++ ; } } } return count ; } public static void Main ( String [ ] args ) { int N = 14 ; Console . Write ( countPair ( N ) ) ; } }

Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int MAX = 10 ; static List < int > [ ] adj = new List < int > [ MAX ] ; static int min_cost_node ; static void addEdge ( int u , int v ) { adj [ u ] . Add ( v ) ; adj [ v ] . Add ( u ) ; } static void dfs ( int v , int [ ] cost , bool [ ] vis ) { vis [ v ] = true ; min_cost_node = Math . Min ( min_cost_node , cost [ v - 1 ] ) ; for ( int i = 0 ; i < adj [ v ] . Count ; i ++ ) { if ( vis [ adj [ v ] [ i ] ] == false ) { dfs ( adj [ v ] [ i ] , cost , vis ) ; } } } static int minimumCost ( int V , int [ ] cost ) { bool [ ] vis = new bool [ V + 1 ] ; int min_cost = 0 ; for ( int i = 1 ; i <= V ; i ++ ) { if ( ! vis [ i ] ) { min_cost_node = int . MaxValue ; dfs ( i , cost , vis ) ; min_cost += min_cost_node ; } } return min_cost ; } public static void Main ( String [ ] args ) { int V = 6 ; int [ ] cost = { 12 , 25 , 8 , 11 , 10 , 7 } ; for ( int i = 0 ; i < adj . Length ; i ++ ) adj [ i ] = new List < int > ( ) ; addEdge ( 1 , 2 ) ; addEdge ( 1 , 3 ) ; addEdge ( 3 , 2 ) ; addEdge ( 2 , 5 ) ; addEdge ( 4 , 6 ) ; int min_cost = minimumCost ( V , cost ) ; Console . Write ( min_cost + " STRNEWLINE " ) ; } }

Index/key variables: MAX, i, u, v
Accumulator variables: i, min_cost
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int getMinimumMoves ( int n , int k , int d , int [ ] a ) { int MAX = 100000 ; List < int > [ ] v = new List < int > [ MAX ] ; for ( int i = 0 ; i < v . Length ; i ++ ) v [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int cnt = 0 ; v [ a [ i ] ] . Add ( 0 ) ; while ( a [ i ] > 0 ) { a [ i ] /= d ; cnt ++ ; v [ a [ i ] ] . Add ( cnt ) ; } } int ans = int . MaxValue ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( v [ i ] . Count >= k ) { int move = 0 ; v [ i ] . Sort ( ) ; for ( int j = 0 ; j < k ; j ++ ) { move += v [ i ] [ j ] ; } ans = Math . Min ( ans , move ) ; } } return ans ; } public static void Main ( String [ ] args ) { int N = 5 , K = 3 , D = 2 ; int [ ] A = { 1 , 2 , 3 , 4 , 5 } ; Console . Write ( getMinimumMoves ( N , K , D , A ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: cnt, i, j, move
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int Maxlen ( int [ ] arr , int n ) { int ans = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) count = 0 ; else count ++ ; ans = Math . Max ( ans , count ) ; } return ans ; } public static void Main ( ) { int [ ] arr = { 1 , 7 , 2 } ; int n = arr . Length ; Console . WriteLine ( Maxlen ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > get_submaxarr ( int [ ] arr , int n , int y ) { int j = 0 ; Stack < int > stk = new Stack < int > ( ) ; int [ ] maxarr = new int [ n ] ; Array . Fill ( maxarr , 0 ) ; stk . Push ( 0 ) ; for ( int i = 1 ; i < n ; i ++ ) { while ( stk . Count != 0 && arr [ i ] > arr [ stk . Peek ( ) ] ) { maxarr [ stk . Peek ( ) ] = i - 1 ; stk . Pop ( ) ; } stk . Push ( i ) ; } while ( stk . Count != 0 ) { maxarr [ stk . Count ] = n - 1 ; stk . Pop ( ) ; } List < int > submax = new List < int > ( ) ; for ( int i = 0 ; i <= n - y ; i ++ ) { while ( maxarr [ j ] < i + y - 1 j < i ) { j ++ ; } submax . Add ( arr [ j ] ) ; } return submax ; } static List < int > get_subminarr ( int [ ] arr , int n , int y ) { int j = 0 ; Stack < int > stk = new Stack < int > ( ) ; int [ ] minarr = new int [ n ] ; Array . Fill ( minarr , 0 ) ; stk . Push ( 0 ) ; for ( int i = 1 ; i < n ; i ++ ) { while ( stk . Count != 0 && arr [ i ] < arr [ stk . Peek ( ) ] ) { minarr [ stk . Peek ( ) ] = i ; stk . Pop ( ) ; } stk . Push ( i ) ; } while ( stk . Count != 0 ) { minarr [ stk . Peek ( ) ] = n ; stk . Pop ( ) ; } List < int > submin = new List < int > ( ) ; for ( int i = 0 ; i <= n - y ; i ++ ) { while ( minarr [ j ] <= i + y - 1 j < i ) { j ++ ; } submin . Add ( arr [ j ] ) ; } return submin ; } static void getMinDifference ( int [ ] Arr , int N , int Y ) { List < int > submin = get_subminarr ( Arr , N , Y ) ; List < int > submax = get_submaxarr ( Arr , N , Y ) ; int minn = submax [ 0 ] - submin [ 0 ] ; int b = submax . Count ; for ( int i = 1 ; i < b ; i ++ ) { int dif = submax [ i ] - submin [ i ] + 1 ; minn = Math . Min ( minn , dif ) ; } Console . WriteLine ( minn ) ; } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 3 , 2 , 2 } ; int N = arr . Length ; int Y = 4 ; getMinDifference ( arr , N , Y ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int func ( int A , int B , int C , int x ) { return ( A * x * x + B * x + C ) ; } static int findMinx ( int A , int B , int C , int K ) { int start = 1 ; int end = ( int ) Math . Ceiling ( Math . Sqrt ( K ) ) ; while ( start <= end ) { int mid = start + ( end - start ) / 2 ; int x = func ( A , B , C , mid ) ; int Y = func ( A , B , C , mid - 1 ) ; if ( x >= K && Y < K ) { return mid ; } else if ( x < K ) { start = mid + 1 ; } else { end = mid - 1 ; } } return - 1 ; } public static void Main ( String [ ] args ) { int A = 3 , B = 4 , C = 5 , K = 6 ; Console . WriteLine ( findMinx ( A , B , C , K ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static Dictionary < int , List < int > > tree ; static List < int > path ; static int maxHeight , maxHeightNode ; static bool getDiameterPath ( int vertex , int targetVertex , int parent , List < int > path ) { if ( vertex == targetVertex ) { path . Add ( vertex ) ; return true ; } foreach ( int i in tree [ vertex ] ) { if ( i == parent ) continue ; if ( getDiameterPath ( i , targetVertex , vertex , path ) ) { path . Add ( vertex ) ; return true ; } } return false ; } static void farthestNode ( int vertex , int parent , int height ) { if ( height > maxHeight ) { maxHeight = height ; maxHeightNode = vertex ; } if ( tree . ContainsKey ( vertex ) && tree [ vertex ] . Count > 0 ) { foreach ( int i in tree [ vertex ] ) { if ( i == parent ) continue ; farthestNode ( i , vertex , height + 1 ) ; } } } static void addedge ( int a , int b ) { if ( ! tree . ContainsKey ( a ) ) tree [ a ] = new List < int > ( ) ; tree [ a ] . Add ( b ) ; if ( ! tree . ContainsKey ( b ) ) tree [ b ] = new List < int > ( ) ; tree [ b ] . Add ( a ) ; } static void FindCenter ( int n ) { maxHeight = - 1 ; maxHeightNode = - 1 ; farthestNode ( 0 , - 1 , 0 ) ; int leaf1 = maxHeightNode ; maxHeight = - 1 ; farthestNode ( maxHeightNode , - 1 , 0 ) ; int leaf2 = maxHeightNode ; path = new List < int > ( ) ; getDiameterPath ( leaf1 , leaf2 , - 1 , path ) ; int pathSize = path . Count ; if ( pathSize % 2 == 1 ) { Console . WriteLine ( path [ pathSize / 2 ] ) ; } else { Console . WriteLine ( path [ pathSize / 2 ] + " , ▁ " + path [ ( pathSize - 1 ) / 2 ] ) ; } } static void Main ( ) { int N = 4 ; tree = new Dictionary < int , List < int > > ( ) ; addedge ( 1 , 0 ) ; addedge ( 1 , 2 ) ; addedge ( 1 , 3 ) ; FindCenter ( N ) ; } }

Index/key variables: a, b, vertex
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int maxm = 1000000000 ; static int count ( int [ ] v , int n ) { int i , odd = 0 , even = 0 ; int j , d , count ; int t = ( int ) 1 << v . Length ; int size = v . Length ; for ( i = 1 ; i < t ; i ++ ) { d = 1 ; count = 0 ; for ( j = 0 ; j < size ; j ++ ) { if ( ( i & ( 1 << j ) ) > 0 ) { d *= v [ j ] ; count ++ ; } } if ( count % 2 == 1 ) odd += n / d ; else even += n / d ; } return ( odd - even ) ; } static int BinarySearch ( int l , int r , int [ ] v , int key ) { int mid ; while ( r - l > 1 ) { mid = ( l + r ) / 2 ; if ( key <= count ( v , mid ) ) { r = mid ; } else { l = mid ; } } if ( key == count ( v , l ) ) return l ; else return r ; } public static void Main ( String [ ] args ) { int K = 10 ; int [ ] v = { 2 , 3 } ; Console . Write ( BinarySearch ( 1 , maxm , v , K ) + " STRNEWLINE " ) ; } }

Index/key variables: j
Accumulator variables: count, d, even, i, j, odd
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void minDistancePoints ( int [ ] A , int K , int n ) { Dictionary < int , Boolean > m = new Dictionary < int , Boolean > ( ) ; Queue < int > q = new Queue < int > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { m . Add ( A [ i ] , true ) ; q . Enqueue ( A [ i ] ) ; } List < int > ans = new List < int > ( ) ; while ( K > 0 ) { int x = q . Dequeue ( ) ; if ( ! m . ContainsKey ( x - 1 ) && K > 0 ) { m . Add ( x - 1 , true ) ; q . Enqueue ( x - 1 ) ; ans . Add ( x - 1 ) ; K -- ; } if ( ! m . ContainsKey ( x + 1 ) && K > 0 ) { m . Add ( x + 1 , true ) ; q . Enqueue ( x + 1 ) ; ans . Add ( x + 1 ) ; K -- ; } } foreach ( int i in ans ) Console . Write ( i + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] A = new int [ ] { - 1 , 4 , 6 } ; int K = 3 ; int n = A . Length ; minDistancePoints ( A , K , n ) ; } }

Index/key variables: i
Accumulator variables: K
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int search ( int [ , ] mat , int n , int m ) { int i , a = int . MaxValue ; for ( i = 0 ; i < n ; i ++ ) { int low = 0 ; int high = m - 1 ; int mid ; int ans = int . MaxValue ; while ( low <= high ) { mid = ( low + high ) / 2 ; if ( mat [ i , mid ] == 1 ) { if ( mid == 0 ) { ans = 0 ; break ; } else if ( mat [ i , mid - 1 ] == 0 ) { ans = mid ; break ; } } if ( mat [ i , mid ] == 1 ) high = mid - 1 ; else low = mid + 1 ; } if ( ans < a ) a = ans ; } if ( a == int . MaxValue ) return - 1 ; return a + 1 ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 0 , 0 , 0 } , { 0 , 0 , 1 } , { 0 , 1 , 1 } } ; Console . Write ( search ( mat , 3 , 3 ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class pair { public char first ; public int second ; public pair ( char first , int second ) { this . first = first ; this . second = second ; } } static void maxSubString ( char [ ] S , int K , int N ) { int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < N ; ++ i ) { freq [ S [ i ] - ' a ' ] = 1 ; } List < pair > answer = new List < pair > ( ) ; for ( int i = 0 ; i < 26 ; ++ i ) { if ( freq [ i ] == 0 ) continue ; char ch = ( char ) ( i + 97 ) ; int count = 0 ; int index = - 1 ; for ( int j = 0 ; j < N ; ++ j ) { if ( S [ j ] == ch ) count ++ ; if ( count == K ) index = j ; } answer . Add ( new pair ( ch , index ) ) ; } int flag = 0 ; for ( int i = 0 ; i < ( int ) answer . Count ; ++ i ) { if ( answer [ i ] . second > - 1 ) { flag = 1 ; Console . Write ( answer [ i ] . first + " ▁ " + answer [ i ] . second + " STRNEWLINE " ) ; } } if ( flag == 0 ) Console . Write ( " - 1" + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String S = " cbaabaacbcd " ; int K = 2 ; int N = S . Length ; maxSubString ( S . ToCharArray ( ) , K , N ) ; } }

Index/key variables: i, j
Accumulator variables: count
Iterator variables: i, j
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static void greaterK ( int n , int k ) { int [ ] p = new int [ String . Join ( " " , n ) . Length + 2 ] ; int index = 0 ; int x = n ; int j ; while ( x > 0 ) { p [ index ] = ( int ) ( x % k ) ; x /= k ; index ++ ; } int idx = 0 ; for ( int i = 0 ; i < p . Length - 1 ; ++ i ) { if ( p [ i ] >= 2 ) { p [ i ] = 0 ; p [ i + 1 ] ++ ; for ( j = idx ; j < i ; ++ j ) { p [ j ] = 0 ; } idx = i + 1 ; } if ( p [ i ] == k ) { p [ i ] = 0 ; p [ i + 1 ] ++ ; } } j = p . Length - 1 ; if ( p [ j ] >= 2 ) { p [ index ] = 1 ; index ++ ; } int ans = 0 ; for ( int i = p . Length - 1 ; i >= 0 ; -- i ) { ans = ans * k + p [ i ] ; } Console . Write ( ans + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int n = 29 , k = 7 ; greaterK ( n , k ) ; } }

Index/key variables: i, index, j
Accumulator variables: index, x
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static Boolean canBeBalanced ( String s , int n ) { int count = 0 , count_1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' ( ' ) count ++ ; else count -- ; count_1 = Math . Min ( count_1 , count ) ; } if ( count_1 >= - 1 && count == 0 ) return true ; return false ; } public static void Main ( String [ ] args ) { String s = " ( ) ) ( ) ( " ; int n = s . Length ; if ( canBeBalanced ( s , n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int max_element ( int [ ] arr ) { int max = arr [ 0 ] ; foreach ( int ele in arr ) if ( max < ele ) max = ele ; return max ; } static int calculateDifference ( int [ ] arr , int n ) { int max_val = max_element ( arr ) ; bool [ ] prime = new bool [ max_val + 1 ] ; for ( int index = 0 ; index < max_val + 1 ; index ++ ) prime [ index ] = true ; prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= max_val ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i <= max_val ; i += p ) prime [ i ] = false ; } } int x1 = 1 , x2 = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] ) x1 ^= arr [ i ] ; else if ( arr [ i ] != 1 ) x2 ^= arr [ i ] ; } return Math . Abs ( x1 - x2 ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 5 , 10 , 15 , 7 } ; int n = arr . Length ; Console . WriteLine ( calculateDifference ( arr , n ) ) ; } }

Index/key variables: i, index, p
Accumulator variables: i, index, p, x1, x2
Iterator variables: ele, i, index, p
Class/struct names: GFG
C# program:
using System ; class GFG { public class Node { public int data ; public Node next ; } ; static Node insert ( Node head , int item ) { Node temp = new Node ( ) ; temp . data = item ; temp . next = head ; head = temp ; return head ; } static int countNode ( Node head ) { int count = 0 ; while ( head . next != null ) { Node ptr = head . next ; while ( ptr != null ) { if ( head . data == ptr . data ) { count ++ ; break ; } ptr = ptr . next ; } head = head . next ; } return count ; } public static void Main ( String [ ] args ) { Node head = null ; head = insert ( head , 5 ) ; head = insert ( head , 7 ) ; head = insert ( head , 5 ) ; head = insert ( head , 1 ) ; head = insert ( head , 7 ) ; Console . WriteLine ( countNode ( head ) ) ; } }

Accumulator variables: count
Class/struct names: GFG, Node