dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void countStringPairs ( String a [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { char p [ ] = a [ i ] . toCharArray ( ) ; char q [ ] = a [ j ] . toCharArray ( ) ; if ( p [ 0 ] != q [ 0 ] ) { char temp = p [ 0 ] ; p [ 0 ] = q [ 0 ] ; q [ 0 ] = temp ; int flag1 = 0 ; int flag2 = 0 ; for ( int k = 0 ; k < n ; k ++ ) { if ( a [ k ] . equals ( new String ( p ) ) ) { flag1 = 1 ; } if ( a [ k ] . equals ( new String ( q ) ) ) { flag2 = 1 ; } } if ( flag1 == 0 && flag2 == 0 ) { ans = ans + 1 ; } } } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String arr [ ] = { " good " , " bad " , " food " } ; int N = arr . length ; countStringPairs ( arr , N ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
class GFG { static void addFrequencyToCharacter ( char [ ] s ) { int frequency [ ] = new int [ 26 ] ; int n = s . length ; for ( int i = 0 ; i < n ; i ++ ) { frequency [ s [ i ] - ' a ' ] += 1 ; } for ( int i = 0 ; i < n ; i ++ ) { int add = frequency [ s [ i ] - ' a ' ] % 26 ; if ( ( int ) ( s [ i ] ) + add <= ( int ) ( ' z ' ) ) s [ i ] = ( char ) ( ( int ) ( s [ i ] ) + add ) ; else { add = ( ( int ) ( s [ i ] ) + add ) - ( ( int ) ( ' z ' ) ) ; s [ i ] = ( char ) ( ( int ) ( ' a ' ) + add - 1 ) ; } } System . out . println ( s ) ; } public static void main ( String [ ] args ) { String str = " geeks " ; addFrequencyToCharacter ( str . toCharArray ( ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static String isPossible ( String S , int R , int N ) { int cntl = 0 , cntr = 0 ; int cntu = 0 , cntd = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S . charAt ( i ) == ' L ' ) cntl ++ ; else if ( S . charAt ( i ) == ' R ' ) cntr ++ ; else if ( S . charAt ( i ) == ' U ' ) cntu ++ ; else cntd ++ ; } if ( Math . max ( Math . max ( cntl , cntr ) , Math . max ( cntu , cntd ) ) >= R ) return " Yes " ; HashMap < Integer , Integer > mp = new HashMap < > ( ) ; int r_square = R * R ; for ( int i = 1 ; i * i <= r_square ; i ++ ) { mp . put ( i * i , i ) ; if ( mp . containsKey ( r_square - i * i ) ) { if ( Math . max ( cntl , cntr ) >= mp . get ( r_square - i * i ) && Math . max ( cntu , cntd ) >= i ) return " Yes " ; if ( Math . max ( cntl , cntr ) >= i && Math . max ( cntu , cntd ) >= mp . get ( r_square - i * i ) ) return " Yes " ; } } return " No " ; } public static void main ( String [ ] args ) { String S = " RDLLDDLDU " ; int R = 5 ; int N = S . length ( ) ; System . out . println ( isPossible ( S , R , N ) ) ; } }

Accumulator variables: cntd, cntl, cntr, cntu, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void addASCII ( char [ ] S , char [ ] N ) { for ( int i = 0 ; i < S . length ; i ++ ) { int a = ( int ) ( N [ i ] ) - '0' ; int b = ( int ) ( S [ i ] ) + a ; if ( b > 122 ) b -= 26 ; S [ i ] = ( char ) ( b ) ; } System . out . print ( S ) ; } public static void main ( String [ ] args ) { String S = " sun " , N = "966" ; addASCII ( S . toCharArray ( ) , N . toCharArray ( ) ) ; } }

Index/key variables: i
Accumulator variables: b, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static String decHex ( int n ) { char alpha [ ] = { ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' } ; StringBuilder ans = new StringBuilder ( " " ) ; while ( n > 0 ) { if ( n % 16 < 10 ) { ans . append ( Integer . toString ( n % 16 ) ) ; } else { ans . append ( alpha [ n % 16 - 10 ] ) ; } n /= 16 ; } ans = ans . reverse ( ) ; return ans . toString ( ) ; } static int hexDec ( String convertedHex ) { char mp [ ] = { 10 , 11 , 12 , 13 , 14 , 15 } ; int ans = 0 ; int pos = 0 ; StringBuilder s = new StringBuilder ( convertedHex ) ; convertedHex = s . reverse ( ) . toString ( ) ; for ( char ch : convertedHex . toCharArray ( ) ) { if ( Character . isDigit ( ch ) ) { ans += ( ( int ) Math . pow ( 16 , pos ) ) * ( ch - '0' ) ; } else { ans += ( ( int ) Math . pow ( 16 , pos ) ) * mp [ ch - ' A ' ] ; } pos += 1 ; } return ans ; } static String removeChars ( String hexaVal , String S ) { HashSet < Character > setk = new HashSet < > ( ) ; for ( char ch : S . toCharArray ( ) ) { setk . add ( ch ) ; } String ans = " " ; for ( char ch : hexaVal . toCharArray ( ) ) { if ( setk . contains ( ch ) ) { continue ; } ans += ch ; } return ans ; } static void convertArr ( int arr [ ] , String S ) { for ( int i = 0 ; i < arr . length ; i ++ ) { String hexaVal = decHex ( arr [ i ] ) ; String convertedHex = removeChars ( hexaVal , S ) ; int decVal = hexDec ( convertedHex ) ; arr [ i ] = decVal ; } for ( int val : arr ) { System . out . print ( val + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 74 , 91 , 31 , 122 } ; String S = "1AB " ; convertArr ( arr , S ) ; } }

Index/key variables: i
Accumulator variables: ans, i, n, pos
Iterator variables: ch, i, val
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int findMinimumChairs ( String s ) { int count = 0 ; int i = 0 ; int mini = Integer . MIN_VALUE ; while ( i < s . length ( ) ) { if ( s . charAt ( i ) == ' E ' ) count ++ ; else count -- ; mini = Math . max ( count , mini ) ; i ++ ; } return mini ; } public static void main ( String [ ] args ) { String s = " EELEE " ; System . out . print ( findMinimumChairs ( s ) ) ; } }

Accumulator variables: count, i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void fillString ( String str , int k ) { char s [ ] = str . toCharArray ( ) ; HashMap < Integer , Character > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] != ' ? ' ) { mp . put ( i % k , s [ i ] ) ; } } for ( int i = 0 ; i < s . length ; i ++ ) { if ( ! mp . containsKey ( i % k ) ) { System . out . println ( - 1 ) ; return ; } s [ i ] = mp . getOrDefault ( i % k , s [ i ] ) ; } System . out . println ( new String ( s ) ) ; } public static void main ( String [ ] args ) { String S = " ? ? ? ? abcd " ; int K = 4 ; fillString ( S , K ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void rearrangeString ( char [ ] s1 , char [ ] s2 ) { int [ ] cnt = new int [ 26 ] ; for ( int i = 0 ; i < s2 . length ; i ++ ) cnt [ s2 [ i ] - ' a ' ] ++ ; int unique = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) if ( cnt [ i ] != 0 ) unique ++ ; if ( unique == 1 ) { int count_in_s2 = s2 . length ; int count_in_s1 = 0 ; for ( int i = 0 ; i < s1 . length ; i ++ ) if ( s1 [ i ] == s2 [ 0 ] ) count_in_s1 ++ ; if ( count_in_s1 < count_in_s2 ) { System . out . print ( new String ( s1 ) ) ; return ; } System . out . print ( - 1 ) ; } else { int inc = 1 ; for ( int i = 0 ; i < s2 . length - 1 ; i ++ ) if ( s2 [ i ] > s2 [ i + 1 ] ) inc = 0 ; if ( inc == 1 ) { Arrays . sort ( s1 ) ; for ( int k = 0 ; k < s1 . length / 2 ; k ++ ) { char temp = s1 [ k ] ; s1 [ k ] = s1 [ s1 . length - k - 1 ] ; s1 [ s1 . length - k - 1 ] = temp ; } System . out . print ( new String ( s1 ) ) ; } else { Arrays . sort ( s1 ) ; System . out . print ( new String ( s1 ) ) ; } } } public static void main ( String [ ] args ) { char [ ] s1 = " abcd " . toCharArray ( ) ; char [ ] s2 = " ab " . toCharArray ( ) ; rearrangeString ( s1 , s2 ) ; } }

Index/key variables: i, k
Accumulator variables: count_in_s1, i, k, unique
Iterator variables: i, k
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static boolean isReducible ( String str ) { int N = str . length ( ) ; ArrayList < Character > s = new ArrayList < Character > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( str . charAt ( i ) == '1' ) s . add ( str . charAt ( i ) ) ; else if ( s . size ( ) > 0 ) s . remove ( s . size ( ) - 1 ) ; else return false ; } if ( s . size ( ) == 0 ) { return true ; } else { return false ; } } public static void main ( String [ ] args ) { String str = "11011000" ; if ( isReducible ( str ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int cntMinOperation ( char [ ] S , int N ) { int cntOp = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( S [ i ] == '0' && S [ i + 1 ] == '0' ) { S [ i + 1 ] = '1' ; cntOp += 1 ; } } return cntOp ; } public static void main ( String [ ] args ) { String S = "10001" ; int N = S . length ( ) ; System . out . print ( cntMinOperation ( S . toCharArray ( ) , N ) ) ; } }

Index/key variables: i
Accumulator variables: cntOp, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String solution ( String s ) { Vector < Character > vowel = new Vector < Character > ( ) ; Vector < Character > consonant = new Vector < Character > ( ) ; for ( char i : s . toCharArray ( ) ) { if ( i == ' a ' i == ' e ' i == ' i ' i == ' o ' i == ' u ' ) { vowel . add ( i ) ; } else { consonant . add ( i ) ; } } int Nc , Nv ; Nv = vowel . size ( ) ; Nc = consonant . size ( ) ; int M = Nc / ( Nv - 1 ) ; String ans = " " ; int consotnant_till = 0 ; for ( char i : vowel ) { ans += i ; int temp = 0 ; for ( int j = consotnant_till ; j < Math . min ( Nc , consotnant_till + M ) ; j ++ ) { ans += consonant . get ( j ) ; temp ++ ; } consotnant_till += temp ; } return ans ; } public static void main ( String [ ] args ) { String str = " aaaabbbcc " ; System . out . print ( solution ( str ) ) ; } }

Accumulator variables: ans, consotnant_till, j, temp
Iterator variables: i, j
Class/struct names: GFG
Java program:
public class GFG { static void smallestlexicographicstring ( char [ ] s , int k ) { int n = s . length ; if ( k >= n ) { for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = ' a ' ; } System . out . print ( s ) ; return ; } for ( int i = 0 ; i < n ; i ++ ) { if ( k == 0 ) { break ; } if ( s [ i ] == ' a ' ) continue ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( s [ j ] > s [ i ] ) { s [ j ] = s [ i ] ; break ; } else if ( j == n - 1 ) s [ j ] = s [ i ] ; } s [ i ] = ' a ' ; k -- ; } System . out . print ( s ) ; } public static void main ( String [ ] args ) { char [ ] s = ( " geeksforgeeks " ) . toCharArray ( ) ; int k = 6 ; smallestlexicographicstring ( s , k ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, k
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void canReduceString ( String S , int N ) { int count_1 = 0 ; int count_2 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S . charAt ( i ) == ' ( ' ) { count_1 ++ ; } else { count_2 ++ ; } } if ( count_1 == 0 count_2 == 0 ) { System . out . print ( " - 1" + "NEW_LINE"); } else if ( count_1 == count_2 ) { System . out . print ( "0" + "NEW_LINE"); } else if ( N % 2 != 0 ) { System . out . print ( " - 1" ) ; } else { System . out . print ( Math . abs ( count_1 - count_2 ) / 2 ) ; } } public static void main ( String [ ] args ) { String S = " ) ) ) ( ( ( " ; int N = S . length ( ) ; canReduceString ( S , N ) ; } }

Accumulator variables: count_1, count_2, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void isAcceptedDFA ( String s , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( s . charAt ( i ) == ' a ' ) count ++ ; } if ( count == N && count != 0 ) { System . out . print ( " Accepted " ) ; } else { System . out . print ( " Not ▁ Accepted " ) ; } } public static void main ( String [ ] args ) { String S = " aaaaa " ; isAcceptedDFA ( S , S . length ( ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void maximum_pallindromic ( int arr [ ] ) { int res = 0 ; int c1 = 0 , c2 = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { res += arr [ i ] / 3 ; arr [ i ] = arr [ i ] % 3 ; if ( arr [ i ] == 1 ) c1 ++ ; else if ( arr [ i ] == 2 ) c2 ++ ; } res += Math . min ( c1 , c2 ) ; int t = Math . min ( c1 , c2 ) ; c1 -= t ; c2 -= t ; res += 2 * ( c2 / 3 ) ; c2 %= 3 ; res += c2 / 2 ; System . out . print ( res ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; maximum_pallindromic ( arr ) ; } }

Index/key variables: i
Accumulator variables: c1, c2, i, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void find_Winner ( String [ ] arr , int N ) { @ SuppressWarnings ( " unchecked " ) Vector < Character > [ ] Q = new Vector [ N ] ; for ( int i = 0 ; i < Q . length ; i ++ ) Q [ i ] = new Vector < Character > ( ) ; int M = arr . length ; for ( int i = 0 ; i < M ; i ++ ) { int len = arr [ i ] . length ( ) ; for ( int j = 0 ; j < len ; j ++ ) { Q [ i ] . add ( arr [ i ] . charAt ( j ) ) ; } } int player = 0 ; while ( Q [ player ] . size ( ) > 0 ) { int nextPlayer = Q [ player ] . get ( 0 ) - '0' - 1 ; Q [ player ] . remove ( 0 ) ; player = nextPlayer ; } System . out . print ( " Player ▁ " + ( player + 1 ) ) ; } public static void main ( String [ ] args ) { int N = 3 ; String [ ] arr = { "323" , "2" , "2" } ; find_Winner ( arr , N ) ; } }

Index/key variables: N, i, player
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static int longestSubstring ( String s ) { int dp [ ] = new int [ 1024 ] ; Arrays . fill ( dp , s . length ( ) ) ; int res = 0 , mask = 0 ; dp [ 0 ] = - 1 ; for ( int i = 0 ; i < s . length ( ) ; ++ i ) { mask ^= 1 << ( s . charAt ( i ) - '0' ) ; res = Math . max ( res , i - dp [ mask ] ) ; for ( int j = 0 ; j <= 9 ; ++ j ) res = Math . max ( res , i - dp [ mask ^ ( 1 << j ) ] ) ; dp [ mask ] = Math . min ( dp [ mask ] , i ) ; } return res ; } public static void main ( String [ ] args ) { String s = "3242415" ; System . out . println ( longestSubstring ( s ) ) ; } }

Index/key variables: mask
Accumulator variables: mask
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void Validate ( String M ) { int len = M . length ( ) ; String temp = " " ; for ( int i = 0 ; i < len ; i ++ ) { if ( Character . isDigit ( M . charAt ( i ) ) ) temp += M . charAt ( i ) ; } int nwlen = temp . length ( ) ; if ( nwlen != 10 ) { System . out . print ( "InvalidNEW_LINE"); return ; } String res = " " ; String x = temp . substring ( 0 , 3 ) ; res += " ( " + x + " ) - " ; x = temp . substring ( 3 , 6 ) ; res += " ( " + x + " ) - " ; x = temp . substring ( 6 , 9 ) ; res += " ( " + x + " ) - " ; x = temp . substring ( 9 , 10 ) ; res += " ( " + x + " ) " ; System . out . print ( res + "NEW_LINE"); } public static void main ( String [ ] args ) { String M = "91 ▁ 234rt5%34*0 ▁ 3" ; Validate ( M ) ; } }

Accumulator variables: i, res, temp
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class Main { static void hexaModK ( String N , String k ) { HashMap < Character , Integer > map = new HashMap < > ( ) ; for ( char i = '0' ; i <= '9' ; i ++ ) { map . put ( i , i - '0' ) ; } map . put ( ' A ' , 10 ) ; map . put ( ' B ' , 11 ) ; map . put ( ' C ' , 12 ) ; map . put ( ' D ' , 13 ) ; map . put ( ' E ' , 14 ) ; map . put ( ' F ' , 15 ) ; long m = Long . parseLong ( k , 16 ) ; long base = 1 ; long ans = 0 ; for ( int i = N . length ( ) - 1 ; i >= 0 ; i -- ) { long n = map . get ( N . charAt ( i ) ) % m ; ans = ( ans + ( base % m * n % m ) % m ) % m ; base = ( base % m * 16 % m ) % m ; } System . out . println ( Long . toHexString ( ans ) . toUpperCase ( ) ) ; } public static void main ( String args [ ] ) { String n = "3E8" ; String k = "13" ; hexaModK ( n , k ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: Main
Java program:
import java . util . * ; class GFG { static String combination = " " ; static HashSet < String > combinations = new LinkedHashSet < String > ( ) ; static void printSequences ( HashSet < String > combinations ) { for ( String s : combinations ) { System . out . print ( s + " ▁ " ) ; } } static void generateCombinations ( String s , int n ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { combination += ( s . charAt ( i ) ) ; long x = Integer . valueOf ( combination ) ; if ( x <= n ) { combinations . add ( combination ) ; generateCombinations ( s , n ) ; } combination = combination . substring ( 0 , combination . length ( ) - 1 ) ; } } public static void main ( String [ ] args ) { String S = "124" ; int N = 100 ; generateCombinations ( S , N ) ; printSequences ( combinations ) ; } }

Accumulator variables: combination, i
Iterator variables: i, s
Class/struct names: GFG
Java program:
import java . util . Arrays ; public class GFG { static int compute_hash ( String str ) { int p = 31 ; int MOD = ( int ) 1e9 + 7 ; int hash_val = 0 ; int mul = 1 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { char ch = str . charAt ( i ) ; hash_val = ( hash_val + ( ch - ' a ' + 1 ) * mul ) % MOD ; mul = ( mul * p ) % MOD ; } return hash_val ; } static int distinct_str ( String arr [ ] , int n ) { int hash [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { hash [ i ] = compute_hash ( arr [ i ] ) ; } Arrays . sort ( hash ) ; int cntElem = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( hash [ i ] != hash [ i - 1 ] ) { cntElem ++ ; } } return cntElem ; } public static void main ( String [ ] args ) { String arr [ ] = { " abcde " , " abcce " , " abcdf " , " abcde " } ; int N = arr . length ; System . out . println ( distinct_str ( arr , N ) ) ; } }

Index/key variables: i, n
Accumulator variables: cntElem, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void SieveOfEratosthenes ( boolean [ ] prime , int n ) { for ( int i = 0 ; i <= n ; i ++ ) { prime [ i ] = true ; } prime [ 0 ] = prime [ 1 ] = false ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( prime [ i ] == true ) { for ( int j = 2 ; i * j <= n ; j ++ ) { prime [ i * j ] = false ; } } } } static void removePrimeFrequencies ( char [ ] s ) { int n = s . length ; boolean [ ] prime = new boolean [ n + 1 ] ; SieveOfEratosthenes ( prime , n ) ; HashMap < Character , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( m . containsKey ( s [ i ] ) ) { m . put ( s [ i ] , m . get ( s [ i ] ) + 1 ) ; } else { m . put ( s [ i ] , 1 ) ; } } String new_String = " " ; for ( int i = 0 ; i < s . length ; i ++ ) { if ( prime [ m . get ( s [ i ] ) ] ) continue ; new_String += s [ i ] ; } System . out . print ( new_String ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; removePrimeFrequencies ( str . toCharArray ( ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, new_String
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static String rearrange ( String s ) { String s1 = " " , s2 = " " , ans = " " ; char [ ] s3 = s . toCharArray ( ) ; for ( char x : s3 ) { if ( x >= ' a ' && x <= ' z ' ) s1 += x ; else s2 += x ; } int n = s1 . length ( ) ; int m = s2 . length ( ) ; if ( Math . abs ( n - m ) > 1 ) return " - 1" ; int i = 0 , j = 0 , k = 0 ; int flag = ( n >= m ) ? 1 : 0 ; while ( i < n && j < m ) { if ( flag != 0 ) ans += s1 . charAt ( i ++ ) ; else ans += s2 . charAt ( j ++ ) ; if ( flag == 1 ) flag = 0 ; else flag = 1 ; } return ans ; } public static void main ( String [ ] args ) { String str = " geeks2020" ; System . out . print ( rearrange ( str ) + "NEW_LINE"); } }

Accumulator variables: ans, i, j, s1, s2
Iterator variables: x
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void charactersCount ( String str , int n ) { int count = 0 ; while ( n > 0 ) { char cur = str . charAt ( 0 ) ; int ind = 0 ; for ( int j = 1 ; j < n ; j ++ ) { if ( str . charAt ( j ) < cur ) { cur = str . charAt ( j ) ; ind = j ; } } str = str . substring ( 0 , ind ) + str . substring ( ind + 1 ) ; n -- ; count += ind + 1 ; } System . out . print ( count + "NEW_LINE"); } public static void main ( String [ ] args ) { String str = " aabbc " ; int n = 5 ; charactersCount ( str , n ) ; } }

Accumulator variables: count, j, n
Iterator variables: j
Class/struct names: GFG
Java program:
class GFG { public static void printMiddleCharacter ( String str ) { int len = str . length ( ) ; int middle = len / 2 ; System . out . println ( str . charAt ( middle ) ) ; } public static void main ( String args [ ] ) { String str = " GeeksForGeeks " ; printMiddleCharacter ( str ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static boolean check ( String s ) { HashSet < Character > a = new HashSet < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( a . contains ( s . charAt ( i ) ) ) { return false ; } a . add ( s . charAt ( i ) ) ; } return true ; } static ArrayList < String > helper ( ArrayList < String > arr , int ind ) { ArrayList < String > fin = new ArrayList < > ( ) ; fin . add ( " " ) ; if ( ind == arr . size ( ) ) return fin ; ArrayList < String > tmp = helper ( arr , ind + 1 ) ; ArrayList < String > ret = new ArrayList < > ( tmp ) ; for ( int i = 0 ; i < tmp . size ( ) ; i ++ ) { String test = tmp . get ( i ) + arr . get ( ind ) ; if ( check ( test ) ) ret . add ( test ) ; } return ret ; } static int maxLength ( ArrayList < String > arr ) { ArrayList < String > tmp = helper ( arr , 0 ) ; int len = 0 ; for ( int i = 0 ; i < tmp . size ( ) ; i ++ ) { len = len > tmp . get ( i ) . length ( ) ? len : tmp . get ( i ) . length ( ) ; } return len ; } public static void main ( String [ ] args ) { ArrayList < String > s = new ArrayList < > ( ) ; s . add ( " abcdefgh " ) ; System . out . println ( maxLength ( s ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void Range_sum_query ( String S , Vector < pair > Query ) { int N = S . length ( ) ; int [ ] A = new int [ N ] ; A [ 0 ] = S . charAt ( 0 ) - ' a ' + 1 ; for ( int i = 1 ; i < N ; i ++ ) { A [ i ] = S . charAt ( i ) - ' a ' + 1 ; A [ i ] = A [ i ] + A [ i - 1 ] ; } for ( int i = 0 ; i < Query . size ( ) ; i ++ ) { if ( Query . get ( i ) . first == 1 ) { System . out . print ( A [ ( Query . get ( i ) . second ) - 1 ] + "NEW_LINE"); } else { System . out . print ( A [ ( Query . get ( i ) . second ) - 1 ] - A [ ( Query . get ( i ) . first ) - 2 ] + "NEW_LINE"); } } } public static void main ( String [ ] args ) { String S = " abcd " ; Vector < pair > Query = new Vector < pair > ( ) ; Query . add ( new pair ( 2 , 4 ) ) ; Query . add ( new pair ( 1 , 3 ) ) ; Range_sum_query ( S , Query ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
class GFG { static void swap_ ( char [ ] a , int l , int i ) { char temp ; temp = a [ l ] ; a [ l ] = a [ i ] ; a [ i ] = temp ; } static void permute ( char [ ] str , int l , int r , int n ) { int i ; if ( l == r ) { int j = Integer . valueOf ( String . valueOf ( str ) ) ; if ( j % n == 0 ) System . out . print ( String . valueOf ( str ) + "NEW_LINE"); return ; } for ( i = l ; i < r ; i ++ ) { swap_ ( str , l , i ) ; permute ( str , l + 1 , r , n ) ; swap_ ( str , l , i ) ; } } public static void main ( String [ ] args ) { String str = "125" ; int n = 5 ; int len = str . length ( ) ; if ( len > 0 ) permute ( str . toCharArray ( ) , 0 , len , n ) ; } }

Index/key variables: i, l
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG