dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void rotatedSumQuery ( int arr [ ] , int n , vector < vector < int > > & query , int Q ) { int prefix [ 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 ) cout << prefix [ start + R ] << endl ; else cout << prefix [ start + R ] - prefix [ start + L - 1 ] << endl ; } } } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int Q = 5 ; vector < vector < int > > query = { { 2 , 1 , 3 } , { 1 , 3 } , { 2 , 0 , 3 } , { 1 , 4 } , { 2 , 3 , 5 } } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; rotatedSumQuery ( arr , n , query , Q ) ; return 0 ; }

Index/key variables: i, q
Accumulator variables: i, q, stdc
Iterator variables: i, q
C++ program:
#include <bits/stdc++.h>
using namespace std ; void isConversionPossible ( string s1 , string s2 , int x ) { int diff , 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 ) { cout << " NO " << endl ; return ; } } cout << " YES " << endl ; } int main ( ) { string s1 = " you " ; string s2 = " ara " ; int x = 6 ; isConversionPossible ( s1 , s2 , x ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countRotation ( int n ) { int count = 0 ; do { int digit = n % 10 ; if ( digit == 0 ) count ++ ; n = n / 10 ; } while ( n != 0 ) ; return count ; } int main ( ) { int n = 10203 ; cout << countRotation ( n ) ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; class Node { public : int data ; Node * next ; } ; void 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 ; } void printList ( Node * node ) { while ( node != NULL ) { cout << node -> data << " ▁ - > ▁ " ; node = node -> next ; } cout << " NULL " ; } Node * rightRotate ( Node * head , int k ) { if ( ! head ) 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 ; } int main ( ) { Node * head = NULL ; push ( & head , 5 ) ; push ( & head , 4 ) ; push ( & head , 3 ) ; push ( & head , 2 ) ; push ( & head , 1 ) ; int k = 2 ; Node * updated_head = rightRotate ( head , k ) ; printList ( updated_head ) ; return 0 ; }

Accumulator variables: cnt, len, stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; 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 ] and 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 ] and a [ i + 1 ] < a [ i + 2 ] ) ) { flag = 1 ; break ; } } if ( flag == 0 ) return true ; int val1 = INT_MAX , mini = -1 , val2 = INT_MIN , maxi ; 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 and 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 and 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 ; } int main ( ) { int a [ ] = { 4 , 5 , 6 , 2 , 3 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; if ( isPossible ( a , n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cntRotations ( string s , int n ) { string str = s + s ; int pre [ 2 * n ] = { 0 } ; 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 ; } int main ( ) { string s = " abecidft " ; int n = s . length ( ) ; cout << cntRotations ( s , n ) ; return 0 ; }

Index/key variables: i, l, r
Accumulator variables: ans, i, left, stdc, x1
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; 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 ; } int main ( ) { char s [ ] = " abecidft " ; int n = strlen ( s ) ; cout << " ▁ " << cntRotations ( s , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, lh, rh, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define size  2
void performQueries ( string str , int n , int queries [ ] [ size ] , 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 ; cout << str [ index ] << " STRNEWLINE " ; } } } int main ( ) { string str = " abcdefgh " ; int n = str . length ( ) ; int queries [ ] [ size ] = { { 1 , 2 } , { 2 , 2 } , { 1 , 4 } , { 2 , 7 } } ; int q = sizeof ( queries ) / sizeof ( queries [ 0 ] ) ; performQueries ( str , n , queries , q ) ; return 0 ; }

Index/key variables: i, index, size
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void ReverseArray ( string & arr , int left , int right ) { char temp ; while ( left < right ) { temp = arr [ left ] ; arr [ left ] = arr [ right ] ; arr [ right ] = temp ; left ++ ; right -- ; } } bool RotateAndCheck ( string & str1 , string & str2 , int d ) { if ( str1 . length ( ) != str2 . length ( ) ) return false ; string left_rot_str1 , right_rot_str1 ; bool left_flag = true , right_flag = true ; int str1_size = str1 . size ( ) ; for ( int i = 0 ; i < str1_size ; i ++ ) { left_rot_str1 . push_back ( str1 [ i ] ) ; right_rot_str1 . push_back ( str1 [ i ] ) ; } ReverseArray ( left_rot_str1 , 0 , d - 1 ) ; ReverseArray ( left_rot_str1 , d , str1_size - 1 ) ; ReverseArray ( left_rot_str1 , 0 , str1_size - 1 ) ; ReverseArray ( right_rot_str1 , 0 , str1_size - d - 1 ) ; ReverseArray ( right_rot_str1 , str1_size - d , str1_size - 1 ) ; ReverseArray ( right_rot_str1 , 0 , str1_size - 1 ) ; for ( int i = 0 ; i < str1_size ; i ++ ) { if ( left_rot_str1 [ i ] != str2 [ i ] ) { left_flag = false ; } if ( right_rot_str1 [ i ] != str2 [ i ] ) { right_flag = false ; } } if ( left_flag right_flag ) return true ; return false ; } int main ( ) { string str1 = " abcdefg " ; string str2 = " cdefgab " ; int d = 2 ; d = d % str1 . size ( ) ; if ( RotateAndCheck ( str1 , str2 , d ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i, left, right
Accumulator variables: i, left, right, stdc
Iterator variables: i
Boolean variables: left_flag, right_flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; 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 ) ; cout << " Odd ▁ = ▁ " << odd_count << endl ; cout << " Even ▁ = ▁ " << even_count << endl ; } int main ( ) { int n = 1234 ; countOddRotations ( n ) ; }

Accumulator variables: even_count, odd_count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numberOfDigits ( int n ) { int cnt = 0 ; while ( n > 0 ) { cnt ++ ; n /= 10 ; } return cnt ; } void cal ( int num ) { int digits = numberOfDigits ( num ) ; int powTen = pow ( 10 , digits - 1 ) ; for ( int i = 0 ; i < digits - 1 ; i ++ ) { int firstDigit = num / powTen ; int left = ( ( num * 10 ) + firstDigit ) - ( firstDigit * powTen * 10 ) ; cout << left << " ▁ " ; num = left ; } } int main ( ) { int num = 1445 ; cal ( num ) ; return 0 ; }

Accumulator variables: cnt, i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int main ( ) { int n = 2 ; char S [ ] = { '0' , '1' , '2' } ; int k = 3 ; sort ( S , S + 3 ) ; vector < int > w ; w . push_back ( -1 ) ; while ( w . size ( ) > 0 ) { w [ w . size ( ) - 1 ] ++ ; int m = w . size ( ) ; if ( m == n ) { string str ; for ( int i = 0 ; i < w . size ( ) ; i ++ ) { str += S [ w [ i ] ] ; } cout << str << endl ; } while ( w . size ( ) < n ) { w . push_back ( w [ w . size ( ) - m ] ) ; } while ( w . size ( ) > 0 && w [ w . size ( ) - 1 ] == k - 1 ) { w . pop_back ( ) ; } } return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, str
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void CheckKCycles ( int n , string s ) { bool ff = true ; int x = 0 ; for ( int i = 1 ; i < n ; i ++ ) { x = ( s . substr ( i ) + s . substr ( 0 , i ) ) . length ( ) ; if ( x >= s . length ( ) ) { continue ; } ff = false ; break ; } if ( ff ) { cout << ( " Yes " ) ; } else { cout << ( " No " ) ; } } int main ( ) { int n = 3 ; string s = "123" ; CheckKCycles ( n , s ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
Boolean variables: ff
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct ListNode { int data ; struct ListNode * next ; } ; 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 ) { cout << 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 ) { cout << head -> data << " ▁ " ; head = head -> next ; } return ; } c = c -> next ; } } void push ( struct ListNode * * head , int val ) { struct ListNode * new_node = new ListNode ; new_node -> data = val ; new_node -> next = ( * head ) ; ( * head ) = new_node ; } int main ( ) { struct ListNode * head = NULL ; push ( & head , 70 ) ; push ( & head , 60 ) ; push ( & head , 50 ) ; push ( & head , 40 ) ; push ( & head , 30 ) ; push ( & head , 20 ) ; push ( & head , 10 ) ; ListNode * tmp = head ; cout << " Given ▁ List : ▁ " ; while ( tmp != NULL ) { cout << tmp -> data << " ▁ " ; tmp = tmp -> next ; } cout << endl ; int m = 3 , n = 6 , k = 2 ; cout << " After ▁ rotation ▁ of ▁ sublist : ▁ " ; rotateSubList ( head , m , n , k ) ; return 0 ; }

Accumulator variables: count, stdc
Class/struct names: ListNode
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool rightRotationDivisor ( int N ) { int lastDigit = N % 10 ; int rightRotation = ( lastDigit * pow ( 10 , int ( log10 ( N ) ) ) ) + floor ( N / 10 ) ; return ( rightRotation % N == 0 ) ; } void generateNumbers ( int m ) { for ( int i = pow ( 10 , ( m - 1 ) ) ; i < pow ( 10 , m ) ; i ++ ) if ( rightRotationDivisor ( i ) ) cout << i << endl ; } int main ( ) { int m = 3 ; generateNumbers ( m ) ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void generateNumbers ( int m ) { vector < int > numbers ; int k_max , x ; for ( int y = 0 ; y < 10 ; y ++ ) { k_max = ( int ) ( pow ( 10 , m - 2 ) * ( 10 * y + 1 ) ) / ( int ) ( pow ( 10 , m - 1 ) + y ) ; for ( int k = 1 ; k <= k_max ; k ++ ) { x = ( int ) ( y * ( pow ( 10 , m - 1 ) - k ) ) / ( 10 * k - 1 ) ; if ( ( int ) ( y * ( pow ( 10 , m - 1 ) - k ) ) % ( 10 * k - 1 ) == 0 ) numbers . push_back ( 10 * x + y ) ; } } sort ( numbers . begin ( ) , numbers . end ( ) ) ; for ( int i = 0 ; i < numbers . size ( ) ; i ++ ) cout << ( numbers [ i ] ) << endl ; } int main ( ) { int m = 3 ; generateNumbers ( m ) ; }

Index/key variables: i
Accumulator variables: i, k, stdc, y
Iterator variables: i, k, y
C++ program:
#include <climits>
#include <iostream>
using namespace std ; void checkIfSortRotated ( int arr [ ] , int n ) { int minEle = INT_MAX ; int maxEle = INT_MIN ; int minIndex = -1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < minEle ) { minEle = arr [ i ] ; minIndex = i ; } } int flag1 = 1 ; for ( int i = 1 ; i < minIndex ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { flag1 = 0 ; break ; } } int flag2 = 1 ; for ( int i = minIndex + 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) { flag2 = 0 ; break ; } } if ( flag1 && flag2 && ( arr [ n - 1 ] < arr [ 0 ] ) ) cout << " YES " ; else cout << " NO " ; } int main ( ) { int arr [ ] = { 3 , 4 , 5 , 1 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; checkIfSortRotated ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool checkRotatedAndSorted ( int arr [ ] , int n ) { int x = 0 , y = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] < arr [ i + 1 ] ) x ++ ; else y ++ ; } if ( x == 1 y == 1 ) { if ( arr [ n - 1 ] < arr [ 0 ] ) x ++ ; else y ++ ; if ( x == 1 y == 1 ) return true ; } return false ; } int main ( ) { int arr [ ] = { 4 , 5 , 1 , 2 , 3 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( checkRotatedAndSorted ( arr , n ) ) cout << " YES " << endl ; else cout << " NO " << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, x, y
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  4
void rotate90Clockwise ( int arr [ N ] [ N ] ) { for ( int j = 0 ; j < N ; j ++ ) { for ( int i = N - 1 ; i >= 0 ; i -- ) cout << arr [ i ] [ j ] << " ▁ " ; cout << ' ' ; } } int main ( ) { int arr [ N ] [ N ] = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; rotate90Clockwise ( arr ) ; return 0 ; }

Index/key variables: N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  4
void rotate ( int arr [ N ] [ N ] ) { 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 ; } } } void print ( int arr [ N ] [ N ] ) { for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) cout << arr [ i ] [ j ] << " ▁ " ; cout << ' ' ; } } int main ( ) { int arr [ N ] [ N ] = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; rotate ( arr ) ; print ( arr ) ; return 0 ; }

Index/key variables: N, i, j
Accumulator variables: stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  4
void rotate ( int arr [ N ] [ N ] ) { 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 ; } } } void print ( int arr [ N ] [ N ] ) { for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) cout << arr [ i ] [ j ] << " ▁ " ; cout << ' ' ; } } int main ( ) { int arr [ N ] [ N ] = { { 1 , 2 , 3 , 4 } , { 5 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; rotate ( arr ) ; print ( arr ) ; return 0 ; }

Index/key variables: N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void occurredOnce ( int arr [ ] , int n ) { sort ( arr , arr + n ) ; if ( arr [ 0 ] != arr [ 1 ] ) cout << arr [ 0 ] << " ▁ " ; for ( int i = 1 ; i < n - 1 ; i ++ ) if ( arr [ i ] != arr [ i + 1 ] && arr [ i ] != arr [ i - 1 ] ) cout << arr [ i ] << " ▁ " ; if ( arr [ n - 2 ] != arr [ n - 1 ] ) cout << arr [ n - 1 ] << " ▁ " ; } int main ( ) { int arr [ ] = { 7 , 7 , 8 , 8 , 9 , 1 , 1 , 4 , 2 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; occurredOnce ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void occurredOnce ( int arr [ ] , int n ) { unordered_map < int , int > mp ; for ( int i = 0 ; i < n ; i ++ ) mp [ arr [ i ] ] ++ ; for ( auto it = mp . begin ( ) ; it != mp . end ( ) ; it ++ ) if ( it -> second == 1 ) cout << it -> first << " ▁ " ; } int main ( ) { int arr [ ] = { 7 , 7 , 8 , 8 , 9 , 1 , 1 , 4 , 2 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; occurredOnce ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, it, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; 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 cout << arr [ i - 1 ] << " ▁ " ; if ( arr [ n - 1 ] != arr [ 0 ] && arr [ n - 1 ] != arr [ n - 2 ] ) cout << arr [ n - 1 ] ; } int main ( ) { int arr [ ] = { 7 , 7 , 8 , 8 , 9 , 1 , 1 , 4 , 2 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; occurredOnce ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, len, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void rvereseArray ( int arr [ ] , int start , int end ) { while ( start < end ) { int temp = arr [ start ] ; arr [ start ] = arr [ end ] ; arr [ end ] = temp ; start ++ ; end -- ; } } void printArray ( int arr [ ] , int size ) { for ( int i = 0 ; i < size ; i ++ ) cout << arr [ i ] << " ▁ " ; } 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 ) ; } int main ( ) { int arr [ ] = { 12 , 10 , 5 , 6 , 52 , 36 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int k = 2 ; splitArr ( arr , k , n ) ; printArray ( arr , n ) ; return 0 ; }

Index/key variables: end, i, start
Accumulator variables: end, i, start, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isRotation ( string a , string b ) { int n = a . length ( ) ; int m = b . length ( ) ; if ( n != m ) return false ; int lps [ 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 ; } int main ( ) { string s1 = " ABACD " ; string s2 = " CDABA " ; cout << ( isRotation ( s1 , s2 ) ? "1" : "0" ) ; }

Index/key variables: i, k, len, n
Accumulator variables: i, stdc
Iterator variables: k
C++ program:
#include <bits/stdc++.h>
using namespace std ; 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 ; } int main ( ) { string n = "43262488612" ; cout << " Rotations : ▁ " << countRotationsDivBy8 ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimunMoves ( string arr [ ] , int n ) { int ans = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { int curr_count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { string tmp = arr [ j ] + arr [ j ] ; int index = tmp . find ( arr [ i ] ) ; if ( index == string :: npos ) return -1 ; curr_count += index ; } ans = min ( curr_count , ans ) ; } return ans ; } int main ( ) { string arr [ ] = { " xzzwo " , " zwoxz " , " zzwox " , " xzzwo " } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << minimunMoves ( arr , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: curr_count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * next ; } ; int countRotation ( struct Node * head ) { int count = 0 ; int min = head -> data ; while ( head != NULL ) { if ( min > head -> data ) break ; count ++ ; head = head -> next ; } return count ; } void push ( struct Node * * head , int data ) { struct Node * newNode = new Node ; newNode -> data = data ; newNode -> next = ( * head ) ; ( * head ) = newNode ; } void printList ( struct Node * node ) { while ( node != NULL ) { printf ( " % d ▁ " , node -> data ) ; node = node -> next ; } } int main ( ) { struct Node * head = NULL ; push ( & head , 12 ) ; push ( & head , 11 ) ; push ( & head , 8 ) ; push ( & head , 5 ) ; push ( & head , 18 ) ; push ( & head , 15 ) ; printList ( head ) ; cout << endl ; cout << " Linked ▁ list ▁ rotated ▁ elements : ▁ " ; cout << countRotation ( head ) << endl ; return 0 ; }

Accumulator variables: count, stdc
Class/struct names: Node