dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static void smallestGreater ( int [ ] arr , int n ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { s . Add ( arr [ i ] ) ; } int [ ] newAr = new int [ s . Count ] ; int j = 0 ; foreach ( int p in s ) { newAr [ j ] = p ; j ++ ; } Array . Sort ( newAr ) ; for ( int i = 0 ; i < n ; i ++ ) { int temp = lowerBound ( newAr , 0 , newAr . GetLength ( 0 ) , arr [ i ] ) ; if ( temp < n ) Console . Write ( newAr [ temp ] + " ▁ " ) ; else Console . Write ( " _ ▁ " ) ; } } static int lowerBound ( int [ ] array , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( element > array [ middle ] ) { low = middle + 1 ; } else { high = middle ; } } return low + 1 ; } public static void Main ( String [ ] args ) { int [ ] ar = { 6 , 3 , 9 , 8 , 10 , 2 , 1 , 15 , 7 } ; int n = ar . Length ; smallestGreater ( ar , n ) ; } }

Index/key variables: i, j, middle, temp
Accumulator variables: i, j
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { public const int d = 256 ; public const int q = 103 ; public static void checkPalindromes ( string str ) { int N = str . Length ; Console . WriteLine ( str [ 0 ] + " ▁ Yes " ) ; if ( N == 1 ) { return ; } int firstr = str [ 0 ] % q ; int second = str [ 1 ] % q ; int h = 1 , i , j ; for ( i = 1 ; i < N ; i ++ ) { if ( firstr == second ) { for ( j = 0 ; j < i / 2 ; j ++ ) { if ( str [ j ] != str [ i - j ] ) { break ; } } Console . WriteLine ( ( j == i / 2 ) ? str [ i ] + " ▁ Yes " : str [ i ] + " ▁ No " ) ; } else { Console . WriteLine ( str [ i ] + " ▁ No " ) ; } if ( i != N - 1 ) { if ( i % 2 == 0 ) { h = ( h * d ) % q ; firstr = ( firstr + h * str [ i / 2 ] ) % q ; second = ( second * d + str [ i + 1 ] ) % q ; } else { second = ( d * ( second + q - str [ ( i + 1 ) / 2 ] * h ) % q + str [ i + 1 ] ) % q ; } } } } public static void Main ( string [ ] args ) { string txt = " aabaacaabaa " ; checkPalindromes ( txt ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class Test { static int [ ] arr = new int [ ] { 1 , 0 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 1 } ; static void findZeroes ( int m ) { int wL = 0 , wR = 0 ; int bestL = 0 , bestWindow = 0 ; int zeroCount = 0 ; while ( wR < arr . Length ) { if ( zeroCount <= m ) { if ( arr [ wR ] == 0 ) zeroCount ++ ; wR ++ ; } if ( zeroCount > m ) { if ( arr [ wL ] == 0 ) zeroCount -- ; wL ++ ; } if ( ( wR - wL > bestWindow ) && ( zeroCount <= m ) ) { bestWindow = wR - wL ; bestL = wL ; } } for ( int i = 0 ; i < bestWindow ; i ++ ) { if ( arr [ bestL + i ] == 0 ) Console . Write ( bestL + i + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int m = 2 ; Console . Write ( " Indexes ▁ of ▁ zeroes ▁ to ▁ be ▁ flipped ▁ are ▁ " ) ; findZeroes ( m ) ; } }

Index/key variables: wL, wR
Accumulator variables: i, wL, wR, zeroCount
Iterator variables: i
Class/struct names: Test
C# program:
using System ; class Test { static int [ ] arr = new int [ ] { 1 , 2 , 2 , 4 } ; static int countIncreasing ( int n ) { int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] > arr [ j - 1 ] ) cnt ++ ; else break ; } } return cnt ; } public static void Main ( String [ ] args ) { Console . Write ( " Count ▁ of ▁ strictly ▁ increasing " + " subarrays ▁ is ▁ " + countIncreasing ( arr . Length ) ) ; } }

Index/key variables: j
Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: Test
C# program:
using System ; class GFG { static int [ ] arr = new int [ ] { 1 , 2 , 2 , 4 } ; static int countIncreasing ( int n ) { int cnt = 0 ; int len = 1 ; for ( int i = 0 ; i < n - 1 ; ++ i ) { if ( arr [ i + 1 ] > arr [ i ] ) len ++ ; else { cnt += ( ( ( len - 1 ) * len ) / 2 ) ; len = 1 ; } } if ( len > 1 ) cnt += ( ( ( len - 1 ) * len ) / 2 ) ; return cnt ; } public static void Main ( ) { Console . WriteLine ( " Count ▁ of ▁ strictly ▁ " + " increasing ▁ subarrays ▁ is ▁ " + countIncreasing ( arr . Length ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, len
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static long arraySum ( int [ ] arr , int n ) { long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + arr [ i ] ; return sum ; } static long maxDiff ( int [ ] arr , int n , int k ) { Array . Sort ( arr ) ; long arraysum = arraySum ( arr , n ) ; long diff1 = Math . Abs ( arraysum - 2 * arraySum ( arr , k ) ) ; Array . Reverse ( arr ) ; long diff2 = Math . Abs ( arraysum - 2 * arraySum ( arr , k ) ) ; return ( Math . Max ( diff1 , diff2 ) ) ; } static public void Main ( ) { int [ ] arr = { 1 , 7 , 4 , 8 , - 1 , 5 , 2 , 1 } ; int n = arr . Length ; int k = 3 ; Console . WriteLine ( " Maximum ▁ Difference ▁ = ▁ " + maxDiff ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minNumber ( int [ ] a , int n , int x ) { Array . Sort ( a ) ; int k ; for ( k = 0 ; a [ ( n ) / 2 ] != x ; k ++ ) { a [ n ++ ] = x ; Array . Sort ( a ) ; } return k ; } public static void Main ( String [ ] args ) { int x = 10 ; int [ ] a = { 10 , 20 , 30 } ; int n = 3 ; Console . WriteLine ( minNumber ( a , n - 1 , x ) ) ; } }

Accumulator variables: k, n
Iterator variables: k
Class/struct names: GFG
C# program:
using System ; class GFG { public static int minNumber ( int [ ] a , int n , int x ) { int l = 0 , h = 0 , e = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == x ) e ++ ; else if ( a [ i ] > x ) h ++ ; else if ( a [ i ] < x ) l ++ ; } int ans = 0 ; if ( l > h ) ans = l - h ; else if ( l < h ) ans = h - l - 1 ; return ans + 1 - e ; } public static void Main ( ) { int x = 10 ; int [ ] a = { 10 , 20 , 30 } ; int n = a . Length ; Console . WriteLine ( minNumber ( a , n , x ) ) ; } }

Index/key variables: i
Accumulator variables: e, h, i, l
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void preprocess ( int [ ] arr , int N , int [ ] left , int [ ] right ) { left [ 0 ] = 0 ; int lastIncr = 0 ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] > arr [ i - 1 ] ) lastIncr = i ; left [ i ] = lastIncr ; } right [ N - 1 ] = N - 1 ; int firstDecr = N - 1 ; for ( int i = N - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] > arr [ i + 1 ] ) firstDecr = i ; right [ i ] = firstDecr ; } } static bool isSubarrayMountainForm ( int [ ] arr , int [ ] left , int [ ] right , int L , int R ) { return ( right [ L ] >= left [ R ] ) ; } static public void Main ( ) { int [ ] arr = { 2 , 3 , 2 , 4 , 4 , 6 , 3 , 2 } ; int N = arr . Length ; int [ ] left = new int [ N ] ; int [ ] right = new int [ N ] ; preprocess ( arr , N , left , right ) ; int L = 0 ; int R = 2 ; if ( isSubarrayMountainForm ( arr , left , right , L , R ) ) Console . WriteLine ( " Subarray ▁ is ▁ in ▁ " + " mountain ▁ form " ) ; else Console . WriteLine ( " Subarray ▁ is ▁ not ▁ " + " in ▁ mountain ▁ form " ) ; L = 1 ; R = 3 ; if ( isSubarrayMountainForm ( arr , left , right , L , R ) ) Console . WriteLine ( " Subarray ▁ is ▁ in ▁ " + " mountain ▁ form " ) ; else Console . WriteLine ( " Subarray ▁ is ▁ not ▁ " + " in ▁ mountain ▁ form " ) ; } }

Index/key variables: L, N, R, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void preCompute ( int [ ] arr , int n , int [ ] pre ) { pre [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) pre [ i ] = arr [ i ] + pre [ i - 1 ] ; } public static int rangeSum ( int i , int j , int [ ] pre ) { if ( i == 0 ) return pre [ j ] ; return pre [ j ] - pre [ i - 1 ] ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . Length ; int [ ] pre = new int [ n ] ; preCompute ( arr , n , pre ) ; Console . WriteLine ( rangeSum ( 1 , 3 , pre ) ) ; Console . WriteLine ( rangeSum ( 2 , 4 , pre ) ) ; } } \

Index/key variables: i, j, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void checkEVENodd ( int [ ] arr , int n , int l , int r ) { if ( arr [ r ] == 1 ) Console . WriteLine ( " odd " ) ; else Console . WriteLine ( " even " ) ; } public static void Main ( ) { int [ ] arr = { 1 , 1 , 0 , 1 } ; int n = arr . Length ; checkEVENodd ( arr , n , 1 , 3 ) ; } }

Index/key variables: r
Class/struct names: GFG
C# program:
using System ; public class GFG { static int findMean ( int [ ] arr , int l , int r ) { int sum = 0 , count = 0 ; for ( int i = l ; i <= r ; i ++ ) { sum += arr [ i ] ; count ++ ; } int mean = ( int ) Math . Floor ( ( double ) sum / count ) ; return mean ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; Console . WriteLine ( findMean ( arr , 0 , 2 ) ) ; Console . WriteLine ( findMean ( arr , 1 , 3 ) ) ; Console . WriteLine ( findMean ( arr , 0 , 4 ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { public static readonly int MAX = 1000005 ; static int [ ] prefixSum = new int [ MAX ] ; static void calculatePrefixSum ( int [ ] arr , int n ) { prefixSum [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) prefixSum [ i ] = prefixSum [ i - 1 ] + arr [ i ] ; } static int findMean ( int l , int r ) { if ( l == 0 ) return ( int ) Math . Floor ( ( double ) ( prefixSum [ r ] / ( r + 1 ) ) ) ; return ( int ) Math . Floor ( ( double ) ( prefixSum [ r ] - prefixSum [ l - 1 ] ) / ( r - l + 1 ) ) ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . Length ; calculatePrefixSum ( arr , n ) ; Console . WriteLine ( findMean ( 1 , 2 ) ) ; Console . WriteLine ( findMean ( 1 , 3 ) ) ; Console . WriteLine ( findMean ( 1 , 4 ) ) ; } }

Index/key variables: MAX, i, r
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void updateQuery ( int [ ] arr , int n , int q , int l , int r , int k ) { if ( q == 0 ) { arr [ l - 1 ] += k ; arr [ r ] += - k ; } else { arr [ l - 1 ] += - k ; arr [ r ] += k ; } return ; } static void generateArray ( int [ ] arr , int n ) { for ( int i = 1 ; i < n ; ++ i ) arr [ i ] += arr [ i - 1 ] ; } public static void Main ( ) { int n = 5 ; int [ ] arr = new int [ n + 1 ] ; for ( int i = 0 ; i < arr . Length ; i ++ ) arr [ i ] = 0 ; int q = 0 , l = 1 , r = 3 , k = 2 ; updateQuery ( arr , n , q , l , r , k ) ; q = 1 ; l = 3 ; r = 5 ; k = 3 ; updateQuery ( arr , n , q , l , r , k ) ; q = 0 ; l = 2 ; r = 5 ; k = 1 ; updateQuery ( arr , n , q , l , r , k ) ; generateArray ( arr , n ) ; for ( int i = 0 ; i < n ; ++ i ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i, r
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int calculateProduct ( int [ ] A , int L , int R , int P ) { L = L - 1 ; R = R - 1 ; int ans = 1 ; for ( int i = L ; i <= R ; i ++ ) { ans = ans * A [ i ] ; ans = ans % P ; } return ans ; } static public void Main ( ) { int [ ] A = { 1 , 2 , 3 , 4 , 5 , 6 } ; int P = 229 ; int L = 2 , R = 5 ; Console . WriteLine ( calculateProduct ( A , L , R , P ) ) ; L = 1 ; R = 3 ; Console . WriteLine ( calculateProduct ( A , L , R , P ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100 ; int [ ] pre_product = new int [ MAX ] ; int [ ] inverse_product = new int [ MAX ] ; int modInverse ( int a , int m ) { int m0 = m , t , q ; int x0 = 0 , x1 = 1 ; if ( m == 1 ) return 0 ; while ( a > 1 ) { q = a / m ; t = m ; m = a % m ; a = t ; t = x0 ; x0 = x1 - q * x0 ; x1 = t ; } if ( x1 < 0 ) x1 += m0 ; return x1 ; } void calculate_Pre_Product ( int [ ] A , int N , int P ) { pre_product [ 0 ] = A [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { pre_product [ i ] = pre_product [ i - 1 ] * A [ i ] ; pre_product [ i ] = pre_product [ i ] % P ; } } void calculate_inverse_product ( int [ ] A , int N , int P ) { inverse_product [ 0 ] = modInverse ( pre_product [ 0 ] , P ) ; for ( int i = 1 ; i < N ; i ++ ) inverse_product [ i ] = modInverse ( pre_product [ i ] , P ) ; } int calculateProduct ( int [ ] A , int L , int R , int P ) { L = L - 1 ; R = R - 1 ; int ans ; if ( L == 0 ) ans = pre_product [ R ] ; else ans = pre_product [ R ] * inverse_product [ L - 1 ] ; return ans ; } public static void Main ( ) { GFG d = new GFG ( ) ; int [ ] A = { 1 , 2 , 3 , 4 , 5 , 6 } ; int P = 113 ; d . calculate_Pre_Product ( A , A . Length , P ) ; d . calculate_inverse_product ( A , A . Length , P ) ; int L = 2 , R = 5 ; Console . WriteLine ( d . calculateProduct ( A , L , R , P ) ) ; L = 1 ; R = 3 ; Console . WriteLine ( d . calculateProduct ( A , L , R , P ) ) ; } }

Index/key variables: MAX, R, i
Accumulator variables: i, x1
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 10000 ; static int [ ] prefix = new int [ MAX + 1 ] ; static void buildPrefix ( ) { bool [ ] prime = new bool [ MAX + 1 ] ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] == false ) { for ( int i = p * 2 ; i <= MAX ; i += p ) prime [ i ] = true ; } } prefix [ 0 ] = prefix [ 1 ] = 0 ; for ( int p = 2 ; p <= MAX ; p ++ ) { prefix [ p ] = prefix [ p - 1 ] ; if ( prime [ p ] == false ) prefix [ p ] ++ ; } } static int query ( int L , int R ) { return prefix [ R ] - prefix [ L - 1 ] ; } public static void Main ( ) { buildPrefix ( ) ; int L = 5 , R = 10 ; Console . WriteLine ( query ( L , R ) ) ; L = 1 ; R = 10 ; Console . WriteLine ( query ( L , R ) ) ; } }

Index/key variables: R, i, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static void command ( bool [ ] arr , int a , int b ) { arr [ a ] ^= true ; arr [ b + 1 ] ^= true ; } static void process ( bool [ ] arr , int n ) { for ( int k = 1 ; k <= n ; k ++ ) { arr [ k ] ^= arr [ k - 1 ] ; } } static void result ( bool [ ] arr , int n ) { for ( int k = 1 ; k <= n ; k ++ ) { if ( arr [ k ] == true ) Console . Write ( "1" + " ▁ " ) ; else Console . Write ( "0" + " ▁ " ) ; } } public static void Main ( ) { int n = 5 , m = 3 ; bool [ ] arr = new bool [ n + 2 ] ; command ( arr , 1 , 5 ) ; command ( arr , 2 , 5 ) ; command ( arr , 3 , 5 ) ; process ( arr , n ) ; result ( arr , n ) ; } }

Index/key variables: a, k
Accumulator variables: k
Iterator variables: k
Class/struct names: GFG
C# program:
using System ; class GFG { public class query { public int start , end ; public query ( int start , int end ) { this . start = start ; this . end = end ; } } public static void incrementByD ( int [ ] arr , query [ ] q_arr , int n , int m , int d ) { int [ ] sum = new int [ n ] ; for ( int i = 0 ; i < m ; i ++ ) { sum [ q_arr [ i ] . start ] += d ; if ( ( q_arr [ i ] . end + 1 ) < n ) sum [ q_arr [ i ] . end + 1 ] -= d ; } arr [ 0 ] += sum [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { sum [ i ] += sum [ i - 1 ] ; arr [ i ] += sum [ i ] ; } } public static void printArray ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 5 , 4 , 8 , 6 , 1 } ; query [ ] q_arr = new query [ 5 ] ; q_arr [ 0 ] = new query ( 0 , 3 ) ; q_arr [ 1 ] = new query ( 4 , 5 ) ; q_arr [ 2 ] = new query ( 1 , 4 ) ; q_arr [ 3 ] = new query ( 0 , 1 ) ; q_arr [ 4 ] = new query ( 2 , 5 ) ; int n = arr . Length ; int m = q_arr . Length ; int d = 2 ; Console . WriteLine ( " Original ▁ Array : " ) ; printArray ( arr , n ) ; incrementByD ( arr , q_arr , n , m , d ) ; Console . WriteLine ( " STRNEWLINE Modified ▁ Array : " ) ; printArray ( arr , n ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, query
C# program:
using System ; public class GFG { static readonly int MAX = 100000 ; static int [ ] tree = new int [ MAX ] ; static bool [ ] lazy = new bool [ MAX ] ; static void toggle ( int node , int st , int en , int us , int ue ) { if ( lazy [ node ] ) { lazy [ node ] = false ; tree [ node ] = en - st + 1 - tree [ node ] ; if ( st < en ) { lazy [ node << 1 ] = ! lazy [ node << 1 ] ; lazy [ 1 + ( node << 1 ) ] = ! lazy [ 1 + ( node << 1 ) ] ; } } if ( st > en us > en ue < st ) { return ; } if ( us <= st && en <= ue ) { tree [ node ] = en - st + 1 - tree [ node ] ; if ( st < en ) { lazy [ node << 1 ] = ! lazy [ node << 1 ] ; lazy [ 1 + ( node << 1 ) ] = ! lazy [ 1 + ( node << 1 ) ] ; } return ; } int mid = ( st + en ) / 2 ; toggle ( ( node << 1 ) , st , mid , us , ue ) ; toggle ( ( node << 1 ) + 1 , mid + 1 , en , us , ue ) ; if ( st < en ) { tree [ node ] = tree [ node << 1 ] + tree [ ( node << 1 ) + 1 ] ; } } static int countQuery ( int node , int st , int en , int qs , int qe ) { if ( st > en qs > en qe < st ) { return 0 ; } if ( lazy [ node ] ) { lazy [ node ] = false ; tree [ node ] = en - st + 1 - tree [ node ] ; if ( st < en ) { lazy [ node << 1 ] = ! lazy [ node << 1 ] ; lazy [ ( node << 1 ) + 1 ] = ! lazy [ ( node << 1 ) + 1 ] ; } } if ( qs <= st && en <= qe ) { return tree [ node ] ; } int mid = ( st + en ) / 2 ; return countQuery ( ( node << 1 ) , st , mid , qs , qe ) + countQuery ( ( node << 1 ) + 1 , mid + 1 , en , qs , qe ) ; } public static void Main ( ) { int n = 5 ; toggle ( 1 , 0 , n - 1 , 1 , 2 ) ; toggle ( 1 , 0 , n - 1 , 2 , 4 ) ; Console . WriteLine ( countQuery ( 1 , 0 , n - 1 , 2 , 3 ) ) ; toggle ( 1 , 0 , n - 1 , 2 , 4 ) ; Console . WriteLine ( countQuery ( 1 , 0 , n - 1 , 1 , 4 ) ) ; } }

Index/key variables: MAX, node
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairs ( int [ ] a , int n , int x , int k ) { Array . Sort ( a ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int d = ( a [ i ] - 1 ) / x ; int a1 = Math . Max ( ( d + k ) * x , a [ i ] ) ; int it1 = Array . BinarySearch ( a , a1 ) ; int a2 = Math . Max ( ( d + k + 1 ) * x , a [ i ] ) ; int it2 = Array . BinarySearch ( a , a2 ) ; ans += Math . Abs ( it2 - it1 ) ; } return ans ; } static void Main ( ) { int [ ] a = { 1 , 3 , 5 , 7 } ; int n = a . Length ; int x = 2 , k = 1 ; Console . Write ( countPairs ( a , n , x , k ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static float probability ( int [ ] a , int [ ] b , int size1 , int size2 ) { int max1 = int . MinValue , count1 = 0 ; for ( int i = 0 ; i < size1 ; i ++ ) { if ( a [ i ] > max1 ) { max1 = a [ i ] ; count1 = 1 ; } else if ( a [ i ] == max1 ) { count1 ++ ; } } int max2 = int . MinValue , count2 = 0 ; for ( int i = 0 ; i < size2 ; i ++ ) { if ( b [ i ] > max2 ) { max2 = b [ i ] ; count2 = 1 ; } else if ( b [ i ] == max2 ) { count2 ++ ; } } return ( float ) ( count1 * count2 ) / ( size1 * size2 ) ; } public static void Main ( ) { int [ ] a = { 1 , 2 , 3 } ; int [ ] b = { 1 , 3 , 3 } ; int size1 = a . Length ; int size2 = b . Length ; Console . WriteLine ( probability ( a , b , size1 , size2 ) ) ; } }

Index/key variables: i
Accumulator variables: count1, count2, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int countDe ( int [ ] arr , int n ) { int [ ] v = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) v [ i ] = arr [ i ] ; Array . Sort ( arr ) ; int count1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] != v [ i ] ) count1 ++ ; Array . Reverse ( arr ) ; int count2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] != v [ i ] ) count2 ++ ; return ( Math . Min ( count1 , count2 ) ) ; } public static void Main ( ) { int [ ] arr = new int [ ] { 5 , 9 , 21 , 17 , 13 } ; int n = 5 ; Console . WriteLine ( " Minimum ▁ Dearrangement ▁ = ▁ " + countDe ( arr , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: count1, count2, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; public class GFG { static int maxOfSegmentMins ( int [ ] a , int n , int k ) { if ( k == 1 ) return a . Min ( ) ; if ( k == 2 ) return Math . Max ( a [ 0 ] , a [ n - 1 ] ) ; return a . Max ( ) ; } static public void Main ( ) { int [ ] a = { - 10 , - 9 , - 8 , 2 , 7 , - 6 , - 5 } ; int n = a . Length ; int k = 2 ; Console . WriteLine ( maxOfSegmentMins ( a , n , k ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int printMinimumProduct ( int [ ] arr , int n ) { int first_min = Math . Min ( arr [ 0 ] , arr [ 1 ] ) ; int second_min = Math . Max ( arr [ 0 ] , arr [ 1 ] ) ; for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i ] < first_min ) { second_min = first_min ; first_min = arr [ i ] ; } else if ( arr [ i ] < second_min ) second_min = arr [ i ] ; } return first_min * second_min ; } public static void Main ( ) { int [ ] a = { 11 , 8 , 5 , 7 , 5 , 100 } ; int n = a . Length ; Console . WriteLine ( printMinimumProduct ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long noOfTriples ( long [ ] arr , int n ) { Array . Sort ( arr ) ; long count = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == arr [ 2 ] ) count ++ ; if ( arr [ 0 ] == arr [ 2 ] ) return ( count - 2 ) * ( count - 1 ) * ( count ) / 6 ; else if ( arr [ 1 ] == arr [ 2 ] ) return ( count - 1 ) * ( count ) / 2 ; return count ; } public static void Main ( ) { long [ ] arr = { 1 , 3 , 3 , 4 } ; int n = arr . Length ; Console . Write ( noOfTriples ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkReverse ( int [ ] arr , int n ) { int [ ] temp = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { temp [ i ] = arr [ i ] ; } Array . Sort ( temp ) ; int front ; for ( front = 0 ; front < n ; front ++ ) { if ( temp [ front ] != arr [ front ] ) { break ; } } int back ; for ( back = n - 1 ; back >= 0 ; back -- ) { if ( temp [ back ] != arr [ back ] ) { break ; } } if ( front >= back ) { return true ; } do { front ++ ; if ( arr [ front - 1 ] < arr [ front ] ) { return false ; } } while ( front != back ) ; return true ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 5 , 4 , 3 } ; int n = arr . Length ; if ( checkReverse ( arr , n ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: back, front, i, n
Accumulator variables: back, front, i
Iterator variables: back, front, i
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool checkReverse ( int [ ] arr , int n ) { if ( n == 1 ) { return true ; } int i ; for ( i = 1 ; arr [ i - 1 ] < arr [ i ] && i < n ; i ++ ) ; if ( i == n ) { return true ; } int j = i ; while ( j < n && arr [ j ] < arr [ j - 1 ] ) { if ( i > 1 && arr [ j ] < arr [ i - 2 ] ) { return false ; } j ++ ; } if ( j == n ) { return true ; } int k = j ; if ( arr [ k ] < arr [ i - 1 ] ) { return false ; } while ( k > 1 && k < n ) { if ( arr [ k ] < arr [ k - 1 ] ) { return false ; } k ++ ; } return true ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 4 , 10 , 9 , 8 } ; int n = arr . Length ; if ( checkReverse ( arr , n ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int MinOperation ( int [ ] a , int [ ] b , int n ) { Array . Sort ( a ) ; Array . Sort ( b ) ; int result = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( a [ i ] > b [ i ] ) result = result + Math . Abs ( a [ i ] - b [ i ] ) ; else if ( a [ i ] < b [ i ] ) result = result + Math . Abs ( a [ i ] - b [ i ] ) ; } return result ; } public static void Main ( ) { int [ ] a = { 3 , 1 , 1 } ; int [ ] b = { 1 , 2 , 2 } ; int n = a . Length ; Console . WriteLine ( MinOperation ( a , b , n ) ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG