dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; string removeOddIndexCharacters ( string s ) { string new_string = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( i % 2 == 1 ) { continue ; } new_string += s [ i ] ; } return new_string ; } int main ( ) { string str = " abcdef " ; cout << removeOddIndexCharacters ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, new_string, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int longestGP ( int A [ ] , int N ) { if ( N < 2 ) return N ; int length = 1 , common_ratio = 1 ; int maxlength = 1 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( A [ i + 1 ] % A [ i ] == 0 ) { if ( A [ i + 1 ] / A [ i ] == common_ratio ) { length = length + 1 ; maxlength = max ( maxlength , length ) ; } else { common_ratio = A [ i + 1 ] / A [ i ] ; length = 2 ; } } else { maxlength = max ( maxlength , length ) ; length = 1 ; } } maxlength = max ( maxlength , length ) ; return maxlength ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 7 , 14 , 28 , 56 , 89 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << longestGP ( 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 uncrossedLines ( int * a , int * b , int n , int m ) { int dp [ n + 1 ] [ m + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= m ; j ++ ) { if ( i == 0 j == 0 ) dp [ i ] [ j ] = 0 ; else if ( a [ i - 1 ] == b [ j - 1 ] ) dp [ i ] [ j ] = 1 + dp [ i - 1 ] [ j - 1 ] ; else dp [ i ] [ j ] = max ( dp [ i - 1 ] [ j ] , dp [ i ] [ j - 1 ] ) ; } } return dp [ n ] [ m ] ; } int main ( ) { int A [ ] = { 3 , 9 , 2 } ; int B [ ] = { 3 , 2 , 9 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; int M = sizeof ( B ) / sizeof ( B [ 0 ] ) ; cout << uncrossedLines ( A , B , N , M ) ; return 0 ; }

Index/key variables: i, j, m, n
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minFlips ( vector < vector < int > > & mat , string s ) { int N = mat . size ( ) ; int M = mat [ 0 ] . size ( ) ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( mat [ i ] [ j ] != s [ i + j ] - '0' ) { count ++ ; } } } return count ; } int main ( ) { vector < vector < int > > mat = { { 1 , 0 , 1 } , { 0 , 1 , 1 } , { 0 , 0 , 0 } } ; string s = "10001" ; cout << minFlips ( mat , s ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void displaypath ( vector < vector < string > > & res ) { for ( int i = 0 ; i < res . size ( ) ; i ++ ) { cout << " [ ▁ " ; for ( int j = 0 ; j < res [ 0 ] . size ( ) ; j ++ ) { cout << res [ i ] [ j ] << " , ▁ " ; } cout << " ▁ ] STRNEWLINE " ; } } vector < string > addWord ( string word , unordered_set < string > & dict ) { vector < string > res ; for ( int i = 0 ; i < word . size ( ) ; i ++ ) { char s = word [ i ] ; for ( char c = ' a ' ; c <= ' z ' ; c ++ ) { word [ i ] = c ; if ( dict . count ( word ) ) res . push_back ( word ) ; } word [ i ] = s ; } return res ; } vector < vector < string > > findLadders ( vector < string > & Dict , string beginWord , string endWord ) { vector < vector < string > > res ; unordered_set < string > visit ; queue < vector < string > > q ; unordered_set < string > dict ( Dict . begin ( ) , Dict . end ( ) ) ; q . push ( { beginWord } ) ; bool flag = false ; while ( ! q . empty ( ) ) { int size = q . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { vector < string > cur = q . front ( ) ; q . pop ( ) ; vector < string > newadd ; newadd = addWord ( cur . back ( ) , dict ) ; for ( int j = 0 ; j < newadd . size ( ) ; j ++ ) { vector < string > newline ( cur . begin ( ) , cur . end ( ) ) ; newline . push_back ( newadd [ j ] ) ; if ( newadd [ j ] == endWord ) { flag = true ; res . push_back ( newline ) ; } visit . insert ( newadd [ j ] ) ; q . push ( newline ) ; } } if ( flag ) { break ; } for ( auto it : visit ) { dict . erase ( it ) ; } visit . clear ( ) ; } return res ; } int main ( ) { vector < string > str { " ted " , " tex " , " red " , " tax " , " tad " , " den " , " rex " , " pee " } ; string beginWord = " red " ; string endWord = " tax " ; vector < vector < string > > res = findLadders ( str , beginWord , endWord ) ; displaypath ( res ) ; }

Index/key variables: i, j
Accumulator variables: c, i, j, stdc
Iterator variables: c, i, it, j
Boolean variables: flag
C++ program:
#include <bits/stdc++.h>
using namespace std ; int revNum ( int N ) { int x = 0 ; while ( N ) { x = x * 10 + N % 10 ; N = N / 10 ; } return x ; } int ctNonPalin ( int arr [ ] , int N ) { int Res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int x = revNum ( arr [ i ] ) ; if ( x == arr [ i ] ) { continue ; } else { Res += ( arr [ i ] % 10 == N % 10 ) ; } } return Res ; } int main ( ) { int arr [ ] = { 121 , 134 , 2342 , 4514 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << ctNonPalin ( arr , N ) ; }

Index/key variables: i
Accumulator variables: Res, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minlt ( vector < int > arr , int target , int n ) { vector < vector < int > > dp ( arr . size ( ) + 1 , vector < int > ( target + 1 , -1 ) ) ; for ( int i = 0 ; i < arr . size ( ) + 1 ; i ++ ) dp [ i ] [ 0 ] = 0 ; for ( int j = 0 ; j < target + 1 ; j ++ ) dp [ 0 ] [ j ] = INT_MAX ; for ( int i = 1 ; i <= arr . size ( ) ; i ++ ) { for ( int j = 1 ; j <= target ; j ++ ) { if ( arr [ i - 1 ] > j ) { dp [ i ] [ j ] = dp [ i - 1 ] [ j ] ; } else { dp [ i ] [ j ] = min ( dp [ i - 1 ] [ j ] , ( dp [ i ] [ j - arr [ i - 1 ] ] ) != INT_MAX ? ( dp [ i ] [ j - arr [ i - 1 ] ] + 1 ) : INT_MAX ) ; } } } if ( dp [ arr . size ( ) ] [ target ] == INT_MAX ) { return -1 ; } else { return dp [ arr . size ( ) ] [ target ] ; } } int main ( ) { vector < int > arr = { 2 , 3 , 5 , 4 , 1 } ; int target = 11 ; int n = arr . size ( ) ; cout << minlt ( arr , target , n ) ; }

Index/key variables: i, j, target
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minServerLoads ( int n , vector < int > & servers ) { int totalLoad = 0 ; for ( int i : servers ) totalLoad += i ; int requiredLoad = totalLoad / 2 ; vector < vector < int > > dp ( n + 1 , vector < int > ( requiredLoad + 1 , 0 ) ) ; for ( int i = 1 ; i < n + 1 ; i ++ ) { for ( int j = 1 ; j < requiredLoad + 1 ; j ++ ) { if ( servers [ i - 1 ] > j ) dp [ i ] [ j ] = dp [ i - 1 ] [ j ] ; else dp [ i ] [ j ] = max ( dp [ i - 1 ] [ j ] , servers [ i - 1 ] + dp [ i - 1 ] [ j - servers [ i - 1 ] ] ) ; } } return totalLoad - 2 * dp [ n ] [ requiredLoad ] ; } int main ( ) { int N = 5 ; vector < int > servers = { 1 , 2 , 3 , 4 , 5 } ; cout << ( minServerLoads ( N , servers ) ) ; }

Index/key variables: i, j, n, requiredLoad
Accumulator variables: i, j, stdc, totalLoad
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxLenSub ( int arr [ ] , int N ) { int Pos = 0 ; int Neg = 0 ; int res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 0 ) { Pos = Neg = 0 ; } else if ( arr [ i ] > 0 ) { Pos += 1 ; if ( Neg != 0 ) { Neg += 1 ; } res = max ( res , Pos ) ; } else { swap ( Pos , Neg ) ; Neg += 1 ; if ( Pos != 0 ) { Pos += 1 ; } res = max ( res , Pos ) ; } } return res ; } int main ( ) { int arr [ ] = { -1 , -2 , -3 , 0 , 1 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << maxLenSub ( arr , N ) ; }

Index/key variables: i
Accumulator variables: Neg, Pos, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxLength ( vector < string > arr ) { int len = INT_MIN ; int N = arr . size ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int l = arr [ i ] . size ( ) ; if ( len < l ) { len = l ; } } return len ; } void maxStrings ( vector < string > arr , int len ) { int N = arr . size ( ) ; vector < string > ans ; for ( int i = 0 ; i < N ; i ++ ) { if ( len == arr [ i ] . size ( ) ) { ans . push_back ( arr [ i ] ) ; } } for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { cout << ans [ i ] << " ▁ " ; } } void printStrings ( vector < string > & arr ) { int max = maxLength ( arr ) ; maxStrings ( arr , max ) ; } int main ( ) { vector < string > arr = { " aba " , " aa " , " ad " , " vcd " , " aba " } ; printStrings ( arr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int min_flips ( string & str , int k ) { if ( str . size ( ) == 0 ) return 0 ; int ans = 0 ; int cnt_zeros = 0 ; for ( char ch : str ) { if ( ch == '0' ) { ++ cnt_zeros ; } else { cnt_zeros = 0 ; } if ( cnt_zeros == k ) { ++ ans ; cnt_zeros = 0 ; } } return ans ; } int main ( ) { string str = "11100000011" ; int k = 3 ; cout << min_flips ( str , k ) ; return 0 ; }

Accumulator variables: stdc
Iterator variables: ch
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < vector < int > > maxSubArray ( int arr [ ] , int n , int K ) { vector < vector < int > > solution ; int multi = 1 ; int start = 0 ; if ( n <= 1 K < 0 ) { return solution ; } for ( int i = 0 ; i < n ; i ++ ) { multi = multi * arr [ i ] ; while ( multi > K ) { multi = multi / arr [ start ] ; start ++ ; } vector < int > list ; for ( int j = i ; j >= start ; j -- ) { list . insert ( list . begin ( ) , arr [ j ] ) ; solution . push_back ( list ) ; } } return solution ; } int main ( ) { int arr [ ] = { 2 , 7 , 1 , 4 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int K = 7 ; vector < vector < int > > v = maxSubArray ( arr , n , K ) ; cout << " [ " ; bool first = true ; for ( auto x : v ) { if ( ! first ) { cout << " , ▁ " ; } else { first = false ; } cout << " [ " ; bool ff = true ; for ( int y : x ) { if ( ! ff ) { cout << " , ▁ " ; } else { ff = false ; } cout << y ; } cout << " ] " ; } cout << " ] " ; return 0 ; }

Index/key variables: i, j, start
Accumulator variables: i, j, start, stdc
Iterator variables: i, j, x, y
Boolean variables: ff, first
C++ program:
#include <bits/stdc++.h>
using namespace std ; int solve ( vector < vector < int > > & D , int N , int X , int Y ) { vector < double > T ; for ( int i = 0 ; i < N ; i ++ ) { int x = D [ i ] [ 0 ] ; int y = D [ i ] [ 1 ] ; double speed = D [ i ] [ 2 ] ; double time = ( ( x * x - X * X ) + ( y * y - Y * Y ) ) / ( speed * speed ) ; T . push_back ( time ) ; } sort ( T . begin ( ) , T . end ( ) ) ; int i = 0 ; int total = 0 ; while ( i < T . size ( ) - 1 ) { int count = 1 ; while ( i < T . size ( ) - 1 and T [ i ] == T [ i + 1 ] ) { count += 1 ; i += 1 ; } total += ( count * ( count - 1 ) ) / 2 ; i += 1 ; } return total ; } int main ( ) { int N = 5 ; vector < vector < int > > D = { { 5 , 12 , 1 } , { 16 , 63 , 5 } , { -10 , 24 , 2 } , { 7 , 24 , 2 } , { -24 , 7 , 2 } } ; int X = 0 , Y = 0 ; cout << ( solve ( D , N , X , Y ) ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc, total
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int getMaxLength ( int arr [ ] , int N ) { int res = 2 ; int dist = 2 ; int curradj = ( arr [ 1 ] - arr [ 0 ] ) ; int prevadj = ( arr [ 1 ] - arr [ 0 ] ) ; for ( int i = 2 ; i < N ; i ++ ) { curradj = arr [ i ] - arr [ i - 1 ] ; if ( curradj == prevadj ) { dist ++ ; } else { prevadj = curradj ; res = max ( res , dist ) ; dist = 2 ; } } res = max ( res , dist ) ; return res ; } int main ( ) { int arr [ ] = { 10 , 7 , 4 , 6 , 8 , 10 , 11 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << getMaxLength ( arr , N ) ; }

Index/key variables: i
Accumulator variables: dist, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <vector>
using namespace std ; int minSteps ( string str , int N ) { int smaller , cost = 0 ; int f [ 26 ] = { 0 } ; for ( int i = 0 ; i < N ; i ++ ) { int curr_ele = str [ i ] - ' a ' ; smaller = 0 ; for ( int j = 0 ; j <= curr_ele ; j ++ ) { if ( f [ j ] ) smaller += f [ j ] ; } if ( smaller == 0 ) cost += ( i + 1 ) ; else cost += ( i - smaller + 1 ) ; f [ str [ i ] - ' a ' ] ++ ; } return cost ; } int main ( ) { string str = " abcab " ; int N = str . size ( ) ; cout << minSteps ( str , N ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: cost, i, j, smaller, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; vector < int > findSubarrays ( vector < int > & a ) { int n = a . size ( ) ; vector < int > freq ( n + 1 ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 0 ) { if ( count == 0 ) continue ; else { int value = count ; for ( int j = 1 ; j <= count ; j ++ ) { freq [ j ] += value ; value -- ; } count = 0 ; } } else count ++ ; } if ( count > 0 ) { int value = count ; for ( int j = 1 ; j <= count ; j ++ ) { freq [ j ] += value ; value -- ; } } return freq ; } void countRectangles ( vector < int > & a , vector < int > & b , int K ) { int n = a . size ( ) ; int m = b . size ( ) ; vector < int > subA = findSubarrays ( a ) ; vector < int > subB = findSubarrays ( b ) ; int total = 0 ; for ( int i = 1 ; i < subA . size ( ) ; i ++ ) { if ( K % i == 0 and ( K / i ) <= m ) { total = total + subA [ i ] * subB [ K / i ] ; } } cout << total ; } int main ( ) { vector < int > a = { 0 , 0 , 1 , 1 } ; vector < int > b = { 1 , 0 , 1 } ; int K = 2 ; countRectangles ( a , b , K ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc, value
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printRes ( vector < int > & res ) { int n = res . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { cout << res [ i ] << " ▁ " ; } } void printLBS ( int arr [ ] , int N ) { int lis [ N ] ; int lds [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { lis [ i ] = lds [ i ] = 1 ; } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < i ; j ++ ) { if ( arr [ j ] < arr [ i ] ) { if ( lis [ i ] < lis [ j ] + 1 ) lis [ i ] = lis [ j ] + 1 ; } } } for ( int i = N - 1 ; i >= 0 ; i -- ) { for ( int j = N - 1 ; j > i ; j -- ) { if ( arr [ j ] < arr [ i ] ) { if ( lds [ i ] < lds [ j ] + 1 ) lds [ i ] = lds [ j ] + 1 ; } } } int MaxVal = arr [ 0 ] , inx = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( MaxVal < lis [ i ] + lds [ i ] - 1 ) { MaxVal = lis [ i ] + lds [ i ] - 1 ; inx = i ; } } int ct1 = lis [ inx ] ; vector < int > res ; for ( int i = inx ; i >= 0 && ct1 > 0 ; i -- ) { if ( lis [ i ] == ct1 ) { res . push_back ( arr [ i ] ) ; ct1 -- ; } } reverse ( res . begin ( ) , res . end ( ) ) ; int ct2 = lds [ inx ] - 1 ; for ( int i = inx ; i < N && ct2 > 0 ; i ++ ) { if ( lds [ i ] == ct2 ) { res . push_back ( arr [ i ] ) ; ct2 -- ; } } printRes ( res ) ; } int main ( ) { int arr [ ] = { 80 , 60 , 30 , 40 , 20 , 10 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; printLBS ( arr , N ) ; }

Index/key variables: N, i, inx, j
Accumulator variables: ct1, ct2, i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool possible ( int T , int arr [ ] , int n , int d ) { int partition = 1 ; int total = 0 ; for ( int i = 0 ; i < n ; i ++ ) { total = total + arr [ i ] ; if ( total > T ) { partition = partition + 1 ; total = arr [ i ] ; if ( partition > d ) { return false ; } } } return true ; } void calcT ( int n , int d , int arr [ ] ) { int mx = -1 , sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { mx = max ( mx , arr [ i ] ) ; sum = sum + arr [ i ] ; } int lb = mx ; int ub = sum ; while ( lb < ub ) { int T_mid = lb + ( ub - lb ) / 2 ; if ( possible ( T_mid , arr , n , d ) == true ) { ub = T_mid ; } else { lb = T_mid + 1 ; } } cout << lb << endl ; } int main ( ) { int d = 2 ; int arr [ ] = { 1 , 1 , 1 , 1 , 1 } ; int n = sizeof arr / sizeof arr [ 0 ] ; calcT ( n , d , arr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minReqSubstring ( string s , int n ) { char ongoing = ' N ' ; int count = 0 , l = s . size ( ) ; for ( int i = 1 ; i < l ; i ++ ) { if ( ongoing == ' N ' ) { if ( s [ i ] < s [ i - 1 ] ) { ongoing = ' D ' ; } else if ( s [ i ] == s [ i - 1 ] ) { ongoing = ' N ' ; } else { ongoing = ' I ' ; } } else if ( ongoing == ' I ' ) { if ( s [ i ] > s [ i - 1 ] ) { ongoing = ' I ' ; } else if ( s [ i ] == s [ i - 1 ] ) { ongoing = ' I ' ; } else { ongoing = ' N ' ; count += 1 ; } } else { if ( s [ i ] < s [ i - 1 ] ) { ongoing = ' D ' ; } else if ( s [ i ] == s [ i - 1 ] ) { ongoing = ' D ' ; } else { ongoing = ' N ' ; count += 1 ; } } } return count + 1 ; } int main ( ) { string S = " aeccdhba " ; int n = S . size ( ) ; cout << ( minReqSubstring ( S , n ) ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimum_required_operations ( int arr [ ] , int n , int k ) { int answer = 0 ; long long mod = 1000000007 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] + arr [ i + 1 ] > k ) { if ( arr [ i ] > k ) { answer += ( arr [ i ] - k ) ; arr [ i ] = k ; } answer += ( arr [ i ] + arr [ i + 1 ] ) - k ; arr [ i + 1 ] = ( k - arr [ i ] ) ; answer %= mod ; } } return answer ; } int main ( ) { int a [ ] = { 9 , 50 , 4 , 14 , 42 , 89 } ; int k = 10 ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << ( minimum_required_operations ( a , n , k ) ) ; return 0 ; }

Index/key variables: i
Accumulator variables: answer, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string findSmallestString ( string str1 , string str2 ) { int freq1 [ 26 ] , freq2 [ 26 ] ; memset ( freq1 , 0 , sizeof freq1 ) ; memset ( freq2 , 0 , sizeof freq2 ) ; int n1 = str1 . length ( ) ; int n2 = str2 . length ( ) ; for ( int i = 0 ; i < n1 ; ++ i ) { freq1 [ str1 [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < n2 ; ++ i ) { freq2 [ str2 [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; ++ i ) { freq1 [ i ] -= freq2 [ i ] ; } string res = " " ; int minIndex = str2 [ 0 ] - ' a ' ; for ( int i = 0 ; i < 26 ; ++ i ) { for ( int j = 0 ; j < freq1 [ i ] ; ++ j ) { res += ( char ) ( i + ' a ' ) ; } if ( i == minIndex ) { res += str2 ; } } return res ; } int main ( ) { string str1 = " geeksforgeeksfor " ; string str2 = " for " ; cout << findSmallestString ( str1 , str2 ) ; }

Index/key variables: i
Accumulator variables: res, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int decryptString ( string s , unsigned int N ) { for ( unsigned int i = 0 ; i < s . size ( ) ; i += 2 * N ) { auto end = s . begin ( ) + i + N ; if ( i + N > s . size ( ) ) end = s . end ( ) ; reverse ( s . begin ( ) + i , end ) ; } cout << s << endl ; } int main ( ) { string s = " ihTs ▁ suohld ▁ ebeas ! y " ; unsigned int N = 3 ; decryptString ( s , N ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void determineWinner ( string str ) { vector < int > A ( 10 ) ; int sum1 = 0 , sum2 = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { A [ int ( str [ i ] ) - 48 ] ++ ; } for ( int i = 0 ; i <= 9 ; i ++ ) { if ( i % 2 != 0 ) { sum1 = sum1 + A [ i ] ; } else { sum2 = sum2 + A [ i ] ; } } if ( sum1 == sum2 ) { cout << " - 1" ; } else if ( sum1 > sum2 ) { cout << " Player ▁ 1" ; } else { cout << " Player ▁ 2" ; } } int main ( ) { string str = "78787" ; determineWinner ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void manipulateStrings ( string P , string Q ) { int freq [ 26 ] ; memset ( freq , 0 , sizeof ( freq ) ) ; for ( int i = 0 ; i < P . size ( ) ; i ++ ) { freq [ P [ i ] - ' a ' ] ++ ; } for ( int i = 0 ; i < Q . size ( ) ; i ++ ) { freq [ Q [ i ] - ' a ' ] -- ; } string sb = " " ; int pos = Q [ 0 ] - ' a ' ; for ( int i = 0 ; i <= pos ; i ++ ) { while ( freq [ i ] > 0 ) { char c = ( char ) ( ' a ' + i ) ; sb += c ; freq [ i ] -- ; } } sb += Q ; for ( int i = pos + 1 ; i < 26 ; i ++ ) { while ( freq [ i ] > 0 ) { char c = ( char ) ( ' a ' + i ) ; sb += c ; freq [ i ] -- ; } } cout << sb << endl ; } int main ( ) { string P = " geeksforgeeksfor " ; string Q = " for " ; manipulateStrings ( P , Q ) ; }

Index/key variables: i
Accumulator variables: i, sb, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numberMoves ( string s ) { int row [ ] = { 2 , 3 , 3 , 2 , 1 , 2 , 2 , 2 , 1 , 2 , 2 , 2 , 3 , 3 , 1 , 1 , 1 , 1 , 2 , 1 , 1 , 3 , 1 , 3 , 1 , 3 } ; int n = s . length ( ) ; int move = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( row [ s [ i ] - ' a ' ] != row [ s [ i - 1 ] - ' a ' ] ) { move ++ ; } } return move ; } int main ( ) { string str = " geeksforgeeks " ; cout << numberMoves ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, move, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int L ; int R ; int K ; } ; int kMultipleSum ( int arr [ ] , Node Query [ ] , int N , int Q ) { int prefixSum [ N + 1 ] [ N ] ; for ( int i = 1 ; i <= N ; i ++ ) { prefixSum [ i ] [ 0 ] = arr [ 0 ] ; for ( int j = 0 ; j < N ; j ++ ) { if ( j % i == 0 ) { prefixSum [ i ] [ j ] = arr [ j ] + prefixSum [ i ] [ j - 1 ] ; } else { prefixSum [ i ] [ j ] = prefixSum [ i ] [ j - 1 ] ; } } } for ( int i = 0 ; i < Q ; i ++ ) { int last = prefixSum [ Query [ i ] . K ] [ Query [ i ] . R ] ; int first ; if ( Query [ i ] . L == 0 ) { first = prefixSum [ Query [ i ] . K ] [ Query [ i ] . L ] ; } else { first = prefixSum [ Query [ i ] . K ] [ Query [ i ] . L - 1 ] ; } cout << last - first << endl ; } } int main ( ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int N = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int Q = 2 ; Node Query [ Q ] ; Query [ 0 ] . L = 2 , Query [ 0 ] . R = 5 , Query [ 0 ] . K = 2 ; Query [ 1 ] . L = 3 , Query [ 1 ] . R = 5 , Query [ 1 ] . K = 5 ; kMultipleSum ( arr , Query , N , Q ) ; }

Index/key variables: N, Q, i, j
Accumulator variables: i, j, stdc
Iterator variables: i, j
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; int mod = 1000000007 ; long countS ( string str [ ] , int n , int m ) { unordered_map < int , unordered_set < char > > counts ; for ( int i = 0 ; i < n ; i ++ ) { string s = str [ i ] ; for ( int j = 0 ; j < m ; j ++ ) { counts [ j ] . insert ( s [ j ] ) ; } } long result = 1 ; for ( auto index : counts ) { result = ( result * counts [ index . first ] . size ( ) ) % mod ; } return result ; } int main ( ) { string str [ ] = { "112" , "211" } ; int N = 2 , M = 3 ; cout << countS ( str , N , M ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, stdc
Iterator variables: i, index, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void solve ( int n , int arr [ ] ) { int i , ans = 0 ; for ( i = 0 ; i < n ; i ++ ) { int left = max ( i - 1 , 0 ) ; int right = min ( n - 1 , i + 1 ) ; while ( left >= 0 ) { if ( arr [ left ] > arr [ i ] ) { left ++ ; break ; } left -- ; } if ( left < 0 ) left ++ ; while ( right < n ) { if ( arr [ right ] > arr [ i ] ) { right -- ; break ; } right ++ ; } if ( right >= n ) right -- ; ans = 1 + right - left ; cout << ans << " ▁ " ; } } int main ( ) { int arr [ ] = { 4 , 2 , 1 } ; int n = sizeof arr / sizeof arr [ 0 ] ; solve ( n , arr ) ; return 0 ; }

Index/key variables: i, left, right
Accumulator variables: i, left, right, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countSubstrings ( string s , int n ) { int count = 0 , sum = 0 ; unordered_map < int , int > mp ; mp [ 0 ] ++ ; for ( int i = 0 ; i < n ; ++ i ) { sum += ( s [ i ] - '0' ) ; count += mp [ sum - ( i + 1 ) ] ; ++ mp [ sum - ( i + 1 ) ] ; } return count ; } int main ( ) { string str = "112112" ; int n = str . length ( ) ; cout << countSubstrings ( str , n ) << endl ; return 0 ; }

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