dhyuti-n/xlcost-variable-roles huggingface dataset:
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 void printSingles ( Node node ) { if ( node == null ) { return ; } if ( node . left != null && node . right != null ) { printSingles ( node . left ) ; printSingles ( node . right ) ; } else if ( node . right != null ) { Console . Write ( node . right . data + " ▁ " ) ; printSingles ( node . right ) ; } else if ( node . left != null ) { Console . Write ( node . left . data + " ▁ " ) ; printSingles ( node . 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 . left . right = new Node ( 4 ) ; tree . root . right . left = new Node ( 5 ) ; tree . root . right . left . right = new Node ( 6 ) ; tree . printSingles ( tree . root ) ; } }

Class/struct names: BinaryTree, 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 { public Node root ; public virtual void kDistantFromLeafUtil ( Node node , int [ ] path , bool [ ] visited , int pathLen , int k ) { if ( node == null ) { return ; } path [ pathLen ] = node . data ; visited [ pathLen ] = false ; pathLen ++ ; if ( node . left == null && node . right == null && pathLen - k - 1 >= 0 && visited [ pathLen - k - 1 ] == false ) { Console . Write ( path [ pathLen - k - 1 ] + " ▁ " ) ; visited [ pathLen - k - 1 ] = true ; return ; } kDistantFromLeafUtil ( node . left , path , visited , pathLen , k ) ; kDistantFromLeafUtil ( node . right , path , visited , pathLen , k ) ; } public virtual void printKDistantfromLeaf ( Node node , int k ) { int [ ] path = new int [ 1000 ] ; bool [ ] visited = new bool [ 1000 ] ; kDistantFromLeafUtil ( node , path , visited , 0 , k ) ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . left = new Node ( 6 ) ; tree . root . right . right = new Node ( 7 ) ; tree . root . right . left . right = new Node ( 8 ) ; Console . WriteLine ( " ▁ Nodes ▁ at ▁ distance ▁ 2 ▁ are ▁ : " ) ; tree . printKDistantfromLeaf ( tree . root , 2 ) ; } }

Index/key variables: pathLen
Accumulator variables: pathLen
Class/struct names: BinaryTree, Node
C# program:
using System ; class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } class BinaryTree { Node root ; int printKDistantfromLeaf ( Node node , int k ) { if ( node == null ) return - 1 ; int lk = printKDistantfromLeaf ( node . left , k ) ; int rk = printKDistantfromLeaf ( node . right , k ) ; bool isLeaf = lk == - 1 && lk == rk ; if ( lk == 0 || rk == 0 || ( isLeaf && k == 0 ) ) Console . Write ( " ▁ " + node . data ) ; if ( isLeaf && k > 0 ) return k - 1 ; if ( lk > 0 && lk < k ) return lk - 1 ; if ( rk > 0 && rk < k ) return rk - 1 ; return - 2 ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; tree . root . right . left = new Node ( 6 ) ; tree . root . right . right = new Node ( 7 ) ; tree . root . right . left . right = new Node ( 8 ) ; Console . Write ( " Nodes ▁ at ▁ distance ▁ 2 ▁ are ▁ : " ) ; tree . printKDistantfromLeaf ( tree . root , 2 ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections . Generic ; public class Node { public int key ; public Node left , right ; public Node ( int key ) { this . key = key ; left = right = null ; } } public class BinaryTree { Node root ; void printCorner ( Node root ) { Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; while ( q . Count != 0 ) { int n = q . Count ; for ( int i = 0 ; i < n ; i ++ ) { Node temp = q . Peek ( ) ; q . Dequeue ( ) ; if ( i == 0 i == n - 1 ) Console . Write ( temp . key + " ▁ " ) ; if ( temp . left != null ) q . Enqueue ( temp . left ) ; if ( temp . right != null ) q . Enqueue ( temp . right ) ; } } } public static void Main ( String [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 15 ) ; tree . root . left = new Node ( 10 ) ; tree . root . right = new Node ( 20 ) ; tree . root . left . left = new Node ( 8 ) ; tree . root . left . right = new Node ( 12 ) ; tree . root . right . left = new Node ( 16 ) ; tree . root . right . right = new Node ( 25 ) ; tree . printCorner ( tree . root ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { static readonly int COUNT = 10 ; public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; this . left = null ; this . right = null ; } } ; static void print2DUtil ( Node root , int space ) { if ( root == null ) return ; space += COUNT ; print2DUtil ( root . right , space ) ; Console . Write ( " STRNEWLINE " ) ; for ( int i = COUNT ; i < space ; i ++ ) Console . Write ( " ▁ " ) ; Console . Write ( root . data + " STRNEWLINE " ) ; print2DUtil ( root . left , space ) ; } static void print2D ( Node root ) { print2DUtil ( root , 0 ) ; } 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 . left . right = new Node ( 5 ) ; root . right . left = new Node ( 6 ) ; root . right . right = new Node ( 7 ) ; root . left . left . left = new Node ( 8 ) ; root . left . left . right = new Node ( 9 ) ; root . left . right . left = new Node ( 10 ) ; root . left . right . right = new Node ( 11 ) ; root . right . left . left = new Node ( 12 ) ; root . right . left . right = new Node ( 13 ) ; root . right . right . left = new Node ( 14 ) ; root . right . right . right = new Node ( 15 ) ; print2D ( root ) ; } }

Accumulator variables: i, space
Iterator variables: i
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 { public Node root ; public static int max_level = 0 ; public virtual void leftViewUtil ( Node node , int level ) { if ( node == null ) { return ; } if ( max_level < level ) { Console . Write ( " ▁ " + node . data ) ; max_level = level ; } leftViewUtil ( node . left , level + 1 ) ; leftViewUtil ( node . right , level + 1 ) ; } public virtual void leftView ( ) { leftViewUtil ( root , 1 ) ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 12 ) ; tree . root . left = new Node ( 10 ) ; tree . root . right = new Node ( 30 ) ; tree . root . right . left = new Node ( 25 ) ; tree . root . right . right = new Node ( 40 ) ; tree . leftView ( ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections . Generic ; public class PrintRightView { private class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; this . left = null ; this . right = null ; } } private static void printRightView ( Node root ) { if ( root == null ) return ; Queue < Node > queue = new Queue < Node > ( ) ; queue . Enqueue ( root ) ; while ( queue . Count != 0 ) { int n = queue . Count ; for ( int i = 1 ; i <= n ; i ++ ) { Node temp = queue . Dequeue ( ) ; if ( i == n ) Console . Write ( temp . data + " ▁ " ) ; if ( temp . left != null ) queue . Enqueue ( temp . left ) ; if ( temp . right != null ) queue . Enqueue ( temp . right ) ; } } } public static void Main ( String [ ] args ) { Node root = new Node ( 10 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 7 ) ; root . left . right = new Node ( 8 ) ; root . right . right = new Node ( 15 ) ; root . right . left = new Node ( 12 ) ; root . right . right . left = new Node ( 14 ) ; printRightView ( root ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: Node, PrintRightView
C# program:
using System ; using System . Collections . Generic ; class GFG { static int rotate ( int [ ] arr , int N , int X ) { int nextPower = 1 ; while ( nextPower <= N ) nextPower *= 2 ; if ( X == 1 ) return nextPower - N ; int prevPower = nextPower / 2 ; return 2 * ( N - prevPower ) + 1 ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int X = 1 ; int N = arr . Length ; Console . Write ( rotate ( arr , N , X ) ) ; } }

Accumulator variables: nextPower
Class/struct names: GFG
C# program:
using System ; class GFG { static void findMaximumZeros ( string str , int n ) { int c0 = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( str [ i ] == '0' ) c0 ++ ; } if ( c0 == n ) { Console . Write ( n ) ; return ; } string s = str + str ; int mx = 0 ; for ( int i = 0 ; i < n ; ++ i ) { int cs = 0 ; int ce = 0 ; for ( int j = i ; j < i + n ; ++ j ) { if ( s [ j ] == '0' ) cs ++ ; else break ; } for ( int j = i + n - 1 ; j >= i ; -- j ) { if ( s [ j ] == '0' ) ce ++ ; else break ; } int val = cs + ce ; mx = Math . Max ( val , mx ) ; } Console . Write ( mx ) ; } public static void Main ( string [ ] args ) { string s = "1001" ; int n = s . Length ; findMaximumZeros ( s , n ) ; } }

Index/key variables: i, j
Accumulator variables: c0, ce, cs
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void findMaximumZeros ( string str , int n ) { int c0 = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( str [ i ] == '0' ) c0 ++ ; } if ( c0 == n ) { Console . Write ( n ) ; return ; } int mx = 0 ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '0' ) cnt ++ ; else { mx = Math . Max ( mx , cnt ) ; cnt = 0 ; } } mx = Math . Max ( mx , cnt ) ; int start = 0 , end = n - 1 ; cnt = 0 ; while ( str [ start ] != '1' && start < n ) { cnt ++ ; start ++ ; } while ( str [ end ] != '1' && end >= 0 ) { cnt ++ ; end -- ; } mx = Math . Max ( mx , cnt ) ; Console . Write ( mx ) ; } static public void Main ( ) { string s = "1001" ; int n = s . Length ; findMaximumZeros ( s , n ) ; } }

Index/key variables: end, i, start
Accumulator variables: c0, cnt, end, i, start
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void stringShift ( String s , int [ , ] shift ) { int val = 0 ; for ( int i = 0 ; i < shift . GetLength ( 0 ) ; ++ i ) if ( shift [ i , 0 ] == 0 ) val -= shift [ i , 1 ] ; else val += shift [ i , 1 ] ; int len = s . Length ; val = val % len ; String result = " " ; if ( val > 0 ) result = s . Substring ( len - val , val ) + s . Substring ( 0 , len - val ) ; else result = s . Substring ( - val , len ) + s . Substring ( 0 , - val ) ; Console . WriteLine ( result ) ; } public static void Main ( String [ ] args ) { String s = " abc " ; int [ , ] shift = new int [ , ] { { 0 , 1 } , { 1 , 2 } } ; stringShift ( s , shift ) ; } }

Accumulator variables: val
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void rotateArray ( int [ ] arr , int N ) { int [ ] v = arr ; Array . Sort ( v ) ; for ( int i = 1 ; i <= N ; ++ i ) { int x = arr [ N - 1 ] ; i = N - 1 ; while ( i > 0 ) { arr [ i ] = arr [ i - 1 ] ; arr [ 0 ] = x ; i -= 1 ; } if ( arr == v ) { Console . Write ( " YES " ) ; return ; } } Console . Write ( " NO " ) ; } public static void Main ( ) { int [ ] arr = { 3 , 4 , 5 , 1 , 2 } ; int N = arr . Length ; rotateArray ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findLargestRotation ( int num ) { int ans = num ; double lg = ( double ) ( Math . Log10 ( num ) + 1 ) ; int len = ( int ) ( Math . Floor ( lg ) ) ; int x = ( int ) Math . Pow ( 10 , len - 1 ) ; for ( int i = 1 ; i < len ; i ++ ) { int lastDigit = num % 10 ; num = num / 10 ; num += ( lastDigit * x ) ; if ( num > ans ) { ans = num ; } } Console . Write ( ans ) ; } public static void Main ( string [ ] args ) { int N = 657 ; findLargestRotation ( N ) ; } }

Accumulator variables: i, num
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int numberOfDigit ( int N ) { int digit = 0 ; while ( N > 0 ) { digit ++ ; N /= 10 ; } return digit ; } static void rotateNumberByK ( int N , int K ) { int X = numberOfDigit ( N ) ; K = ( ( K % X ) + X ) % X ; int left_no = N / ( int ) ( Math . Pow ( 10 , X - K ) ) ; N = N % ( int ) ( Math . Pow ( 10 , X - K ) ) ; int left_digit = numberOfDigit ( left_no ) ; N = ( N * ( int ) ( Math . Pow ( 10 , left_digit ) ) ) + left_no ; Console . WriteLine ( N ) ; } public static void Main ( string [ ] args ) { int N = 12345 , K = 7 ; rotateNumberByK ( N , K ) ; } }

Accumulator variables: N, digit
Class/struct names: GFG
C# program:
using System ; class GFG { static void minMovesToSort ( int [ ] arr , int N ) { int count = 0 ; int index = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] < arr [ i + 1 ] ) { count ++ ; index = i ; } } if ( count == 0 ) { Console . Write ( "0" ) ; } else if ( count == N - 1 ) { Console . Write ( N - 1 ) ; } else if ( count == 1 && arr [ 0 ] <= arr [ N - 1 ] ) { Console . Write ( index + 1 ) ; } else { Console . Write ( " - 1" ) ; } } public static void Main ( ) { int [ ] arr = { 2 , 1 , 5 , 4 , 2 } ; int N = arr . Length ; minMovesToSort ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 3 ; static int findMaximumDiagonalSumOMatrixf ( int [ , ] A ) { int maxDiagonalSum = Int32 . MinValue ; for ( int i = 0 ; i < N ; i ++ ) { int curr = 0 ; for ( int j = 0 ; j < N ; j ++ ) { curr += A [ j , ( i + j ) % N ] ; } maxDiagonalSum = Math . Max ( maxDiagonalSum , curr ) ; } for ( int i = 0 ; i < N ; i ++ ) { int curr = 0 ; for ( int j = 0 ; j < N ; j ++ ) { curr += A [ ( i + j ) % N , j ] ; } maxDiagonalSum = Math . Max ( maxDiagonalSum , curr ) ; } return maxDiagonalSum ; } public static void Main ( ) { int [ , ] mat = { { 1 , 1 , 2 } , { 2 , 1 , 2 } , { 1 , 2 , 2 } } ; Console . Write ( findMaximumDiagonalSumOMatrixf ( mat ) ) ; } }

Accumulator variables: curr, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void diagonalSumPerfectSquare ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { Console . Write ( arr [ ( j + i ) % 7 ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] srgs ) { int N = 7 ; int [ ] arr = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = i + 1 ; } diagonalSumPerfectSquare ( arr , N ) ; } }

Index/key variables: N, i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int MaxSum ( int [ ] arr , int n , int k ) { int i , max_sum = 0 , sum = 0 ; for ( i = 0 ; i < k ; i ++ ) { sum += arr [ i ] ; } max_sum = sum ; while ( i < n ) { sum = sum - arr [ i - k ] + arr [ i ] ; if ( max_sum < sum ) { max_sum = sum ; } i ++ ; } return max_sum ; } static int gcd ( int n1 , int n2 ) { if ( n2 == 0 ) { return n1 ; } else { return gcd ( n2 , n1 % n2 ) ; } } static int [ ] RotateArr ( int [ ] arr , int n , int d ) { int i = 0 , j = 0 ; d = d % n ; int no_of_sets = gcd ( d , n ) ; for ( i = 0 ; i < no_of_sets ; i ++ ) { int temp = arr [ i ] ; j = i ; while ( true ) { int k = j + d ; if ( k >= n ) k = k - n ; if ( k == i ) break ; arr [ j ] = arr [ k ] ; j = k ; } arr [ j ] = temp ; } return arr ; } static void performQuery ( int [ ] arr , int [ , ] Q , int q ) { int N = arr . Length ; for ( int i = 0 ; i < q ; i ++ ) { if ( Q [ i , 0 ] == 1 ) { arr = RotateArr ( arr , N , Q [ i , 1 ] ) ; for ( int t = 0 ; t < arr . Length ; t ++ ) { Console . Write ( arr [ t ] + " ▁ " ) ; } Console . WriteLine ( ) ; } else { Console . WriteLine ( MaxSum ( arr , N , Q [ i , 1 ] ) ) ; } } } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int q = 5 ; int [ , ] Q = { { 1 , 2 } , { 2 , 3 } , { 1 , 3 } , { 1 , 1 } , { 2 , 4 } } ; performQuery ( arr , Q , q ) ; } }

Index/key variables: i, j, k, t
Accumulator variables: i, sum, t
Iterator variables: i, t
Class/struct names: GFG
C# program:
using System ; class GFG { public static int getMinimumRemoval ( String str ) { int n = str . Length ; int ans = n ; if ( n % 2 == 0 ) { int [ ] freqEven = new int [ 128 ] ; int [ ] freqOdd = new int [ 128 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { freqEven [ str [ i ] ] ++ ; } else { freqOdd [ str [ i ] ] ++ ; } } int evenMax = 0 , oddMax = 0 ; for ( char chr = ' a ' ; chr <= ' z ' ; chr ++ ) { evenMax = Math . Max ( evenMax , freqEven [ chr ] ) ; oddMax = Math . Max ( oddMax , freqOdd [ chr ] ) ; } ans = ans - evenMax - oddMax ; } else { int [ ] freq = new int [ 128 ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ str [ i ] ] ++ ; } int strMax = 0 ; for ( char chr = ' a ' ; chr <= ' z ' ; chr ++ ) { strMax = Math . Max ( strMax , freq [ chr ] ) ; } ans = ans - strMax ; } return ans ; } public static void Main ( String [ ] args ) { String str = " geeksgeeks " ; Console . Write ( getMinimumRemoval ( str ) ) ; } }

Index/key variables: chr, i
Accumulator variables: chr, i
Iterator variables: chr, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findAltSubSeq ( String s ) { int n = s . Length , ans = int . MinValue ; for ( int i = 0 ; i < 10 ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { int cur = 0 , f = 0 ; for ( int k = 0 ; k < n ; k ++ ) { if ( f == 0 && s [ k ] - '0' == i ) { f = 1 ; cur ++ ; } else if ( f == 1 && s [ k ] - '0' == j ) { f = 0 ; cur ++ ; } } if ( i != j && cur % 2 == 1 ) cur -- ; ans = Math . Max ( cur , ans ) ; } } return ans ; } public static void Main ( String [ ] args ) { String s = "100210601" ; Console . Write ( findAltSubSeq ( s ) ) ; } }

Index/key variables: k
Accumulator variables: cur, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void matrix ( int n , int m , int [ , ] li ) { int ctr = 0 ; while ( ctr < 2 * n - 1 ) { for ( int i = 0 ; i < Math . Abs ( n - ctr - 1 ) ; i ++ ) { Console . Write ( " ▁ " ) ; } ArrayList lst = new ArrayList ( ) ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i + j == ctr ) { lst . Add ( li [ i , j ] ) ; } } } for ( int i = lst . Count - 1 ; i >= 0 ; i -- ) { Console . Write ( ( int ) lst [ i ] + " ▁ " ) ; } Console . Write ( " STRNEWLINE " ) ; ctr += 1 ; } } public static void Main ( string [ ] args ) { int n = 8 ; int m = n ; int [ , ] li = { { 4 , 5 , 6 , 9 , 8 , 7 , 1 , 4 } , { 1 , 5 , 9 , 7 , 5 , 3 , 1 , 6 } , { 7 , 5 , 3 , 1 , 5 , 9 , 8 , 0 } , { 6 , 5 , 4 , 7 , 8 , 9 , 3 , 7 } , { 3 , 5 , 6 , 4 , 8 , 9 , 2 , 1 } , { 3 , 1 , 6 , 4 , 7 , 9 , 5 , 0 } , { 8 , 0 , 7 , 2 , 3 , 1 , 0 , 8 } , { 7 , 5 , 3 , 1 , 5 , 9 , 8 , 5 } } ; matrix ( n , m , li ) ; } }

Index/key variables: i
Accumulator variables: ctr, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int getFirstElement ( int [ ] a , int N , int K , int M ) { K %= N ; int index ; if ( K >= M ) index = ( N - K ) + ( M - 1 ) ; else index = ( M - K - 1 ) ; int result = a [ index ] ; return result ; } public static void Main ( ) { int [ ] a = { 1 , 2 , 3 , 4 , 5 } ; int N = 5 ; int K = 3 , M = 2 ; Console . Write ( getFirstElement ( a , N , K , M ) ) ; } }

Index/key variables: index
Class/struct names: GFG
C# program:
using System ; class GFG { public static int getFirstElement ( int [ ] a , int N , int K , int M ) { K %= N ; int index = ( K + M - 1 ) % N ; int result = a [ index ] ; return result ; } public static void Main ( string [ ] args ) { int [ ] a = { 3 , 4 , 5 , 23 } ; int N = a . Length ; int K = 2 , M = 1 ; Console . Write ( getFirstElement ( a , N , K , M ) ) ; } }

Index/key variables: index
Class/struct names: GFG
C# program:
using System ; class GFG { static void left_rotate ( int [ ] arr ) { int last = arr [ 1 ] ; for ( int i = 3 ; i < arr . Length ; i = i + 2 ) { arr [ i - 2 ] = arr [ i ] ; } arr [ arr . Length - 1 ] = last ; } static void right_rotate ( int [ ] arr ) { int start = arr [ arr . Length - 2 ] ; for ( int i = arr . Length - 4 ; i >= 0 ; i = i - 2 ) { arr [ i + 2 ] = arr [ i ] ; } arr [ 0 ] = start ; } public static void rotate ( int [ ] arr ) { left_rotate ( arr ) ; right_rotate ( arr ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; rotate ( arr ) ; } }

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 maximumMatchingPairs ( int [ ] perm1 , int [ ] perm2 , int n ) { int [ ] left = new int [ n ] ; int [ ] right = new int [ n ] ; Dictionary < int , int > mp1 = new Dictionary < int , int > ( ) ; Dictionary < int , int > mp2 = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { mp1 [ perm1 [ i ] ] = i ; } for ( int j = 0 ; j < n ; j ++ ) { mp2 [ perm2 [ j ] ] = j ; } for ( int i = 0 ; i < n ; i ++ ) { int idx2 = mp2 [ perm1 [ i ] ] ; int idx1 = i ; if ( idx1 == idx2 ) { left [ i ] = 0 ; right [ i ] = 0 ; } else if ( idx1 < idx2 ) { left [ i ] = ( n - ( idx2 - idx1 ) ) ; right [ i ] = ( idx2 - idx1 ) ; } else { left [ i ] = ( idx1 - idx2 ) ; right [ i ] = ( n - ( idx1 - idx2 ) ) ; } } Dictionary < int , int > freq1 = new Dictionary < int , int > ( ) ; Dictionary < int , int > freq2 = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq1 . ContainsKey ( left [ i ] ) ) freq1 [ left [ i ] ] ++ ; else freq1 [ left [ i ] ] = 1 ; if ( freq2 . ContainsKey ( right [ i ] ) ) freq2 [ right [ i ] ] ++ ; else freq2 [ right [ i ] ] = 1 ; } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . Max ( ans , Math . Max ( freq1 [ left [ i ] ] , freq2 [ right [ i ] ] ) ) ; } return ans ; } public static void Main ( string [ ] args ) { int [ ] P1 = { 5 , 4 , 3 , 2 , 1 } ; int [ ] P2 = { 1 , 2 , 3 , 4 , 5 } ; int n = P1 . Length ; Console . Write ( maximumMatchingPairs ( P1 , P2 , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int countRotation ( int [ ] arr , int n ) { for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { return i ; } } return 0 ; } public static void Main ( String [ ] args ) { int [ ] arr1 = { 4 , 5 , 1 , 2 , 3 } ; Console . WriteLine ( countRotation ( arr1 , arr1 . Length ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int countRotation ( int [ ] arr , int low , int high ) { if ( low > high ) { return 0 ; } int mid = low + ( high - low ) / 2 ; if ( mid < high && arr [ mid ] > arr [ mid + 1 ] ) { return mid + 1 ; } if ( mid > low && arr [ mid ] < arr [ mid - 1 ] ) { return mid ; } if ( arr [ mid ] > arr [ low ] ) { return countRotation ( arr , mid + 1 , high ) ; } if ( arr [ mid ] < arr [ high ] ) { return countRotation ( arr , low , mid - 1 ) ; } else { int rightIndex = countRotation ( arr , mid + 1 , high ) ; int leftIndex = countRotation ( arr , low , mid - 1 ) ; if ( rightIndex == 0 ) { return leftIndex ; } return rightIndex ; } } public static void Main ( String [ ] args ) { int [ ] arr1 = { 4 , 5 , 1 , 2 , 3 } ; Console . WriteLine ( countRotation ( arr1 , 0 , arr1 . Length - 1 ) ) ; } }

Index/key variables: high, low, mid
Class/struct names: GFG