dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static void canReduceArray ( int arr [ ] , int N , int K ) { Arrays . sort ( arr ) ; int b [ ] = new int [ N ] ; int j = N ; for ( int i = 0 ; i < N ; i ++ ) { b [ j - 1 ] = arr [ i ] ; j = j - 1 ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] - arr [ i + 1 ] > K ) { System . out . print ( " No " ) ; return ; } } System . out . print ( " Yes " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 1 , 1 , 3 } ; int N = arr . length ; int K = 1 ; canReduceArray ( arr , N , K ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void mergeStrings ( String s1 , String s2 ) { int len1 = s1 . length ( ) ; int len2 = s2 . length ( ) ; int pntr1 = 0 ; int pntr2 = 0 ; String ans = " " ; while ( pntr1 < len1 && pntr2 < len2 ) { if ( s1 . charAt ( pntr1 ) < s2 . charAt ( pntr2 ) ) { ans += s1 . charAt ( pntr1 ) ; pntr1 ++ ; } else { ans += s2 . charAt ( pntr2 ) ; pntr2 ++ ; } } if ( pntr1 < len1 ) { ans += s1 . substring ( pntr1 , len1 ) ; } if ( pntr2 < len2 ) { ans += s2 . substring ( pntr2 , len2 ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { String S1 = " abdcdtx " ; String S2 = " achilp " ; mergeStrings ( S1 , S2 ) ; } }

Accumulator variables: ans, pntr1, pntr2
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void sortStr ( String str ) { char S [ ] = str . toCharArray ( ) ; int N = S . length ; ArrayList < Character > temp = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] != ' a ' && S [ i ] != ' e ' && S [ i ] != ' i ' && S [ i ] != ' o ' && S [ i ] != ' u ' ) temp . add ( S [ i ] ) ; } if ( temp . size ( ) != 0 ) Collections . sort ( temp ) ; int ptr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] != ' a ' && S [ i ] != ' e ' && S [ i ] != ' i ' && S [ i ] != ' o ' && S [ i ] != ' u ' ) S [ i ] = temp . get ( ptr ++ ) ; } System . out . println ( new String ( S ) ) ; } public static void main ( String [ ] args ) { String S = " geeksforgeeks " ; sortStr ( S ) ; } }

Index/key variables: i
Accumulator variables: i, ptr
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { public static int upper_bound ( int arr [ ] , int key ) { int l = - 1 , r = arr . length ; while ( l + 1 < r ) { int m = ( l + r ) >>> 1 ; if ( arr [ m ] <= key ) l = m ; else r = m ; } return l + 1 ; } static void countPairs ( int arr [ ] , int n , int k ) { Arrays . sort ( arr ) ; int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int high = upper_bound ( arr , k * arr [ i ] ) ; ans += high - i - 1 ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 9 , 5 } ; int n = arr . length ; int k = 2 ; countPairs ( arr , n , k ) ; } }

Index/key variables: i, m
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findXOR ( int [ ] [ ] mat , int K ) { int N = mat . length ; int M = mat [ 0 ] . length ; ArrayList < Integer > digXOR = new ArrayList < Integer > ( ) ; for ( int l = 1 ; l <= ( N + M - 1 ) ; l ++ ) { int s_col = Math . max ( 0 , l - N ) ; int count = Math . min ( l , Math . min ( ( M - s_col ) , N ) ) ; int currXOR = 0 ; for ( int j = 0 ; j < count ; j ++ ) { currXOR = ( currXOR ^ mat [ Math . min ( N , l ) - j - 1 ] [ s_col + j ] ) ; } digXOR . add ( currXOR ) ; } Collections . sort ( digXOR ) ; System . out . print ( digXOR . get ( N + M - 1 - K ) ) ; } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; int K = 3 ; findXOR ( mat , K ) ; } }

Accumulator variables: j, l
Iterator variables: j, l
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void maximumSum ( int [ ] arr , int N ) { int sum ; Arrays . sort ( arr ) ; sum = ( arr [ N - 1 ] - arr [ 0 ] ) + ( arr [ N - 2 ] - arr [ 0 ] ) + ( arr [ N - 1 ] - arr [ N - 2 ] ) ; System . out . println ( sum ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 4 , 2 } ; int N = arr . length ; maximumSum ( arr , N ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class pair { int first , second , third ; pair ( int first , int second , int third ) { this . first = first ; this . second = second ; this . third = third ; } } class GFG { static int findSum ( ArrayList < pair > v , int n ) { Map < Integer , Boolean > um = new HashMap < > ( ) ; int res = 0 ; int cnt = 0 ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { if ( cnt == n ) break ; int x = v . get ( i ) . second ; int y = v . get ( i ) . third ; int xorResult = v . get ( i ) . first ; if ( um . get ( x ) == null && um . get ( y ) == null ) { res += xorResult ; um . put ( x , true ) ; um . put ( y , true ) ; cnt += 2 ; } } return res ; } static void findMaxMinSum ( int a [ ] , int n ) { ArrayList < pair > v = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int xorResult = a [ i ] ^ a [ j ] ; v . add ( new pair ( xorResult , a [ i ] , a [ j ] ) ) ; } } Collections . sort ( v , ( aa , b ) -> aa . first - b . first ) ; int maxi = 0 , mini = 0 ; mini = findSum ( v , n ) ; Collections . reverse ( v ) ; maxi = findSum ( v , n ) ; System . out . print ( mini + " ▁ " + maxi ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int N = arr . length ; findMaxMinSum ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: cnt, i, j, res
Iterator variables: i, j
Class/struct names: GFG, pair
Java program:
import java . io . * ; import java . util . * ; class GFG { static void maximumSumPermutation ( int [ ] arr ) { int N = arr . length ; Arrays . sort ( arr ) ; int temp = arr [ 0 ] ; arr [ 0 ] = arr [ N - 1 ] ; arr [ N - 1 ] = temp ; for ( int i : arr ) { System . out . print ( i + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; maximumSumPermutation ( arr ) ; } }

Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class GFG { static void findMaxNumbers ( int arr [ ] , int n , int k ) { Arrays . sort ( arr ) ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int opr = ( int ) Math . ceil ( ( Math . log ( arr [ i ] ) / Math . log ( 2 ) ) ) ; k -= opr ; if ( k < 0 ) { break ; } cnt ++ ; } System . out . println ( cnt ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 5 , 8 , 4 , 7 } ; int N = arr . length ; int K = 5 ; findMaxNumbers ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: cnt, i, k
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class GFG { static void meanOfRemainingElements ( int [ ] arr , int N , int K ) { Arrays . sort ( arr ) ; int kthPercent = ( N * K ) / 100 ; float sum = 0f ; for ( int i = 0 ; i < N ; i ++ ) if ( i >= kthPercent && i < ( N - kthPercent ) ) sum += arr [ i ] ; float mean = ( sum / ( N - 2 * kthPercent ) ) ; System . out . format ( " % .5f " , mean ) ; } public static void main ( String args [ ] ) { int [ ] arr = { 6 , 2 , 7 , 5 , 1 , 2 , 0 , 3 , 10 , 2 , 5 , 0 , 5 , 5 , 0 , 8 , 7 , 6 , 8 , 0 } ; int arr_size = arr . length ; int K = 5 ; meanOfRemainingElements ( arr , arr_size , K ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void minOperation ( int a [ ] , int N ) { int totOps = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { totOps += Math . abs ( a [ i ] - a [ i + 1 ] ) ; } int maxOps = Math . max ( Math . abs ( a [ 0 ] - a [ 1 ] ) , Math . abs ( a [ N - 1 ] - a [ N - 2 ] ) ) ; for ( int i = 1 ; i < N - 1 ; i ++ ) { maxOps = Math . max ( maxOps , Math . abs ( a [ i ] - a [ i - 1 ] ) + Math . abs ( a [ i ] - a [ i + 1 ] ) - Math . abs ( a [ i - 1 ] - a [ i + 1 ] ) ) ; } System . out . println ( totOps - maxOps ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , - 1 , 0 , 1 , 1 } ; int N = arr . length ; minOperation ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, totOps
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void maxIntersection ( int segments [ ] [ ] , int N ) { int [ ] rvalues = new int [ N ] ; int [ ] lvalues = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { lvalues [ i ] = segments [ i ] [ 0 ] ; rvalues [ i ] = segments [ i ] [ 1 ] ; } Arrays . sort ( lvalues ) ; Arrays . sort ( rvalues ) ; int [ ] answer = { - 1 , - 1 } ; int numIntersections = 0 ; for ( int i = 0 ; i < N ; ++ i ) { int lesser = lower_bound ( rvalues , 0 , segments . length , segments [ i ] [ 0 ] ) ; int greater = Math . max ( 0 , N - ( upper_bound ( lvalues , 0 , segments . length , segments [ i ] [ 1 ] ) ) ) ; if ( ( N - lesser - greater ) >= numIntersections ) { answer = new int [ ] { segments [ i ] [ 0 ] , segments [ i ] [ 1 ] } ; numIntersections = ( N - lesser - greater ) ; } } System . out . print ( answer [ 0 ] + " ▁ " + answer [ 1 ] ) ; } static int lower_bound ( int [ ] a , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( element > a [ middle ] ) low = middle + 1 ; else high = middle ; } return low ; } static int upper_bound ( int [ ] a , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( a [ middle ] > element ) high = middle ; else low = middle + 1 ; } return low ; } public static void main ( String [ ] args ) { int segments [ ] [ ] = { { 1 , 4 } , { 2 , 3 } , { 3 , 6 } } ; int N = segments . length ; maxIntersection ( segments , N ) ; } }

Index/key variables: N, i, middle
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int temp [ ] = new int [ 100000 ] ; static int merge ( int A [ ] , int left , int mid , int right ) { int swaps = 0 ; int i = left , j = mid , k = left ; while ( i < mid && j <= right ) { if ( A [ i ] <= A [ j ] ) { temp [ k ] = A [ i ] ; k ++ ; i ++ ; } else { temp [ k ] = A [ j ] ; k ++ ; j ++ ; swaps += mid - i ; } } while ( i < mid ) { temp [ k ] = A [ i ] ; k ++ ; i ++ ; } while ( j <= right ) { temp [ k ] = A [ j ] ; k ++ ; j ++ ; } while ( left <= right ) { A [ left ] = temp [ left ] ; left ++ ; } return swaps ; } static int mergeInsertionSwap ( int A [ ] , int left , int right ) { int swaps = 0 ; if ( left < right ) { int mid = left + ( right - left ) / 2 ; swaps += mergeInsertionSwap ( A , left , mid ) ; swaps += mergeInsertionSwap ( A , mid + 1 , right ) ; swaps += merge ( A , left , mid + 1 , right ) ; } return swaps ; } public static void main ( String [ ] args ) { int A [ ] = { 2 , 1 , 3 , 1 , 2 } ; int N = A . length ; System . out . println ( mergeInsertionSwap ( A , 0 , N - 1 ) ) ; } }

Index/key variables: i, j, k, left
Accumulator variables: i, j, k, left, swaps
Class/struct names: GFG
Java program:
import java . util . * ; class triplet implements Comparable < triplet > { int a , b , c ; triplet ( int a , int b , int c ) { this . a = a ; this . b = b ; this . c = c ; } public int compareTo ( triplet o ) { return this . a - o . a ; } } class GFG { static int seg [ ] ; public static void maxValue ( int a [ ] , int b [ ] , int n , int k ) { triplet arr [ ] = new triplet [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = new triplet ( a [ i ] , b [ i ] , a [ i ] + b [ i ] ) ; } Arrays . sort ( arr ) ; seg = new int [ 4 * n ] ; build ( arr , 0 , 0 , n - 1 ) ; int maxvalue = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int right = search ( arr , arr [ i ] . a + k ) ; if ( right != - 1 ) { maxvalue = Math . max ( maxvalue , arr [ i ] . b - arr [ i ] . a + getMax ( arr , 0 , 0 , n - 1 , i + 1 , right ) ) ; } } System . out . println ( maxvalue ) ; } public static int search ( triplet arr [ ] , int val ) { int low = 0 , high = arr . length - 1 ; int ans = - 1 ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( arr [ mid ] . a <= val ) { ans = mid ; low = mid + 1 ; } else high = mid - 1 ; } return ans ; } public static void build ( triplet arr [ ] , int index , int s , int e ) { if ( s == e ) { seg [ index ] = arr [ s ] . c ; return ; } int mid = s + ( e - s ) / 2 ; build ( arr , 2 * index + 1 , s , mid ) ; build ( arr , 2 * index + 2 , mid + 1 , e ) ; seg [ index ] = Math . max ( seg [ 2 * index + 1 ] , seg [ 2 * index + 2 ] ) ; } public static int getMax ( triplet arr [ ] , int index , int s , int e , int qs , int qe ) { if ( qe < s e < qs ) return Integer . MIN_VALUE / 2 ; if ( s >= qs && e <= qe ) return seg [ index ] ; int mid = s + ( e - s ) / 2 ; return Math . max ( getMax ( arr , 2 * index + 1 , s , mid , qs , qe ) , getMax ( arr , 2 * index + 2 , mid + 1 , e , qs , qe ) ) ; } public static void main ( String args [ ] ) { int N = 4 , K = 1 ; int A [ ] = { 5 , 6 , 9 , 10 } ; int B [ ] = { 3 , 0 , 10 , - 10 } ; maxValue ( A , B , N , K ) ; } }

Index/key variables: i, index, mid, n, s
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, triplet
Java program:
import java . io . * ; import java . util . * ; class GFG { static int maxCntRemovedfromArray ( int [ ] arr , int N , int [ ] brr , int M ) { Arrays . sort ( arr ) ; int i = 0 ; int sumArr = 0 ; for ( i = 0 ; i < N ; i ++ ) { sumArr += arr [ i ] ; } int sumBrr = 0 ; for ( i = 0 ; i < M ; i ++ ) { sumBrr += brr [ i ] ; } int cntRemElem = 0 ; while ( i < N && sumArr >= sumBrr ) { sumArr -= arr [ i ] ; i += 1 ; if ( sumArr >= sumBrr ) { cntRemElem += 1 ; } } return cntRemElem ; } public static void main ( String [ ] args ) { int [ ] arr = new int [ ] { 1 , 2 , 4 , 6 } ; int [ ] brr = new int [ ] { 7 } ; int N = arr . length ; int M = brr . length ; System . out . println ( maxCntRemovedfromArray ( arr , N , brr , M ) ) ; } }

Index/key variables: i
Accumulator variables: cntRemElem, i, sumArr, sumBrr
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 findPair ( pair arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { int a = arr [ i ] . first , b = arr [ i ] . second ; for ( int j = i + 1 ; j < N ; j ++ ) { int c = arr [ j ] . first , d = arr [ j ] . second ; if ( a < c && b > d ) { System . out . println ( " ( " + a + " ▁ " + b + " ) , ▁ ( " + c + " ▁ " + d + " ) " ) ; return ; } } } System . out . println ( " NO ▁ SUCH ▁ PAIR ▁ EXIST " ) ; } public static void main ( String [ ] args ) { pair arr [ ] = { new pair ( 3 , 7 ) , new pair ( 21 , 23 ) , new pair ( 4 , 13 ) , new pair ( 1 , 2 ) , new pair ( 7 , - 1 ) } ; findPair ( arr , 5 ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, pair
Java program:
import java . util . * ; class GFG { static class pair implements Comparable < pair > { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } public int compareTo ( pair p ) { return this . first - p . first ; } } static void findpair ( pair [ ] arr , int N ) { Arrays . sort ( arr ) ; for ( int i = 1 ; i < N ; i ++ ) { int b = arr [ i - 1 ] . second ; int d = arr [ i ] . second ; if ( b > d ) { System . out . print ( " ( " + arr [ i - 1 ] . first + " ▁ " + b + " ) , ▁ ( " + arr [ i ] . first + " ▁ " + d + " ) " ) ; return ; } } System . out . print ( "NO SUCH PAIR EXISTNEW_LINE"); } public static void main ( String [ ] args ) { pair arr [ ] = { new pair ( 3 , 7 ) , new pair ( 21 , 23 ) , new pair ( 4 , 13 ) , new pair ( 1 , 2 ) , new pair ( 7 , - 1 ) } ; findpair ( arr , 5 ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
import java . io . * ; import java . util . * ; class GFG { static void printOrder ( int order [ ] , int N , int X ) { ArrayList < int [ ] > vect = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( order [ i ] % X == 0 ) { vect . add ( new int [ ] { order [ i ] / X , i + 1 } ) ; } else { vect . add ( new int [ ] { order [ i ] / X + 1 , i + 1 } ) ; } } Collections . sort ( vect , ( a , b ) -> a [ 0 ] - b [ 0 ] ) ; for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( vect . get ( i ) [ 1 ] + " ▁ " ) ; } System . out . println ( ) ; } public static void main ( String args [ ] ) { int N = 3 , X = 3 ; int order [ ] = { 2 , 7 , 4 } ; printOrder ( order , N , X ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void reverse ( int arr [ ] , int start , int end ) { int mid = ( end - start + 1 ) / 2 ; for ( int i = 0 ; i < mid ; i ++ ) { int temp = arr [ start + i ] ; arr [ start + i ] = arr [ end - i ] ; arr [ end - i ] = temp ; } return ; } static void shuffleArrayUtil ( int arr [ ] , int start , int end ) { int i ; int l = end - start + 1 ; if ( l == 2 ) return ; int mid = start + l / 2 ; if ( l % 4 > 0 ) { mid -= 1 ; } int mid1 = start + ( mid - start ) / 2 ; int mid2 = mid + ( end + 1 - mid ) / 2 ; reverse ( arr , mid1 , mid2 - 1 ) ; reverse ( arr , mid1 , mid - 1 ) ; reverse ( arr , mid , mid2 - 1 ) ; shuffleArrayUtil ( arr , start , mid - 1 ) ; shuffleArrayUtil ( arr , mid , end ) ; } static void shuffleArray ( int arr [ ] , int N , int start , int end ) { shuffleArrayUtil ( arr , start , end ) ; for ( int i = 0 ; i < N ; i ++ ) System . out . printf ( " % d ▁ " , arr [ i ] ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 5 , 2 , 4 , 6 } ; int N = arr . length ; shuffleArray ( arr , N , 0 , N - 1 ) ; } }

Index/key variables: i
Accumulator variables: i, mid
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void rearrange ( int A [ ] , int B [ ] , int N , int X ) { boolean flag = true ; Arrays . sort ( A ) ; Arrays . sort ( B ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] + B [ N - 1 - i ] > X ) { flag = false ; break ; } } if ( flag == true ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 2 , 3 } ; int B [ ] = { 1 , 1 , 2 } ; int X = 4 ; int N = A . length ; rearrange ( A , B , N , X ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void numOperation ( int arr [ ] , int N , int D ) { Arrays . sort ( arr ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( ( arr [ i + 1 ] - arr [ i ] ) % D != 0 ) { System . out . println ( " - 1" ) ; return ; } } int count = 0 ; int mid = arr [ N / 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { count += Math . abs ( mid - arr [ i ] ) / D ; } System . out . println ( count ) ; } public static void main ( String [ ] args ) { int N = 4 , D = 2 ; int arr [ ] = { 2 , 4 , 6 , 8 } ; numOperation ( arr , N , D ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findSum ( int A [ ] , int N , int K ) { Arrays . sort ( A ) ; int sum = 0 ; for ( int i = N / K ; i < N ; i += K - 1 ) { sum += A [ i ] ; } System . out . print ( sum ) ; } public static void main ( String [ ] args ) { int K = 4 ; int A [ ] = { 2 , 3 , 1 , 4 , 7 , 5 , 6 , 1 } ; int N = A . length ; findSum ( A , N , K ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . PriorityQueue ; class GFG { static int findSmallestNumLeft ( int arr [ ] , int N ) { PriorityQueue < Integer > PQ = new PriorityQueue < Integer > ( ( a , b ) -> b - a ) ; for ( int i = 0 ; i < N ; i ++ ) { PQ . add ( arr [ i ] ) ; } while ( PQ . size ( ) > 1 ) { int top1 = PQ . peek ( ) ; PQ . remove ( ) ; int top2 = PQ . peek ( ) ; PQ . remove ( ) ; PQ . add ( ( top1 + top2 + 1 ) / 2 ) ; } return PQ . peek ( ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 30 , 16 , 40 } ; int N = arr . length ; System . out . print ( findSmallestNumLeft ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static 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 int digitProduct ( int number ) { int product = 1 ; while ( number > 0 ) { product *= ( number % 10 ) ; number /= 10 ; } return product ; } static boolean compositedigitProduct ( int num ) { int res = digitProduct ( num ) ; if ( res == 1 ) { return false ; } if ( isComposite ( res ) ) { return true ; } return false ; } static int largestCompositeDigitProduct ( int a [ ] , int n , int k ) { Vector < pair > pq = new Vector < pair > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( i % k ) == 0 ) { continue ; } if ( compositedigitProduct ( a [ i ] ) ) { int b = digitProduct ( a [ i ] ) ; pq . add ( new pair ( b , a [ i ] ) ) ; } } Collections . sort ( pq , ( x , y ) -> x . first - y . first ) ; return pq . get ( pq . size ( ) - 1 ) . second ; } public static void main ( String [ ] args ) { int arr [ ] = { 233 , 144 , 89 , 71 , 13 , 21 , 11 , 34 , 55 , 23 } ; int n = arr . length ; int k = 3 ; int ans = largestCompositeDigitProduct ( arr , n , k ) ; System . out . print ( ans + "NEW_LINE"); } }

Index/key variables: i
Accumulator variables: i, number, product
Iterator variables: i
Class/struct names: GFG, pair
Java program:
import java . io . * ; import java . util . * ; class GFG { public static void findMinimum ( int arr [ ] , int N , int K ) { Arrays . sort ( arr ) ; int ans = 0 ; for ( int i = 1 ; i < 2 * ( N / K ) ; i += 2 ) { ans += arr [ i ] ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 11 , 20 , 5 , 7 , 8 , 14 , 2 , 17 , 16 , 10 } ; int N = arr . length ; int K = 5 ; findMinimum ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findSubarrays ( int arr [ ] , int N ) { Arrays . sort ( arr ) ; int i = 0 ; for ( i = 0 ; i < N - 1 ; i ++ ) { if ( arr [ i ] == arr [ i + 1 ] ) { System . out . println ( " YES " ) ; return ; } } System . out . println ( " NO " ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 4 , 3 , 0 , 1 , 2 , 0 } ; int N = arr . length ; findSubarrays ( arr , N ) ; } }

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