dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static Vector < String > subString ( String s , int n ) { Vector < String > v = new Vector < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int len = 1 ; len <= n - i ; len ++ ) { String find = s . substring ( i , i + len ) ; v . add ( find ) ; } } return v ; } static int IsPresent ( String str , String target ) { if ( str . contains ( target ) ) { return 1 ; } return - 1 ; } static void countSubStrings ( String S , String T ) { Vector < String > v = subString ( S , S . length ( ) ) ; int ans = 0 ; for ( String it : v ) { if ( IsPresent ( it , T ) != - 1 ) { ans ++ ; } } System . out . print ( ans ) ; } public static void main ( String [ ] args ) { String S = " dabc " ; String T = " ab " ; countSubStrings ( S , T ) ; } }

Accumulator variables: ans, i, len
Iterator variables: i, it, len
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void minOperation ( int X [ ] , int Y [ ] , int n ) { int C = 0 ; int count = 0 ; for ( int i = 1 ; i < n ; i = i + 2 ) { if ( X [ i ] != Y [ i ] ) { count ++ ; } else { if ( count != 0 ) C ++ ; count = 0 ; } } if ( count != 0 ) C ++ ; count = 0 ; for ( int i = 0 ; i < n ; i = i + 2 ) { if ( X [ i ] != Y [ i ] ) { count ++ ; } else { if ( count != 0 ) C ++ ; count = 0 ; } } if ( count != 0 ) C ++ ; System . out . print ( C ) ; } public static void main ( String [ ] args ) { int X [ ] = { 1 , 0 , 0 , 0 , 0 , 1 } ; int Y [ ] = { 1 , 1 , 0 , 1 , 1 , 1 } ; int N = X . length ; minOperation ( X , Y , N ) ; } }

Index/key variables: i
Accumulator variables: C, count
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minimumcntOperationReq ( int arr [ ] , int N ) { int cntOp = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] == arr [ i + 1 ] ) { cntOp ++ ; } } return ( cntOp + 1 ) / 2 ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 1 , 0 , 1 , 0 , 0 , 0 } ; int N = arr . length ; System . out . print ( minimumcntOperationReq ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: cntOp, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void isSequenceValid ( int [ ] B , int N ) { for ( int i = 0 ; i < N ; i ++ ) { if ( ( i + 1 ) % B [ i ] != 0 ) { System . out . print ( " No " ) ; return ; } } System . out . print ( " Yes " ) ; } public static void main ( String [ ] args ) { int N = 4 ; int [ ] arr = { 1 , 2 , 3 , 2 } ; isSequenceValid ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void ConstArrayAdjacentCoprime ( int N ) { for ( int i = 1 ; i <= N ; i ++ ) { System . out . print ( i + " ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 6 ; ConstArrayAdjacentCoprime ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxEqrows ( Vector < Vector < Integer > > mat , int N , int M ) { HashMap < Vector < Integer > , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( mp . containsKey ( mat . get ( i ) ) ) { mp . put ( mat . get ( i ) , mp . get ( mat . get ( i ) ) + 1 ) ; } else { mp . put ( mat . get ( i ) , 1 ) ; } } int cntMaxRows = 0 ; for ( int i = 0 ; i < N ; i ++ ) { Vector < Integer > onesCompRow = new Vector < Integer > ( ) ; for ( int j = 0 ; j < M ; j ++ ) { onesCompRow . add ( 0 ) ; } for ( int j = 0 ; j < M ; j ++ ) { onesCompRow . set ( j , mat . get ( i ) . get ( j ) ^ 1 ) ; } if ( ! mp . containsKey ( mat . get ( i ) ) ) { cntMaxRows = Math . max ( cntMaxRows , mp . get ( onesCompRow ) ) ; } else if ( ! mp . containsKey ( onesCompRow ) ) { cntMaxRows = Math . max ( cntMaxRows , mp . get ( mat . get ( i ) ) ) ; } else { cntMaxRows = Math . max ( cntMaxRows , mp . get ( mat . get ( i ) ) + mp . get ( onesCompRow ) ) ; } } return cntMaxRows ; } public static void main ( String [ ] args ) { Vector < Vector < Integer > > mat = new Vector < Vector < Integer > > ( ) ; mat . add ( new Vector < Integer > ( ) ) ; mat . add ( new Vector < Integer > ( ) ) ; mat . add ( new Vector < Integer > ( ) ) ; mat . get ( 0 ) . add ( 0 ) ; mat . get ( 0 ) . add ( 1 ) ; mat . get ( 0 ) . add ( 0 ) ; mat . get ( 0 ) . add ( 0 ) ; mat . get ( 0 ) . add ( 1 ) ; mat . get ( 1 ) . add ( 1 ) ; mat . get ( 1 ) . add ( 1 ) ; mat . get ( 1 ) . add ( 0 ) ; mat . get ( 1 ) . add ( 1 ) ; mat . get ( 1 ) . add ( 1 ) ; mat . get ( 2 ) . add ( 1 ) ; mat . get ( 2 ) . add ( 0 ) ; mat . get ( 2 ) . add ( 1 ) ; mat . get ( 2 ) . add ( 1 ) ; mat . get ( 2 ) . add ( 0 ) ; int N = mat . size ( ) ; int M = mat . get ( 0 ) . size ( ) ; System . out . println ( maxEqrows ( mat , N , M ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void minimumCost ( String a , String b ) { int fre1 [ ] = new int [ 256 ] ; int fre2 [ ] = new int [ 256 ] ; for ( char c : a . toCharArray ( ) ) fre1 [ ( int ) ( c ) ] ++ ; for ( char c : b . toCharArray ( ) ) fre2 [ ( int ) ( c ) ] ++ ; int mincost = 0 ; for ( int i = 0 ; i < 256 ; i ++ ) { mincost += Math . abs ( fre1 [ i ] - fre2 [ i ] ) ; } System . out . println ( mincost ) ; } public static void main ( String [ ] args ) { String A = "1AB + - " , B = " cc " ; minimumCost ( A , B ) ; } }

Index/key variables: i
Accumulator variables: i, mincost
Iterator variables: c, i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public void minCost ( int [ ] arr ) { int odd = 0 , even = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] % 2 == 0 ) even ++ ; else odd ++ ; } System . out . print ( Math . min ( even , odd ) ) ; } public static void main ( String [ ] args ) { GFG obj = new GFG ( ) ; int arr [ ] = { 1 , 2 , 3 } ; obj . minCost ( arr ) ; } }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findMaxSumByAlternatingSign ( int arr [ ] , int N ) { int cntNeg = 0 ; int MaxAltSum = 0 ; int SmValue = 0 ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] < 0 ) { cntNeg += 1 ; } sum += Math . abs ( arr [ i ] ) ; SmValue = Math . min ( SmValue , Math . abs ( arr [ i ] ) ) ; } MaxAltSum = sum ; if ( cntNeg % 2 == 1 ) { MaxAltSum -= 2 * SmValue ; } return MaxAltSum ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , - 2 , - 4 , 5 } ; int N = arr . length ; System . out . print ( findMaxSumByAlternatingSign ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: MaxAltSum, cntNeg, i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void constructNewArraySumZero ( int arr [ ] , int N ) { int newArr [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { if ( i % 2 == 0 ) { newArr [ i ] = arr [ i + 1 ] ; } else { newArr [ i ] = - arr [ i - 1 ] ; } } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( newArr [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , - 5 , - 6 , 8 } ; int N = arr . length ; constructNewArraySumZero ( arr , N ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void bitonicSequence ( int num , int lower , int upper ) { if ( num > ( upper - lower ) * 2 + 1 ) { System . out . println ( - 1 ) ; return ; } Deque < Integer > ans = new ArrayDeque < > ( ) ; for ( int i = 0 ; i < Math . min ( upper - lower + 1 , num - 1 ) ; i ++ ) ans . add ( upper - i ) ; for ( int i = 0 ; i < num - ans . size ( ) ; i ++ ) ans . addFirst ( upper - i - 1 ) ; System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int N = 5 , L = 3 , R = 10 ; bitonicSequence ( N , L , R ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countSubStrings ( String s , String t ) { int answ = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { for ( int j = 0 ; j < t . length ( ) ; j ++ ) { if ( t . charAt ( j ) != s . charAt ( i ) ) { answ += 1 ; int k = 1 ; int z = - 1 ; int q = 1 ; while ( j + z >= 0 && 0 <= i + z && s . charAt ( i + z ) == t . charAt ( j + z ) ) { z -= 1 ; answ += 1 ; q += 1 ; } while ( s . length ( ) > i + k && j + k < t . length ( ) && s . charAt ( i + k ) == t . charAt ( j + k ) ) { k += 1 ; answ += q ; z = - 1 ; } } } } return answ ; } public static void main ( String [ ] args ) { String S = " aba " ; String T = " baba " ; System . out . println ( countSubStrings ( S , T ) ) ; } }

Accumulator variables: answ, i, j, k, q, z
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int minimumCntOfFlipsRequired ( String str ) { int n = str . length ( ) ; int zeros = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == '0' ) { zeros ++ ; } } if ( zeros == 0 zeros == n ) { return 0 ; } int minFlips = Integer . MAX_VALUE ; int currOnes = 0 ; int flips ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == '1' ) { currOnes ++ ; } flips = currOnes + ( zeros - ( i + 1 - currOnes ) ) ; minFlips = Math . min ( minFlips , flips ) ; } return minFlips ; } public static void main ( String [ ] args ) { String s1 = "100101" ; System . out . println ( minimumCntOfFlipsRequired ( s1 ) ) ; } }

Accumulator variables: currOnes, i, zeros
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findLongestNonDecreasing ( int A [ ] , int N ) { int res = 0 ; int start = 0 ; int end = N - 1 ; int prev = - 1 ; while ( start <= end ) { if ( A [ start ] <= A [ end ] ) { if ( prev == - 1 ) { prev = A [ start ] ; res ++ ; start ++ ; } else { if ( A [ start ] >= prev ) { res ++ ; prev = A [ start ] ; start ++ ; } else if ( A [ end ] >= prev ) { res ++ ; prev = A [ end ] ; end -- ; } else { break ; } } } else { if ( prev == - 1 ) { prev = A [ end ] ; res ++ ; end -- ; } else { if ( A [ end ] >= prev ) { res ++ ; prev = A [ end ] ; end -- ; } else if ( A [ start ] >= prev ) { res ++ ; prev = A [ start ] ; start ++ ; } else { break ; } } } } return res ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 1 , 3 , 5 , 4 , 3 , 6 , 2 , 1 } ; int N = A . length ; System . out . print ( findLongestNonDecreasing ( A , N ) ) ; } }

Index/key variables: end, start
Accumulator variables: end, res, start
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static void findPairs ( int N ) { for ( int i = 0 ; i <= N ; i ++ ) { System . out . print ( " ( " + i + " , ▁ " + ( N - i ) + " ) , ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 5 ; findPairs ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class solution { static int GCD ( int a , int b ) { if ( b == 0 ) return a ; return GCD ( b , a % b ) ; } static int findPartition ( int nums [ ] , int N ) { int [ ] prefix = new int [ N ] ; int [ ] suffix = new int [ N ] ; int i , k ; prefix [ 0 ] = nums [ 0 ] ; for ( i = 1 ; i < N ; i ++ ) { prefix [ i ] = prefix [ i - 1 ] * nums [ i ] ; } suffix [ N - 1 ] = nums [ N - 1 ] ; for ( i = N - 2 ; i >= 0 ; i -- ) { suffix [ i ] = suffix [ i + 1 ] * nums [ i ] ; } for ( k = 0 ; k < N - 1 ; k ++ ) { if ( GCD ( prefix [ k ] , suffix [ k + 1 ] ) == 1 ) { return k ; } } return - 1 ; } public static void main ( String args [ ] ) { int arr [ ] = { 2 , 3 , 4 , 5 } ; int N = arr . length ; System . out . println ( findPartition ( arr , N ) ) ; } }

Index/key variables: N, i, k
Accumulator variables: i, k
Iterator variables: i, k
Class/struct names: solution
Java program:
import java . util . * ; class GFG { static int separate ( int arr [ ] , int n , int parity ) { int count = 1 , res = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( ( ( arr [ i ] + parity ) & 1 ) != 0 && ( ( arr [ i - 1 ] + parity ) & 1 ) != 0 ) count ++ ; else { if ( count > 1 ) res += count - 1 ; count = 1 ; } } return res ; } void printArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . println ( arr [ i ] + " ▁ " ) ; } static void requiredOps ( int arr [ ] , int N ) { int res1 = separate ( arr , N , 0 ) ; int res2 = separate ( arr , N , 1 ) ; System . out . print ( Math . max ( res1 , res2 ) ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 13 , 2 , 6 , 8 , 3 , 5 , 7 , 10 , 14 , 15 } ; int N = arr . length ; requiredOps ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count, i, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static boolean [ ] SieveOfEratosthenes ( int N ) { boolean [ ] isPrime = new boolean [ N + 1 ] ; Arrays . fill ( isPrime , true ) ; isPrime [ 0 ] = false ; isPrime [ 1 ] = false ; for ( int p = 2 ; p * p <= N ; p ++ ) { if ( isPrime [ p ] ) { for ( int i = p * p ; i <= N ; i += p ) { isPrime [ i ] = false ; } } } return isPrime ; } public static int cntPairsdiffOfPrimeisPrime ( int N ) { int cntPairs = 0 ; boolean [ ] isPrime = SieveOfEratosthenes ( N ) ; for ( int i = 2 ; i <= N ; i ++ ) { if ( isPrime [ i ] && isPrime [ i - 2 ] ) { cntPairs += 2 ; } } return cntPairs ; } public static void main ( String args [ ] ) { int N = 5 ; System . out . println ( cntPairsdiffOfPrimeisPrime ( N ) ) ; } }

Index/key variables: i, p
Accumulator variables: cntPairs, i, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void longestSubsequence ( int arr [ ] , int N ) { int count = 1 ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] != arr [ i - 1 ] ) { count ++ ; } } System . out . println ( count ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 7 , 8 , 1 , 2 , 2 , 5 , 5 , 1 } ; int N = arr . length ; longestSubsequence ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int substringCount ( String s ) { int [ ] freq = new int [ 26 ] ; char max_char = ' # ' ; int maxfreq = Integer . MIN_VALUE ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { freq [ s . charAt ( i ) - ' a ' ] ++ ; if ( maxfreq < freq [ s . charAt ( i ) - ' a ' ] ) maxfreq = freq [ s . charAt ( i ) - ' a ' ] ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( maxfreq == freq [ i ] ) { max_char = ( char ) ( i + ' a ' ) ; break ; } } int ans = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char ch = s . charAt ( i ) ; if ( max_char == ch ) { ans += ( s . length ( ) - i ) ; } } return ans ; } public static void main ( String [ ] args ) { String S = " abcab " ; System . out . println ( substringCount ( 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 minSum ( int [ ] arr , int n ) { int [ ] ans = new int [ n ] ; Arrays . fill ( ans , 1 ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > arr [ i - 1 ] ) { ans [ i ] = Math . max ( ans [ i ] , ans [ i - 1 ] + 1 ) ; } } for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] > arr [ i + 1 ] ) { ans [ i ] = Math . max ( ans [ i ] , ans [ i + 1 ] + 1 ) ; } } int s = 0 ; for ( int x : ans ) { s = s + x ; } System . out . print ( s + "NEW_LINE"); } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 2 } ; int N = arr . length ; minSum ( arr , N ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i, x
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void minSteps ( String S ) { String new_str = " " ; int N = S . length ( ) ; int i = 0 ; while ( i < N ) { new_str += S . charAt ( i ) ; int j = i ; while ( i < N && S . charAt ( i ) == S . charAt ( j ) ) ++ i ; } System . out . print ( ( int ) Math . ceil ( ( new_str . length ( ) + 1 ) / 2.0 ) ) ; } public static void main ( String [ ] args ) { String S = "0010100" ; minSteps ( S ) ; } }

Accumulator variables: new_str
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int countPairs ( int [ ] arr , int N ) { int cntPairs = 0 ; HashMap < Integer , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { mp . put ( arr [ i ] , mp . getOrDefault ( arr [ i ] , 0 ) + 1 ) ; } for ( Map . Entry < Integer , Integer > freq : mp . entrySet ( ) ) { cntPairs += ( freq . getValue ( ) * ( freq . getValue ( ) - 1 ) ) / 2 ; } return cntPairs ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 1 , 2 , 2 } ; int N = arr . length ; System . out . println ( countPairs ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: cntPairs, 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 palindromeMatrix ( int N , int M , int [ ] [ ] arr ) { int ans = 0 ; for ( int i = 0 ; i < ( N + 1 ) / 2 ; i ++ ) { for ( int j = 0 ; j < ( M + 1 ) / 2 ; j ++ ) { HashSet < pair > s = new HashSet < > ( ) ; s . add ( new pair ( i , j ) ) ; s . add ( new pair ( i , M - j - 1 ) ) ; s . add ( new pair ( N - i - 1 , j ) ) ; s . add ( new pair ( N - i - 1 , M - j - 1 ) ) ; Vector < Integer > values = new Vector < > ( ) ; for ( pair p : s ) { values . add ( arr [ p . first ] [ p . second ] ) ; } int max = Collections . max ( values ) ; for ( int k = 1 ; k < values . size ( ) ; k ++ ) { ans += max - values . get ( k ) ; } } } System . out . print ( ans ) ; } public static void main ( String [ ] args ) { int N = 3 , M = 3 ; int [ ] [ ] arr = { { 1 , 2 , 1 } , { 3 , 4 , 1 } , { 1 , 2 , 1 } } ; palindromeMatrix ( N , M , arr ) ; } }

Accumulator variables: ans, i, j, k
Iterator variables: i, j, k, p
Class/struct names: GFG, pair
Java program:
import java . util . * ; class GFG { static int minimumMoves ( int n ) { int cnt2 = 0 , cnt5 = 0 ; while ( n % 2 == 0 ) { n /= 2 ; cnt2 ++ ; } while ( n % 5 == 0 ) { n /= 5 ; cnt5 ++ ; } if ( n == 1 && cnt2 <= cnt5 ) { return 2 * cnt5 - cnt2 ; } else return - 1 ; } public static void main ( String [ ] args ) { int N = 25 ; System . out . print ( minimumMoves ( N ) ) ; } }

Accumulator variables: cnt2, cnt5, n
Class/struct names: GFG
Java program:
import java . util . * ; class solution { static void check ( int n ) { if ( ( n & n - 1 ) != 0 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } public static void main ( String args [ ] ) { int n = 5 ; check ( n ) ; } }

Class/struct names: solution
Java program:
class GFG { public static int MinOperation ( int arr [ ] , int N , int K ) { int cntOpe = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( K > arr [ i ] ) { if ( ( K - arr [ i ] ) % 2 == 0 ) { cntOpe += 2 ; } else { cntOpe += 1 ; } } else if ( K < arr [ i ] ) { if ( ( K - arr [ i ] ) % 2 == 0 ) { cntOpe += 1 ; } else { cntOpe += 2 ; } } } return cntOpe ; } public static void main ( String [ ] args ) { int arr [ ] = { 8 , 7 , 2 , 1 , 3 } ; int K = 5 ; int N = arr . length ; System . out . println ( MinOperation ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: cntOpe, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static ArrayList < Integer > rearrangeArray ( ArrayList < Integer > A , ArrayList < Integer > B , int N ) { HashMap < Integer , Integer > m = new HashMap < Integer , Integer > ( ) ; int xor_value = 0 ; for ( int i = 0 ; i < N ; i ++ ) { xor_value ^= A . get ( i ) ; xor_value ^= B . get ( i ) ; m . put ( B . get ( i ) , m . getOrDefault ( B . get ( i ) + 1 , 0 ) ) ; } for ( int i = 0 ; i < N ; i ++ ) { B . set ( i , A . get ( i ) ^ xor_value ) ; if ( m . getOrDefault ( B . get ( i ) , - 1 ) != - 1 ) { m . put ( B . get ( i ) , m . getOrDefault ( B . get ( i ) , 0 ) - 1 ) ; } else return ( new ArrayList < Integer > ( ) ) ; } return B ; } static void rearrangeArrayUtil ( ArrayList < Integer > A , ArrayList < Integer > B , int N ) { ArrayList < Integer > ans = rearrangeArray ( A , B , N ) ; if ( ans . size ( ) != 0 ) { for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { System . out . print ( ans . get ( i ) + " ▁ " ) ; } } else { System . out . println ( " - 1" ) ; } } public static void main ( String [ ] args ) { ArrayList < Integer > A = new ArrayList < Integer > ( Arrays . asList ( 13 , 21 , 33 , 49 , 53 ) ) ; ArrayList < Integer > B = new ArrayList < Integer > ( Arrays . asList ( 54 , 50 , 34 , 22 , 14 ) ) ; int N = ( int ) A . size ( ) ; rearrangeArrayUtil ( A , B , N ) ; } }

Accumulator variables: i, xor_value
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static long binCoff ( long n , long r ) { long val = 1 ; int i ; if ( r > ( n - r ) ) r = ( n - r ) ; for ( i = 0 ; i < r ; i ++ ) { val *= ( n - i ) ; val /= ( i + 1 ) ; } return val ; } static void findWays ( int M ) { int n = M / 2 ; long a , b , ans ; a = binCoff ( 2 * n , n ) ; b = a / ( n + 1 ) ; System . out . print ( b ) ; } public static void main ( String [ ] args ) { int M = 4 , X = 5 ; findWays ( M ) ; } }

Accumulator variables: i, val
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static void countInverse ( int [ ] arr , int N , int M ) { int XOR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int gcdOfMandelement = gcd ( M , arr [ i ] ) ; if ( gcdOfMandelement == 1 ) { XOR ^= arr [ i ] ; } } System . out . println ( XOR ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 } ; int M = 4 ; int N = arr . length ; countInverse ( arr , N , M ) ; } }

Index/key variables: i
Accumulator variables: XOR, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int Moves_Calculator ( int x , int y , int row , int col ) { int total_moves = 0 ; if ( ( row - x ) > 0 && ( col - y ) > 0 ) total_moves += Math . min ( ( row - x ) , ( col - y ) ) ; if ( ( y - 1 ) > 0 && ( x - 1 ) > 0 ) total_moves += Math . min ( ( y - 1 ) , ( x - 1 ) ) ; if ( ( x - 1 ) > 0 && ( col - y ) > 0 ) total_moves += Math . min ( ( x - 1 ) , ( col - y ) ) ; if ( ( row - x ) > 0 && ( y - 1 ) > 0 ) total_moves += Math . min ( ( row - x ) , ( y - 1 ) ) ; total_moves += ( row - 1 ) + ( col - 1 ) ; int king_moves = 0 ; if ( x + 1 <= row ) king_moves += 1 ; if ( x - 1 > 0 ) king_moves += 1 ; if ( y + 1 <= col ) king_moves += 1 ; if ( y - 1 > 0 ) king_moves += 1 ; if ( x + 1 <= row && y + 1 <= col ) king_moves += 1 ; if ( x + 1 <= row && y - 1 > 0 ) king_moves += 1 ; if ( x - 1 > 0 && y - 1 > 0 ) king_moves += 1 ; if ( x - 1 > 0 && y + 1 <= col ) king_moves += 1 ; return total_moves - king_moves ; } public static void main ( String [ ] args ) { int n = 8 , m = 8 ; int x = 1 , y = 1 ; System . out . println ( Moves_Calculator ( x , y , m , n ) ) ; } }

Accumulator variables: king_moves, total_moves
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int clstNum ( int N ) { return ( N - 1 ) ; } public static void main ( String [ ] args ) { int N = 11 ; System . out . println ( clstNum ( N ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int equvInverse ( int [ ] arr , int N , int P ) { int cntElem = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] * arr [ i ] ) % P == 1 ) { cntElem ++ ; } } return cntElem ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 6 , 4 , 5 } ; int N = arr . length ; int P = 7 ; System . out . println ( equvInverse ( arr , N , P ) ) ; } }

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