dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countStrings ( string s , int k ) { int ans = 1 ; int len = s . size ( ) ; int flag = 0 ; int start_ind ; for ( int i = 0 ; i < len - 1 ; i ++ ) { if ( s [ i ] - '0' + s [ i + 1 ] - '0' == k && flag == 0 ) { flag = 1 ; start_ind = i ; } if ( flag == 1 && s [ i ] - '0' + s [ i + 1 ] - '0' != k ) { flag = 0 ; if ( ( i - start_ind + 1 ) % 2 != 0 ) ans *= ( i - start_ind + 1 - 1 ) / 2 + 1 ; } } if ( flag == 1 && ( len - start_ind ) % 2 != 0 ) ans *= ( len - start_ind ) / 2 + 1 ; cout << ans ; } int main ( ) { string S = "313" ; int K = 4 ; countStrings ( S , K ) ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void find_num ( string n ) { int ans = 0 ; int sumOfDigitsN = 0 ; for ( int c = 0 ; c < n . length ( ) ; c ++ ) { sumOfDigitsN += n - '0' ; } int x = 11 ; while ( true ) { int newNum = x * stoi ( n ) ; int tempSumDigits = 0 ; string temp = to_string ( newNum ) ; for ( int c = 0 ; c < temp . length ( ) ; c ++ ) { tempSumDigits += temp - '0' ; } if ( tempSumDigits == sumOfDigitsN ) { ans = x ; break ; } x ++ ; } cout << ans << endl ; } int main ( ) { string N = "3029" ; find_num ( N ) ; return 0 ; }

Accumulator variables: c, sumOfDigitsN, tempSumDigits, x
Iterator variables: c
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findDisStr ( vector < string > & arr , int N ) { unordered_set < string > DistString ; for ( int i = 0 ; i < N ; i ++ ) { if ( ! DistString . count ( arr [ i ] ) ) { DistString . insert ( arr [ i ] ) ; } } for ( auto String : DistString ) { cout << String << " ▁ " ; } } int main ( ) { vector < string > arr = { " Geeks " , " For " , " Geeks " , " Code " , " Coder " } ; int N = arr . size ( ) ; findDisStr ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: String, i
C++ program:
#include <iostream>
using namespace std ; string modifyString ( int A [ ] , string str , int K ) { int N = str . size ( ) ; int count [ N + 1 ] = { 0 } ; for ( int i = 0 ; i < K ; i ++ ) { count [ A [ i ] ] ++ ; } for ( int i = 1 ; i <= N / 2 ; i ++ ) { count [ i ] = count [ i ] + count [ i - 1 ] ; if ( count [ i ] & 1 ) { swap ( str [ i - 1 ] , str [ N - i ] ) ; } } return str ; } int main ( ) { string str = " abcdef " ; int arr [ ] = { 1 , 2 , 3 } ; int K = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << modifyString ( arr , str , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findFraction ( string s ) { string be_deci = " " , af_deci = " " , reccu = " " ; bool x = true , y = false , z = false ; for ( int i = 0 ; i < s . size ( ) ; ++ i ) { if ( s [ i ] == ' . ' ) { x = false ; y = true ; continue ; } if ( s [ i ] == ' ( ' ) { z = true ; y = false ; continue ; } if ( x ) be_deci += s [ i ] ; if ( y ) af_deci += s [ i ] ; if ( z ) { for ( ; i < s . size ( ) && s [ i ] != ' ) ' ; ++ i ) reccu += s [ i ] ; break ; } } int num_be_deci = stoi ( be_deci ) ; int num_af_deci = 0 ; if ( af_deci . size ( ) != 0 ) num_af_deci = stoi ( af_deci ) ; int numr = num_be_deci * pow ( 10 , af_deci . size ( ) ) + num_af_deci ; int deno = pow ( 10 , af_deci . size ( ) ) ; if ( reccu . size ( ) == 0 ) { int gd = __gcd ( numr , deno ) ; cout << numr / gd << " ▁ / ▁ " << deno / gd ; } else { int reccu_num = stoi ( reccu ) ; int numr1 = numr * pow ( 10 , reccu . size ( ) ) + reccu_num ; int deno1 = deno * pow ( 10 , reccu . size ( ) ) ; int res_numr = numr1 - numr , res_deno = deno1 - deno ; int gd = __gcd ( res_numr , res_deno ) ; cout << res_numr / gd << " ▁ / ▁ " << res_deno / gd ; } } int main ( ) { string str = "23.98(231 ) " ; findFraction ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: af_deci, be_deci, reccu, stdc
Iterator variables: i
Boolean variables: x, y, z
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool lexi_largest_String ( int a [ ] , int i , int sum , vector < int > & v ) { if ( sum < 0 ) return false ; if ( sum == 0 ) return true ; if ( i < 0 ) return false ; v . push_back ( i ) ; if ( lexi_largest_String ( a , i , sum - a [ i ] , v ) ) return true ; auto it = v . end ( ) ; it -- ; v . erase ( it ) ; return lexi_largest_String ( a , i - 1 , sum , v ) ; } void generateString ( int a [ ] , int sum ) { vector < int > v ; lexi_largest_String ( a , 25 , sum , v ) ; string s = " " ; for ( int j = 0 ; j < v . size ( ) ; j ++ ) s += ( char ) ( v [ j ] + ' a ' ) ; cout << s << endl ; } int main ( ) { int a [ ] = { 1 , 1 , 2 , 33 , 4 , 6 , 9 , 7 , 36 , 32 , 58 , 32 , 28 , 904 , 22 , 255 , 47 , 69 , 558 , 544 , 21 , 36 , 48 , 85 , 48 , 58 } ; int sum = 236 ; generateString ( a , sum ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: it, j, s, stdc
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
#include <iostream>
using namespace std ; int fact ( int a ) { int i , f = 1 ; for ( i = 2 ; i <= a ; i ++ ) f = f * i ; return f ; } int permute ( int n , int r ) { int ans = 0 ; ans = ( fact ( n ) / fact ( n - r ) ) ; return ans ; } int findPermutations ( int n ) { int sum = 0 , P ; for ( int r = 1 ; r <= n ; r ++ ) { P = permute ( n , r ) ; sum = sum + P ; } return sum ; } int main ( ) { string str = " xz " ; int result , n ; n = str . length ( ) ; cout << findPermutations ( n ) ; return 0 ; }

Accumulator variables: i, r, stdc
Iterator variables: i, r
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int V = 5 ; void DFS ( bool graph [ ] [ V ] , bool marked [ ] , int n , int vert , int start , int & count ) { marked [ vert ] = true ; if ( n == 0 ) { marked [ vert ] = false ; if ( graph [ vert ] [ start ] ) { count ++ ; return ; } else return ; } for ( int i = 0 ; i < V ; i ++ ) if ( ! marked [ i ] && graph [ vert ] [ i ] ) DFS ( graph , marked , n - 1 , i , start , count ) ; marked [ vert ] = false ; } int countCycles ( bool graph [ ] [ V ] , int n ) { bool marked [ V ] ; memset ( marked , 0 , sizeof ( marked ) ) ; int count = 0 ; for ( int i = 0 ; i < V - ( n - 1 ) ; i ++ ) { DFS ( graph , marked , n - 1 , i , i , count ) ; marked [ i ] = true ; } return count / 2 ; } int main ( ) { bool graph [ ] [ V ] = { { 0 , 1 , 0 , 1 , 0 } , { 1 , 0 , 1 , 0 , 1 } , { 0 , 1 , 0 , 1 , 0 } , { 1 , 0 , 1 , 0 , 1 } , { 0 , 1 , 0 , 1 , 0 } } ; int n = 4 ; cout << " Total ▁ cycles ▁ of ▁ length ▁ " << n << " ▁ are ▁ " << countCycles ( graph , n ) ; return 0 ; }

Index/key variables: V, i, start, vert
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long polynomialRollingHash ( string const & str ) { int p = 31 ; int m = 1e9 + 9 ; long long power_of_p = 1 ; long long hash_val = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { hash_val = ( hash_val + ( str [ i ] - ' a ' + 1 ) * power_of_p ) % m ; power_of_p = ( power_of_p * p ) % m ; } return ( hash_val % m + m ) % m ; } int main ( ) { string str1 = " geeksforgeeks " ; string str2 = " geeks " ; cout << " Hash ▁ of ▁ ' " << str1 << " ' ▁ = ▁ " << polynomialRollingHash ( str1 ) ; cout << endl ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void firstNonRepElement ( string str ) { map < char , int > mpp ; for ( auto i : str ) { mpp [ i ] ++ ; } for ( auto i : str ) { if ( mpp [ i ] == 1 ) { cout << i << endl ; return ; } } return ; } int main ( ) { string str = " geeksforgeeks " ; firstNonRepElement ( str ) ; }

Index/key variables: i
Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubstrings ( string str , int K ) { int N = str . size ( ) ; int answer = 0 ; unordered_map < char , int > map ; for ( int i = 0 ; i < K ; i ++ ) { map [ str [ i ] ] ++ ; } if ( map . size ( ) == K ) answer ++ ; for ( int i = K ; i < N ; i ++ ) { map [ str [ i ] ] ++ ; map [ str [ i - K ] ] -- ; if ( map [ str [ i - K ] ] == 0 ) { map . erase ( str [ i - K ] ) ; } if ( map . size ( ) == K ) { answer ++ ; } } return answer ; } int main ( ) { string str = " aabcdabbcdc " ; int K = 3 ; cout << countSubstrings ( str , K ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: answer, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; unordered_map < string , bool > mp ; bool isScramble ( string S1 , string S2 ) { if ( S1 . length ( ) != S2 . length ( ) ) { return false ; } int n = S1 . length ( ) ; if ( n == 0 ) { return true ; } if ( S1 == S2 ) { return true ; } string copy_S1 = S1 , copy_S2 = S2 ; sort ( copy_S1 . begin ( ) , copy_S1 . end ( ) ) ; sort ( copy_S2 . begin ( ) , copy_S2 . end ( ) ) ; if ( copy_S1 != copy_S2 ) { return false ; } string key = ( S1 + " ▁ " + S2 ) ; if ( mp . find ( key ) != mp . end ( ) ) { return mp [ key ] ; } bool flag = false ; for ( int i = 1 ; i < n ; i ++ ) { if ( isScramble ( S1 . substr ( 0 , i ) , S2 . substr ( 0 , i ) ) && isScramble ( S1 . substr ( i , n - i ) , S2 . substr ( i , n - i ) ) ) { flag = true ; return true ; } if ( isScramble ( S1 . substr ( 0 , i ) , S2 . substr ( n - i , i ) ) && isScramble ( S1 . substr ( i , n - i ) , S2 . substr ( 0 , n - i ) ) ) { flag = true ; return true ; } } mp [ key ] = flag ; return false ; } int main ( ) { string S1 = " coder " ; string S2 = " ocred " ; if ( isScramble ( S1 , S2 ) ) { cout << " Yes " ; } else { cout << " No " ; } return 0 ; }

Index/key variables: key
Accumulator variables: i, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void LongestPalindromicPrefix ( string s ) { int n = s . length ( ) ; int max_len = 0 ; for ( int len = 1 ; len <= n ; len ++ ) { string temp = s . substr ( 0 , len ) ; string temp2 = temp ; reverse ( temp2 . begin ( ) , temp2 . end ( ) ) ; if ( temp == temp2 ) { max_len = len ; } } cout << s . substr ( 0 , max_len ) ; } int main ( ) { string str = " abaab " ; LongestPalindromicPrefix ( str ) ; }

Accumulator variables: len, stdc
Iterator variables: len
C++ program:
#include <bits/stdc++.h>
using namespace std ; string find_kth_String_of_n ( int n , int k ) { int d [ n ] = { 0 } ; for ( int i = n - 1 ; i > -1 ; i -- ) { d [ i ] = k % 26 ; k /= 26 ; } if ( k > 0 ) return " - 1" ; string s = " " ; for ( int i = 0 ; i < n ; i ++ ) s += ( d [ i ] + ( ' a ' ) ) ; return s ; } int main ( ) { int n = 3 ; int k = 10 ; k -= 1 ; cout << find_kth_String_of_n ( n , k ) ; return 0 ; }

Index/key variables: i, n
Accumulator variables: i, k, s, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinLength ( string s ) { int n = s . size ( ) ; map < char , int > counts ; vector < int > indices ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' a ' s [ i ] == ' e ' s [ i ] == ' o ' s [ i ] == ' i ' s [ i ] == ' u ' ) { counts [ s [ i ] ] ++ ; indices . push_back ( i ) ; } } if ( counts . size ( ) < 5 ) return -1 ; int flag1 = 0 , flag2 = 0 ; int i = 0 ; int j = indices . size ( ) - 1 ; while ( ( j - i ) >= 4 ) { if ( ! flag1 && counts [ s [ indices [ i ] ] ] > 1 ) { counts [ s [ indices [ i ] ] ] -- ; i ++ ; } else flag1 = 1 ; if ( ! flag2 && counts [ s [ indices [ j ] ] ] > 1 ) { counts [ s [ indices [ j ] ] ] -- ; j -- ; } else flag2 = 1 ; if ( flag1 && flag2 ) break ; } return ( indices [ j ] - indices [ i ] + 1 ) ; } int main ( ) { string s = " aaeebbeaccaaoiuooooooooiuu " ; cout << findMinLength ( s ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isConsonants ( char x ) { x = tolower ( x ) ; return ! ( x == ' a ' x == ' e ' x == ' i ' x == ' o ' x == ' u ' ) ; } string longestConsonantsSubsequence ( string str ) { string answer = " " ; int n = str . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( isConsonants ( str [ i ] ) ) { answer += str [ i ] ; } } return answer ; } int main ( ) { string str = " geeksforgeeks " ; cout << longestConsonantsSubsequence ( str ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: answer, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int lengthOfSubsequence ( string str , int K ) { map < char , int > mp ; for ( char ch : str ) { mp [ ch ] ++ ; } int minimum = mp [ ' A ' ] ; for ( int i = 1 ; i < K ; i ++ ) { minimum = min ( minimum , mp [ ( char ) ( i + ' A ' ) ] ) ; } return minimum * K ; } int main ( ) { string str = " ACAABCCAB " ; int K = 3 ; cout << lengthOfSubsequence ( str , K ) ; return 0 ; }

Index/key variables: ch
Accumulator variables: i, stdc
Iterator variables: ch, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define V  4
void printSolution ( int dist [ ] [ V ] ) ; #define INF  99999
bool negCyclefloydWarshall ( int graph [ ] [ V ] ) { int dist [ V ] [ V ] , i , j , k ; for ( i = 0 ; i < V ; i ++ ) for ( j = 0 ; j < V ; j ++ ) dist [ i ] [ j ] = graph [ i ] [ j ] ; for ( k = 0 ; k < V ; k ++ ) { for ( i = 0 ; i < V ; i ++ ) { for ( j = 0 ; j < V ; j ++ ) { if ( dist [ i ] [ k ] + dist [ k ] [ j ] < dist [ i ] [ j ] ) dist [ i ] [ j ] = dist [ i ] [ k ] + dist [ k ] [ j ] ; } } } for ( int i = 0 ; i < V ; i ++ ) if ( dist [ i ] [ i ] < 0 ) return true ; return false ; } int main ( ) { int graph [ V ] [ V ] = { { 0 , 1 , INF , INF } , { INF , 0 , -1 , INF } , { INF , INF , 0 , -1 } , { -1 , INF , INF , 0 } } ; if ( negCyclefloydWarshall ( graph ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: V, i, j, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <iostream>
using namespace std ; string convertToString ( int sum ) { string str = " " ; while ( sum ) { str = str + ( char ) ( ( sum % 10 ) + '0' ) ; sum = sum / 10 ; } return str ; } string GetIndividulaDigitSum ( string str , int len ) { int sum = 0 ; for ( int i = 0 ; i < len ; i ++ ) { sum = sum + str [ i ] - '0' ; } return convertToString ( sum ) ; } int GetDigitalRoot ( string str ) { if ( str . length ( ) == 1 ) { return str [ 0 ] - '0' ; } str = GetIndividulaDigitSum ( str , str . length ( ) ) ; return GetDigitalRoot ( str ) ; } int main ( ) { string str = "675987890789756545689070986776987" ; cout << GetDigitalRoot ( str ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void count ( string str1 , string str2 ) { int c = 0 , j = 0 ; for ( int i = 0 ; i < str1 . length ( ) ; i ++ ) { if ( str2 . find ( str1 [ i ] ) >= 0 and j == str1 . find ( str1 [ i ] ) ) c += 1 ; j += 1 ; } cout << " No . ▁ of ▁ matching ▁ characters ▁ are : ▁ " << c / 2 ; } int main ( ) { string str1 = " aabcddekll12 @ " ; string str2 = " bb2211@55k " ; count ( str1 , str2 ) ; }

Index/key variables: i
Accumulator variables: c, i, j, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int countOfLetters ( string str ) { int letter = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) || ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) ) letter ++ ; } return letter ; } int countOfNumbers ( string str ) { int number = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] >= '0' && str [ i ] <= '9' ) number ++ ; } return number ; } void check ( string str ) { if ( countOfLetters ( str ) == countOfNumbers ( str ) ) cout << " Yes STRNEWLINE " ; else cout << " No STRNEWLINE " ; } int main ( ) { string str = " GeeKs01324" ; check ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, letter, number
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findMinCost ( string s , int i , int j ) { vector < vector < int > > gr ( 26 ) ; bool edge [ 26 ] [ 26 ] ; for ( int k = 0 ; k < 26 ; k ++ ) for ( int l = 0 ; l < 26 ; l ++ ) edge [ k ] [ l ] = 0 ; for ( int k = 0 ; k < s . size ( ) ; k ++ ) { if ( k - 1 >= 0 and ! edge [ s [ k ] - 97 ] [ s [ k - 1 ] - 97 ] ) gr [ s [ k ] - 97 ] . push_back ( s [ k - 1 ] - 97 ) , edge [ s [ k ] - 97 ] [ s [ k - 1 ] - 97 ] = 1 ; if ( k + 1 <= s . size ( ) - 1 and ! edge [ s [ k ] - 97 ] [ s [ k + 1 ] - 97 ] ) gr [ s [ k ] - 97 ] . push_back ( s [ k + 1 ] - 97 ) , edge [ s [ k ] - 97 ] [ s [ k + 1 ] - 97 ] = 1 ; } queue < int > q ; q . push ( s [ i ] - 97 ) ; bool v [ 26 ] = { 0 } ; int d = 0 ; while ( q . size ( ) ) { int cnt = q . size ( ) ; while ( cnt -- ) { int curr = q . front ( ) ; q . pop ( ) ; if ( v [ curr ] ) continue ; v [ curr ] = 1 ; if ( curr == s [ j ] - 97 ) return d ; for ( auto it : gr [ curr ] ) q . push ( it ) ; } d ++ ; } return -1 ; } int main ( ) { string s = " abcde " ; int i = 0 ; int j = 4 ; cout << findMinCost ( s , i , j ) ; }

Index/key variables: curr, i, j, k, l
Accumulator variables: cnt, d, k, l, stdc
Iterator variables: it, k, l
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool twoColorUtil ( vector < int > G [ ] , int src , int N , int colorArr [ ] ) { colorArr [ src ] = 1 ; queue < int > q ; q . push ( src ) ; while ( ! q . empty ( ) ) { int u = q . front ( ) ; q . pop ( ) ; for ( int v = 0 ; v < G [ u ] . size ( ) ; ++ v ) { if ( colorArr [ G [ u ] [ v ] ] == -1 ) { colorArr [ G [ u ] [ v ] ] = 1 - colorArr [ u ] ; q . push ( G [ u ] [ v ] ) ; } else if ( colorArr [ G [ u ] [ v ] ] == colorArr [ u ] ) return false ; } } return true ; } bool twoColor ( vector < int > G [ ] , int N ) { int colorArr [ N ] ; for ( int i = 1 ; i <= N ; ++ i ) colorArr [ i ] = -1 ; for ( int i = 1 ; i <= N ; i ++ ) if ( colorArr [ i ] == -1 ) if ( twoColorUtil ( G , i , N , colorArr ) == false ) return false ; return true ; } bool isOddSum ( int info [ ] [ 3 ] , int n , int m ) { vector < int > G [ 2 * n ] ; int pseudo = n + 1 ; int pseudo_count = 0 ; for ( int i = 0 ; i < m ; i ++ ) { if ( info [ i ] [ 2 ] % 2 == 1 ) { int u = info [ i ] [ 0 ] ; int v = info [ i ] [ 1 ] ; G [ u ] . push_back ( v ) ; G [ v ] . push_back ( u ) ; } else { int u = info [ i ] [ 0 ] ; int v = info [ i ] [ 1 ] ; G [ u ] . push_back ( pseudo ) ; G [ pseudo ] . push_back ( u ) ; G [ v ] . push_back ( pseudo ) ; G [ pseudo ] . push_back ( v ) ; pseudo_count ++ ; pseudo ++ ; } } return twoColor ( G , n + pseudo_count ) ; } int main ( ) { int n = 4 , m = 3 ; int info [ 4 ] [ 3 ] = { { 1 , 2 , 12 } , { 2 , 3 , 1 } , { 4 , 3 , 1 } , { 4 , 1 , 20 } } ; if ( isOddSum ( info , n , m ) == true ) cout << " No STRNEWLINE " ; else cout << " Yes STRNEWLINE " ; return 0 ; }

Index/key variables: N, i, pseudo, src, u, v
Accumulator variables: i, pseudo, pseudo_count, stdc
Iterator variables: i, v
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 26 ; void performQueries ( string str , int q , int type [ ] , char ch [ ] , int freq [ ] ) { int n = str . length ( ) ; int L [ MAX ] [ n ] ; int F [ MAX ] [ n ] ; int cnt [ MAX ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { int k = str [ i ] - ' a ' ; cnt [ k ] ++ ; for ( int j = 0 ; j < MAX ; j ++ ) { if ( k == j ) { L [ j ] [ cnt [ j ] ] = i ; F [ j ] [ cnt [ j ] ] = i ; } else L [ j ] [ cnt [ j ] ] = L [ j ] [ cnt [ j ] ] + 1 ; } } for ( int i = 0 ; i < q ; i ++ ) { if ( type [ i ] == 1 ) { cout << L [ ch [ i ] - ' a ' ] [ freq [ i ] ] ; } else { cout << F [ ch [ i ] - ' a ' ] [ freq [ i ] ] ; } cout << " STRNEWLINE " ; } } int main ( ) { string str = " geeksforgeeks " ; int type [ ] = { 1 , 2 } ; char ch [ ] = { ' e ' , ' k ' } ; int freq [ ] = { 2 , 2 } ; int q = sizeof ( type ) / sizeof ( int ) ; performQueries ( str , q , type , ch , freq ) ; return 0 ; }

Index/key variables: MAX, i, j, k, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int anagram_pairs ( vector < string > s , int n ) { map < string , int > mp ; for ( int i = 0 ; i < n ; i ++ ) { sort ( s [ i ] . begin ( ) , s [ i ] . end ( ) ) ; mp [ s [ i ] ] ++ ; } int ans = 0 ; for ( auto i = mp . begin ( ) ; i != mp . end ( ) ; i ++ ) { int k = i -> second ; ans += ( k * ( k - 1 ) ) / 2 ; } return ans ; } int main ( ) { vector < string > s = { " aaab " , " aaba " , " baaa " , " cde " , " dec " } ; int n = s . size ( ) ; cout << anagram_pairs ( s , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char Insert ( char arr [ ] , int n , int k ) { int ind = 0 ; int sz = 0 ; string s = " " ; char ch = arr [ 0 ] ; s += ch ; sz = 1 ; ind = 0 ; for ( int i = 1 ; i < n ; i ++ ) { ch = arr [ i ] ; string s1 = s . substr ( 0 , ind + 1 ) ; int temp = k % sz ; int ro = temp - min ( temp , sz - ind - 1 ) ; if ( ro == 0 ) { string s2 = s . substr ( ind + 1 , temp ) ; string s3 = s . substr ( ind + temp + 1 , sz - ind - temp - 1 ) ; s = s1 + s2 + ch + s3 ; ind = s1 . size ( ) + s2 . size ( ) ; sz = s . size ( ) ; } else { string s2 = s . substr ( 0 , ro ) ; string s3 = s . substr ( ro , sz - ro ) ; s = s2 + ch + s3 ; ind = s2 . size ( ) ; sz = s . size ( ) ; } } if ( ind == 0 ) return s [ sz - 1 ] ; else return s [ ind - 1 ] ; } int main ( ) { char arr [ ] = { '1' , '2' , '3' , '4' , '5' } ; int k = 2 ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << Insert ( arr , n , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, s, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  100005
char ans [ N ] ; int sieve [ N ] ; void Rearrange ( string s , int n ) { fill ( sieve + 1 , sieve + n + 1 , 1 ) ; int sz = 0 ; for ( int i = 2 ; i <= n / 2 ; i ++ ) { if ( sieve [ i ] ) { for ( int j = 1 ; i * j <= n ; j ++ ) { if ( sieve [ i * j ] ) sz ++ ; sieve [ i * j ] = 0 ; } } } map < char , int > m ; for ( auto it : s ) m [ it ] ++ ; vector < pair < int , char > > v ; for ( auto it : m ) v . push_back ( { it . second , it . first } ) ; sort ( v . begin ( ) , v . end ( ) ) ; if ( v . back ( ) . first < sz ) { cout << -1 ; return ; } for ( int i = 2 ; i <= n ; i ++ ) { if ( ! sieve [ i ] ) { ans [ i ] = v . back ( ) . second ; } } int idx = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( sieve [ i ] ) { ans [ i ] = v [ idx ] . second ; v [ idx ] . first -- ; if ( v [ idx ] . first == 0 ) idx ++ ; } cout << ans [ i ] ; } } int main ( ) { string str = " aabaaaa " ; int n = str . size ( ) ; Rearrange ( str , n ) ; return 0 ; }

Index/key variables: N, i, idx, it
Accumulator variables: first, i, idx, j, stdc, sz
Iterator variables: i, it, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isCycleRec ( int v , vector < int > adj [ ] , vector < bool > & visited , vector < bool > & recur ) { visited [ v ] = true ; recur [ v ] = true ; for ( int i = 0 ; i < adj [ v ] . size ( ) ; i ++ ) { if ( visited [ adj [ v ] [ i ] ] == false ) { if ( isCycleRec ( adj [ v ] [ i ] , adj , visited , recur ) ) return true ; } else if ( visited [ adj [ v ] [ i ] ] == true && recur [ adj [ v ] [ i ] ] == true ) return true ; } recur [ v ] = false ; return false ; } bool isCycle ( int arr [ ] , int n ) { vector < int > adj [ n ] ; for ( int i = 0 ; i < n ; i ++ ) if ( i != ( i + arr [ i ] + n ) % n ) adj [ i ] . push_back ( ( i + arr [ i ] + n ) % n ) ; vector < bool > visited ( n , false ) ; vector < bool > recur ( n , false ) ; for ( int i = 0 ; i < n ; i ++ ) if ( visited [ i ] == false ) if ( isCycleRec ( i , adj , visited , recur ) ) return true ; return true ; } int main ( void ) { int arr [ ] = { 2 , -1 , 1 , 2 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; if ( isCycle ( arr , n ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

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