dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static double getProbability ( double p , double q ) { p /= 100 ; q /= 100 ; double probability = ( p * p + q * q ) / ( p + q ) ; return probability ; } public static void Main ( ) { double p , q ; p = 80 ; q = 40 ; Console . WriteLine ( getProbability ( p , q ) ) ; } }

Accumulator variables: p, q
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 1 ) { return true ; } } return false ; } public static void Main ( ) { int [ ] arr = { 3 , 9 , 12 , 13 , 15 } ; int n = arr . Length ; if ( check ( arr , n ) ) { Console . WriteLine ( " Odd ▁ Bit - wise ▁ OR " ) ; } else { Console . WriteLine ( " Even ▁ Bit - wise ▁ OR " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Diagnostics ; class GFG { private static double nanoTime ( ) { long nano = 10000L * Stopwatch . GetTimestamp ( ) ; nano /= TimeSpan . TicksPerMillisecond ; nano *= 100L ; return nano ; } public static void Main ( String [ ] args ) { int n = 800000 ; double t = nanoTime ( ) ; long sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += i ; t = nanoTime ( ) - t ; Console . WriteLine ( " sum ▁ is : ▁ " + sum ) ; Console . WriteLine ( " time ▁ taken ▁ by ▁ normal ▁ loops : " + ( t / Math . Pow ( 10.0 , 9.0 ) ) ) ; t = nanoTime ( ) ; sum = 0 ; for ( int i = 1 ; i <= n ; i += 8 ) { sum += i ; sum += ( i + 1 ) ; sum += ( i + 2 ) ; sum += ( i + 3 ) ; sum += ( i + 4 ) ; sum += ( i + 5 ) ; sum += ( i + 6 ) ; sum += ( i + 7 ) ; } t = nanoTime ( ) - t ; Console . WriteLine ( " sum ▁ is : ▁ " + ( sum ) ) ; Console . WriteLine ( " time ▁ taken ▁ by ▁ normal ▁ loops : " + ( t / Math . Pow ( 10.0 , 9.0 ) ) ) ; } }

Accumulator variables: i, nano, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int _log ( double x , double baset ) { return ( int ) ( Math . Log ( x ) / Math . Log ( baset ) ) ; } static double recursiveLogStar ( double n , double b ) { if ( n > 1.0 ) return 1.0 + recursiveLogStar ( _log ( n , b ) , b ) ; else return 0 ; } static public void Main ( ) { int n = 100 , baset = 5 ; Console . WriteLine ( " Log * ( " + n + " ) ▁ = ▁ " + recursiveLogStar ( n , baset ) ) ; } }

Class/struct names: GFG
C# program:
static int iterativeLogStar ( double n , double b ) { int count = 0 ; while ( n >= 1 ) { n = _log ( n , b ) ; count ++ ; } return count ; }

Accumulator variables: count
C# program:
static void function ( int n ) { int count = 0 ; for ( int i = n / 2 ; i <= n ; i ++ ) for ( int j = 1 ; j <= n ; j = 2 * j ) for ( int k = 1 ; k <= n ; k = k * 2 ) count ++ ; }

Accumulator variables: count, i
Iterator variables: i, j, k
C# program:
using System ; class GFG { static double maxKth ( int [ ] arr , int N , int C , int K ) { if ( N + C < K ) { return - 1 ; } int iter = 300 ; double l = 0 , r = 1000000000.0 ; while ( iter -- > 0 ) { double mid = ( l + r ) * 0.5 ; double a = 0 ; double b = 0 ; for ( int i = 0 ; i < N ; i ++ ) { a += ( int ) ( ( double ) arr [ i ] / mid ) ; if ( ( double ) arr [ i ] >= mid ) { b ++ ; } } if ( a >= K && b + C >= K ) { l = mid ; } else { r = mid ; } } return l ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 8 } ; int K = 1 , C = 1 ; int N = arr . Length ; Console . Write ( maxKth ( arr , N , C , K ) ) ; } }

Index/key variables: i
Accumulator variables: a, b, i, iter
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isPossibleToSelect ( int [ ] arr , int N , int dif , int K ) { int count = 1 ; int prev = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] >= ( prev + dif ) ) { count ++ ; if ( count == K ) return true ; prev = arr [ i ] ; } } return false ; } static int binarySearch ( int [ ] arr , int left , int right , int K , int N ) { int ans = 1 ; while ( left <= right ) { int dif = left + ( right - left ) / 2 ; if ( isPossibleToSelect ( arr , N , dif , K ) ) { ans = Math . Max ( ans , dif ) ; left = dif + 1 ; } else right = dif - 1 ; } return ans ; } public static void Main ( ) { int N , K ; N = 7 ; K = 4 ; int [ ] arr = { 1 , 4 , 9 , 0 , 2 , 13 , 3 } ; Array . Sort ( arr ) ; Console . Write ( binarySearch ( arr , 0 , arr [ N - 1 ] , K , N ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static int cal ( List < int > arr , int mid ) { int chocolate = 0 ; foreach ( int i in arr ) { if ( i >= mid ) chocolate += i - mid ; } return chocolate ; } static int maximumCut ( List < int > arr , int K ) { int low = 0 ; int high = arr . Max ( ) ; while ( low <= high ) { int mid = ( low + high ) / 2 ; int chocolate = cal ( arr , mid ) ; if ( chocolate == K ) return mid ; else if ( chocolate < K ) high = mid - 1 ; else { low = mid + 1 ; if ( mid > high ) high = mid ; } } return high ; } public static void Main ( ) { int K = 7 ; List < int > arr = new List < int > ( ) { 15 , 20 , 8 , 17 } ; Console . Write ( maximumCut ( arr , K ) ) ; } }

Accumulator variables: chocolate
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; public class GFG { static bool check ( int [ ] bananas , int mid_val , int H ) { int time = 0 ; for ( int i = 0 ; i < bananas . Length ; i ++ ) { if ( bananas [ i ] % mid_val != 0 ) { time += ( ( bananas [ i ] / mid_val ) + 1 ) ; } else { time += ( bananas [ i ] / mid_val ) ; } } if ( time <= H ) { return true ; } else { return false ; } } static int minEatingSpeed ( int [ ] piles , int H ) { int start = 1 ; int end = piles . Max ( ) ; while ( start < end ) { int mid = start + ( end - start ) / 2 ; if ( ( check ( piles , mid , H ) ) == true ) { end = mid ; } else { start = mid + 1 ; } } return end ; } public static void Main ( String [ ] args ) { int [ ] piles = { 30 , 11 , 23 , 4 , 20 } ; int H = 6 ; Console . Write ( minEatingSpeed ( piles , H ) ) ; } }

Index/key variables: i
Accumulator variables: i, time
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int minSumPair ( int [ ] arr , int N ) { if ( N < 5 ) { return - 1 ; } int [ ] prefixMin = new int [ N ] ; prefixMin [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < N - 1 ; i ++ ) { prefixMin [ i ] = Math . Min ( arr [ i ] , prefixMin [ i - 1 ] ) ; } int ans = int . MaxValue ; for ( int i = 3 ; i < N - 1 ; i ++ ) { ans = Math . Min ( ans , arr [ i ] + prefixMin [ i - 2 ] ) ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 2 , 4 , 6 , 3 , 7 } ; int N = arr . Length ; Console . Write ( minSumPair ( arr , N ) + " STRNEWLINE " ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long check ( long [ ] H , long [ ] A , long mid , long N , long M , long L ) { long sum = 0 ; for ( long i = 0 ; i < N ; i ++ ) { long speed = mid * A [ ( int ) i ] + H [ ( int ) i ] ; if ( speed >= L ) { sum += speed ; } } return sum ; } static long buzzTime ( long N , long M , long L , long [ ] H , long [ ] A ) { long low = 0 , high = 100000000 ; long ans = 0 ; while ( high >= low ) { long mid = low + ( high - low ) / 2 ; if ( check ( H , A , mid , N , M , L ) >= M ) { ans = mid ; high = mid - 1 ; } else low = mid + 1 ; } return ans ; } public static void Main ( String [ ] args ) { long M = 400 , L = 120 ; long [ ] H = { 20 , 50 , 20 } ; long [ ] A = { 20 , 70 , 90 } ; long N = A . Length ; Console . Write ( buzzTime ( N , M , L , H , A ) ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findCount ( string number ) { int sum = 0 ; for ( int i = 0 ; i < number . Length ; ++ i ) { sum += ( int ) number [ i ] - 48 ; } int count = 0 ; for ( int i = 0 ; i < number . Length ; ++ i ) { int remaining_sum = sum - ( ( int ) number [ i ] - 48 ) ; for ( int j = 0 ; j <= 9 ; ++ j ) { if ( ( remaining_sum + j ) % 3 == 0 && j != number [ i ] - 48 ) { ++ count ; } } } Console . Write ( count ) ; } public static void Main ( ) { string number = "235" ; findCount ( number ) ; } }

Index/key variables: i
Accumulator variables: sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool is_possible ( int [ ] teams , int T , int k ) { int sum = 0 ; for ( int i = 0 ; i < teams . Length ; i ++ ) { sum += Math . Min ( T , teams [ i ] ) ; } return ( sum >= ( T * k ) ) ; } public static int countOfTeams ( int [ ] teams_list , int N , int K ) { int lb = 0 ; double ub = 1e9 ; while ( lb <= ub ) { int mid = lb + ( int ) ( ub - lb ) / 2 ; if ( is_possible ( teams_list , mid , K ) ) { if ( ! is_possible ( teams_list , mid + 1 , K ) ) { return mid ; } else { lb = mid + 1 ; } } else { ub = mid - 1 ; } } return 0 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 } ; int K = 2 ; int N = arr . Length ; Console . WriteLine ( countOfTeams ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimumOperations ( int [ ] arr , int N ) { int mx = 0 , pos = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] >= mx ) { mx = arr [ i ] ; pos = i ; } } Console . Write ( ( mx - 1 ) * N + pos + 1 ) ; } public static void Main ( ) { int [ ] arr = { 2 , 0 , 2 } ; int N = arr . Length ; minimumOperations ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static long n , m , k , l , r , i ; static bool check ( long v , long [ ] a ) { long tec = 0 , ans = 0 ; long [ ] b = new long [ ( int ) ( n + k + 1 ) ] ; for ( int i = 0 ; i < n ; i ++ ) { tec -= b [ i ] ; if ( a [ i ] + tec < v ) { long mov = v - a [ i ] - tec ; ans = ans + mov ; tec += mov ; b [ i + ( int ) k ] = mov ; } } return ans <= m ; } static long FindLargest ( long [ ] a ) { l = 1 ; r = ( long ) Math . Pow ( 10 , 10 ) ; while ( r - l > 0 ) { long tm = ( l + r + 1 ) / 2 ; if ( check ( tm , a ) ) l = tm ; else r = tm - 1 ; } return l ; } public static void Main ( String [ ] args ) { long [ ] a = { 2 , 2 , 2 , 2 , 1 , 1 } ; m = 2 ; k = 3 ; n = a . Length ; Console . WriteLine ( FindLargest ( a ) ) ; } }

Index/key variables: i
Accumulator variables: i, tec
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } class Solution { public static List < int > findSteps ( Node root , int data ) { List < int > steps = new List < int > ( ) ; while ( data != 1 ) { if ( data / 2.0 > data / 2 ) { steps . Add ( 1 ) ; } else { steps . Add ( - 1 ) ; } int parent = data / 2 ; data = parent ; } steps . Reverse ( ) ; return steps ; } public static bool findKey ( Node root , int data ) { List < int > steps = findSteps ( root , data ) ; foreach ( int cur_step in steps ) { if ( cur_step == - 1 ) { if ( root . left == null ) return false ; root = root . left ; } else { if ( root . right == null ) return false ; root = root . right ; } } return true ; } public static void Main ( ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . left . right = new Node ( 5 ) ; root . right . left = new Node ( 6 ) ; root . right . right = new Node ( 7 ) ; root . left . left . left = new Node ( 8 ) ; root . left . left . right = new Node ( 9 ) ; root . left . right . left = new Node ( 10 ) ; Console . Write ( findKey ( root , 7 ) ) ; } }

Iterator variables: cur_step
Class/struct names: Node, Solution
C# program:
using System ; class GFG { static int largestAltitude ( int L , int B ) { if ( L > B ) { int t = L ; L = B ; B = t ; } int low = 0 , high = L ; int res = 0 ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( mid <= ( B / 2 ) ) { res = mid ; low = mid + 1 ; } else high = mid - 1 ; } return res ; } public static void Main ( string [ ] args ) { int L = 3 ; int B = 4 ; Console . Write ( largestAltitude ( L , B ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static void printFreq ( int [ ] arr , int N ) { int freq = 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] == arr [ i - 1 ] ) { freq ++ ; } else { Console . WriteLine ( " Frequency ▁ of ▁ " + arr [ i - 1 ] + " ▁ is : ▁ " + freq ) ; freq = 1 ; } } Console . WriteLine ( " Frequency ▁ of ▁ " + arr [ N - 1 ] + " ▁ is : ▁ " + freq ) ; } static public void Main ( ) { int [ ] arr = { 1 , 1 , 1 , 2 , 3 , 3 , 5 , 5 , 8 , 8 , 8 , 9 , 9 , 10 } ; int N = arr . Length ; printFreq ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: freq, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isMaximumMedian ( int [ , ] arr , int N , int K , int mid ) { int [ , ] Pre = new int [ N + 5 , N + 5 ] ; for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { Pre [ i + 1 , j + 1 ] = Pre [ i + 1 , j ] + Pre [ i , j + 1 ] - Pre [ i , j ] ; if ( arr [ i , j ] <= mid ) Pre [ i + 1 , j + 1 ] ++ ; } } int required = ( K * K + 1 ) / 2 ; bool flag = false ; for ( int i = K ; i <= N ; ++ i ) { for ( int j = K ; j <= N ; ++ j ) { int X = Pre [ i , j ] - Pre [ i - K , j ] - Pre [ i , j - K ] + Pre [ i - K , j - K ] ; if ( X < required ) flag = true ; } } return flag ; } static int maximumMedian ( int [ , ] arr , int N , int K ) { int low = 0 , high = ( int ) 1e9 ; while ( low < high ) { int mid = low + ( high - low ) / 2 ; if ( isMaximumMedian ( arr , N , K , mid ) ) { low = mid + 1 ; } else { high = mid ; } } return low ; } public static void Main ( string [ ] args ) { int [ , ] arr = { { 1 , 5 , 12 } , { 6 , 7 , 11 } , { 8 , 9 , 10 } } ; int N = arr . GetLength ( 0 ) ; int K = 2 ; Console . WriteLine ( maximumMedian ( arr , N , K ) ) ; } }

Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static void findMinDays ( int [ ] arr , int [ ] R , int N , int X , int K ) { int low = 0 , high = X ; int minDays = - 1 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int temp = arr [ i ] + R [ i ] * mid ; if ( temp >= K ) { sum += temp ; } } if ( sum >= X ) { minDays = mid ; high = mid - 1 ; } else { low = mid + 1 ; } } Console . Write ( minDays ) ; } public static void Main ( string [ ] args ) { int X = 100 , K = 45 ; int [ ] arr = { 2 , 5 , 2 , 6 } ; int [ ] R = { 10 , 13 , 15 , 12 } ; int N = arr . Length ; findMinDays ( arr , R , N , X , K ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getPairsCount ( int [ ] a , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( ( a [ i ] * a [ j ] ) == Math . Abs ( i - j ) ) count ++ ; } } return count ; } public static void Main ( ) { int [ ] arr = { 1 , 1 , 2 , 4 } ; int N = arr . Length ; Console . Write ( getPairsCount ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static string lexicographicallySmallestString ( string S , int N ) { int LastZe = - 1 ; string ans = " " ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( S [ i ] == '0' ) { LastZe = i ; break ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( i <= LastZe && S [ i ] == '0' ) ans += S [ i ] ; else if ( i > LastZe ) ans += S [ i ] ; } return ans ; } public static void Main ( ) { string S = "11001101" ; int N = S . Length ; Console . Write ( lexicographicallySmallestString ( S , N ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void numberofBoxes ( int W , int B , int O ) { int low = 0 , high = Math . Min ( W , B ) ; int ans = 0 ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( ( ( W >= mid ) && ( B >= mid ) ) && ( ( W - mid ) + ( B - mid ) + O ) >= mid ) { ans = mid ; low = mid + 1 ; } else high = mid - 1 ; } Console . Write ( ans ) ; } public static void Main ( ) { int W = 3 , B = 3 , O = 1 ; numberofBoxes ( W , B , O ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static int minSwaps ( int N , int M , int [ , ] A , int [ , ] B ) { int count01 = 0 ; int count10 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( A [ i , j ] != B [ i , j ] ) { if ( A [ i , j ] == 1 ) count10 ++ ; else count01 ++ ; } } } if ( count01 == count10 ) return count01 ; else return - 1 ; } public static void Main ( String [ ] args ) { int [ , ] A = { { 1 , 1 , 0 } , { 0 , 0 , 1 } , { 0 , 1 , 0 } } ; int [ , ] B = { { 0 , 0 , 1 } , { 0 , 1 , 0 } , { 1 , 1 , 0 } } ; int N = A . GetLength ( 0 ) ; int M = 3 ; Console . Write ( minSwaps ( N , M , A , B ) ) ; } }

Accumulator variables: count01, count10, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int Count ( int N , int K ) { if ( K == 0 ) return 0 ; int sum = 0 ; int res = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sum += i ; if ( sum <= K ) res ++ ; else break ; } return res ; } public static void Main ( ) { int N = 6 , K = 14 ; Console . WriteLine ( Count ( N , K ) ) ; } }

Accumulator variables: i, res, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static string removeLastOccurrence ( string S , string W , int N , int M ) { char [ ] ch = S . ToCharArray ( ) ; if ( M > N ) return S ; for ( int i = N - M ; i >= 0 ; i -- ) { int flag = 0 ; for ( int j = 0 ; j < M ; j ++ ) { if ( ch [ j + i ] != W [ j ] ) { flag = 1 ; break ; } } if ( flag == 0 ) { for ( int j = i ; j < N - M ; j ++ ) ch [ j ] = ch [ j + M ] ; Array . Resize ( ref ch , N - M ) ; break ; } } S = string . Concat ( ch ) ; return S ; } public static void Main ( ) { string S = " This ▁ is ▁ GeeksForGeeks " ; string W = " Geeks " ; int N = S . Length ; int M = W . Length ; Console . Write ( removeLastOccurrence ( S , W , N , M ) ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static void maximumIndices ( int [ ] arr , int N ) { int [ ] temp = new int [ N ] ; int maxIndices = ( N - 1 ) / 2 ; Array . Sort ( arr ) ; for ( int i = 0 ; i < maxIndices ; i ++ ) { temp [ 2 * i + 1 ] = arr [ i ] ; } int j = 0 ; for ( int i = maxIndices ; i < N ; ) { if ( temp [ j ] == 0 ) { temp [ j ] = arr [ i ] ; i ++ ; } j ++ ; } for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( temp [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int N = 4 ; maximumIndices ( arr , N ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int repeatingElement ( int [ ] arr , int N ) { int M = 0 , sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; M = Math . Max ( M , arr [ i ] ) ; } int sum1 = M * ( M + 1 ) / 2 ; int ans = ( sum - sum1 ) / ( N - M ) ; return ans ; } public static void Main ( ) { int [ ] arr = { 2 , 6 , 4 , 3 , 1 , 5 , 2 } ; int N = 7 ; Console . WriteLine ( repeatingElement ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int calculateMax ( int N , int M , int K ) { int ans = - 1 ; int low = 0 , high = M ; while ( low <= high ) { int mid = ( low + high ) / 2 ; int val = 0 ; int L = K - 1 ; int R = N - K ; val += mid ; if ( mid >= L ) { val += ( L ) * ( 2 * mid - L - 1 ) / 2 ; } else { val += mid * ( mid - 1 ) / 2 + ( L - mid ) ; } if ( mid >= R ) { val += ( R ) * ( 2 * mid - R - 1 ) / 2 ; } else { val += mid * ( mid - 1 ) / 2 + ( R - mid ) ; } if ( val <= M ) { ans = Math . Max ( ans , mid ) ; low = mid + 1 ; } else high = mid - 1 ; } return ans ; } static void Main ( ) { int N = 7 , M = 100 , K = 6 ; Console . Write ( calculateMax ( N , M , K ) ) ; } }

Accumulator variables: val
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int ans = 0 ; static List < List < int > > edges = new List < List < int > > ( ) ; static void Add_edge ( int u , int v ) { edges [ u ] . Add ( v ) ; edges [ v ] . Add ( u ) ; } static void minTimeToColor ( int node , int parent , int arrival_time ) { int current_time = 0 ; for ( int x = 0 ; x < edges [ node ] . Count ; x ++ ) { if ( edges [ node ] [ x ] != parent ) { ++ current_time ; if ( current_time == arrival_time ) ++ current_time ; ans = Math . Max ( ans , current_time ) ; minTimeToColor ( edges [ node ] [ x ] , node , current_time ) ; } } } static void Main ( ) { for ( int i = 0 ; i < 100000 ; i ++ ) { edges . Add ( new List < int > ( ) ) ; } int [ , ] A = { { 1 , 2 } , { 2 , 3 } , { 3 , 4 } } ; for ( int i = 0 ; i < 3 ; i ++ ) { Add_edge ( A [ i , 0 ] , A [ i , 1 ] ) ; } minTimeToColor ( 1 , - 1 , 0 ) ; Console . WriteLine ( ans ) ; } }

Index/key variables: node, u, v, x
Accumulator variables: i, x
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int largestNum ( List < int > arr ) { int res = 0 ; arr . Sort ( ) ; int l = 0 , r = arr . Count - 1 ; while ( l < r ) { int sum = arr [ l ] + arr [ r ] ; if ( sum == 0 ) { res = Math . Max ( res , Math . Max ( arr [ l ] , arr [ r ] ) ) ; return res ; } else if ( sum < 0 ) { l ++ ; } else { r -- ; } } return res ; } public static void Main ( ) { List < int > arr = new List < int > ( ) { 3 , 2 , - 2 , 5 , - 3 } ; Console . Write ( largestNum ( arr ) ) ; } }

Index/key variables: l, r
Accumulator variables: l, r
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findLarger ( int [ ] arr , int n ) { int mid = ( n + 1 ) / 2 ; int mx = Int32 . MinValue ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > mx ) mx = arr [ i ] ; } int [ ] count = new int [ mx + 1 ] ; Array . Clear ( count , 0 , mx + 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { count [ arr [ i ] ] ++ ; } for ( int i = mx ; i >= 0 ; i -- ) { while ( count [ i ] > 0 ) { count [ i ] -- ; mid -- ; Console . Write ( i + " ▁ " ) ; if ( mid == 0 ) break ; } if ( mid == 0 ) break ; } } public static void Main ( ) { int [ ] arr = { 10 , 4 , 2 , 8 , 9 } ; int N = arr . Length ; findLarger ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, mid
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static double probability ( int [ ] arr1 , int [ ] arr2 ) { int N = arr1 . Length ; int M = arr2 . Length ; double res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int y = 0 ; for ( int j = 0 ; j < M ; j ++ ) { if ( arr2 [ j ] > arr1 [ i ] ) y ++ ; } res += y ; } res = ( double ) res / ( double ) ( N * M ) ; return res ; } static void Main ( ) { int [ ] arr1 = { 5 , 2 , 6 , 1 } ; int [ ] arr2 = { 1 , 6 , 10 , 1 } ; Console . WriteLine ( probability ( arr1 , arr2 ) ) ; } }

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