dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <iostream>
using namespace std ; typedef long long int ll ; void solve ( int n , int k ) { int x1 , d ; d = k * ( k + 1 ) ; if ( ( 2 * n ) % d != 0 ) { cout << " - 1" ; return ; } x1 = 2 * n / d ; for ( int i = 1 ; i <= k ; i ++ ) { cout << x1 * i << " ▁ " ; } cout << endl ; } int main ( ) { int n = 10 , k = 4 ; solve ( n , k ) ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int checkBitonic ( string s ) { int i , j ; for ( i = 1 ; i < s . size ( ) ; i ++ ) { if ( s [ i ] > s [ i - 1 ] ) continue ; if ( s [ i ] <= s [ i - 1 ] ) break ; } if ( i == s . size ( ) - 1 ) return 1 ; for ( j = i + 1 ; j < s . size ( ) ; j ++ ) { if ( s [ j ] < s [ j - 1 ] ) continue ; if ( s [ j ] >= s [ j - 1 ] ) break ; } i = j ; if ( i != s . size ( ) ) return 0 ; return 1 ; } int main ( ) { string s = " abcdfgcba " ; ( checkBitonic ( s ) == 1 ) ? cout << " YES " : cout << " NO " ; 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 solve ( int N ) { if ( N % 2 == 0 ) { cout << N / 2 << " ▁ " << N << endl ; } else { cout << ( N - 1 ) / 2 << " ▁ " << ( N - 1 ) << endl ; } } int main ( ) { int N = 10 ; solve ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findArray ( int * a , int n , int P ) { int mi = * min_element ( a , a + n ) ; int ctr = 0 ; mi = max ( 0 , mi - 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] -= mi ; ctr += mi ; } int i = P - 1 ; int start = -1 ; while ( 1 ) { if ( a [ i ] == 0 ) { start = i ; break ; } a [ i ] -= 1 ; ctr += 1 ; i = ( i - 1 + n ) % n ; } a [ start ] = ctr ; for ( int i = 0 ; i < n ; i ++ ) { cout << a [ i ] << " , ▁ " ; } } int main ( ) { int N = 5 ; int P = 2 ; int arr [ ] = { 3 , 2 , 0 , 2 , 7 } ; findArray ( arr , N , P ) ; return 0 ; }

Index/key variables: i, start
Accumulator variables: ctr, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void makeArray ( int a [ ] , int n ) { for ( int i = 1 ; i <= n ; i ++ ) cout << i * n << " ▁ " ; } int main ( ) { int N = 6 ; int arr [ N ] ; makeArray ( arr , N ) ; }

Index/key variables: N
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int printOddFactorNumber ( int n , int m ) { for ( int i = n ; i <= m ; i ++ ) { if ( ( i > 0 ) && ( ( i & ( i - 1 ) ) != 0 ) ) cout << i << " ▁ " ; } } int main ( ) { int N = 2 , M = 10 ; printOddFactorNumber ( N , M ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printSeries ( int n ) { int k = 2 ; for ( int i = 0 ; i < n ; i ++ ) { cout << ( k * ( 2 * k - 1 ) ) << " ▁ " ; k += 2 ; } cout << endl ; } int main ( ) { int N = 12 ; printSeries ( N ) ; return 0 ; }

Accumulator variables: i, k, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string find ( vector < string > S , int N ) { string pref ; string suff ; string mid ; for ( int i = 0 ; i < N ; i ++ ) { int first = int ( S [ i ] . find_first_of ( ' * ' ) ) ; int last = int ( S [ i ] . find_last_of ( ' * ' ) ) ; for ( int z = 0 ; z < int ( pref . size ( ) ) && z < first ; z ++ ) { if ( pref [ z ] != S [ i ] [ z ] ) { return " * " ; } } for ( int z = int ( pref . size ( ) ) ; z < first ; z ++ ) { pref += S [ i ] [ z ] ; } for ( int z = 0 ; z < int ( suff . size ( ) ) && int ( S [ i ] . size ( ) ) - 1 - z > last ; z ++ ) { if ( suff [ z ] != S [ i ] [ int ( S [ i ] . size ( ) ) - 1 - z ] ) { return " * " ; } } for ( int z = int ( suff . size ( ) ) ; int ( S [ i ] . size ( ) ) - 1 - z > last ; z ++ ) { suff += S [ i ] [ int ( S [ i ] . size ( ) ) - 1 - z ] ; } for ( int z = first ; z <= last ; z ++ ) { if ( S [ i ] [ z ] != ' * ' ) mid += S [ i ] [ z ] ; } } reverse ( suff . begin ( ) , suff . end ( ) ) ; return pref + mid + suff ; } int main ( ) { int N = 3 ; vector < string > s ( N ) ; s [ 0 ] = " pq * du * q " ; s [ 1 ] = " pq * abc * q " ; s [ 2 ] = " p * d * q " ; cout << find ( s , N ) ; return 0 ; }

Index/key variables: i, z
Accumulator variables: i, mid, pref, stdc, suff, z
Iterator variables: i, z
C++ program:
#include <bits/stdc++.h>
using namespace std ; int k1 = 2 ; int k2 = 2 ; int gap = 5 ; int printPattern ( int i , int j , int n ) { if ( j >= n ) { k1 = 2 ; k2 = 2 ; k1 -- ; k2 ++ ; if ( i == 2 ) { k1 = 0 ; k2 = n - 1 ; } return 0 ; } if ( i >= 3 ) { return 1 ; } if ( j > k2 ) { k1 += gap ; k2 += gap ; } if ( j >= k1 && j <= k2 i == 2 ) { cout << " * " ; } else { cout << " ▁ " ; } if ( printPattern ( i , j + 1 , n ) == 1 ) { return 1 ; } cout << endl ; return printPattern ( i + 1 , 0 , n ) ; } int main ( ) { int N = 3 ; printPattern ( 0 , 0 , N * 5 ) ; return 0 ; }

Accumulator variables: k1, k2, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void stateA ( string ) ; void stateB ( string ) ; void stateC ( string ) ; void stateD ( string ) ; void stateE ( string ) ; void stateF ( string ) ; void checkstateA ( string n ) { if ( n [ 0 ] == '0' ) stateB ( n . substr ( 1 ) ) ; else stateD ( n . substr ( 1 ) ) ; } void stateB ( string n ) { if ( n . length ( ) == 0 ) cout << " string ▁ not ▁ accepted " ; else { if ( n [ 0 ] == '1' ) stateC ( n . substr ( 1 ) ) ; else stateD ( n . substr ( 1 ) ) ; } } void stateC ( string n ) { cout << " String ▁ accepted " ; } void stateD ( string n ) { if ( n . length ( ) == 0 ) cout << " string ▁ not ▁ accepted " ; else { if ( n [ 0 ] == '1' ) stateD ( n . substr ( 1 ) ) ; else stateE ( n . substr ( 1 ) ) ; } } void stateE ( string n ) { if ( n . length ( ) == 0 ) cout << " string ▁ not ▁ accepted " ; else { if ( n [ 0 ] == '0' ) stateE ( n . substr ( 1 ) ) ; else stateF ( n . substr ( 1 ) ) ; } } void stateF ( string n ) { if ( n . length ( ) == 0 ) cout << " string ▁ accepred " ; else { if ( n [ 0 ] == '1' ) stateD ( n . substr ( 1 ) ) ; else stateE ( n . substr ( 1 ) ) ; } } int main ( ) { string n = "0100101" ; checkstateA ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int HogbenNumber ( int a ) { int p = ( pow ( a , 2 ) - a + 1 ) ; return p ; } int main ( ) { int N = 10 ; cout << HogbenNumber ( N ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void check_string_exist ( string S ) { int size = S . length ( ) ; bool check = true ; for ( int i = 0 ; i < size ; i ++ ) { if ( S [ i ] != S [ ( i + 2 ) % size ] ) { check = false ; break ; } } if ( check ) cout << " Yes " << endl ; else cout << " No " << endl ; } int main ( ) { string S = " papa " ; check_string_exist ( S ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
Boolean variables: check
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getProduct ( int n ) { int product = 1 ; while ( n != 0 ) { product = product * ( n % 10 ) ; n = n / 10 ; } return product ; } int productinRange ( int l , int r ) { if ( r - l > 9 ) return 0 ; else { int p = 1 ; for ( int i = l ; i <= r ; i ++ ) p *= getProduct ( i ) ; return p ; } } int main ( ) { int l = 11 , r = 15 ; cout << productinRange ( l , r ) << endl ; l = 1 , r = 15 ; cout << productinRange ( l , r ) ; return 0 ; }

Accumulator variables: i, p, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int checkQwertyRow ( char x ) { set < char > first_row = { '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , '0' , ' - ' , ' = ' } ; set < char > second_row = { ' Q ' , ' W ' , ' E ' , ' R ' , ' T ' , ' Y ' , ' U ' , ' I ' , ' O ' , ' P ' , ' [ ' , ' ] ' , ' q ' , ' w ' , ' e ' , ' r ' , ' t ' , ' y ' , ' u ' , ' i ' , ' o ' , ' p ' } ; set < char > third_row = { ' A ' , ' S ' , ' D ' , ' F ' , ' G ' , ' H ' , ' J ' , ' K ' , ' L ' , ' ; ' , ' : ' , ' a ' , ' s ' , ' d ' , ' f ' , ' g ' , ' h ' , ' j ' , ' k ' , ' l ' } ; set < char > fourth_row = { ' Z ' , ' X ' , ' C ' , ' V ' , ' B ' , ' N ' , ' M ' , ' , ' , ' . ' , ' / ' , ' z ' , ' x ' , ' c ' , ' v ' , ' b ' , ' n ' , ' m ' } ; if ( first_row . count ( x ) > 0 ) { return 1 ; } else if ( second_row . count ( x ) > 0 ) { return 2 ; } else if ( third_row . count ( x ) > 0 ) { return 3 ; } else if ( fourth_row . count ( x ) > 0 ) { return 4 ; } return 0 ; } bool checkValidity ( string str ) { char x = str [ 0 ] ; int row = checkQwertyRow ( x ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { x = str [ i ] ; if ( row != checkQwertyRow ( x ) ) { return false ; } } return true ; } int main ( ) { string str = " GeeksforGeeks " ; if ( checkValidity ( str ) ) 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 ; long long fib ( long long n ) { long long f0 = 0 ; long long f1 = 1 ; if ( n == 0 ) return 0 ; if ( n == 1 ) return 1 ; else { long long rem = n % 60 ; if ( rem == 0 ) return 0 ; for ( long long i = 2 ; i < rem + 3 ; i ++ ) { long long f = ( f0 + f1 ) % 60 ; f0 = f1 ; f1 = f ; } long long s = f1 - 1 ; return s ; } } int main ( ) { long long m = 10087887 ; long long n = 2983097899 ; long long final = abs ( fib ( n ) - fib ( m - 1 ) ) ; cout << final % 10 << endl ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printSinX ( int N ) { int Xi = 0 ; int num = 1 ; while ( N -- ) { cout << " X " << num << " ▁ = ▁ " << Xi ; cout << " ▁ sin ( X " << num << " ) ▁ = ▁ " << fixed ; cout << setprecision ( 6 ) << sin ( Xi ) << endl ; num += 1 ; Xi += 710 ; } } int main ( ) { int N = 5 ; printSinX ( N ) ; return 0 ; }

Accumulator variables: N, Xi, num, stdc
C++ program:
#include " bits / stdc + + . h "
using namespace std ; void sumBetweenZero ( int arr [ ] , int N ) { int i = 0 ; vector < int > A ; int sum = 0 ; for ( i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 0 ) { i ++ ; break ; } } for ( ; i < N ; i ++ ) { if ( arr [ i ] == 0 ) { A . push_back ( sum ) ; sum = 0 ; } else { sum += arr [ i ] ; } } for ( int i = 0 ; i < A . size ( ) ; i ++ ) { cout << A [ i ] << ' ▁ ' ; } if ( A . size ( ) == 0 ) cout << " - 1" ; } int main ( ) { int arr [ ] = { 1 , 0 , 3 , 4 , 0 , 4 , 4 , 0 , 2 , 1 , 4 , 0 , 3 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; sumBetweenZero ( arr , N ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int nthTerm ( int N ) { if ( N == 1 ) { return 2 ; } return ( ( N - 1 ) * 13 ) + nthTerm ( N - 1 ) ; } int main ( ) { int N = 17 ; cout << nthTerm ( N ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maximumSubsequence ( int arr [ ] , int N ) { unordered_map < int , int > M ; for ( int i = 0 ; i < N ; i ++ ) { M [ arr [ i ] ] ++ ; } int distinct_size = M . size ( ) ; int maxFreq = 1 ; for ( auto & it : M ) { maxFreq = max ( maxFreq , it . second ) ; } cout << max ( min ( distinct_size , maxFreq - 1 ) , min ( distinct_size - 1 , maxFreq ) ) ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 4 , 4 , 4 , 4 , 5 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; maximumSubsequence ( 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 countCharacters ( vector < string > & strings , string chars ) { int res = 0 ; unordered_map < char , int > freq ; for ( int i = 0 ; i < chars . length ( ) ; i ++ ) freq [ chars [ i ] ] += 1 ; for ( auto st : strings ) { bool flag = true ; for ( auto c : st ) { if ( ! freq ) { flag = false ; break ; } } if ( flag ) res += st . length ( ) ; } return res ; } int main ( ) { vector < string > strings = { " hi " , " data " , " geeksforgeeks " } ; string chars = " tiadhae " ; cout << countCharacters ( strings , chars ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, res, stdc
Iterator variables: c, i, st
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; void arrayConstruct ( int N ) { for ( int i = 2 ; i <= N ; i = i + 2 ) cout << i << " ▁ " ; for ( int i = 1 ; i < N - 1 ; i = i + 2 ) cout << i << " ▁ " ; cout << N - 1 + ( N / 2 ) << endl ; } void createArray ( int N ) { if ( N % 4 == 0 ) arrayConstruct ( N ) ; else cout << -1 << endl ; } int main ( ) { int N = 8 ; createArray ( N ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int distinctSubstring ( string & P , string & Q , int K , int N ) { unordered_set < string > S ; for ( int i = 0 ; i < N ; ++ i ) { int sum = 0 ; string s ; for ( int j = i ; j < N ; ++ j ) { int pos = P [ j ] - ' a ' ; sum += Q [ pos ] - '0' ; s += P [ j ] ; if ( sum <= K ) { S . insert ( s ) ; } else { break ; } } } return S . size ( ) ; } int main ( ) { string S = " abcde " ; string W = "12345678912345678912345678" ; int K = 5 ; int N = S . length ( ) ; cout << distinctSubstring ( S , W , K , N ) ; return 0 ; }

Index/key variables: j, pos
Accumulator variables: s, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int distinctSubstring ( string & P , string & Q , int K , int N ) { unordered_set < string > S ; for ( int i = 0 ; i < N ; ++ i ) { int sum = 0 ; string s ; for ( int j = i ; j < N ; ++ j ) { int pos = P [ j ] - ' a ' ; sum += Q [ pos ] - '0' ; s += P [ j ] ; if ( sum <= K ) { S . insert ( s ) ; } else { break ; } } } return S . size ( ) ; } int main ( ) { string P = " abcde " ; string Q = "12345678912345678912345678" ; int K = 5 ; int N = P . length ( ) ; cout << distinctSubstring ( P , Q , K , N ) ; return 0 ; }

Index/key variables: j, pos
Accumulator variables: s, stdc, sum
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printPattern ( int n ) { int i , j ; for ( i = 1 ; i <= n ; i ++ ) { for ( j = 1 ; j < 2 * n ; j ++ ) { if ( j == ( n - i + 1 ) || j == ( n + i - 1 ) ) { cout << " * ▁ " ; } else if ( ( i >= 4 && i <= n - 4 ) && ( j == n - i + 4 j == n + i - 4 ) ) { cout << " * ▁ " ; } else if ( i == n || ( i == n - 4 && j >= n - ( n - 2 * 4 ) && j <= n + n - 2 * 4 ) ) { cout << " * ▁ " ; } else { cout << " ▁ " << " ▁ " ; } } cout << " STRNEWLINE " ; } } int main ( ) { int N = 9 ; printPattern ( N ) ; }

Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isKAlternating ( string s , int k ) { if ( s . length ( ) < k ) return false ; int checker = 0 ; for ( int i = 0 ; i < k ; i ++ ) { int bitAtIndex = s [ i ] - ' a ' ; if ( ( checker & ( 1 << bitAtIndex ) ) > 0 ) { return false ; } checker = checker | ( 1 << bitAtIndex ) ; } for ( int i = k ; i < s . length ( ) ; i ++ ) if ( s [ i - k ] != s [ i ] ) return false ; return true ; } int main ( ) { string str = " acdeac " ; int K = 4 ; if ( isKAlternating ( str , K ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include " bits / stdc + + . h "
using namespace std ; int MAX = 100000 ; void findFactors ( int N ) { int temp = sqrt ( N ) ; int factor [ MAX ] = { 1 } ; int i , j , k ; int len1 = 1 ; while ( temp % 2 == 0 ) { factor [ len1 ++ ] = 2 ; factor [ len1 ++ ] = 2 ; temp /= 2 ; } for ( j = 3 ; j < sqrt ( temp ) ; j += 2 ) { while ( temp % j == 0 ) { factor [ len1 ++ ] = j ; factor [ len1 ++ ] = j ; temp /= j ; } } if ( temp > 2 ) { factor [ len1 ++ ] = temp ; factor [ len1 ++ ] = temp ; } int M [ len1 ] [ MAX ] = { 0 } ; int tpc = 0 , tpr = 0 ; M [ 0 ] [ 0 ] = 1 ; j = 1 ; while ( j < len1 ) { if ( factor [ j ] != factor [ j - 1 ] ) { tpr ++ ; M [ tpr ] [ 0 ] = factor [ j ] ; j ++ ; tpc = 1 ; } else { M [ tpr ] [ tpc ] = M [ tpr ] [ tpc - 1 ] * factor [ j ] ; j ++ ; tpc ++ ; } } int arr1 [ MAX ] , arr2 [ MAX ] ; int l1 , l2 ; l1 = l2 = 1 ; arr1 [ 0 ] = arr2 [ 0 ] = 1 ; for ( i = 1 ; i < tpr + 1 ; i ++ ) { for ( j = 0 ; M [ i ] [ j ] != 0 ; j ++ ) { for ( k = 0 ; k < l1 ; k ++ ) { arr2 [ l2 ++ ] = arr1 [ k ] * M [ i ] [ j ] ; } } for ( j = l1 ; j < l2 ; j ++ ) { arr1 [ j ] = arr2 [ j ] ; } l1 = l2 ; } for ( i = 0 ; i < l2 ; i ++ ) { cout << arr2 [ i ] << ' ▁ ' ; } } int main ( ) { int N = 900 ; findFactors ( N ) ; return 0 ; }

Index/key variables: MAX, i, j, k, len1, tpc, tpr
Accumulator variables: i, j, k, l2, len1, temp, tpc, tpr
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; int matrix [ 100 ] [ 100 ] ; void printRequiredMatrix ( int n ) { if ( n == 1 ) { cout << "1" << " STRNEWLINE " ; } else if ( n % 2 != 0 ) { cout << " - 1" << " STRNEWLINE " ; } else { for ( int i = 0 ; i < n ; i ++ ) { matrix [ i ] [ i ] = n ; } int u = n - 1 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { matrix [ i ] [ u ] = i + 1 ; for ( int j = 1 ; j < n / 2 ; j ++ ) { int a = ( i + j ) % ( n - 1 ) ; int b = ( i - j + n - 1 ) % ( n - 1 ) ; if ( a < b ) swap ( a , b ) ; matrix [ b ] [ a ] = i + 1 ; } } for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < i ; j ++ ) matrix [ i ] [ j ] = matrix [ j ] [ i ] + n ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) cout << matrix [ i ] [ j ] << " ▁ " ; cout << " STRNEWLINE " ; } } cout << " STRNEWLINE " ; } int main ( ) { int n = 1 ; printRequiredMatrix ( n ) ; n = 3 ; printRequiredMatrix ( n ) ; n = 6 ; printRequiredMatrix ( n ) ; return 0 ; }

Index/key variables: a, b, i, j, u
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubstring ( string & S , int & n ) { int ans = 0 ; int i = 0 ; while ( i < n ) { int cnt0 = 0 , cnt1 = 0 ; if ( S [ i ] == '0' ) { while ( i < n && S [ i ] == '0' ) { cnt0 ++ ; i ++ ; } int j = i ; while ( j < n && S [ j ] == '1' ) { cnt1 ++ ; j ++ ; } } else { while ( i < n && S [ i ] == '1' ) { cnt1 ++ ; i ++ ; } int j = i ; while ( j < n && S [ j ] == '0' ) { cnt0 ++ ; j ++ ; } } ans += min ( cnt0 , cnt1 ) ; } return ans ; } int main ( ) { string S = "0001110010" ; int n = S . length ( ) ; cout << countSubstring ( S , n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, cnt0, cnt1, i, j, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findNumbers ( int n ) { int i = 1 ; while ( i <= n ) { cout << ( 3 * i * ( i - 1 ) + 1 ) << " ▁ " ; i ++ ; } } int main ( ) { int n = 4 ; findNumbers ( n ) ; }

Accumulator variables: i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; void decToOctal ( int n ) { int octalNum [ 100 ] ; int i = 0 ; while ( n != 0 ) { octalNum [ i ] = n % 8 ; n = n / 8 ; i ++ ; } for ( int j = i - 1 ; j >= 0 ; j -- ) cout << octalNum [ j ] ; cout << " STRNEWLINE " ; } void nDigitPerfectSquares ( int n ) { int decimal = pow ( ceil ( sqrt ( pow ( 8 , n ) ) ) - 1 , 2 ) ; decToOctal ( decimal ) ; } int main ( ) { int n = 2 ; nDigitPerfectSquares ( n ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void reverseStr ( string & str , int l , int h ) { int n = h - l ; for ( int i = 0 ; i < n / 2 ; i ++ ) { swap ( str [ i + l ] , str [ n - i - 1 + l ] ) ; } } void reverseString ( string & s , int A [ ] , int n ) { reverseStr ( s , 0 , A [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) reverseStr ( s , A [ i - 1 ] , A [ i ] ) ; reverseStr ( s , A [ n - 1 ] , s . length ( ) ) ; } int main ( ) { string s = " abcdefgh " ; int A [ ] = { 2 , 4 , 6 } ; int n = sizeof ( A ) / sizeof ( A [ 0 ] ) ; reverseString ( s , A , n ) ; cout << s ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool Formatted ( string s ) { vector < char > k ; int i = 0 ; while ( i < s . size ( ) ) { if ( s [ i ] == ' ) ' or s [ i ] == ' ( ' ) { k . push_back ( s [ i ] ) ; i += 1 ; } else { char st ; while ( s [ i ] != ' ) ' and s [ i ] != ' ) ' ) { st = s [ i ] ; i = i + 1 ; } k . push_back ( st ) ; } } int depth = 0 , flag = 1 ; int open = 0 , close = 0 ; for ( char i : k ) { if ( i == ' ( ' ) { depth += 1 ; open += 1 ; } else if ( i == ' ) ' ) { depth -= 1 ; close += 1 ; } else { if ( i - '0' != depth ) { flag = 0 ; break ; } } } if ( open != close ) flag = 0 ; return ( flag == 1 ) ? true : false ; } int main ( ) { string s = " ( (2 ) ( (3 ) ) ) " ; bool k = Formatted ( s ) ; if ( k == true ) printf ( " Yes " ) ; else printf ( " No " ) ; return 0 ; }

Index/key variables: i
Accumulator variables: close, depth, i, open, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findSum ( int * arr , int n , int k ) { if ( k <= n - 2 ) return ( arr [ n - 1 ] - arr [ 0 ] ) ; return 0 ; } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int n = sizeof ( arr ) / sizeof ( int ) ; int k = 1 ; cout << findSum ( arr , n , k ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxSubStr ( string str , int n ) { int count0 = 0 , count1 = 0 ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '0' ) { count0 ++ ; } else { count1 ++ ; } if ( count0 == count1 ) { cnt ++ ; } } if ( cnt == 0 ) { return -1 ; } return cnt ; } int main ( ) { string str = "0100110101" ; int n = str . length ( ) ; cout << maxSubStr ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: cnt, count0, count1, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define lli  long long int
lli squareDigitSum ( string s ) { lli lengthN = s . length ( ) ; lli result = ( lengthN / 9 ) * 81 + pow ( ( lengthN % 9 ) , 2 ) ; return result ; } int main ( ) { string s = "1111" ; cout << squareDigitSum ( s ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; string getString ( char x ) { string s ( 1 , x ) ; return s ; } bool solve ( string s1 , string s2 ) { string a = getString ( s1 [ 0 ] ) , b = getString ( s2 [ 0 ] ) ; for ( int i = 1 ; i < s1 . length ( ) ; i ++ ) if ( s1 [ i ] != s1 [ i - 1 ] ) { a += getString ( s1 [ i ] ) ; } for ( int i = 1 ; i < s2 . length ( ) ; i ++ ) if ( s2 [ i ] != s2 [ i - 1 ] ) { b += getString ( s2 [ i ] ) ; } if ( a == b ) return true ; return false ; } int main ( ) { string s1 = " Geeks " , s2 = " Geks " ; if ( solve ( s1 , s2 ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i
Accumulator variables: a, b, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define x  26
#define mod  3001
using namespace std ; int CntSubstr ( string s , int l ) { int hash = 0 ; for ( int i = 0 ; i < l ; i ++ ) { hash = ( hash * x + ( s [ i ] - 97 ) ) % mod ; } int pow_l = 1 ; for ( int i = 0 ; i < l - 1 ; i ++ ) pow_l = ( pow_l * x ) % mod ; unordered_set < int > result ; result . insert ( hash ) ; for ( int i = l ; i < s . size ( ) ; i ++ ) { hash = ( ( hash - pow_l * ( s [ i - l ] - 97 ) + 2 * mod ) * x + ( s [ i ] - 97 ) ) % mod ; result . insert ( hash ) ; } cout << result . size ( ) << endl ; } int main ( ) { string s = " abcba " ; int l = 2 ; CntSubstr ( s , l ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isValidString ( string str , int n ) { int index = find ( str . begin ( ) , str . end ( ) , ' b ' ) - str . begin ( ) ; if ( index == 0 ) return false ; while ( index <= n - 1 ) { if ( str [ index - 1 ] != ' a ' ) return false ; if ( index + 1 < n && str [ index + 1 ] != ' b ' ) return false ; if ( index + 2 < n && str [ index + 2 ] == ' b ' ) return false ; if ( index == n - 1 ) return false ; index = find ( str . begin ( ) + index + 2 , str . end ( ) , ' b ' ) - str . begin ( ) ; } return true ; } int main ( ) { string str = " abbaaabbabba " ; int n = str . length ( ) ; isValidString ( str , n ) ? cout << " true " : cout << " false " ; return 0 ; }

Accumulator variables: stdc