dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define N  2005
#define mod  (int)(1e9 + 7)
int n , q ; int par [ N ] , Rank [ N ] ; map < int , int > m ; void initialize ( ) { for ( int i = 0 ; i <= n ; i ++ ) { par [ i ] = i ; Rank [ i ] = 0 ; } } int find ( int x ) { if ( par [ x ] != x ) par [ x ] = find ( par [ x ] ) ; return par [ x ] ; } void Union ( int x , int y ) { int xpar = find ( x ) ; int ypar = find ( y ) ; if ( Rank [ xpar ] < Rank [ ypar ] ) par [ xpar ] = ypar ; else if ( Rank [ xpar ] > Rank [ ypar ] ) par [ ypar ] = xpar ; else { par [ ypar ] = xpar ; Rank [ xpar ] ++ ; } } int power ( long long a , long long m1 ) { if ( m1 == 0 ) return 1 ; else if ( m1 == 1 ) return a ; else if ( m1 == 2 ) return ( 1LL * a * a ) % mod ; else if ( m1 & 1 ) return ( 1LL * a * power ( power ( a , m1 / 2 ) , 2 ) ) % mod ; else return power ( power ( a , m1 / 2 ) , 2 ) % mod ; } void query ( int l , int r ) { m [ l + r ] = max ( m [ l + r ] , r ) ; } int possiblestrings ( ) { initialize ( ) ; for ( auto i = m . begin ( ) ; i != m . end ( ) ; i ++ ) { int x = i -> first - i -> second ; int y = i -> second ; while ( x < y ) { Union ( x , y ) ; x ++ ; y -- ; } } int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) if ( par [ i ] == i ) ans ++ ; return power ( 26 , ans ) % mod ; } int main ( ) { n = 4 ; query ( 1 , 3 ) ; query ( 2 , 4 ) ; cout << possiblestrings ( ) ; return 0 ; }

Index/key variables: N, i, x, xpar, ypar
Accumulator variables: ans, i, stdc, x, y
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; class node { public : int data ; node * left ; node * right ; node ( int data ) { this -> data = data ; this -> left = NULL ; this -> right = NULL ; } } ; bool iterativeSearch ( node * root , int x ) { if ( root == NULL ) return false ; queue < node * > q ; q . push ( root ) ; while ( q . empty ( ) == false ) { node * node = q . front ( ) ; if ( node -> data == x ) return true ; q . pop ( ) ; if ( node -> left != NULL ) q . push ( node -> left ) ; if ( node -> right != NULL ) q . push ( node -> right ) ; } return false ; } int main ( ) { node * NewRoot = NULL ; node * root = new node ( 2 ) ; root -> left = new node ( 7 ) ; root -> right = new node ( 5 ) ; root -> left -> right = new node ( 6 ) ; root -> left -> right -> left = new node ( 1 ) ; root -> left -> right -> right = new node ( 11 ) ; root -> right -> right = new node ( 9 ) ; root -> right -> right -> left = new node ( 4 ) ; iterativeSearch ( root , 6 ) ? cout << " Found STRNEWLINE " : cout << " Not ▁ Found STRNEWLINE " ; iterativeSearch ( root , 12 ) ? cout << " Found STRNEWLINE " : cout << " Not ▁ Found STRNEWLINE " ; return 0 ; }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; class node { public : int data ; node * left ; node * right ; node * next ; } ; void populateNext ( node * root ) { node * next = NULL ; populateNextRecur ( root , & next ) ; } void populateNextRecur ( node * p , node * * next_ref ) { if ( p ) { populateNextRecur ( p -> right , next_ref ) ; p -> next = * next_ref ; * next_ref = p ; populateNextRecur ( p -> left , next_ref ) ; } }

Accumulator variables: stdc
Class/struct names: node
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isValid ( string str , int len ) { for ( int i = 1 ; i < len ; i ++ ) { if ( str [ i ] == str [ i - 1 ] ) return false ; } return true ; } int main ( ) { string str = "0110" ; int len = str . length ( ) ; if ( isValid ( str , len ) ) cout << " Valid " ; else cout << " Invalid " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int check ( string s , int K ) { for ( int ch = 0 ; ch < 26 ; ch ++ ) { char c = ' a ' + ch ; int last = -1 ; bool found = true ; for ( int i = 0 ; i < K ; i ++ ) if ( s [ i ] == c ) last = i ; if ( last == -1 ) continue ; for ( int i = K ; i < s . size ( ) ; i ++ ) { if ( s [ i ] == c ) last = i ; if ( last <= ( i - K ) ) { found = false ; break ; } } if ( found ) return 1 ; } return 0 ; } int binarySearch ( string s ) { int low = 1 , high = ( int ) s . size ( ) ; int ans ; while ( low <= high ) { int mid = ( high + low ) >> 1 ; if ( check ( s , mid ) ) { ans = mid ; high = mid - 1 ; } else low = mid + 1 ; } return ans ; } int32_t main ( ) { string s = " abcde " ; cout << binarySearch ( s ) << endl ; s = " aaaa " ; cout << binarySearch ( s ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: ch, i, stdc
Iterator variables: ch, i
Boolean variables: found
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int seg [ 10 ] = { 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; string LedRequired ( string s , int led ) { int count = 0 ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { count += seg [ int ( s [ i ] ) - 48 ] ; } if ( count <= led ) return " YES " ; else return " NO " ; } int main ( ) { string S = "123456789" ; int led = 20 ; cout << LedRequired ( S , led ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: count, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int vowel_calc ( string s ) { int n = s . length ( ) ; vector < int > arr ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) arr . push_back ( n ) ; else arr . push_back ( ( n - i ) + arr [ i - 1 ] - i ) ; } int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( s [ i ] == ' a ' s [ i ] == ' e ' s [ i ] == ' i ' s [ i ] == ' o ' s [ i ] == ' u ' ) sum += arr [ i ] ; return sum ; } int main ( ) { string s = " daceh " ; cout << vowel_calc ( s ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <iostream>
#include <stack>
using namespace std ; struct node { int data ; struct node * left , * right ; } ; struct node * newNode ( int data ) { struct node * node = new struct node ; node -> data = data ; node -> left = node -> right = NULL ; return ( node ) ; } bool iterativeSearch ( node * root , int x ) { if ( root == NULL ) return false ; stack < node * > nodeStack ; nodeStack . push ( root ) ; while ( nodeStack . empty ( ) == false ) { struct node * node = nodeStack . top ( ) ; if ( node -> data == x ) return true ; nodeStack . pop ( ) ; if ( node -> right ) nodeStack . push ( node -> right ) ; if ( node -> left ) nodeStack . push ( node -> left ) ; } return false ; } int main ( void ) { struct node * NewRoot = NULL ; struct node * root = newNode ( 2 ) ; root -> left = newNode ( 7 ) ; root -> right = newNode ( 5 ) ; root -> left -> right = newNode ( 6 ) ; root -> left -> right -> left = newNode ( 1 ) ; root -> left -> right -> right = newNode ( 11 ) ; root -> right -> right = newNode ( 9 ) ; root -> right -> right -> left = newNode ( 4 ) ; iterativeSearch ( root , 6 ) ? cout << " Found STRNEWLINE " : cout << " Not ▁ Found STRNEWLINE " ; iterativeSearch ( root , 12 ) ? cout << " Found STRNEWLINE " : cout << " Not ▁ Found STRNEWLINE " ; return 0 ; }

Class/struct names: node
C++ program:
#include <iostream>
using namespace std ; bool find ( string s1 , string s2 ) { int len = s1 . length ( ) , len_1 = s2 . length ( ) ; if ( len != len_1 ) return false ; int d [ len ] = { 0 } ; d [ 0 ] = s2 [ 0 ] - s1 [ 0 ] ; for ( int i = 1 ; i < len ; i ++ ) { if ( s1 [ i ] > s2 [ i ] ) return false ; else { d [ i ] = s2 [ i ] - s1 [ i ] ; } } for ( int i = 0 ; i < len - 1 ; i ++ ) { if ( d [ i ] < d [ i + 1 ] ) return false ; } return true ; } int main ( ) { string s1 = " abcd " , s2 = " bcdd " ; if ( find ( s1 , s2 ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Index/key variables: i, len
Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool ispalindrome ( int x ) { int ans = 0 ; int temp = x ; while ( temp > 0 ) { ans = 10 * ans + temp % 10 ; temp = temp / 10 ; } return ans == x ; } int SuperPalindromes ( int L , int R ) { int LIMIT = 100000 ; int ans = 0 ; for ( int i = 0 ; i < LIMIT ; i ++ ) { string s = to_string ( i ) ; string rs = s . substr ( 0 , s . size ( ) - 1 ) ; reverse ( rs . begin ( ) , rs . end ( ) ) ; string p = s + rs ; int p_sq = pow ( stoi ( p ) , 2 ) ; if ( p_sq > R ) break ; if ( p_sq >= L and ispalindrome ( p_sq ) ) ans = ans + 1 ; } for ( int i = 0 ; i < LIMIT ; i ++ ) { string s = to_string ( i ) ; string rs = s ; reverse ( rs . begin ( ) , rs . end ( ) ) ; string p = s + rs ; int p_sq = pow ( stoi ( p ) , 2 ) ; if ( p_sq > R ) break ; if ( p_sq >= L and ispalindrome ( p_sq ) ) ans = ans + 1 ; } return ans ; } int main ( ) { string L = "4" ; string R = "1000" ; printf ( " % d STRNEWLINE " , SuperPalindromes ( stoi ( L ) , stoi ( R ) ) ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char NthCharacter ( int n ) { string s = " " ; int c = 1 ; for ( int i = 1 ; ; i ++ ) { if ( c < 10 ) s += char ( 48 + c ) ; else { string s1 = " " ; int dup = c ; while ( dup ) { s1 += char ( ( dup % 10 ) + 48 ) ; dup /= 10 ; } reverse ( s1 . begin ( ) , s1 . end ( ) ) ; s += s1 ; } c ++ ; if ( s . length ( ) >= n ) { return s [ n - 1 ] ; } } } int main ( ) { int n = 11 ; cout << NthCharacter ( n ) ; return 0 ; }

Accumulator variables: c, dup, i, s, s1, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void solve ( string s , int k ) { int count = 0 , length = 0 , pos = 0 ; map < char , int > m ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { m [ s [ i ] ] ++ ; length ++ ; if ( length > k ) { m [ s [ pos ++ ] ] -- ; length -- ; } if ( length == k && m [ s [ i ] ] == length ) count ++ ; } cout << count << endl ; } int main ( ) { string s = " aaaabbbccdddd " ; int k = 4 ; solve ( s , k ) ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i, length, pos, stdc
Iterator variables: i
C++ program:
#include <cstring>
#include <iostream>
using namespace std ; int main ( ) { string str = " A ▁ computer ▁ science ▁ portal ▁ for ▁ geeks " ; for ( int i = 0 ; i < str . length ( ) ; ++ i ) { if ( str [ i ] == ' ▁ ' ) { str [ i ] = ' - ' ; } } cout << str << endl ; return 0 ; }

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

Index/key variables: i, j, str
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool solve ( string n , int l ) { if ( l < 3 ) { if ( stoi ( n ) % 8 == 0 ) return true ; reverse ( n . begin ( ) , n . end ( ) ) ; if ( stoi ( n ) % 8 == 0 ) return true ; return false ; } int hash [ 10 ] = { 0 } ; for ( int i = 0 ; i < l ; i ++ ) hash [ n [ i ] - '0' ] ++ ; for ( int i = 104 ; i < 1000 ; i += 8 ) { int dup = i ; int freq [ 10 ] = { 0 } ; freq [ dup % 10 ] ++ ; dup = dup / 10 ; freq [ dup % 10 ] ++ ; dup = dup / 10 ; freq [ dup % 10 ] ++ ; dup = i ; if ( freq [ dup % 10 ] > hash [ dup % 10 ] ) continue ; dup = dup / 10 ; if ( freq [ dup % 10 ] > hash [ dup % 10 ] ) continue ; dup = dup / 10 ; if ( freq [ dup % 10 ] > hash [ dup % 10 ] ) continue ; return true ; } return false ; } int main ( ) { string number = "31462708" ; int l = number . length ( ) ; if ( solve ( number , 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 ; string newString ( string s , int k ) { string X = " " ; while ( s . length ( ) > 0 ) { char temp = s [ 0 ] ; for ( long long i = 1 ; i < k and i < s . length ( ) ; i ++ ) { if ( s [ i ] < temp ) { temp = s [ i ] ; } } X = X + temp ; for ( long long i = 0 ; i < k ; i ++ ) { if ( s [ i ] == temp ) { s . erase ( s . begin ( ) + i ) ; break ; } } } return X ; } int main ( ) { string s = " gaurang " ; int k = 3 ; cout << newString ( s , k ) ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPalindromePossible ( string input ) { int len = input . length ( ) ; int diffCount = 0 , i ; char diff [ 2 ] [ 2 ] ; for ( i = 0 ; i < len / 2 ; i ++ ) { if ( input [ i ] != input [ len - i - 1 ] ) { if ( diffCount == 2 ) return false ; diff [ diffCount ] [ 0 ] = input [ i ] ; diff [ diffCount ++ ] [ 1 ] = input [ len - i - 1 ] ; } } switch ( diffCount ) { case 0 : return true ; case 1 : { char midChar = input [ i ] ; if ( len % 2 != 0 and ( diff [ 0 ] [ 0 ] == midChar or diff [ 0 ] [ 1 ] == midChar ) ) return true ; } case 2 : if ( ( diff [ 0 ] [ 0 ] == diff [ 1 ] [ 0 ] and diff [ 0 ] [ 1 ] == diff [ 1 ] [ 1 ] ) or ( diff [ 0 ] [ 0 ] == diff [ 1 ] [ 1 ] and diff [ 0 ] [ 1 ] == diff [ 1 ] [ 0 ] ) ) return true ; } return false ; } int main ( ) { cout << boolalpha << isPalindromePossible ( " bbg " ) << endl ; cout << boolalpha << isPalindromePossible ( " bdababd " ) << endl ; cout << boolalpha << isPalindromePossible ( " gcagac " ) << endl ; return 0 ; }

Index/key variables: diffCount, i
Accumulator variables: diffCount, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void strToBinary ( string s ) { int n = s . length ( ) ; for ( int i = 0 ; i <= n ; i ++ ) { int val = int ( s [ i ] ) ; string bin = " " ; while ( val > 0 ) { ( val % 2 ) ? bin . push_back ( '1' ) : bin . push_back ( '0' ) ; val /= 2 ; } reverse ( bin . begin ( ) , bin . end ( ) ) ; cout << bin << " ▁ " ; } } int main ( ) { string s = " geeks " ; strToBinary ( s ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc, val
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int binarySearch ( string * arr , int low , int high , string x ) { if ( low > high ) return -1 ; int mid = ( low + high ) / 2 ; if ( arr [ mid ] == " " ) { int left = mid - 1 ; int right = mid + 1 ; while ( 1 ) { if ( left < low && right > high ) return -1 ; if ( left >= low && arr [ left ] != " " ) { mid = left ; break ; } else if ( right <= high && arr [ right ] != " " ) { mid = right ; break ; } left -- ; right ++ ; } } if ( arr [ mid ] == x ) return mid ; else if ( arr [ mid ] > x ) return binarySearch ( arr , low , mid - 1 , x ) ; else return binarySearch ( arr , mid + 1 , high , x ) ; } int sparseSearch ( string arr [ ] , string x , int n ) { return binarySearch ( arr , 0 , n - 1 , x ) ; } int main ( ) { ios_base :: sync_with_stdio ( false ) ; string arr [ ] = { " for " , " geeks " , " " , " " , " " , " " , " ide " , " practice " , " " , " " , " " , " quiz " } ; string x = " geeks " ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; int index = sparseSearch ( arr , x , n ) ; if ( index != -1 ) cout << x << " ▁ found ▁ at ▁ index ▁ " << index << " STRNEWLINE " ; else cout << x << " ▁ not ▁ found STRNEWLINE " ; return 0 ; }

Index/key variables: left, mid, right
Accumulator variables: left, right, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int factorial ( int n ) { int f = 1 ; for ( int i = 1 ; i <= n ; i ++ ) f = f * i ; return f ; } int calculateTotal ( string temp , int n ) { int f = factorial ( n ) ; map < char , int > hm ; for ( int i = 0 ; i < temp . length ( ) ; i ++ ) { hm [ temp [ i ] ] ++ ; } for ( auto e : hm ) { int x = e . second ; if ( x > 1 ) { int temp5 = factorial ( x ) ; f /= temp5 ; } return f ; } } static void nextPermutation ( string & temp ) { int i ; for ( i = temp . length ( ) - 1 ; i > 0 ; i -- ) if ( temp [ i ] > temp [ i - 1 ] ) break ; int min = i ; int j , x = temp [ i - 1 ] ; for ( j = i + 1 ; j < temp . length ( ) ; j ++ ) if ( ( temp [ j ] < temp [ min ] ) and ( temp [ j ] > x ) ) min = j ; swap ( temp [ i - 1 ] , temp [ min ] ) ; sort ( temp . begin ( ) + i , temp . end ( ) ) ; cout << temp << endl ; } void printAllPermutations ( string s ) { string temp ( s ) ; sort ( temp . begin ( ) , temp . end ( ) ) ; cout << temp << endl ; int total = calculateTotal ( temp , temp . length ( ) ) ; for ( int i = 1 ; i < total ; i ++ ) { nextPermutation ( temp ) ; } } int main ( ) { string s = " AAB " ; printAllPermutations ( s ) ; }

Index/key variables: i, j, min
Accumulator variables: f, i, j, stdc
Iterator variables: e, i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * left , * right ; } ; Node * newNode ( int data ) { Node * temp = new Node ; temp -> data = data ; temp -> left = temp -> right = NULL ; return temp ; } void Swap ( Node * * a , Node * * b ) { Node * temp = * a ; * a = * b ; * b = temp ; } void swapEveryKLevelUtil ( Node * root , int level , int k ) { if ( root == NULL || ( root -> left == NULL && root -> right == NULL ) ) return ; if ( ( level + 1 ) % k == 0 ) Swap ( & root -> left , & root -> right ) ; swapEveryKLevelUtil ( root -> left , level + 1 , k ) ; swapEveryKLevelUtil ( root -> right , level + 1 , k ) ; } void swapEveryKLevel ( Node * root , int k ) { swapEveryKLevelUtil ( root , 1 , k ) ; } void inorder ( Node * root ) { if ( root == NULL ) return ; inorder ( root -> left ) ; cout << root -> data << " ▁ " ; inorder ( root -> right ) ; } int main ( ) { struct Node * root = newNode ( 1 ) ; root -> left = newNode ( 2 ) ; root -> right = newNode ( 3 ) ; root -> left -> left = newNode ( 4 ) ; root -> right -> right = newNode ( 8 ) ; root -> right -> left = newNode ( 7 ) ; int k = 2 ; cout << " Before ▁ swap ▁ node ▁ : " << endl ; inorder ( root ) ; swapEveryKLevel ( root , k ) ; cout << " After swap Node : " << endl ; inorder ( root ) ; return 0 ; }

Accumulator variables: stdc
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; string printSequence ( string arr [ ] , string input ) { string output = " " ; int n = input . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( input [ i ] == ' ▁ ' ) output = output + "0" ; else { int position = input [ i ] - ' A ' ; output = output + arr [ position ] ; } } return output ; } int main ( ) { string str [ ] = { "2" , "22" , "222" , "3" , "33" , "333" , "4" , "44" , "444" , "5" , "55" , "555" , "6" , "66" , "666" , "7" , "77" , "777" , "7777" , "8" , "88" , "888" , "9" , "99" , "999" , "9999" } ; string input = " GEEKSFORGEEKS " ; cout << printSequence ( str , input ) ; return 0 ; }

Index/key variables: i, position
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std ; int findLUSlength ( string a , string b ) { unordered_map < string , int > map ; vector < string > strArr ; strArr . push_back ( a ) ; strArr . push_back ( b ) ; for ( string s : strArr ) { for ( int i = 0 ; i < ( 1 << s . length ( ) ) ; i ++ ) { string t = " " ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { if ( ( ( i >> j ) & 1 ) != 0 ) t += s [ j ] ; } if ( map . count ( t ) ) map [ t ] ++ ; else map [ t ] = 1 ; } } int res = 0 ; for ( auto a : map ) { if ( a . second == 1 ) res = max ( res , ( int ) a . first . length ( ) ) ; } return res ; } int main ( ) { string a = " abcdabcd " , b = " abcabc " ; cout << findLUSlength ( a , b ) ; return 0 ; }

Index/key variables: j, t
Accumulator variables: i, j, t
Iterator variables: a, i, j, s
C++ program:
#include <bits/stdc++.h>
using namespace std ; string Round ( string s , int n ) { string c = s ; if ( c [ n - 1 ] == '0' ) return s ; else if ( c [ n - 1 ] == '1' c [ n - 1 ] == '2' c [ n - 1 ] == '3' c [ n - 1 ] == '4' c [ n - 1 ] == '5' ) { c [ n - 1 ] = '0' ; return c ; } else { c [ n - 1 ] = '0' ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( c [ i ] == '9' ) c [ i ] = '0' ; else { int t = c [ i ] - '0' + 1 ; c [ i ] = ( char ) ( 48 + t ) ; break ; } } } string s1 = c ; if ( s1 [ 0 ] == '0' ) s1 = "1" + s1 ; return s1 ; } int main ( ) { string s = "5748965412485599999874589965999" ; int n = s . length ( ) ; cout << Round ( s , n ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isEven ( string s ) { int l = s . length ( ) ; bool dotSeen = false ; for ( int i = l - 1 ; i >= 0 ; i -- ) { if ( s [ i ] == '0' && dotSeen == false ) continue ; if ( s [ i ] == ' . ' ) { dotSeen = true ; continue ; } if ( ( s [ i ] - '0' ) % 2 == 0 ) return true ; return false ; } } int main ( ) { string s = "100.70" ; if ( isEven ( s ) ) cout << " Even " ; else cout << " Odd " ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
Boolean variables: dotSeen
C++ program:
#include <iostream>
using namespace std ; int minCost ( string & s ) { bool alphabets [ 26 ] = { false } ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) alphabets [ s [ i ] - 97 ] = true ; int count = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) if ( alphabets [ i ] ) count ++ ; return count ; } int main ( ) { string s = " geeksforgeeks " ; cout << " Total ▁ cost ▁ to ▁ construct ▁ " << s << " ▁ is ▁ " << minCost ; return 0 ; }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; struct Node { int data ; struct Node * left , * right ; } ; struct Node * newnode ( int data ) { struct Node * node = new Node ; node -> data = data ; node -> left = node -> right = NULL ; return ( node ) ; } void pathCountUtil ( Node * node , unordered_map < int , int > & m , int path_len ) { if ( node == NULL ) return ; if ( node -> left == NULL && node -> right == NULL ) { m [ path_len ] ++ ; return ; } pathCountUtil ( node -> left , m , path_len + 1 ) ; pathCountUtil ( node -> right , m , path_len + 1 ) ; } void pathCounts ( Node * root ) { unordered_map < int , int > m ; pathCountUtil ( root , m , 1 ) ; for ( auto itr = m . begin ( ) ; itr != m . end ( ) ; itr ++ ) cout << itr -> second << " ▁ paths ▁ have ▁ length ▁ " << itr -> first << endl ; } int main ( ) { struct Node * root = newnode ( 8 ) ; root -> left = newnode ( 5 ) ; root -> right = newnode ( 4 ) ; root -> left -> left = newnode ( 9 ) ; root -> left -> right = newnode ( 7 ) ; root -> right -> right = newnode ( 11 ) ; root -> right -> right -> left = newnode ( 3 ) ; pathCounts ( root ) ; return 0 ; }

Index/key variables: path_len
Accumulator variables: itr, stdc
Iterator variables: itr
Class/struct names: Node
C++ program:
#include <bits/stdc++.h>
using namespace std ; string simplify ( string path ) { vector < string > v ; int n = path . length ( ) ; string ans ; for ( int i = 0 ; i < n ; i ++ ) { string dir = " " ; while ( i < n && path [ i ] != ' / ' ) { dir += path [ i ] ; i ++ ; } if ( dir == " . . " ) { if ( ! v . empty ( ) ) v . pop_back ( ) ; } else if ( dir == " . " dir == " " ) { } else { v . push_back ( dir ) ; } } for ( auto i : v ) { ans += " / " + i ; } if ( ans == " " ) return " / " ; return ans ; } int main ( ) { string str ( " / a / . / b / . . / . . / c / " ) ; string res = simplify ( str ) ; cout << res ; return 0 ; }

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