dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static void rotatedSumQuery ( int [ ] arr , int n , int [ , ] query , int Q ) { int [ ] prefix = new int [ 2 * n ] ; for ( int i = 0 ; i < n ; i ++ ) { prefix [ i ] = arr [ i ] ; prefix [ i + n ] = arr [ i ] ; } for ( int i = 1 ; i < 2 * n ; i ++ ) prefix [ i ] += prefix [ i - 1 ] ; int start = 0 ; for ( int q = 0 ; q < Q ; q ++ ) { if ( query [ q , 0 ] == 1 ) { int k = query [ q , 1 ] ; start = ( start + k ) % n ; } else if ( query [ q , 0 ] == 2 ) { int L , R ; L = query [ q , 1 ] ; R = query [ q , 2 ] ; if ( start + L == 0 ) Console . Write ( prefix [ start + R ] + " STRNEWLINE " ) ; else Console . Write ( prefix [ start + R ] - prefix [ start + L - 1 ] + " STRNEWLINE " ) ; } } } public static void Main ( ) { int [ ] arr = new int [ ] { 1 , 2 , 3 , 4 , 5 , 6 } ; int Q = 5 ; int [ , ] query = new int [ , ] { { 2 , 1 , 3 } , { 1 , 3 , 0 } , { 2 , 0 , 3 } , { 1 , 4 , 0 } , { 2 , 3 , 5 } } ; int n = arr . Length ; rotatedSumQuery ( arr , n , query , Q ) ; } }

Index/key variables: i
Accumulator variables: i, q
Iterator variables: i, q
Class/struct names: GFG
C# program:
using System ; class GFG { static void isConversionPossible ( String s1 , String s2 , int x ) { int diff = 0 , n ; n = s1 . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( s1 [ i ] == s2 [ i ] ) continue ; diff = ( ( int ) ( s2 [ i ] - s1 [ i ] ) + 26 ) % 26 ; if ( diff > x ) { Console . Write ( " NO " ) ; return ; } } Console . Write ( " YES " ) ; } public static void Main ( ) { String s1 = " you " ; String s2 = " ara " ; int x = 6 ; isConversionPossible ( s1 , s2 , x ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class Solution { static int countRotation ( int n ) { int count = 0 ; do { int digit = n % 10 ; if ( digit % 2 == 0 ) count ++ ; n = n / 10 ; } while ( n != 0 ) ; return count ; } public static void Main ( ) { int n = 10203 ; Console . Write ( countRotation ( n ) ) ; } }

Accumulator variables: count
Class/struct names: Solution
C# program:
using System ; class GFG { public class Node { public int data ; public Node next ; } static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = ( head_ref ) ; ( head_ref ) = new_node ; return head_ref ; } static void printList ( Node node ) { while ( node != null ) { Console . Write ( node . data + " ▁ - > ▁ " ) ; node = node . next ; } Console . Write ( " null " ) ; } static Node rightRotate ( Node head , int k ) { if ( head == null ) return head ; Node tmp = head ; int len = 1 ; while ( tmp . next != null ) { tmp = tmp . next ; len ++ ; } if ( k > len ) k = k % len ; k = len - k ; if ( k == 0 k == len ) return head ; Node current = head ; int cnt = 1 ; while ( cnt < k && current != null ) { current = current . next ; cnt ++ ; } if ( current == null ) return head ; Node kthnode = current ; tmp . next = head ; head = kthnode . next ; kthnode . next = null ; return head ; } public static void Main ( String [ ] args ) { Node head = null ; head = push ( head , 5 ) ; head = push ( head , 4 ) ; head = push ( head , 3 ) ; head = push ( head , 2 ) ; head = push ( head , 1 ) ; int k = 2 ; Node updated_head = rightRotate ( head , k ) ; printList ( updated_head ) ; } }

Accumulator variables: cnt, len
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static bool isPossible ( int [ ] a , int n ) { if ( n <= 2 ) return true ; int flag = 0 ; for ( int i = 0 ; i < n - 2 ; i ++ ) { if ( ! ( a [ i ] > a [ i + 1 ] && a [ i + 1 ] > a [ i + 2 ] ) ) { flag = 1 ; break ; } } if ( flag == 0 ) return true ; flag = 0 ; for ( int i = 0 ; i < n - 2 ; i ++ ) { if ( ! ( a [ i ] < a [ i + 1 ] && a [ i + 1 ] < a [ i + 2 ] ) ) { flag = 1 ; break ; } } if ( flag == 0 ) return true ; int val1 = int . MaxValue , mini = - 1 , val2 = int . MinValue , maxi = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] < val1 ) { mini = i ; val1 = a [ i ] ; } if ( a [ i ] > val2 ) { maxi = i ; val2 = a [ i ] ; } } flag = 1 ; for ( int i = 0 ; i < maxi ; i ++ ) { if ( a [ i ] > a [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 && maxi + 1 == mini ) { flag = 1 ; for ( int i = mini ; i < n - 1 ; i ++ ) { if ( a [ i ] > a [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 ) return true ; } flag = 1 ; for ( int i = 0 ; i < mini ; i ++ ) { if ( a [ i ] < a [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 && maxi - 1 == mini ) { flag = 1 ; for ( int i = maxi ; i < n - 1 ; i ++ ) { if ( a [ i ] < a [ i + 1 ] ) { flag = 0 ; break ; } } if ( flag == 1 ) return true ; } return false ; } public static void Main ( ) { int [ ] a = { 4 , 5 , 6 , 2 , 3 } ; int n = a . Length ; if ( isPossible ( a , n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int cntRotations ( string s , int n ) { string str = s + s ; int [ ] pre = new int [ 2 * n ] ; for ( int i = 0 ; i < 2 * n ; i ++ ) { if ( i != 0 ) pre [ i ] += pre [ i - 1 ] ; if ( str [ i ] == ' a ' str [ i ] == ' e ' str [ i ] == ' i ' str [ i ] == ' o ' str [ i ] == ' u ' ) { pre [ i ] ++ ; } } int ans = 0 ; for ( int i = n - 1 ; i < 2 * n - 1 ; i ++ ) { int r = i , l = i - n ; int x1 = pre [ r ] ; if ( l >= 0 ) x1 -= pre [ l ] ; r = i - n / 2 ; int left = pre [ r ] ; if ( l >= 0 ) left -= pre [ l ] ; int right = x1 - left ; if ( left > right ) { ans ++ ; } } return ans ; } public static void Main ( ) { String s = " abecidft " ; int n = s . Length ; Console . WriteLine ( cntRotations ( s , n ) ) ; } }

Index/key variables: i, l, r
Accumulator variables: ans, i, left, x1
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int cntRotations ( char [ ] s , int n ) { int lh = 0 , rh = 0 , i , ans = 0 ; for ( i = 0 ; i < n / 2 ; ++ i ) if ( s [ i ] == ' a ' s [ i ] == ' e ' s [ i ] == ' i ' s [ i ] == ' o ' s [ i ] == ' u ' ) { lh ++ ; } for ( i = n / 2 ; i < n ; ++ i ) if ( s [ i ] == ' a ' s [ i ] == ' e ' s [ i ] == ' i ' s [ i ] == ' o ' s [ i ] == ' u ' ) { rh ++ ; } if ( lh > rh ) ans ++ ; for ( i = 1 ; i < n ; ++ i ) { if ( s [ i - 1 ] == ' a ' s [ i - 1 ] == ' e ' s [ i - 1 ] == ' i ' s [ i - 1 ] == ' o ' s [ i - 1 ] == ' u ' ) { rh ++ ; lh -- ; } if ( s [ ( i - 1 + n / 2 ) % n ] == ' a ' || s [ ( i - 1 + n / 2 ) % n ] == ' e ' || s [ ( i - 1 + n / 2 ) % n ] == ' i ' || s [ ( i - 1 + n / 2 ) % n ] == ' o ' || s [ ( i - 1 + n / 2 ) % n ] == ' u ' ) { rh -- ; lh ++ ; } if ( lh > rh ) ans ++ ; } return ans ; } static void Main ( ) { char [ ] s = { ' a ' , ' b ' , ' e ' , ' c ' , ' i ' , ' d ' , ' f ' , ' t ' } ; int n = s . Length ; Console . WriteLine ( cntRotations ( s , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, lh, rh
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int size = 2 ; static void performQueries ( String str , int n , int [ , ] queries , int q ) { int ptr = 0 ; for ( int i = 0 ; i < q ; i ++ ) { if ( queries [ i , 0 ] == 1 ) { ptr = ( ptr + queries [ i , 1 ] ) % n ; } else { int k = queries [ i , 1 ] ; int index = ( ptr + k - 1 ) % n ; Console . WriteLine ( str [ index ] ) ; } } } public static void Main ( String [ ] args ) { String str = " abcdefgh " ; int n = str . Length ; int [ , ] queries = { { 1 , 2 } , { 2 , 2 } , { 1 , 4 } , { 2 , 7 } } ; int q = queries . GetLength ( 0 ) ; performQueries ( str , n , queries , q ) ; } }

Index/key variables: index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class Solution { static void countOddRotations ( int n ) { int odd_count = 0 , even_count = 0 ; do { int digit = n % 10 ; if ( digit % 2 == 1 ) odd_count ++ ; else even_count ++ ; n = n / 10 ; } while ( n != 0 ) ; Console . WriteLine ( " Odd ▁ = ▁ " + odd_count ) ; Console . WriteLine ( " Even ▁ = ▁ " + even_count ) ; } public static void Main ( ) { int n = 1234 ; countOddRotations ( n ) ; } }

Accumulator variables: even_count, odd_count
Class/struct names: Solution
C# program:
using System ; public class GFG { static int numberOfDigits ( int n ) { int cnt = 0 ; while ( n > 0 ) { cnt ++ ; n /= 10 ; } return cnt ; } static void cal ( int num ) { int digits = numberOfDigits ( num ) ; int powTen = ( int ) Math . Pow ( 10 , digits - 1 ) ; for ( int i = 0 ; i < digits - 1 ; i ++ ) { int firstDigit = num / powTen ; int left = ( ( num * 10 ) + firstDigit ) - ( firstDigit * powTen * 10 ) ; Console . Write ( left + " ▁ " ) ; num = left ; } } static public void Main ( ) { int num = 1445 ; cal ( num ) ; } }

Accumulator variables: cnt, i, n
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void CheckKCycles ( int n , String s ) { bool ff = true ; int x = 0 ; for ( int i = 1 ; i < n ; i ++ ) { x = ( s . Substring ( i ) + s . Substring ( 0 , i ) ) . Length ; if ( x >= s . Length ) { continue ; } ff = false ; break ; } if ( ff ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } public static void Main ( String [ ] args ) { int n = 3 ; String s = "123" ; CheckKCycles ( n , s ) ; } }

Accumulator variables: i
Iterator variables: i
Boolean variables: ff
Class/struct names: GFG
C# program:
using System ; class GFG { public class ListNode { public int data ; public ListNode next ; } public static void rotateSubList ( ListNode A , int m , int n , int k ) { int size = n - m + 1 ; if ( k > size ) { k = k % size ; } if ( k == 0 k == size ) { ListNode head = A ; while ( head != null ) { Console . Write ( head . data ) ; head = head . next ; } return ; } ListNode link = null ; if ( m == 1 ) { link = A ; } ListNode c = A ; int count = 0 ; ListNode end = null ; ListNode pre = null ; while ( c != null ) { count ++ ; if ( count == m - 1 ) { pre = c ; link = c . next ; } if ( count == n - k ) { if ( m == 1 ) { end = c ; A = c . next ; } else { end = c ; pre . next = c . next ; } } if ( count == n ) { ListNode d = c . next ; c . next = link ; end . next = d ; ListNode head = A ; while ( head != null ) { Console . Write ( head . data + " ▁ " ) ; head = head . next ; } return ; } c = c . next ; } } public static ListNode push ( ListNode head , int val ) { ListNode new_node = new ListNode ( ) ; new_node . data = val ; new_node . next = ( head ) ; ( head ) = new_node ; return head ; } public static void Main ( string [ ] args ) { ListNode head = null ; head = push ( head , 70 ) ; head = push ( head , 60 ) ; head = push ( head , 50 ) ; head = push ( head , 40 ) ; head = push ( head , 30 ) ; head = push ( head , 20 ) ; head = push ( head , 10 ) ; ListNode tmp = head ; Console . Write ( " Given ▁ List : ▁ " ) ; while ( tmp != null ) { Console . Write ( tmp . data + " ▁ " ) ; tmp = tmp . next ; } Console . WriteLine ( ) ; int m = 3 , n = 6 , k = 2 ; Console . Write ( " After ▁ rotation ▁ of ▁ sublist : ▁ " ) ; rotateSubList ( head , m , n , k ) ; } }

Accumulator variables: count
Class/struct names: GFG, ListNode
C# program:
using System ; public class GFG { static bool rightRotationDivisor ( int N ) { int lastDigit = N % 10 ; int rightRotation = ( int ) ( lastDigit * Math . Pow ( 10 , ( int ) ( Math . Log10 ( N ) ) ) + Math . Floor ( ( double ) N / 10 ) ) ; return ( rightRotation % N == 0 ) ; } static void generateNumbers ( int m ) { for ( int i = ( int ) Math . Pow ( 10 , ( m - 1 ) ) ; i < Math . Pow ( 10 , m ) ; i ++ ) if ( rightRotationDivisor ( i ) ) Console . WriteLine ( i ) ; } public static void Main ( ) { int m = 3 ; generateNumbers ( m ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void generateNumbers ( int m ) { List < int > numbers = new List < int > ( ) ; int k_max , x ; for ( int y = 0 ; y < 10 ; y ++ ) { k_max = ( int ) ( Math . Pow ( 10 , m - 2 ) * ( 10 * y + 1 ) ) / ( int ) ( Math . Pow ( 10 , m - 1 ) + y ) ; for ( int k = 1 ; k <= k_max ; k ++ ) { x = ( int ) ( y * ( Math . Pow ( 10 , m - 1 ) - k ) ) / ( 10 * k - 1 ) ; if ( ( int ) ( y * ( Math . Pow ( 10 , m - 1 ) - k ) ) % ( 10 * k - 1 ) == 0 ) numbers . Add ( 10 * x + y ) ; } } numbers . Sort ( ) ; for ( int i = 0 ; i < numbers . Count ; i ++ ) Console . WriteLine ( numbers [ i ] ) ; } public static void Main ( String [ ] args ) { int m = 3 ; generateNumbers ( m ) ; } }

Index/key variables: i
Accumulator variables: i, k, y
Iterator variables: i, k, y
Class/struct names: GFG
C# program:
using System ; class GFG { static void checkIfSortRotated ( int [ ] arr , int n ) { int minEle = int . MaxValue ; int maxEle = int . MinValue ; int minIndex = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < minEle ) { minEle = arr [ i ] ; minIndex = i ; } } bool flag1 = true ; for ( int i = 1 ; i < minIndex ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { flag1 = false ; break ; } } bool flag2 = true ; for ( int i = minIndex + 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { flag2 = false ; break ; } } if ( flag1 && flag2 && ( arr [ n - 1 ] < arr [ 0 ] ) ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } public static void Main ( ) { int [ ] arr = { 3 , 4 , 5 , 1 , 2 } ; int n = arr . Length ; checkIfSortRotated ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: flag1, flag2
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 4 ; static void rotate90Clockwise ( int [ , ] arr ) { for ( int j = 0 ; j < N ; j ++ ) { for ( int i = N - 1 ; i >= 0 ; i -- ) Console . Write ( arr [ i , j ] + " ▁ " ) ; Console . WriteLine ( ) ; } } static void Main ( ) { int [ , ] arr = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; rotate90Clockwise ( arr ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static void rotate ( int [ , ] arr ) { int n = arr . GetLength ( 0 ) ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < i ; ++ j ) { int temp = arr [ i , j ] ; arr [ i , j ] = arr [ j , i ] ; arr [ j , i ] = temp ; } } for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < n / 2 ; ++ j ) { int temp = arr [ i , j ] ; arr [ i , j ] = arr [ i , n - j - 1 ] ; arr [ i , n - j - 1 ] = temp ; } } } static void printMatrix ( int [ , ] arr ) { int n = arr . GetLength ( 0 ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) Console . Write ( arr [ i , j ] + " ▁ " ) ; Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int [ , ] arr = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; rotate ( arr ) ; printMatrix ( arr ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void rotate ( int [ , ] arr ) { int n = arr . GetLength ( 0 ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n - i ; j ++ ) { int temp = arr [ i , j ] ; arr [ i , j ] = arr [ n - 1 - j , n - 1 - i ] ; arr [ n - 1 - j , n - 1 - i ] = temp ; } } for ( int i = 0 ; i < n / 2 ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { int temp = arr [ i , j ] ; arr [ i , j ] = arr [ n - 1 - i , j ] ; arr [ n - 1 - i , j ] = temp ; } } } static void printMatrix ( int [ , ] arr ) { int n = arr . GetLength ( 0 ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) Console . Write ( arr [ i , j ] + " ▁ " ) ; Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int [ , ] arr = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; rotate ( arr ) ; printMatrix ( arr ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void occurredOnce ( int [ ] arr , int n ) { Array . Sort ( arr ) ; if ( arr [ 0 ] != arr [ 1 ] ) Console . Write ( arr [ 0 ] + " ▁ " ) ; for ( int i = 1 ; i < n - 1 ; i ++ ) if ( arr [ i ] != arr [ i + 1 ] && arr [ i ] != arr [ i - 1 ] ) Console . Write ( arr [ i ] + " ▁ " ) ; if ( arr [ n - 2 ] != arr [ n - 1 ] ) Console . Write ( arr [ n - 1 ] + " ▁ " ) ; } public static void Main ( ) { int [ ] arr = { 7 , 7 , 8 , 8 , 9 , 1 , 1 , 4 , 2 , 2 } ; int n = arr . Length ; occurredOnce ( 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 { static void occurredOnce ( int [ ] arr , int n ) { Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . ContainsKey ( arr [ i ] ) ) mp [ arr [ i ] ] = 1 + mp [ arr [ i ] ] ; else mp . Add ( arr [ i ] , 1 ) ; } foreach ( KeyValuePair < int , int > entry in mp ) { if ( Int32 . Parse ( String . Join ( " " , entry . Value ) ) == 1 ) Console . Write ( entry . Key + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 7 , 7 , 8 , 8 , 9 , 1 , 1 , 4 , 2 , 2 } ; int n = arr . Length ; occurredOnce ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: entry, i
Class/struct names: GFG
C# program:
using System ; class GFG { static void occurredOnce ( int [ ] arr , int n ) { int i = 1 , len = n ; if ( arr [ 0 ] == arr [ len - 1 ] ) { i = 2 ; len -- ; } for ( ; i < n ; i ++ ) if ( arr [ i ] == arr [ i - 1 ] ) i ++ ; else Console . Write ( arr [ i - 1 ] + " ▁ " ) ; if ( arr [ n - 1 ] != arr [ 0 ] && arr [ n - 1 ] != arr [ n - 2 ] ) Console . Write ( arr [ n - 1 ] ) ; } public static void Main ( ) { int [ ] arr = { 7 , 7 , 8 , 8 , 9 , 1 , 1 , 4 , 2 , 2 } ; int n = arr . Length ; occurredOnce ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i, len
Class/struct names: GFG
C# program:
using System ; class GFG { static void rvereseArray ( int [ ] arr , int start , int end ) { while ( start < end ) { int temp = arr [ start ] ; arr [ start ] = arr [ end ] ; arr [ end ] = temp ; start ++ ; end -- ; } } static void printArray ( int [ ] arr , int size ) { for ( int i = 0 ; i < size ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } static void splitArr ( int [ ] arr , int k , int n ) { rvereseArray ( arr , 0 , n - 1 ) ; rvereseArray ( arr , 0 , n - k - 1 ) ; rvereseArray ( arr , n - k , n - 1 ) ; } public static void Main ( ) { int [ ] arr = { 12 , 10 , 5 , 6 , 52 , 36 } ; int n = arr . Length ; int k = 2 ; splitArr ( arr , k , n ) ; printArray ( arr , n ) ; } }

Index/key variables: end, i, start
Accumulator variables: end, i, start
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool isRotation ( string a , string b ) { int n = a . Length ; int m = b . Length ; if ( n != m ) return false ; int [ ] lps = new int [ n ] ; int len = 0 ; int i = 1 ; lps [ 0 ] = 0 ; while ( i < n ) { if ( a [ i ] == b [ len ] ) { lps [ i ] = ++ len ; ++ i ; } else { if ( len == 0 ) { lps [ i ] = 0 ; ++ i ; } else { len = lps [ len - 1 ] ; } } } i = 0 ; for ( int k = lps [ n - 1 ] ; k < m ; ++ k ) { if ( b [ k ] != a [ i ++ ] ) return false ; } return true ; } public static void Main ( ) { string s1 = " ABACD " ; string s2 = " CDABA " ; Console . WriteLine ( isRotation ( s1 , s2 ) ? "1" : "0" ) ; } }

Index/key variables: i, k, len, n
Accumulator variables: i
Iterator variables: k
Class/struct names: GFG
C# program:
using System ; class GFG { static int countRotationsDivBy8 ( String n ) { int len = n . Length ; int count = 0 ; if ( len == 1 ) { int oneDigit = n [ 0 ] - '0' ; if ( oneDigit % 8 == 0 ) return 1 ; return 0 ; } if ( len == 2 ) { int first = ( n [ 0 ] - '0' ) * 10 + ( n [ 1 ] - '0' ) ; int second = ( n [ 1 ] - '0' ) * 10 + ( n [ 0 ] - '0' ) ; if ( first % 8 == 0 ) count ++ ; if ( second % 8 == 0 ) count ++ ; return count ; } int threeDigit ; for ( int i = 0 ; i < ( len - 2 ) ; i ++ ) { threeDigit = ( n [ i ] - '0' ) * 100 + ( n [ i + 1 ] - '0' ) * 10 + ( n [ i + 2 ] - '0' ) ; if ( threeDigit % 8 == 0 ) count ++ ; } threeDigit = ( n [ len - 1 ] - '0' ) * 100 + ( n [ 0 ] - '0' ) * 10 + ( n [ 1 ] - '0' ) ; if ( threeDigit % 8 == 0 ) count ++ ; threeDigit = ( n [ len - 2 ] - '0' ) * 100 + ( n [ len - 1 ] - '0' ) * 10 + ( n [ 0 ] - '0' ) ; if ( threeDigit % 8 == 0 ) count ++ ; return count ; } public static void Main ( ) { String n = "43262488612" ; Console . Write ( " Rotations : ▁ " + countRotationsDivBy8 ( n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int minimunMoves ( string [ ] arr , int n ) { int ans = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { int curr_count = 0 ; string tmp = " " ; for ( int j = 0 ; j < n ; j ++ ) { tmp = arr [ j ] + arr [ j ] ; int index = tmp . IndexOf ( arr [ i ] , StringComparison . Ordinal ) ; if ( index == arr [ i ] . Length ) { return - 1 ; } curr_count += index ; } ans = Math . Min ( curr_count , ans ) ; } return ans ; } public static void Main ( string [ ] args ) { string [ ] arr = new string [ ] { " xzzwo " , " zwoxz " , " zzwox " , " xzzwo " } ; int n = arr . Length ; Console . WriteLine ( minimunMoves ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: curr_count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { public class Node { public int data ; public Node next ; } ; static Node tail ; static Node rotateHelper ( Node blockHead , Node blockTail , int d , int k ) { if ( d == 0 ) return blockHead ; if ( d > 0 ) { Node temp = blockHead ; for ( int i = 1 ; temp . next . next != null && i < k - 1 ; i ++ ) temp = temp . next ; blockTail . next = blockHead ; tail = temp ; return rotateHelper ( blockTail , temp , d - 1 , k ) ; } if ( d < 0 ) { blockTail . next = blockHead ; tail = blockHead ; return rotateHelper ( blockHead . next , blockHead , d + 1 , k ) ; } return blockHead ; } static Node rotateByBlocks ( Node head , int k , int d ) { if ( head == null head . next == null ) return head ; if ( d == 0 ) return head ; Node temp = head ; tail = null ; int i ; for ( i = 1 ; temp . next != null && i < k ; i ++ ) temp = temp . next ; Node nextBlock = temp . next ; if ( i < k ) head = rotateHelper ( head , temp , d % k , i ) ; else head = rotateHelper ( head , temp , d % k , k ) ; tail . next = rotateByBlocks ( nextBlock , k , d % k ) ; return head ; } static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head_ref ; head_ref = new_node ; return head_ref ; } static void printList ( Node node ) { while ( node != null ) { Console . Write ( node . data + " ▁ " ) ; node = node . next ; } } public static void Main ( String [ ] args ) { Node head = null ; for ( int i = 9 ; i > 0 ; i -= 1 ) head = push ( head , i ) ; Console . Write ( " Given ▁ linked ▁ list ▁ STRNEWLINE " ) ; printList ( head ) ; int k = 3 , d = 2 ; head = rotateByBlocks ( head , k , d ) ; Console . Write ( " by blocks " printList ( head ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static bool isRotation ( long x , long y ) { long x64 = x | ( x << 32 ) ; while ( x64 >= y ) { if ( x64 == y ) { return true ; } x64 >>= 1 ; } return false ; } public static void Main ( ) { long x = 122 ; long y = 2147483678L ; if ( isRotation ( x , y ) == false ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int countRotations ( String n ) { int len = n . Length ; if ( len == 1 ) { int oneDigit = n [ 0 ] - '0' ; if ( oneDigit % 4 == 0 ) return 1 ; return 0 ; } int twoDigit , count = 0 ; for ( int i = 0 ; i < ( len - 1 ) ; i ++ ) { twoDigit = ( n [ i ] - '0' ) * 10 + ( n [ i + 1 ] - '0' ) ; if ( twoDigit % 4 == 0 ) count ++ ; } twoDigit = ( n [ len - 1 ] - '0' ) * 10 + ( n [ 0 ] - '0' ) ; if ( twoDigit % 4 == 0 ) count ++ ; return count ; } public static void Main ( ) { String n = "4834" ; Console . Write ( " Rotations : ▁ " + countRotations ( n ) ) ; } }

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