dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void minCost ( int [ ] arr , int N , int X ) { Array . Sort ( arr ) ; int sum = 0 ; int cost = 0 ; int INT_MAX = Int32 . MaxValue ; int min_cost = Int32 . MaxValue ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] < 0 ) { cost = Math . Abs ( arr [ i ] ) * X + ( sum - Math . Abs ( arr [ i ] ) * i ) ; sum += Math . Abs ( arr [ i ] ) ; min_cost = Math . Min ( min_cost , cost ) ; } } Console . Write ( min_cost ) ; } static public void Main ( ) { int [ ] arr = { - 1 , - 3 , - 2 , 4 , - 1 } ; int N = arr . Length ; int X = 2 ; minCost ( arr , N , X ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int ans = 0 ; static void countArraysUtil ( List < int > arr , int X , int K , int xorVal ) { if ( X == 0 ) { int cnt = 0 ; for ( int i = 0 ; i < arr . Count ; i ++ ) { if ( arr [ i ] > xorVal ) cnt ++ ; } if ( cnt >= K ) ans ++ ; return ; } int temp = arr [ 0 ] ; arr . RemoveAt ( 0 ) ; countArraysUtil ( arr , X - 1 , K , xorVal ) ; arr . Insert ( 0 , temp ) ; temp = arr [ arr . Count - 1 ] ; arr . RemoveAt ( arr . Count - 1 ) ; countArraysUtil ( arr , X - 1 , K , xorVal ) ; arr . Add ( temp ) ; arr [ 0 ] ++ ; countArraysUtil ( arr , X - 1 , K , xorVal ) ; arr [ 0 ] -- ; arr [ arr . Count - 1 ] ++ ; countArraysUtil ( arr , X - 1 , K , xorVal ) ; arr [ arr . Count - 1 ] -- ; } static void countArrays ( List < int > arr , int X , int K ) { int xorVal = 0 ; for ( int i = 0 ; i < arr . Count ; i ++ ) xorVal = xorVal ^ arr [ i ] ; countArraysUtil ( arr , X , K , xorVal ) ; Console . Write ( ans ) ; } public static void Main ( ) { List < int > arr = new List < int > ( ) { 10 , 2 , 10 , 5 } ; int X = 3 , K = 3 ; countArrays ( arr , X , K ) ; } }

Index/key variables: i
Accumulator variables: ans, cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static int hashFunction ( int N ) { int [ ] prime = { 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 } ; int value = 1 , r ; while ( N != 0 ) { r = N % 10 ; value = value * prime [ r ] ; N = N / 10 ; } return value ; } static void findDiff ( int [ ] arr , int n ) { Dictionary < int , List < int > > m = new Dictionary < int , List < int > > ( ) ; int h , min , max ; for ( int i = 0 ; i < n ; i ++ ) { h = hashFunction ( arr [ i ] ) ; if ( ! m . ContainsKey ( h ) ) { m [ h ] = new List < int > ( ) ; } m [ h ] . Add ( arr [ i ] ) ; } foreach ( KeyValuePair < int , List < int > > i in m ) { if ( i . Value . Count > 1 ) { min = Int32 . MaxValue ; max = Int32 . MinValue ; for ( int j = 0 ; j < i . Value . Count ; j ++ ) { if ( m [ i . Key ] [ j ] < min ) { min = m [ i . Key ] [ j ] ; } if ( m [ i . Key ] [ j ] > max ) { max = m [ i . Key ] [ j ] ; } } Console . Write ( max - min ) ; break ; } else if ( m [ i . Key ] . Equals ( m . Last ( ) . Value ) ) Console . Write ( - 1 ) ; } } static void Main ( ) { int [ ] arr = { 121 , 312 , 234 , 211 , 112 , 102 } ; int N = arr . Length ; findDiff ( arr , N ) ; } }

Index/key variables: h, i, j, r
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int cntMaxApples ( int [ ] apples , int [ ] days ) { List < Tuple < int , int > > pq = new List < Tuple < int , int > > ( ) ; int i = 0 ; int n = apples . Length ; int total_apples = 0 ; while ( i < n . Count > 0 ) { if ( i < n && apples [ i ] != 0 ) { pq . Add ( new Tuple < int , int > ( i + days [ i ] - 1 , apples [ i ] ) ) ; pq . Sort ( ) ; } while ( pq . Count > 0 && pq [ 0 ] . Item1 < i ) { pq . RemoveAt ( 0 ) ; } if ( pq . Count > 0 ) { Tuple < int , int > curr = pq [ 0 ] ; pq . RemoveAt ( 0 ) ; if ( curr . Item2 > 1 ) { pq . Add ( new Tuple < int , int > ( curr . Item1 , curr . Item2 - 1 ) ) ; pq . Sort ( ) ; } ++ total_apples ; } ++ i ; } return total_apples ; } static void Main ( ) { int [ ] apples = { 1 , 2 , 3 , 5 , 2 } ; int [ ] days = { 3 , 2 , 1 , 4 , 2 } ; Console . Write ( cntMaxApples ( apples , days ) ) ; } }

Index/key variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static int findArea ( int [ ] arr , int n ) { Array . Sort ( arr ) ; Array . Reverse ( arr ) ; int [ ] dimension = { 0 , 0 } ; for ( int i = 0 , j = 0 ; i < n - 1 && j < 2 ; i ++ ) if ( arr [ i ] == arr [ i + 1 ] ) dimension [ j ++ ] = arr [ i ++ ] ; return ( dimension [ 0 ] * dimension [ 1 ] ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 2 , 1 , 4 , 6 , 6 , 2 , 5 } ; int n = arr . Length ; Console . Write ( findArea ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findSumLength ( List < int > arr , int n ) { Dictionary < int , int > freq = new Dictionary < int , int > ( ) ; foreach ( int i in arr ) { if ( freq . ContainsKey ( i ) ) freq [ i ] += 1 ; else freq [ i ] = 1 ; } Dictionary < int , int > freq_2 = new Dictionary < int , int > ( ) ; foreach ( KeyValuePair < int , int > entry in freq ) { if ( freq [ entry . Key ] >= 2 ) freq_2 [ entry . Key ] = freq [ entry . Key ] ; } List < int > arr1 = new List < int > ( ) ; foreach ( KeyValuePair < int , int > entry in freq_2 ) arr1 . Add ( entry . Key * ( freq_2 [ entry . Key ] / 2 ) * 2 ) ; arr1 . Sort ( ) ; int summ = 0 ; foreach ( int i in arr1 ) { summ += i ; } Console . WriteLine ( summ ) ; } public static void Main ( ) { List < int > arr = new List < int > ( ) { 5 , 3 , 2 , 3 , 6 , 4 , 4 , 4 , 5 , 5 , 5 } ; int n = arr . Count ; findSumLength ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: summ
Iterator variables: entry, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static int findArea ( int [ ] arr , int n ) { ISet < int > s = new HashSet < int > ( ) ; int first = 0 , second = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! s . Contains ( arr [ i ] ) ) { s . Add ( arr [ i ] ) ; continue ; } if ( arr [ i ] > first ) { second = first ; first = arr [ i ] ; } else if ( arr [ i ] > second ) { second = arr [ i ] ; } } return ( first * second ) ; } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 4 , 2 , 1 , 4 , 6 , 6 , 2 , 5 } ; int n = arr . Length ; Console . WriteLine ( findArea ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class PrintPath { public class Node { public int data ; public Node left , right ; public Node ( int data ) { left = right = null ; this . data = data ; } } ; public static void printTopToBottomPath ( Node curr , Dictionary < Node , Node > parent ) { Stack < Node > stk = new Stack < Node > ( ) ; while ( curr != null ) { stk . Push ( curr ) ; curr = parent [ curr ] ; } while ( stk . Count != 0 ) { curr = stk . Pop ( ) ; Console . Write ( curr . data + " ▁ " ) ; } Console . WriteLine ( ) ; } public static void printRootToLeaf ( Node root ) { if ( root == null ) return ; Stack < Node > nodeStack = new Stack < Node > ( ) ; nodeStack . Push ( root ) ; Dictionary < Node , Node > parent = new Dictionary < Node , Node > ( ) ; parent . Add ( root , null ) ; while ( nodeStack . Count != 0 ) { Node current = nodeStack . Pop ( ) ; if ( current . left == null && current . right == null ) printTopToBottomPath ( current , parent ) ; if ( current . right != null ) { parent . Add ( current . right , current ) ; nodeStack . Push ( current . right ) ; } if ( current . left != null ) { parent . Add ( current . left , current ) ; nodeStack . Push ( current . left ) ; } } } public static void Main ( String [ ] args ) { Node root = new Node ( 10 ) ; root . left = new Node ( 8 ) ; root . right = new Node ( 2 ) ; root . left . left = new Node ( 3 ) ; root . left . right = new Node ( 5 ) ; root . right . left = new Node ( 2 ) ; printRootToLeaf ( root ) ; } }

Index/key variables: curr
Class/struct names: Node, PrintPath
C# program:
using System ; using System . Collections . Generic ; public class GameOfReplacingArrayElements { public static int playGame ( int [ ] arr ) { HashSet < int > set = new HashSet < int > ( ) ; foreach ( int i in arr ) set . Add ( i ) ; return ( set . Count % 2 == 0 ) ? 1 : 2 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 2 , 2 , 2 , 2 } ; Console . Write ( " Player ▁ " + playGame ( arr ) + " ▁ wins " ) ; } }

Iterator variables: i
Class/struct names: GameOfReplacingArrayElements
C# program:
using System ; using System . Collections . Generic ; class GfG { static int longLenStrictBitonicSub ( int [ ] arr , int n ) { Dictionary < int , int > inc = new Dictionary < int , int > ( ) ; Dictionary < int , int > dcr = new Dictionary < int , int > ( ) ; int [ ] len_inc = new int [ n ] ; int [ ] len_dcr = new int [ n ] ; int longLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int len = 0 ; if ( inc . ContainsKey ( arr [ i ] - 1 ) ) len = inc [ arr [ i ] - 1 ] ; len_inc [ i ] = len + 1 ; if ( inc . ContainsKey ( arr [ i ] ) ) { inc . Remove ( arr [ i ] ) ; inc . Add ( arr [ i ] , len_inc [ i ] ) ; } else inc . Add ( arr [ i ] , len_inc [ i ] ) ; } for ( int i = n - 1 ; i >= 0 ; i -- ) { int len = 0 ; if ( dcr . ContainsKey ( arr [ i ] - 1 ) ) len = dcr [ arr [ i ] - 1 ] ; len_dcr [ i ] = len + 1 ; if ( dcr . ContainsKey ( arr [ i ] ) ) { dcr . Remove ( arr [ i ] ) ; dcr . Add ( arr [ i ] , len_dcr [ i ] ) ; } else dcr . Add ( arr [ i ] , len_dcr [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) if ( longLen < ( len_inc [ i ] + len_dcr [ i ] - 1 ) ) longLen = len_inc [ i ] + len_dcr [ i ] - 1 ; return longLen ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 5 , 2 , 3 , 4 , 5 , 3 , 2 } ; int n = arr . Length ; Console . WriteLine ( " Longest ▁ length ▁ strict ▁ " + " bitonic ▁ subsequence ▁ = ▁ " + longLenStrictBitonicSub ( arr , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; public class GFG { static void Selection_Sort ( int [ ] arr , int n ) { for ( int i = 0 ; i < n - 1 ; ++ i ) { int min_index = i ; for ( int j = i + 1 ; j < n ; ++ j ) { if ( arr [ j ] < arr [ min_index ] ) min_index = j ; } int temp = arr [ i ] ; arr [ i ] = arr [ min_index ] ; arr [ min_index ] = temp ; } } public static void Main ( String [ ] args ) { int n = 5 ; int [ ] arr = { 2 , 0 , 1 , 4 , 3 } ; Selection_Sort ( arr , n ) ; Console . Write ( " The ▁ Sorted ▁ Array ▁ by ▁ using ▁ Selection ▁ Sort ▁ is ▁ : ▁ " ) ; for ( int i = 0 ; i < n ; ++ i ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: i, j, min_index
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int lastSeenElement ( int [ ] a , int n ) { Dictionary < int , int > hash = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( hash . ContainsKey ( a [ i ] ) ) { hash [ a [ i ] ] = i ; } else { hash . Add ( a [ i ] , i ) ; } } int res_ind = int . MaxValue , res = 0 ; foreach ( KeyValuePair < int , int > x in hash ) { if ( x . Value < res_ind ) { res_ind = x . Value ; res = x . Key ; } } return res ; } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 1 , 2 , 2 , 4 , 1 } ; int n = a . Length ; Console . WriteLine ( lastSeenElement ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; public class GFG { static void Bubble_Sort ( int [ ] arr , int n ) { for ( int i = 1 ; i < n ; ++ i ) { for ( int j = 0 ; j <= ( n - i - 1 ) ; ++ j ) { if ( arr [ j ] > arr [ j + 1 ] ) { int temp = arr [ j ] ; arr [ j ] = arr [ j + 1 ] ; arr [ j + 1 ] = temp ; } } } } static public void Main ( ) { int n = 5 ; int [ ] arr = { 2 , 0 , 1 , 4 , 3 } ; Bubble_Sort ( arr , n ) ; Console . Write ( " The ▁ Sorted ▁ Array ▁ by ▁ using ▁ Bubble ▁ Sort ▁ is ▁ : ▁ " ) ; for ( int i = 0 ; i < n ; ++ i ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } }

Index/key variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minimum_possible_sum ( int [ ] arr , int n , int k ) { if ( n == 0 ) { return 0 ; } if ( n == 1 ) { return arr [ 0 ] ; } List < int > ms = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { ms . Add ( arr [ i ] ) ; } ms . Sort ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int smallest_element = ms [ 0 ] ; int largest_element = ms [ ms . Count - 1 ] ; int a = smallest_element * 2 ; int b = largest_element / 2 ; if ( a + b < smallest_element + largest_element ) { ms . RemoveAt ( 0 ) ; ms . RemoveAt ( ms . Count - 1 ) ; ms . Add ( a ) ; ms . Add ( b ) ; ms . Sort ( ) ; } } int ans = 0 ; foreach ( int x in ms ) { ans += x ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 50 , 1 , 100 , 100 , 1 } ; int K = 2 ; int n = arr . Length ; Console . Write ( minimum_possible_sum ( arr , n , K ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { static void firstSubsequence ( String s ) { int isMax = - 1 ; for ( int i = 0 ; i < s . Length - 1 ; i ++ ) { if ( s [ i ] > s [ i + 1 ] ) { isMax = i ; break ; } } if ( isMax >= 0 ) { s = s . Substring ( 0 , isMax ) + s . Substring ( isMax + 1 ) ; s . rerase ( isMax , 1 ) ; } else { s . erase ( s . Length - 1 , 1 ) ; s = s . Substring ( 0 , s . Length - 1 ) ; } Console . Write ( s ) ; } public static void Main ( String [ ] args ) { String S = " geeksforgeeks " ; firstSubsequence ( S ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int largeProduct ( int [ ] A , int [ ] B , int N ) { if ( N == 0 ) { return 0 ; } List < int > pq = new List < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { pq . Add ( A [ i ] ) ; } Array . Sort ( B ) ; pq . Sort ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int min = pq [ 0 ] ; pq . RemoveAt ( 0 ) ; int maximized_element = Math . Max ( min * B [ i ] , min + B [ i ] ) ; pq . Add ( maximized_element ) ; pq . Sort ( ) ; } int max_product = 1 ; while ( pq . Count > 0 ) { max_product *= pq [ 0 ] ; pq . RemoveAt ( 0 ) ; } return max_product ; } static public void Main ( ) { int [ ] A = { 1 , 1 , 10 } ; int [ ] B = { 1 , 1 , 1 } ; int N = 3 ; Console . WriteLine ( largeProduct ( A , B , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, max_product
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class Graph { static readonly int MAX_PATH_SIZE = 1000 ; public class Node { public char data ; public Node left , right ; } ; static Node newNode ( char data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } public class PATH { public int Hd ; public char key ; public PATH ( int Hd , char key ) { this . Hd = Hd ; this . key = key ; } public PATH ( ) { } } ; static void printPath ( List < PATH > path , int size ) { int minimum_Hd = int . MaxValue ; PATH p ; for ( int it = 0 ; it < size ; it ++ ) { p = path [ it ] ; minimum_Hd = Math . Min ( minimum_Hd , p . Hd ) ; } for ( int it = 0 ; it < size ; it ++ ) { p = path [ it ] ; int noOfUnderScores = Math . Abs ( p . Hd - minimum_Hd ) ; for ( int i = 0 ; i < noOfUnderScores ; i ++ ) Console . Write ( " _ " ) ; Console . WriteLine ( p . key ) ; } Console . WriteLine ( " = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = " ) ; } static void printAllPathsUtil ( Node root , List < PATH > AllPath , int HD , int order ) { if ( root == null ) return ; if ( root . left == null && root . right == null ) { AllPath [ order ] = new PATH ( HD , root . data ) ; printPath ( AllPath , order + 1 ) ; return ; } AllPath [ order ] = new PATH ( HD , root . data ) ; printAllPathsUtil ( root . left , AllPath , HD - 1 , order + 1 ) ; printAllPathsUtil ( root . right , AllPath , HD + 1 , order + 1 ) ; } static void printAllPaths ( Node root ) { if ( root == null ) return ; List < PATH > Allpaths = new List < PATH > ( ) ; for ( int i = 0 ; i < MAX_PATH_SIZE ; i ++ ) { Allpaths . Add ( new PATH ( ) ) ; } printAllPathsUtil ( root , Allpaths , 0 , 0 ) ; } public static void Main ( String [ ] args ) { Node root = newNode ( ' A ' ) ; root . left = newNode ( ' B ' ) ; root . right = newNode ( ' C ' ) ; root . left . left = newNode ( ' D ' ) ; root . left . right = newNode ( ' E ' ) ; root . right . left = newNode ( ' F ' ) ; root . right . right = newNode ( ' G ' ) ; printAllPaths ( root ) ; } }

Index/key variables: it, order
Accumulator variables: i, it
Iterator variables: i, it
Class/struct names: Graph, Node, PATH
C# program:
using System ; class GFG { static int minsteps ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += Math . Abs ( arr [ i ] - ( int ) ( Math . Pow ( 2 , i ) ) ) ; } return ans ; } public static void Main ( ) { int [ ] arr = { 1 , 8 , 2 , 10 , 6 } ; int n = arr . Length ; Console . WriteLine ( minsteps ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void leftRotate ( int [ ] arr , int d , int n ) { leftRotateRec ( arr , 0 , d , n ) ; } public static void leftRotateRec ( int [ ] arr , int i , int d , int n ) { if ( d == 0 d == n ) return ; if ( n - d == d ) { swap ( arr , i , n - d + i , d ) ; return ; } if ( d < n - d ) { swap ( arr , i , n - d + i , d ) ; leftRotateRec ( arr , i , d , n - d ) ; } else { swap ( arr , i , d , n - d ) ; leftRotateRec ( arr , n - d + i , 2 * d - n , d ) ; } } public static void printArray ( int [ ] arr , int size ) { int i ; for ( i = 0 ; i < size ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } public static void swap ( int [ ] arr , int fi , int si , int d ) { int i , temp ; for ( i = 0 ; i < d ; i ++ ) { temp = arr [ fi + i ] ; arr [ fi + i ] = arr [ si + i ] ; arr [ si + i ] = temp ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 , 7 } ; leftRotate ( arr , 2 , 7 ) ; printArray ( arr , 7 ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findCost ( int [ ] a , int n ) { Array . Sort ( a ) ; Array . Reverse ( a ) ; int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { int p = a [ j ] - j ; a [ j ] = 0 ; if ( p < 0 ) { p = 0 ; continue ; } count += p ; } return count ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 6 , 7 , 4 , 2 , 5 , 3 } ; int N = arr . Length ; Console . Write ( findCost ( arr , N ) ) ; } }

Index/key variables: j
Accumulator variables: count, j
Iterator variables: j
Class/struct names: GFG
C# program:
static void leftRotate ( int [ ] arr , int d , int n ) { int i , j ; if ( d == 0 d == n ) return ; i = d ; j = n - d ; while ( i != j ) { if ( i < j ) { swap ( arr , d - i , d + j - i , i ) ; j -= i ; } else { swap ( arr , d - i , d , j ) ; i -= j ; } } swap ( arr , d - i , d , i ) ; }

Accumulator variables: i, j
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countPairs ( int [ ] arr , int n ) { int ans = 0 ; Dictionary < int , int > count = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( count . ContainsKey ( arr [ i ] ) ) { ans += count [ arr [ i ] ] ; count [ arr [ i ] ] = count [ arr [ i ] ] + 1 ; } else { count . Add ( arr [ i ] , 1 ) ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 1 , 1 } ; int N = arr . Length ; Console . Write ( countPairs ( arr , N ) ) ; } }

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

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static string findLargest ( char [ ] s ) { int len = s . Length ; int [ ] loccur = new int [ 26 ] ; Array . Fill ( loccur , - 1 ) ; for ( int i = len - 1 ; i >= 0 ; -- i ) { int chI = s [ i ] - ' a ' ; if ( loccur [ chI ] == - 1 ) { loccur [ chI ] = i ; } } char [ ] sorted_s = ( new string ( s ) ) . ToCharArray ( ) ; Array . Sort ( sorted_s ) ; Array . Reverse ( sorted_s ) ; for ( int i = 0 ; i < len ; ++ i ) { if ( s [ i ] != sorted_s [ i ] ) { int chI = sorted_s [ i ] - ' a ' ; int last_occ = loccur [ chI ] ; char temp = s [ i ] ; s [ i ] = s [ last_occ ] ; s [ last_occ ] = temp ; break ; } } return ( new string ( s ) ) ; } static void Main ( ) { string str = " yrstvw " ; char [ ] s = str . ToCharArray ( ) ; Console . WriteLine ( findLargest ( s ) ) ; } }

Index/key variables: chI, i, last_occ
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class PairInSortedRotated { static bool pairInSortedRotated ( int [ ] arr , int n , int x ) { int i ; for ( i = 0 ; i < n - 1 ; i ++ ) if ( arr [ i ] > arr [ i + 1 ] ) break ; int l = ( i + 1 ) % n ; int r = i ; while ( l != r ) { if ( arr [ l ] + arr [ r ] == x ) return true ; if ( arr [ l ] + arr [ r ] < x ) l = ( l + 1 ) % n ; else r = ( n + r - 1 ) % n ; } return false ; } public static void Main ( ) { int [ ] arr = { 11 , 15 , 6 , 8 , 9 , 10 } ; int sum = 16 ; int n = arr . Length ; if ( pairInSortedRotated ( arr , n , sum ) ) Console . WriteLine ( " Array ▁ has ▁ two ▁ elements " + " ▁ with ▁ sum ▁ 16" ) ; else Console . WriteLine ( " Array ▁ doesn ' t ▁ have ▁ two " + " ▁ elements ▁ with ▁ sum ▁ 16 ▁ " ) ; } }

Index/key variables: i, l, r
Accumulator variables: i
Iterator variables: i
Class/struct names: PairInSortedRotated
C# program:
using System ; class GFG { static int pairsInSortedRotated ( int [ ] arr , int n , int x ) { int i ; for ( i = 0 ; i < n - 1 ; i ++ ) if ( arr [ i ] > arr [ i + 1 ] ) break ; int l = ( i + 1 ) % n ; int r = i ; int cnt = 0 ; while ( l != r ) { if ( arr [ l ] + arr [ r ] == x ) { cnt ++ ; if ( l == ( r - 1 + n ) % n ) { return cnt ; } l = ( l + 1 ) % n ; r = ( r - 1 + n ) % n ; } else if ( arr [ l ] + arr [ r ] < x ) l = ( l + 1 ) % n ; else r = ( n + r - 1 ) % n ; } return cnt ; } static public void Main ( ) { int [ ] arr = { 11 , 15 , 6 , 7 , 9 , 10 } ; int sum = 16 ; int n = arr . Length ; Console . WriteLine ( pairsInSortedRotated ( arr , n , sum ) ) ; } }

Index/key variables: i, l, r
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class Test { static int [ ] arr = new int [ ] { 10 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; static int maxSum ( ) { int arrSum = 0 ; int currVal = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { arrSum = arrSum + arr [ i ] ; currVal = currVal + ( i * arr [ i ] ) ; } int maxVal = currVal ; for ( int j = 1 ; j < arr . Length ; j ++ ) { currVal = currVal + arrSum - arr . Length * arr [ arr . Length - j ] ; if ( currVal > maxVal ) maxVal = currVal ; } return maxVal ; } public static void Main ( ) { Console . WriteLine ( " Max ▁ sum ▁ is ▁ " + maxSum ( ) ) ; } }

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