dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; public class GFG { private static bool [ ] prime ; private static void sieve ( int n ) { prime = new bool [ n + 1 ] ; for ( int i = 0 ; i < prime . Length ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) prime [ i ] = false ; } } } private static int MinWays ( int [ , ] a , int n , int m ) { int [ ] dp = new int [ 1 << m ] ; for ( int i = 0 ; i < dp . Length ; i ++ ) { dp [ i ] = n + 1 ; } for ( int i = 0 ; i < a . GetLength ( 0 ) ; i ++ ) { int bitmask = BitMask ( GetRow ( a , i ) ) ; for ( int j = ( 1 << m ) - 1 ; j >= 0 ; j -- ) { if ( dp [ j ] != n + 1 ) { dp [ j bitmask ] = Math . Min ( dp [ j bitmask ] , dp [ j ] + 1 ) ; } } dp [ bitmask ] = 1 ; } return ( dp [ ( 1 << m ) - 1 ] - 1 ) == ( n + 1 ) ? - 1 : ( dp [ ( 1 << m ) - 1 ] - 1 ) ; } private static int BitMask ( int [ ] a ) { int bitmask = 0 ; for ( int i = 0 ; i < a . Length ; i ++ ) { if ( prime [ a [ i ] ] ) { bitmask |= ( 1 << i ) ; } } return bitmask ; } public static int [ ] GetRow ( int [ , ] matrix , int row ) { var rowLength = matrix . GetLength ( 1 ) ; var rowVector = new int [ rowLength ] ; for ( var i = 0 ; i < rowLength ; i ++ ) rowVector [ i ] = matrix [ row , i ] ; return rowVector ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 4 , 6 , 5 , 8 } , { 2 , 9 , 12 , 14 } , { 32 , 7 , 18 , 16 } , { 12 , 4 , 35 , 17 } } ; int m = mat . GetLength ( 0 ) ; int n = mat . GetLength ( 1 ) ; int max = 10000 ; sieve ( max ) ; Console . WriteLine ( MinWays ( mat , n , m ) ) ; } }

Index/key variables: bitmask, i, j, p, rowLength
Accumulator variables: bitmask, i, j, p
Iterator variables: i, j, p
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int INF = 10000 ; static void minCost ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int m = 2 * n ; int [ , ] cost = new int [ n + 1 , m + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= m ; j ++ ) { cost [ i , j ] = INF ; } } cost [ 0 , 0 ] = 0 ; int prev = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { prev = cost [ i - 1 , 0 ] ; for ( int j = 1 ; j <= m ; j ++ ) { cost [ i , j ] = Math . Min ( cost [ i , j ] , prev + Math . Abs ( j - arr [ i - 1 ] ) ) ; prev = Math . Min ( prev , cost [ i - 1 , j ] ) ; } } int minCost = INF ; for ( int j = 1 ; j <= m ; j ++ ) { minCost = Math . Min ( minCost , cost [ n , j ] ) ; } Console . Write ( minCost ) ; } public static void Main ( ) { int [ ] arr = { 4 , 2 , 4 , 4 , 5 , 2 } ; int N = arr . Length ; minCost ( arr , N ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkbit ( int [ ] array , int index ) { int val = array [ index >> 5 ] & ( 1 << ( index & 31 ) ) ; if ( val == 0 ) return false ; return true ; } static void setbit ( int [ ] array , int index ) { array [ index >> 5 ] |= ( 1 << ( index & 31 ) ) ; } public static void Main ( String [ ] args ) { int a = 2 , b = 10 ; int size = Math . Abs ( b - a ) ; size = ( int ) Math . Ceiling ( ( double ) size / 32 ) ; int [ ] array = new int [ size ] ; for ( int i = a ; i <= b ; i ++ ) if ( i % 2 == 0 i % 5 == 0 ) setbit ( array , i - a ) ; Console . WriteLine ( " MULTIPLES ▁ of ▁ 2 ▁ and ▁ 5 : " ) ; for ( int i = a ; i <= b ; i ++ ) if ( checkbit ( array , i - a ) ) Console . Write ( i + " ▁ " ) ; } }

Index/key variables: size
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] arr1 = new int [ ] { 0 , 1 , 0 , 1 , 1 , 1 , 1 } ; static int [ ] arr2 = new int [ ] { 1 , 1 , 1 , 1 , 1 , 0 , 1 } ; static int longestCommonSum ( int n ) { int maxLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int sum1 = 0 , sum2 = 0 ; for ( int j = i ; j < n ; j ++ ) { sum1 += arr1 [ j ] ; sum2 += arr2 [ j ] ; if ( sum1 == sum2 ) { int len = j - i + 1 ; if ( len > maxLen ) maxLen = len ; } } } return maxLen ; } public static void Main ( ) { Console . Write ( " Length ▁ of ▁ the ▁ longest ▁ " + " common ▁ span ▁ with ▁ same ▁ sum ▁ is ▁ " ) ; Console . Write ( longestCommonSum ( arr1 . Length ) ) ; } }

Index/key variables: j
Accumulator variables: i, j, sum1, sum2
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findNumberOfLIS ( int [ ] nums ) { if ( nums . Length == 0 ) return 0 ; int n = nums . Length ; int [ ] dp_l = new int [ n ] ; Array . Fill ( dp_l , 1 ) ; int [ ] dp_c = new int [ n ] ; Array . Fill ( dp_c , 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( nums [ i ] <= nums [ j ] ) continue ; if ( dp_l [ j ] + 1 > dp_l [ i ] ) { dp_l [ i ] = dp_l [ j ] + 1 ; dp_c [ i ] = dp_c [ j ] ; } else if ( dp_l [ j ] + 1 == dp_l [ i ] ) dp_c [ i ] += dp_c [ j ] ; } } int max_length = 0 ; foreach ( int i in dp_l ) max_length = Math . Max ( i , max_length ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( dp_l [ i ] == max_length ) count += dp_c [ i ] ; } return count ; } static void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 4 , 7 } ; Console . WriteLine ( findNumberOfLIS ( arr ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int [ , , ] dp ; static int [ ] KMPArray ; static int m ; private static int findSubsequence ( int [ ] a , int [ ] sequence , int i , int prev , int k ) { if ( k == m ) return int . MinValue ; if ( i == a . Length ) return 0 ; if ( prev != - 1 && dp [ i , prev , k ] != - 1 ) { return dp [ i , prev , k ] ; } int include = 0 ; if ( prev == - 1 a [ i ] >= a [ prev ] ) { int k2 = k ; while ( k2 > 0 && a [ i ] != sequence [ k2 ] ) k2 = KMPArray [ k2 - 1 ] ; if ( a [ i ] == sequence [ k2 ] ) k2 ++ ; include = 1 + findSubsequence ( a , sequence , i + 1 , i , k2 ) ; } int ans = Math . Max ( include , findSubsequence ( a , sequence , i + 1 , prev , k ) ) ; if ( prev != - 1 ) { dp [ i , prev , k ] = ans ; } return ans ; } private static void fillKMPArray ( int [ ] pattern ) { int j = 0 ; int i = 1 ; KMPArray [ 0 ] = 0 ; while ( i < m ) { if ( pattern [ i ] == pattern [ j ] ) { j ++ ; KMPArray [ i ] = j ; i ++ ; } else { if ( j != 0 ) j = KMPArray [ j - 1 ] ; else { KMPArray [ i ] = j ; i ++ ; } } } } static void printAnswer ( int [ ] a , int [ ] sequence ) { m = sequence . Length ; KMPArray = new int [ m ] ; fillKMPArray ( sequence ) ; dp = new int [ a . Length , a . Length , a . Length ] ; for ( int i = 0 ; i < a . Length ; i ++ ) for ( int j = 0 ; j < a . Length ; j ++ ) for ( int k = 0 ; k < a . Length ; k ++ ) dp [ i , j , k ] = - 1 ; int ans = findSubsequence ( a , sequence , 0 , - 1 , 0 ) ; Console . WriteLine ( ( ans < 0 ) ? 0 : ans ) ; } public static void Main ( ) { int [ ] arr = { 5 , 3 , 9 , 3 , 4 , 7 } ; int [ ] arr1 = { 3 , 4 } ; printAnswer ( arr , arr1 ) ; } }

Index/key variables: i, j, k2, m, prev
Accumulator variables: i, j, k, k2
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public int val ; public Node left , right ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . val = data ; temp . left = null ; temp . right = null ; return temp ; } public static bool checkEvenOddLevel ( Node root ) { if ( root == null ) return true ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; int level = 0 ; while ( q . Count != 0 ) { List < int > list = new List < int > ( ) ; int size = q . Count ; for ( int i = 0 ; i < size ; i ++ ) { Node node = q . Dequeue ( ) ; list . Add ( node . val ) ; if ( node . left != null ) q . Enqueue ( node . left ) ; if ( node . right != null ) q . Enqueue ( node . right ) ; } if ( level % 2 == 0 ) { for ( int i = 0 ; i < list . Count - 1 ; i ++ ) { if ( list [ i + 1 ] > list [ i ] ) continue ; return false ; } } else if ( level % 2 == 1 ) { for ( int i = 0 ; i < list . Count - 1 ; i ++ ) { if ( list [ i + 1 ] < list [ i ] ) continue ; return false ; } } level ++ ; } return true ; } public static void Main ( String [ ] args ) { Node root = null ; root = newNode ( 2 ) ; root . left = newNode ( 6 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 7 ) ; root . right . right = newNode ( 11 ) ; root . left . left . left = newNode ( 10 ) ; root . left . left . right = newNode ( 5 ) ; root . left . right . right = newNode ( 1 ) ; if ( checkEvenOddLevel ( root ) ) { Console . WriteLine ( " YES " ) ; } else { Console . WriteLine ( " NO " ) ; } } }

Index/key variables: i
Accumulator variables: i, level
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int longestCommonSum ( int [ ] arr1 , int [ ] arr2 , int n ) { int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = arr1 [ i ] - arr2 [ i ] ; Dictionary < int , int > hM = new Dictionary < int , int > ( ) ; int sum = 0 ; int max_len = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( sum == 0 ) max_len = i + 1 ; if ( hM . ContainsKey ( sum ) ) max_len = Math . Max ( max_len , i - hM [ sum ] ) ; else hM [ sum ] = i ; } return max_len ; } static public void Main ( ) { int [ ] arr1 = { 0 , 1 , 0 , 1 , 1 , 1 , 1 } ; int [ ] arr2 = { 1 , 1 , 1 , 1 , 1 , 0 , 1 } ; int n = arr1 . Length ; Console . WriteLine ( longestCommonSum ( arr1 , arr2 , n ) ) ; } }

Index/key variables: i, n, sum
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxN = 20 ; static int [ , , , ] dp = new int [ maxN , maxN , 27 , maxN ] ; public static int solve ( String s , int n , int idx , int k , char last , int count ) { if ( k < 0 ) return n + 1 ; if ( idx == n ) return 0 ; int ans = dp [ idx , k , last - ' a ' , count ] ; if ( ans != - 1 ) return ans ; ans = n + 1 ; ans = Math . Min ( ans , solve ( s , n , idx + 1 , k - 1 , last , count ) ) ; int inc = 0 ; if ( count == 1 count == 9 count == 99 ) inc = 1 ; if ( last == s [ idx ] ) { ans = Math . Min ( ans , inc + solve ( s , n , idx + 1 , k , s [ idx ] , count + 1 ) ) ; } else { ans = Math . Min ( ans , 1 + solve ( s , n , idx + 1 , k , s [ idx ] , 1 ) ) ; } return dp [ idx , k , last - ' a ' , count ] = ans ; } public static int MinRunLengthEncoding ( String s , int n , int k ) { for ( int i = 0 ; i < maxN ; i ++ ) for ( int j = 0 ; j < maxN ; j ++ ) for ( int p = 0 ; p < 27 ; p ++ ) for ( int l = 0 ; l < maxN ; l ++ ) dp [ i , j , p , l ] = - 1 ; return solve ( s , n , 0 , k , ( char ) 123 , 0 ) ; } public static void Main ( String [ ] args ) { String S = " abbbcdcdd " ; int N = 9 , K = 2 ; Console . WriteLine ( MinRunLengthEncoding ( S , N , K ) ) ; } }

Index/key variables: idx
Accumulator variables: i, j, l, p
Iterator variables: i, j, l, p
Class/struct names: GFG
C# program:
using System ; class GFG { public static int mElementsWithMaxSum ( int [ , ] matrix , int M , int block , int [ , ] dp ) { if ( block == matrix . GetLength ( 0 ) ) return 0 ; if ( dp [ block , M ] != - 1 ) return dp [ block , M ] ; int ans = mElementsWithMaxSum ( matrix , M , block + 1 , dp ) ; for ( int i = 0 ; i < GetRow ( matrix , block ) . Length ; i ++ ) { for ( int j = i ; j < GetRow ( matrix , block ) . Length ; j ++ ) { if ( j - i + 1 <= M ) { ans = Math . Max ( ans , matrix [ block , j ] - ( ( i - 1 ) >= 0 ? matrix [ block , i - 1 ] : 0 ) + mElementsWithMaxSum ( matrix , M - j + i - 1 , block + 1 , dp ) ) ; } } } return dp [ block , M ] = ans ; } public static void preComputing ( int [ , ] matrix , int N ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < GetRow ( matrix , i ) . Length ; j ++ ) { matrix [ i , j ] = ( j > 0 ? matrix [ i , j - 1 ] : 0 ) + matrix [ i , j ] ; } } } public static void mElementsWithMaxSumUtil ( int [ , ] matrix , int M , int N ) { preComputing ( matrix , N ) ; int [ , ] dp = new int [ N + 5 , M + 5 ] ; for ( int i = 0 ; i < N + 5 ; i ++ ) { for ( int j = 0 ; j < M + 5 ; j ++ ) { dp [ i , j ] = - 1 ; } } int sum = mElementsWithMaxSum ( matrix , M , 0 , dp ) ; Console . Write ( sum ) ; } public static int [ ] GetRow ( int [ , ] matrix , int row ) { var rowLength = matrix . GetLength ( 1 ) ; var rowVector = new int [ rowLength ] ; for ( var i = 0 ; i < rowLength ; i ++ ) rowVector [ i ] = matrix [ row , i ] ; return rowVector ; } public static void Main ( String [ ] args ) { int N = 3 ; int M = 4 ; int [ , ] matrix = { { 2 , 3 , 5 } , { - 1 , 7 , 0 } , { 8 , 10 , 0 } } ; mElementsWithMaxSumUtil ( matrix , M , N ) ; } }

Index/key variables: i, rowLength
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int lastRemaining ( int n , Dictionary < int , int > dp ) { if ( dp . ContainsKey ( n ) ) return dp [ n ] ; if ( n == 1 ) return 1 ; else dp . Add ( n , 2 * ( 1 + n / 2 - lastRemaining ( n / 2 , dp ) ) ) ; return dp [ n ] ; } public static void Main ( String [ ] args ) { int N = 5 ; Dictionary < int , int > dp = new Dictionary < int , int > ( ) ; Console . Write ( lastRemaining ( N , dp ) ) ; } }

Index/key variables: n
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , ] dp = new int [ 1005 , 1005 ] ; static int maximumSumUtil ( int [ ] a , int index , int count , int n ) { if ( index > n count > n + 1 ) { return 0 ; } if ( dp [ index , count ] != - 1 ) return dp [ index , count ] ; int ans1 = maximumSumUtil ( a , index + 1 , count + 1 , n ) + a [ index ] * count ; int ans2 = maximumSumUtil ( a , index + 1 , count , n ) ; return ( dp [ index , count ] = Math . Max ( ans1 , ans2 ) ) ; } static void maximumSum ( int [ ] arr , int N ) { for ( int i = 0 ; i < 1005 ; i ++ ) { for ( int j = 0 ; j < 1005 ; j ++ ) { dp [ i , j ] = - 1 ; } } Console . Write ( maximumSumUtil ( arr , 0 , 1 , N - 1 ) ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { - 1 , 2 , - 10 , 4 , - 20 } ; int N = arr . Length ; maximumSum ( arr , N ) ; } }

Index/key variables: index
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static void rearrange ( int [ ] arr , int n , int x ) { SortedDictionary < int , List < int > > m = new SortedDictionary < int , List < int > > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int diff = Math . Abs ( x - arr [ i ] ) ; if ( m . ContainsKey ( diff ) ) { List < int > al = m ; al . Add ( arr [ i ] ) ; m = al ; } else { List < int > al = new List < int > ( ) ; al . Add ( arr [ i ] ) ; m . Add ( diff , al ) ; } } int index = 0 ; foreach ( int entry in m . Keys ) { List < int > al = m [ entry ] ; for ( int i = 0 ; i < al . Count ; i ++ ) arr [ index ++ ] = al [ i ] ; } } static void printArray ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static public void Main ( ) { int [ ] arr = { 10 , 5 , 3 , 9 , 2 } ; int n = arr . Length ; int x = 7 ; rearrange ( arr , n , x ) ; printArray ( arr , n ) ; } }

Index/key variables: entry, i
Accumulator variables: i, index
Iterator variables: entry, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > find_sequence ( int n ) { List < int > temp = new List < int > ( ) ; temp . Add ( 1 ) ; temp . Add ( - 1 ) ; if ( n == 1 ) return temp ; List < int > arr = find_sequence ( n - 1 ) ; List < int > ans = new List < int > ( n ) ; ans . Add ( arr [ 0 ] + 1 ) ; ans . Add ( n - 1 ) ; if ( n % 2 == 0 ) { List < int > div_by_2 = find_sequence ( n / 2 ) ; if ( div_by_2 [ 0 ] < ans [ 0 ] ) { ans . Clear ( ) ; ans . Add ( div_by_2 [ 0 ] + 1 ) ; ans . Add ( n / 2 ) ; } } if ( n % 3 == 0 ) { List < int > div_by_3 = find_sequence ( n / 3 ) ; if ( div_by_3 [ 0 ] < ans [ 0 ] ) { ans . Clear ( ) ; ans . Add ( div_by_3 [ 0 ] + 1 ) ; ans . Add ( n / 3 ) ; } } return ans ; } static List < int > find_solution ( int n ) { List < int > a = find_sequence ( n ) ; Console . WriteLine ( a [ 0 ] ) ; List < int > sequence = new List < int > ( ) ; sequence . Add ( n ) ; while ( a [ 1 ] != - 1 ) { sequence . Add ( a [ 1 ] ) ; List < int > arr = find_sequence ( a [ 1 ] ) ; a . Insert ( 1 , arr [ 1 ] ) ; } sequence . Reverse ( ) ; return sequence ; } public static void Main ( String [ ] args ) { int n = 5 ; List < int > res = find_solution ( n ) ; for ( int i = 0 ; i < res . Count ; i ++ ) { Console . Write ( res [ i ] + " ▁ " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int n , t ; public static int FindNoOfFullVessels ( int n , int t ) { double [ , ] Matrix = new double [ n , n ] ; Matrix [ 0 , 0 ] = t * 1.0 ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) { double exceededwater = Matrix [ i , j ] - 1.0 ; if ( exceededwater < 0 ) continue ; ans ++ ; if ( i + 1 < n ) Matrix [ i + 1 , j ] += exceededwater / 2 ; if ( i + 1 < n && j + 1 < n ) Matrix [ i + 1 , j + 1 ] += exceededwater / 2 ; } } return ans ; } public static void Main ( ) { int N = 3 ; int T = 4 ; Console . WriteLine ( FindNoOfFullVessels ( N , T ) ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class SortWave { void swap ( int [ ] arr , int a , int b ) { int temp = arr [ a ] ; arr [ a ] = arr [ b ] ; arr [ b ] = temp ; } void sortInWave ( int [ ] arr , int n ) { Array . Sort ( arr ) ; for ( int i = 0 ; i < n - 1 ; i += 2 ) swap ( arr , i , i + 1 ) ; } public static void Main ( ) { SortWave ob = new SortWave ( ) ; int [ ] arr = { 10 , 90 , 49 , 2 , 1 , 5 , 23 } ; int n = arr . Length ; ob . sortInWave ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: a, b, i
Accumulator variables: i
Iterator variables: i
Class/struct names: SortWave
C# program:
using System ; class GFG { static int findMaxTimes ( String S ) { int [ ] arr = new int [ 26 ] ; int [ , ] dp = new int [ 26 , 26 ] ; for ( int i = 0 ; i < S . Length ; i ++ ) { int now = S [ i ] - ' a ' ; for ( int j = 0 ; j < 26 ; j ++ ) { dp [ j , now ] += arr [ j ] ; } arr [ now ] ++ ; } int ans = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) ans = Math . Max ( ans , arr [ i ] ) ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) { ans = Math . Max ( ans , dp [ i , j ] ) ; } } return ans ; } public static void Main ( String [ ] args ) { String S = " ddee " ; Console . Write ( findMaxTimes ( S ) ) ; } }

Index/key variables: i, j, now
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class SortWave { void swap ( int [ ] arr , int a , int b ) { int temp = arr [ a ] ; arr [ a ] = arr [ b ] ; arr [ b ] = temp ; } void sortInWave ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i += 2 ) { if ( i > 0 && arr [ i - 1 ] > arr [ i ] ) swap ( arr , i - 1 , i ) ; if ( i < n - 1 && arr [ i ] < arr [ i + 1 ] ) swap ( arr , i , i + 1 ) ; } } public static void Main ( ) { SortWave ob = new SortWave ( ) ; int [ ] arr = { 10 , 90 , 49 , 2 , 1 , 5 , 23 } ; int n = arr . Length ; ob . sortInWave ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } }

Index/key variables: a, b, i
Accumulator variables: i
Iterator variables: i
Class/struct names: SortWave
C# program:
using System ; public class Node { public int data ; public Node left ; public Node right ; public Node ( int data ) { this . data = data ; left = null ; right = null ; } } public virtual void print ( Node root ) { if ( root == null ) { return ; } print ( root . left ) ; Console . Write ( root . data + " ▁ " ) ; print ( root . right ) ; } } public class BinaryTree { public Node root ; public virtual Node prune ( Node root , int sum ) { if ( root == null ) { return null ; } root . left = prune ( root . left , sum - root . data ) ; root . right = prune ( root . right , sum - root . data ) ; if ( isLeaf ( root ) ) { if ( sum > root . data ) { root = null ; } } return root ; } public virtual bool isLeaf ( Node root ) { if ( root == null ) { return false ; } if ( root . left == null && root . right == null ) { return true ; } return false ; } public class GFG { public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . left = new Node ( 6 ) ; tree . root . right . right = new Node ( 7 ) ; tree . root . left . left . left = new Node ( 8 ) ; tree . root . left . left . right = new Node ( 9 ) ; tree . root . left . right . left = new Node ( 12 ) ; tree . root . right . right . left = new Node ( 10 ) ; tree . root . right . right . left . right = new Node ( 11 ) ; tree . root . left . left . right . left = new Node ( 13 ) ; tree . root . left . left . right . right = new Node ( 14 ) ; tree . root . left . left . right . right . left = new Node ( 15 ) ; Console . WriteLine ( " Tree ▁ before ▁ truncation " ) ; tree . print ( tree . root ) ; tree . prune ( tree . root , 45 ) ; Console . WriteLine ( " STRNEWLINE Tree ▁ after ▁ truncation " ) ; tree . print ( tree . root ) ; } }

Class/struct names: BinaryTree, GFG, Node
C# program:
using System ; class GFG { static int count_unique_sum ( int n ) { int i ; int [ ] ar = new int [ n + 1 ] ; int [ ] fsum = new int [ n + 1 ] ; int [ ] rsum = new int [ n + 1 ] ; int ans = 1 ; for ( i = 0 ; i <= n ; i ++ ) { ar [ i ] = i ; } fsum [ 0 ] = ar [ 0 ] ; rsum [ n ] = ar [ n ] ; for ( i = 1 ; i <= n ; i ++ ) { fsum [ i ] = ar [ i ] + fsum [ i - 1 ] ; } for ( i = n - 1 ; i >= 0 ; i -- ) { rsum [ i ] = ar [ i ] + rsum [ i + 1 ] ; } for ( int k = 2 ; k <= n ; k ++ ) { ans += 1 + rsum [ n + 1 - k ] - fsum [ k - 1 ] ; } return ans ; } public static void Main ( String [ ] args ) { int N = 4 ; Console . Write ( count_unique_sum ( N ) ) ; } }

Index/key variables: i, n
Accumulator variables: ans, i, k
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { public virtual void moveToEnd ( int [ ] mPlusN , int size ) { int i , j = size - 1 ; for ( i = size - 1 ; i >= 0 ; i -- ) { if ( mPlusN [ i ] != - 1 ) { mPlusN [ j ] = mPlusN [ i ] ; j -- ; } } } public virtual void merge ( int [ ] mPlusN , int [ ] N , int m , int n ) { int i = n ; int j = 0 ; int k = 0 ; while ( k < ( m + n ) ) { if ( ( j == n ) ( i < ( m + n ) && mPlusN [ i ] <= N [ j ] ) ) { mPlusN [ k ] = mPlusN [ i ] ; k ++ ; i ++ ; } else { mPlusN [ k ] = N [ j ] ; k ++ ; j ++ ; } } } public virtual void printArray ( int [ ] arr , int size ) { int i ; for ( i = 0 ; i < size ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } Console . WriteLine ( " " ) ; } public static void Main ( string [ ] args ) { GFG mergearray = new GFG ( ) ; int [ ] mPlusN = new int [ ] { 2 , 8 , - 1 , - 1 , - 1 , 13 , - 1 , 15 , 20 } ; int [ ] N = new int [ ] { 5 , 7 , 9 , 25 } ; int n = N . Length ; int m = mPlusN . Length - n ; mergearray . moveToEnd ( mPlusN , m + n ) ; mergearray . merge ( mPlusN , N , m , n ) ; mergearray . printArray ( mPlusN , m + n ) ; } }

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