dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; public class FlipTree { public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; } } ; public static Node flipBinaryTree ( Node root ) { if ( root == null ) return root ; if ( root . left == null && root . right == null ) return root ; Node flippedRoot = flipBinaryTree ( root . left ) ; root . left . left = root . right ; root . left . right = root ; root . left = root . right = null ; return flippedRoot ; } public static void printLevelOrder ( Node root ) { if ( root == null ) return ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; while ( true ) { int nodeCount = q . Count ; if ( nodeCount == 0 ) break ; while ( nodeCount > 0 ) { Node node = q . Dequeue ( ) ; Console . Write ( node . data + " ▁ " ) ; if ( node . left != null ) q . Enqueue ( node . left ) ; if ( node . right != null ) q . Enqueue ( node . right ) ; nodeCount -- ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 1 ) ; root . right . left = new Node ( 4 ) ; root . right . right = new Node ( 5 ) ; Console . WriteLine ( " Level ▁ order ▁ traversal ▁ of ▁ given ▁ tree " ) ; printLevelOrder ( root ) ; root = flipBinaryTree ( root ) ; Console . WriteLine ( " Level ▁ order ▁ traversal ▁ of ▁ flipped ▁ tree " ) ; printLevelOrder ( root ) ; } }

Accumulator variables: nodeCount
Class/struct names: FlipTree, Node
C# program:
using System ; using System . Collections . Generic ; class GfG { static String simplify ( String str ) { int len = str . Length ; char [ ] res = new char [ len ] ; int index = 0 , i = 0 ; Stack < int > s = new Stack < int > ( ) ; s . Push ( 0 ) ; while ( i < len ) { if ( str [ i ] == ' + ' ) { if ( s . Peek ( ) == 1 ) res [ index ++ ] = ' - ' ; if ( s . Peek ( ) == 0 ) res [ index ++ ] = ' + ' ; } else if ( str [ i ] == ' - ' ) { if ( s . Peek ( ) == 1 ) res [ index ++ ] = ' + ' ; else if ( s . Peek ( ) == 0 ) res [ index ++ ] = ' - ' ; } else if ( str [ i ] == ' ( ' && i > 0 ) { if ( str [ i - 1 ] == ' - ' ) { int x = ( s . Peek ( ) == 1 ) ? 0 : 1 ; s . Push ( x ) ; } else if ( str [ i - 1 ] == ' + ' ) s . Push ( s . Peek ( ) ) ; } else if ( str [ i ] == ' ) ' ) s . Pop ( ) ; else res [ index ++ ] = str [ i ] ; i ++ ; } return new String ( res ) ; } public static void Main ( String [ ] args ) { String s1 = " a - ( b + c ) " ; String s2 = " a - ( b - c - ( d + e ) ) - f " ; Console . WriteLine ( simplify ( s1 ) ) ; Console . WriteLine ( simplify ( s2 ) ) ; } }

Index/key variables: i, len
Accumulator variables: i, index
Class/struct names: GfG
C# program:
using System ; class GFG { static int BOUND = 4 ; static int top = - 1 ; static int length = 0 ; static int [ ] create_new ( int [ ] a ) { int [ ] new_a = new int [ length + BOUND ] ; for ( int i = 0 ; i < length ; i ++ ) new_a [ i ] = a [ i ] ; length += BOUND ; return new_a ; } static int [ ] push ( int [ ] a , int element ) { if ( top == length - 1 ) a = create_new ( a ) ; a [ ++ top ] = element ; return a ; } static void pop ( int [ ] a ) { top -- ; } static void display ( int [ ] a ) { if ( top == - 1 ) Console . WriteLine ( " Stack ▁ is ▁ Empty " ) ; else { Console . Write ( " Stack : ▁ " ) ; for ( int i = 0 ; i <= top ; i ++ ) Console . Write ( a [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int [ ] a = create_new ( new int [ length + BOUND ] ) ; a = push ( a , 1 ) ; a = push ( a , 2 ) ; a = push ( a , 3 ) ; a = push ( a , 4 ) ; display ( a ) ; a = push ( a , 5 ) ; a = push ( a , 6 ) ; display ( a ) ; a = push ( a , 7 ) ; a = push ( a , 8 ) ; display ( a ) ; a = push ( a , 9 ) ; display ( a ) ; } }

Index/key variables: i
Accumulator variables: i, length, top
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void constructBlanceArray ( int [ ] BOP , int [ ] BCP , String str , int n ) { Stack < int > stk = new Stack < int > ( ) ; ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ( ' ) stk . Push ( i ) ; else { if ( stk . Count != 0 ) { BCP [ i ] = 1 ; BOP [ stk . Peek ( ) ] = 1 ; stk . Pop ( ) ; } else BCP [ i ] = 0 ; } } for ( int i = 1 ; i < n ; i ++ ) { BCP [ i ] += BCP [ i - 1 ] ; BOP [ i ] += BOP [ i - 1 ] ; } } static int query ( int [ ] BOP , int [ ] BCP , int s , int e ) { if ( BOP [ s - 1 ] == BOP [ s ] ) { return ( BCP [ e ] - BOP [ s ] ) * 2 ; } else { return ( BCP [ e ] - BOP [ s ] + 1 ) * 2 ; } } public static void Main ( String [ ] args ) { String str = " ( ) ) ( ( ) ) ( ( ) ) ( " ; int n = str . Length ; int [ ] BCP = new int [ n + 1 ] ; int [ ] BOP = new int [ n + 1 ] ; constructBlanceArray ( BOP , BCP , str , n ) ; int startIndex = 5 , endIndex = 11 ; Console . Write ( " Maximum ▁ Length ▁ Correct ▁ " + " Bracket ▁ Subsequence ▁ between ▁ " + startIndex + " ▁ and ▁ " + endIndex + " ▁ = ▁ " + query ( BOP , BCP , startIndex , endIndex ) + " STRNEWLINE " ) ; startIndex = 4 ; endIndex = 5 ; Console . Write ( " Maximum ▁ Length ▁ Correct ▁ " + " Bracket ▁ Subsequence ▁ between ▁ " + startIndex + " ▁ and ▁ " + endIndex + " ▁ = ▁ " + query ( BOP , BCP , startIndex , endIndex ) + " STRNEWLINE " ) ; startIndex = 1 ; endIndex = 5 ; Console . Write ( " Maximum ▁ Length ▁ Correct ▁ " + " Bracket ▁ Subsequence ▁ between ▁ " + startIndex + " ▁ and ▁ " + endIndex + " ▁ = ▁ " + query ( BOP , BCP , startIndex , endIndex ) + " STRNEWLINE " ) ; } }

Index/key variables: e, i, s
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class HeapSort { void heapify ( int [ ] arr , int n , int i ) { int largest = i ; int l = 2 * i + 1 ; int r = 2 * i + 2 ; if ( l < n && arr [ l ] > arr [ largest ] ) largest = l ; if ( r < n && arr [ r ] > arr [ largest ] ) largest = r ; if ( largest != i ) { int swap = arr [ i ] ; arr [ i ] = arr [ largest ] ; arr [ largest ] = swap ; heapify ( arr , n , largest ) ; } } public void sort ( int [ ] arr ) { int n = arr . Length ; for ( int i = n / 2 - 1 ; i >= 0 ; i -- ) heapify ( arr , n , i ) ; for ( int i = n - 1 ; i > 0 ; i -- ) { int temp = arr [ 0 ] ; arr [ 0 ] = arr [ i ] ; arr [ i ] = temp ; heapify ( arr , i , 0 ) ; } } static void printArray ( int [ ] arr ) { int n = arr . Length ; for ( int i = 0 ; i < n ; ++ i ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . Read ( ) ; } public static void Main ( ) { int [ ] arr = { 12 , 11 , 13 , 5 , 6 , 7 } ; int n = arr . Length ; HeapSort ob = new HeapSort ( ) ; ob . sort ( arr ) ; Console . WriteLine ( " Sorted ▁ array ▁ is " ) ; printArray ( arr ) ; } }

Index/key variables: i, l, largest, r
Accumulator variables: i
Iterator variables: i
Class/struct names: HeapSort
C# program:
using System ; class HeapSort { static void buildMaxHeap ( int [ ] arr , int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > arr [ ( i - 1 ) / 2 ] ) { int j = i ; while ( arr [ j ] > arr [ ( j - 1 ) / 2 ] ) { swap ( arr , j , ( j - 1 ) / 2 ) ; j = ( j - 1 ) / 2 ; } } } } static void heapSort ( int [ ] arr , int n ) { buildMaxHeap ( arr , n ) ; for ( int i = n - 1 ; i > 0 ; i -- ) { swap ( arr , 0 , i ) ; int j = 0 , index ; do { index = ( 2 * j + 1 ) ; if ( index < ( i - 1 ) && arr [ index ] < arr [ index + 1 ] ) index ++ ; if ( index < i && arr [ j ] < arr [ index ] ) swap ( arr , j , index ) ; j = index ; } while ( index < i ) ; } } public static void swap ( int [ ] a , int i , int j ) { int temp = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = temp ; } static void printArray ( int [ ] arr ) { int n = arr . Length ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 10 , 20 , 15 , 17 , 9 , 21 } ; int n = arr . Length ; Console . Write ( " Given ▁ array : ▁ " ) ; printArray ( arr ) ; heapSort ( arr , n ) ; Console . Write ( " Sorted ▁ array : ▁ " ) ; printArray ( arr ) ; } }

Index/key variables: i, index, j
Accumulator variables: i, index
Iterator variables: i
Class/struct names: HeapSort
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public int data ; public Node left , right ; } public static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } public static Node flipBinaryTree ( Node root ) { Node curr = root ; Node next = null ; Node temp = null ; Node prev = null ; while ( curr != null ) { next = curr . left ; curr . left = temp ; temp = curr . right ; curr . right = prev ; prev = curr ; curr = next ; } return prev ; } public static void printLevelOrder ( Node root ) { if ( root == null ) { return ; } LinkedList < Node > q = new LinkedList < Node > ( ) ; q . AddLast ( root ) ; while ( true ) { int nodeCount = q . Count ; if ( nodeCount == 0 ) { break ; } while ( nodeCount > 0 ) { Node node = q . First . Value ; Console . Write ( node . data + " ▁ " ) ; q . RemoveFirst ( ) ; if ( node . left != null ) { q . AddLast ( node . left ) ; } if ( node . right != null ) { q . AddLast ( node . right ) ; } nodeCount -- ; } Console . WriteLine ( ) ; } } public static void Main ( string [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . right . left = newNode ( 4 ) ; root . right . right = newNode ( 5 ) ; Console . Write ( " Level ▁ order ▁ traversal ▁ " + " of ▁ given ▁ tree STRNEWLINE " ) ; printLevelOrder ( root ) ; root = flipBinaryTree ( root ) ; Console . Write ( " STRNEWLINE Level ▁ order ▁ traversal ▁ " + " of ▁ the ▁ flipped ▁ tree STRNEWLINE " ) ; printLevelOrder ( root ) ; } }

Accumulator variables: nodeCount
Class/struct names: GFG, Node
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 { Node root ; bool IsFoldable ( Node node ) { if ( node == null ) return true ; return IsFoldableUtil ( node . left , node . right ) ; } bool IsFoldableUtil ( Node n1 , Node n2 ) { if ( n1 == null && n2 == null ) return true ; if ( n1 == null n2 == null ) return false ; return IsFoldableUtil ( n1 . left , n2 . right ) && IsFoldableUtil ( n1 . right , n2 . left ) ; } 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 . right . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; if ( tree . IsFoldable ( tree . root ) ) Console . WriteLine ( " tree ▁ is ▁ foldable " ) ; else Console . WriteLine ( " Tree ▁ is ▁ not ▁ foldable " ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int d ) { data = d ; left = right = null ; } } class GFG { public Node root ; public virtual int isSumProperty ( Node node ) { int left_data = 0 , right_data = 0 ; if ( node == null || ( node . left == null && node . right == null ) ) { return 1 ; } else { if ( node . left != null ) { left_data = node . left . data ; } if ( node . right != null ) { right_data = node . right . data ; } if ( ( node . data == left_data + right_data ) && ( isSumProperty ( node . left ) != 0 ) && isSumProperty ( node . right ) != 0 ) { return 1 ; } else { return 0 ; } } } public static void Main ( string [ ] args ) { GFG tree = new GFG ( ) ; tree . root = new Node ( 10 ) ; tree . root . left = new Node ( 8 ) ; tree . root . right = new Node ( 2 ) ; tree . root . left . left = new Node ( 3 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . right = new Node ( 2 ) ; if ( tree . isSumProperty ( tree . root ) != 0 ) { Console . WriteLine ( " The ▁ given ▁ tree ▁ satisfies " + " ▁ children ▁ sum ▁ property " ) ; } else { Console . WriteLine ( " The ▁ given ▁ tree ▁ does ▁ not " + " ▁ satisfy ▁ children ▁ sum ▁ property " ) ; } } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { static bool isHeap ( int [ ] arr , int i , int n ) { if ( i >= ( n - 2 ) / 2 ) { return true ; } if ( arr [ i ] >= arr [ 2 * i + 1 ] && arr [ i ] >= arr [ 2 * i + 2 ] && isHeap ( arr , 2 * i + 1 , n ) && isHeap ( arr , 2 * i + 2 , n ) ) { return true ; } return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 90 , 15 , 10 , 7 , 12 , 2 , 7 , 3 } ; int n = arr . Length - 1 ; if ( isHeap ( arr , 0 , n ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isHeap ( int [ ] arr , int n ) { for ( int i = 0 ; i <= ( n - 2 ) / 2 ; i ++ ) { if ( arr [ 2 * i + 1 ] > arr [ i ] ) { return false ; } if ( 2 * i + 2 < n && arr [ 2 * i + 2 ] > arr [ i ] ) { return false ; } } return true ; } public static void Main ( ) { int [ ] arr = { 90 , 15 , 10 , 7 , 12 , 2 , 7 , 3 } ; int n = arr . Length ; if ( isHeap ( arr , n ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class MinHeap { int [ ] harr ; int heap_size ; int capacity ; public MinHeap ( int [ ] a , int size ) { heap_size = size ; capacity = size ; harr = a ; int i = ( heap_size - 1 ) / 2 ; while ( i >= 0 ) { MinHeapify ( i ) ; i -- ; } } void MinHeapify ( int i ) { int l = left ( i ) ; int r = right ( i ) ; int smallest = i ; if ( l < heap_size && harr [ l ] < harr [ i ] ) smallest = l ; if ( r < heap_size && harr [ r ] < harr [ smallest ] ) smallest = r ; if ( smallest != i ) { swap ( i , smallest ) ; MinHeapify ( smallest ) ; } } int parent ( int i ) { return ( i - 1 ) / 2 ; } int left ( int i ) { return ( 2 * i + 1 ) ; } int right ( int i ) { return ( 2 * i + 2 ) ; } int extractMin ( ) { if ( heap_size <= 0 ) return int . MaxValue ; if ( heap_size == 1 ) { heap_size -- ; return harr [ 0 ] ; } int root = harr [ 0 ] ; harr [ 0 ] = harr [ heap_size - 1 ] ; heap_size -- ; MinHeapify ( 0 ) ; return root ; } void insertKey ( int k ) { if ( heap_size == capacity ) { Console . WriteLine ( " Overflow : ▁ Could ▁ not ▁ insertKey " ) ; return ; } heap_size ++ ; int i = heap_size - 1 ; harr [ i ] = k ; while ( i != 0 && harr [ parent ( i ) ] > harr [ i ] ) { swap ( i , parent ( i ) ) ; i = parent ( i ) ; } } Boolean isSizeOne ( ) { return ( heap_size == 1 ) ; } void swap ( int x , int y ) { int temp = harr [ x ] ; harr [ x ] = harr [ y ] ; harr [ y ] = temp ; } static int minCost ( int [ ] len , int n ) { int cost = 0 ; MinHeap minHeap = new MinHeap ( len , n ) ; while ( ! minHeap . isSizeOne ( ) ) { int min = minHeap . extractMin ( ) ; int sec_min = minHeap . extractMin ( ) ; cost += ( min + sec_min ) ; minHeap . insertKey ( min + sec_min ) ; } return cost ; } public static void Main ( String [ ] args ) { int [ ] len = { 4 , 3 , 2 , 6 } ; int size = len . Length ; Console . WriteLine ( " Total ▁ cost ▁ for ▁ connecting ▁ ropes ▁ is ▁ " + minCost ( len , size ) ) ; } } ;

Index/key variables: i, l, r, smallest, x, y
Accumulator variables: cost, heap_size, i
Class/struct names: MinHeap
C# program:
using System ; using System . Collections . Generic ; public class ConnectRopes { static int minCost ( int [ ] arr , int n ) { List < int > pq = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { pq . Add ( arr [ i ] ) ; } int res = 0 ; while ( pq . Count > 1 ) { pq . Sort ( ) ; int first = pq [ 0 ] ; int second = pq [ 1 ] ; pq . RemoveRange ( 0 , 2 ) ; res += first + second ; pq . Add ( first + second ) ; } return res ; } public static void Main ( String [ ] args ) { int [ ] len = { 4 , 3 , 2 , 6 } ; int size = len . Length ; Console . WriteLine ( " Total ▁ cost ▁ for ▁ connecting " + " ▁ ropes ▁ is ▁ " + minCost ( len , size ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: ConnectRopes
C# program:
using System ; using System . Collections . Generic ; class GFG { static void generate_derangement ( int N ) { int [ ] S = new int [ N + 1 ] ; List < int > PQ = new List < int > ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { S [ i ] = i ; PQ . Add ( S [ i ] ) ; } int [ ] D = new int [ N + 1 ] ; PQ . Sort ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { PQ . Sort ( ) ; int d = PQ [ 0 ] ; PQ . RemoveAt ( 0 ) ; if ( d != S [ i ] i == N ) { D [ i ] = d ; } else { PQ . Sort ( ) ; D [ i ] = PQ [ 0 ] ; PQ . RemoveAt ( 0 ) ; PQ . Add ( d ) ; } } if ( D [ N ] == S [ N ] ) { int t = D [ N - 1 ] ; D [ N - 1 ] = D [ N ] ; D [ N ] = t ; } for ( int i = 1 ; i <= N ; i ++ ) Console . Write ( D [ i ] + " ▁ " ) ; Console . Write ( " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { generate_derangement ( 10 ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void generate_derangement ( int N ) { int [ ] S = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) S [ i ] = i ; int [ ] D = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; i += 2 ) { if ( i == N ) { D [ N ] = S [ N - 1 ] ; D [ N - 1 ] = S [ N ] ; } else { D [ i ] = i + 1 ; D [ i + 1 ] = i ; } } for ( int i = 1 ; i <= N ; i ++ ) Console . Write ( D [ i ] + " ▁ " ) ; Console . WriteLine ( ) ; } public static void Main ( ) { generate_derangement ( 10 ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printLargest ( int [ ] seq , int N ) { int [ ] res = new int [ N ] ; List < int > pq = new List < int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) pq . Add ( seq [ i ] ) ; for ( int i = 0 ; i < N ; i ++ ) { pq . Sort ( ) ; pq . Reverse ( ) ; int d = pq [ 0 ] ; pq . RemoveAt ( 0 ) ; if ( d != seq [ i ] i == N - 1 ) { res [ i ] = d ; } else { res [ i ] = pq [ 0 ] ; pq . RemoveAt ( 0 ) ; pq . Add ( d ) ; } } if ( res [ N - 1 ] == seq [ N - 1 ] ) { res [ N - 1 ] = res [ N - 2 ] ; res [ N - 2 ] = seq [ N - 1 ] ; } Console . WriteLine ( " Largest ▁ Derangement " ) ; for ( int i = 0 ; i < N ; i ++ ) Console . Write ( res [ i ] + " ▁ " ) ; } static void Main ( ) { int [ ] seq = { 92 , 3 , 52 , 13 , 2 , 31 , 1 } ; int n = seq . Length ; printLargest ( seq , n ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int Profit ( int costPrice , int sellingPrice ) { int profit = ( sellingPrice - costPrice ) ; return profit ; } static int Loss ( int costPrice , int sellingPrice ) { int Loss = ( costPrice - sellingPrice ) ; return Loss ; } public static void Main ( ) { int costPrice = 1500 , sellingPrice = 2000 ; if ( sellingPrice == costPrice ) Console . Write ( " No ▁ profit ▁ nor ▁ Loss " ) ; else if ( sellingPrice > costPrice ) Console . Write ( Profit ( costPrice , sellingPrice ) + " ▁ Profit ▁ " ) ; else Console . Write ( Loss ( costPrice , sellingPrice ) + " ▁ Loss ▁ " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int nextPerfectSquare ( int N ) { int nextN = ( int ) Math . Floor ( Math . Sqrt ( N ) ) + 1 ; return nextN * nextN ; } public static void Main ( ) { int n = 35 ; Console . WriteLine ( nextPerfectSquare ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void printSubstrings ( int n ) { int s = ( int ) Math . Log10 ( n ) ; int d = ( int ) ( Math . Pow ( 10 , s ) + 0.5 ) ; int k = d ; while ( n > 0 ) { while ( d > 0 ) { Console . WriteLine ( n / d ) ; d = d / 10 ; } n = n % k ; k = k / 10 ; d = k ; } } public static void Main ( ) { int n = 123 ; printSubstrings ( n ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static long MOD = ( long ) ( 1e9 + 7 ) ; static long powerLL ( long x , long n ) { long result = 1 ; while ( n > 0 ) { if ( n % 2 == 1 ) { result = result * x % MOD ; } n = n / 2 ; x = x * x % MOD ; } return result ; } static long powerStrings ( String sa , String sb ) { long a = 0 , b = 0 ; for ( int i = 0 ; i < sa . Length ; i ++ ) { a = ( a * 10 + ( sa [ i ] - '0' ) ) % MOD ; } for ( int i = 0 ; i < sb . Length ; i ++ ) { b = ( b * 10 + ( sb [ i ] - '0' ) ) % ( MOD - 1 ) ; } return powerLL ( a , b ) ; } public static void Main ( String [ ] args ) { String sa = "2" , sb = "3" ; Console . WriteLine ( powerStrings ( sa , sb ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPowerOfTwo ( int n ) { return n != 0 && ( ( n & ( n - 1 ) ) == 0 ) ; } static int previousPowerOfTwo ( int n ) { while ( ( n & n - 1 ) > 1 ) { n = n & n - 1 ; } return n ; } static bool checkSum ( int n ) { if ( n == 0 n == 1 ) { Console . WriteLine ( " No " ) ; return false ; } else if ( isPowerOfTwo ( n ) ) { Console . WriteLine ( n / 2 + " ▁ " + n / 2 ) ; return true ; } else { int x = previousPowerOfTwo ( n ) ; int y = n - x ; if ( isPowerOfTwo ( y ) ) { Console . WriteLine ( x + " ▁ " + y ) ; return true ; } else { return false ; } } } public static void Main ( ) { int n1 = 20 ; if ( checkSum ( n1 ) == false ) Console . WriteLine ( " No " ) ; Console . WriteLine ( ) ; int n2 = 11 ; if ( checkSum ( n2 ) == false ) Console . WriteLine ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int complement ( int num ) { int len = 0 , temp , comp ; temp = num ; while ( true ) { len ++ ; num = num / 10 ; if ( Math . Abs ( num ) == 0 ) break ; } num = temp ; comp = ( int ) Math . Pow ( 10 , len ) - num ; return comp ; } public static void Main ( ) { Console . WriteLine ( complement ( 25 ) ) ; Console . WriteLine ( complement ( 456 ) ) ; } }

Accumulator variables: len
Class/struct names: GFG
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 && b == 0 ) return 0 ; if ( a == 0 ) return b ; if ( b == 0 ) return a ; if ( a == b ) return a ; if ( a > b ) return gcd ( a - b , b ) ; return gcd ( a , b - a ) ; } public static void Main ( ) { int a = 98 , b = 56 ; Console . WriteLine ( " GCD ▁ of ▁ " + a + " ▁ and ▁ " + b + " ▁ is ▁ " + gcd ( a , b ) ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static int countOddSum ( int [ ] a , int n ) { int c_odd = 0 , result = 0 ; bool odd = false ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] % 2 == 1 ) { odd = ! odd ; } if ( odd ) { c_odd ++ ; } } for ( int i = 0 ; i < n ; i ++ ) { result += c_odd ; if ( a [ i ] % 2 == 1 ) { c_odd = ( n - i - c_odd ) ; } } return result ; } public static void Main ( String [ ] args ) { int [ ] ar = { 5 , 4 , 4 , 5 , 1 , 3 } ; int n = ar . Length ; Console . Write ( " The ▁ Number ▁ of ▁ Subarrays ▁ " + " with ▁ odd ▁ sum ▁ is ▁ " + countOddSum ( ar , n ) ) ; } }

Index/key variables: i
Accumulator variables: c_odd, i, result
Iterator variables: i
Boolean variables: odd
Class/struct names: GFG
C# program:
using System ; public class GFG { static void findNthRoot ( double x , int n ) { double low , high ; if ( x >= 0 && x <= 1 ) { low = x ; high = 1 ; } else { low = 1 ; high = x ; } double epsilon = 0.00000001 ; double guess = ( low + high ) / 2 ; while ( Math . Abs ( ( Math . Pow ( guess , n ) ) - x ) >= epsilon ) { if ( Math . Pow ( guess , n ) > x ) { high = guess ; } else { low = guess ; } guess = ( low + high ) / 2 ; } Console . WriteLine ( guess ) ; } static public void Main ( ) { double x = 5 ; int n = 2 ; findNthRoot ( x , n ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static long calculateSum ( int n ) { long sum = 0 ; for ( int row = 0 ; row < n ; row ++ ) { sum = sum + ( 1 << row ) ; } return sum ; } static public void Main ( ) { int n = 10 ; Console . WriteLine ( " Sum ▁ of ▁ all ▁ elements : " + calculateSum ( n ) ) ; } }

Accumulator variables: row
Iterator variables: row
Class/struct names: GFG