dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int longestsubarray ( int [ ] a , int N ) { int maxlength = 0 , sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( a [ i ] == 1 ) { sum ++ ; } else { sum = 0 ; } maxlength = Math . Max ( maxlength , sum ) ; } return maxlength ; } static void solveQueries ( int [ ] arr , int n , List < List < int > > Q , int k ) { int cntQuery = Q . Count ; for ( int i = 0 ; i < cntQuery ; i ++ ) { if ( Q [ i ] [ 0 ] == 1 ) { Console . Write ( longestsubarray ( arr , n ) + " ▁ " ) ; } else { arr [ Q [ i ] [ 1 ] - 1 ] ^= 1 ; } } } static void Main ( ) { int N = 10 ; int [ ] arr = { 1 , 1 , 0 , 1 , 1 , 1 , 0 , 0 , 1 , 1 } ; List < List < int > > Q = new List < List < int > > ( ) ; Q . Add ( new List < int > { 1 } ) ; Q . Add ( new List < int > { 2 , 3 } ) ; Q . Add ( new List < int > { 1 } ) ; int K = 3 ; solveQueries ( arr , N , Q , K ) ; } }

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 void uniqueElements ( int [ ] arr , int start , int K , Dictionary < int , int > mp ) { HashSet < int > st = new HashSet < int > ( ) ; for ( int i = 0 ; i < K ; i ++ ) st . Add ( arr [ start + i ] ) ; foreach ( int itr in st ) { if ( mp . ContainsKey ( itr ) ) { mp [ itr ] ++ ; } else { mp [ itr ] = 1 ; } } } static void checkAnswer ( Dictionary < int , int > mp , int N , int K ) { for ( int i = 1 ; i <= N ; i ++ ) { if ( mp . ContainsKey ( i ) ) if ( mp [ i ] == ( N - K + 1 ) ) { Console . Write ( i + " ▁ " ) ; return ; } } Console . Write ( - 1 + " ▁ " ) ; } static void smallestPresentNumber ( int [ ] arr , int N , int K ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i <= N - K ; i ++ ) { uniqueElements ( arr , i , K , mp ) ; } checkAnswer ( mp , N , K ) ; } static void generateK ( int [ ] arr , int N ) { for ( int k = 1 ; k <= N ; k ++ ) smallestPresentNumber ( arr , N , k ) ; } static void Main ( ) { int [ ] arr = { 2 , 3 , 5 , 3 , 2 , 3 , 1 , 3 , 2 , 7 } ; int N = arr . Length ; generateK ( arr , N ) ; } }

Index/key variables: i, itr
Accumulator variables: i, k
Iterator variables: i, itr, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public int data ; public Node left , right ; } ; static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } static Node getDeepestRightLeafNode ( Node root ) { if ( root == null ) return null ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; Node result = null ; while ( q . Count != 0 ) { Node temp = q . Peek ( ) ; q . Dequeue ( ) ; if ( temp . left != null ) { q . Enqueue ( temp . left ) ; } if ( temp . right != null ) { q . Enqueue ( temp . right ) ; if ( temp . right . left == null && temp . right . right == null ) result = temp . right ; } } return result ; } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . right = newNode ( 4 ) ; root . right . left = newNode ( 5 ) ; root . right . right = newNode ( 6 ) ; root . right . left . right = newNode ( 7 ) ; root . right . right . right = newNode ( 8 ) ; root . right . left . right . left = newNode ( 9 ) ; root . right . right . right . right = newNode ( 10 ) ; Node result = getDeepestRightLeafNode ( root ) ; if ( result != null ) Console . WriteLine ( " Deepest ▁ Right ▁ Leaf ▁ Node ▁ : : ▁ " + result . data ) ; else Console . WriteLine ( " No ▁ result , ▁ right ▁ leaf ▁ not ▁ found STRNEWLINE " ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { static void checkString ( String X , String Y ) { int L = - 1 ; int R = - 1 ; for ( int i = 0 ; i < X . Length ; ++ i ) { if ( X [ i ] != Y [ i ] ) { L = i ; break ; } } for ( int i = X . Length - 1 ; i > 0 ; -- i ) { if ( X [ i ] != Y [ i ] ) { R = i ; break ; } } X = X . Substring ( 0 , L ) + reverse ( X . Substring ( L , R + 1 - L ) ) + X . Substring ( R + 1 ) ; if ( X . Equals ( Y ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } static String reverse ( String input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = a . Length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . Join ( " " , a ) ; } public static void Main ( String [ ] args ) { String X = " adcbef " , Y = " abcdef " ; checkString ( X , Y ) ; } }

Index/key variables: i, l, r
Accumulator variables: l, r
Iterator variables: i, l
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] seg ; static int maxLength ( int [ ] a , int [ ] b , int n , int c ) { if ( n == 0 ) return 0 ; int max_length = 0 ; int low = 0 , high = n ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( possible ( a , b , n , c , mid ) ) { max_length = mid ; low = mid + 1 ; } else high = mid - 1 ; } return max_length ; } static bool possible ( int [ ] a , int [ ] b , int n , int c , int k ) { int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { sum += a [ i ] ; } int total_cost = sum * k + getMax ( b , 0 , n - 1 , 0 , k - 1 , 0 ) ; if ( total_cost <= c ) return true ; for ( int i = k ; i < n ; i ++ ) { sum += a [ i ] ; sum -= a [ i - k ] ; total_cost = sum * k + getMax ( b , 0 , n - 1 , i - k + 1 , i , 0 ) ; if ( total_cost <= c ) return true ; } return false ; } static void build ( int [ ] b , int index , int s , int e ) { if ( s == e ) { seg [ index ] = b [ s ] ; return ; } int mid = s + ( e - s ) / 2 ; build ( b , 2 * index + 1 , s , mid ) ; build ( b , 2 * index + 2 , mid + 1 , e ) ; seg [ index ] = Math . Max ( seg [ 2 * index + 1 ] , seg [ 2 * index + 2 ] ) ; } public static int getMax ( int [ ] b , int ss , int se , int qs , int qe , int index ) { if ( se < qs ss > qe ) return Int32 . MinValue / 2 ; if ( ss >= qs && se <= qe ) return seg [ index ] ; int mid = ss + ( se - ss ) / 2 ; return Math . Max ( getMax ( b , ss , mid , qs , qe , 2 * index + 1 ) , getMax ( b , mid + 1 , se , qs , qe , 2 * index + 2 ) ) ; } static void initialiseSegmentTree ( int N ) { seg = new int [ 4 * N ] ; } static void Main ( ) { int [ ] A = { 1 , 2 , 1 , 6 , 5 , 5 , 6 , 1 } ; int [ ] B = { 14 , 8 , 15 , 15 , 9 , 10 , 7 , 12 } ; int C = 40 ; int N = A . Length ; initialiseSegmentTree ( N ) ; build ( B , 0 , 0 , N - 1 ) ; Console . WriteLine ( maxLength ( A , B , N , C ) ) ; } }

Index/key variables: i, index, s
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static int maxLength ( int [ ] a , int [ ] b , int n , int c ) { if ( n == 0 ) return 0 ; int max_length = 0 ; int low = 0 , high = n ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( possible ( a , b , n , c , mid ) ) { max_length = mid ; low = mid + 1 ; } else high = mid - 1 ; } return max_length ; } public static bool possible ( int [ ] a , int [ ] b , int n , int c , int k ) { List < int > dq = new List < int > ( ) ; int sum = 0 ; for ( int i = 0 ; i < k ; i ++ ) { sum += a [ i ] ; while ( dq . Count > 0 && b [ i ] > b [ dq [ dq . Count - 1 ] ] ) dq . RemoveAt ( dq . Count - 1 ) ; dq . Add ( i ) ; } int total_cost = sum * k + b [ dq [ 0 ] ] ; if ( total_cost <= c ) return true ; for ( int i = k ; i < n ; i ++ ) { sum += a [ i ] ; sum -= a [ i - k ] ; while ( dq . Count > 0 && dq [ 0 ] <= i - k ) dq . RemoveAt ( 0 ) ; while ( dq . Count > 0 && b [ i ] > b [ dq [ dq . Count - 1 ] ] ) dq . RemoveAt ( dq . Count - 1 ) ; dq . Add ( i ) ; total_cost = sum * k + b [ dq [ 0 ] ] ; if ( total_cost <= c ) return true ; } return false ; } public static void Main ( String [ ] args ) { int [ ] A = { 1 , 2 , 1 , 6 , 5 , 5 , 6 , 1 } ; int [ ] B = { 14 , 8 , 15 , 15 , 9 , 10 , 7 , 12 } ; int N = A . Length ; int C = 40 ; Console . WriteLine ( maxLength ( A , B , N , C ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findNthNum ( int N ) { left = 1 ; right = N ; while ( left <= right ) { mid = left + ( right - left ) / 2 ; t = ( mid * ( mid + 1 ) ) / 2 ; if ( t < N ) { left = mid + 1 ; } else if ( t == N ) { a = mid ; break ; } else { a = mid ; right = mid - 1 ; } } t = a - 1 ; b = N - ( t * ( t + 1 ) ) / 2 - 1 ; Console . Write ( ( 1 << a ) + ( 1 << b ) ) ; } public static void Main ( ) { int N = 15 ; findNthNum ( N ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void longestSubWithMaxSum ( int [ ] arr , int N ) { int Max = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { if ( Max < arr [ i ] ) Max = arr [ i ] ; } if ( Max < 0 ) { Console . Write ( Max ) ; return ; } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] >= 0 ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , - 4 , - 2 , 3 , 0 } ; int N = arr . Length ; longestSubWithMaxSum ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int digiSum ( int a ) { int sum = 0 ; while ( a != 0 ) { sum += a % 10 ; a = a / 10 ; } return sum ; } static bool isPrime ( int r ) { bool s = true ; for ( int i = 2 ; i * i <= r ; i ++ ) { if ( r % i == 0 ) { s = false ; break ; } } return s ; } static bool isMorannumber ( int n ) { int dup = n ; int sum = digiSum ( dup ) ; if ( n % sum == 0 ) { int c = n / sum ; if ( isPrime ( c ) ) { return true ; } } return false ; } static void FirstKMorannumber ( int [ ] a , int n , int k ) { int X = k ; Array . Sort ( a ) ; SortedSet < int > s = new SortedSet < int > ( ) ; for ( int i = n - 1 ; i >= 0 && k > 0 ; i -- ) { if ( isMorannumber ( a [ i ] ) ) { s . Add ( a [ i ] ) ; k -- ; } } if ( k > 0 ) { Console . WriteLine ( X + " ▁ Moran ▁ numbers ▁ are " + " ▁ not ▁ present ▁ in ▁ the ▁ array " ) ; return ; } foreach ( var val in s ) { Console . Write ( val + " , ▁ " ) ; } Console . Write ( " STRNEWLINE " ) ; } public static void Main ( ) { int [ ] A = { 34 , 198 , 21 , 42 , 63 , 45 , 22 , 44 , 43 } ; int K = 4 ; int N = A . Length ; FirstKMorannumber ( A , N , K ) ; } }

Index/key variables: i
Accumulator variables: i, k, sum
Iterator variables: i, val
Boolean variables: s
Class/struct names: GFG
C# program:
using System ; using System . Text ; class GFG { static bool isdivisible ( StringBuilder newstr , long K ) { long num = 0 ; for ( int i = 0 ; i < newstr . Length ; i ++ ) { num = num * 10 + newstr [ i ] - '0' ; } if ( num % K == 0 ) return true ; else return false ; } static void findLargestNo ( String str , StringBuilder newstr , StringBuilder ans , int index , long K ) { if ( index == str . Length ) { if ( isdivisible ( newstr , K ) ) { if ( ( newstr . ToString ( ) . CompareTo ( ans . ToString ( ) ) > 0 && ans . Length == newstr . Length ) newstr . Length > ans . Length ) { ans . EnsureCapacity ( 0 ) ; ans . Append ( newstr ) ; } } return ; } StringBuilder x = new StringBuilder ( newstr . ToString ( ) + str [ index ] ) ; findLargestNo ( str , x , ans , index + 1 , K ) ; findLargestNo ( str , newstr , ans , index + 1 , K ) ; } public static void Main ( String [ ] args ) { String str = "121400" ; StringBuilder ans = new StringBuilder ( ) , newstr = new StringBuilder ( ) ; long K = 8 ; findLargestNo ( str , newstr , ans , 0 , K ) ; if ( ans . ToString ( ) != " " ) Console . WriteLine ( ans ) ; else Console . WriteLine ( - 1 ) ; } }

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System . Collections . Generic ; using System ; class GFG { static void findRockSample ( int [ , ] ranges , int n , int r , int [ ] arr ) { List < int > a = new List < int > ( ) ; for ( int i = 0 ; i < r ; i ++ ) { int c = 0 ; int l = ranges [ i , 0 ] ; int h = ranges [ i , 1 ] ; for ( int j = 0 ; j < arr . Length ; j ++ ) { if ( l <= arr [ j ] && arr [ j ] <= h ) c += 1 ; } a . Add ( c ) ; } foreach ( var i in a ) { Console . Write ( i + " ▁ " ) ; } } public static void Main ( ) { int n = 5 ; int r = 2 ; int [ ] arr = { 400 , 567 , 890 , 765 , 987 } ; int [ , ] ranges = { { 300 , 380 } , { 800 , 1000 } } ; findRockSample ( ranges , n , r , arr ) ; } }

Index/key variables: j
Accumulator variables: c, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GfG { class Node { public int key ; public Node left , right ; } static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = null ; temp . right = null ; return ( temp ) ; } static bool isleaf ( Node curr_node ) { return ( curr_node . left == null && curr_node . right == null ) ; } static int deepestOddLevelDepthUtil ( Node curr_node , int curr_level ) { if ( curr_node == null ) return 0 ; curr_level += 1 ; if ( curr_level % 2 != 0 && isleaf ( curr_node ) ) return curr_level ; return Math . Max ( deepestOddLevelDepthUtil ( curr_node . left , curr_level ) , deepestOddLevelDepthUtil ( curr_node . right , curr_level ) ) ; } static int deepestOddLevelDepth ( Node curr_node ) { return deepestOddLevelDepthUtil ( curr_node , 0 ) ; } public static void Main ( String [ ] args ) { Node root = newNode ( 10 ) ; root . left = newNode ( 28 ) ; root . right = newNode ( 13 ) ; root . right . left = newNode ( 14 ) ; root . right . right = newNode ( 15 ) ; root . right . right . left = newNode ( 23 ) ; root . right . right . right = newNode ( 24 ) ; Console . WriteLine ( deepestOddLevelDepth ( root ) ) ; } }

Accumulator variables: curr_level
Class/struct names: GfG, Node
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static void findNumbers ( string st , ArrayList result , int prev , int n , int K ) { if ( st . Length == n ) { result . Add ( Int32 . Parse ( st ) ) ; return ; } if ( st . Length == n - 1 ) { if ( prev - K >= 0 ) { string pt = " " ; pt += ( char ) ( prev - K + 48 ) ; findNumbers ( st + pt , result , prev - K , n , K ) ; } if ( K != 0 && prev + K < 10 ) { string pt = " " ; pt += ( char ) ( prev + K + 48 ) ; findNumbers ( st + pt , result , prev + K , n , K ) ; } } else { for ( int j = 1 ; j <= 9 ; j ++ ) { string pt = " " ; pt += ( char ) ( j + 48 ) ; findNumbers ( st + pt , result , prev , n , K ) ; } } } static ArrayList numDifference ( int N , int K ) { ArrayList res = new ArrayList ( ) ; string st = " " ; if ( N == 1 && K == 0 ) { res . Add ( 0 ) ; } else if ( N == 1 && K > 0 ) { return res ; } for ( int i = 1 ; i < 10 ; i ++ ) { string temp = " " ; temp += ( char ) ( 48 + i ) ; findNumbers ( st + temp , res , i , N , K ) ; st = " " ; } return res ; } static void numDifferenceUtil ( int N , int K ) { ArrayList res = new ArrayList ( ) ; res = numDifference ( N , K ) ; for ( int i = 0 ; i < res . Count ; i ++ ) { Console . Write ( res [ i ] + " ▁ " ) ; } } public static void Main ( string [ ] args ) { int N = 2 , K = 9 ; numDifferenceUtil ( N , K ) ; } }

Index/key variables: i
Accumulator variables: i, j, pt, temp
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Linq ; using System . Collections . Generic ; class GFG { static void countMaximum ( int [ ] a , int n ) { a . OrderByDescending ( c => c ) . ToArray ( ) ; int count = 0 ; int mark = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( ( a [ i ] + n >= mark ) ) { count += 1 ; } mark = Math . Max ( mark , a [ i ] + i + 1 ) ; } Console . Write ( count ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 8 , 9 , 6 } ; int N = arr . Length ; countMaximum ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String reverse ( String input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = a . Length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . Join ( " " , a ) ; } static char findKthChar ( int n , int k ) { String prev = " A " ; String cur = " " ; if ( n == 1 ) { return ' A ' ; } for ( int j = 2 ; j <= n ; j ++ ) { cur = prev + " B " ; for ( int i = 0 ; i < prev . Length ; i ++ ) { if ( prev [ i ] == ' A ' ) { prev . Replace ( prev [ i ] , ' B ' ) ; } else { prev . Replace ( prev [ i ] , ' A ' ) ; } } prev = reverse ( prev ) ; cur += prev ; prev = cur ; } return cur [ k ] ; } public static void Main ( String [ ] args ) { int N = 4 ; int K = 3 ; Console . Write ( findKthChar ( N , K ) ) ; } }

Index/key variables: i, k, l, r
Accumulator variables: cur, i, j, l, r
Iterator variables: i, j, l
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxSubarray ( int [ ] a , int k ) { int n = a . Length ; int answer = 0 ; int start = 0 ; long s = 0 ; Queue < int > dq = new Queue < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int x = a [ i ] ; while ( dq . Count != 0 && a [ dq . Peek ( ) ] <= x ) dq . Dequeue ( ) ; dq . Enqueue ( i ) ; s += x ; long cost = ( long ) a [ dq . Peek ( ) ] * ( answer + 1 ) - s ; if ( cost <= ( long ) k ) answer ++ ; else { if ( dq . Peek ( ) == start ) dq . Dequeue ( ) ; s -= a [ start ++ ] ; } } return answer ; } public static void Main ( String [ ] args ) { int [ ] a = { 2 , 2 , 4 } ; int k = 10 ; Console . WriteLine ( maxSubarray ( a , k ) ) ; } }

Index/key variables: i
Accumulator variables: answer, i, s, start
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 ; } } public class BinaryTree { public Node root ; public virtual int depthOfOddLeafUtil ( Node node , int level ) { if ( node == null ) { return 0 ; } if ( node . left == null && node . right == null && ( level & 1 ) != 0 ) { return level ; } return Math . Max ( depthOfOddLeafUtil ( node . left , level + 1 ) , depthOfOddLeafUtil ( node . right , level + 1 ) ) ; } public virtual int depthOfOddLeaf ( Node node ) { int level = 1 , depth = 0 ; return depthOfOddLeafUtil ( node , level ) ; } public static void Main ( string [ ] args ) { int k = 45 ; 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 . right . left = new Node ( 5 ) ; tree . root . right . right = new Node ( 6 ) ; tree . root . right . left . right = new Node ( 7 ) ; tree . root . right . right . right = new Node ( 8 ) ; tree . root . right . left . right . left = new Node ( 9 ) ; tree . root . right . right . right . right = new Node ( 10 ) ; tree . root . right . right . right . right . left = new Node ( 11 ) ; Console . WriteLine ( tree . depthOfOddLeaf ( tree . root ) + " ▁ is ▁ the ▁ required ▁ depth " ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { static String canSplitArray ( int [ ] arr , int n , int k ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] <= k ) { return " No " ; } } return " Yes " ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 6 , 1 , 8 , 16 } ; int N = arr . Length ; int K = 3 ; Console . WriteLine ( canSplitArray ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int smallSumSubset ( List < int > data , int target , int maxVal ) { int sum = 0 ; foreach ( int i in data ) sum += i ; if ( target <= 0 ) return 0 ; else if ( sum < target ) return maxVal ; else if ( sum == target ) return data . Count ; else if ( data [ 0 ] >= target ) return 1 ; else if ( data [ 0 ] < target ) { List < int > temp = new List < int > ( ) ; for ( int i = 1 ; i < data . Count ; i ++ ) temp . Add ( data [ i ] ) ; return Math . Min ( smallSumSubset ( temp , target , maxVal ) , 1 + smallSumSubset ( temp , target - data [ 0 ] , maxVal ) ) ; } return 0 ; } static void Main ( ) { List < int > data = new List < int > ( ) ; data . Add ( 3 ) ; data . Add ( 1 ) ; data . Add ( 7 ) ; data . Add ( 1 ) ; data . Add ( 2 ) ; int target = 11 ; int val = smallSumSubset ( data , target , data . Count + 1 ) ; if ( val > data . Count ) Console . Write ( - 1 ) ; else Console . Write ( val ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool swapXandY ( char [ ] str , int X , int Y ) { int N = str . Length ; X = X + Y ; Y = X - Y ; X = X - Y ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' p ' ) { str [ i ] = ' r ' ; } else if ( str [ i ] == ' r ' ) { str [ i ] = ' p ' ; } } return true ; } static int maxCost ( String str , int X , int Y ) { int N = str . Length ; if ( Y > X ) { swapXandY ( str . ToCharArray ( ) , X , Y ) ; } int res = 0 ; int countP = 0 ; int countR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' p ' ) { countP ++ ; } else if ( str [ i ] == ' r ' ) { if ( countP > 0 ) { countP -- ; res += X ; } else countR ++ ; } else { res += Math . Min ( countP , countR ) * Y ; countP = 0 ; countR = 0 ; } } res += Math . Min ( countP , countR ) * Y ; return res ; } public static void Main ( String [ ] args ) { String str = " abppprrr " ; int X = 5 , Y = 4 ; Console . Write ( maxCost ( str , X , Y ) ) ; } }

Index/key variables: i
Accumulator variables: countP, countR, i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void uniqueElement ( int [ ] arr ) { int x = arr [ 0 ] ; int flag = 1 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( arr [ i ] != x ) { flag = 0 ; break ; } } if ( flag == 1 ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } static public void Main ( ) { int [ ] arr = { 9 , 9 , 9 , 9 , 9 , 9 , 9 } ; uniqueElement ( arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxCount ( int [ ] freq ) { int n = freq . Length - 1 ; int ans = 0 ; for ( int sum = 2 ; sum <= 2 * n ; ++ sum ) { int possiblePair = 0 ; for ( int firElement = 1 ; firElement < ( sum + 1 ) / 2 ; firElement ++ ) { if ( sum - firElement <= n ) { possiblePair += Math . Min ( freq [ firElement ] , freq [ sum - firElement ] ) ; } } if ( sum % 2 == 0 ) { possiblePair += freq [ sum / 2 ] / 2 ; } ans = Math . Max ( ans , possiblePair ) ; } return ans ; } static int countofPairs ( int [ ] a ) { int n = a . Length ; int [ ] freq = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; ++ i ) freq [ a [ i ] ] ++ ; return maxCount ( freq ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 4 , 3 , 3 , 5 , 6 } ; Console . Write ( countofPairs ( a ) + " STRNEWLINE " ) ; } }

Index/key variables: firElement, i
Accumulator variables: firElement, possiblePair
Iterator variables: firElement, i, sum
Class/struct names: GFG
C# program:
using System ; class GFG { public static int getMaxSum ( int [ ] a , int n ) { int [ , ] dp = new int [ n , 2 ] ; dp [ 0 , 0 ] = a [ 0 ] ; dp [ 0 , 1 ] = a [ 0 ] * a [ 0 ] ; int max_sum = Math . Max ( dp [ 0 , 0 ] , dp [ 0 , 1 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { dp [ i , 0 ] = Math . Max ( a [ i ] , dp [ i - 1 , 0 ] + a [ i ] ) ; dp [ i , 1 ] = Math . Max ( dp [ i - 1 , 1 ] + a [ i ] , a [ i ] * a [ i ] ) ; dp [ i , 1 ] = Math . Max ( dp [ i , 1 ] , dp [ i - 1 , 0 ] + a [ i ] * a [ i ] ) ; max_sum = Math . Max ( max_sum , dp [ i , 1 ] ) ; max_sum = Math . Max ( max_sum , dp [ i , 0 ] ) ; } return max_sum ; } public static void Main ( String [ ] args ) { int n = 5 ; int [ ] a = { 1 , - 5 , 8 , 12 , - 8 } ; Console . WriteLine ( getMaxSum ( a , n ) ) ; } }

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