dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; public class GFG { static void encode ( String s , int k ) { String newS = " " ; for ( int i = 0 ; i < s . Length ; ++ i ) { int val = s [ i ] ; int dup = k ; if ( val + k > 122 ) { k -= ( 122 - val ) ; k = k % 26 ; newS += ( char ) ( 96 + k ) ; } else { newS += ( char ) ( 96 + k ) ; } k = dup ; } Console . Write ( newS ) ; } public static void Main ( ) { String str = " abc " ; int k = 28 ; encode ( str , k ) ; } }

Index/key variables: i
Accumulator variables: k, newS
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isVowel ( char x ) { if ( x == ' a ' x == ' e ' x == ' i ' x == ' o ' x == ' u ' ) return true ; else return false ; } static String updateSandwichedVowels ( String a ) { int n = a . Length ; String updatedString = " " ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 i == n - 1 ) { updatedString += a [ i ] ; continue ; } if ( ( isVowel ( a [ i ] ) ) == true && isVowel ( a [ i - 1 ] ) == false && isVowel ( a [ i + 1 ] ) == false ) { continue ; } updatedString += a [ i ] ; } return updatedString ; } public static void Main ( ) { String str = " geeksforgeeks " ; String updatedString = updateSandwichedVowels ( str ) ; Console . WriteLine ( updatedString ) ; }

Index/key variables: i
Accumulator variables: i, updatedString
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 int ans ; static Node newNode ( int data ) { Node newNode = new Node ( ) ; newNode . data = data ; newNode . left = newNode . right = null ; return ( newNode ) ; } static void findPathUtil ( Node root , int k , List < int > path , int flag ) { if ( root == null ) return ; if ( root . data >= k ) flag = 1 ; if ( root . left == null && root . right == null ) { if ( flag == 1 ) { ans = 1 ; Console . Write ( " ( " ) ; for ( int i = 0 ; i < path . Count ; i ++ ) { Console . Write ( path [ i ] + " , ▁ " ) ; } Console . Write ( root . data + " ) , ▁ " ) ; } return ; } path . Add ( root . data ) ; findPathUtil ( root . left , k , path , flag ) ; findPathUtil ( root . right , k , path , flag ) ; path . RemoveAt ( path . Count - 1 ) ; } static void findPath ( Node root , int k ) { int flag = 0 ; ans = 0 ; List < int > v = new List < int > ( ) ; findPathUtil ( root , k , v , flag ) ; if ( ans == 0 ) Console . Write ( " - 1" ) ; } public static void Main ( String [ ] args ) { int K = 25 ; Node root = newNode ( 10 ) ; root . left = newNode ( 5 ) ; root . right = newNode ( 8 ) ; root . left . left = newNode ( 29 ) ; root . left . right = newNode ( 2 ) ; root . right . right = newNode ( 98 ) ; root . right . left = newNode ( 1 ) ; root . right . right . right = newNode ( 50 ) ; root . left . left . left = newNode ( 20 ) ; findPath ( root , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int Tridecagonal_num ( int n ) { return ( 11 * n * n - 9 * n ) / 2 ; } public static void Main ( String [ ] args ) { int n = 3 ; Console . Write ( Tridecagonal_num ( n ) + " STRNEWLINE " ) ; n = 10 ; Console . Write ( Tridecagonal_num ( n ) + " STRNEWLINE " ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { public class Node { public int data ; public Node left ; public Node right ; } ; static Node newNode ( int k ) { Node node = new Node ( ) ; node . data = k ; node . right = node . left = null ; return node ; } static bool isHeap ( Node root ) { Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; bool nullish = false ; while ( q . Count != 0 ) { Node temp = q . Peek ( ) ; q . Dequeue ( ) ; if ( temp . left != null ) { if ( nullish temp . left . data >= temp . data ) { return false ; } q . Enqueue ( temp . left ) ; } else { nullish = true ; } if ( temp . right != null ) { if ( nullish temp . right . data >= temp . data ) { return false ; } q . Enqueue ( temp . right ) ; } else { nullish = true ; } } return true ; } public static void Main ( String [ ] args ) { Node root = null ; root = newNode ( 10 ) ; root . left = newNode ( 9 ) ; root . right = newNode ( 8 ) ; root . left . left = newNode ( 7 ) ; root . left . right = newNode ( 6 ) ; root . right . left = newNode ( 5 ) ; root . right . right = newNode ( 4 ) ; root . left . left . left = newNode ( 3 ) ; root . left . left . right = newNode ( 2 ) ; root . left . right . left = newNode ( 1 ) ; if ( isHeap ( root ) ) Console . Write ( " Given ▁ binary ▁ tree ▁ is ▁ a ▁ Heap STRNEWLINE " ) ; else Console . Write ( " Given ▁ binary ▁ tree ▁ is ▁ not ▁ a ▁ Heap STRNEWLINE " ) ; } }

Boolean variables: nullish
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int findNumbers ( int n , int w ) { int x = 0 , sum = 0 ; if ( w >= 0 && w <= 8 ) { x = 9 - w ; } else if ( w >= - 9 && w <= - 1 ) { x = 10 + w ; } sum = ( int ) Math . Pow ( 10 , n - 2 ) ; sum = ( x * sum ) ; return sum ; } static public void Main ( ) { int n , w ; n = 3 ; w = 4 ; Console . WriteLine ( findNumbers ( n , w ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int MaximumHeight ( int [ ] a , int n ) { int result = 1 ; for ( int i = 1 ; i <= n ; ++ i ) { int y = ( i * ( i + 1 ) ) / 2 ; if ( y < n ) result = i ; else break ; } return result ; } static public void Main ( ) { int [ ] arr = { 40 , 100 , 20 , 30 } ; int n = arr . Length ; Console . WriteLine ( MaximumHeight ( arr , n ) ) ; } }

Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static int findK ( int n , int k ) { ArrayList a = new ArrayList ( n ) ; for ( int i = 1 ; i < n ; i ++ ) if ( i % 2 == 1 ) a . Add ( i ) ; for ( int i = 1 ; i < n ; i ++ ) if ( i % 2 == 0 ) a . Add ( i ) ; return ( int ) ( a [ k - 1 ] ) ; } static void Main ( ) { int n = 10 , k = 3 ; Console . WriteLine ( findK ( n , k ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int factorial ( int n ) { return ( n == 1 n == 0 ) ? 1 : n * factorial ( n - 1 ) ; } public static void Main ( ) { int num = 5 ; Console . WriteLine ( " Factorial ▁ of ▁ " + num + " ▁ is ▁ " + factorial ( num ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class PellNumber { public static int pell ( int n ) { if ( n <= 2 ) return n ; int a = 1 ; int b = 2 ; int c ; for ( int i = 3 ; i <= n ; i ++ ) { c = 2 * b + a ; a = b ; b = c ; } return b ; } public static void Main ( ) { int n = 4 ; Console . Write ( pell ( n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: PellNumber
C# program:
using System ; class GFG { static bool isMultipleOf10 ( int n ) { if ( n % 15 == 0 ) return true ; return false ; } public static void Main ( ) { int n = 30 ; if ( isMultipleOf10 ( n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static int countOddPrimeFactors ( int n ) { int result = 1 ; while ( n % 2 == 0 ) n /= 2 ; for ( int i = 3 ; i * i <= n ; i += 2 ) { int divCount = 0 ; while ( n % i == 0 ) { n /= i ; ++ divCount ; } result *= divCount + 1 ; } if ( n > 2 ) result *= 2 ; return result ; } static int politness ( int n ) { return countOddPrimeFactors ( n ) - 1 ; } public static void Main ( ) { int n = 90 ; Console . WriteLine ( " Politness ▁ of ▁ " + n + " ▁ = ▁ " + politness ( n ) ) ; n = 15 ; Console . WriteLine ( " Politness ▁ of ▁ " + n + " ▁ = ▁ " + politness ( n ) ) ; } }

Accumulator variables: i, n, result
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static int MAX = 1000000 ; static ArrayList primes = new ArrayList ( ) ; static void Sieve ( ) { int n = MAX ; int nNew = ( int ) Math . Sqrt ( n ) ; int [ ] marked = new int [ n / 2 + 500 ] ; for ( int i = 1 ; i <= ( nNew - 1 ) / 2 ; i ++ ) for ( int j = ( i * ( i + 1 ) ) << 1 ; j <= n / 2 ; j = j + 2 * i + 1 ) marked [ j ] = 1 ; primes . Add ( 2 ) ; for ( int i = 1 ; i <= n / 2 ; i ++ ) if ( marked [ i ] == 0 ) primes . Add ( 2 * i + 1 ) ; } static int binarySearch ( int left , int right , int n ) { if ( left <= right ) { int mid = ( left + right ) / 2 ; if ( mid == 0 mid == primes . Count - 1 ) return ( int ) primes [ mid ] ; if ( ( int ) primes [ mid ] == n ) return ( int ) primes [ mid - 1 ] ; if ( ( int ) primes [ mid ] < n && ( int ) primes [ mid + 1 ] > n ) return ( int ) primes [ mid ] ; if ( n < ( int ) primes [ mid ] ) return binarySearch ( left , mid - 1 , n ) ; else return binarySearch ( mid + 1 , right , n ) ; } return 0 ; } static void Main ( ) { Sieve ( ) ; int n = 17 ; Console . WriteLine ( binarySearch ( 0 , primes . Count - 1 , n ) ) ; } }

Index/key variables: i, j, mid
Accumulator variables: i
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class Test { static int factorial ( int n ) { if ( n == 0 ) return 1 ; return n * factorial ( n - 1 ) ; } public static void Main ( ) { int num = 5 ; Console . WriteLine ( " Factorial ▁ of ▁ " + num + " ▁ is ▁ " + factorial ( 5 ) ) ; } }

Class/struct names: Test
C# program:
using System ; class GFG { static int FlipBits ( int n ) { return n -= ( n & ( - n ) ) ; } public static void Main ( String [ ] args ) { int N = 12 ; Console . Write ( " The ▁ number ▁ after " + " unsetting ▁ the ▁ " ) ; Console . Write ( " rightmost ▁ set ▁ bit : ▁ " + FlipBits ( N ) ) ; } }

Accumulator variables: n
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void Maximum_xor_Triplet ( int n , int [ ] a ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { s . Add ( a [ i ] ^ a [ j ] ) ; } } int ans = 0 ; foreach ( int i in s ) { for ( int j = 0 ; j < n ; j ++ ) { ans = Math . Max ( ans , i ^ a [ j ] ) ; } } Console . WriteLine ( ans ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 3 , 8 , 15 } ; int n = a . Length ; Maximum_xor_Triplet ( n , a ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void printMissing ( int [ ] ar , int low , int high ) { Array . Sort ( ar ) ; int index = ceilindex ( ar , low , 0 , ar . Length - 1 ) ; int x = low ; while ( index < ar . Length && x <= high ) { if ( ar [ index ] != x ) { Console . Write ( x + " ▁ " ) ; } else index ++ ; x ++ ; } while ( x <= high ) { Console . Write ( x + " ▁ " ) ; x ++ ; } } static int ceilindex ( int [ ] ar , int val , int low , int high ) { if ( val < ar [ 0 ] ) return 0 ; if ( val > ar [ ar . Length - 1 ] ) return ar . Length ; int mid = ( low + high ) / 2 ; if ( ar [ mid ] == val ) return mid ; if ( ar [ mid ] < val ) { if ( mid + 1 < high && ar [ mid + 1 ] >= val ) return mid + 1 ; return ceilindex ( ar , val , mid + 1 , high ) ; } else { if ( mid - 1 >= low && ar [ mid - 1 ] < val ) return mid ; return ceilindex ( ar , val , low , mid - 1 ) ; } } static public void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 4 } ; int low = 1 , high = 10 ; printMissing ( arr , low , high ) ; } }

Index/key variables: index, mid
Accumulator variables: index, x
Class/struct names: GFG
C# program:
using System ; class GFG { static void printMissing ( int [ ] arr , int n , int low , int high ) { bool [ ] points_of_range = new bool [ high - low + 1 ] ; for ( int i = 0 ; i < high - low + 1 ; i ++ ) points_of_range [ i ] = false ; for ( int i = 0 ; i < n ; i ++ ) { if ( low <= arr [ i ] && arr [ i ] <= high ) points_of_range [ arr [ i ] - low ] = true ; } for ( int x = 0 ; x <= high - low ; x ++ ) { if ( points_of_range [ x ] == false ) Console . Write ( " { 0 } ▁ " , low + x ) ; } } public static void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 4 } ; int n = arr . Length ; int low = 1 , high = 10 ; printMissing ( arr , n , low , high ) ; } }

Index/key variables: i, x
Accumulator variables: i, x
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printMissing ( int [ ] arr , int n , int low , int high ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { s . Add ( arr [ i ] ) ; } for ( int x = low ; x <= high ; x ++ ) if ( ! s . Contains ( x ) ) Console . Write ( x + " ▁ " ) ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 4 } ; int n = arr . Length ; int low = 1 , high = 10 ; printMissing ( arr , n , low , high ) ; } }

Index/key variables: i
Accumulator variables: i, x
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int find ( int [ ] a , int [ ] b , int k , int n1 , int n2 ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < n2 ; i ++ ) s . Add ( b [ i ] ) ; int missing = 0 ; for ( int i = 0 ; i < n1 ; i ++ ) { if ( ! s . Contains ( a [ i ] ) ) missing ++ ; if ( missing == k ) return a [ i ] ; } return - 1 ; } public static void Main ( String [ ] args ) { int [ ] a = { 0 , 2 , 4 , 6 , 8 , 10 , 12 , 14 , 15 } ; int [ ] b = { 4 , 10 , 6 , 8 , 12 } ; int n1 = a . Length ; int n2 = b . Length ; int k = 3 ; Console . WriteLine ( find ( a , b , k , n1 , n2 ) ) ; } }

Index/key variables: i
Accumulator variables: i, missing
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findString ( string S , int N ) { int [ ] amounts = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { amounts [ i ] = 0 ; } for ( int i = 0 ; i < S . Length ; i ++ ) { amounts [ ( int ) ( S [ i ] - 97 ) ] ++ ; } int count = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( amounts [ i ] > 0 ) count ++ ; } if ( count > N ) { Console . Write ( " - 1" ) ; } else { string ans = " " ; int high = 100001 ; int low = 0 ; int mid , total ; while ( ( high - low ) > 1 ) { total = 0 ; mid = ( high + low ) / 2 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( amounts [ i ] > 0 ) { total += ( amounts [ i ] - 1 ) / mid + 1 ; } } if ( total <= N ) { high = mid ; } else { low = mid ; } } Console . Write ( high + " ▁ " ) ; total = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( amounts [ i ] > 0 ) { total += ( amounts [ i ] - 1 ) / high + 1 ; for ( int j = 0 ; j < ( ( amounts [ i ] - 1 ) / high + 1 ) ; j ++ ) { ans += ( char ) ( i + 97 ) ; } } } for ( int i = total ; i < N ; i ++ ) { ans += ' a ' ; } string reverse = " " ; int Len = ans . Length - 1 ; while ( Len >= 0 ) { reverse = reverse + ans [ Len ] ; Len -- ; } Console . Write ( reverse ) ; } } public static void Main ( ) { string S = " toffee " ; int K = 4 ; findString ( S , K ) ; } }

Index/key variables: Len, i
Accumulator variables: Len, ans, count, i, j, total
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static void printFirstRepeating ( int [ ] arr ) { int min = - 1 ; HashSet < int > set = new HashSet < int > ( ) ; for ( int i = arr . Length - 1 ; i >= 0 ; i -- ) { if ( set . Contains ( arr [ i ] ) ) { min = i ; } else { set . Add ( arr [ i ] ) ; } } if ( min != - 1 ) { Console . WriteLine ( " The ▁ first ▁ repeating ▁ element ▁ is ▁ " + arr [ min ] ) ; } else { Console . WriteLine ( " There ▁ are ▁ no ▁ repeating ▁ elements " ) ; } } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 10 , 5 , 3 , 4 , 3 , 5 , 6 } ; printFirstRepeating ( arr ) ; } }

Index/key variables: i, min
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printFirstRepeating ( int [ ] arr , int n ) { int k = 0 ; int max = n ; for ( int i = 0 ; i < n ; i ++ ) if ( max < arr [ i ] ) max = arr [ i ] ; int [ ] a = new int [ max + 1 ] ; int [ ] b = new int [ max + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ arr [ i ] ] != 0 ) { b [ arr [ i ] ] = 1 ; k = 1 ; continue ; } else a [ arr [ i ] ] = i ; } if ( k == 0 ) Console . WriteLine ( " No ▁ repeating ▁ element ▁ found " ) ; else { int min = max + 1 ; for ( int i = 0 ; i < max + 1 ; i ++ ) if ( ( a [ i ] != 0 ) && min > a [ i ] && ( b [ i ] != 0 ) ) min = a [ i ] ; Console . Write ( arr [ min ] ) ; } Console . WriteLine ( ) ; } static void Main ( ) { int [ ] arr = { 10 , 5 , 3 , 4 , 3 , 5 , 6 } ; int n = arr . Length ; printFirstRepeating ( arr , n ) ; } }

Index/key variables: i, min
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int printKDistinct ( int [ ] arr , int n , int k ) { int dist_count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int j ; for ( j = 0 ; j < n ; j ++ ) if ( i != j && arr [ j ] == arr [ i ] ) break ; if ( j == n ) dist_count ++ ; if ( dist_count == k ) return arr [ i ] ; } return - 1 ; } public static void Main ( ) { int [ ] ar = { 1 , 2 , 1 , 3 , 4 , 2 } ; int n = ar . Length ; int k = 2 ; Console . Write ( printKDistinct ( ar , n , k ) ) ; } }

Index/key variables: i, j
Accumulator variables: dist_count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void countSubarrays ( int [ ] A ) { int res = 0 ; int curr = A [ 0 ] ; int [ ] cnt = new int [ A . Length ] ; cnt [ 0 ] = 1 ; for ( int c = 1 ; c < A . Length ; c ++ ) { if ( A == curr ) cnt ++ ; else curr = A ; cnt = 1 ; } for ( int i = 1 ; i < cnt . Length ; i ++ ) { res += Math . Min ( cnt [ i - 1 ] , cnt [ i ] ) ; } Console . WriteLine ( res - 1 ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 1 , 1 , 0 , 0 , 1 , 0 } ; countSubarrays ( A ) ; } }

Index/key variables: i
Accumulator variables: c, cnt, i, res
Iterator variables: c, i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GfG { 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 ; } static bool isEvenOddBinaryTree ( Node root ) { if ( root == null ) return true ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; int level = 0 ; while ( q . Count != 0 ) { int size = q . Count ; for ( int i = 0 ; i < size ; i ++ ) { Node node = q . Dequeue ( ) ; if ( level % 2 == 0 ) { if ( node . val % 2 == 1 ) return false ; } else if ( level % 2 == 1 ) { if ( node . val % 2 == 0 ) return false ; } if ( node . left != null ) { q . Enqueue ( node . left ) ; } if ( node . right != null ) { q . Enqueue ( node . right ) ; } } level ++ ; } return true ; } public static void Main ( String [ ] args ) { Node root = null ; root = newNode ( 2 ) ; root . left = newNode ( 3 ) ; root . right = newNode ( 9 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 10 ) ; root . right . right = newNode ( 6 ) ; if ( isEvenOddBinaryTree ( root ) ) { Console . WriteLine ( " YES " ) ; } else { Console . WriteLine ( " NO " ) ; } } }

Accumulator variables: i, level
Iterator variables: i
Class/struct names: GfG, Node
C# program:
using System ; class GFG { static int findMaxLen ( int [ ] a , int n ) { int [ ] freq = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; ++ i ) { freq [ a [ i ] ] ++ ; } int maxFreqElement = int . MinValue ; int maxFreqCount = 1 ; for ( int i = 1 ; i <= n ; ++ i ) { if ( freq [ i ] > maxFreqElement ) { maxFreqElement = freq [ i ] ; maxFreqCount = 1 ; } else if ( freq [ i ] == maxFreqElement ) maxFreqCount ++ ; } int ans ; if ( maxFreqElement == 1 ) ans = 0 ; else { ans = ( ( n - maxFreqCount ) / ( maxFreqElement - 1 ) ) ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 1 , 2 } ; int n = a . Length ; Console . Write ( findMaxLen ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: maxFreqCount
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getMid ( int s , int e ) { return s + ( e - s ) / 2 ; } static int MaxUtil ( int [ ] st , int ss , int se , int l , int r , int node ) { if ( l <= ss && r >= se ) return st [ node ] ; if ( se < l ss > r ) return - 1 ; int mid = getMid ( ss , se ) ; return Math . Max ( MaxUtil ( st , ss , mid , l , r , 2 * node + 1 ) , MaxUtil ( st , mid + 1 , se , l , r , 2 * node + 2 ) ) ; } static int getMax ( int [ ] st , int n , int l , int r ) { if ( l < 0 r > n - 1 l > r ) { Console . Write ( " Invalid ▁ Input " ) ; return - 1 ; } return MaxUtil ( st , 0 , n - 1 , l , r , 0 ) ; } static int constructSTUtil ( int [ ] arr , int ss , int se , int [ ] st , int si ) { if ( ss == se ) { st [ si ] = arr [ ss ] ; return arr [ ss ] ; } int mid = getMid ( ss , se ) ; st [ si ] = Math . Max ( constructSTUtil ( arr , ss , mid , st , si * 2 + 1 ) , constructSTUtil ( arr , mid + 1 , se , st , si * 2 + 2 ) ) ; return st [ si ] ; } static int [ ] constructST ( int [ ] arr , int n ) { int x = ( int ) ( Math . Ceiling ( Math . Log ( n ) ) ) ; int max_size = 2 * ( int ) Math . Pow ( 2 , x ) - 1 ; int [ ] st = new int [ max_size ] ; constructSTUtil ( arr , 0 , n - 1 , st , 0 ) ; return st ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 2 , 3 , 0 } ; int n = arr . Length ; int [ ] st = constructST ( arr , n ) ; int [ , ] Q = { { 1 , 3 } , { 0 , 2 } } ; for ( int i = 0 ; i < Q . GetLength ( 0 ) ; i ++ ) { int max = getMax ( st , n , Q [ i , 0 ] , Q [ i , 1 ] ) ; int ok = 0 ; for ( int j = 30 ; j >= 0 ; j -- ) { if ( ( max & ( 1 << j ) ) != 0 ) ok = 1 ; if ( ok <= 0 ) continue ; max |= ( 1 << j ) ; } Console . Write ( max + " ▁ " ) ; } } }

Index/key variables: max_size, node, si, ss
Accumulator variables: i, j, max
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int calculate ( int [ ] a , int n ) { Array . Sort ( a ) ; int count = 1 ; int answer = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] == a [ i - 1 ] ) { count += 1 ; } else { answer = answer + ( count * ( count - 1 ) ) / 2 ; count = 1 ; } } answer = answer + ( count * ( count - 1 ) ) / 2 ; return answer ; } public static void Main ( ) { int [ ] a = { 1 , 2 , 1 , 2 , 4 } ; int n = a . Length ; Console . WriteLine ( calculate ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int calculate ( int [ ] a , int n ) { int maximum = a . Max ( ) ; int [ ] frequency = new int [ maximum + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { frequency [ a [ i ] ] += 1 ; } int answer = 0 ; for ( int i = 0 ; i < ( maximum ) + 1 ; i ++ ) { answer = answer + frequency [ i ] * ( frequency [ i ] - 1 ) ; } return answer / 2 ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 1 , 2 , 4 } ; int n = a . Length ; Console . WriteLine ( calculate ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSubArray ( int [ ] arr , int n ) { int sum = 0 ; int maxsize = - 1 , startindex = 0 ; int endindex = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { sum = ( arr [ i ] == 0 ) ? - 1 : 1 ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] == 0 ) sum += - 1 ; else sum += 1 ; if ( sum == 0 && maxsize < j - i + 1 ) { maxsize = j - i + 1 ; startindex = i ; } } } endindex = startindex + maxsize - 1 ; if ( maxsize == - 1 ) Console . WriteLine ( " No ▁ such ▁ subarray " ) ; else Console . WriteLine ( startindex + " ▁ to ▁ " + endindex ) ; return maxsize ; } public static void Main ( ) { int [ ] arr = { 1 , 0 , 0 , 1 , 0 , 1 , 1 } ; int size = arr . Length ; findSubArray ( arr , size ) ; } }

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