dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int Mod = ( int ) ( 1e9 + 7 ) ; static int power ( int X , int Y , int Mod ) { if ( Y == 0 ) return 1 ; int p = power ( X , Y / 2 , Mod ) % Mod ; p = ( p * p ) % Mod ; if ( ( Y & 1 ) != 0 ) { p = ( X * p ) % Mod ; } return p ; } static int Inversefactorial ( int N ) { if ( N <= 0 ) return 1 ; int fact = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { fact = ( fact * i ) % Mod ; } return power ( fact , Mod - 2 , Mod ) ; } static int factorial ( int N ) { if ( N <= 0 ) return 1 ; int fact = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { fact = ( fact * i ) % Mod ; } return fact ; } static int nck ( int N , int K ) { int factN = factorial ( N ) ; int inv = Inversefactorial ( K ) ; int invFact = Inversefactorial ( N - K ) ; return ( ( ( factN * inv ) % Mod ) * invFact ) % Mod ; } static int TotalWaYs ( int N , int M ) { if ( ( ( N + M ) % 3 ) != 0 ) return 0 ; int X = N - ( N + M ) / 3 ; int Y = M - ( N + M ) / 3 ; if ( X < 0 Y < 0 ) return 0 ; return nck ( X + Y , Y ) ; } public static void Main ( String [ ] args ) { int N = 3 , M = 3 ; Console . Write ( TotalWaYs ( N , M ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void calculateProfit ( int n , int [ ] earnings , int [ ] cost , int e ) { int profit = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int earning_per_day = 0 ; int daily_spent_food = 0 ; if ( i == ( n - 1 ) ) { earning_per_day = earnings [ i ] * e ; profit = profit + earning_per_day ; break ; } if ( cost [ i ] < earnings [ i ] ) { earning_per_day = earnings [ i ] * e ; daily_spent_food = cost [ i ] * e ; profit = profit + earning_per_day - daily_spent_food ; } } Console . Write ( profit + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int n = 4 ; int [ ] earnings = { 1 , 8 , 6 , 7 } ; int [ ] cost = { 1 , 3 , 4 , 1 } ; int e = 5 ; calculateProfit ( n , earnings , cost , e ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkEvenSum ( int [ ] arr , int N , int size ) { int even_freq = 0 , odd_freq = 0 ; for ( int i = 0 ; i < size ; i ++ ) { if ( arr [ i ] % 2 == 1 ) odd_freq ++ ; else even_freq ++ ; } if ( even_freq >= N ) return true ; else { if ( odd_freq % 2 == 1 ) { int taken = odd_freq - 1 ; int req = N - taken ; if ( even_freq < req ) { return false ; } else return true ; } else { int taken = odd_freq ; int req = N - taken ; if ( even_freq < req ) { return false ; } else return true ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 9 , 2 , 3 , 4 , 18 , 7 , 7 , 6 } ; int size = arr . Length ; int N = 5 ; if ( checkEvenSum ( arr , N , size ) ) Console . Write ( " Yes " + " STRNEWLINE " ) ; else Console . Write ( " No " + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: even_freq, i, odd_freq
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void mindigits ( int n ) { if ( n % 9 == 0 ) { Console . WriteLine ( n / 9 ) ; } else { Console . WriteLine ( ( n / 9 ) + 1 ) ; } } public static void Main ( String [ ] args ) { int n1 = 24 ; int n2 = 18 ; mindigits ( n1 ) ; mindigits ( n2 ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int digitsOf ( int num ) { return num . ToString ( ) . Length ; } static int count ( int a , int tn ) { int diff = ( int ) Math . Pow ( 10 , digitsOf ( a ) ) ; return ( ( tn - a ) / diff ) + 1 ; } public static void Main ( String [ ] args ) { int n = 25 , m = 4500 ; Console . WriteLine ( count ( n , m ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int minOperations ( int [ ] a , int N ) { int num_of_ops1 , num_of_ops2 , sum ; num_of_ops1 = num_of_ops2 = sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += a [ i ] ; if ( i % 2 == 0 && sum >= 0 ) { num_of_ops1 += ( 1 + Math . Abs ( sum ) ) ; sum = - 1 ; } else if ( i % 2 == 1 && sum <= 0 ) { num_of_ops1 += ( 1 + Math . Abs ( sum ) ) ; sum = 1 ; } } sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += a [ i ] ; if ( i % 2 == 1 && sum >= 0 ) { num_of_ops2 += ( 1 + Math . Abs ( sum ) ) ; sum = - 1 ; } else if ( i % 2 == 0 && sum <= 0 ) { num_of_ops2 += ( 1 + Math . Abs ( sum ) ) ; sum = 1 ; } } return Math . Min ( num_of_ops1 , num_of_ops2 ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , - 4 , 5 , 0 , 1 } ; int N = arr . Length ; Console . Write ( minOperations ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, num_of_ops1, num_of_ops2, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkEquall ( int [ ] arr , int N ) { int sumEven = 0 , sumOdd = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i % 2 == 1 ) sumOdd += arr [ i ] ; else sumEven += arr [ i ] ; } if ( sumEven == sumOdd ) return true ; else return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 7 , 3 , 5 , 7 } ; int N = arr . Length ; if ( checkEquall ( arr , N ) ) Console . Write ( " YES " + " STRNEWLINE " ) ; else Console . Write ( " NO " + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: i, sumEven, sumOdd
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool isSumOfPower ( int n ) { bool [ ] isSum = new bool [ n + 1 ] ; List < int > perfectPowers = new List < int > ( ) ; perfectPowers . Add ( 1 ) ; for ( int i = 0 ; i < ( n + 1 ) ; i ++ ) { isSum [ i ] = false ; } for ( int i = 2 ; i < ( n + 1 ) ; i ++ ) { if ( isSum [ i ] == true ) { perfectPowers . Add ( i ) ; continue ; } for ( int j = i * i ; j > 0 && j < ( n + 1 ) ; j *= i ) { isSum [ j ] = true ; } } for ( int i = 0 ; i < perfectPowers . Count ; i ++ ) { isSum [ perfectPowers [ i ] ] = false ; } for ( int i = 0 ; i < perfectPowers . Count ; i ++ ) { for ( int j = i ; j < perfectPowers . Count ; j ++ ) { int sum = perfectPowers [ i ] + perfectPowers [ j ] ; if ( sum < ( n + 1 ) ) isSum [ sum ] = true ; } } return isSum [ n ] ; } public static void Main ( String [ ] args ) { int n = 9 ; if ( isSumOfPower ( n ) ) { Console . Write ( " true STRNEWLINE " ) ; } else { Console . Write ( " false STRNEWLINE " ) ; } } }

Index/key variables: i, j, n, sum
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void update ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] += ( i + 1 ) ; } } static bool check ( int [ ] arr , int N ) { int f = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < N ; j ++ ) { if ( arr [ i ] == arr [ j ] ) { count ++ ; } } if ( count >= 2 ) { f = 1 ; break ; } } if ( f == 1 ) return true ; else return false ; } static void incrementCount ( int [ ] arr , int N ) { int min = 0 ; while ( check ( arr , N ) != true ) { update ( arr , N ) ; min ++ ; } Console . WriteLine ( min ) ; } public static void Main ( String [ ] args ) { int N = 3 ; int [ ] arr = { 12 , 8 , 4 } ; incrementCount ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j, min
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void checkPossible ( int [ ] a ) { int even_no_count = 0 ; for ( int i = 0 ; i < a . Length ; i ++ ) { if ( a [ i ] % 2 == 0 ) even_no_count ++ ; } if ( a . Length / 2 > even_no_count ) { Console . WriteLine ( " No " ) ; return ; } Console . WriteLine ( " Yes " ) ; int j = 0 ; for ( int i = 1 ; i < a . Length ; i += 2 ) { if ( a [ i ] % 2 == 0 ) continue ; else { while ( j < a . Length && a [ j ] % 2 != 0 ) j += 2 ; a [ i ] += a [ j ] ; a [ j ] = a [ i ] - a [ j ] ; a [ i ] -= a [ j ] ; } } for ( int i = 0 ; i < a . Length ; i ++ ) { Console . Write ( a [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 , 5 , 6 , 7 } ; checkPossible ( arr ) ; } }

Index/key variables: i, j
Accumulator variables: even_no_count, i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxORminusXOR ( int N ) { int MSB = ( int ) Math . Ceiling ( Math . Log ( N ) ) ; int M = 0 ; for ( int i = 0 ; i <= MSB ; i ++ ) M += ( 1 << i ) ; return M ; } public static void Main ( String [ ] args ) { int N = 10 ; Console . Write ( maxORminusXOR ( N ) ) ; } }

Accumulator variables: M, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int No_of_Triangle ( int N , int K ) { if ( N < K ) return - 1 ; else { int Tri_up = 0 ; Tri_up = ( ( N - K + 1 ) * ( N - K + 2 ) ) / 2 ; int Tri_down = 0 ; Tri_down = ( ( N - 2 * K + 1 ) * ( N - 2 * K + 2 ) ) / 2 ; return Tri_up + Tri_down ; } } public static void Main ( String [ ] args ) { int N = 4 , K = 2 ; Console . Write ( No_of_Triangle ( N , K ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool canMake ( int n , int [ ] ar ) { if ( n == 1 ) return true ; else { if ( ar [ 0 ] < ar [ 1 ] ) { int i = 1 ; while ( i < n && ar [ i - 1 ] < ar [ i ] ) { i ++ ; } while ( i + 1 < n && ar [ i ] > ar [ i + 1 ] ) { i ++ ; } if ( i >= n - 1 ) return true ; else return false ; } else if ( ar [ 0 ] > ar [ 1 ] ) { int i = 1 ; while ( i < n && ar [ i - 1 ] > ar [ i ] ) { i ++ ; } while ( i + 1 < n && ar [ i ] < ar [ i + 1 ] ) { i ++ ; } if ( i >= n - 1 ) return true ; else return false ; } else { for ( int i = 2 ; i < n ; i ++ ) { if ( ar [ i - 1 ] <= ar [ i ] ) return false ; } return true ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . Length ; if ( ! canMake ( n , arr ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int check_length ( int n ) { int ans = 0 ; while ( n != 0 ) { n = n >> 1 ; ans ++ ; } return ans ; } static bool check_ith_bit ( int n , int i ) { return ( n & ( 1 << ( i - 1 ) ) ) != 0 ? true : false ; } static int no_of_flips ( int n ) { int len = check_length ( n ) ; int ans = 0 ; int right = 1 ; int left = len ; while ( right < left ) { if ( check_ith_bit ( n , right ) != check_ith_bit ( n , left ) ) ans ++ ; left -- ; right ++ ; } return ans ; } public static void Main ( String [ ] args ) { int n = 12 ; Console . WriteLine ( no_of_flips ( n ) ) ; } }

Accumulator variables: ans, left, right
Class/struct names: GFG
C# program:
using System ; class GFG { static void findPair ( int A , int B , int N ) { int X , Y ; X = N - B + A ; if ( X % 2 != 0 ) { Console . Write ( " - 1" ) ; } else { X = X / 2 ; Y = N - X ; Console . Write ( X + " ▁ " + Y ) ; } } public static void Main ( string [ ] args ) { int A = 1 ; int B = 3 ; int N = 4 ; findPair ( A , B , N ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( int [ ] a , int n ) { int ma = a [ 1 ] - a [ 0 ] ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( ( a [ i ] > a [ i - 1 ] && a [ i + 1 ] < a [ i ] ) || ( a [ i ] < a [ i - 1 ] && a [ i + 1 ] > a [ i ] ) ) ma = Math . Max ( ma , Math . Abs ( a [ i ] - a [ i + 1 ] ) ) ; else return false ; } Console . Write ( " Amplitude ▁ = ▁ " + ma ) ; Console . WriteLine ( ) ; return true ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 1 , 5 , 0 , 7 , - 6 } ; int n = a . Length ; int wave = ( n - 1 ) / 2 ; if ( check ( a , n ) ) Console . Write ( " Waves ▁ = ▁ " + wave ) ; else Console . Write ( " - 1" ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static void findRank ( int [ ] A , int N ) { int [ ] rank = new int [ N ] ; Stack < int > s = new Stack < int > ( ) ; s . Push ( A [ N - 1 ] ) ; for ( int i = N - 2 ; i >= 0 ; i -- ) { if ( A [ i ] < s . Peek ( ) ) { s . Push ( A [ i ] ) ; rank [ i ] = s . Count ( ) - 1 ; } else { while ( s . Count ( ) != 0 && A [ i ] >= s . Peek ( ) ) { s . Pop ( ) ; } s . Push ( A [ i ] ) ; rank [ i ] = s . Count ( ) - 1 ; } } for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( rank [ i ] + " ▁ " ) ; } } public static void Main ( ) { int [ ] A = new int [ ] { 1 , 2 , 3 , 5 , 4 } ; int N = A . Length ; findRank ( A , N ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSetBit ( int n ) { int i = 0 ; int ans = 0 ; while ( ( 1 << i ) <= n ) { bool k = true ; int change = 1 << i ; for ( int j = 0 ; j <= n ; j ++ ) { ans += k == true ? 0 : 1 ; if ( change == 1 ) { k = ! k ; change = 1 << i ; } else { change -- ; } } i ++ ; } return ans ; } static int countSetBits ( int L , int R ) { return Math . Abs ( countSetBit ( R ) - countSetBit ( L - 1 ) ) ; } public static void Main ( String [ ] args ) { int L = 3 , R = 5 ; Console . Write ( " Total ▁ set ▁ bit ▁ count ▁ is ▁ " + countSetBits ( L , R ) + " STRNEWLINE " ) ; } }

Accumulator variables: ans, change, i, j
Iterator variables: j
Boolean variables: k
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSetBits ( int L , int R ) { int count = 0 ; for ( int i = L ; i <= R ; i ++ ) { int n = i ; while ( n > 0 ) { count += ( n & 1 ) ; n = n >> 1 ; } } return count ; } public static void Main ( String [ ] args ) { int L = 3 , R = 5 ; Console . Write ( " Total ▁ set ▁ Bit ▁ count ▁ is ▁ " + countSetBits ( L , R ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSetBits ( int L , int R ) { int count = 0 ; for ( int i = L ; i <= R ; i ++ ) { count += countSetBits ( i ) ; } return count ; } static int countSetBits ( long x ) { int setBits = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; setBits ++ ; } return setBits ; } public static void Main ( String [ ] args ) { int L = 3 , R = 5 ; Console . Write ( " Total ▁ set ▁ bit ▁ count ▁ is ▁ " + countSetBits ( L , R ) ) ; } }

Accumulator variables: count, i, setBits
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void countElement ( int [ ] A , int N , int [ ] B , int M , int K ) { int cnt = 0 ; for ( int i = 0 ; i < M ; i ++ ) { int currentElement = B [ i ] ; for ( int j = 0 ; j < N ; j ++ ) { int diff = Math . Abs ( currentElement - A [ j ] ) ; if ( diff <= K ) { cnt ++ ; break ; } } } Console . Write ( cnt ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 100 , 65 , 35 , 85 , 55 } ; int [ ] B = { 30 , 60 , 75 , 95 } ; int K = 5 ; int N = A . Length ; int M = B . Length ; countElement ( A , N , B , M , K ) ; } }

Index/key variables: i, j
Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void createString ( int N ) { for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( ' a ' ) ; } for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( ' b ' ) ; } } public static void Main ( String [ ] args ) { int N = 4 ; createString ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSubset ( int [ ] A , bool flag ) { int n = A . Length ; int sum = 0 ; if ( flag ) { for ( int i = 1 ; i < n ; i ++ ) A [ i ] = - A [ i ] ; } for ( int i = 1 ; i < n ; i ++ ) { if ( A [ i ] > 0 ) { sum += A [ i ] ; } } return sum ; } static int findBest ( int [ ] A ) { int x = maxSubset ( A , false ) ; int y = maxSubset ( A , true ) ; y = - y ; y += A [ 0 ] ; y = - y ; return Math . Max ( x , y ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 1 , 10 , 4 , - 6 , 3 } ; Console . Write ( findBest ( A ) + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: i, sum, y
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < string > solve ( int n , int [ ] arr ) { string s = " aaa " ; List < string > ans = new List < string > ( ) ; ans . Add ( s ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( s . Length - 1 >= arr [ i ] ) { char ch = s [ arr [ i ] ] ; if ( ch == ' b ' ) ch = ' a ' ; else ch = ' b ' ; char [ ] chr = s . ToCharArray ( ) ; chr [ arr [ i ] ] = ch ; s = new string ( chr ) ; } ans . Add ( s ) ; } return ans ; } public static void Main ( ) { int [ ] arr = { 2 , 0 , 3 } ; int n = arr . Length ; List < string > ans = solve ( n , arr ) ; for ( int i = ans . Count - 1 ; i >= 0 ; i -- ) { Console . WriteLine ( ans [ i ] ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSwaps ( int [ ] A , int n ) { Array . Sort ( A ) ; int ind = 1 , res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { while ( ind < n && A [ ind ] == A [ i ] ) ind ++ ; if ( ind < n && A [ ind ] > A [ i ] ) { res ++ ; ind ++ ; } if ( ind >= n ) break ; } return res ; } public static void Main ( String [ ] args ) { int [ ] A = { 4 , 3 , 3 , 2 , 5 } ; Console . Write ( countSwaps ( A , 5 ) ) ; } }

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

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

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void FindMatrix ( int n , int m , int x , int y ) { int a , b , i , j ; if ( n * m == 1 ) { if ( x > y ) { Console . Write ( y + " STRNEWLINE " ) ; } else { Console . Write ( x + " STRNEWLINE " ) ; } return ; } a = Math . Min ( x , y ) ; b = Math . Min ( 2 * x , y ) - a ; bool flag = true ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < m ; j ++ ) { if ( flag ) Console . Write ( a + " ▁ " ) ; else Console . Write ( b + " ▁ " ) ; flag = ! flag ; } if ( ( ( n % 2 != 0 && m % 2 == 0 ) || ( n % 2 == 0 && m % 2 == 0 ) ) ) flag = ! flag ; Console . Write ( " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int N , M , X , Y ; N = 3 ; M = 3 ; X = 5 ; Y = 3 ; FindMatrix ( N , M , X , Y ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class TSPGreedy { static void findMinRoute ( int [ , ] tsp ) { int sum = 0 ; int counter = 0 ; int j = 0 , i = 0 ; int min = int . MaxValue ; List < int > visitedRouteList = new List < int > ( ) ; visitedRouteList . Add ( 0 ) ; int [ ] route = new int [ tsp . Length ] ; while ( i < tsp . GetLength ( 0 ) && j < tsp . GetLength ( 1 ) ) { if ( counter >= tsp . GetLength ( 0 ) - 1 ) { break ; } if ( j != i && ! ( visitedRouteList . Contains ( j ) ) ) { if ( tsp [ i , j ] < min ) { min = tsp [ i , j ] ; route [ counter ] = j + 1 ; } } j ++ ; if ( j == tsp . GetLength ( 0 ) ) { sum += min ; min = int . MaxValue ; visitedRouteList . Add ( route [ counter ] - 1 ) ; j = 0 ; i = route [ counter ] - 1 ; counter ++ ; } } i = route [ counter - 1 ] - 1 ; for ( j = 0 ; j < tsp . GetLength ( 0 ) ; j ++ ) { if ( ( i != j ) && tsp [ i , j ] < min ) { min = tsp [ i , j ] ; route [ counter ] = j + 1 ; } } sum += min ; Console . Write ( " Minimum ▁ Cost ▁ is ▁ : ▁ " ) ; Console . WriteLine ( sum ) ; } public static void Main ( String [ ] args ) { int [ , ] tsp = { { - 1 , 10 , 15 , 20 } , { 10 , - 1 , 35 , 25 } , { 15 , 35 , - 1 , 30 } , { 20 , 25 , 30 , - 1 } } ; findMinRoute ( tsp ) ; } }

Index/key variables: counter
Accumulator variables: counter, j, sum
Iterator variables: j
Class/struct names: TSPGreedy
C# program:
using System ; using System . Linq ; class GFG { static void findCount ( int [ ] Arr1 , int [ ] Arr2 ) { int MAX = Math . Max ( Arr1 . Max ( ) , Arr2 . Max ( ) ) ; int [ ] Count = new int [ 2 * MAX + 1 ] ; int n = Arr1 . Length , m = Arr2 . Length ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { int element = Arr1 [ i ] + Arr2 [ j ] ; Count [ element ] ++ ; } } for ( int i = 1 ; i <= 2 * MAX ; i ++ ) { if ( Count [ i ] > 0 ) { Console . Write ( i + " - > " + Count [ i ] + " STRNEWLINE " ) ; } } } public static void Main ( String [ ] args ) { int [ ] arr1 = { 1 , 2 } ; int [ ] arr2 = { 1 , 2 , 1 } ; findCount ( arr1 , arr2 ) ; } }

Index/key variables: element, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void findAandB ( double N ) { if ( N == 1 ) { Console . Write ( " No " ) ; return ; } double a = N * N / ( N - 1 ) ; double b = a / N ; Console . Write ( " a ▁ = ▁ " + a + " STRNEWLINE " ) ; Console . Write ( " b ▁ = ▁ " + b + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { double N = 6 ; findAandB ( N ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSelections ( int [ ] A , int n , int k ) { Array . Sort ( A ) ; int sum = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + A [ i ] ; if ( sum > k ) { break ; } count ++ ; } return count ; } public static void Main ( String [ ] args ) { int [ ] A = { 3 , 7 , 2 , 9 , 4 } ; int k = 15 ; int n = A . Length ; Console . Write ( maxSelections ( A , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void computePair ( double K ) { if ( K == 1 ) { Console . Write ( " No " ) ; return ; } else { Console . Write ( K * K / ( K - 1 ) + " ▁ " ) ; Console . Write ( K / ( K - 1 ) + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { double K = 6 ; computePair ( K ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static String ConstructBinaryString ( int N , int M , int K ) { if ( M < ( N - 1 ) || M > K * ( N + 1 ) ) return " - 1" ; string ans = " " ; int l = Math . Min ( K , M / ( N - 1 ) ) ; int temp = N ; while ( temp != 0 ) { temp -- ; ans += '0' ; if ( temp == 0 ) break ; for ( int i = 0 ; i < l ; i ++ ) { ans += '1' ; } } M -= ( N - 1 ) * l ; if ( M == 0 ) return ans ; l = Math . Min ( M , K ) ; for ( int i = 0 ; i < l ; i ++ ) ans += '1' ; M -= l ; while ( M > 0 ) { ans = '1' + ans ; M -- ; } return ans ; } public static void Main ( string [ ] args ) { int N = 5 , M = 9 , K = 2 ; Console . Write ( ConstructBinaryString ( N , M , K ) ) ; } }

Accumulator variables: M, ans, i, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void number ( int num ) { int [ ] a = new int [ 20 ] ; int r , i = 0 , j ; while ( num > 0 ) { r = num % 10 ; if ( 9 - r > r ) a [ i ] = r ; else a [ i ] = 9 - r ; i ++ ; num = num / 10 ; } if ( a [ i - 1 ] == 0 ) { Console . Write ( "9" ) ; i -- ; } for ( j = i - 1 ; j >= 0 ; j -- ) Console . Write ( a [ j ] ) ; } public static void Main ( string [ ] args ) { int num = 4545 ; number ( num ) ; } }

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