dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; string getSmallestStr ( string S , int K ) { string X = " " ; priority_queue < char , vector < char > , greater < char > > pq ; int i , n = S . length ( ) ; K = min ( K , n ) ; for ( i = 0 ; i < K ; i ++ ) pq . push ( S [ i ] ) ; while ( ! pq . empty ( ) ) { X += pq . top ( ) ; pq . pop ( ) ; if ( i < S . length ( ) ) pq . push ( S [ i ] ) ; i ++ ; } return X ; } int main ( ) { string S = " geeksforgeeks " ; int K = 5 ; cout << getSmallestStr ( S , K ) ; return 0 ; }

Index/key variables: i
Accumulator variables: X, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void roundToNearest ( string str , int n ) { if ( str == " " ) return ; if ( str [ n - 1 ] - '0' <= 5 ) { str [ n - 1 ] = '0' ; cout << str . substr ( 0 , n ) ; } else { int carry = 0 ; str [ n - 1 ] = '0' ; int i = n - 2 ; carry = 1 ; while ( i >= 0 && carry == 1 ) { int currentDigit = str [ i ] - '0' ; currentDigit += carry ; if ( currentDigit > 9 ) { carry = 1 ; currentDigit = 0 ; } else carry = 0 ; str [ i ] = ( char ) ( currentDigit + '0' ) ; i -- ; } if ( carry == 1 ) cout << carry ; cout << str . substr ( 0 , n ) ; } } int main ( ) { string str = "99999999999999993" ; int n = str . length ( ) ; roundToNearest ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: currentDigit, i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isDigit ( char ch ) { if ( ch >= '0' && ch <= '9' ) return true ; return false ; } int nextNonDigit ( string str , int i ) { while ( i < str . length ( ) && isDigit ( str [ i ] ) ) { i ++ ; } if ( i >= str . length ( ) ) return -1 ; return i ; } void appendRepeated ( string & sb , string str , int times ) { for ( int i = 0 ; i < times ; i ++ ) sb . append ( str ) ; } string findString ( string str , int n ) { string sb = " " ; int startStr = nextNonDigit ( str , 0 ) ; while ( startStr != -1 ) { int endStr = startStr ; while ( ( endStr + 1 ) < n && ! isDigit ( str [ endStr + 1 ] ) ) { endStr ++ ; } int startNum = endStr + 1 ; if ( startNum == -1 ) break ; int endNum = startNum ; while ( ( endNum + 1 ) < n && isDigit ( str [ endNum + 1 ] ) ) { endNum ++ ; } int num = str [ startNum ] - '0' ; appendRepeated ( sb , str . substr ( startStr , endStr + 1 - startStr ) , num ) ; startStr = nextNonDigit ( str , endStr + 1 ) ; } return sb ; } int main ( ) { string str = " g1ee1ks1for1g1e2ks1" ; int n = str . length ( ) ; cout << findString ( str , n ) << endl ; return 0 ; }

Index/key variables: i, startNum
Accumulator variables: endNum, endStr, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string replacePi ( string s ) { if ( s . length ( ) == 0 || s . length ( ) == 1 ) return s ; if ( s [ 0 ] == ' p ' && s [ 1 ] == ' i ' ) { string smallOutput = replacePi ( s . substr ( 2 ) ) ; return "3.14" + smallOutput ; } else { return s [ 0 ] + replacePi ( s . substr ( 1 ) ) ; } } int main ( ) { string s = " pipppiiipi " ; string result = replacePi ( s ) ; cout << result << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; #define MAX  26
string smallestStr ( string str , int n ) { int i , j ; int chk [ MAX ] ; for ( i = 0 ; i < MAX ; i ++ ) chk [ i ] = -1 ; for ( i = 0 ; i < n ; i ++ ) { if ( chk [ str [ i ] - ' a ' ] == -1 ) chk [ str [ i ] - ' a ' ] = i ; } for ( i = 0 ; i < n ; i ++ ) { bool flag = false ; for ( j = 0 ; j < str [ i ] - ' a ' ; j ++ ) { if ( chk [ j ] > chk [ str [ i ] - ' a ' ] ) { flag = true ; break ; } } if ( flag ) break ; } if ( i < n ) { char ch1 = str [ i ] ; char ch2 = char ( j + ' a ' ) ; for ( i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ch1 ) str [ i ] = ch2 ; else if ( str [ i ] == ch2 ) str [ i ] = ch1 ; } } return str ; } int main ( ) { string str = " ccad " ; int n = str . length ( ) ; cout << smallestStr ( str , n ) ; return 0 ; }

Index/key variables: MAX, i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; int longest_substring ( string s , int k ) { int n = s . size ( ) ; if ( k > 1 ) { s += s ; n *= 2 ; } int ans = 0 ; int i = 0 ; while ( i < n ) { int x = 0 ; while ( s [ i ] == '0' && i < n ) x ++ , i ++ ; ans = max ( ans , x ) ; i ++ ; } if ( k == 1 or ans != n ) return ans ; else return ( ans / 2 ) * k ; } int main ( ) { string s = "010001000" ; int k = 4 ; cout << longest_substring ( s , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, n, s, stdc, x
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Occurrence ( string s , int position ) { int count = 0 ; for ( int i = 0 ; i < position - 1 ; i ++ ) if ( s [ i ] == s [ position - 1 ] ) count ++ ; return count ; } int main ( ) { string s = " ababababab " ; int p = 9 ; cout << Occurrence ( s , p ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countOccurrence ( string s , int position ) { int alpha [ 26 ] = { 0 } , b [ s . size ( ) ] = { 0 } ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { b [ i ] = alpha [ ( int ) s [ i ] - 97 ] ; alpha [ ( int ) s [ i ] - 97 ] ++ ; } return b [ position - 1 ] ; } int main ( ) { string s = " ababababab " ; int p = 9 ; cout << countOccurrence ( s , p ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  26
bool canBeMapped ( string s1 , int l1 , string s2 , int l2 ) { if ( l1 != l2 ) return false ; int freq1 [ MAX ] = { 0 } ; int freq2 [ MAX ] = { 0 } ; for ( int i = 0 ; i < l1 ; i ++ ) freq1 [ s1 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < l2 ; i ++ ) freq2 [ s2 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( freq1 [ i ] == 0 ) continue ; bool found = false ; for ( int j = 0 ; j < MAX ; j ++ ) { if ( freq1 [ i ] == freq2 [ j ] ) { freq2 [ j ] = -1 ; found = true ; break ; } } if ( ! found ) return false ; } return true ; } int main ( ) { string s1 = " axx " ; string s2 = " cbc " ; int l1 = s1 . length ( ) ; int l2 = s2 . length ( ) ; if ( canBeMapped ( s1 , l1 , s2 , l2 ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: MAX, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
Boolean variables: found
C++ program:
#include <bits/stdc++.h>
using namespace std ; set < string > stringSet ; void find_permutation ( string & str1 , string & str2 , int len1 , int len2 , int i , int j , string res ) { if ( res . length ( ) == len1 + len2 ) { stringSet . insert ( res ) ; return ; } if ( i < len1 ) find_permutation ( str1 , str2 , len1 , len2 , i + 1 , j , res + str1 [ i ] ) ; if ( j < len2 ) find_permutation ( str1 , str2 , len1 , len2 , i , j + 1 , res + str2 [ j ] ) ; } void print_set ( ) { set < string > :: iterator itr ; for ( itr = stringSet . begin ( ) ; itr != stringSet . end ( ) ; itr ++ ) cout << ( * itr ) << endl ; } int main ( ) { string str1 = " aa " , str2 = " ab " ; int len1 = str1 . length ( ) ; int len2 = str2 . length ( ) ; find_permutation ( str1 , str2 , len1 , len2 , 0 , 0 , " " ) ; print_set ( ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: itr, stdc
Iterator variables: itr
C++ program:
#include <bits/stdc++.h>
using namespace std ; void generateStr ( char * a , char * b , string s , int count , int len ) { if ( count == len ) { cout << s << endl ; return ; } generateStr ( a + 1 , b + 1 , s + ( * a ) , count + 1 , len ) ; generateStr ( a + 1 , b + 1 , s + ( * b ) , count + 1 , len ) ; } int main ( ) { char * a = " abc " , * b = " def " ; int n = strlen ( a ) ; generateStr ( a , b , " " , 0 , n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
#include <vector>
using namespace std ; void GetAllValidIpAddress ( vector < string > & result , string givenString , int index , int count , string ipAddress ) { if ( givenString . size ( ) == index && count == 4 ) { ipAddress . pop_back ( ) ; result . push_back ( ipAddress ) ; return ; } if ( givenString . size ( ) < index + 1 ) return ; ipAddress = ipAddress + givenString . substr ( index , 1 ) + ' . ' ; GetAllValidIpAddress ( result , givenString , index + 1 , count + 1 , ipAddress ) ; ipAddress . erase ( ipAddress . end ( ) - 2 , ipAddress . end ( ) ) ; if ( givenString . size ( ) < index + 2 givenString [ index ] == '0' ) return ; ipAddress = ipAddress + givenString . substr ( index , 2 ) + ' . ' ; GetAllValidIpAddress ( result , givenString , index + 2 , count + 1 , ipAddress ) ; ipAddress . erase ( ipAddress . end ( ) - 3 , ipAddress . end ( ) ) ; if ( givenString . size ( ) < index + 3 || stoi ( givenString . substr ( index , 3 ) ) > 255 ) return ; ipAddress += givenString . substr ( index , 3 ) + ' . ' ; GetAllValidIpAddress ( result , givenString , index + 3 , count + 1 , ipAddress ) ; ipAddress . erase ( ipAddress . end ( ) - 4 , ipAddress . end ( ) ) ; } int main ( ) { string givenString = "25525511135" ; vector < string > result ; GetAllValidIpAddress ( result , givenString , 0 , 0 , " " ) ; for ( int i = 0 ; i < result . size ( ) ; i ++ ) { cout << result [ i ] << " STRNEWLINE " ; } }

Index/key variables: i, index
Accumulator variables: i, ipAddress
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int countSubStr ( string s , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 2 ; ) { if ( s [ i ] == '0' && s [ i + 1 ] == '1' && s [ i + 2 ] == '0' ) { count ++ ; i += 3 ; } else if ( s [ i ] == '1' && s [ i + 1 ] == '0' && s [ i + 2 ] == '1' ) { count ++ ; i += 3 ; } else { i ++ ; } } return count ; } int main ( ) { string s = "10101010101" ; int n = s . length ( ) ; cout << countSubStr ( s , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countTotalDistinct ( string str ) { int cnt = 0 ; set < string > items ; for ( int i = 0 ; i < str . length ( ) ; ++ i ) { string temp = " " ; set < char > ans ; for ( int j = i ; j < str . length ( ) ; ++ j ) { temp = temp + str [ j ] ; ans . insert ( str [ j ] ) ; if ( items . find ( temp ) == items . end ( ) ) { items . insert ( temp ) ; cnt += ans . size ( ) ; } } } return cnt ; } int main ( ) { string str = " ABCA " ; cout << countTotalDistinct ( str ) ; return 0 ; }

Index/key variables: j
Accumulator variables: cnt, stdc
Iterator variables: i, j
C++ program:
#include <iostream>
#include <map>
using namespace std ; void division_of_string ( string str , int k ) { int n = str . size ( ) ; map < char , bool > has ; int ans , cnt = 0 , i = 0 ; while ( i < n ) { if ( ! has [ str [ i ] ] ) { cnt ++ ; has [ str [ i ] ] = true ; } if ( cnt == k ) { ans = i ; break ; } i ++ ; } i ++ ; has . clear ( ) ; cnt = 0 ; while ( i < n ) { if ( ! has [ str [ i ] ] ) { cnt ++ ; has [ str [ i ] ] = true ; } if ( cnt == k ) { break ; } i ++ ; } if ( cnt < k ) { cout << " Not ▁ possible " << endl ; } else { i = 0 ; while ( i <= ans ) { cout << str [ i ] ; i ++ ; } cout << endl ; while ( i < n ) { cout << str [ i ] ; i ++ ; } cout << endl ; } cout << endl ; } int main ( ) { string str = " geeksforgeeks " ; int k = 4 ; division_of_string ( str , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isVowel ( char c ) { return ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) ; } int countSubstringsUtil ( string s ) { int count = 0 ; map < char , int > mp ; int n = s . length ( ) ; int start = 0 ; for ( int i = 0 ; i < n ; i ++ ) { mp [ s [ i ] ] ++ ; while ( mp [ ' a ' ] > 0 && mp [ ' e ' ] > 0 && mp [ ' i ' ] > 0 && mp [ ' o ' ] > 0 && mp [ ' u ' ] > 0 ) { count += n - i ; mp [ s [ start ] ] -- ; start ++ ; } } return count ; } int countSubstrings ( string s ) { int count = 0 ; string temp = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( isVowel ( s [ i ] ) ) { temp += s [ i ] ; } else { if ( temp . length ( ) > 0 ) count += countSubstringsUtil ( temp ) ; temp = " " ; } } if ( temp . length ( ) > 0 ) count += countSubstringsUtil ( temp ) ; return count ; } int main ( ) { string s = " aeouisddaaeeiouua " ; cout << countSubstrings ( s ) << endl ; return 0 ; }

Index/key variables: i, start
Accumulator variables: count, i, start, stdc, temp
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string removeDuplicates ( string S ) { string ans = " " ; for ( auto it : S ) { if ( ans . empty ( ) or ans . back ( ) != it ) ans . push_back ( it ) ; else if ( ans . back ( ) == it ) ans . pop_back ( ) ; } return ans ; } int main ( ) { string str = " keexxllx " ; cout << removeDuplicates ( str ) ; }

Accumulator variables: stdc
Iterator variables: it
C++ program:
#include <bits/stdc++.h>
using namespace std ; string reverseWords ( string str ) { int start = 0 ; for ( int i = 0 ; i <= str . size ( ) ; i ++ ) { if ( str [ i ] == ' ▁ ' || i == str . size ( ) ) { int end = i - 1 ; while ( start < end ) { swap ( str [ start ] , str [ end ] ) ; start ++ ; end -- ; } start = i + 1 ; } } return str ; } int main ( ) { string str = " Geeks ▁ for ▁ Geeks " ; cout << reverseWords ( str ) ; 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 ; void reverse ( char k [ ] ) { stack < char * > s ; char * token = strtok ( k , " ▁ " ) ; while ( token != NULL ) { s . push ( token ) ; token = strtok ( NULL , " ▁ " ) ; } while ( ! s . empty ( ) ) { cout << s . top ( ) << " ▁ " ; s . pop ( ) ; } } int main ( ) { char k [ ] = " geeks ▁ for ▁ geeks " ; reverse ( k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubString ( string s , char c , int k ) { int leftCount = 0 , rightCount = 0 ; int left = 0 , right = 0 ; int freq = 0 ; int result = 0 , len = s . length ( ) ; while ( s [ left ] != c && left < len ) { left ++ ; leftCount ++ ; } right = left + 1 ; while ( freq != ( k - 1 ) && ( right - 1 ) < len ) { if ( s [ right ] == c ) freq ++ ; right ++ ; } while ( left < len && ( right - 1 ) < len ) { while ( s [ left ] != c && left < len ) { left ++ ; leftCount ++ ; } while ( right < len && s [ right ] != c ) { if ( s [ right ] == c ) freq ++ ; right ++ ; rightCount ++ ; } result = result + ( leftCount + 1 ) * ( rightCount + 1 ) ; freq = k - 1 ; leftCount = 0 ; rightCount = 0 ; left ++ ; right ++ ; } return result ; } int main ( ) { string s = "3123231" ; char c = '3' ; int k = 2 ; cout << countSubString ( s , c , k ) ; return 0 ; }

Index/key variables: left, right
Accumulator variables: freq, left, leftCount, right, rightCount, stdc
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
#define MOD  1000000007
using namespace std ; int solve ( string test ) { int size = test . size ( ) ; int total = 0 ; for ( int i = 0 ; i <= 8 ; i ++ ) { int x = i ; int y = i + 1 ; string newtest ; for ( int j = 0 ; j < size ; j ++ ) { if ( test [ j ] == x + 48 test [ j ] == y + 48 ) { newtest += test [ j ] ; } } if ( newtest . size ( ) > 0 ) { int size1 = newtest . size ( ) ; int prefix [ size1 ] = { 0 } ; for ( int j = 0 ; j < size1 ; j ++ ) { if ( newtest [ j ] == y + 48 ) { prefix [ j ] ++ ; } } for ( int j = 1 ; j < size1 ; j ++ ) { prefix [ j ] += prefix [ j - 1 ] ; } int count = 0 ; int firstcount = 0 ; int ss = 0 ; int prev = 0 ; for ( int j = 0 ; j < size1 ; j ++ ) { if ( newtest [ j ] == x + 48 ) { count ++ ; firstcount ++ ; } else { ss += count * count ; int pairsum = ( firstcount * firstcount - ss ) / 2 ; int temp = pairsum ; pairsum -= prev ; prev = temp ; int secondway = prefix [ size1 - 1 ] ; if ( j != 0 ) secondway -= prefix [ j - 1 ] ; int answer = count * ( count - 1 ) * secondway * ( secondway - 1 ) ; answer /= 4 ; answer += ( pairsum * secondway * ( secondway - 1 ) ) / 2 ; total += answer ; count = 0 ; } } } } return total ; } int main ( ) { string test = "13134422" ; cout << solve ( test ) << endl ; return 0 ; }

Index/key variables: j, size1
Accumulator variables: answer, count, firstcount, i, j, newtest, pairsum, secondway, ss, stdc, total
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPossible ( int l , int m , int x , int y ) { if ( l * m == x + y ) return true ; return false ; } int main ( ) { int l = 3 , m = 2 , x = 4 , y = 2 ; if ( isPossible ( l , m , x , y ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  26
int countPairs ( string str , int k ) { int n = str . size ( ) ; int freq [ MAX ] ; memset ( freq , 0 , sizeof freq ) ; for ( int i = 0 ; i < n ; i ++ ) freq [ str [ i ] - ' a ' ] ++ ; int cnt = 0 ; if ( k == 0 ) { for ( int i = 0 ; i < MAX ; i ++ ) if ( freq [ i ] > 1 ) cnt += ( ( freq [ i ] * ( freq [ i ] - 1 ) ) / 2 ) ; } else { for ( int i = 0 ; i < MAX ; i ++ ) if ( freq [ i ] > 0 && i + k < MAX && freq [ i + k ] > 0 ) cnt += ( freq [ i ] * freq [ i + k ] ) ; ; } return cnt ; } int main ( ) { string str = " abcdab " ; int k = 0 ; cout << countPairs ( str , k ) ; return 0 ; }

Index/key variables: MAX, i
Accumulator variables: cnt, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPalin ( int i , int j , int k , int l , int p , int q , string s ) { int start = i , end = q ; while ( start < end ) { if ( s [ start ] != s [ end ] ) return false ; start ++ ; if ( start == j + 1 ) start = k ; end -- ; if ( end == p - 1 ) end = l ; } return true ; } int countSubStr ( string s ) { int count = 0 ; int n = s . size ( ) ; for ( int i = 0 ; i < n - 2 ; i ++ ) { for ( int j = i ; j < n - 2 ; j ++ ) { for ( int k = j + 1 ; k < n - 1 ; k ++ ) { for ( int l = k ; l < n - 1 ; l ++ ) { for ( int p = l + 1 ; p < n ; p ++ ) { for ( int q = p ; q < n ; q ++ ) { if ( isPalin ( i , j , k , l , p , q , s ) ) { count ++ ; } } } } } } } return count ; } int main ( ) { string s = " abca " ; cout << countSubStr ( s ) ; return 0 ; }

Index/key variables: end, start
Accumulator variables: count, end, i, j, k, l, p, q, start, stdc
Iterator variables: i, j, k, l, p, q
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int n ) { if ( n == 0 n == 1 ) return false ; for ( int i = 2 ; i * i <= n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } int sumAscii ( string str , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPrime ( i + 1 ) ) sum += ( int ) ( str [ i ] ) ; } return sum ; } int main ( ) { string str = " geeksforgeeks " ; int n = str . size ( ) ; cout << sumAscii ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > graph [ 100 ] ; vector < string > weight ( 100 ) ; bool Pangram ( string x ) { map < char , int > mp ; int n = x . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) mp [ x [ i ] ] ++ ; if ( mp . size ( ) == 26 ) return true ; else return false ; } int countTotalPangram ( int n ) { int cnt = 0 ; for ( int i = 1 ; i <= n ; i ++ ) if ( Pangram ( weight [ i ] ) ) cnt ++ ; return cnt ; } void dfs ( int node , int parent ) { for ( int to : graph [ node ] ) { if ( to == parent ) continue ; dfs ( to , node ) ; weight [ node ] += weight [ to ] ; } } int main ( ) { int n = 6 ; weight [ 1 ] = " abcde " ; weight [ 2 ] = " fghijkl " ; weight [ 3 ] = " abcdefg " ; weight [ 4 ] = " mnopqr " ; weight [ 5 ] = " stuvwxy " ; weight [ 6 ] = " zabcdef " ; graph [ 1 ] . push_back ( 2 ) ; graph [ 2 ] . push_back ( 3 ) ; graph [ 2 ] . push_back ( 4 ) ; graph [ 1 ] . push_back ( 5 ) ; graph [ 5 ] . push_back ( 6 ) ; dfs ( 1 , 1 ) ; cout << countTotalPangram ( n ) ; return 0 ; }

Index/key variables: i, node, to
Accumulator variables: cnt, i, stdc
Iterator variables: i, to
C++ program:
#include <bits/stdc++.h>
using namespace std ; int cnt = 0 ; vector < int > graph [ 100 ] ; vector < string > weight ( 100 ) ; bool uniqueChars ( string x ) { map < char , int > mp ; int n = x . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) mp [ x [ i ] ] ++ ; if ( mp . size ( ) == x . size ( ) ) return true ; else return false ; } void dfs ( int node , int parent ) { if ( uniqueChars ( weight [ node ] ) ) cnt += 1 ; for ( int to : graph [ node ] ) { if ( to == parent ) continue ; dfs ( to , node ) ; } } int main ( ) { weight [ 1 ] = " abc " ; weight [ 2 ] = " aba " ; weight [ 3 ] = " bcb " ; weight [ 4 ] = " moh " ; weight [ 5 ] = " aa " ; graph [ 1 ] . push_back ( 2 ) ; graph [ 2 ] . push_back ( 3 ) ; graph [ 2 ] . push_back ( 4 ) ; graph [ 1 ] . push_back ( 5 ) ; dfs ( 1 , 1 ) ; cout << cnt ; return 0 ; }

Index/key variables: i, node
Accumulator variables: cnt, i, stdc
Iterator variables: i, to
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isValid ( char s [ ] ) { char * p ; if ( ( p = strstr ( s , " geek " ) ) && ( strstr ( p + 4 , " keeg " ) ) ) return true ; return false ; } int main ( ) { char s [ ] = " geekeekeeg " ; if ( isValid ( s ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = 256 ; static string lastNonRepeating ( string str , int n ) { int freq [ MAX ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) freq [ str . at ( i ) ] ++ ; for ( int i = n - 1 ; i >= 0 ; i -- ) { char ch = str . at ( i ) ; if ( freq [ ch ] == 1 ) { string res ; res += ch ; return res ; } } return " - 1" ; } int main ( ) { string str = " GeeksForGeeks " ; int n = str . size ( ) ; cout << lastNonRepeating ( str , n ) ; return 0 ; }

Index/key variables: MAX, ch
Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findCount ( string s , int n , int a , int b ) { int res = 0 ; for ( int i = 0 ; i < b ; i ++ ) { if ( i == a ) res += ( s [ n - i - 1 ] != '1' ) ; else res += ( s [ n - i - 1 ] != '0' ) ; } return res ; } int main ( ) { string str = "1001011001" ; int N = str . size ( ) ; int A = 3 , B = 6 ; cout << findCount ( str , N , A , B ) ; return 0 ; }

Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; const int NUM = 31 ; void positions ( string str , int n ) { for ( int i = 0 ; i < n ; i ++ ) { cout << ( str [ i ] & NUM ) << " ▁ " ; } } int main ( ) { string str = " Geeks " ; int n = str . length ( ) ; positions ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void permute ( string & str , int l , int r ) { if ( l == r ) { if ( str . find ( " AB " ) == string :: npos ) cout << str << " ▁ " ; return ; } for ( int i = l ; i <= r ; i ++ ) { swap ( str [ l ] , str [ i ] ) ; permute ( str , l + 1 , r ) ; swap ( str [ l ] , str [ i ] ) ; } } int main ( ) { string str = " ABC " ; permute ( str , 0 , str . length ( ) - 1 ) ; return 0 ; }

Index/key variables: i, l
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int lenoflongestnonpalindrome ( string s ) { int max1 = 1 , len = 0 ; for ( int i = 0 ; i < s . length ( ) - 1 ; i ++ ) { if ( s [ i ] == s [ i + 1 ] ) len = 0 ; else if ( s [ i + 1 ] == s [ i - 1 ] && i > 0 ) len = 1 ; len ++ ; } if ( max1 == 1 ) return 0 ; else return max1 ; } int main ( ) { string s = " synapse " ; cout << lenoflongestnonpalindrome ( s ) << " STRNEWLINE " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, len, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string makePalindrome ( string str ) { int i = 0 , j = str . length ( ) - 1 ; while ( i <= j ) { if ( str [ i ] == ' * ' && str [ j ] == ' * ' ) { str [ i ] = ' a ' ; str [ j ] = ' a ' ; } else if ( str [ j ] == ' * ' ) str [ j ] = str [ i ] ; else if ( str [ i ] == ' * ' ) str [ i ] = str [ j ] ; else if ( str [ i ] != str [ j ] ) return " - 1" ; i ++ ; j -- ; } return str ; } int main ( ) { string str = " na * an " ; cout << makePalindrome ( str ) ; return 0 ; }

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