dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumPalindromicStrings ( string S ) { int N = S . length ( ) ; vector < int > freq ( 26 ) ; for ( int i = 0 ; i < N ; i ++ ) { freq [ S [ i ] - ' a ' ] ++ ; } vector < int > oddFreqCharacters ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] & 1 ) { oddFreqCharacters . push_back ( i ) ; freq [ i ] -- ; } freq [ i ] /= 2 ; } vector < string > ans ; if ( oddFreqCharacters . empty ( ) ) { string left = " " ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 0 ; j < freq [ i ] ; j ++ ) { left += char ( i + ' a ' ) ; } } string right = left ; reverse ( right . begin ( ) , right . end ( ) ) ; ans . push_back ( left + right ) ; } else { string middle = " " ; int c = oddFreqCharacters . back ( ) ; oddFreqCharacters . pop_back ( ) ; middle += char ( c + ' a ' ) ; string left = " " ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 0 ; j < freq [ i ] ; j ++ ) { left += char ( i + ' a ' ) ; } } string right = left ; reverse ( right . begin ( ) , right . end ( ) ) ; ans . push_back ( left + middle + right ) ; while ( ! oddFreqCharacters . empty ( ) ) { int c = oddFreqCharacters . back ( ) ; oddFreqCharacters . pop_back ( ) ; string middle = " " ; middle += char ( c + ' a ' ) ; ans . push_back ( middle ) ; } } cout << " [ " ; for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { cout << ans [ i ] ; if ( i != ans . size ( ) - 1 ) { cout << " , ▁ " ; } } cout << " ] " ; return 0 ; } int main ( ) { string S = " geeksforgeeks " ; minimumPalindromicStrings ( S ) ; }

Index/key variables: i
Accumulator variables: i, j, left, middle, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void possibleEqualArray ( int A [ ] , int N ) { vector < int > pref ( N ) ; pref [ 0 ] = A [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { pref [ i ] = pref [ i - 1 ] ^ A [ i ] ; } if ( pref [ N - 1 ] == 0 ) { cout << " YES " ; return ; } int cur_xor = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { cur_xor ^= A [ i ] ; for ( int j = 0 ; j < i ; j ++ ) { if ( j ) { int middle_xor = pref [ j - 1 ] ^ pref [ i - 1 ] ; int left_xor = pref [ j - 1 ] ; int right_xor = cur_xor ; if ( left_xor == middle_xor && middle_xor == right_xor ) { cout << " YES " ; return ; } } } } cout << " NO " ; } int main ( ) { int A [ ] = { 0 , 2 , 2 } ; int N = sizeof ( A ) / sizeof ( int ) ; possibleEqualArray ( A , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cur_xor, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void GenerateArray ( int N , int X ) { int prev_xor = X ; for ( int i = 1 ; i <= N ; i ++ ) { cout << ( i ^ prev_xor ) ; if ( i != N ) { cout << " ▁ " ; } prev_xor = i ; } } int main ( ) { int N = 4 , X = 3 ; cout << " The ▁ generated ▁ array ▁ is ▁ " ; GenerateArray ( N , X ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void createGrid ( char grid [ ] [ 1001 ] , bool is1 , int N , int M ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( is1 ) { grid [ i ] [ j ] = '0' ; is1 = false ; } else { grid [ i ] [ j ] = '1' ; is1 = true ; } } if ( M % 2 == 0 ) is1 = ! is1 ; } } bool testGrid ( char testGrid [ ] [ 1001 ] , char Grid [ ] [ 1001 ] , int N , int M ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( Grid [ i ] [ j ] != ' * ' ) { if ( Grid [ i ] [ j ] != testGrid [ i ] [ j ] ) { return false ; } } } } return true ; } void printGrid ( char grid [ ] [ 1001 ] , int N , int M ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { cout << grid [ i ] [ j ] << " ▁ " ; } cout << endl ; } } void findPossibleGrid ( int N , int M , char grid [ ] [ 1001 ] ) { char gridTest1 [ N ] [ 1001 ] , gridTest2 [ N ] [ 1001 ] ; createGrid ( gridTest1 , true , N , M ) ; createGrid ( gridTest2 , false , N , M ) ; if ( testGrid ( gridTest1 , grid , N , M ) ) { cout << " Yes STRNEWLINE " ; printGrid ( gridTest1 , N , M ) ; } else if ( testGrid ( gridTest2 , grid , N , M ) ) { cout << " Yes STRNEWLINE " ; printGrid ( gridTest2 , N , M ) ; } else { cout << " No STRNEWLINE " ; } } int main ( ) { int N = 4 , M = 4 ; char grid [ ] [ 1001 ] = { { ' * ' , ' * ' , '1' , '0' } , { ' * ' , ' * ' , ' * ' , ' * ' } , { ' * ' , ' * ' , ' * ' , ' * ' } , { ' * ' , ' * ' , '0' , '1' } } ; findPossibleGrid ( N , M , grid ) ; return 0 ; }

Index/key variables: N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
Boolean variables: is1
C++ program:
#include <bits/stdc++.h>
using namespace std ; const long long INF64 = 1000000000000000000ll ; const int N = 200 * 1000 + 13 ; int n ; long long arr [ N ] , brr [ N ] ; void brute ( int ind , long long l , long long r ) { if ( ind == n / 2 ) { for ( int i = 0 ; i < int ( n ) ; i ++ ) printf ( " % lld ▁ " , brr [ i ] ) ; puts ( " " ) ; exit ( 0 ) ; } for ( long long i = l ; i <= arr [ ind ] / 2 ; ++ i ) if ( arr [ ind ] - i <= r ) { brr [ ind ] = i ; brr [ n - ind - 1 ] = arr [ ind ] - i ; brute ( ind + 1 , i , arr [ ind ] - i ) ; } } int main ( ) { n = 2 ; n *= 2 ; arr [ 0 ] = 5 ; arr [ 1 ] = 6 ; brute ( 0 , 0 , INF64 ) ; return 0 ; }

Index/key variables: N, i, ind
Accumulator variables: i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void modifyString ( string & s , string & s1 , string & s2 ) { string ans = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int k = 0 ; if ( s [ i ] == s1 [ k ] && i + s1 . length ( ) <= s . length ( ) ) { int j ; for ( j = i ; j < i + s1 . length ( ) ; j ++ ) { if ( s [ j ] != s1 [ k ] ) { break ; } else { k = k + 1 ; } } if ( j == i + s1 . length ( ) ) { ans . append ( s2 ) ; i = j - 1 ; } else { ans . push_back ( s [ i ] ) ; } } else { ans . push_back ( s [ i ] ) ; } } cout << ans ; } int main ( ) { string S = " geeksforgeeks " ; string S1 = " eek " ; string S2 = " ok " ; modifyString ( S , S1 , S2 ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minCount ( int N , int K ) { int SmallestNumber [ 10 ] ; int MinimumSteps [ 10 ] ; for ( int i = 0 ; i <= 9 ; i ++ ) { SmallestNumber [ i ] = INT_MAX ; MinimumSteps [ i ] = INT_MAX ; } for ( int i = 1 ; i <= 10 ; i ++ ) { int num = K * i ; SmallestNumber [ num % 10 ] = min ( SmallestNumber [ num % 10 ] , num ) ; MinimumSteps [ num % 10 ] = min ( MinimumSteps [ num % 10 ] , i ) ; } if ( N < SmallestNumber [ N % 10 ] ) { return -1 ; } else { return MinimumSteps [ N % 10 ] ; } } int main ( ) { int N = 42 , K = 7 ; cout << minCount ( N , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countMinSteps ( int arr [ ] , int N ) { int val = 0 ; int mx = INT_MIN ; for ( int i = 0 ; i < N ; i ++ ) { int curr = arr [ i ] ; mx = max ( mx , curr ) ; val = max ( val , mx - curr ) ; } long long res = 0 ; while ( ( 1LL << res ) - 1 < val ) { ++ res ; } return res ; } int main ( ) { int arr [ ] = { 1 , 7 , 6 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << countMinSteps ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int func2 ( int L , int R , int K ) { if ( R - L >= 2 ) return 1 ; return min ( L , L ^ R ) ; } int func3 ( int L , int R , int K ) { if ( ( R ^ L ) > L && ( R ^ L ) < R ) return 0 ; return func2 ( L , R , K ) ; } int func4 ( int L , int R , int K ) { if ( R - L >= 4 ) return 0 ; int minval = L ^ ( L + 1 ) ^ ( L + 2 ) ^ ( L + 3 ) ; return min ( minval , func3 ( L , R , K ) ) ; } int minimumXor ( int L , int R , int K ) { if ( K > 4 ) return 0 ; else if ( K == 4 ) return func4 ( L , R , K ) ; else if ( K == 3 ) return func3 ( L , R , K ) ; else if ( K == 2 ) return func2 ( L , R , K ) ; else return L ; } int main ( ) { int L = 1 , R = 3 , K = 3 ; cout << minimumXor ( L , R , K ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int setBits ( long n ) { int count = 0 ; while ( n > 0 ) { n = n & ( n - 1 ) ; count ++ ; } return count ; } void findNthTerm ( int N ) { int x = setBits ( N ^ ( N - 1 ) ) ; cout << x ; } int main ( ) { int N = 8 ; findNthTerm ( N ) ; return 0 ; }

Accumulator variables: count, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findEquation ( int A , int B , int C ) { cout << " ( " << C << " ) " << " x ^ 2 ▁ + ( " << B << " ) x ▁ + ▁ ( " << A << " ) ▁ = ▁ 0" ; } int main ( ) { int A = 1 , B = -5 , C = 6 ; findEquation ( A , B , C ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinMoves ( int arr [ ] , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) sum += arr [ i ] ; if ( sum % N != 0 ) return -1 ; int avg = sum / N ; int total = 0 ; int needCount = 0 ; for ( int i = 0 ; i < N ; i ++ ) { needCount += ( arr [ i ] - avg ) ; total = max ( max ( abs ( needCount ) , arr [ i ] - avg ) , total ) ; } return total ; } int main ( ) { int arr [ ] = { 1 , 0 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << findMinMoves ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, needCount, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void find ( int N , vector < vector < int > > Arr ) { int amount = 0 ; vector < int > mid_odd ; for ( int i = 0 ; i < N ; i ++ ) { int siz = Arr [ i ] . size ( ) ; for ( int j = 0 ; j < siz / 2 ; j ++ ) amount = amount + Arr [ i ] [ j ] ; if ( siz % 2 == 1 ) mid_odd . push_back ( Arr [ i ] [ siz / 2 ] ) ; } sort ( mid_odd . begin ( ) , mid_odd . end ( ) ) ; for ( int i = 0 ; i < mid_odd . size ( ) ; i ++ ) if ( i % 2 == 0 ) amount = amount + mid_odd [ i ] ; cout << amount << endl ; } int main ( ) { int N = 2 ; vector < vector < int > > Arr { { 5 , 2 , 3 , 4 } , { 1 , 6 } } ; find ( N , Arr ) ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string checkPattern ( int arr [ ] , int m , int k , int n ) { int count = 1 , t = 0 ; for ( int i = 0 ; i < n - m ; i ++ ) { if ( arr [ i ] == arr [ i + m ] ) { t ++ ; if ( t == m ) { t = 0 ; count ++ ; if ( count == k ) { return " Yes " ; } } } else { t = 0 ; count = 1 ; } } return " No " ; } int main ( ) { int arr [ ] = { 6 , 1 , 3 , 3 , 3 , 3 } ; int M = 1 , K = 3 ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << checkPattern ( arr , M , K , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc, t
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void getZarr ( string str , int Z [ ] ) { int n = str . length ( ) ; int k ; int L = 0 ; int R = 0 ; for ( int i = 1 ; i < n ; ++ i ) { if ( i > R ) { L = R = i ; while ( R < n && str [ R - L ] == str [ R ] ) { R ++ ; } Z [ i ] = R - L ; R -- ; } else { k = i - L ; if ( Z [ k ] < R - i + 1 ) { Z [ i ] = Z [ k ] ; } else { L = i ; while ( R < n && str [ R - L ] == str [ R ] ) { R ++ ; } Z [ i ] = R - L ; R -- ; } } } } string goodStr ( string str , string word ) { string concat = word + " $ " + str ; int l = concat . length ( ) ; int Z [ l ] ; getZarr ( concat , Z ) ; string res ; int pSize = word . size ( ) ; for ( int i = 0 ; i < l ; ++ i ) { if ( i + pSize < l - 1 && Z [ i + pSize + 1 ] == pSize ) { i += pSize - 1 ; } else if ( i < str . length ( ) ) { res += str [ i ] ; } } return res ; } int main ( ) { string str = " Z - kmalgorithmkmiskmkmkmhelpfulkminkmsearching " ; string word = " km " ; cout << goodStr ( str , word ) ; return 0 ; }

Index/key variables: R, i, k, l
Accumulator variables: R, i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findOccurrences ( string S , string T ) { int n1 = S . size ( ) ; int n2 = T . size ( ) ; int ans = 0 ; int last = 0 ; for ( int i = 0 ; i <= n1 - n2 ; i ++ ) { bool chk = true ; for ( int j = 0 ; j < n2 ; j ++ ) { if ( T [ j ] != S [ i + j ] ) { chk = false ; break ; } } if ( chk ) { ans += ( i + 1 - last ) * ( n1 - ( i + n2 - 1 ) ) ; last = i + 1 ; } } cout << ans ; } int main ( ) { string S = " dabc " , T = " ab " ; findOccurrences ( S , T ) ; }

Index/key variables: j
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
Boolean variables: chk
C++ program:
#include <bits/stdc++.h>
using namespace std ; void LargestArray ( int N , int low , int high ) { int high_index = N - ( high - low + 1 ) ; if ( high_index > ( N - 1 ) / 2 ) { cout << " Not ▁ Possible " ; return ; } if ( high_index <= 0 ) high_index = 1 ; int A [ N ] ; int temp = high ; for ( int i = high_index ; i >= 0 ; i -- ) { A [ i ] = temp -- ; } high -= 1 ; for ( int i = high_index + 1 ; i < N ; i ++ ) A [ i ] = high -- ; for ( int i = 0 ; i < N ; i ++ ) { cout << A [ i ] << ' ▁ ' ; } } int main ( ) { int N = 5 , low = 2 , high = 6 ; LargestArray ( N , low , high ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: high, i, stdc, temp
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printDiagonalTraversal ( vector < vector < int > > & nums ) { int max_size = nums . size ( ) ; for ( int i = 0 ; i < nums . size ( ) ; i ++ ) { if ( max_size < nums [ i ] . size ( ) ) { max_size = nums [ i ] . size ( ) ; } } vector < vector < int > > v ( 2 * max_size - 1 ) ; for ( int i = 0 ; i < nums . size ( ) ; i ++ ) { for ( int j = 0 ; j < nums [ i ] . size ( ) ; j ++ ) { v [ i + j ] . push_back ( nums [ i ] [ j ] ) ; } } for ( int i = 0 ; i < v . size ( ) ; i ++ ) { reverse ( v [ i ] . begin ( ) , v [ i ] . end ( ) ) ; for ( int j = 0 ; j < v [ i ] . size ( ) ; j ++ ) cout << v [ i ] [ j ] << " ▁ " ; } } int main ( ) { vector < vector < int > > arr = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; printDiagonalTraversal ( arr ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void isValid ( string s ) { int n = sqrt ( s . length ( ) ) ; char check = s [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = i , y = i ; while ( x >= 0 && y < n ) { if ( s [ ( n * x ) + y ] != check || s [ ( n * y ) + x ] != check ) { cout << " No " << endl ; return ; } x -- ; y ++ ; } } cout << " Yes " << endl ; } int main ( ) { string str = " abacdaeaafaghaia " ; isValid ( str ) ; return 0 ; }

Accumulator variables: i, stdc, x, y
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 10 ; int pref [ N ] , power [ N ] ; int toDigit ( char ch ) { return ( ch - '0' ) ; } void powerOf10 ( ) { power [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) power [ i ] = power [ i - 1 ] * 10 ; } void precomputePrefix ( string str , int n ) { pref [ 0 ] = str [ 0 ] - '0' ; for ( int i = 1 ; i < n ; i ++ ) pref [ i ] = pref [ i - 1 ] + toDigit ( str [ i ] ) ; } int triangularNumber ( int i ) { int res = i * ( i + 1 ) / 2 ; return res ; } int sumOfSubstrings ( string str ) { int n = str . size ( ) ; powerOf10 ( ) ; precomputePrefix ( str , n ) ; int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { ans += ( pref [ n - i - 2 ] * ( i + 1 ) + toDigit ( str [ n - i - 1 ] ) * triangularNumber ( n - i - 1 ) ) * power [ i ] ; } return ans ; } int main ( ) { string str = "1234" ; cout << sumOfSubstrings ( str ) ; return 0 ; }

Index/key variables: N, i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int OddLengthSum ( vector < int > & arr ) { int sum = 0 ; int l = arr . size ( ) ; for ( int i = 0 ; i < l ; i ++ ) { for ( int j = i ; j < l ; j += 2 ) { for ( int k = i ; k <= j ; k ++ ) { sum += arr [ k ] ; } } } return sum ; } int main ( ) { vector < int > arr = { 1 , 5 , 3 , 1 , 2 } ; cout << OddLengthSum ( arr ) ; return 0 ; }

Index/key variables: k
Accumulator variables: i, j, k, stdc, sum
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int OddLengthSum ( vector < int > & arr ) { int sum = 0 ; int l = arr . size ( ) ; for ( int i = 0 ; i < l ; i ++ ) { sum += ( ( ( i + 1 ) * ( l - i ) + 1 ) / 2 ) * arr [ i ] ; } return sum ; } int main ( ) { vector < int > arr = { 1 , 5 , 3 , 1 , 2 } ; cout << OddLengthSum ( arr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int phi ( int n ) { int result = 1 ; for ( int p = 2 ; p < n ; p ++ ) { if ( __gcd ( p , n ) == 1 ) { result ++ ; } } return result ; } bool sameEulerTotient ( int n ) { return phi ( n ) == phi ( 2 * n ) ; } int main ( ) { int N = 13 ; if ( sameEulerTotient ( N ) ) cout << " Yes " ; else cout << " No " ; }

Accumulator variables: p, result, stdc
Iterator variables: p
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool sameEulerTotient ( int N ) { return ( N & 1 ) ; } int main ( ) { int N = 13 ; if ( sameEulerTotient ( N ) ) cout << " Yes " ; else cout << " No " ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void solve ( int arr [ ] , int N ) { map < int , int > M ; for ( int i = 0 ; i < N ; i ++ ) { M [ i ] = arr [ i ] ; } sort ( arr , arr + N ) ; unordered_map < int , int > Count ; for ( int i = 0 ; i < N ; i ++ ) { Count [ arr [ i ] ] = pow ( 2 , N - i - 1 ) ; } for ( auto & it : M ) { cout << Count [ M [ it . second ] ] << ' ▁ ' ; } } int main ( ) { int arr [ ] = { 5 , 2 , 1 } ; int N = sizeof arr / sizeof arr [ 0 ] ; solve ( arr , N ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <string>
using namespace std ; bool checkOdd ( char ch ) { return ( ( ch - '0' ) & 1 ) ; } string Insert_dash ( string num_str ) { string result_str = num_str ; for ( int x = 0 ; x < num_str . length ( ) - 1 ; x ++ ) { if ( checkOdd ( num_str [ x ] ) && checkOdd ( num_str [ x + 1 ] ) ) { result_str . insert ( x + 1 , " - " ) ; num_str = result_str ; x ++ ; } } return result_str ; } int main ( ) { string str = "1745389" ; cout << Insert_dash ( str ) ; return 0 ; }

Index/key variables: x
Accumulator variables: x
Iterator variables: x
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int N = 3 , M = 3 ; bool checkReverseBitonic ( int arr [ ] , int n ) { int i , j , f = 0 ; for ( i = 1 ; i < n ; i ++ ) { if ( arr [ i ] < arr [ i - 1 ] ) continue ; if ( arr [ i ] == arr [ i - 1 ] ) return false ; else { f = 1 ; break ; } } if ( i == n ) return true ; for ( j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] > arr [ j - 1 ] ) continue ; if ( arr [ i ] == arr [ i - 1 ] ) return false ; else { if ( f == 1 ) return false ; } } return true ; } void check ( int arr [ N ] [ M ] ) { int f = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ! checkReverseBitonic ( arr [ i ] , M ) ) { cout << " No " << endl ; return ; } } for ( int i = 0 ; i < N ; i ++ ) { int temp [ N ] ; for ( int j = 0 ; j < N ; j ++ ) { temp [ j ] = arr [ j ] [ i ] ; } if ( ! checkReverseBitonic ( temp , N ) ) { cout << " No " << endl ; return ; } } cout << " Yes " ; } int main ( ) { int m [ N ] [ M ] = { { 2 , 3 , 4 } , { 1 , 2 , 3 } , { 4 , 5 , 6 } } ; check ( m ) ; return 0 ; }

Index/key variables: M, N, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int SpiralElement ( int x , int y ) { int r ; if ( x < y ) { if ( y % 2 == 1 ) { r = y * y ; return ( r - x + 1 ) ; } else { r = ( y - 1 ) * ( y - 1 ) ; return ( r + x ) ; } } else { if ( x % 2 == 0 ) { r = x * x ; return ( r - y + 1 ) ; } else { r = ( x - 1 ) * ( x - 1 ) ; return ( r + y ) ; } } } int main ( ) { int x = 2 , y = 3 ; cout << SpiralElement ( x , y ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void string_modify ( string s ) { char alphabets [ 26 ] ; int flag = 0 , hold_i ; char hold_l ; int i ; for ( i = 0 ; i < 26 ; i ++ ) { alphabets [ i ] = i + ' a ' ; } set < int > difference ; string reconstruct = " " ; for ( int i = 1 ; i < s . size ( ) ; i ++ ) { difference . insert ( s [ i ] - s [ i - 1 ] ) ; } if ( difference . size ( ) == 1 ) { cout << " No ▁ modifications ▁ required " ; return ; } for ( auto it = difference . begin ( ) ; it != difference . end ( ) ; it ++ ) { int index = s [ 0 ] - ' a ' ; reconstruct = " " ; flag = 0 ; for ( int i = 0 ; i < s . size ( ) && flag <= 1 ; i ++ ) { reconstruct += alphabets [ index ] ; index += * it ; if ( index < 0 ) { index += 26 ; } index %= 26 ; if ( reconstruct [ i ] != s [ i ] ) { flag ++ ; hold_i = i ; hold_l = s [ i ] ; } } if ( flag == 1 ) { s [ hold_i ] = reconstruct [ hold_i ] ; break ; } } if ( flag > 1 ) { hold_i = 0 ; hold_l = s [ 0 ] ; int temp = ( s [ 1 ] - ' a ' - ( s [ 2 ] - s [ 1 ] ) ) % 26 ; if ( temp < 0 ) { temp += 26 ; } s [ 0 ] = alphabets [ temp ] ; } cout << hold_i << " ▁ - > ▁ " << hold_l << endl << s << endl ; } int main ( ) { string s = " aeimqux " ; string_modify ( s ) ; }

Index/key variables: hold_i, i, index, temp
Accumulator variables: flag, i, index, it, reconstruct, stdc, temp
Iterator variables: i, it
C++ program:
#include <iostream>
using namespace std ; void evenSubMatrix ( int N ) { int even = 1 ; int odd = 2 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( ( i + j ) % 2 == 0 ) { cout << even << " ▁ " ; even += 2 ; } else { cout << odd << " ▁ " ; odd += 2 ; } } cout << " STRNEWLINE " ; } } int main ( ) { int N = 4 ; evenSubMatrix ( N ) ; return 0 ; }

Accumulator variables: even, i, j, odd
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximum_inversion ( int n , int k ) { int answer = 0 ; k = min ( k , n / 2 ) ; int left = 1 ; int right = n ; while ( k -- ) { answer += 2 * ( right - left ) - 1 ; left ++ ; right -- ; } cout << answer << endl ; } int main ( ) { int N = 5 ; int K = 3 ; maximum_inversion ( N , K ) ; N = 4 ; K = 1 ; maximum_inversion ( N , K ) ; return 0 ; }

Accumulator variables: answer, k, left, right, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getFirstSetBitPos ( int n ) { return log2 ( n & - n ) + 1 ; } int oddFirst ( int a , int b ) { int steps_a = getFirstSetBitPos ( a ) ; int steps_b = getFirstSetBitPos ( b ) ; if ( steps_a == steps_b ) { return -1 ; } if ( steps_a > steps_b ) { return b ; } if ( steps_a < steps_b ) { return a ; } } int main ( ) { int a = 10 ; int b = 8 ; cout << oddFirst ( a , b ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool helper ( string & s , int pos ) { int len = s . size ( ) ; if ( pos >= len ) return true ; if ( ! isdigit ( s [ pos ] ) ) return false ; int num = 0 ; for ( int i = pos ; i < len ; i ++ ) { num = num * 10 + s [ pos ] - '0' ; if ( i + 1 + num > len ) return false ; if ( helper ( s , i + 1 + num ) ) return true ; } return false ; } int main ( ) { string s = "123abc4db1c " ; if ( helper ( s , 0 ) ) cout << " Yes " ; else cout << " No " ; }

Index/key variables: pos
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long N_bonacci [ 100 ] ; void N_bonacci_nums ( int n , int k ) { N_bonacci [ 0 ] = 1 ; for ( int i = 1 ; i <= 50 ; ++ i ) { for ( int j = i - 1 ; j >= i - k and j >= 0 ; -- j ) N_bonacci [ i ] += N_bonacci [ j ] ; } vector < long long > ans ; for ( int i = 50 ; i >= 0 ; -- i ) if ( n - N_bonacci [ i ] >= 0 ) { ans . push_back ( N_bonacci [ i ] ) ; n -= N_bonacci [ i ] ; } if ( ans . size ( ) == 1 ) ans . push_back ( 0 ) ; cout << ans . size ( ) << endl ; for ( int i = 0 ; i < ans . size ( ) ; ++ i ) cout << ans [ i ] << " , ▁ " ; } int main ( ) { int n = 21 , k = 5 ; N_bonacci_nums ( n , k ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: n, stdc
Iterator variables: i, j