dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; class GFG { static int [ ] [ ] dp = new int [ 505 ] [ 505 ] ; static int [ ] [ ] choose = new int [ 502 ] [ 502 ] ; static int calc ( int l , int r , String s ) { if ( Math . abs ( r - l ) % 2 == 0 ) { return 0 ; } if ( l > r ) { return dp [ l ] [ r ] = 1 ; } if ( dp [ l ] [ r ] != - 1 ) { return dp [ l ] [ r ] ; } if ( ( r - l ) == 1 ) { if ( s . charAt ( l ) == s . charAt ( r ) ) { dp [ l ] [ r ] = 1 ; } else { dp [ l ] [ r ] = 0 ; } return dp [ l ] [ r ] ; } int ans = 0 ; for ( int k = l + 1 ; k <= r ; k += 2 ) { int temp = 1 ; if ( s . charAt ( l ) == s . charAt ( k ) ) { temp = calc ( l + 1 , k - 1 , s ) * calc ( k + 1 , r , s ) * choose [ ( ( r - l + 1 ) / 2 ) ] [ ( ( r - k ) / 2 ) ] ; ans += temp ; } } return dp [ l ] [ r ] = ans ; } static int waysToClearString ( String S ) { for ( int i = 0 ; i < 505 ; i ++ ) { for ( int j = 0 ; j < 505 ; j ++ ) dp [ i ] [ j ] = - 1 ; } int n = S . length ( ) ; choose [ 0 ] [ 0 ] = 1 ; for ( int i = 1 ; i <= ( n / 2 ) ; ++ i ) { choose [ i ] [ 0 ] = 1 ; for ( int j = 1 ; j <= i ; ++ j ) { choose [ i ] [ j ] = ( choose [ i - 1 ] [ j ] + choose [ i - 1 ] [ j - 1 ] ) ; } } return calc ( 0 , n - 1 , S ) ; } public static void main ( String [ ] args ) { String S = " aabccb " ; System . out . println ( waysToClearString ( S ) ) ; } }

Index/key variables: i, j, l, r
Accumulator variables: ans, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
class GFG { static void findSubsequence ( String str ) { int n = str . length ( ) ; char [ ] res = new char [ n ] ; for ( int i = 0 ; i < n ; i ++ ) res [ i ] = 0 ; for ( int pos = 0 ; pos <= 9 ; pos ++ ) { char lst1 = '0' ; boolean flag = true ; char lst2 = ( char ) ( pos + '0' ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( lst2 <= str . charAt ( i ) ) { res [ i ] = '2' ; lst2 = str . charAt ( i ) ; } else if ( lst1 <= str . charAt ( i ) ) { res [ i ] = '1' ; lst1 = str . charAt ( i ) ; } else flag = false ; } if ( lst1 > pos + '0' ) flag = false ; if ( flag ) { String S1 = " " ; String S2 = " " ; for ( int i = 0 ; i < n ; i ++ ) { if ( res [ i ] == '1' ) { S1 += str . charAt ( i ) ; } else { S2 += str . charAt ( i ) ; } } System . out . print ( S1 + " ▁ " + S2 + "NEW_LINE"); return ; } } System . out . print ( " - 1" ) ; } public static void main ( String [ ] args ) { String S = "040425524644" ; findSubsequence ( S ) ; S = "123456789" ; findSubsequence ( S ) ; } }

Index/key variables: i, n
Accumulator variables: S1, S2, i, pos
Iterator variables: i, pos
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String ans , s ; static int K ; static void getString ( int curlen , int N , int [ ] prod ) { if ( curlen == N ) { K -- ; if ( K == 0 ) ans = s ; return ; } char ch ; int ok , t , i ; for ( ch = '2' ; ch <= '9' ; ch ++ ) { s += ch ; ok = 1 ; t = 1 ; for ( i = curlen ; i >= 0 && s . length ( ) > i ; i -- ) { t *= s . charAt ( i ) - 48 ; if ( prod [ t ] != 0 ) ok = 0 ; prod [ t ] ++ ; } if ( ok != 0 ) getString ( curlen + 1 , N , prod ) ; t = 1 ; for ( i = curlen ; i >= 0 && s . length ( ) > i ; i -- ) { t *= s . charAt ( i ) - 48 ; prod [ t ] -- ; } if ( s . length ( ) > 0 ) s = s . substring ( 0 , s . length ( ) - 1 ) ; } } static String kthValidString ( int N ) { if ( N > 10 ) { return " - 1" ; } if ( N == 1 ) { if ( K > 10 ) { return " - 1" ; } String s = " " ; K -- ; s += ( K + '0' ) ; return s ; } ans = " - 1" ; s = " " ; int [ ] prod = new int [ 10005 ] ; getString ( 0 , N , prod ) ; return ans ; } public static void main ( String [ ] args ) { int N = 3 ; K = 4 ; System . out . print ( kthValidString ( N ) ) ; } }

Index/key variables: t
Accumulator variables: K, ch, i, s, t
Iterator variables: ch, i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int BalancedStringBySwapping ( String s ) { int unbalancedPair = 0 ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { if ( unbalancedPair > 0 && s . charAt ( i ) == ' ] ' ) { -- unbalancedPair ; } else if ( s . charAt ( i ) == ' [ ' ) { ++ unbalancedPair ; } } return ( unbalancedPair + 1 ) / 2 ; } public static void main ( String [ ] args ) { String s = " ] ] ] [ [ [ " ; System . out . println ( BalancedStringBySwapping ( s ) ) ; } }

Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int lengthNPalindrome ( int N , int K ) { int half = N / 2 ; if ( N % 2 == 1 ) { half += 1 ; } int ans = 1 ; for ( int i = 1 ; i <= half ; i ++ ) { ans *= K ; K -- ; } return ans ; } static int palindromicStrings ( int N , int K ) { if ( N == 1 ) { return K ; } if ( N == 2 ) { return 2 * K ; } int ans = 0 ; ans += ( 2 * K ) ; for ( int i = 3 ; i <= N ; i ++ ) { ans += lengthNPalindrome ( i , K ) ; } return ans ; } public static void main ( String [ ] args ) { int N = 4 , K = 3 ; System . out . println ( palindromicStrings ( N , K ) ) ; } }

Accumulator variables: K, ans, half, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int LCS ( String S , int N , String T , int M , int dp [ ] [ ] ) { if ( N == 0 M == 0 ) return 0 ; if ( dp [ N ] [ M ] != 0 ) return dp [ N ] [ M ] ; if ( S . charAt ( N - 1 ) == T . charAt ( M - 1 ) ) { return dp [ N ] [ M ] = 1 + LCS ( S , N - 1 , T , M - 1 , dp ) ; } return dp [ N ] [ M ] = Math . max ( LCS ( S , N - 1 , T , M , dp ) , LCS ( S , N , T , M - 1 , dp ) ) ; } static int minimumCharacter ( String S ) { String T = " abcdefghijklmnopqrstuvwxyz " ; int N = S . length ( ) , M = T . length ( ) ; int dp [ ] [ ] = new int [ N + 1 ] [ M + 1 ] ; return ( 26 - LCS ( S , N , T , M , dp ) ) ; } public static void main ( String [ ] args ) { String S = " abcdadc " ; System . out . println ( minimumCharacter ( S ) ) ; } }

Index/key variables: M, N
Class/struct names: GFG
Java program:
class GFG { static long MOD = 1000000007 ; public static long exp_mod ( long a , long b ) { long ret = 1 ; for ( ; b > 0 ; b >>= 1 , a = a * a % MOD ) { if ( ( b & 1 ) > 0 ) ret = ret * a % MOD ; } return ret ; } public static long countOfWays ( String s , int k ) { int N = s . length ( ) ; long ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( s . charAt ( i ) == '5' || s . charAt ( 0 ) == '0' ) { ans = ( ans + exp_mod ( 2 , i ) ) % MOD ; } } long q = exp_mod ( 2 , N ) ; long qk = exp_mod ( q , k ) ; long inv = exp_mod ( q - 1 , MOD - 2 ) ; ans = ans * ( qk - 1 ) % MOD ; ans = ans * inv % MOD ; return ans ; } public static void main ( String args [ ] ) { String S = "1256" ; int K = 1 ; System . out . println ( countOfWays ( S , K ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printMiddleString ( String S , String T , int N ) { int [ ] a1 = new int [ N + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { a1 [ i + 1 ] = ( int ) S . charAt ( i ) - 97 + ( int ) T . charAt ( i ) - 97 ; } for ( int i = N ; i >= 1 ; i -- ) { a1 [ i - 1 ] += ( int ) a1 [ i ] / 26 ; a1 [ i ] %= 26 ; } for ( int i = 0 ; i <= N ; i ++ ) { if ( ( a1 [ i ] & 1 ) != 0 ) { if ( i + 1 <= N ) { a1 [ i + 1 ] += 26 ; } } a1 [ i ] = ( int ) a1 [ i ] / 2 ; } for ( int i = 1 ; i <= N ; i ++ ) { System . out . print ( ( char ) ( a1 [ i ] + 97 ) ) ; } } public static void main ( String [ ] args ) { int N = 5 ; String S = " afogk " ; String T = " asdji " ; printMiddleString ( S , T , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static char KthCharacter ( String s , String t , long k ) { long f = 1 ; long ss = 2 ; String tmp = " " ; int len = tmp . length ( ) ; while ( len < k ) { long tf = f ; long ts = ss ; while ( tf -- != 0 ) { tmp += s ; } while ( ts -- != 0 ) { tmp += t ; } f += 2 ; ss += 2 ; len = tmp . length ( ) ; } char output = tmp . charAt ( ( int ) k - 1 ) ; return output ; } public static void main ( String [ ] args ) { String S1 = " a " , S2 = " bc " ; int k = 4 ; char ans = KthCharacter ( S1 , S2 , k ) ; System . out . println ( ans ) ; } }

Accumulator variables: f, ss, tf, tmp, ts
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static char KthCharacter ( String s , String t , long k ) { long n = s . length ( ) ; long m = t . length ( ) ; long first = 1 ; long second = 2 ; char output = ' ? ' ; while ( k > 0 ) { if ( k > first * n ) { long x = first * n ; k = k - x ; first = first + 2 ; if ( k > second * m ) { long y = second * m ; k = k - y ; second = second + 2 ; } else { long ind = k % m ; ind -- ; if ( ind < 0 ) ind = m - 1 ; output = t . charAt ( ( int ) ind ) ; break ; } } else { long ind = k % n ; ind -- ; if ( ind < 0 ) ind = n - 1 ; output = s . charAt ( ( int ) ind ) ; break ; } } return output ; } public static void main ( String [ ] args ) { String S1 = " a " , S2 = " bc " ; int k = 4 ; char ans = KthCharacter ( S1 , S2 , k ) ; System . out . println ( ans ) ; } }

Accumulator variables: ind
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void makeContiguous ( String S , int N ) { int fst_occur = 0 , lst_occur = 0 ; for ( int x = 0 ; x < N ; x ++ ) { if ( S . charAt ( x ) == '1' ) { fst_occur = x ; break ; } } for ( int x = N - 1 ; x >= 0 ; x -- ) { if ( S . charAt ( x ) == '1' ) { lst_occur = x ; break ; } } int count = 0 ; for ( int x = fst_occur ; x <= lst_occur ; x ++ ) { if ( S . charAt ( x ) == '0' ) { count ++ ; } } System . out . print ( count ) ; } public static void main ( String [ ] args ) { String S = "010001011" ; int N = S . length ( ) ; makeContiguous ( S , N ) ; } }

Accumulator variables: count, x
Iterator variables: x
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int fact ( int n ) { int ans = 1 ; for ( int i = 2 ; i <= n ; i ++ ) ans = ans * i ; return ans ; } static int findComb ( int N , int M ) { int x = fact ( N + 1 ) ; int y = fact ( M ) ; return ( x * y ) ; } public static void main ( String [ ] args ) { int N = 2 ; int M = 2 ; System . out . print ( findComb ( N , M ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void countCamelCase ( String S ) { int count = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) >= 65 && S . charAt ( i ) <= 91 ) { count ++ ; } } System . out . println ( count ) ; } public static void main ( String [ ] args ) { String S = " ckjkUUYII " ; countCamelCase ( S ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findRepitition ( char a ) { if ( a <= ' z ' && a >= ' a ' ) { return a - ' a ' ; } else if ( a <= ' Z ' && a >= ' A ' ) { return a - ' A ' ; } return 0 ; } static void decodeString ( String str ) { String output = " " ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { output += ( str . charAt ( i ) ) ; i += findRepitition ( str . charAt ( i ) ) ; } System . out . print ( " Decrypted ▁ code ▁ is ▁ { " + output + " } " + "NEW_LINE"); } public static void main ( String [ ] args ) { String str = " abbbb ▁ acccdddd " ; decodeString ( str ) ; } }

Accumulator variables: i, output
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printString ( String S , int N ) { String [ ] plaintext = new String [ 5 ] ; int freq [ ] = new int [ 26 ] ; int freqSorted [ ] = new int [ 26 ] ; int Used [ ] = new int [ 26 ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( S . charAt ( i ) != ' ▁ ' ) { freq [ S . charAt ( i ) - ' A ' ] ++ ; } } for ( int i = 0 ; i < 26 ; i ++ ) { freqSorted [ i ] = freq [ i ] ; } String T = " ETAOINSHRDLCUMWFGYPBVKJXQZ " ; Arrays . sort ( freqSorted ) ; freqSorted = reverse ( freqSorted ) ; for ( int i = 0 ; i < 5 ; i ++ ) { int ch = - 1 ; for ( int j = 0 ; j < 26 ; j ++ ) { if ( freqSorted [ i ] == freq [ j ] && Used [ j ] == 0 ) { Used [ j ] = 1 ; ch = j ; break ; } } if ( ch == - 1 ) break ; int x = T . charAt ( i ) - ' A ' ; x = x - ch ; String curr = " " ; for ( int k = 0 ; k < N ; k ++ ) { if ( S . charAt ( k ) == ' ▁ ' ) { curr += ( char ) ' ▁ ' ; continue ; } int y = S . charAt ( k ) - ' A ' ; y += x ; if ( y < 0 ) y += 26 ; if ( y > 25 ) y -= 26 ; curr += ( char ) ( ' A ' + y ) ; } plaintext [ i ] = curr ; } for ( int i = 0 ; i < 5 ; i ++ ) { System . out . print ( plaintext [ i ] + "NEW_LINE"); } } static int [ ] reverse ( int a [ ] ) { int i , n = a . length , t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } return a ; } public static void main ( String [ ] args ) { String S = " B ▁ TJNQMF ▁ NFTTBHF " ; int N = S . length ( ) ; printString ( S , N ) ; } }

Index/key variables: i, j
Accumulator variables: curr, i, j, k, y
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String canMadeEmpty ( String s , int n ) { Stack < Character > St = new Stack < Character > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' c ' ) { if ( St . size ( ) >= 2 ) { char b = St . peek ( ) ; St . pop ( ) ; char a = St . peek ( ) ; St . pop ( ) ; if ( a != ' a ' b != ' b ' ) return " No " ; } else return " No " ; } else St . add ( s . charAt ( i ) ) ; } if ( St . size ( ) == 0 ) { return " Yes " ; } else { return " No " ; } } public static void main ( String [ ] args ) { String S = " aabcbc " ; int N = S . length ( ) ; System . out . print ( canMadeEmpty ( S , N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static void countOperations ( String S ) { int n = S . length ( ) ; int ans = 0 ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( S . charAt ( i ) == '0' ) { cnt ++ ; } else { if ( cnt > 0 ) { cnt -- ; ans ++ ; } } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String S = "110011010" ; countOperations ( S ) ; } }

Accumulator variables: ans, cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static String check ( String S ) { int N = S . length ( ) ; Deque < Integer > A = new LinkedList < Integer > ( ) ; Deque < Integer > B = new LinkedList < Integer > ( ) ; Deque < Integer > C = new LinkedList < Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( S . charAt ( i ) == ' A ' ) { A . addLast ( i ) ; } else if ( S . charAt ( i ) == ' B ' ) { B . addLast ( i ) ; } else { C . addLast ( i ) ; } } if ( N % 3 > 0 || A . size ( ) != B . size ( ) || A . size ( ) != C . size ( ) ) { return " No " ; } for ( Iterator itr = B . iterator ( ) ; itr . hasNext ( ) ; ) { Integer b = ( Integer ) itr . next ( ) ; if ( A . size ( ) > 0 && b > A . getFirst ( ) ) { A . pop ( ) ; } else { return " No " ; } } for ( Iterator itr = B . descendingIterator ( ) ; itr . hasNext ( ) ; ) { Integer b = ( Integer ) itr . next ( ) ; if ( C . size ( ) > 0 && b < C . getLast ( ) ) { C . pollLast ( ) ; } else { return " No " ; } } return " Yes " ; } public static void main ( String [ ] args ) { String S = " ABABCC " ; System . out . println ( check ( S ) ) ; } }

Accumulator variables: i
Iterator variables: i, itr
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String isSumEqual ( String A , String B , String C ) { int L = A . length ( ) ; int M = B . length ( ) ; int N = A . length ( ) ; A = reverse ( A ) ; B = reverse ( B ) ; C = reverse ( C ) ; int rem = 0 ; for ( int i = 0 ; i < Math . max ( L , Math . max ( M , N ) ) ; i ++ ) { int curr = rem ; if ( i < L ) curr += A . charAt ( i ) - ' a ' ; if ( i < M ) curr += B . charAt ( i ) - ' a ' ; rem = curr / 10 ; curr %= 10 ; if ( i < N && curr != C . charAt ( i ) - ' a ' ) { return " No " ; } } if ( rem > 0 ) return " No " ; else return " Yes " ; } static String reverse ( String input ) { char [ ] a = input . toCharArray ( ) ; int l , r = a . length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . valueOf ( a ) ; } public static void main ( String [ ] args ) { String A = " acb " , B = " cba " , C = " cdb " ; System . out . print ( isSumEqual ( A , B , C ) ) ; } }

Index/key variables: l, r
Accumulator variables: curr, i, l, r
Iterator variables: i, l
Class/struct names: GFG
Java program:
public class GFG { static int minimumHammingDistance ( String S , int K ) { int n = S . length ( ) ; int [ ] pref = new int [ n ] ; pref [ 0 ] = S . charAt ( 0 ) - '0' ; for ( int i = 1 ; i < n ; i ++ ) pref [ i ] = pref [ i - 1 ] + ( S . charAt ( i ) - '0' ) ; int cnt = pref [ n - 1 ] ; int ans = cnt ; for ( int i = 0 ; i < n - K ; i ++ ) { int value = pref [ i + K - 1 ] - ( i - 1 >= 0 ? pref [ i - 1 ] : 0 ) ; ans = Math . min ( ans , cnt - value + ( K - value ) ) ; } return ans ; } public static void main ( String args [ ] ) { String s = "101" ; int K = 2 ; System . out . println ( minimumHammingDistance ( s , K ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { private static boolean isPrime ( int n ) { if ( n <= 1 ) return false ; else if ( n == 2 ) return true ; else if ( n % 2 == 0 ) return false ; for ( int i = 3 ; i <= Math . sqrt ( n ) ; i += 2 ) { if ( n % i == 0 ) return false ; } return true ; } private static void checkPermutation ( String s1 , String s2 ) { int freq [ ] = new int [ 26 ] ; for ( char ch : s1 . toCharArray ( ) ) { freq [ ch - ' a ' ] -- ; } for ( char ch : s2 . toCharArray ( ) ) { freq [ ch - ' a ' ] ++ ; } boolean isAllChangesPrime = true ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] == 0 ) { continue ; } else if ( ! isPrime ( Math . abs ( freq [ i ] ) ) ) { isAllChangesPrime = false ; break ; } } if ( isAllChangesPrime ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void main ( String [ ] args ) { String S1 = " gekforgk " ; String S2 = " geeksforgeeks " ; checkPermutation ( S1 , S2 ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: ch, i
Boolean variables: isAllChangesPrime
Class/struct names: GFG
Java program:
import java . lang . * ; import java . io . * ; import java . util . * ; class GFG { static int countWays ( String S , int N ) { int ans = 0 ; for ( int mask = 0 ; mask < ( 1 << N ) ; mask ++ ) { String X = " " , Y = " " ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( mask >> i & 1 ) == 1 ) { X += S . charAt ( i ) ; } else { Y += S . charAt ( i ) ; } } Y = new StringBuilder ( Y ) . reverse ( ) . toString ( ) ; if ( X . equals ( Y ) ) { ans ++ ; } } return ans ; } public static void main ( String [ ] args ) { String S = " mippiisssisssiipsspiim " ; int N = S . length ( ) ; System . out . println ( countWays ( S , N ) ) ; } }

Accumulator variables: X, Y, ans, i, mask
Iterator variables: i, mask
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static void isEqualSubstring ( String str , int x ) { int n = str . length ( ) ; int i = 0 ; while ( i < n && i < x ) { if ( str . charAt ( i ) != str . charAt ( n - i - 1 ) ) { System . out . println ( " false " ) ; return ; } i ++ ; } System . out . println ( " true " ) ; } public static void main ( String [ ] args ) { String str = " GeeksforGeeks " ; int x = 3 ; isEqualSubstring ( str , x ) ; } }

Accumulator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static void minimumOperations ( String S , int N ) { int ans = 0 ; int cntOne = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( S . charAt ( i ) == '0' ) { ans += cntOne ; cntOne *= 2 ; } else cntOne ++ ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String S = "001" ; int N = S . length ( ) ; minimumOperations ( S , N ) ; } }

Accumulator variables: ans, cntOne, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void differentBitwiseOR ( String s1 , String s2 ) { int n = s1 . length ( ) ; int t00 = 0 , t10 = 0 , t01 = 0 , t11 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s1 . charAt ( i ) == '0' && s2 . charAt ( i ) == '0' ) { t00 ++ ; } if ( s1 . charAt ( i ) == '1' && s2 . charAt ( i ) == '0' ) { t10 ++ ; } if ( s1 . charAt ( i ) == '1' && s2 . charAt ( i ) == '1' ) { t11 ++ ; } if ( s1 . charAt ( i ) == '0' && s2 . charAt ( i ) == '1' ) { t01 ++ ; } } int ans = t00 * t10 + t01 * t10 + t00 * t11 ; System . out . print ( ans ) ; } public static void main ( String [ ] args ) { String S1 = "01001" ; String S2 = "11011" ; differentBitwiseOR ( S1 , S2 ) ; } }

Accumulator variables: i, t00, t01, t10, t11
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void RemoveCharacters ( String s ) { String ans = " " ; int [ ] c = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) c [ i ] = 0 ; int pos = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( c [ ( int ) s . charAt ( i ) - 97 ] == 0 ) { c [ ( int ) s . charAt ( i ) - 97 ] = 1 ; pos = i ; ans += s . charAt ( i ) ; } } for ( int i = pos + 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( 0 ) ) { ans += s . charAt ( i ) ; break ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String S = " abcaadbcd " ; RemoveCharacters ( S ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void changeCharacters ( String S , int N , int K ) { int flag = 1 ; int count = 0 ; Stack < Character > st = new Stack < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( st . empty ( ) ) { if ( S . charAt ( i ) == '0' ) { flag = 0 ; break ; } count = 0 ; st . push ( S . charAt ( i ) ) ; } else { if ( S . charAt ( i ) == '0' ) { count ++ ; if ( count == K ) { st . pop ( ) ; count = 0 ; } } else { count = 0 ; } } } if ( flag == 1 ) System . out . print ( " YES " ) ; else System . out . print ( " NO " ) ; } public static void main ( String args [ ] ) { String S = "100100" ; int N = S . length ( ) ; int K = 2 ; changeCharacters ( S , N , K ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static boolean prefixDivisble ( int n ) { int i = 1 ; while ( n > 0 ) { if ( n % i != 0 ) return false ; n = n / 10 ; i ++ ; } return true ; } public static void main ( String [ ] args ) { int n = 52248 ; if ( prefixDivisble ( n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i
Class/struct names: GFG
Java program:
class GFG { static void MinimumCost ( String S , int A , int B ) { int count = 0 ; int group = 0 ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) == '0' ) { count += 1 ; } else { if ( count > 0 ) { group += 1 ; } count = 0 ; } } if ( count > 0 ) group += 1 ; if ( group == 0 ) { System . out . println ( 0 ) ; } else { System . out . print ( Math . min ( A , B ) * ( group - 1 ) + B ) ; } } public static void main ( String args [ ] ) { int A = 1 ; int B = 5 ; String S = "01100" ; MinimumCost ( S , A , B ) ; } }

Accumulator variables: count, group, i
Iterator variables: i
Class/struct names: GFG