dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int MAX = 1000 ; static Boolean lineExists ( int [ ] x , int [ ] y , int [ ] v , int n ) { int size = ( 2 * MAX ) + 1 ; long [ ] arr = new long [ size ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ x [ i ] + MAX ] += v [ i ] ; } for ( int i = 1 ; i < size ; i ++ ) arr [ i ] += arr [ i - 1 ] ; if ( arr [ size - 1 ] == 0 ) return true ; if ( arr [ size - 1 ] - arr [ 0 ] == 0 ) return true ; for ( int i = 1 ; i < size - 1 ; i ++ ) { if ( arr [ i - 1 ] == arr [ size - 1 ] - arr [ i - 1 ] ) return true ; if ( arr [ i - 1 ] == arr [ size - 1 ] - arr [ i ] ) return true ; if ( arr [ i ] == arr [ size - 1 ] - arr [ i ] ) return true ; } if ( arr [ size - 2 ] == 0 ) return true ; return false ; } public static void Main ( String [ ] args ) { int [ ] x = { - 3 , 5 , 8 } ; int [ ] y = { 8 , 7 , 9 } ; int [ ] v = { 8 , 2 , 10 } ; int n = x . Length ; if ( lineExists ( x , y , v , n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, size
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSum ( int [ ] a , int n ) { Array . Sort ( a ) ; int sum = 0 ; for ( int i = 0 ; i < n - 1 ; i += 2 ) { sum += a [ i ] ; } return sum ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 2 , 1 , 4 , 5 } ; int n = arr . Length ; Console . WriteLine ( maxSum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static void sortWithRemainder ( int [ ] arr , int n , int k ) { ArrayList [ ] v = new ArrayList [ k ] ; for ( int i = 0 ; i < k ; i ++ ) { v [ i ] = new ArrayList ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { v [ arr [ i ] % k ] . Add ( arr [ i ] ) ; } for ( int i = 0 ; i < k ; i ++ ) { v [ i ] . Sort ( ) ; } int j = 0 ; for ( int i = 0 ; i < k ; i ++ ) { foreach ( int x in v [ i ] ) { arr [ j ] = x ; j ++ ; } } printArr ( arr , n ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 10 , 7 , 2 , 6 , 12 , 3 , 33 , 46 } ; int n = arr . Length ; int k = 4 ; sortWithRemainder ( arr , n , k ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { static bool customSort ( string s1 , string s2 ) { int count_a1 = 0 , count_b1 = 0 ; for ( int i = 0 ; i < s1 . Length ; i ++ ) { if ( s1 [ i ] == ' a ' ) { count_a1 ++ ; } else { count_b1 ++ ; } } int count_a2 = 0 , count_b2 = 0 ; for ( int i = 0 ; i < s1 . Length ; i ++ ) { if ( s2 [ i ] == ' a ' ) { count_a2 ++ ; } else { count_b2 ++ ; } } if ( count_a1 * count_b2 > count_b1 * count_a2 ) { return true ; } else { return false ; } } static string concatenateStrings ( string [ ] S , int N ) { string str = " " ; for ( int i = 0 ; i < N ; i ++ ) { str += S [ i ] ; } return str ; } static int getMaxScore ( string [ ] S , int N ) { Array . Sort ( S ) ; string combined_string = concatenateStrings ( S , N ) ; int final_score = 0 , count_a = 0 ; for ( int i = 0 ; i < combined_string . Length ; i ++ ) { if ( combined_string [ i ] == ' a ' ) { count_a ++ ; } else { final_score += count_a ; } } return final_score ; } static public void Main ( ) { string [ ] S = { " aa " , " bb " , " aab " , " bab " } ; int N = S . Length ; Console . WriteLine ( getMaxScore ( S , N ) - 10 ) ; } }

Index/key variables: i
Accumulator variables: count_a, count_a1, count_a2, count_b1, count_b2, final_score, i, str
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class geeksforgeeks { static int minOperations ( int [ ] ar , int k ) { Array . Sort ( ar ) ; int opsNeeded = 0 ; for ( int i = 0 ; i < k ; i ++ ) { opsNeeded += ar [ k - 1 ] - ar [ i ] ; } int ans = opsNeeded ; for ( int i = k ; i < ar . Length ; i ++ ) { opsNeeded = opsNeeded - ( ar [ i - 1 ] - ar [ i - k ] ) ; opsNeeded += ( k - 1 ) * ( ar [ i ] - ar [ i - 1 ] ) ; ans = Math . Min ( ans , opsNeeded ) ; } return ans ; } public static void Main ( ) { int [ ] arr = { 3 , 1 , 9 , 100 } ; int n = arr . Length ; int k = 3 ; Console . Write ( minOperations ( arr , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, opsNeeded
Iterator variables: i
Class/struct names: geeksforgeeks
C# program:
using System ; class GFG { static int x = - 1 ; static String [ ] heap = new String [ 1000 ] ; static void heapForm ( String k ) { x ++ ; heap [ x ] = k ; int child = x ; String tmp ; int index = x / 2 ; while ( index >= 0 ) { if ( heap [ index ] . CompareTo ( heap [ child ] ) > 0 ) { tmp = heap [ index ] ; heap [ index ] = heap [ child ] ; heap [ child ] = tmp ; child = index ; index = index / 2 ; } else { break ; } } } static void heapSort ( ) { int left1 , right1 ; while ( x >= 0 ) { String k ; k = heap [ 0 ] ; Console . Write ( k + " ▁ " ) ; heap [ 0 ] = heap [ x ] ; x = x - 1 ; String tmp ; int index = 0 ; int length = x ; left1 = 1 ; right1 = left1 + 1 ; while ( left1 <= length ) { if ( heap [ index ] . CompareTo ( heap [ left1 ] ) <= 0 && heap [ index ] . CompareTo ( heap [ right1 ] ) <= 0 ) { break ; } else { if ( heap [ left1 ] . CompareTo ( heap [ right1 ] ) < 0 ) { tmp = heap [ index ] ; heap [ index ] = heap [ left1 ] ; heap [ left1 ] = tmp ; index = left1 ; } else { tmp = heap [ index ] ; heap [ index ] = heap [ right1 ] ; heap [ right1 ] = tmp ; index = right1 ; } } left1 = 2 * left1 ; right1 = left1 + 1 ; } } } static void sort ( String [ ] k , int n ) { for ( int i = 0 ; i < n ; i ++ ) { heapForm ( k [ i ] ) ; } heapSort ( ) ; } public static void Main ( String [ ] args ) { String [ ] arr = { " banana " , " orange " , " apple " , " pineapple " , " berries " , " lichi " } ; int n = arr . Length ; sort ( arr , n ) ; } }

Index/key variables: child, i, index, left1, right1, x
Accumulator variables: i, x
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getNumber ( int n , int k ) { int [ ] arr = new int [ n ] ; int i = 0 ; int odd = 1 ; while ( odd <= n ) { arr [ i ++ ] = odd ; odd += 2 ; } int even = 2 ; while ( even <= n ) { arr [ i ++ ] = even ; even += 2 ; } return arr [ k - 1 ] ; } public static void Main ( String [ ] args ) { int n = 8 , k = 5 ; Console . WriteLine ( getNumber ( n , k ) ) ; } }

Index/key variables: n
Accumulator variables: even, i, odd
Class/struct names: GFG
C# program:
using System ; class GFG { static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static void UpdateArr ( int [ ] arr , int n ) { int i = 0 , j = n - 1 ; while ( i < j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; i += 2 ; j -= 2 ; } printArr ( arr , n ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n = arr . Length ; UpdateArr ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 20 ; static int [ ] fact = new int [ N ] ; static void pre ( ) { fact [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { fact [ i ] = i * fact [ i - 1 ] ; } } static int CountPermutation ( int [ ] a , int n ) { int ways = 1 ; Array . Sort ( a ) ; int size = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] == a [ i - 1 ] ) { size ++ ; } else { ways *= fact [ size ] ; size = 1 ; } } ways *= fact [ size ] ; return ways ; } static public void Main ( ) { int [ ] a = { 1 , 2 , 4 , 4 , 2 , 4 } ; int n = a . Length ; pre ( ) ; Console . Write ( CountPermutation ( a , n ) ) ; } }

Index/key variables: N, i, size
Accumulator variables: i, size, ways
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int Next_greater ( int [ ] a , int n , int x ) { Array . Sort ( a ) ; int low = 0 , high = n - 1 , ans = x + 1 ; while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( a [ mid ] <= ans ) { if ( a [ mid ] == ans ) { ans ++ ; high = n - 1 ; } low = mid + 1 ; } else high = mid - 1 ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 5 , 10 , 4 , 7 } ; int x = 4 ; int n = a . Length ; Console . WriteLine ( Next_greater ( a , n , x ) ) ; } }

Index/key variables: mid
Accumulator variables: ans
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100000 ; public static void xorOnSortedArray ( int [ ] arr , int n , int k , int x ) { int [ ] arr1 = new int [ MAX + 1 ] ; int [ ] arr2 = new int [ MAX + 1 ] ; int [ ] xor_val = new int [ MAX + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) arr1 [ arr [ i ] ] ++ ; for ( int i = 0 ; i <= MAX ; i ++ ) xor_val [ i ] = i ^ x ; while ( k -- > 0 ) { int count = 0 ; for ( int i = 0 ; i <= MAX ; i ++ ) { int store = arr1 [ i ] ; if ( arr1 [ i ] > 0 ) { if ( count % 2 == 0 ) { int div = ( int ) Math . Ceiling ( ( double ) ( arr1 [ i ] / 2 ) ) ; arr1 [ i ] = arr1 [ i ] - div ; arr2 [ xor_val [ i ] ] += div ; } else if ( count % 2 != 0 ) { int div = arr1 [ i ] / 2 ; arr1 [ i ] = arr1 [ i ] - div ; arr2 [ xor_val [ i ] ] += div ; } } count = count + store ; } for ( int i = 0 ; i <= MAX ; i ++ ) { arr1 [ i ] = arr1 [ i ] + arr2 [ i ] ; arr2 [ i ] = 0 ; } } int min = int . MaxValue ; int max = int . MinValue ; for ( int i = 0 ; i <= MAX ; i ++ ) { if ( arr1 [ i ] > 0 ) { if ( min > i ) min = i ; if ( max < i ) max = i ; } } Console . WriteLine ( min + " ▁ " + max ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 605 , 986 } ; int n = arr . Length ; int k = 548 , x = 569 ; xorOnSortedArray ( arr , n , k , x ) ; } }

Index/key variables: i
Accumulator variables: i, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printArrangement ( int [ ] a , int n ) { Array . Sort ( a ) ; int [ ] b = new int [ n ] ; int low = 0 , high = n - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) b [ low ++ ] = a [ i ] ; else b [ high -- ] = a [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) { if ( b [ n - 1 ] + b [ 1 ] <= b [ i ] ) { Console . Write ( - 1 ) ; return ; } } else if ( i == ( n - 1 ) ) { if ( b [ n - 2 ] + b [ 0 ] <= b [ i ] ) { Console . Write ( - 1 ) ; return ; } } else { if ( b [ i - 1 ] + b [ i + 1 ] <= b [ i ] ) { Console . Write ( - 1 ) ; return ; } } } for ( int i = 0 ; i < n ; i ++ ) Console . Write ( b [ i ] + " ▁ " ) ; } public static void Main ( ) { int [ ] a = { 1 , 4 , 4 , 3 , 2 } ; int n = a . Length ; printArrangement ( a , n ) ; } }

Index/key variables: i, n
Accumulator variables: high, i, low
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; public class GFG { static List < int > findSubarray ( int [ ] a , int k , int n ) { List < List < int > > vec = new List < List < int > > ( ) ; for ( int i = 0 ; i < n - k + 1 ; i ++ ) { List < int > temp = new List < int > ( ) ; for ( int j = i ; j < i + k ; j ++ ) { temp . Add ( a [ j ] ) ; } vec . Add ( temp ) ; } vec . OrderBy ( l => l [ 0 ] ) ; return vec [ vec . Count - 1 ] ; } static public void Main ( ) { int [ ] a = { 1 , 4 , 3 , 2 , 5 } ; int k = 4 ; int n = a . Length ; List < int > ans = findSubarray ( a , k , n ) ; foreach ( int it in ans ) { Console . Write ( it + " ▁ " ) ; } } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, it, j
Class/struct names: GFG
C# program:
using System ; class GFG { static float knapSack ( int W , float [ ] wt , float [ ] val , int n ) { float maxratio = int . MinValue ; int maxindex = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( val [ i ] / wt [ i ] ) > maxratio ) { maxratio = ( val [ i ] / wt [ i ] ) ; maxindex = i ; } } return ( W * maxratio ) ; } public static void Main ( ) { float [ ] val = { 14 , 27 , 44 , 19 } ; float [ ] wt = { 6 , 7 , 9 , 8 } ; int n = val . Length ; int W = 50 ; Console . WriteLine ( knapSack ( W , wt , val , n ) ) ; } }

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

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int solution ( List < int > arr , int x ) { arr . Sort ( ) ; int closestSum = int . MaxValue ; for ( int i = 0 ; i < arr . Count - 2 ; i ++ ) { int ptr1 = i + 1 , ptr2 = arr . Count - 1 ; while ( ptr1 < ptr2 ) { int sum = arr [ i ] + arr [ ptr1 ] + arr [ ptr2 ] ; if ( Math . Abs ( x - sum ) < Math . Abs ( x - closestSum ) ) { closestSum = sum ; } if ( sum > x ) { ptr2 -- ; } else { ptr1 ++ ; } } } return closestSum ; } public static void Main ( String [ ] args ) { int [ ] ar = { - 1 , 2 , 1 , - 4 } ; List < int > arr = new List < int > ( ar ) ; int x = 1 ; Console . WriteLine ( solution ( arr , x ) ) ; } }

Index/key variables: i, ptr1, ptr2
Accumulator variables: i, ptr1, ptr2
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } class GFG { static Node root1 ; static Node root2 ; static void inorder ( Node root ) { if ( root != null ) { inorder ( root . left ) ; Console . WriteLine ( root . data + " ▁ " ) ; inorder ( root . right ) ; } } static void merge ( Node root1 , Node root2 ) { if ( root1 == null && root2 == null ) { return ; } if ( root1 == null ) { inorder ( root2 ) ; return ; } if ( root2 == null ) { inorder ( root1 ) ; return ; } Node temp1 = root1 ; Node prev1 = null ; while ( temp1 . left != null ) { prev1 = temp1 ; temp1 = temp1 . left ; } Node temp2 = root2 ; Node prev2 = null ; while ( temp2 . left != null ) { prev2 = temp2 ; temp2 = temp2 . left ; } if ( temp1 . data <= temp2 . data ) { Console . Write ( temp1 . data + " ▁ " ) ; if ( prev1 == null ) { merge ( root1 . right , root2 ) ; } else { prev1 . left = temp1 . right ; merge ( root1 , root2 ) ; } } else { Console . Write ( temp2 . data + " ▁ " ) ; if ( prev2 == null ) { merge ( root1 , root2 . right ) ; } else { prev2 . left = temp2 . right ; merge ( root1 , root2 ) ; } } } static public void Main ( ) { GFG . root1 = new Node ( 3 ) ; GFG . root1 . left = new Node ( 1 ) ; GFG . root1 . right = new Node ( 5 ) ; GFG . root2 = new Node ( 4 ) ; GFG . root2 . left = new Node ( 2 ) ; GFG . root2 . right = new Node ( 6 ) ; merge ( root1 , root2 ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { static bool IsSorted ( int [ ] A , int [ ] B , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int x , y ; x = Math . Max ( A [ i ] , B [ i ] ) ; y = Math . Min ( A [ i ] , B [ i ] ) ; A [ i ] = x ; B [ i ] = y ; } for ( int i = 1 ; i < n ; i ++ ) { if ( A [ i ] <= A [ i - 1 ] B [ i ] <= B [ i - 1 ] ) return false ; } return true ; } public static void Main ( ) { int [ ] A = { 1 , 4 , 3 , 5 , 7 } ; int [ ] B = { 2 , 2 , 5 , 8 , 9 } ; int n = A . Length ; if ( IsSorted ( A , B , n ) == true ) { Console . Write ( " True " ) ; } else { Console . Write ( " False " ) ; } } }

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 K_multiple ( int [ ] a , int n , int k ) { Array . Sort ( a ) ; HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( a [ i ] % k == 0 && ! s . Contains ( a [ i ] / k ) ) a [ i ] % k != 0 ) s . Add ( a [ i ] ) ; } foreach ( int i in s ) Console . Write ( i + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 3 , 4 , 5 , 6 , 10 } ; int k = 2 ; int n = a . Length ; K_multiple ( a , n , k ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxWater ( int [ ] height , int n ) { int max = 0 ; int i = 0 , j = n - 1 ; while ( i < j ) { if ( height [ i ] < height [ j ] ) { max = Math . Max ( max , ( j - i - 1 ) * height [ i ] ) ; i ++ ; } else if ( height [ j ] < height [ i ] ) { max = Math . Max ( max , ( j - i - 1 ) * height [ j ] ) ; j -- ; } else { max = Math . Max ( max , ( j - i - 1 ) * height [ i ] ) ; i ++ ; j -- ; } } return max ; } static public void Main ( ) { int [ ] height = { 2 , 1 , 3 , 4 , 6 , 5 } ; int n = height . Length ; Console . Write ( maxWater ( height , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSelectionCount ( int [ ] a , int n ) { int res = 0 ; Array . Sort ( a ) ; int select = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] >= select ) { res ++ ; select ++ ; } } return res ; } public static void Main ( ) { int [ ] arr = { 4 , 2 , 1 , 3 , 5 , 1 , 4 } ; int N = arr . Length ; Console . WriteLine ( maxSelectionCount ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, res, select
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findCombinationsUtil ( int [ ] arr , int index , int n , int red_num ) { HashSet < int > s = new HashSet < int > ( ) ; int sum = 0 ; if ( red_num < 0 ) { return ; } if ( red_num == 0 ) { for ( int i = 0 ; i < index ; i ++ ) { s . Add ( arr [ i ] ) ; } foreach ( int itr in s ) { sum = sum + itr ; } if ( sum == n ) { foreach ( int i in s ) { Console . Write ( i + " ▁ " ) ; } Console . WriteLine ( ) ; return ; } } int prev = ( index == 0 ) ? 1 : arr [ index - 1 ] ; for ( int k = prev ; k <= n ; k ++ ) { if ( index < n ) { arr [ index ] = k ; findCombinationsUtil ( arr , index + 1 , n , red_num - k ) ; } } } static void findCombinations ( int n ) { int [ ] a = new int [ n ] ; findCombinationsUtil ( a , 0 , n , n ) ; } public static void Main ( String [ ] arr ) { int n = 7 ; findCombinations ( n ) ; } }

Index/key variables: i, index, n
Accumulator variables: i, k
Iterator variables: i, itr, k
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( int [ ] arr , int n ) { int modify = 0 ; if ( arr [ 0 ] > arr [ 1 ] ) { arr [ 0 ] = arr [ 1 ] / 2 ; modify ++ ; } for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( ( arr [ i - 1 ] < arr [ i ] && arr [ i + 1 ] < arr [ i ] ) || ( arr [ i - 1 ] > arr [ i ] && arr [ i + 1 ] > arr [ i ] ) ) { arr [ i ] = ( arr [ i - 1 ] + arr [ i + 1 ] ) / 2 ; if ( arr [ i ] == arr [ i - 1 ] arr [ i ] == arr [ i + 1 ] ) return false ; modify ++ ; } } if ( arr [ n - 1 ] < arr [ n - 2 ] ) modify ++ ; if ( modify > 1 ) return false ; return true ; } public static void Main ( ) { int [ ] arr = { 2 , 4 , 8 , 6 , 9 , 12 } ; int n = arr . Length ; if ( check ( arr , n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, modify
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 2 ; static int M = 2 ; static Boolean isMatrixInc ( int [ , ] a ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( i - 1 >= 0 ) { if ( a [ i , j ] <= a [ i - 1 , j ] ) return false ; } if ( j - 1 >= 0 ) { if ( a [ i , j ] <= a [ i , j - 1 ] ) return false ; } } } return true ; } public static void Main ( String [ ] args ) { int [ , ] a = { { 2 , 10 } , { 11 , 20 } } ; if ( isMatrixInc ( a ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = 1000005 ; static int [ ] prime = new int [ N ] ; static void seive ( ) { for ( int i = 2 ; i < N ; i ++ ) { if ( prime [ i ] == 0 ) { for ( int j = i + i ; j < N ; j += i ) { prime [ j ] = 1 ; } } } prime [ 1 ] = 1 ; } static int maxSizeArr ( int [ ] arr , int n , int k ) { List < int > v = new List < int > ( ) ; List < int > diff = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ arr [ i ] ] == 1 ) { v . Add ( i ) ; } } for ( int i = 1 ; i < v . Count ; i ++ ) { diff . Add ( v [ i ] - v [ i - 1 ] - 1 ) ; } diff . Sort ( ) ; for ( int i = 1 ; i < diff . Count ; i ++ ) { diff [ i ] = diff [ i ] + diff [ i - 1 ] ; } if ( k > n || ( k == 0 && v . Count > 0 ) ) { return - 1 ; } else if ( v . Count <= k ) { return ( n - k ) ; } else if ( v . Count > k ) { int tt = v . Count - k ; int sum = 0 ; sum += diff [ tt - 1 ] ; int res = n - ( v . Count + sum ) ; return res ; } return 1 ; } public static void Main ( String [ ] args ) { seive ( ) ; int [ ] arr = { 2 , 4 , 2 , 2 , 4 , 2 , 4 , 2 } ; int n = arr . Length ; int k = 2 ; Console . WriteLine ( maxSizeArr ( arr , n , k ) ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static long mod = 1000000007 ; static int fact ( int n ) { int res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } static int nCr ( int n , int r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } static long powmod ( long a , long n ) { if ( n == 0 ) return 1 ; long pt = powmod ( a , n / 2 ) ; pt = ( pt * pt ) % mod ; if ( n % 2 == 1 ) return ( pt * a ) % mod ; else return pt ; } static long CountSubset ( int [ ] arr , int n ) { long ans = powmod ( 2 , n - 1 ) ; Array . Sort ( arr ) ; for ( int i = 0 ; i < n ; ++ i ) { int j = i + 1 ; while ( j < n && arr [ j ] == arr [ i ] ) { int r = n - 1 - j ; int l = i ; ans = ( ans + nCr ( l + r , l ) ) % mod ; j ++ ; } } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 2 } ; int n = arr . Length ; Console . WriteLine ( CountSubset ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long mod = 1000000007 ; static long [ , ] arr = new long [ 1001 , 1001 ] ; static void Preprocess ( ) { arr [ 0 , 0 ] = 1 ; for ( int i = 1 ; i <= 1000 ; ++ i ) { arr [ i , 0 ] = 1 ; for ( int j = 1 ; j < i ; ++ j ) { arr [ i , j ] = ( arr [ i - 1 , j - 1 ] + arr [ i - 1 , j ] ) % mod ; } arr [ i , i ] = 1 ; } } static long powmod ( long a , long n ) { if ( n == 0 ) { return 1 ; } long pt = powmod ( a , n / 2 ) ; pt = ( pt * pt ) % mod ; if ( n % 2 == 1 ) { return ( pt * a ) % mod ; } else { return pt ; } } static long CountSubset ( int [ ] val , int n ) { long ans = powmod ( 2 , n - 1 ) ; Array . Sort ( val ) ; for ( int i = 0 ; i < n ; ++ i ) { int j = i + 1 ; while ( j < n && val [ j ] == val [ i ] ) { int r = n - 1 - j ; int l = i ; ans = ( ans + arr [ l + r , l ] ) % mod ; j ++ ; } } return ans ; } public static void Main ( String [ ] args ) { Preprocess ( ) ; int [ ] val = { 2 , 3 , 2 } ; int n = val . Length ; Console . WriteLine ( CountSubset ( val , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void reArrange ( String [ ] words , int n ) { Dictionary < String , int > freq = new Dictionary < String , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { freq . Add ( words [ i ] , ( i + 1 ) ) ; } Array . Sort ( words ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( freq [ words [ i ] ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { String [ ] words = { " live " , " place " , " travel " , " word " , " sky " } ; int n = words . Length ; reArrange ( words , n ) ; } }

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