dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static void countTriplets ( int [ ] arr , int N ) { Vector < Integer > zero_i = new Vector < Integer > ( ) ; Vector < Integer > one_i = new Vector < Integer > ( ) ; HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 0 ) zero_i . add ( i + 1 ) ; else if ( arr [ i ] == 1 ) one_i . add ( i + 1 ) ; else mp . put ( i + 1 , 1 ) ; } int total = zero_i . size ( ) * one_i . size ( ) * mp . size ( ) ; for ( int i = 0 ; i < zero_i . size ( ) ; i ++ ) { for ( int j = 0 ; j < one_i . size ( ) ; j ++ ) { int p = zero_i . get ( i ) ; int q = one_i . get ( j ) ; int r = 2 * p - q ; if ( mp . containsKey ( r ) && mp . get ( r ) > 0 ) total -- ; r = 2 * q - p ; if ( mp . containsKey ( r ) && mp . get ( r ) > 0 ) total -- ; r = ( p + q ) / 2 ; if ( mp . containsKey ( r ) && mp . get ( r ) > 0 && Math . abs ( r - p ) == Math . abs ( r - q ) ) total -- ; } } System . out . print ( total ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 0 , 1 , 2 , 1 } ; int N = arr . length ; countTriplets ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, j, total
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void PrimeFactors ( int N ) { Stack < Integer > st = new Stack < > ( ) ; int i = 2 ; while ( N != 1 ) { if ( N % i == 0 ) { st . push ( i ) ; while ( N % i == 0 ) { N = N / i ; } } i ++ ; } while ( ! st . isEmpty ( ) ) { System . out . println ( st . peek ( ) ) ; st . pop ( ) ; } } public static void main ( String [ ] args ) { int N = 8 ; PrimeFactors ( N ) ; ; } }

Accumulator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int CountSubarray ( int arr [ ] , int n , int k ) { int temp = k , count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == temp ) { if ( temp == 1 ) { count ++ ; temp = k ; } else temp -- ; } else { temp = k ; if ( arr [ i ] == k ) i -- ; } } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 7 , 9 , 3 , 2 , 1 , 8 , 3 , 2 , 1 } ; int N = arr . length ; int K = 3 ; System . out . println ( CountSubarray ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, temp
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int LCM ( int A , int B ) { return ( A * B / __gcd ( A , B ) ) ; } static void findSmallestNumber ( int X ) { int lcm = 1 ; int temp = X ; while ( temp > 0 ) { int last = temp % 10 ; temp /= 10 ; if ( last == 0 ) continue ; lcm = LCM ( lcm , last ) ; } int answer = ( ( X + lcm - 1 ) / lcm ) * lcm ; System . out . print ( answer ) ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int X = 280 ; findSmallestNumber ( X ) ; } }

Accumulator variables: temp
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void minSum ( int N ) { long low = 0 , high = 1000000000 ; while ( low + 1 < high ) { long mid = low + ( high - low ) / 2 ; if ( mid * mid >= N ) { high = mid ; } else { low = mid ; } } long first = high ; low = 0 ; high = 1000000000 ; while ( low + 1 < high ) { long mid = low + ( high - low ) / 2 ; if ( first * mid > N ) { high = mid ; } else { low = mid ; } } long second = high ; System . out . println ( first + second ) ; } public static void main ( String [ ] args ) { int N = 10 ; minSum ( N ) ; } }

Class/struct names: GFG
Java program:
import java . lang . * ; class GFG { static void minSum ( int N ) { int ans = ( int ) Math . ceil ( 2 * Math . sqrt ( N + 1 ) ) ; System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int N = 10 ; minSum ( N ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int INF = 1000000 ; static int [ ] pref = new int [ 500005 ] ; static int [ ] suf = new int [ 500005 ] ; static int [ ] MAX = new int [ 500005 ] ; static void build ( int a [ ] , int tl , int tr , int v ) { if ( tl == tr ) { MAX [ v ] = a [ tl ] ; pref [ v ] = a [ tl ] ; suf [ v ] = a [ tl ] ; } else { int tm = ( tl + tr ) / 2 ; build ( a , tl , tm , v * 2 ) ; build ( a , tm + 1 , tr , v * 2 + 1 ) ; MAX [ v ] = Math . max ( MAX [ v * 2 ] , Math . max ( MAX [ v * 2 + 1 ] , suf [ v * 2 ] + pref [ v * 2 + 1 ] ) ) ; pref [ v ] = Math . max ( pref [ v * 2 ] , pref [ 2 * v ] + ( pref [ 2 * v ] == ( tm - tl + 1 ) ? 1 : 0 ) * pref [ v * 2 + 1 ] ) ; suf [ v ] = Math . max ( suf [ v * 2 + 1 ] , suf [ 2 * v + 1 ] + suf [ v * 2 ] * ( suf [ 2 * v + 1 ] == ( tr - tm ) ? 1 : 0 ) ) ; } } static void update ( int a [ ] , int pos , int tl , int tr , int v ) { if ( tl > pos tr < pos ) { return ; } if ( tl == tr && tl == pos ) { MAX [ v ] = a [ pos ] ; pref [ v ] = a [ pos ] ; suf [ v ] = a [ pos ] ; } else { int tm = ( tl + tr ) / 2 ; update ( a , pos , tl , tm , v * 2 ) ; update ( a , pos , tm + 1 , tr , v * 2 + 1 ) ; MAX [ v ] = Math . max ( MAX [ v * 2 ] , Math . max ( MAX [ v * 2 + 1 ] , suf [ v * 2 ] + pref [ v * 2 + 1 ] ) ) ; pref [ v ] = Math . max ( pref [ v * 2 ] , pref [ 2 * v ] + ( pref [ 2 * v ] == ( tm - tl + 1 ) ? 1 : 0 ) * pref [ v * 2 + 1 ] ) ; suf [ v ] = Math . max ( suf [ v * 2 + 1 ] , suf [ 2 * v + 1 ] + ( suf [ 2 * v + 1 ] == ( tr - tm ) ? 1 : 0 ) * suf [ v * 2 ] ) ; } } static void solveQueries ( int arr [ ] , int n , int [ ] [ ] Q , int k ) { int cntQuery = Q . length ; build ( arr , 0 , n - 1 , 1 ) ; for ( int i = 0 ; i < cntQuery ; i ++ ) { if ( Q [ i ] [ 0 ] == 1 ) { System . out . print ( MAX [ 1 ] + " ▁ " ) ; } else { arr [ Q [ i ] [ 1 ] - 1 ] ^= 1 ; update ( arr , Q [ i ] [ 1 ] - 1 , 0 , n - 1 , 1 ) ; } } } public static void main ( String [ ] args ) { int N = 10 ; int arr [ ] = { 1 , 1 , 0 , 1 , 1 , 1 , 0 , 0 , 1 , 1 } ; int [ ] [ ] Q = { { 1 } , { 2 , 3 } , { 1 } } ; int K = 3 ; solveQueries ( arr , N , Q , K ) ; } }

Index/key variables: i, pos, tl, v
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countFreq ( int N , int K ) { int count = 0 ; while ( N > 0 ) { if ( N % 10 == K ) { count ++ ; } N = N / 10 ; } return count ; } static int findElementUtil ( int arr [ ] , int N , int K ) { int c ; int max ; int ele = 0 ; max = 0 ; for ( int i = 0 ; i < N ; i ++ ) { c = countFreq ( arr [ i ] , K ) ; if ( c > max ) { max = c ; ele = arr [ i ] ; } } if ( max == 0 ) return - 1 ; else return ele ; } static void findElement ( int arr [ ] , int N , int K ) { int ele = findElementUtil ( arr , N , K ) ; if ( ele == - 1 ) System . out . print ( " - 1" ) ; else System . out . print ( ele ) ; } public static void main ( String [ ] args ) { int K = 3 ; int arr [ ] = { 3 , 77 , 343 , 456 } ; int N = arr . length ; findElement ( arr , K , 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 findMinDeletions ( int [ ] [ ] v , int n ) { int minDel = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int L = v [ i ] [ 0 ] ; int R = v [ i ] [ 1 ] ; int Count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( v [ j ] [ 0 ] >= L && v [ j ] [ 1 ] <= R ) { Count += 1 ; } } minDel = Math . min ( minDel , n - Count ) ; } return minDel ; } public static void main ( String [ ] args ) { int [ ] [ ] v = { { 1 , 3 } , { 4 , 12 } , { 5 , 8 } , { 13 , 20 } } ; int N = v . length ; System . out . print ( findMinDeletions ( v , N ) ) ; } }

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 maxEvenIntegers ( int arr [ ] , int N , int M ) { int curr = 0 ; for ( int i = 0 ; i < M ; i ++ ) { if ( arr [ i ] % 2 == 0 ) curr ++ ; } int ans = curr ; for ( int i = M ; i < N ; i ++ ) { if ( arr [ i - M ] % 2 == 0 ) { curr -- ; } if ( arr [ i ] % 2 == 0 ) curr ++ ; ans = Math . max ( ans , curr ) ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 5 , 4 , 7 , 6 } ; int M = 3 ; int N = arr . length ; System . out . print ( maxEvenIntegers ( arr , N , M ) + "NEW_LINE"); } }

Index/key variables: i
Accumulator variables: curr, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void countNumbers ( int n , int d ) { int total = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int x = i ; while ( x > 0 ) { if ( x % 8 == d ) { total ++ ; break ; } x = x / 8 ; } } System . out . println ( total ) ; } public static void main ( String [ ] args ) { int n = 20 , d = 7 ; countNumbers ( n , d ) ; } }

Accumulator variables: i, total
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int build ( int tree [ ] , int [ ] A , int start , int end , int node ) { if ( start == end ) { tree [ node ] = A [ start ] ; return tree [ node ] ; } int mid = ( start + end ) / 2 ; int X = build ( tree , A , start , mid , 2 * node + 1 ) ; int Y = build ( tree , A , mid + 1 , end , 2 * node + 2 ) ; return ( tree [ node ] = Math . min ( X , Y ) ) ; } static int query ( int tree [ ] , int start , int end , int l , int r , int node ) { if ( start > r end < l ) return Integer . MAX_VALUE ; if ( start >= l && end <= r ) return tree [ node ] ; int mid = ( start + end ) / 2 ; int X = query ( tree , start , mid , l , r , 2 * node + 1 ) ; int Y = query ( tree , mid + 1 , end , l , r , 2 * node + 2 ) ; return Math . min ( X , Y ) ; } static int longestSubArray ( int [ ] A , int N , int K ) { int res = 1 ; int preSum [ ] = new int [ N + 1 ] ; preSum [ 0 ] = A [ 0 ] ; for ( int i = 0 ; i < N ; i ++ ) preSum [ i + 1 ] = preSum [ i ] + A [ i ] ; int tree [ ] = new int [ 4 * N + 5 ] ; build ( tree , A , 0 , N - 1 , 0 ) ; for ( int i = 0 ; i < N ; i ++ ) { int start = i ; int end = N - 1 ; int mid ; int max_index = i ; while ( start <= end ) { mid = ( start + end ) / 2 ; int min_element = query ( tree , 0 , N - 1 , i , mid , 0 ) ; int expected_sum = ( mid - i + 1 ) * min_element ; int actual_sum = preSum [ mid + 1 ] - preSum [ i ] ; if ( actual_sum - expected_sum <= K ) { start = mid + 1 ; max_index = Math . max ( max_index , mid ) ; } else { end = mid - 1 ; } } res = Math . max ( res , max_index - i + 1 ) ; } return res ; } static public void main ( String args [ ] ) { int arr [ ] = { 1 , 7 , 3 , 4 , 5 , 6 } ; int k = 6 ; int n = 6 ; System . out . print ( longestSubArray ( arr , n , k ) ) ; } }

Index/key variables: i, node, start
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findCntTriplet ( int N ) { int cntTriplet = 0 ; for ( int i = 1 ; i < N ; i ++ ) { if ( N % i != 0 ) { cntTriplet += N / i ; } else { cntTriplet += ( N / i ) - 1 ; } } return cntTriplet ; } public static void main ( String [ ] args ) { int N = 3 ; System . out . println ( findCntTriplet ( N ) ) ; } }

Accumulator variables: cntTriplet, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void countDivisors ( int n ) { int count = 0 ; int j = 0 ; int divisor [ ] = new int [ n ] ; for ( int i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) { divisor [ j ] = i ; j += 1 ; } else { divisor [ j ] = i ; divisor [ j + 1 ] = n / i ; j += 2 ; } } } divisor [ j ] = n ; for ( int i = 0 ; i <= j ; i ++ ) { int x = divisor [ i ] ; x -= 1 ; if ( ( n / x ) == ( n % x ) ) count ++ ; } System . out . print ( count ) ; } public static void main ( String [ ] args ) { int N = 10000000 ; countDivisors ( N ) ; } }

Index/key variables: i, j, n
Accumulator variables: count, i, j, x
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int smallestIndexArrayElementsFlip ( int arr [ ] , int N ) { int pos = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] *= - 1 ; int sum = 0 ; for ( int j = 0 ; j < N ; j ++ ) { sum += arr [ j ] ; } if ( sum == 0 ) { pos = i ; break ; } else { arr [ i ] *= - 1 ; } } return pos ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , - 5 , 3 , 4 } ; int N = arr . length ; System . out . println ( smallestIndexArrayElementsFlip ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int smallestIndexArrayElementsFlip ( int arr [ ] , int N ) { int pos = - 1 ; int ArrSum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { ArrSum += arr [ i ] ; } for ( int i = 0 ; i < N ; i ++ ) { if ( 2 * arr [ i ] == ArrSum ) { pos = i ; break ; } } return pos ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , - 5 , 3 , 4 } ; int N = arr . length ; System . out . println ( smallestIndexArrayElementsFlip ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: ArrSum, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String make_String_S_to_T ( String S , String T ) { boolean possible = false ; int M = T . length ( ) ; int N = S . length ( ) ; for ( int i = 0 ; i <= M ; i ++ ) { int prefix_length = i ; int suffix_length = M - i ; String prefix = S . substring ( 0 , prefix_length ) ; String suffix = S . substring ( N - suffix_length , N ) ; if ( ( prefix + suffix ) . equals ( T ) ) { possible = true ; break ; } } if ( possible ) return " YES " ; else return " NO " ; } public static void main ( String [ ] args ) { String S = " ababcdcd " ; String T = " abcd " ; System . out . print ( make_String_S_to_T ( S , T ) ) ; } }

Accumulator variables: i
Iterator variables: i
Boolean variables: possible
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static void findSum ( int a [ ] ) { int ans = 0 ; for ( int low = 0 ; low < a . length ; low ++ ) { for ( int high = low ; high < a . length ; high ++ ) { int count = 0 ; int maxNumber = 0 ; for ( int i = low ; i <= high ; i ++ ) { if ( a [ i ] == maxNumber ) count ++ ; else if ( a [ i ] > maxNumber ) { maxNumber = a [ i ] ; count = 1 ; } } ans += maxNumber * ( ( count % 2 == 0 ) ? 2 : 1 ) ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 4 , 4 , 2 } ; findSum ( arr ) ; } }

Index/key variables: i
Accumulator variables: ans, count, high, i, low
Iterator variables: high, i, low
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void countPairs ( int [ ] arr , int n ) { HashMap < Integer , Integer > mp1 = new HashMap < Integer , Integer > ( ) ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( mp1 . containsKey ( sum ) ) { mp1 . put ( sum , mp1 . get ( sum ) + 1 ) ; } else { mp1 . put ( sum , 1 ) ; } } sum = 0 ; int ans = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { sum += arr [ i ] ; if ( mp1 . containsKey ( sum ) ) { ans += mp1 . get ( sum ) ; } } System . out . print ( ans ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 1 , 1 } ; int n = arr . length ; countPairs ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: ans, i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean isMagic ( int num ) { return ( num % 9 == 1 ) ; } static boolean isComposite ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return false ; if ( n % 2 == 0 n % 3 == 0 ) return true ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return true ; return false ; } static void find ( int L [ ] , int R [ ] , int q ) { int dp [ ] = new int [ 1000005 ] ; dp [ 0 ] = 0 ; dp [ 1 ] = 0 ; for ( int i = 1 ; i < 1000005 ; i ++ ) { if ( isComposite ( i ) && isMagic ( i ) == true ) { dp [ i ] = dp [ i - 1 ] + 1 ; } else dp [ i ] = dp [ i - 1 ] ; } for ( int i = 0 ; i < q ; i ++ ) System . out . println ( dp [ R [ i ] ] - dp [ L [ i ] - 1 ] ) ; } public static void main ( String [ ] args ) { int L [ ] = { 10 , 3 } ; int R [ ] = { 100 , 2279 } ; int Q = 2 ; find ( L , R , Q ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findSmallestInteger ( int arr [ ] , int N , int K ) { int left = 1 ; int right = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; while ( left < right ) { int mid = ( left + right ) / 2 ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += ( arr [ i ] + mid - 1 ) / mid ; } if ( sum > K ) { left = mid + 1 ; } else { right = mid ; } } return left ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 5 , 9 } ; int N = arr . length ; int K = 6 ; System . out . println ( findSmallestInteger ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int minimum_deci_binary_number ( String s ) { int m = Integer . MIN_VALUE ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int temp = s . charAt ( i ) - '0' ; if ( temp > m ) { m = temp ; } } return m ; } public static void main ( String [ ] args ) { String S = "31" ; System . out . println ( minimum_deci_binary_number ( S ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void minOperations ( int arr [ ] , int n ) { int flips = 0 ; for ( int i = 0 ; i < n ; i += 2 ) { if ( arr [ i ] % 2 == 1 ) { continue ; } while ( i < n && arr [ i ] % 2 == 0 ) { i += 2 ; } flips ++ ; } for ( int i = 1 ; i < n ; i += 2 ) { if ( arr [ i ] % 2 == 1 ) { continue ; } while ( i < n && arr [ i ] % 2 == 0 ) { i += 2 ; } flips ++ ; } System . out . println ( flips ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 4 , 3 , 5 , 3 , 2 } ; int N = arr . length ; minOperations ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: flips, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int minimumReverse ( String s , int n ) { int k = 0 , l = 0 ; int sum1 = 0 , sum0 = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '1' ) sum1 ++ ; else sum0 ++ ; if ( s . charAt ( i ) == s . charAt ( i - 1 ) && s . charAt ( i ) == '0' ) k ++ ; else if ( s . charAt ( i ) == s . charAt ( i - 1 ) && s . charAt ( i ) == '1' ) l ++ ; } if ( s . charAt ( 0 ) == '1' ) sum1 ++ ; sum0 ++ ; if ( Math . abs ( sum1 - sum0 ) > 1 ) return - 1 ; return Math . max ( k , l ) ; } public static void main ( String [ ] args ) { String S = "10001" ; int N = S . length ( ) ; System . out . print ( minimumReverse ( S , N ) ) ; } }

Accumulator variables: i, k, l, sum0, sum1
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int cntPairsInTwoArray ( int arr [ ] , int brr [ ] , int N , int M ) { int cntOddArr = 0 ; int cntOddBrr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 1 ) { cntOddArr += 1 ; } } for ( int i = 0 ; i < M ; i ++ ) { if ( brr [ i ] % 2 == 1 ) { cntOddBrr += 1 ; } } return ( N * M ) - ( cntOddArr * cntOddBrr ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 } ; int N = arr . length ; int brr [ ] = { 1 , 2 } ; int M = brr . length ; System . out . print ( cntPairsInTwoArray ( arr , brr , N , M ) ) ; } }

Index/key variables: i
Accumulator variables: cntOddArr, cntOddBrr, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static void max_freq ( int arr [ ] , int N ) { Arrays . sort ( arr ) ; int Max = arr [ N - 1 ] ; int Min = arr [ 0 ] ; int freq [ ] = new int [ Max - Min + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { freq [ arr [ i ] - Min ] ++ ; } int maxSum = 0 ; for ( int i = 0 ; i < ( Max - Min - 1 ) ; i ++ ) { int val = freq [ i ] + freq [ i + 1 ] + freq [ i + 2 ] ; maxSum = Math . max ( maxSum , val ) ; } System . out . println ( maxSum ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 1 , 4 , 1 , 5 , 9 , 2 } ; int N = arr . length ; max_freq ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findMaxLength ( int N , int [ ] arr ) { int [ ] dp = new int [ N + 1 ] ; Arrays . fill ( dp , 1 ) ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 2 * i ; j <= N ; j += i ) { if ( arr [ i - 1 ] < arr [ j - 1 ] ) { dp [ j ] = Math . max ( dp [ j ] , dp [ i ] + 1 ) ; } } } return Arrays . stream ( dp ) . max ( ) . getAsInt ( ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; int N = arr . length ; System . out . print ( findMaxLength ( N , arr ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int binary_search ( int [ ] [ ] vec , int n , int a ) { int low , high , mid ; low = 0 ; high = n - 1 ; while ( low < high ) { mid = low + ( high - low + 1 ) / 2 ; if ( vec [ mid ] [ 0 ] > a ) { high = mid - 1 ; } else if ( vec [ mid ] [ 1 ] <= a ) { low = mid ; } } return low ; } static void modify_vec ( int [ ] [ ] v , int n ) { for ( int i = 1 ; i < n ; i ++ ) { v [ i ] [ 1 ] = Math . min ( v [ i ] [ 1 ] , v [ i - 1 ] [ 1 ] ) ; } } static int evaluate_query ( int [ ] [ ] v , int n , int m1 , int m2 ) { int temp = binary_search ( v , n , m1 ) ; if ( ( v [ temp ] [ 0 ] <= m1 ) && ( v [ temp ] [ 1 ] <= m2 ) ) { return 1 ; } return 0 ; } static void checkPairs ( int [ ] [ ] v , int [ ] [ ] queries ) { int n = v . length ; Arrays . sort ( v , ( a , b ) -> a [ 0 ] - b [ 0 ] ) ; modify_vec ( v , n ) ; int k = queries . length ; for ( int i = 0 ; i < k ; i ++ ) { int m1 = queries [ i ] [ 0 ] ; int m2 = queries [ i ] [ 1 ] ; int result = evaluate_query ( v , n , m1 , m2 ) ; if ( result > 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } public static void main ( String [ ] args ) { int [ ] [ ] arr = { { 3 , 5 } , { 2 , 7 } , { 2 , 3 } , { 4 , 9 } } ; int [ ] [ ] queries = { { 3 , 4 } , { 3 , 2 } , { 4 , 1 } , { 3 , 7 } } ; checkPairs ( arr , queries ) ; } }

Index/key variables: i, mid, temp
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void Sort ( Vector < Integer > ans , int num ) { int pos = - 1 ; for ( int i = 0 ; i < ans . size ( ) ; i ++ ) { if ( ans . get ( i ) >= num ) { pos = i ; break ; } } if ( pos == - 1 ) ans . add ( num ) ; else ans . add ( pos , num ) ; } static void sortStream ( int arr [ ] , int N ) { Vector < Integer > ans = new Vector < Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { Sort ( ans , arr [ i ] ) ; for ( int j = 0 ; j < ans . size ( ) ; j ++ ) { System . out . print ( ans . get ( j ) + " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 1 , 7 , 6 , 2 } ; int N = arr . length ; sortStream ( arr , N ) ; } }

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