dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int subArraylen ( int [ ] arr , int n , int K ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; mp . Add ( arr [ 0 ] , 0 ) ; for ( int i = 1 ; i < n ; i ++ ) { arr [ i ] = arr [ i ] + arr [ i - 1 ] ; mp . Add ( arr [ i ] , i ) ; } int len = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < K ) continue ; else { int x = K - arr [ i ] ; if ( x == 0 ) len = Math . Min ( len , i ) ; if ( mp . ContainsValue ( x ) ) continue ; else { len = Math . Min ( len , i ) ; } } } return len ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 3 , 2 , 4 , 1 } ; int n = arr . Length ; int K = 7 ; int len = subArraylen ( arr , n , K ) ; if ( len == int . MaxValue ) { Console . Write ( " - 1" ) ; } else { Console . Write ( len + " STRNEWLINE " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public 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 int maxOddLevelDepth ( Node root ) { if ( root == null ) return 0 ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; int result = int . MaxValue ; int level = 0 ; while ( q . Count != 0 ) { int size = q . Count ; level += 1 ; while ( size > 0 ) { Node temp = q . Peek ( ) ; q . Dequeue ( ) ; if ( temp . left == null && temp . right == null && ( level % 2 != 0 ) ) { result = level ; } if ( temp . left != null ) { q . Enqueue ( temp . left ) ; } if ( temp . right != null ) { q . Enqueue ( temp . right ) ; } size -= 1 ; } } return result ; } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = 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 ) ; root . right . right . right . right . left = newNode ( 11 ) ; int result = maxOddLevelDepth ( root ) ; if ( result == int . MaxValue ) Console . WriteLine ( " No ▁ leaf ▁ node ▁ at ▁ odd ▁ level " ) ; else { Console . Write ( result ) ; Console . WriteLine ( " ▁ is ▁ the ▁ required ▁ depth ▁ " ) ; } } }

Accumulator variables: level, size
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static int [ ] prime = new int [ 100001 ] ; static void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < 100001 ; i ++ ) prime [ i ] = 1 ; int p = 2 ; while ( p * p <= 100000 ) { if ( prime [ p ] == 1 ) { for ( int i = p * p ; i < 100001 ; i += p ) prime [ i ] = 0 ; } p += 1 ; } } static int join ( int a , int b ) { int mul = 1 ; int bb = b ; while ( b != 0 ) { mul *= 10 ; b /= 10 ; } a *= mul ; a += bb ; return a ; } static void fibonacciOfPrime ( int n1 , int n2 ) { SieveOfEratosthenes ( ) ; List < int > initial = new List < int > ( ) ; for ( int i = n1 ; i <= n2 ; i ++ ) if ( prime [ i ] == 1 ) initial . Add ( i ) ; List < int > now = new List < int > ( ) ; for ( int i = 0 ; i < initial . Count ; i ++ ) { for ( int j = 0 ; j < initial . Count ; j ++ ) { int a = initial [ i ] ; int b = initial [ j ] ; if ( a != b ) { int C = join ( a , b ) ; now . Add ( C ) ; } } } List < int > current = new List < int > ( ) ; for ( int i = 0 ; i < now . Count ; i ++ ) if ( prime [ now [ i ] ] == 1 ) current . Add ( now [ i ] ) ; int [ ] cnt = new int [ 1000009 ] ; for ( int i = 0 ; i < 1000001 ; i ++ ) cnt [ i ] = 0 ; List < int > current_set = new List < int > ( ) ; for ( int i = 0 ; i < current . Count ; i ++ ) { cnt [ current [ i ] ] ++ ; if ( cnt [ current [ i ] ] == 1 ) current_set . Add ( current [ i ] ) ; } long first = 1000000000 ; for ( int i = 0 ; i < current_set . Count ; i ++ ) first = Math . Min ( first , current_set [ i ] ) ; long second = 0 ; for ( int i = 0 ; i < current_set . Count ; i ++ ) second = Math . Max ( second , current_set [ i ] ) ; int count = current_set . Count - 1 ; long curr = 1 ; long c = 0 ; while ( curr < count ) { c = first + second ; first = second ; second = c ; curr += 1 ; } Console . WriteLine ( c ) ; } static void Main ( ) { int x = 2 ; int y = 40 ; fibonacciOfPrime ( x , y ) ; } }

Index/key variables: i, j, p
Accumulator variables: a, b, curr, i, j, mul, p
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countElements ( int [ ] arr , int n , int k ) { Stack < int > s = new Stack < int > ( ) ; int [ ] next_greater = new int [ n + 1 ] ; Array . Fill ( next_greater , n ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . Count == 0 ) { s . Push ( i ) ; continue ; } while ( s . Count != 0 && arr [ s . Peek ( ) ] < arr [ i ] ) { next_greater [ s . Peek ( ) ] = i ; s . Pop ( ) ; } s . Push ( i ) ; } int count = 0 ; int maxi = Int32 . MinValue ; for ( int i = 0 ; i < n ; i ++ ) { if ( next_greater [ i ] - i > k && maxi < arr [ i ] ) { maxi = Math . Max ( maxi , arr [ i ] ) ; count ++ ; } } return count ; } static void Main ( ) { int [ ] arr = { 4 , 2 , 3 , 6 , 4 , 3 , 2 } ; int K = 2 ; int n = arr . Length ; Console . Write ( countElements ( arr , n , K ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void maxLengthOf1s ( int [ ] arr , int n ) { int [ ] prefix = new int [ n ] ; for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i - 2 ] == 1 ) prefix [ i ] = prefix [ i - 1 ] + 1 ; else prefix [ i ] = 0 ; } int [ ] suffix = new int [ n ] ; for ( int i = n - 3 ; i >= 0 ; i -- ) { if ( arr [ i + 2 ] == 1 ) suffix [ i ] = suffix [ i + 1 ] + 1 ; else suffix [ i ] = 0 ; } int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { ans = Math . Max ( ans , prefix [ i + 1 ] + suffix [ i ] ) ; } Console . WriteLine ( ans ) ; } static void Main ( ) { int n = 6 ; int [ ] arr = { 1 , 1 , 1 , 0 , 1 , 1 } ; maxLengthOf1s ( arr , n ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minOperations ( String s ) { int n = s . Length ; int pos = - 1 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == '1' ) { pos = i ; break ; } } if ( pos == - 1 ) { return 0 ; } int last = 1 ; int ans = 1 ; for ( int i = pos + 1 ; i < n ; i ++ ) { if ( s [ i ] == '0' ) { if ( last == 1 ) { ans ++ ; last = 0 ; } } else { if ( last == 0 ) { ans ++ ; last = 1 ; } } } return ans ; } public static void Main ( string [ ] args ) { String s = "10111" ; Console . Write ( minOperations ( s ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public class Node { public int data ; public Node left , right ; public Node ( int key ) { data = key ; left = null ; right = null ; } } static int maxLevel = - 1 ; static int res = - 1 ; static void find ( Node root , int level ) { if ( root != null ) { find ( root . left , ++ level ) ; if ( level > maxLevel ) { res = root . data ; maxLevel = level ; } find ( root . right , level ) ; } } static int deepestNode ( Node root ) { int res = - 1 ; int maxLevel = - 1 ; find ( root , 0 ) ; return res ; } public static void Main ( String [ ] args ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . right . left = new Node ( 5 ) ; root . right . right = new Node ( 6 ) ; root . right . left . right = new Node ( 7 ) ; root . right . right . right = new Node ( 8 ) ; root . right . left . right . left = new Node ( 9 ) ; Console . WriteLine ( deepestNode ( root ) ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static void iskPalindromesPossible ( String s , int k ) { if ( s . Length < k ) { Console . Write ( " Not ▁ Possible " + " STRNEWLINE " ) ; return ; } if ( s . Length == k ) { Console . Write ( " Possible " + " STRNEWLINE " ) ; return ; } Dictionary < int , int > freq = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) if ( freq . ContainsKey ( s [ i ] ) ) { freq [ s [ i ] ] = freq [ s [ i ] ] + 1 ; } else { freq . Add ( s [ i ] , 1 ) ; } int count = 0 ; foreach ( KeyValuePair < int , int > it in freq ) { if ( it . Value % 2 == 1 ) count ++ ; } if ( count > k ) Console . Write ( " No " + " STRNEWLINE " ) ; else Console . Write ( " Yes " + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String str = " poor " ; int K = 3 ; iskPalindromesPossible ( str , K ) ; str = " geeksforgeeks " ; K = 10 ; iskPalindromesPossible ( str , K ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { public class Node { public int data ; public Node left , right ; public Node ( int key ) { data = key ; left = null ; right = null ; } } ; static int height ( Node root ) { if ( root == null ) return 0 ; int leftHt = height ( root . left ) ; int rightHt = height ( root . right ) ; return Math . Max ( leftHt , rightHt ) + 1 ; } static void deepestNode ( Node root , int levels ) { if ( root == null ) return ; if ( levels == 1 ) Console . Write ( root . data + " ▁ " ) ; else if ( levels > 1 ) { deepestNode ( root . left , levels - 1 ) ; deepestNode ( root . right , levels - 1 ) ; } } public static void Main ( String [ ] args ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . right . left = new Node ( 5 ) ; root . right . right = new Node ( 6 ) ; root . right . left . right = new Node ( 7 ) ; root . right . right . right = new Node ( 8 ) ; root . right . left . right . left = new Node ( 9 ) ; int levels = height ( root ) ; deepestNode ( root , levels ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int findPivot ( int [ ] arr , int low , int high ) { if ( high < low ) return - 1 ; if ( high == low ) return low ; int mid = ( low + high ) / 2 ; if ( mid < high && arr [ mid + 1 ] < arr [ mid ] ) { return mid ; } if ( mid > low && arr [ mid ] < arr [ mid - 1 ] ) { return mid - 1 ; } if ( arr [ low ] > arr [ mid ] ) { return findPivot ( arr , low , mid - 1 ) ; } else { return findPivot ( arr , mid + 1 , high ) ; } } public static bool isRotated ( int [ ] arr , int n ) { int l = 0 ; int r = n - 1 ; int pivot = - 1 ; if ( arr [ l ] > arr [ r ] ) { pivot = findPivot ( arr , l , r ) ; int temp = pivot ; if ( l < pivot ) { while ( pivot > l ) { if ( arr [ pivot ] < arr [ pivot - 1 ] ) { return false ; } pivot -- ; } } pivot = temp ; else { pivot ++ ; while ( pivot < r ) { if ( arr [ pivot ] > arr [ pivot + 1 ] ) { return false ; } pivot ++ ; } } return true ; } else { return false ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 4 , 5 , 1 , 2 } ; Console . WriteLine ( isRotated ( arr , 5 ) ) ; } }

Index/key variables: l, low, mid, pivot, r
Accumulator variables: pivot
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class Node { public int data ; public Node left , right ; public Node ( int key ) { data = key ; left = null ; right = null ; } } ; class Gfg { public static Node deepestNode ( Node root ) { Node tmp = null ; if ( root == null ) return null ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; while ( q . Count != 0 ) { tmp = q . Peek ( ) ; q . Dequeue ( ) ; if ( tmp . left != null ) q . Enqueue ( tmp . left ) ; if ( tmp . right != null ) q . Enqueue ( tmp . right ) ; } return tmp ; } public static void Main ( String [ ] args ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . right . left = new Node ( 5 ) ; root . right . right = new Node ( 6 ) ; root . right . left . right = new Node ( 7 ) ; root . right . right . right = new Node ( 8 ) ; root . right . left . right . left = new Node ( 9 ) ; Node deepNode = deepestNode ( root ) ; Console . WriteLine ( deepNode . data ) ; } }

Class/struct names: Gfg, Node
C# program:
using System ; class GFG { static void findpair ( int l , int r ) { int ans1 = l ; int ans2 = 2 * l ; Console . WriteLine ( ans1 + " , ▁ " + ans2 ) ; } public static void Main ( ) { int l = 1 , r = 10 ; findpair ( l , r ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public class Student { public string name ; public int marks , prev_rank ; public Student ( ) { this . marks = 0 ; this . prev_rank = 0 ; } } static void nameRank ( string [ ] names , int [ ] marks , int [ ] updates , int n ) { Student [ ] x = new Student [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = new Student ( ) ; x [ i ] . name = names [ i ] ; x [ i ] . marks = marks [ i ] + updates [ i ] ; x [ i ] . prev_rank = i + 1 ; } Student highest = x [ 0 ] ; for ( int j = 1 ; j < n ; j ++ ) { if ( x [ j ] . marks >= highest . marks ) highest = x [ j ] ; } Console . Write ( " Name : ▁ " + highest . name + " , ▁ Jump : ▁ " + Math . Abs ( highest . prev_rank - 1 ) ) ; } public static void Main ( string [ ] args ) { string [ ] names = { " sam " , " ram " , " geek " } ; int [ ] marks = { 80 , 79 , 75 } ; int [ ] updates = { 0 , 5 , - 9 } ; int n = marks . Length ; nameRank ( names , marks , updates , n ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, Student
C# program:
using System ; class GFG { static int countDigits ( int n ) { int count = 0 ; while ( n > 0 ) { count += 1 ; n /= 10 ; } return count ; } static int getDistinct ( int d , int count ) { int num = 0 ; count = ( int ) Math . Pow ( 10 , count - 1 ) ; while ( count > 0 ) { num += ( count * d ) ; count /= 10 ; } return num ; } static int findCount ( int L , int R ) { int count = 0 ; int countDigitsL = countDigits ( L ) ; int countDigitsR = countDigits ( R ) ; int firstDigitL = ( L / ( int ) Math . Pow ( 10 , countDigitsL - 1 ) ) ; int firstDigitR = ( R / ( int ) Math . Pow ( 10 , countDigitsR - 1 ) ) ; if ( countDigitsL < countDigitsR ) { count += ( 9 * ( countDigitsR - countDigitsL - 1 ) ) ; if ( getDistinct ( firstDigitL , countDigitsL ) >= L ) count += ( 9 - firstDigitL + 1 ) ; else count += ( 9 - firstDigitL ) ; if ( getDistinct ( firstDigitR , countDigitsR ) <= R ) count += firstDigitR ; else count += ( firstDigitR - 1 ) ; } else { if ( getDistinct ( firstDigitL , countDigitsL ) >= L ) count += ( 9 - firstDigitL + 1 ) ; else count += ( 9 - firstDigitL ) ; if ( getDistinct ( firstDigitR , countDigitsR ) <= R ) count -= ( 9 - firstDigitR ) ; else count -= ( 9 - firstDigitR + 1 ) ; } return count ; } public static void Main ( ) { int L = 10 , R = 50 ; Console . WriteLine ( findCount ( L , R ) ) ; } }

Accumulator variables: count, n, num
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = 4 ; static int M = 4 ; static Boolean isPairWithDiff ( int [ , ] mat , int k ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( mat [ i , j ] > k ) { int m = mat [ i , j ] - k ; if ( s . Contains ( m ) ) { return true ; } } else { int m = k - mat [ i , j ] ; if ( s . Contains ( m ) ) { return true ; } } s . Add ( mat [ i , j ] ) ; } } return false ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 5 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 100 } } ; int k = 85 ; Console . WriteLine ( isPairWithDiff ( mat , k ) == true ? " YES " : " NO " ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void printNSE ( int [ ] arr , int n ) { Stack < int > s = new Stack < int > ( ) ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; s . Push ( arr [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( s . Count == 0 ) { s . Push ( arr [ i ] ) ; continue ; } while ( s . Count != 0 && s . Peek ( ) > arr [ i ] ) { mp . Add ( s . Peek ( ) , arr [ i ] ) ; s . Pop ( ) ; } s . Push ( arr [ i ] ) ; } while ( s . Count != 0 ) { mp . Add ( s . Peek ( ) , - 1 ) ; s . Pop ( ) ; } for ( int i = 0 ; i < n ; i ++ ) Console . WriteLine ( arr [ i ] + " ▁ - - - > ▁ " + mp [ arr [ i ] ] ) ; } public static void Main ( ) { int [ ] arr = { 11 , 13 , 21 , 3 } ; int n = arr . Length ; printNSE ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { 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 getDeepestLeftLeafNode ( 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 . left . left == null && temp . left . right == null ) result = temp . left ; } if ( temp . right != null ) q . Enqueue ( temp . right ) ; } return result ; } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = 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 = getDeepestLeftLeafNode ( root ) ; if ( result != null ) Console . WriteLine ( " Deepest ▁ Left ▁ Leaf ▁ Node ▁ : : ▁ " + result . data ) ; else Console . WriteLine ( " No ▁ result , ▁ " + " left ▁ leaf ▁ not ▁ found " ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = null ; right = null ; } } class GFG { public Node root ; public virtual void preOrder ( Node node ) { if ( node != null ) { Console . Write ( node . data + " ▁ " ) ; preOrder ( node . left ) ; preOrder ( node . right ) ; } } public virtual List < Node > getTrees ( int [ ] arr , int start , int end ) { List < Node > trees = new List < Node > ( ) ; if ( start > end ) { trees . Add ( null ) ; return trees ; } for ( int i = start ; i <= end ; i ++ ) { List < Node > ltrees = getTrees ( arr , start , i - 1 ) ; List < Node > rtrees = getTrees ( arr , i + 1 , end ) ; for ( int j = 0 ; j < ltrees . Count ; j ++ ) { for ( int k = 0 ; k < rtrees . Count ; k ++ ) { Node node = new Node ( arr [ i ] ) ; node . left = ltrees [ j ] ; node . right = rtrees [ k ] ; trees . Add ( node ) ; } } } return trees ; } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 4 , 5 , 7 } ; int n = arr . Length ; GFG tree = new GFG ( ) ; List < Node > trees = tree . getTrees ( arr , 0 , n - 1 ) ; Console . WriteLine ( " Preorder ▁ traversal ▁ of ▁ different ▁ " + " ▁ binary ▁ trees ▁ are : " ) ; for ( int i = 0 ; i < trees . Count ; i ++ ) { tree . preOrder ( trees [ i ] ) ; Console . WriteLine ( " " ) ; } } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG, Node
C# program:
using System ; class GFG { public static void Main ( String [ ] args ) { String s1 = " geeks " , s2 = " geeksforgeeks " ; bool result = s2 . EndsWith ( s1 ) ; if ( result ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool ElementsCalculationFunc ( int [ ] pre , int [ ] maxx , int x , int k , int n ) { for ( int i = 0 , j = x ; j <= n ; j ++ , i ++ ) { if ( x * maxx [ j ] - ( pre [ j ] - pre [ i ] ) <= k ) return true ; } return false ; } static void MaxNumberOfElements ( int [ ] a , int n , int k ) { Array . Sort ( a ) ; for ( int i = 0 ; i <= n ; ++ i ) { pre [ i ] = 0 ; maxx [ i ] = 0 ; } for ( int i = 1 ; i <= n ; i ++ ) { pre [ i ] = pre [ i - 1 ] + a [ i - 1 ] ; maxx [ i ] = Math . Max ( maxx [ i - 1 ] , a [ i - 1 ] ) ; } int l = 1 , r = n , ans = 0 ; while ( l < r ) { int mid = ( l + r ) / 2 ; if ( ElementsCalculationFunc ( pre , maxx , mid - 1 , k , n ) ) { ans = mid ; l = mid + 1 ; } else r = mid - 1 ; } Console . Write ( ( int ) ans + " STRNEWLINE " ) ; } public static void Main ( ) { int [ ] arr = { 2 , 4 , 9 } ; int n = arr . Length ; int k = 3 ; MaxNumberOfElements ( arr , n , k ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_STR_LEN = 1000 ; static bool [ , ] P = new bool [ MAX_STR_LEN , MAX_STR_LEN ] ; static int [ ] Kpal = new int [ MAX_STR_LEN ] ; static void checkSubStrPal ( string str , int n ) { for ( int i = 0 ; i < MAX_STR_LEN ; i ++ ) { for ( int j = 0 ; j < MAX_STR_LEN ; j ++ ) P [ i , j ] = false ; Kpal [ i ] = 0 ; } for ( int i = 0 ; i < n ; i ++ ) P [ i , i ] = true ; for ( int i = 0 ; i < n - 1 ; i ++ ) if ( str [ i ] == str [ i + 1 ] ) P [ i , i + 1 ] = true ; for ( int gap = 2 ; gap < n ; gap ++ ) { for ( int i = 0 ; i < n - gap ; i ++ ) { int j = gap + i ; if ( str [ i ] == str [ j ] && P [ i + 1 , j - 1 ] ) P [ i , j ] = true ; } } } static void countKPalindromes ( int i , int j , int k ) { if ( i == j ) { Kpal [ k ] ++ ; return ; } if ( P [ i , j ] == false ) return ; Kpal [ k ] ++ ; int mid = ( i + j ) / 2 ; if ( ( j - i + 1 ) % 2 == 1 ) mid -- ; countKPalindromes ( i , mid , k + 1 ) ; } static void printKPalindromes ( string s ) { int n = s . Length ; checkSubStrPal ( s , n ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n - i ; j ++ ) countKPalindromes ( j , j + i , 1 ) ; for ( int i = 1 ; i <= n ; i ++ ) Console . Write ( Kpal [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } static void Main ( ) { string s = " abacaba " ; printKPalindromes ( s ) ; } }

Index/key variables: MAX_STR_LEN, i, j, k
Accumulator variables: gap, i, j, mid
Iterator variables: gap, i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Text ; class GFG { private static string printNumbers ( int [ ] numbers ) { List < int > array = new List < int > ( ) ; foreach ( int number in numbers ) { if ( findContainsOneTwoThree ( number ) ) { array . Add ( number ) ; } } array . Sort ( ) ; StringBuilder strbuf = new StringBuilder ( ) ; System . Collections . IEnumerator it = array . GetEnumerator ( ) ; while ( it . MoveNext ( ) ) { int value = ( int ) it . Current ; if ( strbuf . Length > 0 ) { strbuf . Append ( " , ▁ " ) ; } strbuf . Append ( Convert . ToString ( value ) ) ; } return ( strbuf . Length > 0 ) ? strbuf . ToString ( ) : " - 1" ; } private static bool findContainsOneTwoThree ( int number ) { string str = Convert . ToString ( number ) ; return ( str . Contains ( "1" ) && str . Contains ( "2" ) && str . Contains ( "3" ) ) ; } public static void Main ( string [ ] args ) { int [ ] numbers = new int [ ] { 123 , 1232 , 456 , 234 , 32145 } ; Console . WriteLine ( printNumbers ( numbers ) ) ; } }

Iterator variables: number
Class/struct names: GFG