dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static void medianChange ( List < int > arr1 , List < int > arr2 ) { int N = arr1 . Count ; List < double > median = new List < double > ( ) ; if ( ( N & 1 ) != 0 ) { median . Add ( arr1 [ N / 2 ] * 1.0 ) ; } else { median . Add ( ( arr1 [ N / 2 ] + arr1 [ ( N - 1 ) / 2 ] ) / 2.0 ) ; } foreach ( int x in arr2 ) { int it = arr1 . IndexOf ( x ) ; arr1 . RemoveAt ( it ) ; N -- ; if ( ( N & 1 ) != 0 ) { median . Add ( arr1 [ N / 2 ] * 1.0 ) ; } else { median . Add ( ( arr1 [ N / 2 ] + arr1 [ ( N - 1 ) / 2 ] ) / 2.0 ) ; } } for ( int i = 0 ; i < median . Count - 1 ; i ++ ) { Console . Write ( median [ i + 1 ] - median [ i ] + " ▁ " ) ; } } static void Main ( ) { List < int > arr1 = new List < int > ( new int [ ] { 2 , 4 , 6 , 8 , 10 } ) ; List < int > arr2 = new List < int > ( new int [ ] { 4 , 6 } ) ; medianChange ( arr1 , arr2 ) ; } }

Index/key variables: i
Accumulator variables: N, i
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { static int nfa = 1 ; static int flag = 0 ; static void state1 ( char c ) { if ( c == ' a ' ) nfa = 2 ; else if ( c == ' b ' c == ' c ' ) nfa = 1 ; else flag = 1 ; } static void state2 ( char c ) { if ( c == ' a ' ) nfa = 3 ; else if ( c == ' b ' c == ' c ' ) nfa = 2 ; else flag = 1 ; } static void state3 ( char c ) { if ( c == ' a ' ) nfa = 1 ; else if ( c == ' b ' c == ' c ' ) nfa = 3 ; else flag = 1 ; } static void state4 ( char c ) { if ( c == ' b ' ) nfa = 5 ; else if ( c == ' a ' c == ' c ' ) nfa = 4 ; else flag = 1 ; } static void state5 ( char c ) { if ( c == ' b ' ) nfa = 6 ; else if ( c == ' a ' c == ' c ' ) nfa = 5 ; else flag = 1 ; } static void state6 ( char c ) { if ( c == ' b ' ) nfa = 4 ; else if ( c == ' a ' c == ' c ' ) nfa = 6 ; else flag = 1 ; } static void state7 ( char c ) { if ( c == ' c ' ) nfa = 8 ; else if ( c == ' b ' c == ' a ' ) nfa = 7 ; else flag = 1 ; } static void state8 ( char c ) { if ( c == ' c ' ) nfa = 9 ; else if ( c == ' b ' c == ' a ' ) nfa = 8 ; else flag = 1 ; } static void state9 ( char c ) { if ( c == ' c ' ) nfa = 7 ; else if ( c == ' b ' c == ' a ' ) nfa = 9 ; else flag = 1 ; } static bool checkA ( String s , int x ) { for ( int i = 0 ; i < x ; i ++ ) { if ( nfa == 1 ) state1 ( s [ i ] ) ; else if ( nfa == 2 ) state2 ( s [ i ] ) ; else if ( nfa == 3 ) state3 ( s [ i ] ) ; } if ( nfa == 1 ) { return true ; } else { nfa = 4 ; } return false ; } static bool checkB ( String s , int x ) { for ( int i = 0 ; i < x ; i ++ ) { if ( nfa == 4 ) state4 ( s [ i ] ) ; else if ( nfa == 5 ) state5 ( s [ i ] ) ; else if ( nfa == 6 ) state6 ( s [ i ] ) ; } if ( nfa == 4 ) { return true ; } else { nfa = 7 ; } return false ; } static bool checkC ( String s , int x ) { for ( int i = 0 ; i < x ; i ++ ) { if ( nfa == 7 ) state7 ( s [ i ] ) ; else if ( nfa == 8 ) state8 ( s [ i ] ) ; else if ( nfa == 9 ) state9 ( s [ i ] ) ; } if ( nfa == 7 ) { return true ; } return false ; } public static void Main ( String [ ] args ) { String s = " bbbca " ; int x = 5 ; if ( checkA ( s , x ) || checkB ( s , x ) || checkC ( s , x ) ) { Console . WriteLine ( " ACCEPTED " ) ; } else { if ( flag == 0 ) { Console . WriteLine ( " NOT ▁ ACCEPTED " ) ; } else { Console . WriteLine ( " INPUT ▁ OUT ▁ OF ▁ DICTIONARY . " ) ; } } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getPositionCount ( int [ ] a , int n ) { int count = 1 ; int min = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] <= min ) { min = a [ i ] ; count ++ ; } } return count ; } public static void Main ( ) { int [ ] a = { 5 , 4 , 6 , 1 , 3 , 1 } ; int n = a . Length ; Console . WriteLine ( getPositionCount ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSum ( int [ ] arr , int n , int k ) { if ( n < k ) { return - 1 ; } int res = 0 ; for ( int i = 0 ; i < k ; i ++ ) res += arr [ i ] ; int curr_sum = res ; for ( int i = k ; i < n ; i ++ ) { curr_sum += arr [ i ] - arr [ i - k ] ; res = Math . Max ( res , curr_sum ) ; } return res ; } static int solve ( int [ ] arr , int n , int k ) { int max_len = 0 , l = 0 , r = n , m ; while ( l <= r ) { m = ( l + r ) / 2 ; if ( maxSum ( arr , n , m ) > k ) r = m - 1 ; else { l = m + 1 ; max_len = m ; } } return max_len ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . Length ; int k = 10 ; Console . WriteLine ( solve ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: curr_sum, i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 100001 ; static int ROW = 10 ; static int COl = 3 ; static List < int > [ ] indices = new List < int > [ MAX ] ; static int [ , ] test = { { 2 , 3 , 6 } , { 2 , 4 , 4 } , { 2 , 6 , 3 } , { 3 , 2 , 6 } , { 3 , 3 , 3 } , { 3 , 6 , 2 } , { 4 , 2 , 4 } , { 4 , 4 , 2 } , { 6 , 2 , 3 } , { 6 , 3 , 2 } } ; static int find_triplet ( int [ ] array , int n ) { int answer = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) { indices [ i ] = new List < int > ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { indices [ array [ i ] ] . Add ( i ) ; } for ( int i = 0 ; i < n ; i ++ ) { int y = array [ i ] ; for ( int j = 0 ; j < ROW ; j ++ ) { int s = test [ j , 1 ] * y ; if ( s % test [ j , 0 ] != 0 ) continue ; if ( s % test [ j , 2 ] != 0 ) continue ; int x = s / test [ j , 0 ] ; int z = s / test [ j , 2 ] ; if ( x > MAX z > MAX ) continue ; int l = 0 ; int r = indices [ x ] . Count - 1 ; int first = - 1 ; while ( l <= r ) { int m = ( l + r ) / 2 ; if ( indices [ x ] [ m ] < i ) { first = m ; l = m + 1 ; } else { r = m - 1 ; } } l = 0 ; r = indices [ z ] . Count - 1 ; int third = - 1 ; while ( l <= r ) { int m = ( l + r ) / 2 ; if ( indices [ z ] [ m ] > i ) { third = m ; r = m - 1 ; } else { l = m + 1 ; } } if ( first != - 1 && third != - 1 ) { answer += ( first + 1 ) * ( indices [ z ] . Count - third ) ; } } } return answer ; } public static void Main ( String [ ] args ) { int [ ] array = { 2 , 4 , 5 , 6 , 7 } ; int n = array . Length ; Console . WriteLine ( find_triplet ( array , n ) ) ; } }

Index/key variables: MAX, i, m, x, z
Accumulator variables: answer, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int distinct ( int [ ] arr , int n ) { int count = 0 ; if ( n == 1 ) return 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( i == 0 ) { if ( arr [ i ] != arr [ i + 1 ] ) count += 1 ; } else { if ( arr [ i ] != arr [ i + 1 ] arr [ i ] != arr [ i - 1 ] ) count += 1 ; } } if ( arr [ n - 1 ] != arr [ n - 2 ] ) count += 1 ; return count ; } public static void Main ( String [ ] args ) { int [ ] arr = { 0 , 0 , 0 , 0 , 0 , 1 , 0 } ; int n = arr . Length ; Console . WriteLine ( distinct ( 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 isSorted ( int [ , ] arr , int N ) { for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i , 0 ] > arr [ i - 1 , 0 ] ) { return false ; } } return true ; } static string isPossibleToSort ( int [ , ] arr , int N ) { int group = arr [ 0 , 1 ] ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i , 1 ] != group ) { return " Yes " ; } } if ( isSorted ( arr , N ) ) { return " Yes " ; } else { return " No " ; } } public static void Main ( ) { int [ , ] arr = { { 340000 , 2 } , { 45000 , 1 } , { 30000 , 2 } , { 50000 , 4 } } ; int N = arr . GetLength ( 0 ) ; Console . WriteLine ( isPossibleToSort ( arr , N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class Node { public Node left , right ; public int data ; public Node ( int data ) { this . data = data ; left = null ; right = null ; } } class AlphaScore { Node root ; AlphaScore ( ) { root = null ; } static long sum = 0 , total_sum = 0 ; static long mod = 1000000007 ; static long getAlphaScore ( Node node ) { if ( node . left != null ) getAlphaScore ( node . left ) ; sum = ( sum + node . data ) % mod ; total_sum = ( total_sum + sum ) % mod ; if ( node . right != null ) getAlphaScore ( node . right ) ; return total_sum ; } static Node constructBST ( int [ ] arr , int start , int end , Node root ) { if ( start > end ) return null ; int mid = ( start + end ) / 2 ; if ( root == null ) root = new Node ( arr [ mid ] ) ; root . left = constructBST ( arr , start , mid - 1 , root . left ) ; root . right = constructBST ( arr , mid + 1 , end , root . right ) ; return root ; } public static void Main ( String [ ] args ) { int [ ] arr = { 10 , 11 , 12 } ; int length = arr . Length ; Array . Sort ( arr ) ; Node root = null ; root = constructBST ( arr , 0 , length - 1 , root ) ; Console . WriteLine ( getAlphaScore ( root ) ) ; } }

Index/key variables: mid
Class/struct names: AlphaScore, Node
C# program:
using System ; class GFG { static int sortByFreq ( int [ ] arr , int n ) { int maxE = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { maxE = Math . Max ( maxE , arr [ i ] ) ; } int [ ] freq = new int [ maxE + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ arr [ i ] ] ++ ; } int cnt = 0 ; for ( int i = 0 ; i <= maxE ; i ++ ) { if ( freq [ i ] > 0 ) { int value = 100000 - i ; arr [ cnt ] = 100000 * freq [ i ] + value ; cnt ++ ; } } return cnt ; } static void printSortedArray ( int [ ] arr , int cnt ) { for ( int i = 0 ; i < cnt ; i ++ ) { int frequency = arr [ i ] / 100000 ; int value = 100000 - ( arr [ i ] % 100000 ) ; for ( int j = 0 ; j < frequency ; j ++ ) { Console . Write ( value + " ▁ " ) ; } } } public static void Main ( ) { int [ ] arr = { 4 , 4 , 5 , 6 , 4 , 2 , 2 , 8 , 5 } ; int n = arr . Length ; int cnt = sortByFreq ( arr , n ) ; Array . Sort ( arr ) ; Array . Reverse ( arr ) ; printSortedArray ( arr , cnt ) ; } }

Index/key variables: cnt, i
Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkRectangles ( int [ ] arr , int n ) { bool ans = true ; Array . Sort ( arr ) ; int area = arr [ 0 ] * arr [ 4 * n - 1 ] ; for ( int i = 0 ; i < 2 * n ; i = i + 2 ) { if ( arr [ i ] != arr [ i + 1 ] arr [ 4 * n - i - 1 ] != arr [ 4 * n - i - 2 ] arr [ i ] * arr [ 4 * n - i - 1 ] != area ) { ans = false ; break ; } } if ( ans ) return true ; return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 8 , 2 , 1 , 2 , 4 , 4 , 8 } ; int n = 2 ; if ( checkRectangles ( arr , n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: i
Iterator variables: i
Boolean variables: ans
Class/struct names: GFG
C# program:
using System ; class GFG { static int cntElements ( int [ ] arr , int n ) { int [ ] copy_arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) copy_arr [ i ] = arr [ i ] ; int count = 0 ; Array . Sort ( arr ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != copy_arr [ i ] ) { count ++ ; } } return count ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 6 , 2 , 4 , 5 } ; int n = arr . Length ; Console . WriteLine ( cntElements ( arr , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void findPairs ( int [ ] arr , int n , int k , int d ) { if ( n < 2 * k ) { Console . Write ( - 1 ) ; return ; } List < pair > pairs = new List < pair > ( ) ; Array . Sort ( arr ) ; for ( int i = 0 ; i < k ; i ++ ) { if ( arr [ n - k + i ] - arr [ i ] >= d ) { pair p = new pair ( arr [ i ] , arr [ n - k + i ] ) ; pairs . Add ( p ) ; } } if ( pairs . Count < k ) { Console . Write ( - 1 ) ; return ; } foreach ( pair v in pairs ) { Console . WriteLine ( " ( " + v . first + " , ▁ " + v . second + " ) " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 6 , 10 , 23 , 14 , 7 , 2 , 20 , 9 } ; int n = arr . Length ; int k = 4 , d = 3 ; findPairs ( arr , n , k , d ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, v
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static int pairs_count ( int [ ] arr , int n , int sum ) { int ans = 0 ; Array . Sort ( arr ) ; int i = 0 , j = n - 1 ; while ( i < j ) { if ( arr [ i ] + arr [ j ] < sum ) i ++ ; else if ( arr [ i ] + arr [ j ] > sum ) j -- ; else { int x = arr [ i ] , xx = i ; while ( ( i < j ) && ( arr [ i ] == x ) ) i ++ ; int y = arr [ j ] , yy = j ; while ( ( j >= i ) && ( arr [ j ] == y ) ) j -- ; if ( x == y ) { int temp = i - xx + yy - j - 1 ; ans += ( temp * ( temp + 1 ) ) / 2 ; } else ans += ( i - xx ) * ( yy - j ) ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 5 , 7 , 5 , - 1 } ; int n = arr . Length ; int sum = 6 ; Console . WriteLine ( pairs_count ( arr , n , sum ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( string str ) { int min = Int32 . MaxValue ; int max = Int32 . MinValue ; int sum = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { int ascii = ( int ) str [ i ] ; if ( ascii < 96 ascii > 122 ) return false ; sum += ascii ; if ( min > ascii ) min = ascii ; if ( max < ascii ) max = ascii ; } min -= 1 ; int eSum = ( ( max * ( max + 1 ) ) / 2 ) - ( ( min * ( min + 1 ) ) / 2 ) ; return sum == eSum ; } static void Main ( ) { string str = " dcef " ; if ( check ( str ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; string str1 = " xyza " ; if ( check ( str1 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, min, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static int findKth ( int [ ] arr , int n , int k ) { HashSet < int > missing = new HashSet < int > ( ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { missing . Add ( arr [ i ] ) ; } int maxm = arr . Max ( ) ; int minm = arr . Min ( ) ; for ( int i = minm + 1 ; i < maxm ; i ++ ) { if ( ! missing . Contains ( i ) ) { count ++ ; } if ( count == k ) { return i ; } } return - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 10 , 9 , 4 } ; int n = arr . Length ; int k = 5 ; Console . WriteLine ( findKth ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public class Node { public int data ; public Node next ; } ; static Node start ; static void sortList ( Node head ) { int startVal = 1 ; while ( head != null ) { head . data = startVal ; startVal ++ ; head = head . next ; } } static void push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head_ref ; head_ref = new_node ; start = head_ref ; } static void printList ( Node node ) { while ( node != null ) { Console . Write ( node . data + " ▁ " ) ; node = node . next ; } } public static void Main ( String [ ] args ) { start = null ; push ( start , 2 ) ; push ( start , 1 ) ; push ( start , 6 ) ; push ( start , 4 ) ; push ( start , 5 ) ; push ( start , 3 ) ; sortList ( start ) ; printList ( start ) ; } }

Accumulator variables: startVal
Class/struct names: GFG, Node
C# program:
using System ; class GfG { public class Node { public int data ; public Node next ; } static bool isSortedDesc ( Node head ) { if ( head == null head . next == null ) return true ; return ( head . data > head . next . data && isSortedDesc ( head . next ) ) ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . next = null ; temp . data = data ; return temp ; } public static void Main ( String [ ] args ) { Node head = newNode ( 7 ) ; head . next = newNode ( 5 ) ; head . next . next = newNode ( 4 ) ; head . next . next . next = newNode ( 3 ) ; if ( isSortedDesc ( head ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minSum ( int [ ] arr , int n ) { List < int > evenArr = new List < int > ( ) ; List < int > oddArr = new List < int > ( ) ; int i ; Array . Sort ( arr ) ; for ( i = 0 ; i < n ; i ++ ) { if ( i < n / 2 ) { oddArr . Add ( arr [ i ] ) ; } else { evenArr . Add ( arr [ i ] ) ; } } evenArr . Sort ( ) ; evenArr . Reverse ( ) ; int k = 0 , sum = 0 ; for ( int j = 0 ; j < evenArr . Count ; j ++ ) { arr [ k ++ ] = evenArr [ j ] ; arr [ k ++ ] = oddArr [ j ] ; sum += evenArr [ j ] * oddArr [ j ] ; } return sum ; } public static void Main ( ) { int [ ] arr = { 1 , 5 , 8 , 9 , 6 , 7 , 3 , 4 , 2 , 0 } ; int n = arr . Length ; Console . WriteLine ( " Minimum ▁ required ▁ sum ▁ = ▁ " + minSum ( arr , n ) ) ; Console . WriteLine ( " Sorted ▁ array ▁ in ▁ " + " required ▁ format ▁ : ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j, k, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void minTime ( string word ) { int ans = 0 ; int curr = 0 ; for ( int i = 0 ; i < word . Length ; i ++ ) { int k = ( int ) word [ i ] - 97 ; int a = Math . Abs ( curr - k ) ; int b = 26 - Math . Abs ( curr - k ) ; ans += Math . Min ( a , b ) ; ans ++ ; curr = ( int ) word [ i ] - 97 ; } Console . Write ( ans ) ; } public static void Main ( ) { string str = " zjpc " ; minTime ( str ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int reduceToOne ( long N ) { int cnt = 0 ; while ( N != 1 ) { if ( N == 2 || ( N % 2 == 1 ) ) { N = N - 1 ; cnt ++ ; } else if ( N % 2 == 0 ) { N = N / ( N / 2 ) ; cnt ++ ; } } return cnt ; } public static void Main ( ) { long N = 35 ; Console . WriteLine ( reduceToOne ( N ) ) ; } }

Accumulator variables: cnt
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static void maxDiamonds ( int [ ] A , int N , int K ) { var pq = new List < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { pq . Add ( A [ i ] ) ; } int ans = 0 ; while ( pq . Count != 0 && K -- > 0 ) { pq . Sort ( ) ; int top = pq [ pq . Count - 1 ] ; pq . RemoveAt ( pq . Count - 1 ) ; ans += top ; top = top / 2 ; pq . Add ( top ) ; } Console . WriteLine ( ans ) ; } public static void Main ( string [ ] args ) { int [ ] A = { 2 , 1 , 7 , 4 , 2 } ; int K = 3 ; int N = A . Length ; maxDiamonds ( A , N , K ) ; } }

Index/key variables: i
Accumulator variables: K, ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MinimumCost ( int [ ] A , int [ ] B , int N ) { int totalCost = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int mod_A = B [ i ] % A [ i ] ; int totalCost_A = Math . Min ( mod_A , A [ i ] - mod_A ) ; int mod_B = A [ i ] % B [ i ] ; int totalCost_B = Math . Min ( mod_B , B [ i ] - mod_B ) ; totalCost += Math . Min ( totalCost_A , totalCost_B ) ; } return totalCost ; } public static void Main ( ) { int [ ] A = { 3 , 6 , 3 } ; int [ ] B = { 4 , 8 , 13 } ; int N = A . Length ; Console . Write ( MinimumCost ( A , B , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, totalCost
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void printLargestDivisible ( int [ ] arr , int N ) { int i , count0 = 0 , count7 = 0 ; for ( i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 0 ) count0 ++ ; else count7 ++ ; } if ( count7 % 50 == 0 ) { while ( count7 != 0 ) { Console . Write ( 7 ) ; count7 -= 1 ; } while ( count0 != 0 ) { Console . Write ( 0 ) ; count0 -= 1 ; } } else if ( count7 < 5 ) { if ( count0 == 0 ) Console . Write ( " No " ) ; else Console . Write ( "0" ) ; } else { count7 = count7 - count7 % 5 ; while ( count7 != 0 ) { Console . Write ( 7 ) ; count7 -= 1 ; } while ( count0 != 0 ) { Console . Write ( 0 ) ; count0 -= 1 ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 0 , 7 , 0 , 7 , 7 , 7 , 7 , 0 , 0 , 0 , 0 , 0 , 0 , 7 , 7 , 7 } ; int N = arr . Length ; printLargestDivisible ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count0, count7, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMaxValByRearrArr ( int [ ] arr , int N ) { Array . Sort ( arr ) ; int res = 0 ; do { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += __gcd ( i + 1 , arr [ i ] ) ; } res = Math . Max ( res , sum ) ; } while ( next_permutation ( arr ) ) ; return res ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } static bool next_permutation ( int [ ] p ) { for ( int a = p . Length - 2 ; a >= 0 ; -- a ) if ( p [ a ] < p [ a + 1 ] ) for ( int b = p . Length - 1 ; ; -- b ) if ( p [ b ] > p [ a ] ) { int t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; for ( ++ a , b = p . Length - 1 ; a < b ; ++ a , -- b ) { t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; } return true ; } return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 1 } ; int N = arr . Length ; Console . Write ( findMaxValByRearrArr ( arr , N ) ) ; } }

Index/key variables: a, b, i
Accumulator variables: i, sum
Iterator variables: a, b, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int min_elements ( int [ ] arr , int N ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] ++ ; } else { mp [ arr [ i ] ] = 1 ; } } int cntMinRem = 0 ; foreach ( KeyValuePair < int , int > it in mp ) { int i = it . Key ; if ( mp [ i ] < i ) { cntMinRem += mp [ i ] ; } else if ( mp [ i ] > i ) { cntMinRem += ( mp [ i ] - i ) ; } } return cntMinRem ; } static void Main ( ) { int [ ] arr = { 2 , 4 , 1 , 4 , 2 } ; int N = arr . Length ; Console . Write ( min_elements ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: cntMinRem, i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { static bool CheckAllarrayEqual ( int [ ] arr , int N ) { if ( N == 1 ) { return true ; } int totalSum = arr [ 0 ] ; int secMax = Int32 . MinValue ; int Max = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] >= Max ) { secMax = Max ; Max = arr [ i ] ; } else if ( arr [ i ] > secMax ) { secMax = arr [ i ] ; } totalSum += arr [ i ] ; } if ( ( secMax * ( N - 1 ) ) > totalSum ) { return false ; } if ( totalSum % ( N - 1 ) != 0 ) { return false ; } return true ; } public static void Main ( ) { int [ ] arr = { 6 , 2 , 2 , 2 } ; int N = arr . Length ; if ( CheckAllarrayEqual ( arr , N ) ) { Console . Write ( " YES " ) ; } else { Console . Write ( " NO " ) ; } } }

Index/key variables: i
Accumulator variables: i, totalSum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void Remove_one_element ( int [ ] arr , int n ) { int post_odd = 0 , post_even = 0 ; int curr_odd = 0 , curr_even = 0 ; int res = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( i % 2 != 0 ) post_odd ^= arr [ i ] ; else post_even ^= arr [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 != 0 ) post_odd ^= arr [ i ] ; else post_even ^= arr [ i ] ; int X = curr_odd ^ post_even ; int Y = curr_even ^ post_odd ; if ( X == Y ) res ++ ; if ( i % 2 != 0 ) curr_odd ^= arr [ i ] ; else curr_even ^= arr [ i ] ; } Console . WriteLine ( res ) ; } public static void Main ( ) { int [ ] arr = { 1 , 0 , 1 , 0 , 1 } ; int N = arr . Length ; Remove_one_element ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: curr_even, curr_odd, i, post_even, post_odd, res
Iterator variables: i
Class/struct names: GFG