dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; public class Main { static void findRank ( String s ) { int N = s . length ( ) ; StringBuilder sb = new StringBuilder ( " " ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( s . charAt ( i ) == '0' ) sb . append ( '0' ) ; else sb . append ( '1' ) ; } String bin = sb . toString ( ) ; long X = ( long ) Math . pow ( 2 , N ) ; long Y = Long . parseLong ( bin , 2 ) ; long ans = X + Y - 1 ; System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String S = "001" ; findRank ( S ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: Main
Java program:
import java . util . * ; class GFG { static int GCD ( int lena , int lenb ) { if ( lena == 0 ) return lenb ; if ( lenb == 0 ) return lena ; if ( lena == lenb ) return lena ; if ( lena > lenb ) return GCD ( lena - lenb , lenb ) ; return GCD ( lena , lenb - lena ) ; } static String StringGCD ( String a , String b ) { int gcd = GCD ( a . length ( ) , b . length ( ) ) ; if ( a . substring ( 0 , gcd ) . equals ( b . substring ( 0 , gcd ) ) ) { int x = ( ( int ) b . length ( ) / gcd ) ; int y = ( ( int ) a . length ( ) / gcd ) ; String r = " " , s = " " ; while ( x -- > 0 ) s += a ; while ( y -- > 0 ) r += b ; if ( s . equals ( r ) ) return a . substring ( 0 , gcd ) ; } return " - 1" ; } public static void main ( String [ ] args ) { String a = " geeksgeeks " ; String b = " geeks " ; System . out . print ( StringGCD ( a , b ) ) ; } }

Accumulator variables: r, s, x, y
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static long scoreOfParentheses ( String S ) { Stack < String > s = new Stack < > ( ) ; int i = 0 ; long ans = 0 ; while ( i < S . length ( ) ) { if ( S . charAt ( i ) == ' ( ' ) s . add ( " ( " ) ; else { if ( s . peek ( ) == " ( " ) { s . pop ( ) ; s . add ( "1" ) ; } else { long count = 0 ; while ( s . peek ( ) != " ( " ) { count += Integer . parseInt ( s . peek ( ) ) ; s . pop ( ) ; } s . pop ( ) ; s . add ( String . valueOf ( 2 * count ) ) ; } } i ++ ; } while ( ! s . isEmpty ( ) ) { ans += Integer . parseInt ( s . peek ( ) ) ; s . pop ( ) ; } return ans ; } public static void main ( String [ ] args ) { String S1 = " ( ( ) ( ( ) ) ) " ; System . out . print ( scoreOfParentheses ( S1 ) + "NEW_LINE"); } }

Accumulator variables: ans, count, i
Class/struct names: GFG
Java program:
class GFG { static void countMinMoves ( String str ) { int n = str . length ( ) ; int a [ ] = new int [ n ] ; int j , ans = 0 , i , sum = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == ' ) ' ) { a [ i ] += sum - 1 ; } else { a [ i ] += sum + 1 ; } sum = a [ i ] ; } if ( sum == 0 ) { i = 1 ; while ( i < n ) { j = i - 1 ; while ( i < n && a [ i ] != 0 ) i ++ ; if ( i < n && a [ i - 1 ] < 0 ) { ans += i - j ; if ( j == 0 ) ans ++ ; } i ++ ; } System . out . println ( ans ) ; } else System . out . println ( " - 1" ) ; } public static void main ( String [ ] args ) { String str = " ) ( ( ) " ; countMinMoves ( str ) ; } }

Index/key variables: i, n
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean canBeBalanced ( String sequence ) { if ( sequence . length ( ) % 2 == 1 ) return false ; Stack < Character > stack_ = new Stack < Character > ( ) ; Stack < Character > stack2_ = new Stack < Character > ( ) ; int countOpen = 0 , countClosed = 0 ; int countSymbol = 0 ; for ( int i = 0 ; i < sequence . length ( ) ; i ++ ) { if ( sequence . charAt ( i ) == ' ) ' ) { countClosed ++ ; if ( stack_ . isEmpty ( ) ) { return false ; } else { stack_ . pop ( ) ; } } else { if ( sequence . charAt ( i ) == ' $ ' ) { countSymbol ++ ; } else { countOpen ++ ; } stack_ . add ( sequence . charAt ( i ) ) ; } } for ( int i = sequence . length ( ) - 1 ; i >= 0 ; i -- ) { if ( sequence . charAt ( i ) == ' ( ' ) { if ( stack2_ . isEmpty ( ) ) { return false ; } else { stack2_ . pop ( ) ; } } else { stack2_ . add ( sequence . charAt ( i ) ) ; } } int extra = Math . abs ( countClosed - countOpen ) ; if ( countSymbol < extra ) { return false ; } else { countSymbol -= extra ; if ( countSymbol % 2 == 0 ) { return true ; } } return false ; } public static void main ( String [ ] args ) { String S = " ( ) ( $ " ; if ( canBeBalanced ( S ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } }

Accumulator variables: countClosed, countOpen, countSymbol, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void maxDiffFreq ( int [ ] [ ] queries , String S ) { int N = S . length ( ) ; int Q = queries . length ; for ( int i = 0 ; i < Q ; ++ i ) { int l = queries [ i ] [ 0 ] - 1 ; int r = queries [ i ] [ 1 ] - 1 ; int freq [ ] = new int [ 26 ] ; for ( int j = l ; j <= r ; j ++ ) { freq [ S . charAt ( j ) - ' a ' ] ++ ; } int mx = 0 ; int mn = 99999999 ; for ( int j = 0 ; j < 26 ; j ++ ) { mx = Math . max ( mx , freq [ j ] ) ; if ( freq [ j ] > 0 ) mn = Math . min ( mn , freq [ j ] ) ; } System . out . print ( mx - mn + "NEW_LINE"); } } public static void main ( String [ ] args ) { String S = " abaabac " ; int [ ] [ ] queries = { { 2 , 6 } , { 1 , 7 } } ; maxDiffFreq ( queries , S ) ; } }

Index/key variables: i, j
Accumulator variables: j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class TrieNode { TrieNode Trie [ ] ; boolean isEnd ; public TrieNode ( ) { Trie = new TrieNode [ 256 ] ; for ( int i = 0 ; i < 256 ; i ++ ) { Trie [ i ] = null ; } isEnd = false ; } } class GFG { static void InsertTrie ( TrieNode root , String s ) { TrieNode temp = root ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( temp . Trie [ s . charAt ( i ) ] == null ) { temp . Trie [ s . charAt ( i ) ] = new TrieNode ( ) ; } temp = temp . Trie [ s . charAt ( i ) ] ; } temp . isEnd = true ; } static void printSuggestions ( TrieNode root , String res ) { if ( root . isEnd == true ) { System . out . print ( res + " ▁ " ) ; } for ( int i = 0 ; i < 256 ; i ++ ) { if ( root . Trie [ i ] != null ) { res += ( char ) i ; printSuggestions ( root . Trie [ i ] , res ) ; res = res . substring ( 0 , res . length ( ) - 2 ) ; } } } static boolean checkPresent ( TrieNode root , String key ) { for ( int i = 0 ; i < key . length ( ) ; i ++ ) { if ( root . Trie [ key . charAt ( i ) ] == null ) { printSuggestions ( root , key . substring ( 0 , i ) ) ; return false ; } root = root . Trie [ key . charAt ( i ) ] ; } if ( root . isEnd == true ) { return true ; } printSuggestions ( root , key ) ; return false ; } public static void main ( String [ ] args ) { String str [ ] = { " gee " , " geeks " , " ape " , " apple " , " geeksforgeeks " } ; String key = " geek " ; TrieNode root = new TrieNode ( ) ; for ( int i = 0 ; i < str . length ; i ++ ) { InsertTrie ( root , str [ i ] ) ; } if ( checkPresent ( root , key ) ) { System . out . println ( " YES " ) ; } } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Boolean variables: isEnd
Class/struct names: GFG, TrieNode
Java program:
import java . util . * ; class GFG { static int countStrings ( String S , String [ ] list ) { HashSet < Character > valid = new HashSet < Character > ( ) ; for ( char x : S . toCharArray ( ) ) { valid . add ( x ) ; } int cnt = 0 ; for ( int i = 0 ; i < list . length ; i ++ ) { int j = 0 ; for ( j = 0 ; j < list [ i ] . length ( ) ; j ++ ) { if ( valid . contains ( list [ i ] . charAt ( j ) ) ) continue ; else break ; } if ( j == list [ i ] . length ( ) ) cnt ++ ; } return cnt ; } public static void main ( String [ ] args ) { String [ ] arr = { " ab " , " aab " , " abaaaa " , " bbd " } ; String S = " ab " ; System . out . print ( countStrings ( S , arr ) + "NEW_LINE"); } }

Index/key variables: i
Accumulator variables: cnt, i, j
Iterator variables: i, j, x
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minLength ( String str , int N , String K , int M ) { Stack < Character > stackOfChar = new Stack < Character > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { stackOfChar . add ( str . charAt ( i ) ) ; if ( stackOfChar . size ( ) >= M ) { String l = " " ; for ( int j = M - 1 ; j >= 0 ; j -- ) { if ( K . charAt ( j ) != stackOfChar . peek ( ) ) { int f = 0 ; while ( f != l . length ( ) ) { stackOfChar . add ( l . charAt ( f ) ) ; f ++ ; } break ; } else { l = stackOfChar . peek ( ) + l ; stackOfChar . pop ( ) ; } } } } return stackOfChar . size ( ) ; } public static void main ( String [ ] args ) { String S1 = " fffoxoxoxfxo " ; String S2 = " fox " ; int N = S1 . length ( ) ; int M = S2 . length ( ) ; System . out . print ( minLength ( S1 , N , S2 , M ) ) ; } }

Accumulator variables: f, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void palindrome_prod ( String N ) { Vector < Integer > palindrome_list = new Vector < Integer > ( ) ; for ( int i = 101 ; i < 1000 ; i ++ ) { for ( int j = 121 ; j < 1000 ; j += ( i % 11 == 0 ) ? 1 : 11 ) { int n = i * j ; String x = String . valueOf ( n ) ; String y = x ; reverse ( y ) ; if ( x == y ) { if ( n < Integer . valueOf ( N ) ) { palindrome_list . add ( i * j ) ; } } } } System . out . print ( Collections . max ( palindrome_list ) ) ; } 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 N = "101110" ; palindrome_prod ( N ) ; } }

Index/key variables: l, r
Accumulator variables: i, j, l, r
Iterator variables: i, j, l
Class/struct names: GFG
Java program:
class GFG { static boolean isEqualStrings ( String [ ] arr , int N ) { int M = arr [ 0 ] . length ( ) ; int [ ] cntFreq = new int [ 256 ] ; for ( int i = 0 ; i < N ; i ++ ) { cntFreq [ i ] = 0 ; } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { cntFreq [ arr [ i ] . charAt ( j ) - ' a ' ] += 1 ; } } for ( int i = 0 ; i < 256 ; i ++ ) { if ( cntFreq [ i ] % N != 0 ) { return false ; } } return true ; } public static void main ( String [ ] args ) { String [ ] arr = { " aab " , " bbc " , " cca " } ; int N = arr . length ; if ( isEqualStrings ( arr , N ) ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void PrintStack ( Stack < Character > s ) { if ( s . isEmpty ( ) ) return ; char x = s . peek ( ) ; s . pop ( ) ; PrintStack ( s ) ; System . out . print ( x ) ; s . add ( x ) ; } static void minString ( String s ) { Stack < Character > Stack = new Stack < Character > ( ) ; Stack . add ( s . charAt ( 0 ) ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( Stack . isEmpty ( ) ) { Stack . add ( s . charAt ( i ) ) ; } else { if ( Stack . peek ( ) == s . charAt ( i ) ) { Stack . pop ( ) ; } else { Stack . push ( s . charAt ( i ) ) ; } } } PrintStack ( Stack ) ; } public static void main ( String [ ] args ) { String str = "101001" ; minString ( str ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int count_of_accident ( String a , String b ) { int n = a . length ( ) , m = b . length ( ) ; if ( n > m ) return ( m * ( m + 1 ) ) / 2 ; else return ( n * ( n + 1 ) ) / 2 + ( m - n ) * n ; } static double count_of_collision ( String a , String b ) { int n = a . length ( ) , m = b . length ( ) ; double answer = 0 ; int count_of_truck_in_lane_b = 0 ; for ( int i = 0 ; i < m ; i ++ ) if ( b . charAt ( i ) == ' T ' ) count_of_truck_in_lane_b ++ ; for ( int i = 0 ; i < n && i < m ; i ++ ) { if ( a . charAt ( i ) == ' T ' ) answer += count_of_truck_in_lane_b ; if ( b . charAt ( i ) == ' T ' ) count_of_truck_in_lane_b -- ; } return answer ; } static void findProbability ( String a , String b ) { int total_outcome = count_of_accident ( a , b ) ; double favourable_outcome = count_of_collision ( a , b ) ; System . out . printf ( " % 4f " , favourable_outcome / total_outcome ) ; } public static void main ( String [ ] args ) { String S = " TCCBCTTB " , T = " BTCCBBTT " ; findProbability ( S , T ) ; } }

Accumulator variables: answer, count_of_truck_in_lane_b, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int power ( int x , int y , int p ) { int res = 1 ; x = x % p ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( ( y & 1 ) == 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } public static void main ( String [ ] args ) { int N = 3 ; int flag , k , m = 0 ; if ( ( N == 1 ) || ( N == 2 ) ) System . out . print ( 62 ) ; else m = 1000000000 + 7 ; if ( N % 2 == 0 ) { k = N / 2 ; flag = 1 ; } else { k = ( N - 1 ) / 2 ; flag = 0 ; } if ( flag != 0 ) { int a = power ( 62 , k , m ) ; System . out . print ( a ) ; } else { int a = power ( 62 , ( k + 1 ) , m ) ; System . out . print ( a ) ; } } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int lenOfLongestReqSubstr ( String s , int N ) { HashMap < Integer , Integer > ind = new HashMap < > ( ) ; int mask = 0 ; ind . put ( 0 , - 1 ) ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int val = s . charAt ( i ) - '0' ; mask ^= ( 1 << val ) ; if ( ind . containsKey ( mask ) ) { ans = Math . max ( ans , i - ind . get ( mask ) ) ; } else ind . put ( mask , i ) ; } return ans ; } public static void main ( String [ ] args ) { String s = "223015150" ; int N = s . length ( ) ; System . out . print ( lenOfLongestReqSubstr ( s , N ) ) ; } }

Accumulator variables: i, mask
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int uniqueMorseRep ( String [ ] arr ) { String [ ] morseCode = { " . - " , " - . . . " , " - . - . " , " - . . " , " . " , " . . - . " , " - - . " , " . . . . " , " . . " , " . - - - " , " - . - " , " . - . . " , " - - " , " - . " , " - - - " , " . - - . " , " - - . - " , " . - . " , " . . . " , " - " , " . . - " , " . . . - " , " . - - " , " - . . - " , " - . - - " , " - - . . " } ; HashSet < String > st = new HashSet < > ( ) ; int N = arr . length ; for ( int i = 0 ; i < N ; i ++ ) { String temp = " " ; int M = arr [ i ] . length ( ) ; for ( int j = 0 ; j < M ; j ++ ) { temp += morseCode [ arr [ i ] . charAt ( j ) - ' a ' ] ; } st . add ( temp ) ; } return st . size ( ) ; } public static void main ( String [ ] args ) { String [ ] arr = { " gig " , " zeg " , " gin " , " msn " } ; System . out . print ( uniqueMorseRep ( arr ) + "NEW_LINE"); } }

Index/key variables: i
Accumulator variables: i, j, temp
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; public class GFG { public static void findFreq ( String str , int N ) { int [ ] freq = new int [ 256 ] ; int max = 0 ; char charMax = '0' ; for ( int i = 0 ; i < N ; i ++ ) { char ch = str . charAt ( i ) ; freq [ ch ] ++ ; if ( freq [ ch ] >= max ) { max = freq [ ch ] ; charMax = ch ; } System . out . println ( charMax + " ▁ - > ▁ " + max ) ; } } public static void main ( String [ ] args ) { String str = " abbc " ; int N = str . length ( ) ; findFreq ( str , N ) ; } }

Index/key variables: ch
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findMinCost ( String str , int pos ) { int n = str . length ( ) ; StringBuilder input1 = new StringBuilder ( ) ; input1 . append ( str ) ; if ( pos >= n / 2 ) { input1 = input1 . reverse ( ) ; pos = n - pos - 1 ; } int left , right ; left = right = pos ; for ( int i = pos ; i >= 0 ; -- i ) { if ( input1 . charAt ( i ) != input1 . charAt ( n - i - 1 ) ) { left = i ; } } for ( int i = pos ; i < n / 2 ; ++ i ) { if ( input1 . charAt ( i ) != input1 . charAt ( n - i - 1 ) ) { right = i ; } } int ans = 0 ; for ( int i = left ; i <= right ; ++ i ) { if ( input1 . charAt ( i ) != input1 . charAt ( n - i - 1 ) ) ans += 1 ; } int dis = Math . min ( ( 2 * ( pos - left ) + ( right - pos ) ) , ( 2 * ( right - pos ) + ( pos - left ) ) ) ; ans = ans + dis ; return ans ; } public static void main ( String args [ ] ) { String S = " bass " ; int P = 3 ; System . out . println ( findMinCost ( S , P ) ) ; } }

Accumulator variables: ans
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int minCost ( String s , int n ) { int minValue = 100000000 ; for ( int i = 0 ; i <= 25 ; i ++ ) { int cnt = 0 ; for ( int j = 0 ; j < n ; j ++ ) { cnt += Math . min ( Math . abs ( i - ( s . charAt ( j ) - ' a ' ) ) , 26 - Math . abs ( i - ( s . charAt ( j ) - ' a ' ) ) ) ; } minValue = Math . min ( minValue , cnt ) ; } return minValue ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int N = str . length ( ) ; System . out . println ( minCost ( str , N ) ) ; } }

Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { 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 ) ; } static void max_len ( String s [ ] , int N , int M ) { HashSet < String > set_str = new HashSet < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { set_str . add ( s [ i ] ) ; } Vector < String > left_ans = new Vector < > ( ) ; Vector < String > right_ans = new Vector < > ( ) ; String mid = " " ; for ( int i = 0 ; i < N ; i ++ ) { String t = s [ i ] ; t = reverse ( t ) ; if ( t == s [ i ] ) { mid = t ; } else if ( set_str . contains ( t ) ) { left_ans . add ( s [ i ] ) ; right_ans . add ( t ) ; set_str . remove ( s [ i ] ) ; set_str . remove ( t ) ; } } for ( String x : left_ans ) { System . out . print ( x ) ; } System . out . print ( mid ) ; Collections . reverse ( right_ans ) ; for ( String x : right_ans ) { System . out . print ( x ) ; } } public static void main ( String [ ] args ) { int N = 4 , M = 3 ; String s [ ] = { " omg " , " bbb " , " ffd " , " gmo " } ; max_len ( s , N , M ) ; } }

Index/key variables: i, l, r
Accumulator variables: i, l, r
Iterator variables: i, l, x
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static void minimum_length ( int x1 , int y1 , int x2 , int y2 , String str ) { int n = str . length ( ) ; int pos1 , pos2 , pos3 , pos4 ; pos1 = - 1 ; pos2 = - 1 ; pos3 = - 1 ; pos4 = - 1 ; if ( x1 == x2 && y1 == y2 ) { System . out . println ( "0" ) ; } else { for ( int i = 0 ; i < n ; i ++ ) { if ( x2 > x1 ) { if ( str . charAt ( i ) == ' E ' ) { x1 = x1 + 1 ; if ( x1 == x2 ) { pos1 = i ; } } } if ( x2 < x1 ) { if ( str . charAt ( i ) == ' W ' ) { x1 = x1 - 1 ; if ( x1 == x2 ) { pos2 = i ; } } } if ( y2 > y1 ) { if ( str . charAt ( i ) == ' N ' ) { y1 = y1 + 1 ; if ( y1 == y2 ) { pos3 = i ; } } } if ( y2 < y1 ) { if ( str . charAt ( i ) == ' S ' ) { y1 = y1 - 1 ; if ( y1 == y2 ) { pos4 = i ; } } } } int z ; z = Math . max ( pos1 , Math . max ( Math . max ( pos2 , pos3 ) , pos4 ) ) ; if ( x1 == x2 && y1 == y2 ) { System . out . println ( z + 1 ) ; } else { System . out . println ( " - 1" ) ; } } } public static void main ( String [ ] args ) throws java . lang . Exception { String str = " SESNW " ; int x1 = 0 , x2 = 1 , y1 = 0 , y2 = 1 ; minimum_length ( x1 , y1 , x2 , y2 , str ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String ShortenString ( String str1 ) { Stack < Character > st = new Stack < Character > ( ) ; int i = 0 ; while ( i < str1 . length ( ) ) { if ( st . isEmpty ( ) || str1 . charAt ( i ) != st . peek ( ) ) { st . add ( str1 . charAt ( i ) ) ; i ++ ; } else { st . pop ( ) ; i ++ ; } } if ( st . isEmpty ( ) ) { return ( " Empty ▁ String " ) ; } else { String short_String = " " ; while ( ! st . isEmpty ( ) ) { short_String = st . peek ( ) + short_String ; st . pop ( ) ; } return ( short_String ) ; } } public static void main ( String [ ] args ) { String str1 = " azzxzy " ; System . out . print ( ShortenString ( str1 ) ) ; } }

Accumulator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int fact ( int n ) { int res = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { res = res * i ; } return res ; } static int distinctWays ( String str1 , String str2 ) { int n = str1 . length ( ) ; int m = str2 . length ( ) ; if ( n == m ) { return 2 * fact ( n ) * fact ( m ) ; } return fact ( n ) * fact ( m ) ; } public static void main ( String [ ] args ) { String str1 = " aegh " ; String str2 = " rsw " ; System . out . print ( distinctWays ( str1 , str2 ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static String len ( long A , long B ) { String res = " " ; long log = 0 ; do { log = ( long ) ( Math . log ( B ) / Math . log ( 2 ) ) ; if ( log != 0 ) { res += A + " < < " + log ; } else { res += A ; break ; } B = B - ( long ) Math . pow ( 2 , log ) ; if ( B != 0 ) { res += " + " ; } else break ; } while ( log != 0 ) ; return res ; } public static void minimumString ( long A , long B ) { String res1 = len ( A , B ) ; String res2 = len ( B , A ) ; if ( res1 . length ( ) > res2 . length ( ) ) { System . out . println ( res2 ) ; } else { System . out . println ( res1 ) ; } } public static void main ( String args [ ] ) { long A = 6 ; long B = 10 ; minimumString ( A , B ) ; } }

Accumulator variables: res
Class/struct names: GFG
Java program:
class GFG { static void countSubString ( String s ) { int res = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int x = 0 ; for ( int j = i ; j < s . length ( ) ; j ++ ) { int temp = 1 << s . charAt ( j ) - ' a ' ; x ^= temp ; if ( ( x & ( x - 1 ) ) == 0 ) res ++ ; } } System . out . print ( res ) ; } public static void main ( String [ ] args ) { String str = " aaa " ; countSubString ( str ) ; } }

Accumulator variables: i, j, res, x
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void countSubString ( String s ) { int answer = 0 ; HashMap < Integer , Integer > m = new HashMap < Integer , Integer > ( ) ; m . put ( 0 , 1 ) ; int x = 0 ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { x ^= 1 << ( s . charAt ( j ) - ' a ' ) ; answer += m . containsKey ( x ) ? m . get ( x ) : 0 ; for ( int i = 0 ; i < 26 ; ++ i ) { answer += m . containsKey ( x ^ ( 1 << i ) ) ? m . get ( x ^ ( 1 << i ) ) : 0 ; } if ( m . containsKey ( x ) ) m . put ( x , m . get ( x ) + 1 ) ; else m . put ( x , 1 ) ; } System . out . print ( answer ) ; } public static void main ( String [ ] args ) { String str = " abab " ; countSubString ( str ) ; } }

Accumulator variables: answer, j, x
Iterator variables: i, j
Class/struct names: GFG