dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int merge ( int [ ] arr , int [ ] temp , int left , int mid , int right ) { int inv_count = 0 ; int i = left ; int j = mid ; int k = left ; while ( ( i <= mid - 1 ) && ( j <= right ) ) { if ( arr [ i ] <= arr [ j ] ) { temp [ k ++ ] = arr [ i ++ ] ; } else { temp [ k ++ ] = arr [ j ++ ] ; inv_count = inv_count + ( mid - i ) ; } } while ( i <= mid - 1 ) { temp [ k ++ ] = arr [ i ++ ] ; } while ( j <= right ) { temp [ k ++ ] = arr [ j ++ ] ; } for ( i = left ; i <= right ; i ++ ) { arr [ i ] = temp [ i ] ; } return inv_count ; } static int _mergeSort ( int [ ] arr , int [ ] temp , int left , int right ) { int mid , inv_count = 0 ; if ( right > left ) { mid = ( right + left ) / 2 ; inv_count = _mergeSort ( arr , temp , left , mid ) ; inv_count += _mergeSort ( arr , temp , mid + 1 , right ) ; inv_count += merge ( arr , temp , left , mid + 1 , right ) ; } return inv_count ; } static int mergeSort ( int [ ] arr , int array_size ) { int [ ] temp = new int [ array_size ] ; return _mergeSort ( arr , temp , 0 , array_size - 1 ) ; } static int minSwapToReachArr ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] - 1 ) - i > 2 ) { return - 1 ; } } int numOfInversion = mergeSort ( arr , N ) ; return numOfInversion ; } static void Main ( ) { int [ ] arr = { 1 , 2 , 5 , 3 , 4 } ; int N = arr . Length ; int res = minSwapToReachArr ( arr , N ) ; if ( res == - 1 ) Console . WriteLine ( " Not ▁ Possible " ) ; else Console . WriteLine ( res ) ; } }

Index/key variables: array_size, i, j
Accumulator variables: i, inv_count, j, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void twoWaySort ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) if ( ( arr [ i ] & 1 ) != 0 ) arr [ i ] *= - 1 ; Array . Sort ( arr ) ; for ( int i = 0 ; i < n ; i ++ ) if ( ( arr [ i ] & 1 ) != 0 ) arr [ i ] *= - 1 ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 2 , 7 , 5 , 4 } ; twoWaySort ( arr , arr . Length ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPossibleTriangle ( int [ ] arr , int N ) { if ( N < 3 ) return false ; Array . Sort ( arr ) ; for ( int i = 0 ; i < N - 2 ; i ++ ) if ( arr [ i ] + arr [ i + 1 ] > arr [ i + 2 ] ) return true ; return false ; } static public void Main ( ) { int [ ] arr = { 5 , 4 , 3 , 1 , 2 } ; int N = arr . Length ; if ( isPossibleTriangle ( arr , N ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

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 { static void bucketSort ( List < Double > arr , int n ) { List < Double > [ ] b = new List < Double > [ n ] ; for ( int i = 0 ; i < b . Length ; i ++ ) b [ i ] = new List < Double > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { b [ bi ] . Add ( arr [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) b [ i ] . Sort ( ) ; int index = 0 ; arr . Clear ( ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < b [ i ] . Count ; j ++ ) arr . Add ( b [ i ] [ j ] ) ; } static void sortMixed ( double [ ] arr , int n ) { List < Double > Neg = new List < Double > ( ) ; List < Double > Pos = new List < Double > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 0 ) Neg . Add ( - 1 * arr [ i ] ) ; else Pos . Add ( arr [ i ] ) ; } bucketSort ( Neg , ( int ) Neg . Count ) ; bucketSort ( Pos , ( int ) Pos . Count ) ; for ( int i = 0 ; i < Neg . Count ; i ++ ) arr [ i ] = - 1 * Neg [ Neg . Count - 1 - i ] ; for ( int j = Neg . Count ; j < n ; j ++ ) arr [ j ] = Pos [ j - Neg . Count ] ; } public static void Main ( String [ ] args ) { double [ ] arr = { - 0.897 , 0.565 , 0.656 , - 0.1234 , 0 , 0.3434 } ; int n = arr . Length ; sortMixed ( arr , n ) ; Console . Write ( " Sorted ▁ array ▁ is ▁ STRNEWLINE " ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: bi, i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 1000000 ; static int ksmallest ( int [ ] arr , int n , int k ) { int [ ] b = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) { b [ arr [ i ] ] = 1 ; } for ( int j = 1 ; j < MAX ; j ++ ) { if ( b [ j ] != 1 ) { k -- ; } if ( k != 1 ) { return j ; } } return int . MaxValue ; } public static void Main ( ) { int k = 1 ; int [ ] arr = { 1 } ; int n = arr . Length ; Console . WriteLine ( ksmallest ( arr , n , k ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: i, j, k
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void mergeTwoHalf ( int [ ] A , int n ) { Array . Sort ( A ) ; } static public void Main ( ) { int [ ] A = { 2 , 3 , 8 , - 1 , 7 , 10 } ; int n = A . Length ; mergeTwoHalf ( A , n ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( A [ i ] + " ▁ " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minDiff ( int [ ] arr , int n , int k ) { int result = int . MaxValue ; Array . Sort ( arr ) ; for ( int i = 0 ; i <= n - k ; i ++ ) result = Math . Min ( result , arr [ i + k - 1 ] - arr [ i ] ) ; return result ; } public static void Main ( ) { int [ ] arr = { 10 , 100 , 300 , 200 , 1000 , 20 , 30 } ; int n = arr . Length ; int k = 3 ; Console . WriteLine ( minDiff ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void bitonicGenerator ( int [ ] arr , int n ) { List < int > evenArr = new List < int > ( ) ; List < int > oddArr = new List < int > ( ) ; int i = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( i % 2 != 1 ) { evenArr . Add ( arr [ i ] ) ; } else { oddArr . Add ( arr [ i ] ) ; } } evenArr . Sort ( ) ; oddArr . Sort ( ) ; oddArr . Reverse ( ) ; i = 0 ; for ( int j = 0 ; j < evenArr . Count ; j ++ ) { arr [ i ++ ] = evenArr [ j ] ; } for ( int j = 0 ; j < oddArr . Count ; j ++ ) { arr [ i ++ ] = oddArr [ j ] ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 5 , 8 , 9 , 6 , 7 , 3 , 4 , 2 , 0 } ; int n = arr . Length ; bitonicGenerator ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int merge ( int [ ] arr , int [ ] temp , int left , int mid , int right ) { int inv_count = 0 ; int i = left ; int j = mid ; int k = left ; while ( ( i <= mid - 1 ) && ( j <= right ) ) { if ( arr [ i ] <= arr [ j ] ) temp [ k ++ ] = arr [ i ++ ] ; else { temp [ k ++ ] = arr [ j ++ ] ; inv_count = inv_count + ( mid - i ) ; } } while ( i <= mid - 1 ) temp [ k ++ ] = arr [ i ++ ] ; while ( j <= right ) temp [ k ++ ] = arr [ j ++ ] ; for ( i = left ; i <= right ; i ++ ) arr [ i ] = temp [ i ] ; return inv_count ; } static int _mergeSort ( int [ ] arr , int [ ] temp , int left , int right ) { int mid , inv_count = 0 ; if ( right > left ) { mid = ( right + left ) / 2 ; inv_count = _mergeSort ( arr , temp , left , mid ) ; inv_count += _mergeSort ( arr , temp , mid + 1 , right ) ; inv_count += merge ( arr , temp , left , mid + 1 , right ) ; } return inv_count ; } static int countSwaps ( int [ ] arr , int n ) { int [ ] temp = new int [ n ] ; return _mergeSort ( arr , temp , 0 , n - 1 ) ; } public static void Main ( ) { int [ ] arr = { 1 , 20 , 6 , 4 , 5 } ; int n = arr . Length ; Console . Write ( " Number ▁ of ▁ swaps ▁ is ▁ " + countSwaps ( arr , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, inv_count, j, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool isEven ( int n ) { return ( n % 2 == 0 ) ; } public static void Main ( ) { int n = 101 ; if ( isEven ( n ) == true ) Console . WriteLine ( " Even " ) ; else Console . WriteLine ( " Odd " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void findSurpasser ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int count = 0 ; for ( int j = i + 1 ; j < n ; j ++ ) if ( arr [ j ] > arr [ i ] ) count ++ ; Console . Write ( count + " ▁ " ) ; } } static void printArray ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } public static void Main ( ) { int [ ] arr = { 2 , 7 , 5 , 3 , 0 , 8 , 1 } ; int n = arr . Length ; Console . WriteLine ( " Given ▁ array ▁ is ▁ " ) ; printArray ( arr , n ) ; Console . WriteLine ( " Surpasser ▁ Count ▁ of " + " ▁ array ▁ is ▁ " ) ; findSurpasser ( 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 int solve ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int a = 0 , b = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 != 0 ) a = a * 10 + arr [ i ] ; else b = b * 10 + arr [ i ] ; } return a + b ; } public static void Main ( ) { int [ ] arr = { 6 , 8 , 4 , 5 , 2 , 3 } ; int n = arr . Length ; Console . WriteLine ( " Sum ▁ is ▁ " + solve ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxProduct ( int [ ] arr , int n ) { if ( n < 3 ) return - 1 ; int max_product = int . MinValue ; for ( int i = 0 ; i < n - 2 ; i ++ ) for ( int j = i + 1 ; j < n - 1 ; j ++ ) for ( int k = j + 1 ; k < n ; k ++ ) max_product = Math . Max ( max_product , arr [ i ] * arr [ j ] * arr [ k ] ) ; return max_product ; } public static void Main ( ) { int [ ] arr = { 10 , 3 , 5 , 6 , 20 } ; int n = arr . Length ; ; int max = maxProduct ( arr , n ) ; if ( max == - 1 ) Console . WriteLine ( " No ▁ Triplet ▁ Exists " ) ; else Console . WriteLine ( " Maximum ▁ product ▁ is ▁ " + max ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxProduct ( int [ ] arr , int n ) { if ( n < 3 ) return - 1 ; int [ ] leftMin = new int [ n ] ; int [ ] rightMin = new int [ n ] ; int [ ] leftMax = new int [ n ] ; int [ ] rightMax = new int [ n ] ; Array . Fill ( leftMin , - 1 ) ; Array . Fill ( leftMax , - 1 ) ; Array . Fill ( rightMax , - 1 ) ; Array . Fill ( rightMin , - 1 ) ; int max_product = int . MinValue ; int max_sum = arr [ 0 ] ; int min_sum = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { leftMax [ i ] = max_sum ; if ( arr [ i ] > max_sum ) max_sum = arr [ i ] ; leftMin [ i ] = min_sum ; if ( arr [ i ] < min_sum ) min_sum = arr [ i ] ; } max_sum = arr [ n - 1 ] ; min_sum = arr [ n - 1 ] ; for ( int j = n - 2 ; j >= 0 ; j -- ) { rightMax [ j ] = max_sum ; if ( arr [ j ] > max_sum ) max_sum = arr [ j ] ; rightMin [ j ] = min_sum ; if ( arr [ j ] < min_sum ) min_sum = arr [ j ] ; } for ( int i = 1 ; i < n - 1 ; i ++ ) { int max1 = Math . Max ( arr [ i ] * leftMax [ i ] * rightMax [ i ] , arr [ i ] * leftMin [ i ] * rightMin [ i ] ) ; int max2 = Math . Max ( arr [ i ] * leftMax [ i ] * rightMin [ i ] , arr [ i ] * leftMin [ i ] * rightMax [ i ] ) ; max_product = Math . Max ( max_product , Math . Max ( max1 , max2 ) ) ; } return max_product ; } static void Main ( ) { int [ ] arr = { 1 , 4 , 3 , - 6 , - 7 , 0 } ; int n = arr . Length ; int max = maxProduct ( arr , n ) ; if ( max == - 1 ) Console . WriteLine ( " No ▁ Triplet ▁ Exists " ) ; else Console . WriteLine ( " Maximum ▁ product ▁ is ▁ " + max ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static int maxProduct ( int [ ] arr , int n ) { if ( n < 3 ) { return - 1 ; } Array . Sort ( arr ) ; return Math . Max ( arr [ 0 ] * arr [ 1 ] * arr [ n - 1 ] , arr [ n - 1 ] * arr [ n - 2 ] * arr [ n - 3 ] ) ; } public static void Main ( ) { int [ ] arr = { - 10 , - 3 , 5 , 6 , - 20 } ; int n = arr . Length ; int max = maxProduct ( arr , n ) ; if ( max == - 1 ) { Console . WriteLine ( " No ▁ Triplet ▁ Exists " ) ; } else { Console . WriteLine ( " Maximum ▁ product ▁ is ▁ " + max ) ; } } }

Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static int maxProduct ( int [ ] arr , int n ) { if ( n < 3 ) return - 1 ; int maxA = Int32 . MinValue , maxB = Int32 . MinValue , maxC = Int32 . MinValue ; int minA = Int32 . MaxValue , minB = Int32 . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > maxA ) { maxC = maxB ; maxB = maxA ; maxA = arr [ i ] ; } else if ( arr [ i ] > maxB ) { maxC = maxB ; maxB = arr [ i ] ; } else if ( arr [ i ] > maxC ) maxC = arr [ i ] ; if ( arr [ i ] < minA ) { minB = minA ; minA = arr [ i ] ; } else if ( arr [ i ] < minB ) minB = arr [ i ] ; } return Math . Max ( minA * minB * maxA , maxA * maxB * maxC ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , - 4 , 3 , - 6 , 7 , 0 } ; int n = arr . Length ; int max = maxProduct ( arr , n ) ; if ( max == - 1 ) Console . Write ( " No ▁ Triplet ▁ Exists " ) ; else Console . Write ( " Maximum ▁ product ▁ is ▁ " + max ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int getMax ( int [ , ] arr , int n , int q ) { int maxi = int . MinValue ; for ( int i = 0 ; i < n ; i ++ ) { maxi = Math . Max ( maxi , arr [ i , q ] ) ; } return maxi ; } static void sortDatesUtil ( int [ , ] arr , int n , int q ) { int maxi = getMax ( arr , n , q ) ; int p = 1 ; while ( maxi > 0 ) { int [ ] cnt = new int [ 10 ] ; for ( int i = 0 ; i < n ; i ++ ) { cnt [ ( arr [ i , q ] / p ) % 10 ] ++ ; } for ( int i = 1 ; i < 10 ; i ++ ) { cnt [ i ] += cnt [ i - 1 ] ; } int [ , ] ans = new int [ n , 3 ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { int lastDigit = ( arr [ i , q ] / p ) % 10 ; for ( int j = 0 ; j < 3 ; j ++ ) { ans [ cnt [ lastDigit ] - 1 , j ] = arr [ i , j ] ; } cnt [ lastDigit ] -- ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { arr [ i , j ] = ans [ i , j ] ; } } p *= 10 ; maxi /= 10 ; } } static void sortDates ( int [ , ] dates , int n ) { sortDatesUtil ( dates , n , 0 ) ; sortDatesUtil ( dates , n , 1 ) ; sortDatesUtil ( dates , n , 2 ) ; } static void printArr ( int [ , ] arr , int n ) { for ( int i = 0 ; i < 6 ; i ++ ) { for ( int j = 0 ; j < 3 ; j ++ ) { Console . Write ( arr [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int [ , ] dates = { { 20 , 1 , 2014 } , { 25 , 3 , 2010 } , { 3 , 12 , 2000 } , { 18 , 11 , 2000 } , { 19 , 4 , 2015 } , { 9 , 7 , 2005 } } ; int n = dates . GetLength ( 0 ) ; sortDates ( dates , n ) ; Console . Write ( " STRNEWLINE Sorted ▁ Dates STRNEWLINE " ) ; printArr ( dates , n ) ; } }

Index/key variables: i, lastDigit
Accumulator variables: i, j, maxi, p
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minMoves ( char [ , ] a , char [ , ] b , int K ) { int n = a . Length ; int m = a . GetLength ( 0 ) ; int cntOperations = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( a [ i , j ] != b [ i , j ] ) { cntOperations ++ ; if ( i + K - 1 >= n j + K - 1 >= m ) { return - 1 ; } for ( int p = 0 ; p <= K - 1 ; p ++ ) { for ( int q = 0 ; q <= K - 1 ; q ++ ) { if ( a [ i + p , j + q ] == '0' ) { a [ i + p , j + q ] = '1' ; } else { a [ i + p , j + q ] = '0' ; } } } } } } return cntOperations ; } public static void Main ( ) { char [ , ] A = new char [ , ] { { '1' , '0' , '0' } , { '0' , '0' , '0' } , { '0' , '0' , '0' } } ; char [ , ] B = new char [ , ] { { '0' , '0' , '0' } , { '0' , '0' , '0' } , { '0' , '0' , '0' } } ; int K = 3 ; Console . WriteLine ( minMoves ( A , B , K ) ) ; } }

Accumulator variables: cntOperations, i, j, p, q
Iterator variables: i, j, p, q
Class/struct names: GFG
C# program:
using System ; class GFG { public static int maxConsecutiveCnt ( int [ ] arr ) { int X = 0 ; Array . Sort ( arr ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( arr [ i ] <= ( X + 1 ) ) { X = X + arr [ i ] ; } else { break ; } } return X + 1 ; } public static void Main ( ) { int [ ] arr = { 1 , 1 , 1 , 4 } ; Console . Write ( maxConsecutiveCnt ( arr ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int [ , ] prefix_sum_row = new int [ 50 , 51 ] ; public static int [ , ] prefix_sum_col = new int [ 51 , 50 ] ; public static bool is_valid ( int r , int c , int size , int [ , ] grid ) { int r_end = r + size , c_end = c + size ; int sum = 0 ; for ( int i = r , j = c ; i < r_end ; i ++ , j ++ ) { sum += grid [ i , j ] ; } for ( int i = r ; i < r_end ; i ++ ) { if ( prefix_sum_row [ i , c_end ] - prefix_sum_row [ i , c ] != sum ) { return false ; } } for ( int i = c ; i < c_end ; i ++ ) { if ( prefix_sum_col [ r_end , i ] - prefix_sum_col [ r , i ] != sum ) { return false ; } } int ad_sum = 0 ; for ( int i = r , j = c_end - 1 ; i < r_end ; i ++ , j -- ) { ad_sum += grid [ i , j ] ; } return ad_sum == sum ; } public static int largestSquareValidMatrix ( int [ , ] grid ) { int m = grid . GetLength ( 0 ) , n = grid . GetLength ( 1 ) ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { prefix_sum_row [ i , j ] = prefix_sum_row [ i , j - 1 ] + grid [ i , j - 1 ] ; } } for ( int i = 1 ; i <= m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { prefix_sum_col [ i , j ] = prefix_sum_col [ i - 1 , j ] + grid [ i - 1 , j ] ; } } for ( int size = Math . Min ( m , n ) ; size > 1 ; size -- ) { for ( int i = 0 ; i <= m - size ; i ++ ) { for ( int j = 0 ; j <= n - size ; j ++ ) { if ( is_valid ( i , j , size , grid ) ) { return size ; } } } } return 1 ; } public static void Main ( ) { int [ , ] grid = { { 7 , 1 , 4 , 5 , 6 } , { 2 , 5 , 1 , 6 , 4 } , { 1 , 5 , 4 , 3 , 2 } , { 1 , 2 , 7 , 3 , 4 } } ; Console . WriteLine ( largestSquareValidMatrix ( grid ) ) ; } }

Accumulator variables: ad_sum, i, j, size, sum
Iterator variables: i, j, size
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimumPossibleProduct ( int K ) { int res = 1 ; int range = ( 1 << K ) - 1 ; for ( int i = 0 ; i < K ; i ++ ) { res *= ( range - 1 ) ; } res *= range ; return res ; } public static void Main ( string [ ] args ) { int K = 3 ; Console . WriteLine ( minimumPossibleProduct ( K ) ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maximizeSubset ( int [ ] arr , int N ) { Array . Sort ( arr ) ; int maxSize = 0 ; int i = 0 ; int j = i + 2 ; while ( i < N - 2 ) { if ( j >= N i + 1 >= N ) break ; while ( j < N && arr [ i ] + arr [ i + 1 ] > arr [ j ] ) { j ++ ; } maxSize = Math . Max ( maxSize , j - i ) ; i ++ ; j = Math . Max ( j , i + 2 ) ; } return maxSize ; } public static void Main ( ) { int [ ] arr = { 2 , 7 , 4 , 1 , 6 , 9 , 5 , 3 } ; int N = arr . Length ; Console . Write ( maximizeSubset ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int maxShiftArrayValue ( int [ ] arr , int [ ] cap , int N ) { int sumVals = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sumVals += arr [ i ] ; } int maxCapacity = 0 ; for ( int i = 0 ; i < N ; i ++ ) { maxCapacity = Math . Max ( cap [ i ] , maxCapacity ) ; } return Math . Min ( maxCapacity , sumVals ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 3 } ; int [ ] cap = { 5 , 6 } ; int N = arr . Length ; Console . WriteLine ( maxShiftArrayValue ( arr , cap , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, sumVals
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static int Find ( int [ ] parent , int a ) { return parent [ a ] = ( parent [ a ] == a ? a : Find ( parent , parent [ a ] ) ) ; } static void Union ( int [ ] parent , int [ ] rank , int [ ] minVal , int a , int b ) { a = Find ( parent , a ) ; b = Find ( parent , b ) ; if ( rank [ a ] == rank [ b ] ) rank [ a ] ++ ; if ( rank [ a ] > rank [ b ] ) { parent [ b ] = a ; if ( minVal [ a ] >= 0 && minVal [ b ] >= 0 ) { minVal [ a ] = Math . Min ( minVal [ a ] , minVal [ b ] ) ; } else if ( minVal [ a ] >= 0 && minVal [ b ] < 0 ) { minVal [ a ] = minVal [ a ] ; } else if ( minVal [ a ] < 0 && minVal [ b ] >= 0 ) { minVal [ a ] = minVal [ b ] ; } else { minVal [ a ] = Math . Max ( minVal [ a ] , minVal [ b ] ) ; } } else { parent [ a ] = b ; if ( minVal [ a ] >= 0 && minVal [ b ] >= 0 ) { minVal [ b ] = Math . Min ( minVal [ a ] , minVal [ b ] ) ; } else if ( minVal [ a ] >= 0 && minVal [ b ] < 0 ) { minVal [ b ] = minVal [ a ] ; } else if ( minVal [ a ] < 0 && minVal [ b ] >= 0 ) { minVal [ b ] = minVal [ b ] ; } else { minVal [ b ] = Math . Max ( minVal [ a ] , minVal [ b ] ) ; } } } static void findMinCost ( pair [ ] G , int [ ] cost , int N , int M ) { int [ ] parent = new int [ N + 1 ] ; int [ ] rank = new int [ N + 1 ] ; int [ ] minVal = new int [ N + 1 ] ; for ( int i = 1 ; i < N + 1 ; i ++ ) { parent [ i ] = i ; minVal [ i ] = cost [ i - 1 ] ; } foreach ( pair i in G ) { Union ( parent , rank , minVal , i . first , i . second ) ; } HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 1 ; i < N + 1 ; i ++ ) { s . Add ( Find ( parent , i ) ) ; } pair min = new pair ( 0 , int . MaxValue ) ; bool flag = false ; foreach ( int i in s ) { if ( minVal [ i ] < 0 ) { flag = true ; } if ( min . second > minVal [ i ] ) { min = new pair ( i , minVal [ i ] ) ; } } int minCost = 0 ; if ( ! flag || ( flag && s . Count == 1 ) ) { foreach ( int i in s ) { if ( i != min . first ) { minCost += ( minVal [ i ] + min . second ) ; } } Console . Write ( minCost + " STRNEWLINE " ) ; } else { Console . Write ( - 1 + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int N = 6 ; pair [ ] G = { new pair ( 3 , 1 ) , new pair ( 2 , 3 ) , new pair ( 2 , 1 ) , new pair ( 4 , 5 ) , new pair ( 5 , 6 ) , new pair ( 6 , 4 ) } ; int [ ] cost = { 2 , 1 , 5 , 3 , 2 , 9 } ; int M = G . Length ; findMinCost ( G , cost , N , M ) ; } }

Index/key variables: a, b, i
Accumulator variables: i, minCost
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG, pair
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minimumSizeArray ( int S , int P ) { if ( S == P ) { return 1 ; } for ( int i = 2 ; i <= S ; i ++ ) { double d = i ; if ( ( S / d ) >= Math . Pow ( P , 1.0 / d ) ) { return i ; } } return - 1 ; } public static void Main ( ) { int S = 5 , P = 6 ; Console . Write ( minimumSizeArray ( S , P ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countPoints ( int D ) { int count = 0 ; for ( int x = 1 ; x * x < D * D ; x ++ ) { int y = ( int ) Math . Sqrt ( ( D * D - x * x ) ) ; if ( x * x + y * y == D * D ) { count += 4 ; } } count += 4 ; return count ; } public static void Main ( ) { int D = 5 ; Console . Write ( countPoints ( D ) ) ; } }

Accumulator variables: count, x
Iterator variables: x
Class/struct names: GFG