dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static Vector < Integer > solve ( int start , int end ) { String num = " " ; Vector < Integer > ans = new Vector < > ( ) ; for ( int i = 1 ; i <= 9 ; i ++ ) { num = Integer . toString ( i ) ; int value = i ; if ( value >= start && value <= end ) { ans . add ( value ) ; } for ( int j = i + 1 ; j <= 9 ; j ++ ) { num += Integer . toString ( j ) ; value = Integer . valueOf ( num ) ; if ( value >= start && value <= end ) { ans . add ( value ) ; } } } Collections . sort ( ans ) ; ; return ans ; } public static void main ( String [ ] args ) { int L = 12 , R = 87 ; Vector < Integer > ans = solve ( L , R ) ; for ( int it : ans ) System . out . print ( it + " ▁ " ) ; } }

Accumulator variables: i, j, num
Iterator variables: i, it, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int minDistance ( int start [ ] , int end [ ] , int n , int d ) { int left = Integer . MIN_VALUE ; int right = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { left = Math . max ( left , start [ i ] ) ; right = Math . min ( right , end [ i ] ) ; } if ( left > right ) return - 1 ; if ( d >= left && d <= right ) return 0 ; if ( d < left ) return ( left - d ) ; if ( d > right ) return ( d - right ) ; return - 1 ; } public static void main ( String [ ] args ) { int start [ ] = { 0 , 2 , 4 } ; int end [ ] = { 7 , 14 , 6 } ; int n = start . length ; int d = 3 ; System . out . println ( minDistance ( start , end , n , d ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int power ( int x , int y ) { if ( y == 0 ) return 1 ; if ( y % 2 == 0 ) return power ( x , y / 2 ) * power ( x , y / 2 ) ; return x * power ( x , y / 2 ) * power ( x , y / 2 ) ; } static int order ( int num ) { int count = 0 ; while ( num > 0 ) { count ++ ; num = num / 10 ; } return count ; } static int isArmstrong ( int N ) { int r = order ( N ) ; int temp = N , sum = 0 ; while ( temp > 0 ) { int d = temp % 10 ; sum += power ( d , r ) ; temp = temp / 10 ; } if ( sum == N ) return 1 ; return 0 ; } static int maxSum ( int [ ] arr , int N , int K ) { if ( N < K ) { return - 1 ; } int res = 0 ; for ( int i = 0 ; i < K ; i ++ ) { res += arr [ i ] ; } int curr_sum = res ; for ( int i = K ; i < N ; i ++ ) { curr_sum += arr [ i ] - arr [ i - K ] ; res = Math . max ( res , curr_sum ) ; } return res ; } static int maxArmstrong ( int [ ] arr , int N , int K ) { for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = isArmstrong ( arr [ i ] ) ; } return maxSum ( arr , N , K ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 28 , 2 , 3 , 6 , 153 , 99 , 828 , 24 } ; int K = 6 ; int N = arr . length ; System . out . println ( maxArmstrong ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: count, curr_sum, i, res, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; 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 ; x = ( x * x ) % p ; } return res ; } static int countArrays ( int n , int k ) { int mod = 1000000007 ; int ans = power ( n , k , mod ) ; return ans ; } public static void main ( String [ ] args ) { int n = 3 , k = 5 ; int ans = countArrays ( n , k ) ; System . out . println ( ans ) ; } }

Class/struct names: GFG
Java program:
import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; class GFG { static int fact ( int n ) { int res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { res = res * i ; } return res ; } static int nCr ( int n , int r ) { return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } static void countWays ( String s , String t ) { int n = s . length ( ) ; int sum1 = 0 , sum2 = 0 , K = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '1' ) { sum1 ++ ; } else sum1 -- ; } int m = t . length ( ) ; for ( int i = 0 ; i < m ; i ++ ) { if ( t . charAt ( i ) == '1' ) { sum2 ++ ; } else if ( t . charAt ( i ) == '0' ) { sum2 -- ; } else K ++ ; } int P = Math . abs ( sum1 - sum2 ) ; if ( ( P > K ) || ( K - P ) % 2 == 1 ) { System . out . println ( 0 ) ; return ; } System . out . println ( nCr ( K , ( P + K ) / 2 ) ) ; } public static void main ( String [ ] args ) { String S1 = "1010" ; String S2 = "10 ? ? " ; countWays ( S1 , S2 ) ; } }

Accumulator variables: K, i, sum1, sum2
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static void countPairs ( int arr [ ] , int N ) { int answer = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( arr [ i ] + arr [ j ] == i + j ) { answer ++ ; } } } System . out . println ( answer ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 0 , 1 , 2 , 3 , 4 , 5 } ; int N = arr . length ; countPairs ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: answer, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void checkDistribution ( int R , int B , int D ) { if ( Math . max ( R , B ) <= Math . min ( R , B ) * ( D + 1 ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void main ( String [ ] args ) { int R = 1 , B = 1 , D = 0 ; checkDistribution ( R , B , D ) ; } }

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 Vector < pair > primeFactor ( int N ) { Vector < pair > v = new Vector < > ( ) ; int count = 0 ; while ( ( N % 2 ) == 0 ) { N >>= 1 ; count ++ ; } if ( count != 0 ) v . add ( new pair ( 2 , count ) ) ; for ( int i = 3 ; i <= Math . sqrt ( N ) ; i += 2 ) { count = 0 ; while ( N % i == 0 ) { count ++ ; N = N / i ; } if ( count != 0 ) { v . add ( new pair ( i , count ) ) ; } } if ( N > 2 ) v . add ( new pair ( N , 1 ) ) ; return v ; } static void printAnswer ( int n ) { Vector < pair > v = primeFactor ( n ) ; int maxi_size = 0 , prime_factor = 0 ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( maxi_size < v . get ( i ) . second ) { maxi_size = v . get ( i ) . second ; prime_factor = v . get ( i ) . first ; } } if ( maxi_size < 2 ) { System . out . print ( 1 << ' ▁ ' ) ; } else { int product = 1 ; System . out . print ( maxi_size + "NEW_LINE"); for ( int i = 0 ; i < maxi_size - 1 ; i ++ ) { System . out . print ( prime_factor + " ▁ " ) ; product *= prime_factor ; } System . out . print ( ( n / product ) ) ; } } public static void main ( String [ ] args ) { int N = 360 ; printAnswer ( N ) ; } }

Accumulator variables: count, i, product
Iterator variables: i
Class/struct names: GFG, pair
Java program:
import java . lang . * ; import java . util . * ; class GFG { static void IsEvenPath ( int Source [ ] , int Destination [ ] ) { int x_dif = Math . abs ( Source [ 0 ] - Destination [ 0 ] ) ; int y_dif = Math . abs ( Source [ 1 ] - Destination [ 1 ] ) ; int minsteps = x_dif + y_dif ; if ( minsteps % 2 == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { int Source [ ] = { 2 , 1 } ; int Destination [ ] = { 1 , 4 } ; IsEvenPath ( Source , Destination ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static long ABS ( long x ) { return Math . max ( x , - x ) ; } static void findFraction ( long x , long y , long n ) { long A = - 1 , B = - 1 ; for ( long i = 1 ; i <= n ; i ++ ) { long d = ( i * x ) / y ; if ( d >= 0 && ( A == - 1 || ABS ( B * x - y * A ) * ABS ( i * y ) > ABS ( i * x - y * d ) * ABS ( B * y ) ) ) A = d ; B = i ; d ++ ; if ( d >= 0 && ( A == - 1 || ABS ( B * x - y * A ) * ABS ( i * y ) > ABS ( i * x - y * d ) * ABS ( B * y ) ) ) A = d ; B = i ; } A -- ; B -- ; System . out . println ( A + " / " + B ) ; } public static void main ( String [ ] args ) { long x = 3 ; long y = 7 ; long n = 6 ; findFraction ( x , y , n ) ; } }

Accumulator variables: A, B, d, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static String BaseConversion ( int N ) { String s = " " ; while ( N != 0 ) { if ( N % 2 == 0 ) { s = "0" + s ; } else { s = "1" + s ; N -- ; } N /= - 2 ; } if ( s == " " ) { s = "0" ; } return s ; } public static void main ( String args [ ] ) { int N = - 9 ; System . out . println ( BaseConversion ( N ) ) ; } }

Accumulator variables: N
Class/struct names: GFG
Java program:
class GFG { public static void finalInstances ( int instances , int [ ] arr ) { int i = 0 ; while ( i < arr . length ) { if ( arr [ i ] < 25 && instances > 1 ) { instances = ( instances / 2 ) ; i = i + 10 ; } else if ( arr [ i ] > 60 && instances <= Math . pow ( 10 , 8 ) ) { instances = instances * 2 ; i = i + 10 ; } i = i + 1 ; } System . out . println ( instances ) ; } public static void main ( String args [ ] ) { int instances = 2 ; int [ ] arr = { 25 , 23 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 76 , 80 } ; finalInstances ( instances , arr ) ; } }

Index/key variables: i
Class/struct names: GFG
Java program:
import java . util . ArrayList ; import java . util . HashMap ; class GFG { static String isMakeZero ( int arr [ ] , int N , int K ) { HashMap < Integer , Integer > MP = new HashMap < Integer , Integer > ( ) ; ArrayList < Integer > V = new ArrayList < Integer > ( ) ; int X = 1 ; int i ; while ( X > 0 && X < Integer . MAX_VALUE ) { V . add ( X ) ; X *= K ; } for ( i = 0 ; i < N ; i ++ ) { for ( int j = V . size ( ) - 1 ; j >= 0 ; j -- ) { if ( MP . containsKey ( V . get ( j ) ) == false && V . get ( j ) <= arr [ i ] ) { arr [ i ] -= V . get ( j ) ; MP . put ( V . get ( j ) , 1 ) ; } } if ( arr [ i ] != 0 ) break ; } if ( i < N ) return " No " ; else return " Yes " ; } public static void main ( String [ ] args ) { int arr [ ] = { 8 , 0 , 3 , 4 , 80 } ; int N = arr . length ; int K = 2 ; System . out . println ( isMakeZero ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: X, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static String perfectSquare ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int p = ( int ) Math . sqrt ( arr [ i ] ) ; if ( p * p != arr [ i ] ) { return " No " ; } } return " Yes " ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 4 , 100 } ; int N = arr . length ; System . out . println ( perfectSquare ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countKAverageSubarrays ( int arr [ ] , int n , int k ) { int res = 0 ; for ( int L = 0 ; L < n ; L ++ ) { int sum = 0 ; for ( int R = L ; R < n ; R ++ ) { sum += arr [ R ] ; int len = ( R - L + 1 ) ; if ( sum % len == 0 ) { int avg = sum / len ; if ( avg == k ) res ++ ; } } } return res ; } public static void main ( String [ ] args ) { int K = 6 ; int arr [ ] = { 12 , 5 , 3 , 10 , 4 , 8 , 10 , 12 , - 6 , - 1 } ; int N = arr . length ; System . out . print ( countKAverageSubarrays ( arr , N , K ) ) ; } }

Index/key variables: R
Accumulator variables: L, R, res, sum
Iterator variables: L, R
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int minimumElement ( int arr [ ] , int N , int K ) { int minElement = arr [ 0 ] ; for ( int i = 0 ; i < N ; ++ i ) { minElement = Math . min ( minElement , arr [ i ] ) ; } int reqOperations = 0 ; for ( int i = 0 ; i < N ; ++ i ) { reqOperations += arr [ i ] - minElement ; } if ( reqOperations < K ) { K -= reqOperations ; minElement -= ( K + N - 1 ) / N ; } return minElement ; } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 10 , 10 , 10 } ; int K = 7 ; int N = arr . length ; System . out . println ( minimumElement ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: K, minElement, reqOperations
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Vector ; public class GFG { static Vector < String > FractionSplit ( long n , long d ) { Vector < String > UnitFactions = new Vector < > ( ) ; while ( n > 0 ) { long x = ( d + n - 1 ) / n ; String s = "1 / " + String . valueOf ( x ) ; UnitFactions . add ( s ) ; n = n * x - d ; d = d * x ; } return UnitFactions ; } public static void main ( String [ ] args ) { long n = 13 , d = 18 ; Vector < String > res = FractionSplit ( n , d ) ; for ( String s : res ) System . out . print ( s + " , ▁ " ) ; } }

Iterator variables: s
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findPermutation ( int N ) { int [ ] arr = new int [ N ] ; int temp ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = i + 1 ; } for ( int i = 1 ; i < N ; i += 2 ) { temp = arr [ i ] ; arr [ i ] = arr [ i - 1 ] ; arr [ i - 1 ] = temp ; } if ( N % 2 == 1 && N > 1 ) { temp = arr [ N - 1 ] ; arr [ N - 1 ] = arr [ N - 2 ] ; arr [ N - 2 ] = temp ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 7 ; findPermutation ( N ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static void addAP ( int A [ ] , int Q , int [ ] [ ] operations ) { for ( int j = 0 ; j < 2 ; ++ j ) { int L = operations [ j ] [ 0 ] , R = operations [ j ] [ 1 ] , a = operations [ j ] [ 2 ] , d = operations [ j ] [ 3 ] ; int curr = a ; for ( int i = L - 1 ; i < R ; i ++ ) { A [ i ] += curr ; curr += d ; } } for ( int i = 0 ; i < 4 ; ++ i ) System . out . print ( A [ i ] + " ▁ " ) ; } public static void main ( String args [ ] ) { int A [ ] = { 5 , 4 , 2 , 8 } ; int Q = 2 ; int query [ ] [ ] = { { 1 , 2 , 1 , 3 } , { 1 , 4 , 4 , 1 } } ; addAP ( A , Q , query ) ; } }

Index/key variables: i, j
Accumulator variables: curr, i
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { public static void maximizeNumber ( int N , int K ) { String s = Integer . toString ( N ) ; int L = s . length ( ) ; String result = " " ; int i = 0 ; while ( ( i < L ) && ( K <= ( ( int ) s . charAt ( i ) - ( int ) '0' ) ) ) { result += ( s . charAt ( i ) ) ; ++ i ; } result += ( ( char ) ( K + ( int ) '0' ) ) ; while ( i < L ) { result += ( s . charAt ( i ) ) ; ++ i ; } System . out . println ( result ) ; } public static void main ( String args [ ] ) { int N = 6673 , K = 6 ; maximizeNumber ( N , K ) ; } }

Accumulator variables: result
Class/struct names: GFG
Java program:
public class GFG { static int power ( int x , int y ) { int res = 1 ; while ( y > 0 ) { if ( y % 2 != 0 ) res = res * x ; y = y >> 1 ; x = x * x ; } return res ; } static void countArrays ( int N , int K ) { System . out . println ( ( int ) ( power ( N , K ) ) ) ; } public static void main ( String args [ ] ) { int N = 5 , K = 6 ; countArrays ( N , K ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static void minimumDistance ( int arr [ ] , int N ) { int ind = 0 ; int prev = arr [ ind ] ; int s = arr . length ; for ( int i = 0 ; i < N ; i ++ ) { int distance = Integer . MAX_VALUE ; if ( i < arr [ 0 ] ) { distance = arr [ 0 ] - i ; } else if ( i >= prev && ind + 1 < s && i <= arr [ ind + 1 ] ) { distance = Math . min ( i - prev , arr [ ind + 1 ] - i ) ; if ( i == arr [ ind + 1 ] ) { distance = 0 ; prev = arr [ ind + 1 ] ; ind ++ ; } } else { distance = i - prev ; } System . out . print ( distance + " ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 5 ; int arr [ ] = { 0 , 4 } ; minimumDistance ( arr , N ) ; } }

Index/key variables: ind
Accumulator variables: i, ind
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static int countOfPairs ( int arr [ ] , int N , int X ) { int count = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( ( ( arr [ i ] ^ arr [ j ] ) & X ) == 0 ) count ++ ; } } return count ; } public static void main ( String args [ ] ) { int arr [ ] = { 3 , 2 , 5 , 4 , 6 , 7 } ; int X = 6 ; int N = arr . length ; System . out . println ( countOfPairs ( arr , N , X ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countOfPairs ( int [ ] arr , int N , int X ) { int count = 0 ; HashMap < Integer , Integer > M = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( M . containsKey ( arr [ i ] & X ) ) M . put ( ( arr [ i ] & X ) , M . get ( arr [ i ] & X ) + 1 ) ; else M . put ( arr [ i ] & X , 1 ) ; } for ( Integer entry : M . keySet ( ) ) { int p = M . get ( entry ) ; count += p * ( p - 1 ) / 2 ; } return count ; } public static void main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 5 , 4 , 6 , 7 } ; int X = 6 ; int N = arr . length ; System . out . print ( countOfPairs ( arr , N , X ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: entry, i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MAX = 1000 ; static int cntMatrices ( int [ ] [ ] arr , int N , int M , int K ) { int cnt = 0 ; int [ ] [ ] pre = new int [ N + 1 ] [ M + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= M ; j ++ ) { pre [ i ] [ j ] = arr [ i - 1 ] [ j - 1 ] + pre [ i - 1 ] [ j ] + pre [ i ] [ j - 1 ] - pre [ i - 1 ] [ j - 1 ] ; } } for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= M ; j ++ ) { for ( int l = i , r = j ; l > 0 && r > 0 ; l -- , r -- ) { int sum1 = ( K * ( i - l + 1 ) * ( i - r + 1 ) ) ; int sum2 = pre [ i ] [ j ] - pre [ l - 1 ] [ r ] - pre [ l ] [ r - 1 ] + pre [ l - 1 ] [ r - 1 ] ; if ( sum1 <= sum2 ) cnt ++ ; } } } return cnt ; } public static void main ( String args [ ] ) { int [ ] [ ] arr = { { 2 , 2 , 3 } , { 3 , 4 , 5 } , { 4 , 5 , 5 } } ; int K = 4 ; int N = arr . length ; int M = arr [ 0 ] . length ; System . out . println ( cntMatrices ( arr , N , M , K ) ) ; } }

Index/key variables: i, j, l, r
Accumulator variables: cnt, i, j, l, r
Iterator variables: i, j, l
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int ConcatenateArr ( int [ ] arr , int N ) { int ans = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { int l = ( int ) Math . floor ( Math . log10 ( arr [ i ] ) + 1 ) ; ans = ans * ( int ) Math . pow ( 10 , l ) ; ans += arr [ i ] ; } return ans ; } public static void main ( String args [ ] ) { int arr [ ] = { 1 , 23 , 456 } ; int N = arr . length ; System . out . println ( ConcatenateArr ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countXor ( int N ) { int cnt = ( int ) N / 2 + 1 ; return cnt ; } public static void main ( String [ ] args ) { int N = 4 ; System . out . println ( countXor ( N ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int DistRecursion ( String S , int i , int dist ) { char [ ] ch = S . toCharArray ( ) ; if ( i == ch . length ) return Math . abs ( dist ) ; if ( ch [ i ] == ' L ' ) return DistRecursion ( S , i + 1 , dist - 1 ) ; if ( ch [ i ] == ' R ' ) return DistRecursion ( S , i + 1 , dist + 1 ) ; return Math . max ( DistRecursion ( S , i + 1 , dist - 1 ) , DistRecursion ( S , i + 1 , dist + 1 ) ) ; } static int maxDistance ( String S ) { return DistRecursion ( S , 0 , 0 ) ; } public static void main ( String [ ] args ) { String S = " ? RRR ? " ; System . out . print ( maxDistance ( S ) ) ; } }

Index/key variables: i
Class/struct names: GFG
Java program:
import java . awt . * ; import java . util . * ; class GFG { static class pair < T , V > { T first ; V second ; } static void findPairs ( int p , int q , int r ) { ArrayList < Integer > v = new ArrayList < > ( ) ; for ( int i = p ; i <= q ; i ++ ) { if ( i % r == 0 ) { v . add ( i ) ; } } ArrayList < pair < Integer , Integer > > ans = new ArrayList < > ( ) ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { for ( int j = i + 1 ; j < v . size ( ) ; j ++ ) { if ( v . get ( i ) * v . get ( j ) >= p * q / 4 && v . get ( i ) * v . get ( j ) <= p * q ) { pair < Integer , Integer > x = new pair < > ( ) ; x . first = v . get ( i ) ; x . second = v . get ( j ) ; ans . add ( x ) ; } } } if ( ans . size ( ) == 0 ) { System . out . println ( - 1 ) ; } else { for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { System . out . println ( ans . get ( i ) . first + " ▁ " + ans . get ( i ) . second ) ; } } } public static void main ( String [ ] args ) { int p = 14 , q = 30 , r = 5 ; findPairs ( p , q , r ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, pair
Java program:
import java . io . * ; class GFG { static void printRectPattern ( int c1 , int c2 , int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( ( Math . max ( Math . abs ( c1 - i ) , Math . abs ( c2 - j ) ) ) + " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int c1 = 2 ; int c2 = 2 ; int n = 5 ; printRectPattern ( c1 , c2 , n ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countNumbers ( int l , int r ) { int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { if ( ( i & 1 ) == 0 ) count += 1 ; } return count ; } public static void main ( String [ ] args ) { int l = 10 , r = 20 ; System . out . println ( countNumbers ( l , r ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int countNumbers ( int l , int r ) { return ( ( r / 2 ) - ( l - 1 ) / 2 ) ; } public static void main ( String [ ] args ) { int l = 10 ; int r = 20 ; System . out . println ( countNumbers ( l , r ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static boolean isPerfectSquare ( int x ) { int s = ( int ) Math . sqrt ( x ) ; return ( s * s == x ) ; } public static boolean isFibonacci ( int n ) { return isPerfectSquare ( 5 * n * n + 4 ) || isPerfectSquare ( 5 * n * n - 4 ) ; } public static int contiguousFibonacciNumber ( int arr [ ] , int n ) { int current_length = 0 ; int max_length = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isFibonacci ( arr [ i ] ) ) { current_length ++ ; } else { current_length = 0 ; } max_length = Math . max ( max_length , current_length ) ; } return max_length ; } public static void main ( String [ ] args ) { int arr [ ] = { 11 , 8 , 21 , 5 , 3 , 28 , 4 } ; int n = arr . length ; System . out . println ( contiguousFibonacciNumber ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: current_length, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int [ ] [ ] direction = { { - 1 , 0 } , { 0 , 1 } , { 0 , - 1 } , { 1 , 0 } } ; static boolean dfs ( int matrix [ ] [ ] , int i , int j , int N , int M ) { if ( i == N - 1 && j == M - 1 ) { return true ; } matrix [ i ] [ j ] = 1 ; for ( int k = 0 ; k < 4 ; k ++ ) { int newX = i + direction [ k ] [ 0 ] ; int newY = j + direction [ k ] [ 1 ] ; if ( newX >= 0 && newX < N && newY >= 0 && newY < M && matrix [ newX ] [ newY ] == 0 ) { if ( dfs ( matrix , newX , newY , N , M ) ) { return true ; } } } return false ; } static int solve ( int [ ] [ ] matrix ) { int N = matrix . length ; int M = matrix [ 0 ] . length ; if ( ! dfs ( matrix , 0 , 0 , N , M ) ) { return 0 ; } if ( ! dfs ( matrix , 0 , 0 , N , M ) ) { return 1 ; } return 2 ; } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 0 , 1 , 0 , 0 } , { 0 , 1 , 0 , 0 } , { 0 , 0 , 0 , 0 } } ; System . out . println ( solve ( mat ) ) ; } }

Index/key variables: i, j, k, newX, newY
Accumulator variables: k
Iterator variables: k
Class/struct names: GFG