dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static int countSubAllOnes ( String s ) { int l = 0 , r = 0 , ans = 0 ; while ( l <= r ) { if ( r == s . length ( ) ) { ans += ( ( r - l ) * ( r - l + 1 ) ) / 2 ; break ; } if ( s . charAt ( r ) == '1' ) r ++ ; else { ans += ( ( r - l ) * ( r - l + 1 ) ) / 2 ; l = r + 1 ; r ++ ; } } return ans ; } static String flip ( char [ ] s ) { for ( int i = 0 ; i < s . length ; i ++ ) { if ( s [ i ] == '1' ) s [ i ] = '0' ; else s [ i ] = '1' ; } return String . valueOf ( s ) ; } static int countSubAllZerosOnes ( String s ) { int only_1s = countSubAllOnes ( s ) ; s = flip ( s . toCharArray ( ) ) ; int only_0s = countSubAllOnes ( s ) ; return only_0s + only_1s ; } public static void main ( String [ ] args ) { String s = "011" ; System . out . print ( countSubAllZerosOnes ( s ) + "NEW_LINE"); } }

Index/key variables: i
Accumulator variables: ans, i, r
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean sumSquare ( int p ) { return ( p - 1 ) % 4 == 0 ; } static boolean isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static int countOfPrimes ( int L , int R ) { int count = 0 ; for ( int i = L ; i <= R ; i ++ ) { if ( isPrime ( i ) ) { if ( sumSquare ( i ) ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { int L = 5 , R = 41 ; System . out . println ( countOfPrimes ( L , R ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int count_elements ( int arr [ ] , int n ) { int count = 1 ; int max = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( arr [ i ] > max ) { count += 1 ; max = arr [ i ] ; } } return count ; } public static void main ( String s [ ] ) { int arr [ ] = { 2 , 1 , 4 , 6 , 3 } ; int n = arr . length ; System . out . print ( count_elements ( 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 void subString ( char str [ ] , int n ) { int c = 0 ; for ( int len = 1 ; len <= n ; len ++ ) { for ( int i = 0 ; i <= n - len ; i ++ ) { int j = i + len - 1 ; char temp = str [ i ] , f = 0 ; if ( j == i ) { c ++ ; continue ; } int k = i + 1 ; while ( k < n && temp < str [ k ] ) { temp = str [ k ] ; k ++ ; f = 2 ; } if ( k > j ) { c ++ ; f = 2 ; } while ( k < n && temp > str [ k ] && f != 2 ) { k ++ ; f = 0 ; } if ( k > j && f != 2 ) { c ++ ; f = 0 ; } } } System . out . print ( c + "NEW_LINE"); } public static void main ( String [ ] args ) { char str [ ] = " bade " . toCharArray ( ) ; subString ( str , str . length ) ; } }

Index/key variables: i, k
Accumulator variables: c, i, k, len
Iterator variables: i, len
Class/struct names: GFG
Java program:
import java . util . Scanner ; public class GreeksForGreeksQuestions { static int findNumberDivByPowerofTwo ( int [ ] ar , int k , int n ) { int found = - 1 , m = k ; while ( m > 0 ) { int l = 0 ; int r = n - 1 ; while ( l <= r ) { int mid = ( l + r ) / 2 ; if ( ar [ mid ] == m ) { found = m ; break ; } else if ( ar [ mid ] > m ) { r = mid - 1 ; } else if ( ar [ mid ] < m ) { l = mid + 1 ; } } if ( found != - 1 ) { break ; } m = m / 2 ; } return found ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 5 , 7 , 8 , 10 } ; int k = 4 , n = 5 ; System . out . println ( findNumberDivByPowerofTwo ( arr , k , n ) ) ; } }

Index/key variables: mid
Class/struct names: GreeksForGreeksQuestions
Java program:
import java . util . * ; class GFG { public static int findSubset ( int [ ] a , int n ) { int sum = 0 ; int cnt = 0 ; Vector < Integer > v = new Vector < > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( a [ i - 1 ] - i <= 0 ) { sum += a [ i - 1 ] - i ; cnt += 1 ; } else { v . add ( a [ i - 1 ] - i ) ; } } Collections . sort ( v ) ; int ptr = 0 ; while ( ptr < v . size ( ) && sum + v . get ( ptr ) <= 0 ) { cnt += 1 ; ptr += 1 ; sum += v . get ( ptr ) ; } return cnt ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 1 , 6 , 7 , 8 , 2 } ; int n = arr . length ; System . out . println ( findSubset ( arr , n ) ) ; } }

Accumulator variables: cnt, i, ptr, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static void setElement ( int [ ] arr , int n , int index , int x ) { arr [ index ] = x ; } static int getCount ( int [ ] arr , int n , int l , int r ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] >= l && arr [ i ] <= r ) { count ++ ; } } return count ; } static void SolveQuery ( int arr [ ] , int n , ArrayList < List < Integer > > Q ) { int x ; for ( int i = 0 ; i < Q . size ( ) ; i ++ ) { if ( Q . get ( i ) . get ( 0 ) == 1 ) { x = getCount ( arr , n , Q . get ( i ) . get ( 1 ) , Q . get ( i ) . get ( 2 ) ) ; System . out . print ( x + " ▁ " ) ; } else { setElement ( arr , n , Q . get ( i ) . get ( 1 ) , Q . get ( i ) . get ( 2 ) ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 2 , 3 , 4 , 4 , 5 , 6 } ; int n = arr . length ; ArrayList < List < Integer > > Q = new ArrayList < > ( ) ; Q . add ( Arrays . asList ( 1 , 3 , 5 ) ) ; Q . add ( Arrays . asList ( 1 , 2 , 4 ) ) ; Q . add ( Arrays . asList ( 1 , 1 , 2 ) ) ; Q . add ( Arrays . asList ( 2 , 1 , 7 ) ) ; Q . add ( Arrays . asList ( 1 , 1 , 2 ) ) ; SolveQuery ( arr , n , Q ) ; } }

Index/key variables: i, index
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static Vector < Integer > generateSequence ( int [ ] freq , int n ) { HashMap < Integer , Integer > m = new HashMap < Integer , Integer > ( ) ; int total = 0 ; for ( int i = 0 ; i < n ; i ++ ) { m . put ( i , freq [ i ] ) ; total += freq [ i ] ; } for ( int i = 0 ; i < n ; i ++ ) { if ( m . containsKey ( i ) ) { Vector < Integer > sequence = new Vector < Integer > ( ) ; @ SuppressWarnings ( " unchecked " ) HashMap < Integer , Integer > mcopy = ( HashMap < Integer , Integer > ) m . clone ( ) ; if ( mcopy . containsKey ( i ) && mcopy . get ( i ) > 0 ) mcopy . put ( i , mcopy . get ( i ) - 1 ) ; sequence . add ( i ) ; int last = i ; for ( int i1 = 0 ; i1 < total - 1 ; i1 ++ ) { if ( mcopy . containsKey ( last - 1 ) && mcopy . get ( last - 1 ) > 0 ) { mcopy . put ( last - 1 , mcopy . get ( last - 1 ) - 1 ) ; sequence . add ( last - 1 ) ; last -- ; } else if ( mcopy . containsKey ( last + 1 ) ) { mcopy . put ( last + 1 , mcopy . get ( last + 1 ) - 1 ) ; sequence . add ( last + 1 ) ; last ++ ; } else break ; } if ( sequence . size ( ) == total ) { return sequence ; } } } Vector < Integer > empty = new Vector < Integer > ( ) ; return empty ; } static void PrintSequence ( int freq [ ] , int n ) { Vector < Integer > sequence = generateSequence ( freq , n ) ; if ( sequence . size ( ) == 0 ) { System . out . print ( " - 1" ) ; } else { for ( int i = 0 ; i < sequence . size ( ) ; i ++ ) { System . out . print ( sequence . get ( i ) + " ▁ " ) ; } } } public static void main ( String [ ] args ) { int freq [ ] = { 2 , 2 , 2 , 3 , 1 } ; int N = 5 ; PrintSequence ( freq , N ) ; } }

Index/key variables: i
Accumulator variables: i, i1, last, total
Iterator variables: i, i1
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void getMinimumDistance ( int a [ ] , int n ) { Set < Integer > min_set = new HashSet < > ( ) ; Set < Integer > max_set = new HashSet < > ( ) ; int max = 0 , min = Integer . MAX_VALUE ; HashMap < Integer , Integer > frequency = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { frequency . put ( a [ i ] , frequency . getOrDefault ( a [ i ] , 0 ) + 1 ) ; } for ( int i = 0 ; i < n ; i ++ ) { int count = frequency . get ( a [ i ] ) ; if ( count == max ) { max_set . add ( a [ i ] ) ; } else if ( count > max ) { max_set . clear ( ) ; max = count ; max_set . add ( a [ i ] ) ; } if ( count == min ) { min_set . add ( a [ i ] ) ; } else if ( count < min ) { min_set . clear ( ) ; min = count ; min_set . add ( a [ i ] ) ; } } int min_dist = Integer . MAX_VALUE ; int last_min_found = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( min_set . contains ( a [ i ] ) ) last_min_found = i ; if ( max_set . contains ( a [ i ] ) && last_min_found != - 1 ) { min_dist = Math . min ( min_dist , i - last_min_found ) ; } } last_min_found = - 1 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( min_set . contains ( a [ i ] ) ) last_min_found = i ; if ( max_set . contains ( a [ i ] ) && last_min_found != - 1 ) { min_dist = Math . min ( min_dist , last_min_found - i ) ; } } System . out . println ( min_dist ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 2 , 3 , 2 , 3 , 3 } ; int N = arr . length ; getMinimumDistance ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printSubsequenceString ( String str , int k ) { int n = str . length ( ) ; int i ; Vector < Integer > factors = new Vector < Integer > ( ) ; for ( i = 2 ; i <= Math . sqrt ( k ) ; i ++ ) { while ( k % i == 0 ) { factors . add ( i ) ; k /= i ; } } if ( k > 1 ) factors . add ( k ) ; int [ ] count = new int [ n ] ; Arrays . fill ( count , 1 ) ; int index = 0 ; while ( factors . size ( ) > 0 ) { count [ index ++ ] *= factors . get ( factors . size ( ) - 1 ) ; factors . remove ( factors . get ( factors . size ( ) - 1 ) ) ; if ( index == n ) index = 0 ; } String s = " " ; for ( i = 0 ; i < n ; i ++ ) { while ( count [ i ] -- > 0 ) { s += str . charAt ( i ) ; } } System . out . print ( s ) ; } public static void main ( String [ ] args ) { String str = " code " ; int k = 20 ; printSubsequenceString ( str , k ) ; } }

Index/key variables: i, n
Accumulator variables: i, index, k, s
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void changeArr ( int [ ] input ) { int newArray [ ] = Arrays . copyOfRange ( input , 0 , input . length ) ; Arrays . sort ( newArray ) ; int i ; Map < Integer , Integer > ranks = new HashMap < > ( ) ; int rank = 1 ; for ( int index = 0 ; index < newArray . length ; index ++ ) { int element = newArray [ index ] ; if ( ranks . get ( element ) == null ) { ranks . put ( element , rank ) ; rank ++ ; } } for ( int index = 0 ; index < input . length ; index ++ ) { int element = input [ index ] ; input [ index ] = ranks . get ( input [ index ] ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 100 , 2 , 70 , 2 } ; changeArr ( arr ) ; System . out . println ( Arrays . toString ( arr ) ) ; } }

Index/key variables: index
Accumulator variables: index, rank
Iterator variables: index
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void findPair ( int [ ] arr , int n ) { int i , j ; if ( n < 2 ) { System . out . println ( " - 1" ) ; } HashSet < Integer > hashMap = new HashSet < Integer > ( ) ; for ( Integer k : arr ) { hashMap . add ( k ) ; } for ( i = 0 ; i < n - 1 ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { int sum = arr [ i ] + arr [ j ] ; if ( ! hashMap . contains ( sum ) ) { System . out . println ( " ( " + arr [ i ] + " , ▁ " + arr [ j ] + " ) " ) ; } } } } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 2 , 6 } ; int n = arr . length ; findPair ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findLengthOfMaxSubset ( int arr [ ] , int n , int m ) { Set < Integer > s = new HashSet < > ( ) ; int answer = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = arr [ i ] ; if ( tmp != m ) { s . add ( tmp ) ; answer ++ ; } } int min = 1 ; while ( s . contains ( min ) ) { min ++ ; } if ( min != m ) { answer = - 1 ; } return answer ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 4 } ; int N = arr . length ; int M = 3 ; System . out . print ( findLengthOfMaxSubset ( arr , N , M ) ) ; } }

Index/key variables: i
Accumulator variables: answer, i, min
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int m = 5 ; static int countSubsquare ( int arr [ ] [ ] , int n , int X ) { int [ ] [ ] dp = new int [ n + 1 ] [ m + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { dp [ i + 1 ] [ j + 1 ] = arr [ i ] [ j ] ; } } for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { dp [ i ] [ j ] += dp [ i - 1 ] [ j ] + dp [ i ] [ j - 1 ] - dp [ i - 1 ] [ j - 1 ] ; } } int cnt = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { int lo = 1 ; int hi = Math . min ( n - i , m - j ) + 1 ; boolean found = false ; while ( lo <= hi ) { int mid = ( lo + hi ) / 2 ; int ni = i + mid - 1 ; int nj = j + mid - 1 ; int sum = dp [ ni ] [ nj ] - dp [ ni ] [ j - 1 ] - dp [ i - 1 ] [ nj ] + dp [ i - 1 ] [ j - 1 ] ; if ( sum >= X ) { if ( sum == X ) { found = true ; } hi = mid - 1 ; } else { lo = mid + 1 ; } } if ( found == true ) { cnt ++ ; } } } return cnt ; } public static void main ( String [ ] args ) { int N = 4 , X = 10 ; int arr [ ] [ ] = { { 2 , 4 , 3 , 2 , 10 } , { 3 , 1 , 1 , 1 , 5 } , { 1 , 1 , 2 , 1 , 4 } , { 2 , 1 , 1 , 1 , 3 } } ; System . out . print ( countSubsquare ( arr , N , X ) + "NEW_LINE"); } }

Index/key variables: i, j, ni, nj
Accumulator variables: cnt, i, j
Iterator variables: i, j
Boolean variables: found
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void checkArray ( int A [ ] , int B [ ] , int N ) { int start = 0 ; int end = N - 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] != B [ i ] ) { start = i ; break ; } } for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( A [ i ] != B [ i ] ) { end = i ; break ; } } Collections . reverse ( Arrays . asList ( A ) ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] != B [ i ] ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 3 , 2 , 4 } ; int B [ ] = { 1 , 2 , 3 , 4 } ; int N = A . length ; checkArray ( A , B , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countSub ( String str ) { int n = ( int ) str . length ( ) ; int ans = 0 ; int [ ] cnt = new int [ 26 ] ; int i = 0 , j = 0 ; while ( i < n ) { if ( j < n && ( cnt [ str . charAt ( j ) - ' a ' ] == 0 ) ) { cnt [ str . charAt ( j ) - ' a ' ] ++ ; ans += ( j - i + 1 ) ; j ++ ; } else { cnt [ str . charAt ( i ) - ' a ' ] -- ; i ++ ; } } return ans ; } public static void main ( String [ ] args ) { String str = " gffg " ; System . out . print ( countSub ( str ) ) ; } }

Accumulator variables: ans, i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int solve ( int n , int k ) { int ans = 0 ; for ( int j = 1 ; j * j <= n ; j ++ ) { if ( n % j == 0 ) { if ( j <= k ) { ans = Math . max ( ans , j ) ; } if ( n / j <= k ) { ans = Math . max ( ans , n / j ) ; } } } return ans ; } public static void main ( String [ ] args ) { int N = 8 , K = 7 ; System . out . print ( ( N / solve ( N , K ) ) ) ; } }

Accumulator variables: j
Iterator variables: j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void max_sum_subarray ( List < Integer > arr , int L , int R ) { int n = arr . size ( ) ; int [ ] pre = new int [ n ] ; pre [ 0 ] = arr . get ( 0 ) ; for ( int i = 1 ; i < n ; i ++ ) { pre [ i ] = pre [ i - 1 ] + arr . get ( i ) ; } List < Integer > s1 = new ArrayList < > ( ) ; s1 . add ( 0 ) ; int ans = Integer . MIN_VALUE ; ans = Math . max ( ans , pre [ L - 1 ] ) ; int flag = 0 ; for ( int i = L ; i < n ; i ++ ) { if ( i - R >= 0 ) { if ( flag == 0 ) { int it = s1 . indexOf ( 0 ) ; s1 . remove ( it ) ; flag = 1 ; } } if ( i - L >= 0 ) s1 . add ( pre [ i - L ] ) ; ans = Math . max ( ans , pre [ i ] - s1 . get ( 0 ) ) ; if ( i - R >= 0 ) { int it = s1 . indexOf ( pre [ i - R ] ) ; s1 . remove ( it ) ; } } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int L , R ; L = 1 ; R = 3 ; List < Integer > arr = Arrays . asList ( 1 , 2 , 2 , 1 ) ; max_sum_subarray ( arr , L , R ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int rowWise ( char [ ] [ ] v , int n , int m , int k ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int countcons = 0 ; for ( int j = 0 ; j < m ; j ++ ) { if ( v [ i ] [ j ] == '1' ) { countcons = 0 ; } else { countcons ++ ; } if ( countcons >= k ) { ans ++ ; } } } return ans ; } static int colWise ( char [ ] [ ] v , int n , int m , int k ) { int ans = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int countcons = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( v [ j ] [ i ] == '1' ) { countcons = 0 ; } else { countcons ++ ; } if ( countcons >= k ) { ans ++ ; } } } return ans ; } public static void main ( String [ ] args ) { int n = 3 , m = 3 , k = 1 ; char v [ ] [ ] = { { '0' , '0' , '0' } , { '0' , '0' , '0' } , { '0' , '0' , '0' } } ; if ( k == 1 ) { System . out . print ( rowWise ( v , n , m , k ) ) ; } else { System . out . print ( colWise ( v , n , m , k ) + rowWise ( v , n , m , k ) ) ; } } }

Index/key variables: i, j
Accumulator variables: ans, countcons, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean solve ( int a [ ] , int n ) { int mx = Integer . MIN_VALUE ; for ( int j = 1 ; j < n ; j ++ ) { if ( mx > a [ j ] ) return false ; mx = Math . max ( mx , a [ j - 1 ] ) ; } return true ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 0 , 2 } ; int n = a . length ; boolean possible = solve ( a , n ) ; if ( possible ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: j
Accumulator variables: j
Iterator variables: j
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 int [ ] spf = new int [ 100009 ] ; static void sieve ( ) { for ( int i = 0 ; i < 100005 ; i ++ ) spf [ i ] = - 1 ; for ( int i = 2 ; i * i <= 100005 ; i ++ ) { for ( int j = i ; j <= 100005 ; j += i ) { if ( spf [ j ] == - 1 ) { spf [ j ] = i ; } } } } static HashSet < Integer > findPrimeFactors ( HashSet < Integer > s , int n ) { while ( n > 1 ) { s . add ( spf [ n ] ) ; n /= spf [ n ] ; } return s ; } static int MinimumSteps ( int n , int m ) { Queue < pair > q = new LinkedList < > ( ) ; HashSet < Integer > s = new HashSet < Integer > ( ) ; q . add ( new pair ( n , 0 ) ) ; while ( ! q . isEmpty ( ) ) { int newNum = q . peek ( ) . first ; int distance = q . peek ( ) . second ; q . remove ( ) ; HashSet < Integer > k = findPrimeFactors ( s , newNum ) ; for ( int i : k ) { if ( newNum == m ) { return distance ; } else if ( newNum > m ) { break ; } else { q . add ( new pair ( newNum + i , distance + 1 ) ) ; } } } return - 1 ; } public static void main ( String [ ] args ) { int N = 7 , M = 16 ; sieve ( ) ; System . out . print ( MinimumSteps ( N , M ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j, n
Iterator variables: i, j
Class/struct names: GFG, pair
Java program:
import java . util . * ; class GFG { static Vector < Integer > [ ] v = new Vector [ 100000 ] ; static void div ( int n ) { for ( int i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { v [ n ] . add ( i ) ; } } } static int prodof2elements ( int arr [ ] , int n ) { int [ ] arr2 = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr2 [ i ] = arr [ i ] ; } Arrays . sort ( arr2 ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( v [ arr [ i ] ] . size ( ) == 0 ) div ( arr [ i ] ) ; for ( int j : v [ arr [ i ] ] ) { if ( Arrays . binarySearch ( arr2 , j ) >= 0 && Arrays . binarySearch ( arr2 , ( int ) arr [ i ] / j ) >= 0 ) { ans ++ ; break ; } } } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 1 , 8 , 4 , 32 , 18 } ; int N = arr . length ; for ( int i = 0 ; i < v . length ; i ++ ) v [ i ] = new Vector < Integer > ( ) ; System . out . print ( prodof2elements ( arr , N ) ) ; } }

Index/key variables: i, n
Accumulator variables: ans, i
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int max_subarray_size ( int N , int [ ] arr ) { int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { HashMap < Integer , Integer > map1 = new HashMap < > ( ) ; HashMap < Integer , Integer > map2 = new HashMap < > ( ) ; for ( int j = i ; j < N ; j ++ ) { int ele_count ; if ( ! map1 . containsKey ( arr [ j ] ) ) { ele_count = 0 ; } else { ele_count = map1 . get ( arr [ j ] ) ; } if ( map1 . containsKey ( arr [ j ] ) ) { map1 . put ( arr [ j ] , map1 . get ( arr [ j ] ) + 1 ) ; } else { map1 . put ( arr [ j ] , 1 ) ; } if ( map2 . containsKey ( ele_count ) ) { if ( map2 . get ( ele_count ) == 1 ) { map2 . remove ( ele_count ) ; } else { map2 . put ( ele_count , map2 . get ( ele_count ) - 1 ) ; } } if ( map2 . containsKey ( ele_count + 1 ) ) { map2 . put ( ele_count + 1 , map2 . get ( ele_count + 1 ) + 1 ) ; } else { map2 . put ( ele_count + 1 , 1 ) ; } if ( map2 . size ( ) == 1 ) ans = Math . max ( ans , j - i + 1 ) ; } } return ans ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 2 , 5 , 6 , 5 , 6 } ; int N = arr . length ; System . out . println ( max_subarray_size ( N , arr ) ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean vowel ( int vo ) { if ( vo == 0 vo == 4 vo == 8 vo == 14 vo == 20 ) return true ; else return false ; } static boolean check ( String s , int k ) { int [ ] cnt = new int [ 26 ] ; for ( int i = 0 ; i < k - 1 ; i ++ ) { cnt [ s . charAt ( i ) - ' a ' ] ++ ; } for ( int i = k - 1 ; i < s . length ( ) ; i ++ ) { cnt [ s . charAt ( i ) - ' a ' ] ++ ; int flag1 = 0 ; for ( int j = 0 ; j < 26 ; j ++ ) { if ( vowel ( j ) == false && cnt [ j ] > 0 ) { flag1 = 1 ; break ; } } if ( flag1 == 0 ) return true ; cnt [ s . charAt ( i - k + 1 ) - ' a ' ] -- ; } return false ; } static int longestSubString ( String s ) { int l = 1 , r = s . length ( ) ; int maxi = 0 ; while ( l <= r ) { int mid = ( l + r ) / 2 ; if ( check ( s , mid ) ) { l = mid + 1 ; maxi = Math . max ( maxi , mid ) ; } else r = mid - 1 ; } return maxi ; } public static void main ( String [ ] args ) { String s = " sedrewaefhoiu " ; System . out . print ( longestSubString ( s ) ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int countPairs ( int X [ ] , int Y [ ] , int m , int n ) { int [ ] suffix = new int [ 1005 ] ; long total_pairs = 0 ; for ( int i = 0 ; i < n ; i ++ ) suffix [ Y [ i ] ] ++ ; for ( int i = ( int ) 1e3 ; i >= 3 ; i -- ) suffix [ i ] += suffix [ i + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) { if ( X [ i ] == 0 ) continue ; else if ( X [ i ] == 1 ) { total_pairs += suffix [ 0 ] ; continue ; } else if ( X [ i ] == 2 ) total_pairs += suffix [ 5 ] ; else if ( X [ i ] == 3 ) total_pairs += suffix [ 2 ] + suffix [ 4 ] ; else total_pairs += suffix [ X [ i ] + 1 ] ; total_pairs += suffix [ 0 ] + suffix [ 1 ] ; } return ( int ) total_pairs ; } public static void main ( String [ ] args ) { int X [ ] = { 10 , 19 , 18 } ; int Y [ ] = { 11 , 15 , 9 } ; int m = X . length ; int n = Y . length ; System . out . print ( countPairs ( X , Y , m , n ) ) ; } }

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