dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; unordered_set < string > seen ; vector < int > edges ; void dfs ( string node , int & k , string & A ) { for ( int i = 0 ; i < k ; ++ i ) { string str = node + A [ i ] ; if ( seen . find ( str ) == seen . end ( ) ) { seen . insert ( str ) ; dfs ( str . substr ( 1 ) , k , A ) ; edges . push_back ( i ) ; } } } string deBruijn ( int n , int k , string A ) { seen . clear ( ) ; edges . clear ( ) ; string startingNode = string ( n - 1 , A [ 0 ] ) ; dfs ( startingNode , k , A ) ; string S ; int l = pow ( k , n ) ; for ( int i = 0 ; i < l ; ++ i ) S += A [ edges [ i ] ] ; S += startingNode ; return S ; } int main ( ) { int n = 3 , k = 2 ; string A = "01" ; cout << deBruijn ( n , k , A ) ; return 0 ; }

Index/key variables: i
Accumulator variables: S, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > shortestToChar ( string s , char c ) { vector < int > list ; vector < int > res ; int len = s . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( s [ i ] == c ) { list . push_back ( i ) ; } } int p1 , p2 , v1 , v2 ; int l = list . size ( ) - 1 ; p1 = 0 ; p2 = l > 0 ? 1 : 0 ; for ( int i = 0 ; i < len ; i ++ ) { v1 = list [ p1 ] ; v2 = list [ p2 ] ; if ( i <= v1 ) { res . push_back ( v1 - i ) ; } else if ( i <= v2 ) { if ( i - v1 < v2 - i ) { res . push_back ( i - v1 ) ; } else { res . push_back ( v2 - i ) ; p1 = p2 ; p2 = p2 < l ? ( p2 + 1 ) : p2 ; } } else { res . push_back ( i - v2 ) ; } } return res ; } int main ( ) { string s = " geeksforgeeks " ; char c = ' e ' ; vector < int > res = shortestToChar ( s , c ) ; for ( auto i : res ) cout << i << " ▁ " ; return 0 ; }

Index/key variables: i, p1, p2
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countWords ( string str ) { int count = 1 ; for ( int i = 1 ; i < str . length ( ) - 1 ; i ++ ) { if ( isupper ( str [ i ] ) ) count ++ ; } return count ; } int main ( ) { string str = " geeksForGeeks " ; cout << countWords ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string isFibonacci ( string s ) { map < char , int > m ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { m [ s [ i ] ] ++ ; } vector < int > v ; int n = m . size ( ) ; int a = 1 , b = 1 ; int c ; v . push_back ( a ) ; v . push_back ( b ) ; for ( int i = 0 ; i < n - 2 ; i ++ ) { v . push_back ( a + b ) ; c = a + b ; a = b ; b = c ; } int flag = 1 ; int i = 0 ; for ( auto itr = m . begin ( ) ; itr != m . end ( ) ; itr ++ ) { if ( itr -> second != v [ i ] ) { flag = 0 ; break ; } i ++ ; } if ( flag == 1 ) return " YES " ; else return " NO " ; } int main ( ) { string s = " abeeedd " ; cout << isFibonacci ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, itr, stdc
Iterator variables: i, itr
C++ program:
#include <bits/stdc++.h>
using namespace std ; string smallest ( string s ) { int l = s . length ( ) ; string ans = " " ; for ( int i = 0 ; i < l - 1 ; i ++ ) { if ( s [ i ] > s [ i + 1 ] ) { for ( int j = 0 ; j < l ; j ++ ) { if ( i != j ) ans += s [ j ] ; } return ans ; } } ans = s . substr ( 0. , l - 1 ) ; return ans ; } int main ( ) { string s = " abcda " ; cout << smallest ( s ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int fact ( int n ) { int f = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { f = f * i ; } return f ; } int npr ( int n , int r ) { return fact ( n ) / fact ( n - r ) ; } int countPermutations ( string str ) { int even = floor ( str . length ( ) / 2 ) ; int odd = str . length ( ) - even ; int ways = 0 ; int freq [ 26 ] = { 0 } ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { ++ freq [ str [ i ] - ' a ' ] ; } int nvowels = freq [ 0 ] + freq [ 4 ] + freq [ 8 ] + freq [ 14 ] + freq [ 20 ] ; int nconsonants = str . length ( ) - nvowels ; ways = npr ( odd , nvowels ) * npr ( nconsonants , nconsonants ) ; return ways ; } int main ( ) { string str = " geeks " ; cout << countPermutations ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string replacingConsonants ( string s ) { char nVowel [ ] = " aaaeeeeiiiiioooooouuuuuuuu " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) s [ i ] = nVowel [ s [ i ] - ' a ' ] ; return s ; } int main ( ) { string s = " geeksforgeeks " ; cout << replacingConsonants ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isVowel ( char ch ) { if ( ch != ' a ' && ch != ' e ' && ch != ' i ' && ch != ' o ' && ch != ' u ' ) return false ; return true ; } string replaceConsonants ( string s ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( ! isVowel ( s [ i ] ) ) { if ( s [ i ] == ' z ' ) s [ i ] = ' b ' ; else { s [ i ] = ( char ) ( s [ i ] + 1 ) ; if ( isVowel ( s [ i ] ) ) s [ i ] = ( char ) ( s [ i ] + 1 ) ; } } } return s ; } int main ( ) { string s = " geeksforgeeks " ; cout << replaceConsonants ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHAR = 26 ; string removeChars ( string str , int k ) { int hash [ MAX_CHAR ] = { 0 } ; int n = str . length ( ) ; for ( int i = 0 ; i < n ; ++ i ) hash [ str [ i ] - ' a ' ] ++ ; string res = " " ; for ( int i = 0 ; i < n ; ++ i ) { if ( hash [ str [ i ] - ' a ' ] >= k ) { res += str [ i ] ; } } return res ; } int main ( ) { string str = " geeksforgeeks " ; int k = 2 ; cout << removeChars ( str , k ) ; return 0 ; }

Index/key variables: MAX_CHAR, i
Accumulator variables: res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countOnOff ( string n ) { int Led [ ] = { 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 5 } ; int len = n . length ( ) ; int sum = Led [ n [ 0 ] - '0' ] ; for ( int i = 1 ; i < len ; i ++ ) { sum = sum + abs ( Led [ n [ i ] - '0' ] - Led [ n [ i - 1 ] - '0' ] ) ; } return sum ; } int main ( ) { string n = "082" ; cout << countOnOff ( n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; bool check ( string s ) { int freq [ 26 ] = { 0 } ; int n = s . length ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) freq [ s [ i ] - 97 ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) if ( freq [ i ] % 2 == 1 ) return false ; return true ; } int main ( ) { string s = " abaccaba " ; check ( s ) ? cout << " Yes " << endl : cout << " No " << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int max_length_substring ( string st , int n , int k ) { int max_len = 0 ; int len = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( st [ i ] == '0' ) len ++ ; else len = 0 ; max_len = max ( max_len , len ) ; } if ( max_len == n ) return n * k ; int pref = 0 , suff = 0 ; for ( int i = 0 ; st [ i ] == '0' ; ++ i , ++ pref ) ; for ( int i = n - 1 ; st [ i ] == '0' ; -- i , ++ suff ) ; if ( k > 1 ) max_len = max ( max_len , pref + suff ) ; return max_len ; } int main ( ) { int n = 6 ; int k = 3 ; string st = "110010" ; int ans = max_length_substring ( st , n , k ) ; cout << ans ; }

Index/key variables: i
Accumulator variables: len, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isValidSubString ( string r , int K , int p ) { int c = 0 ; for ( int i = 0 ; i < r . length ( ) ; i ++ ) { if ( ( int ) r [ i ] > p ) c ++ ; } if ( c == K ) return true ; else return false ; } void countSubStrings ( string s , int K , int p ) { int l = s . length ( ) ; int count = 0 ; for ( int i = 0 ; i < l ; i ++ ) { for ( int j = K ; ( i + j ) <= l ; j ++ ) { string r = s . substr ( i , j ) ; if ( isValidSubString ( r , K , p ) ) count ++ ; } } cout << count << " STRNEWLINE " ; } int main ( ) { string s = " abepztydba " ; int K = 4 ; int p = 110 ; countSubStrings ( s , K , p ) ; return 0 ; }

Index/key variables: i
Accumulator variables: c, count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int count ( string S , int X ) { int count = 0 ; const int N = S . length ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( S [ i ] != '0' ) { for ( int len = 1 ; ( i + len ) <= N ; ++ len ) { if ( stoi ( S . substr ( i , len ) ) > X ) count ++ ; } } } return count ; } int main ( ) { string S = "2222" ; int X = 97 ; cout << count ( S , X ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, stdc
Iterator variables: i, len
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isBinary ( int n ) { while ( n != 0 ) { int temp = n % 10 ; if ( temp != 0 && temp != 1 ) { return false ; } n = n / 10 ; } return true ; } void formBinaryStr ( int n , int a [ ] ) { bool flag = true ; string s = " " ; for ( int i = 0 ; i < n ; i ++ ) { if ( isBinary ( a [ i ] ) ) s += to_string ( a [ i ] ) ; else { flag = false ; break ; } } if ( flag ) cout << s << " STRNEWLINE " ; else cout << " - 1 STRNEWLINE " ; } int main ( ) { int a [ ] = { 10 , 1 , 0 , 11 , 10 } ; int N = sizeof ( a ) / sizeof ( a [ 0 ] ) ; formBinaryStr ( N , a ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, s, stdc
Iterator variables: i
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int fact ( int n ) { long long result = 1 ; for ( int i = 1 ; i <= n ; i ++ ) result *= i ; return result ; } int getResult ( string str , char ch ) { int has [ 26 ] = { 0 } ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) has [ str [ i ] - ' A ' ] ++ ; int particular = has [ ch - ' A ' ] ; if ( particular == 0 ) return 0 ; has [ ch - ' A ' ] = 0 ; int total = str . length ( ) ; total = total - particular + 1 ; long long int result = fact ( total ) ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( has [ i ] > 1 ) { result = result / fact ( has [ i ] ) ; } } return result ; } int main ( ) { string str = " MISSISSIPPI " ; cout << getResult ( str , ' S ' ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isAnyNotPalindrome ( string s ) { set < char > unique ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) unique . insert ( s [ i ] ) ; if ( unique . size ( ) > 1 ) return true ; else return false ; } int main ( ) { string s = " aaaaab " ; if ( isAnyNotPalindrome ( s ) ) 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 ; #define ll  long int
ll factorial ( ll n ) { ll res = 1 ; for ( int i = 1 ; i <= n ; i ++ ) res = res * i ; return res ; } ll count ( string word ) { ll freq [ 27 ] = { 0 } ; ll vowel = 0 , consonant = 0 ; for ( int i = 0 ; i < word . length ( ) ; i ++ ) { freq [ word [ i ] - ' A ' ] ++ ; if ( word [ i ] == ' A ' word [ i ] == ' E ' word [ i ] == ' I ' word [ i ] == ' O ' word [ i ] == ' U ' ) { vowel ++ ; } else consonant ++ ; } ll vowelArrange ; vowelArrange = factorial ( vowel ) ; vowelArrange /= factorial ( freq [ 0 ] ) ; vowelArrange /= factorial ( freq [ 4 ] ) ; vowelArrange /= factorial ( freq [ 8 ] ) ; vowelArrange /= factorial ( freq [ 14 ] ) ; vowelArrange /= factorial ( freq [ 20 ] ) ; ll consonantArrange ; consonantArrange = factorial ( consonant ) ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( i != 0 && i != 4 && i != 8 && i != 14 && i != 20 ) consonantArrange /= factorial ( freq [ i ] ) ; } ll total = vowelArrange * consonantArrange ; return total ; } int main ( ) { string word = " COMPUTER " ; ll ans = count ( word ) ; cout << ans << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: consonant, consonantArrange, i, stdc, vowel, vowelArrange
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPalindrome ( string s ) { string s1 = " " ; int N = s . length ( ) ; for ( int i = N - 1 ; i >= 0 ; i -- ) s1 += s [ i ] ; if ( s == s1 ) return true ; return false ; } bool createString ( int N ) { string str = " " ; string s = to_string ( N ) ; string letters = " abcdefghij " ; int sum = 0 ; string substr = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int digit = s [ i ] - '0' ; substr += letters [ digit ] ; sum += digit ; } while ( str . length ( ) <= sum ) { str += substr ; } str = str . substr ( 0 , sum ) ; return isPalindrome ( str ) ; } int main ( ) { int N = 61 ; bool flag = createString ( N ) ; if ( flag ) cout << " YES " ; else cout << " NO " ; }

Index/key variables: digit, i
Accumulator variables: i, s1, stdc, str, substr, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long productAscii ( string str ) { long long prod = 1 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { prod *= ( int ) str [ i ] ; } return prod ; } int main ( ) { string str = " GfG " ; cout << productAscii ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, prod, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( string s ) { int n = s . length ( ) ; int Presum [ n ] ; Presum [ 0 ] = s [ 0 ] - '0' ; for ( int i = 1 ; i < n ; i ++ ) { Presum [ i ] = Presum [ i - 1 ] + ( s [ i ] - '0' ) ; } for ( int i = 1 ; i <= n - 1 ; i ++ ) { int sum = Presum [ i - 1 ] ; int presum = 0 ; int it = i ; int flag = 0 ; while ( it < n ) { presum += s [ it ] - '0' ; if ( presum == sum ) { presum = 0 ; flag = 1 ; } else if ( presum > sum ) { break ; } it ++ ; } if ( presum == 0 && it == n && flag == 1 ) { return true ; } } return false ; } int main ( ) { string s = "73452" ; if ( check ( s ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i, it, n
Accumulator variables: i, it, presum, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void balancedString ( string str ) { int count = 0 , i ; int n = str . length ( ) ; for ( i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ( ' ) { cout << str [ i ] ; count ++ ; } else if ( str [ i ] == ' ) ' && count != 0 ) { cout << str [ i ] ; count -- ; } else if ( str [ i ] != ' ) ' ) cout << str [ i ] ; } if ( count != 0 ) for ( i = 0 ; i < count ; i ++ ) cout << " ) " ; } int main ( ) { string str = " gau ) ra ) v ( ku ( mar ( rajput ) ) " ; balancedString ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX = INT_MAX ; int minOperation ( string & s , int i , int j , int count ) { if ( ( i >= s . size ( ) && j < 0 ) || ( i == j ) ) return MAX ; if ( s [ i ] == s [ j ] ) return count ; if ( i >= s . size ( ) ) return minOperation ( s , i , j - 1 , count + 1 ) ; else if ( j < 0 ) return minOperation ( s , i + 1 , j , count + 1 ) ; else return min ( minOperation ( s , i , j - 1 , count + 1 ) , minOperation ( s , i + 1 , j , count + 1 ) ) ; } int main ( ) { string s = " bacdefghipalop " ; int ans = minOperation ( s , 0 , s . size ( ) - 1 , 0 ) ; if ( ans == MAX ) cout << -1 ; else cout << ans ; return 0 ; }

Index/key variables: i, j
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countStrings ( string s ) { long sum = 1 ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { if ( i % 2 == 0 && s [ i ] == ' $ ' ) sum *= 21 ; else if ( s [ i ] == ' $ ' ) sum *= 5 ; } return sum ; } int main ( ) { string str = " s $ $ e $ " ; cout << countStrings ( str ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <string>
using namespace std ; string removeDuplicatesFromString ( string str ) { int counter = 0 ; int i = 0 ; int size = str . size ( ) ; int x ; int length = 0 ; while ( i < size ) { x = str [ i ] - 97 ; if ( ( counter & ( 1 << x ) ) == 0 ) { str [ length ] = ' a ' + x ; counter = counter | ( 1 << x ) ; length ++ ; } i ++ ; } return str . substr ( 0 , length ) ; } int main ( ) { string str = " geeksforgeeks " ; cout << removeDuplicatesFromString ( str ) ; return 0 ; }

Index/key variables: i, length
Accumulator variables: i, length, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string removeDuplicatesFromString ( string str ) { vector < int > table ( 256 , 0 ) ; vector < char > chars ; for ( auto i : str ) chars . push_back ( i ) ; int endIndex = 0 ; for ( int i = 0 ; i < chars . size ( ) ; i ++ ) { if ( table [ chars [ i ] ] == 0 ) { table [ chars [ i ] ] = -1 ; chars [ endIndex ++ ] = chars [ i ] ; } } string ans = " " ; for ( int i = 0 ; i < endIndex ; i ++ ) ans += chars [ i ] ; return ans ; } int main ( ) { string str = " geeksforgeeks " ; cout << ( removeDuplicatesFromString ( str ) ) << endl ; }

Index/key variables: i
Accumulator variables: ans, endIndex, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int firstPos ( string str , int start , int end ) { int firstChar = -1 ; for ( int i = start ; i <= end ; i ++ ) { if ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) { firstChar = i ; break ; } } return firstChar ; } int lastPos ( string str , int start , int end ) { int lastChar = -1 ; for ( int i = start ; i >= end ; i -- ) { if ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) { lastChar = i ; break ; } } return lastChar ; } bool isPalindrome ( string str ) { int firstChar = 0 , lastChar = str . length ( ) - 1 ; bool ch = true ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { firstChar = firstPos ( str , firstChar , lastChar ) ; lastChar = lastPos ( str , lastChar , firstChar ) ; if ( lastChar < 0 firstChar < 0 ) break ; if ( str [ firstChar ] == str [ lastChar ] ) { firstChar ++ ; lastChar -- ; continue ; } ch = false ; break ; } return ( ch ) ; } int main ( ) { string str = " m TABSYMBOL a ▁ 343 ▁ la ▁ y ▁ a ▁ l ▁ am " ; if ( isPalindrome ( str ) ) cout << " YES " ; else cout << " NO " ; return 0 ; }

Index/key variables: firstChar, i, lastChar
Accumulator variables: firstChar, i, lastChar
Iterator variables: i
Boolean variables: ch
C++ program:
#include <bits/stdc++.h>
using namespace std ; int find ( string s ) { int max = 0 , i , j = 0 , countk = 0 , countr = 0 ; int table [ s . length ( ) ] [ 2 ] ; for ( i = 0 ; i < s . length ( ) ; i ++ ) { if ( s [ i ] == ' R ' ) countr ++ ; else table [ j ++ ] [ 0 ] = countr ; } j -- ; for ( i = s . length ( ) - 1 ; i >= 0 ; i -- ) { if ( s [ i ] == ' K ' ) { countk ++ ; table [ j -- ] [ 1 ] = countk ; } if ( min ( table [ j + 1 ] [ 0 ] , table [ j + 1 ] [ 1 ] ) > max ) max = min ( table [ j + 1 ] [ 0 ] , table [ j + 1 ] [ 1 ] ) ; } return max ; } int main ( ) { string s = " RKRRRKKRRKKKKRR " ; int n = find ( s ) ; cout << ( n ) ; }

Index/key variables: i
Accumulator variables: countk, countr, i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHAR = 26 ; void frequency ( int fre [ ] [ MAX_CHAR ] , string s [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { string str = s [ i ] ; for ( int j = 0 ; j < str . size ( ) ; j ++ ) fre [ i ] [ str [ j ] - ' a ' ] ++ ; } } void LongestSequence ( int fre [ ] [ MAX_CHAR ] , int n ) { for ( int i = MAX_CHAR - 1 ; i >= 0 ; i -- ) { int mi = fre [ 0 ] [ i ] ; for ( int j = 1 ; j < n ; j ++ ) mi = min ( fre [ j ] [ i ] , mi ) ; while ( mi -- ) cout << ( char ) ( ' a ' + i ) ; } } int main ( ) { string s [ ] = { " loo " , " lol " , " olive " } ; int n = sizeof ( s ) / sizeof ( s [ 0 ] ) ; int fre [ n ] [ 26 ] = { 0 } ; frequency ( fre , s , n ) ; LongestSequence ( fre , n ) ; return 0 ; }

Index/key variables: MAX_CHAR, i, j, n
Accumulator variables: i, j, mi, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool arePermutation ( string str1 , string str2 ) { int n1 = str1 . length ( ) ; int n2 = str2 . length ( ) ; if ( n1 != n2 ) return false ; sort ( str1 . begin ( ) , str1 . end ( ) ) ; sort ( str2 . begin ( ) , str2 . end ( ) ) ; for ( int i = 0 ; i < n1 ; i ++ ) if ( str1 [ i ] != str2 [ i ] ) return false ; return true ; } int main ( ) { string str1 = " test " ; string str2 = " ttew " ; if ( arePermutation ( str1 , str2 ) ) printf ( " Yes " ) ; else printf ( " No " ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
bool arePermutation ( string str1 , string str2 ) { int count [ NO_OF_CHARS ] = { 0 } ; int i ; for ( i = 0 ; str1 [ i ] && str2 [ i ] ; i ++ ) { count [ str1 [ i ] ] ++ ; count [ str2 [ i ] ] -- ; } if ( str1 [ i ] str2 [ i ] ) return false ; for ( i = 0 ; i < NO_OF_CHARS ; i ++ ) if ( count [ i ] ) return false ; return true ; }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int powerOfJump ( string s ) { int count = 1 ; int max_so_far = INT_MIN ; char ch = s [ s . length ( ) - 1 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s [ i ] == ch ) { if ( count > max_so_far ) { max_so_far = count ; } count = 1 ; } else count ++ ; } return max_so_far ; } int main ( ) { string st = "1010101" ; cout << powerOfJump ( st ) ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findLongestSub ( string bin ) { int n = bin . length ( ) , i ; int sum = 0 ; unordered_map < int , int > prevSum ; int maxlen = 0 ; int currlen ; for ( i = 0 ; i < n ; i ++ ) { if ( bin [ i ] == '1' ) sum ++ ; else sum -- ; if ( sum > 0 ) { maxlen = i + 1 ; } else if ( sum <= 0 ) { if ( prevSum . find ( sum - 1 ) != prevSum . end ( ) ) { currlen = i - prevSum [ sum - 1 ] ; maxlen = max ( maxlen , currlen ) ; } } if ( prevSum . find ( sum ) == prevSum . end ( ) ) prevSum [ sum ] = i ; } return maxlen ; } int main ( ) { string bin = "1010" ; cout << findLongestSub ( bin ) ; return 0 ; }

Index/key variables: i, sum
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int averageValue ( string s ) { int sum_char = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { sum_char += ( int ) s [ i ] ; } return sum_char / s . length ( ) ; } int main ( ) { string s = " GeeksforGeeks " ; cout << averageValue ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum_char
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( string s , int l ) { int freq [ 26 ] = { 0 } ; for ( int i = 0 ; i < l ; i ++ ) { } for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] >= 2 ) return true ; } return false ; } int main ( ) { string s = " geeksforgeeks " ; int l = s . length ( ) ; if ( check ( s , l ) ) 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 ; void predictWinner ( string score , int n ) { int count [ 2 ] = { 0 } , i ; for ( i = 0 ; i < score . size ( ) ; i ++ ) { count [ score [ i ] - '0' ] ++ ; if ( count [ 0 ] == n && count [ 1 ] < n - 1 ) { cout << " GEEKS ▁ lost " ; return ; } if ( count [ 1 ] == n && count [ 0 ] < n - 1 ) { cout << " GEEKS ▁ won " ; return ; } if ( count [ 0 ] == n - 1 && count [ 1 ] == n - 1 ) { count [ 0 ] = 0 ; count [ 1 ] = 0 ; break ; } } for ( i ++ ; i < score . size ( ) ; i ++ ) { count [ score [ i ] - '0' ] ++ ; if ( abs ( count [ 0 ] - count [ 1 ] ) == 2 ) { if ( count [ 0 ] > count [ 1 ] ) cout << " GEEKS ▁ lost " ; else cout << " GEEKS ▁ won " ; return ; } } } int main ( ) { string score = "1001010101111011101111" ; int n = 15 ; predictWinner ( score , n ) ; return 0 ; }

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