dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; unsigned long int binomialCoeff ( unsigned long int n , unsigned long int k ) { unsigned long int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } unsigned long int countOfString ( int N ) { unsigned long int Stotal = pow ( 2 , N ) ; unsigned long int Sequal = 0 ; if ( N % 2 == 0 ) Sequal = binomialCoeff ( N , N / 2 ) ; unsigned long int S1 = ( Stotal - Sequal ) / 2 ; return S1 ; } int main ( ) { int N = 3 ; cout << countOfString ( N ) ; return 0 ; }

Accumulator variables: res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string removeCharRecursive ( string str , char X ) { if ( str . length ( ) == 0 ) { return " " ; } if ( str [ 0 ] == X ) { return removeCharRecursive ( str . substr ( 1 ) , X ) ; } return str [ 0 ] + removeCharRecursive ( str . substr ( 1 ) , X ) ; } int main ( ) { string str = " geeksforgeeks " ; char X = ' e ' ; str = removeCharRecursive ( str , X ) ; cout << str ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isValid ( char a1 , char a2 , string str , int flag ) { char v1 , v2 ; if ( flag == 0 ) { v1 = str [ 4 ] ; v2 = str [ 3 ] ; } else { v1 = str [ 1 ] ; v2 = str [ 0 ] ; } if ( v1 != a1 && v1 != ' ? ' ) return false ; if ( v2 != a2 && v2 != ' ? ' ) return false ; return true ; } bool inRange ( int hh , int mm , int L , int R ) { int a = abs ( hh - mm ) ; if ( a < L a > R ) return false ; return true ; } void displayTime ( int hh , int mm ) { if ( hh > 10 ) cout << hh << " : " ; else if ( hh < 10 ) cout << "0" << hh << " : " ; if ( mm > 10 ) cout << mm << endl ; else if ( mm < 10 ) cout << "0" << mm << endl ; } void maximumTimeWithDifferenceInRange ( string str , int L , int R ) { int i , j ; int h1 , h2 , m1 , m2 ; for ( i = 23 ; i >= 0 ; i -- ) { h1 = i % 10 ; h2 = i / 10 ; if ( ! isValid ( h1 + '0' , h2 + '0' , str , 1 ) ) { continue ; } for ( j = 59 ; j >= 0 ; j -- ) { m1 = j % 10 ; m2 = j / 10 ; if ( ! isValid ( m1 + '0' , m2 + '0' , str , 0 ) ) { continue ; } if ( inRange ( i , j , L , R ) ) { displayTime ( i , j ) ; return ; } } } if ( inRange ( i , j , L , R ) ) displayTime ( i , j ) ; else cout << " - 1" << endl ; } int main ( ) { string timeValue = " ? ? : ? ? " ; int L = 20 , R = 39 ; maximumTimeWithDifferenceInRange ( timeValue , L , R ) ; return 0 ; }

Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( string s , int n ) { stack < char > st ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! st . empty ( ) && st . top ( ) == s [ i ] ) st . pop ( ) ; else st . push ( s [ i ] ) ; } if ( st . empty ( ) ) { return true ; } else { return false ; } } int main ( ) { string str = " aanncddc " ; int n = str . length ( ) ; if ( check ( str , n ) ) { 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 ; void findNumOfValidWords ( vector < string > & w , vector < string > & p ) { unordered_map < int , int > m ; vector < int > res ; for ( string & s : w ) { int val = 0 ; for ( char c : s ) { val = val | ( 1 << ( c - ' a ' ) ) ; } m [ val ] ++ ; } for ( string & s : p ) { int val = 0 ; for ( char c : s ) { val = val | ( 1 << ( c - ' a ' ) ) ; } int temp = val ; int first = s [ 0 ] - ' a ' ; int count = 0 ; while ( temp != 0 ) { if ( ( ( temp >> first ) & 1 ) == 1 ) { if ( m . find ( temp ) != m . end ( ) ) { count += m [ temp ] ; } } temp = ( temp - 1 ) & val ; } res . push_back ( count ) ; } for ( auto & it : res ) { cout << it << ' ' ; } } int main ( ) { vector < string > arr1 ; arr1 = { " aaaa " , " asas " , " able " , " ability " , " actt " , " actor " , " access " } ; vector < string > arr2 ; arr2 = { " aboveyz " , " abrodyz " , " absolute " , " absoryz " , " actresz " , " gaswxyz " } ; findNumOfValidWords ( arr1 , arr2 ) ; return 0 ; }

Index/key variables: temp, val
Accumulator variables: count, stdc
Iterator variables: c
C++ program:
#include <bits/stdc++.h>
using namespace std ; void flip ( string & s ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s [ i ] == '0' ) { while ( s [ i ] == '0' ) { s [ i ] = '1' ; i ++ ; } break ; } } } int main ( ) { string s = "100010001" ; flip ( s ) ; cout << s ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void getOrgString ( string s ) { cout << s [ 0 ] ; int i = 1 ; while ( i < s . length ( ) ) { if ( s [ i ] >= ' A ' && s [ i ] <= ' Z ' ) cout << " ▁ " << ( char ) tolower ( s [ i ] ) ; else cout << s [ i ] ; i ++ ; } } int main ( ) { string s = " ILoveGeeksForGeeks " ; getOrgString ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countChar ( string str , char x ) { int count = 0 , n = 10 ; for ( int i = 0 ; i < str . size ( ) ; i ++ ) if ( str [ i ] == x ) count ++ ; int repetitions = n / str . size ( ) ; count = count * repetitions ; for ( int i = 0 ; i < n % str . size ( ) ; i ++ ) { if ( str [ i ] == x ) count ++ ; } return count ; } int main ( ) { string str = " abcac " ; cout << countChar ( str , ' a ' ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void countFreq ( int arr [ ] , int n , int limit ) { vector < int > count ( limit + 1 , 0 ) ; for ( int i = 0 ; i < n ; i ++ ) count [ arr [ i ] ] ++ ; for ( int i = 0 ; i <= limit ; i ++ ) if ( count [ i ] > 0 ) cout << i << " ▁ " << count [ i ] << endl ; } int main ( ) { int arr [ ] = { 5 , 5 , 6 , 6 , 5 , 6 , 1 , 2 , 3 , 10 , 10 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int limit = 10 ; countFreq ( arr , n , limit ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std ; bool check ( string s , int m ) { int l = s . length ( ) ; int c1 = 0 ; int c2 = 0 ; for ( int i = 0 ; i < l ; i ++ ) { if ( s [ i ] == '0' ) { c2 = 0 ; c1 ++ ; } else { c1 = 0 ; c2 ++ ; } if ( c1 == m c2 == m ) return true ; } return false ; } int main ( ) { string s = "001001" ; int m = 2 ; if ( check ( s , m ) ) cout << " YES " ; else cout << " NO " ; return 0 ; }

Index/key variables: i
Accumulator variables: c1, c2, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int productAtKthLevel ( string tree , int k ) { int level = -1 ; int n = tree . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( tree [ i ] == ' ( ' ) level ++ ; else if ( tree [ i ] == ' ) ' ) level -- ; else { if ( level == k ) product *= ( tree [ i ] - '0' ) ; } } return product ; } int main ( ) { string tree = " ( 0(5(6 ( ) ( ) ) ( 4 ( ) (9 ( ) ( ) ) ) ) ( 7(1 ( ) ( ) ) ( 3 ( ) ( ) ) ) ) " ; int k = 2 ; cout << productAtKthLevel ( tree , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, level, product, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void findDuplciates ( string a [ ] , int n , int m ) { bool isPresent [ n ] [ m ] ; memset ( isPresent , 0 , sizeof ( isPresent ) ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { for ( int k = 0 ; k < n ; k ++ ) { if ( a [ i ] [ j ] == a [ k ] [ j ] && i != k ) { isPresent [ i ] [ j ] = true ; isPresent [ k ] [ j ] = true ; } } for ( int k = 0 ; k < m ; k ++ ) { if ( a [ i ] [ j ] == a [ i ] [ k ] && j != k ) { isPresent [ i ] [ j ] = true ; isPresent [ i ] [ k ] = true ; } } } } for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < m ; j ++ ) if ( ! isPresent [ i ] [ j ] ) printf ( " % c " , a [ i ] [ j ] ) ; } int main ( ) { int n = 2 , m = 5 ; string a [ ] = { " zx " , " xz " } ; findDuplciates ( a , n , m ) ; return 0 ; }

Index/key variables: i, j, k, m, n
Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isValidISBN ( string & isbn ) { int n = isbn . length ( ) ; if ( n != 10 ) return false ; int sum = 0 ; for ( int i = 0 ; i < 9 ; i ++ ) { int digit = isbn [ i ] - '0' ; if ( 0 > digit 9 < digit ) return false ; sum += ( digit * ( 10 - i ) ) ; } char last = isbn [ 9 ] ; if ( last != ' X ' && ( last < '0' last > '9' ) ) return false ; sum += ( ( last == ' X ' ) ? 10 : ( last - '0' ) ) ; return ( sum % 11 == 0 ) ; } int main ( ) { string isbn = "007462542X " ; if ( isValidISBN ( isbn ) ) cout << " Valid " ; else cout << " Invalid " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isVowel ( char c ) { return ( c == ' a ' c == ' A ' c == ' e ' c == ' E ' c == ' i ' c == ' I ' c == ' o ' c == ' O ' c == ' u ' c == ' U ' ) ; } string reverseVowel ( string str ) { int j = 0 ; string vowel ; for ( int i = 0 ; str [ i ] != ' \0' ; i ++ ) if ( isVowel ( str [ i ] ) ) vowel [ j ++ ] = str [ i ] ; for ( int i = 0 ; str [ i ] != ' \0' ; i ++ ) if ( isVowel ( str [ i ] ) ) str [ i ] = vowel [ -- j ] ; return str ; } int main ( ) { string str = " hello ▁ world " ; cout << reverseVowel ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string firstLetterWord ( string str ) { string result = " " ; bool v = true ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] == ' ▁ ' ) v = true ; else if ( str [ i ] != ' ▁ ' && v == true ) { result . push_back ( str [ i ] ) ; v = false ; } } return result ; } int main ( ) { string str = " geeks ▁ for ▁ geeks " ; cout << firstLetterWord ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
Boolean variables: v
C++ program:
#include <bits/stdc++.h>
using namespace std ; void dfs ( int i , int j , vector < vector < int > > & grid , vector < vector < bool > > & vis , int & ans , int z , int z_count ) { int n = grid . size ( ) , m = grid [ 0 ] . size ( ) ; vis [ i ] [ j ] = 1 ; if ( grid [ i ] [ j ] == 0 ) z ++ ; if ( grid [ i ] [ j ] == 2 ) { if ( z == z_count ) ans ++ ; vis [ i ] [ j ] = 0 ; return ; } if ( i >= 1 && ! vis [ i - 1 ] [ j ] && grid [ i - 1 ] [ j ] != -1 ) dfs ( i - 1 , j , grid , vis , ans , z , z_count ) ; if ( i < n - 1 && ! vis [ i + 1 ] [ j ] && grid [ i + 1 ] [ j ] != -1 ) dfs ( i + 1 , j , grid , vis , ans , z , z_count ) ; if ( j >= 1 && ! vis [ i ] [ j - 1 ] && grid [ i ] [ j - 1 ] != -1 ) dfs ( i , j - 1 , grid , vis , ans , z , z_count ) ; if ( j < m - 1 && ! vis [ i ] [ j + 1 ] && grid [ i ] [ j + 1 ] != -1 ) dfs ( i , j + 1 , grid , vis , ans , z , z_count ) ; vis [ i ] [ j ] = 0 ; } int uniquePaths ( vector < vector < int > > & grid ) { int n = grid . size ( ) , m = grid [ 0 ] . size ( ) ; int ans = 0 ; vector < vector < bool > > vis ( n , vector < bool > ( m , 0 ) ) ; int x , y ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < m ; ++ j ) { if ( grid [ i ] [ j ] == 0 ) z_count ++ ; else if ( grid [ i ] [ j ] == 1 ) { x = i , y = j ; } } } dfs ( x , y , grid , vis , ans , 0 , z_count ) ; return ans ; } int main ( ) { vector < vector < int > > grid { { 1 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 } , { 0 , 0 , 2 , -1 } } ; cout << uniquePaths ( grid ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: ans, stdc, z, z_count
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int numPairs ( int a [ ] , int n ) { int ans , i , index ; ans = 0 ; for ( i = 0 ; i < n ; i ++ ) a [ i ] = abs ( a [ i ] ) ; sort ( a , a + n ) ; for ( i = 0 ; i < n ; i ++ ) { index = upper_bound ( a , a + n , 2 * a [ i ] ) - a ; ans += index - i - 1 ; } return ans ; } int main ( ) { int a [ ] = { 3 , 6 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << numPairs ( a , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: ans, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int maxPointOfIntersection ( int x , int y ) { int k = y * ( y - 1 ) / 2 ; k = k + x * ( 2 * y + x - 1 ) ; return k ; } int main ( ) { int x = 3 ; int y = 4 ; cout << ( maxPointOfIntersection ( x , y ) ) ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int Icosihenagonal_num ( int n ) { return ( 19 * n * n - 17 * n ) / 2 ; } int main ( ) { int n = 3 ; cout << Icosihenagonal_num ( n ) << endl ; n = 10 ; cout << Icosihenagonal_num ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; pair < double , double > find_Centroid ( vector < pair < double , double > > & v ) { pair < double , double > ans = { 0 , 0 } ; int n = v . size ( ) ; double signedArea = 0 ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { double x0 = v [ i ] . first , y0 = v [ i ] . second ; double x1 = v [ ( i + 1 ) % n ] . first , y1 = v [ ( i + 1 ) % n ] . second ; double A = ( x0 * y1 ) - ( x1 * y0 ) ; signedArea += A ; ans . first += ( x0 + x1 ) * A ; ans . second += ( y0 + y1 ) * A ; } signedArea *= 0.5 ; ans . first = ( ans . first ) / ( 6 * signedArea ) ; ans . second = ( ans . second ) / ( 6 * signedArea ) ; return ans ; } int main ( ) { vector < pair < double , double > > vp = { { 1 , 2 } , { 3 , -4 } , { 6 , -7 } } ; pair < double , double > ans = find_Centroid ( vp ) ; cout << setprecision ( 12 ) << ans . first << " ▁ " << ans . second << ' ' ; return 0 ; }

Index/key variables: i
Accumulator variables: first, i, second, signedArea, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define ll  long long int
using namespace std ; int main ( ) { int d = 10 ; double a ; a = ( double ) ( 360 - ( 6 * d ) ) / 4 ; cout << a << " , ▁ " << a + d << " , ▁ " << a + ( 2 * d ) << " , ▁ " << a + ( 3 * d ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
#include <math.h>
using namespace std ; void distance ( float a1 , float b1 , float c1 , float d1 , float a2 , float b2 , float c2 , float d2 ) { float x1 , y1 , z1 , d ; if ( a1 / a2 == b1 / b2 && b1 / b2 == c1 / c2 ) { x1 = y1 = 0 ; z1 = - d1 / c1 ; d = fabs ( ( c2 * z1 + d2 ) ) / ( sqrt ( a2 * a2 + b2 * b2 + c2 * c2 ) ) ; cout << " Perpendicular ▁ distance ▁ is ▁ " << d << endl ; } else cout << " Planes ▁ are ▁ not ▁ parallel " ; return ; } int main ( ) { float a1 = 1 ; float b1 = 2 ; float c1 = -1 ; float d1 = 1 ; float a2 = 3 ; float b2 = 6 ; float c2 = -3 ; float d2 = -4 ; distance ( a1 , b1 , c1 , d1 , a2 , b2 , c2 , d2 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int factorial ( int n ) { if ( n == 0 ) return 1 ; return n * factorial ( n - 1 ) ; } long long numOfNecklace ( int N ) { long long ans = factorial ( N ) / ( factorial ( N / 2 ) * factorial ( N / 2 ) ) ; ans = ans * factorial ( N / 2 - 1 ) ; ans = ans * factorial ( N / 2 - 1 ) ; ans /= 2 ; return ans ; } int main ( ) { int N = 4 ; cout << numOfNecklace ( N ) << endl ; return 0 ; }

Accumulator variables: ans, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string isDivisibleByDivisor ( int S , int D ) { S %= D ; unordered_set < int > hashMap ; hashMap . insert ( S ) ; for ( int i = 0 ; i <= D ; i ++ ) { S += ( S % D ) ; S %= D ; if ( hashMap . find ( S ) != hashMap . end ( ) ) { if ( S == 0 ) { return " Yes " ; } return " No " ; } else hashMap . insert ( S ) ; } return " Yes " ; } int main ( ) { int S = 3 , D = 6 ; cout << isDivisibleByDivisor ( S , D ) ; return 0 ; }

Accumulator variables: S, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int minimumSteps ( int x , int y ) { int cnt = 0 ; while ( x != 0 && y != 0 ) { if ( x > y ) { cnt += x / y ; x %= y ; } else { cnt += y / x ; y %= x ; } } cnt -- ; if ( x > 1 y > 1 ) cnt = -1 ; cout << cnt ; } int main ( ) { int x = 3 , y = 1 ; minimumSteps ( x , y ) ; return 0 ; }

Accumulator variables: cnt, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool check ( int A [ ] , int N ) { stack < int > S ; int B_end = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ! S . empty ( ) ) { int top = S . top ( ) ; while ( top == B_end + 1 ) { B_end = B_end + 1 ; S . pop ( ) ; if ( S . empty ( ) ) { break ; } top = S . top ( ) ; } if ( S . empty ( ) ) { S . push ( A [ i ] ) ; } else { top = S . top ( ) ; if ( A [ i ] < top ) { S . push ( A [ i ] ) ; } else { return false ; } } } else { S . push ( A [ i ] ) ; } } return true ; } int main ( ) { int A [ ] = { 4 , 1 , 2 , 3 } ; int N = sizeof ( A ) / sizeof ( A [ 0 ] ) ; check ( A , N ) ? cout << " YES " : cout << " NO " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countMinReversals ( string expr ) { int len = expr . length ( ) ; if ( len % 2 ) return -1 ; stack < char > s ; for ( int i = 0 ; i < len ; i ++ ) { if ( expr [ i ] == ' } ' && ! s . empty ( ) ) { if ( s . top ( ) == ' { ' ) s . pop ( ) ; else s . push ( expr [ i ] ) ; } else s . push ( expr [ i ] ) ; } int red_len = s . size ( ) ; int n = 0 ; while ( ! s . empty ( ) && s . top ( ) == ' { ' ) { s . pop ( ) ; n ++ ; } return ( red_len / 2 + n % 2 ) ; } int main ( ) { string expr = " } } { { " ; cout << countMinReversals ( expr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, n, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countMinReversals ( string expr ) { int len = expr . length ( ) ; if ( len % 2 != 0 ) { return -1 ; } int left_brace = 0 , right_brace = 0 ; int ans ; for ( int i = 0 ; i < len ; i ++ ) { if ( expr [ i ] == ' { ' ) { left_brace ++ ; } else { if ( left_brace == 0 ) { right_brace ++ ; } else { left_brace -- ; } } } ans = ceil ( left_brace / 2 ) + ceil ( right_brace / 2 ) ; return ans ; } int main ( ) { string expr = " } } { { " ; cout << countMinReversals ( expr ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, left_brace, right_brace, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void PrintMinNumberForPattern ( string arr ) { int curr_max = 0 ; int last_entry = 0 ; int j ; for ( int i = 0 ; i < arr . length ( ) ; i ++ ) { int noOfNextD = 0 ; switch ( arr [ i ] ) { case ' I ' : j = i + 1 ; while ( arr [ j ] == ' D ' && j < arr . length ( ) ) { noOfNextD ++ ; j ++ ; } if ( i == 0 ) { curr_max = noOfNextD + 2 ; cout << " ▁ " << ++ last_entry ; cout << " ▁ " << curr_max ; last_entry = curr_max ; } else { curr_max = curr_max + noOfNextD + 1 ; last_entry = curr_max ; cout << " ▁ " << last_entry ; } for ( int k = 0 ; k < noOfNextD ; k ++ ) { cout << " ▁ " << -- last_entry ; i ++ ; } break ; case ' D ' : if ( i == 0 ) { j = i + 1 ; while ( arr [ j ] == ' D ' && j < arr . length ( ) ) { noOfNextD ++ ; j ++ ; } curr_max = noOfNextD + 2 ; cout << " ▁ " << curr_max << " ▁ " << curr_max - 1 ; last_entry = curr_max - 1 ; } else { cout << " ▁ " << last_entry - 1 ; last_entry -- ; } break ; } } cout << endl ; } int main ( ) { PrintMinNumberForPattern ( " IDID " ) ; PrintMinNumberForPattern ( " I " ) ; PrintMinNumberForPattern ( " DD " ) ; PrintMinNumberForPattern ( " II " ) ; PrintMinNumberForPattern ( " DIDI " ) ; PrintMinNumberForPattern ( " IIDDD " ) ; PrintMinNumberForPattern ( " DDIDDIID " ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, k, last_entry, noOfNextD, stdc
Iterator variables: i, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printLeast ( string arr ) { int min_avail = 1 , pos_of_I = 0 ; vector < int > v ; if ( arr [ 0 ] == ' I ' ) { v . push_back ( 1 ) ; v . push_back ( 2 ) ; min_avail = 3 ; pos_of_I = 1 ; } else { v . push_back ( 2 ) ; v . push_back ( 1 ) ; min_avail = 3 ; pos_of_I = 0 ; } for ( int i = 1 ; i < arr . length ( ) ; i ++ ) { if ( arr [ i ] == ' I ' ) { v . push_back ( min_avail ) ; min_avail ++ ; pos_of_I = i + 1 ; } else { v . push_back ( v [ i ] ) ; for ( int j = pos_of_I ; j <= i ; j ++ ) v [ j ] ++ ; min_avail ++ ; } } for ( int i = 0 ; i < v . size ( ) ; i ++ ) cout << v [ i ] << " ▁ " ; cout << endl ; } int main ( ) { printLeast ( " IDID " ) ; printLeast ( " I " ) ; printLeast ( " DD " ) ; printLeast ( " II " ) ; printLeast ( " DIDI " ) ; printLeast ( " IIDDD " ) ; printLeast ( " DDIDDIID " ) ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j, min_avail, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void PrintMinNumberForPattern ( string seq ) { string result ; stack < int > stk ; for ( int i = 0 ; i <= seq . length ( ) ; i ++ ) { stk . push ( i + 1 ) ; if ( i == seq . length ( ) seq [ i ] == ' I ' ) { while ( ! stk . empty ( ) ) { result += to_string ( stk . top ( ) ) ; result += " ▁ " ; stk . pop ( ) ; } } } cout << result << endl ; } int main ( ) { PrintMinNumberForPattern ( " IDID " ) ; PrintMinNumberForPattern ( " I " ) ; PrintMinNumberForPattern ( " DD " ) ; PrintMinNumberForPattern ( " II " ) ; PrintMinNumberForPattern ( " DIDI " ) ; PrintMinNumberForPattern ( " IIDDD " ) ; PrintMinNumberForPattern ( " DDIDDIID " ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, result, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string getMinNumberForPattern ( string seq ) { int n = seq . length ( ) ; if ( n >= 9 ) return " - 1" ; string result ( n + 1 , ' ▁ ' ) ; int count = 1 ; for ( int i = 0 ; i <= n ; i ++ ) { if ( i == n seq [ i ] == ' I ' ) { for ( int j = i - 1 ; j >= -1 ; j -- ) { result [ j + 1 ] = '0' + count ++ ; if ( j >= 0 && seq [ j ] == ' I ' ) break ; } } } return result ; } int main ( ) { string inputs [ ] = { " IDID " , " I " , " DD " , " II " , " DIDI " , " IIDDD " , " DDIDDIID " } ; for ( string input : inputs ) { cout << getMinNumberForPattern ( input ) << " STRNEWLINE " ; } return 0 ; }

Index/key variables: i, j
Accumulator variables: count, i, j, stdc
Iterator variables: i, input, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int isPrime ( int n ) { int i , c = 0 ; for ( i = 1 ; i < n / 2 ; i ++ ) { if ( n % i == 0 ) c ++ ; } if ( c == 1 ) return 1 ; else return 0 ; } void findMinNum ( int arr [ ] , int n ) { int first = 0 , last = 0 , num , rev , i ; int hash [ 10 ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { hash [ arr [ i ] ] ++ ; } cout << " Minimum ▁ number : ▁ " ; for ( int i = 0 ; i <= 9 ; i ++ ) { for ( int j = 0 ; j < hash [ i ] ; j ++ ) cout << i ; } cout << endl ; for ( i = 0 ; i <= 9 ; i ++ ) { if ( hash [ i ] != 0 ) { first = i ; break ; } } for ( i = 9 ; i >= 0 ; i -- ) { if ( hash [ i ] != 0 ) { last = i ; break ; } } num = first * 10 + last ; rev = last * 10 + first ; cout << " Prime ▁ combinations : ▁ " ; if ( isPrime ( num ) && isPrime ( rev ) ) cout << num << " ▁ " << rev ; else if ( isPrime ( num ) ) cout << num ; else if ( isPrime ( rev ) ) cout << rev ; else cout << " No ▁ combinations ▁ exist " ; } int main ( ) { int arr [ ] = { 1 , 2 , 4 , 7 , 8 } ; findMinNum ( arr , 5 ) ; return 0 ; }

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