dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class KSmallestPair { static void kSmallestPair ( int [ ] arr1 , int n1 , int [ ] arr2 , int n2 , int k ) { if ( k > n1 * n2 ) { Console . Write ( " k ▁ pairs ▁ don ' t ▁ exist " ) ; return ; } int [ ] index2 = new int [ n1 ] ; while ( k > 0 ) { int min_sum = int . MaxValue ; int min_index = 0 ; for ( int i1 = 0 ; i1 < n1 ; i1 ++ ) { if ( index2 [ i1 ] < n2 && arr1 [ i1 ] + arr2 [ index2 [ i1 ] ] < min_sum ) { min_index = i1 ; min_sum = arr1 [ i1 ] + arr2 [ index2 [ i1 ] ] ; } } Console . Write ( " ( " + arr1 [ min_index ] + " , ▁ " + arr2 [ index2 [ min_index ] ] + " ) ▁ " ) ; index2 [ min_index ] ++ ; k -- ; } } public static void Main ( String [ ] args ) { int [ ] arr1 = { 1 , 3 , 11 } ; int n1 = arr1 . Length ; int [ ] arr2 = { 2 , 4 , 8 } ; int n2 = arr2 . Length ; int k = 4 ; kSmallestPair ( arr1 , n1 , arr2 , n2 , k ) ; } }

Index/key variables: i1, min_index, n1
Accumulator variables: i1, k
Iterator variables: i1
Class/struct names: KSmallestPair
C# program:
using System ; class GFG { static void number_of_Strings ( int N , int M ) { Console . Write ( Math . Min ( N , Math . Min ( M , ( N + M ) / 3 ) ) ) ; } public static void Main ( String [ ] args ) { int N = 4 , M = 19 ; number_of_Strings ( N , M ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int maxSubset ( int [ ] arr , int N , int X ) { Array . Sort ( arr ) ; Array . Reverse ( arr ) ; int counter = 0 ; int sz = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sz ++ ; if ( arr [ i ] * sz >= X ) { counter ++ ; sz = 0 ; } } return counter ; } public static void Main ( String [ ] args ) { int [ ] arr = { 7 , 11 , 2 , 9 , 5 } ; int N = arr . Length ; int X = 10 ; Console . Write ( maxSubset ( arr , N , X ) ) ; } }

Index/key variables: i
Accumulator variables: counter, i, sz
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maximumModuloValue ( int [ ] A , int n ) { int mn = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { mn = Math . Min ( A [ i ] , mn ) ; } return mn ; } public static void Main ( String [ ] args ) { int [ ] A = { 7 , 10 , 12 } ; int n = A . Length ; Console . WriteLine ( maximumModuloValue ( A , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int N = 3 ; static readonly int M = 4 ; class query { public int x1 , x2 , y1 , y2 , K ; public query ( int x1 , int x2 , int y1 , int y2 , int k ) { this . x1 = x1 ; this . x2 = x2 ; this . y1 = y1 ; this . y2 = y2 ; K = k ; } } ; static void updateQuery ( int from_x , int from_y , int to_x , int to_y , int k , int [ , ] aux ) { aux [ from_x , from_y ] += k ; if ( to_x + 1 < N ) aux [ to_x + 1 , from_y ] -= k ; if ( to_x + 1 < N && to_y + 1 < M ) aux [ to_x + 1 , to_y + 1 ] += k ; if ( to_y + 1 < M ) aux [ from_x , to_y + 1 ] -= k ; } static void updateMatrix ( int [ , ] mat , int [ , ] aux ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 1 ; j < M ; j ++ ) { aux [ i , j ] += aux [ i , j - 1 ] ; } } for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 1 ; j < N ; j ++ ) { aux [ j , i ] += aux [ j - 1 , i ] ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { mat [ i , j ] += aux [ i , j ] ; } } } static void printMatrix ( int [ , ] mat ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { Console . Write ( mat [ i , j ] + " ▁ " ) ; } Console . Write ( " STRNEWLINE " ) ; } } static void matrixQuery ( int [ , ] mat , int Q , query [ ] q ) { int [ , ] aux = new int [ N , M ] ; for ( int i = 0 ; i < Q ; i ++ ) { updateQuery ( q [ i ] . x1 , q [ i ] . x2 , q [ i ] . y1 , q [ i ] . y2 , q [ i ] . K , aux ) ; } updateMatrix ( mat , aux ) ; printMatrix ( mat ) ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 1 , 0 , 1 , 2 } , { 0 , 2 , 4 , 1 } , { 1 , 2 , 1 , 0 } } ; int Q = 1 ; query [ ] q = { new query ( 0 , 0 , 1 , 1 , 2 ) } ; matrixQuery ( mat , Q , q ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, query
C# program:
using System ; class GFG { static void print2largest ( int [ ] arr , int arr_size ) { int i ; if ( arr_size < 2 ) { Console . Write ( " ▁ Invalid ▁ Input ▁ " ) ; return ; } Array . Sort ( arr ) ; for ( i = arr_size - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] != arr [ arr_size - 1 ] ) { Console . Write ( " The ▁ second ▁ largest ▁ " + " element ▁ is ▁ { 0 } STRNEWLINE " , arr [ i ] ) ; return ; } } Console . Write ( " There ▁ is ▁ no ▁ second ▁ " + " largest ▁ element STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 35 , 1 , 10 , 34 , 1 } ; int n = arr . Length ; print2largest ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { public class Node { public int key ; public Node left , right ; public Node ( int key_ ) { key = key_ ; left = null ; right = null ; } } ; public class pair { public Node first ; public bool second ; public pair ( Node first , bool second ) { this . first = first ; this . second = second ; } } static int sumOfLeftLeaves ( Node root ) { if ( root == null ) return 0 ; Queue < pair > q = new Queue < pair > ( ) ; q . Enqueue ( new pair ( root , false ) ) ; int sum = 0 ; while ( q . Count != 0 ) { Node temp = q . Peek ( ) . first ; bool is_left_child = q . Peek ( ) . second ; q . Dequeue ( ) ; if ( is_left_child ) sum = sum + temp . key ; if ( temp . left != null && temp . right != null && is_left_child ) sum = sum - temp . key ; if ( temp . left != null ) { q . Enqueue ( new pair ( temp . left , true ) ) ; } if ( temp . right != null ) { q . Enqueue ( new pair ( temp . right , false ) ) ; } } return sum ; } public static void Main ( String [ ] args ) { Node root = new Node ( 20 ) ; root . left = new Node ( 9 ) ; root . right = new Node ( 49 ) ; root . right . left = new Node ( 23 ) ; root . right . right = new Node ( 52 ) ; root . right . right . left = new Node ( 50 ) ; root . left . left = new Node ( 5 ) ; root . left . right = new Node ( 12 ) ; root . left . right . right = new Node ( 12 ) ; Console . Write ( " Sum ▁ of ▁ left ▁ leaves ▁ is ▁ " + sumOfLeftLeaves ( root ) + " STRNEWLINE " ) ; } }

Class/struct names: GFG, Node, pair
C# program:
using System ; class GFG { static int countNestedPolygons ( int sides ) { int count = 0 ; while ( sides > 5 ) { sides /= 2 ; count += 1 ; } return count ; } public static void Main ( String [ ] args ) { int N = 12 ; Console . Write ( countNestedPolygons ( N ) ) ; } }

Accumulator variables: count, sides
Class/struct names: GFG
C# program:
using System ; class GFG { static void print2largest ( int [ ] arr , int arr_size ) { int i , second ; if ( arr_size < 2 ) { Console . Write ( " ▁ Invalid ▁ Input ▁ " ) ; return ; } int largest = second = int . MinValue ; for ( i = 0 ; i < arr_size ; i ++ ) { largest = Math . Max ( largest , arr [ i ] ) ; } for ( i = 0 ; i < arr_size ; i ++ ) { if ( arr [ i ] != largest ) second = Math . Max ( second , arr [ i ] ) ; } if ( second == int . MinValue ) Console . Write ( " There ▁ is ▁ no ▁ second ▁ " + " largest ▁ element STRNEWLINE " ) ; else Console . Write ( " The ▁ second ▁ largest ▁ " + " element ▁ is ▁ { 0 } STRNEWLINE " , second ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 35 , 1 , 10 , 34 , 1 } ; int n = arr . Length ; print2largest ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void print2largest ( int [ ] arr , int arr_size ) { int i , first , second ; if ( arr_size < 2 ) { Console . WriteLine ( " ▁ Invalid ▁ Input ▁ " ) ; return ; } first = second = int . MinValue ; for ( i = 0 ; i < arr_size ; i ++ ) { if ( arr [ i ] > first ) { second = first ; first = arr [ i ] ; } else if ( arr [ i ] > second && arr [ i ] != first ) second = arr [ i ] ; } if ( second == int . MinValue ) Console . Write ( " There ▁ is ▁ no ▁ second ▁ largest " + " ▁ element STRNEWLINE " ) ; else Console . Write ( " The ▁ second ▁ largest ▁ element " + " ▁ is ▁ " + second ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 12 , 35 , 1 , 10 , 34 , 1 } ; int n = arr . Length ; print2largest ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void queryResult ( int [ ] prefix , pair Q ) { int l = Q . first ; int r = Q . second ; if ( l == 0 ) { int xorval = prefix [ r ] ; Console . Write ( countSetBits ( xorval ) + " STRNEWLINE " ) ; } else { int xorval = prefix [ r ] ^ prefix [ l - 1 ] ; Console . Write ( countSetBits ( xorval ) + " STRNEWLINE " ) ; } } static void calculateCount ( String S , pair [ ] Q , int m ) { int n = S . Length ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = ( 1 << ( S [ i ] - ' a ' ) ) ; } int [ ] prefix = new int [ n ] ; int x = 0 ; for ( int i = 0 ; i < n ; i ++ ) { x ^= arr [ i ] ; prefix [ i ] = x ; } for ( int i = 0 ; i < m ; i ++ ) { queryResult ( prefix , Q [ i ] ) ; } } static int countSetBits ( long x ) { int setBits = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; setBits ++ ; } return setBits ; } public static void Main ( String [ ] args ) { String S = " geeksforgeeks " ; pair [ ] Q = { new pair ( 2 , 4 ) , new pair ( 0 , 3 ) , new pair ( 0 , 12 ) } ; calculateCount ( S , Q , 3 ) ; } }

Index/key variables: i, n, r
Accumulator variables: i, setBits, x
Iterator variables: i
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static long countStrings ( long A , long B , long K ) { long X = ( A + B ) / ( K + 1 ) ; return ( Math . Min ( A , Math . Min ( B , X ) ) * ( K + 1 ) ) ; } public static void Main ( string [ ] args ) { long N = 101 , M = 231 , K = 15 ; Console . Write ( countStrings ( N , M , K ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void UniqueMatrix ( int N ) { int element_value = 1 ; int i = 0 ; while ( i < N ) { if ( i % 2 == 0 ) { for ( int f = element_value ; f < element_value + N ; f ++ ) { Console . Write ( f + " ▁ " ) ; } element_value += N ; } else { for ( int k = element_value + N - 1 ; k > element_value - 1 ; k -- ) { Console . Write ( k + " ▁ " ) ; } element_value += N ; } Console . WriteLine ( ) ; i = i + 1 ; } } static public void Main ( ) { int N = 4 ; UniqueMatrix ( N ) ; } }

Accumulator variables: element_value, f, k
Iterator variables: f, k
Class/struct names: GFG
C# program:
using System ; class GFG { class Pair { public int min ; public int max ; } static Pair getMinMax ( int [ ] arr , int n ) { Pair minmax = new Pair ( ) ; int i ; if ( n == 1 ) { minmax . max = arr [ 0 ] ; minmax . min = arr [ 0 ] ; return minmax ; } if ( arr [ 0 ] > arr [ 1 ] ) { minmax . max = arr [ 0 ] ; minmax . min = arr [ 1 ] ; } else { minmax . max = arr [ 1 ] ; minmax . min = arr [ 0 ] ; } for ( i = 2 ; i < n ; i ++ ) { if ( arr [ i ] > minmax . max ) { minmax . max = arr [ i ] ; } else if ( arr [ i ] < minmax . min ) { minmax . min = arr [ i ] ; } } return minmax ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1000 , 11 , 445 , 1 , 330 , 3000 } ; int arr_size = 6 ; Pair minmax = getMinMax ( arr , arr_size ) ; Console . Write ( " Minimum ▁ element ▁ is ▁ { 0 } " , minmax . min ) ; Console . Write ( " element is { 0 } " , minmax . max ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Pair
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static int sumNodes ( int l ) { int leafNodeCount = ( int ) Math . Pow ( 2 , l - 1 ) ; List < List < int > > vec = new List < List < int > > ( ) ; for ( int i = 1 ; i <= l ; i ++ ) { vec . Add ( new List < int > ( ) ) ; } for ( int i = 1 ; i <= leafNodeCount ; i ++ ) { vec [ l - 1 ] . Add ( i ) ; } for ( int i = l - 2 ; i >= 0 ; i -- ) { int k = 0 ; while ( k < vec [ i + 1 ] . Count - 1 ) { vec [ i ] . Add ( vec [ i + 1 ] [ k ] + vec [ i + 1 ] [ k + 1 ] ) ; k += 2 ; } } int sum = 0 ; for ( int i = 0 ; i < l ; i ++ ) { for ( int j = 0 ; j < vec [ i ] . Count ; j ++ ) { sum += vec [ i ] [ j ] ; } } return sum ; } public static void Main ( string [ ] args ) { int l = 3 ; Console . WriteLine ( sumNodes ( l ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public class Pair { public int min ; public int max ; } static Pair getMinMax ( int [ ] arr , int n ) { Pair minmax = new Pair ( ) ; int i ; if ( n % 2 == 0 ) { if ( arr [ 0 ] > arr [ 1 ] ) { minmax . max = arr [ 0 ] ; minmax . min = arr [ 1 ] ; } else { minmax . min = arr [ 0 ] ; minmax . max = arr [ 1 ] ; } i = 2 ; } else { minmax . min = arr [ 0 ] ; minmax . max = arr [ 0 ] ; i = 1 ; } while ( i < n - 1 ) { if ( arr [ i ] > arr [ i + 1 ] ) { if ( arr [ i ] > minmax . max ) { minmax . max = arr [ i ] ; } if ( arr [ i + 1 ] < minmax . min ) { minmax . min = arr [ i + 1 ] ; } } else { if ( arr [ i + 1 ] > minmax . max ) { minmax . max = arr [ i + 1 ] ; } if ( arr [ i ] < minmax . min ) { minmax . min = arr [ i ] ; } } i += 2 ; } return minmax ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1000 , 11 , 445 , 1 , 330 , 3000 } ; int arr_size = 6 ; Pair minmax = getMinMax ( arr , arr_size ) ; Console . Write ( " Minimum ▁ element ▁ is ▁ { 0 } " , minmax . min ) ; Console . Write ( " element is { 0 } " , minmax . max ) ; } }

Index/key variables: i
Accumulator variables: i
Class/struct names: GFG, Pair
C# program:
using System ; using System . Collections ; public class Query { public int L ; public int R ; public Query ( int L , int R ) { this . L = L ; this . R = R ; } } class GFG { static void printQuerySums ( int [ ] a , int n , ArrayList q , int m ) { for ( int i = 0 ; i < m ; i ++ ) { int L = ( ( Query ) q [ i ] ) . L , R = ( ( Query ) q [ i ] ) . R ; int sum = 0 ; for ( int j = L ; j <= R ; j ++ ) sum += a [ j ] ; Console . Write ( " Sum ▁ of ▁ [ " + L + " , ▁ " + R + " ] ▁ is ▁ " + sum + " STRNEWLINE " ) ; } } public static void Main ( string [ ] argv ) { int [ ] a = { 1 , 1 , 2 , 1 , 3 , 4 , 5 , 2 , 8 } ; int n = a . Length ; ArrayList q = new ArrayList ( ) ; q . Add ( new Query ( 0 , 4 ) ) ; q . Add ( new Query ( 1 , 3 ) ) ; q . Add ( new Query ( 2 , 4 ) ) ; int m = q . Count ; printQuerySums ( a , n , q , m ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG, Query
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findways ( string s , int x ) { if ( x > s . Length ) return 0 ; int n = s . Length ; int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < n ; ++ i ) freq [ s [ i ] - ' a ' ] ++ ; multiset < int > se ; HashSet < int > se = new HashSet < int > ( ) ; for ( int i = 0 ; i < 26 ; ++ i ) if ( freq [ i ] > 0 ) se . Add ( freq [ i ] ) ; int ans = 1 ; for ( int i = 0 ; i < x / 2 ; ++ i ) { int count = 0 ; foreach ( int u in se ) { if ( u >= 2 ) count ++ ; } if ( count == 0 ) return 0 ; else ans = ans * count ; int [ ] arr = new int [ se . Count ] ; se . CopyTo ( arr ) ; int p = arr [ se . Count - 1 ] ; int val = p ; se . Remove ( p ) ; if ( val > 2 ) se . Add ( val - 2 ) ; } if ( x % 2 != 0 ) { int count = 0 ; foreach ( int u in se ) if ( u > 0 ) count ++ ; ans = ans * count ; } return ans ; } static public void Main ( ) { string s = " aaa " ; int x = 2 ; Console . WriteLine ( findways ( s , x ) ) ; } }

Index/key variables: i
Accumulator variables: count
Iterator variables: i, u
Class/struct names: GFG
C# program:
using System ; class GFG { static int findIfPossible ( int n , int a , int b ) { if ( b % a != 0 ) { if ( n == 1 ) return 0 ; else if ( n % b != 0 ) return - 1 ; else return ( int ) n / b ; } int c = b / a ; int x = 0 , y = 0 ; while ( n % b == 0 ) { n = n / b ; x ++ ; } while ( n % c == 0 ) { n = n / c ; y ++ ; } if ( n == 1 ) { int total_steps = x + ( 2 * y ) ; return total_steps ; } else return - 1 ; } public static void Main ( ) { int n = 48 ; int a = 3 , b = 12 ; Console . WriteLine ( findIfPossible ( n , a , b ) ) ; } }

Accumulator variables: x, y
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAXN = 10000 ; static int SQRSIZE = 100 ; static int [ ] arr = new int [ MAXN ] ; static int [ ] block = new int [ SQRSIZE ] ; static int blk_sz ; static void update ( int idx , int val ) { int blockNumber = idx / blk_sz ; block [ blockNumber ] += val - arr [ idx ] ; arr [ idx ] = val ; } static int query ( int l , int r ) { int sum = 0 ; while ( l < r && l % blk_sz != 0 && l != 0 ) { sum += arr [ l ] ; l ++ ; } while ( l + blk_sz <= r ) { sum += block [ l / blk_sz ] ; l += blk_sz ; } while ( l <= r ) { sum += arr [ l ] ; l ++ ; } return sum ; } static void preprocess ( int [ ] input , int n ) { int blk_idx = - 1 ; blk_sz = ( int ) Math . Sqrt ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = input [ i ] ; if ( i % blk_sz == 0 ) { blk_idx ++ ; } block [ blk_idx ] += arr [ i ] ; } } public static void Main ( String [ ] args ) { int [ ] input = { 1 , 5 , 2 , 4 , 6 , 1 , 3 , 5 , 7 , 10 } ; int n = input . Length ; preprocess ( input , n ) ; Console . WriteLine ( " query ( 3 , ▁ 8 ) ▁ : ▁ " + query ( 3 , 8 ) ) ; Console . WriteLine ( " query ( 1 , ▁ 6 ) ▁ : ▁ " + query ( 1 , 6 ) ) ; update ( 8 , 0 ) ; Console . WriteLine ( " query ( 8 , ▁ 8 ) ▁ : ▁ " + query ( 8 , 8 ) ) ; } }

Index/key variables: MAXN, SQRSIZE, blk_idx, blockNumber, i, idx, l
Accumulator variables: blk_idx, i, l, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String removeLeadingZeros ( String str ) { int i = 0 ; int n = str . Length ; while ( str [ i ] == '0' && i < n ) i ++ ; str = str . Substring ( i ) ; return str ; } static void findPairs ( int sum , int K ) { String A , B ; A = " " ; B = " " ; String N = String . Join ( " " , sum ) ; int n = N . Length ; for ( int i = 0 ; i < n ; i ++ ) { int D = N [ i ] - '0' ; if ( D == K ) { int D1 , D2 ; D1 = D / 2 ; D2 = D / 2 + D % 2 ; A = A + ( char ) ( D1 + '0' ) ; B = B + ( char ) ( D2 + '0' ) ; } else { A = A + ( char ) ( D + '0' ) ; B = B + '0' ; } } A = removeLeadingZeros ( A ) ; B = removeLeadingZeros ( B ) ; Console . Write ( A + " , ▁ " + B + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int N = 33673 ; int K = 3 ; findPairs ( N , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 500 ; static int [ , ] lookup = new int [ MAX , MAX ] ; public class Query { public int L , R ; public Query ( int L , int R ) { this . L = L ; this . R = R ; } } ; static void preprocess ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) lookup [ i , i ] = i ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ lookup [ i , j - 1 ] ] < arr [ j ] ) lookup [ i , j ] = lookup [ i , j - 1 ] ; else lookup [ i , j ] = j ; } } static void RMQ ( int [ ] arr , int n , Query [ ] q , int m ) { preprocess ( arr , n ) ; for ( int i = 0 ; i < m ; i ++ ) { int L = q [ i ] . L , R = q [ i ] . R ; Console . WriteLine ( " Minimum ▁ of ▁ [ " + L + " , ▁ " + R + " ] ▁ is ▁ " + arr [ lookup [ L , R ] ] ) ; } } public static void Main ( String [ ] args ) { int [ ] a = { 7 , 2 , 3 , 0 , 5 , 10 , 3 , 12 , 18 } ; int n = a . Length ; Query [ ] q = { new Query ( 0 , 4 ) , new Query ( 4 , 7 ) , new Query ( 7 , 8 ) } ; int m = q . Length ; RMQ ( a , n , q , m ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, Query
C# program:
using System ; class GFG { public static int [ ] findMinimumHike ( int [ ] ratings , int employees ) { int [ ] hikes = new int [ employees ] ; for ( int i = 0 ; i < employees ; i ++ ) hikes [ i ] = 1 ; for ( int i = 1 ; i < employees ; i ++ ) { if ( ratings [ i - 1 ] < ratings [ i ] && hikes [ i - 1 ] >= hikes [ i ] ) hikes [ i ] = hikes [ i - 1 ] + 1 ; } for ( int i = employees - 2 ; i >= 0 ; i -- ) { if ( ratings [ i ] > ratings [ i + 1 ] && hikes [ i + 1 ] >= hikes [ i ] ) hikes [ i ] = hikes [ i + 1 ] + 1 ; } return hikes ; } public static void Main ( String [ ] args ) { int [ ] data = new int [ ] { 5 , 3 , 4 , 2 , 1 , 6 } ; int [ ] result = findMinimumHike ( data , data . Length ) ; Console . WriteLine ( " [ " + String . Join ( " , " , result ) + " ] " ) ; data = new int [ ] { 1 , 3 , 5 , 4 } ; result = findMinimumHike ( data , data . Length ) ; Console . WriteLine ( " [ " + String . Join ( " , " , result ) + " ] " ) ; data = new int [ ] { 1 , 4 } ; result = findMinimumHike ( data , data . Length ) ; Console . WriteLine ( " [ " + String . Join ( " , " , result ) + " ] " ) ; } }

Index/key variables: employees, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 500 ; static int [ , ] lookup = new int [ MAX , MAX ] ; public class Query { public int L , R ; public Query ( int L , int R ) { this . L = L ; this . R = R ; } } ; static void preprocess ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) lookup [ i , 0 ] = i ; for ( int j = 1 ; ( 1 << j ) <= n ; j ++ ) { for ( int i = 0 ; ( i + ( 1 << j ) - 1 ) < n ; i ++ ) { if ( arr [ lookup [ i , j - 1 ] ] < arr [ lookup [ i + ( 1 << ( j - 1 ) ) , j - 1 ] ] ) lookup [ i , j ] = lookup [ i , j - 1 ] ; else lookup [ i , j ] = lookup [ i + ( 1 << ( j - 1 ) ) , j - 1 ] ; } } } static int query ( int [ ] arr , int L , int R ) { int j = ( int ) Math . Log ( R - L + 1 ) ; if ( arr [ lookup [ L , j ] ] <= arr [ lookup [ R - ( 1 << j ) + 1 , j ] ] ) return arr [ lookup [ L , j ] ] ; else return arr [ lookup [ R - ( 1 << j ) + 1 , j ] ] ; } static void RMQ ( int [ ] arr , int n , Query [ ] q , int m ) { preprocess ( arr , n ) ; for ( int i = 0 ; i < m ; i ++ ) { int L = q [ i ] . L , R = q [ i ] . R ; Console . WriteLine ( " Minimum ▁ of ▁ [ " + L + " , ▁ " + R + " ] ▁ is ▁ " + query ( arr , L , R ) ) ; } } public static void Main ( String [ ] args ) { int [ ] a = { 7 , 2 , 3 , 0 , 5 , 10 , 3 , 12 , 18 } ; int n = a . Length ; Query [ ] q = { new Query ( 0 , 4 ) , new Query ( 4 , 7 ) , new Query ( 7 , 8 ) } ; int m = q . Length ; RMQ ( a , n , q , m ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, Query
C# program:
using System ; using System . Collections . Generic ; class GFG { static double sumNodes ( int l ) { double leafNodeCount = Math . Pow ( 2 , l - 1 ) ; double sumLastLevel = 0 ; sumLastLevel = ( leafNodeCount * ( leafNodeCount + 1 ) ) / 2 ; double sum = sumLastLevel * l ; return sum ; } public static void Main ( ) { int l = 3 ; Console . Write ( sumNodes ( l ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static int [ , ] dp = new int [ 100005 , 27 ] ; static int calculate ( int pos , int prev , String s ) { if ( pos == s . Length ) { return 0 ; } if ( dp [ pos , prev ] != - 1 ) return dp [ pos , prev ] ; int val = 0 ; if ( s [ pos ] - ' a ' + 1 != prev ) { val = Math . Max ( val , 1 + calculate ( pos + 1 , s [ pos ] - ' a ' + 1 , s ) ) ; } val = Math . Max ( val , calculate ( pos + 1 , prev , s ) ) ; return dp [ pos , prev ] = val ; } static int longestSubsequence ( String s ) { int n = s . Length ; for ( int i = 0 ; i < 100005 ; i ++ ) { for ( int j = 0 ; j < 27 ; j ++ ) { dp [ i , j ] = - 1 ; } } return calculate ( 0 , 0 , s ) ; } public static void Main ( String [ ] args ) { String str = " ababa " ; Console . Write ( longestSubsequence ( str ) ) ; } }

Index/key variables: pos
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG