dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static void initialize ( int mul [ ] , int div [ ] , int size ) { for ( int i = 1 ; i < size ; i ++ ) { mul [ i ] = ( mul [ i ] * mul [ i - 1 ] ) / div [ i ] ; } } static void update ( int l , int r , int x , int mul [ ] , int div [ ] ) { mul [ l ] *= x ; div [ r + 1 ] *= x ; } static void printArray ( int ar [ ] , int mul [ ] , int div [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { ar [ i ] = ar [ i ] * mul [ i ] ; System . out . print ( ar [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int ar [ ] = { 10 , 5 , 20 , 40 } ; int n = ar . length ; int [ ] mul = new int [ n + 1 ] ; int [ ] div = new int [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { mul [ i ] = div [ i ] = 1 ; } update ( 0 , 1 , 10 , mul , div ) ; update ( 1 , 3 , 20 , mul , div ) ; update ( 2 , 2 , 2 , mul , div ) ; initialize ( mul , div , n + 1 ) ; printArray ( ar , mul , div , n ) ; } }

Index/key variables: i, l
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String getWinner ( String str , int len ) { int total = 0 ; for ( int i = 0 ; i < len ; i ++ ) { if ( str . charAt ( i ) == ' S ' ) { total ++ ; } } if ( ( total % 2 ) == 1 ) return " First " ; return " Second " ; } public static void main ( String [ ] args ) { String str = " GSSS " ; int len = str . length ( ) ; System . out . println ( getWinner ( str , len ) ) ; } }

Accumulator variables: i, total
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static final long MAX = 1000000000 ; static void findTriangle ( long S ) { long X1 = 0 , Y1 = 0 ; long X2 = MAX , Y2 = 1 ; long X3 = ( MAX - S % MAX ) % MAX ; long Y3 = ( S + X3 ) / MAX ; System . out . println ( " ( " + X1 + " , ▁ " + Y1 + " ) " ) ; System . out . println ( " ( " + X2 + " , ▁ " + Y2 + " ) " ) ; System . out . println ( " ( " + X3 + " , ▁ " + Y3 + " ) " ) ; } public static void main ( String [ ] args ) { long S = 4 ; findTriangle ( S ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printArr ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } static void findArrangement ( int arr [ ] , int n ) { if ( n < 2 ) { System . out . print ( " - 1" ) ; return ; } int minVal = Arrays . stream ( arr ) . min ( ) . getAsInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == minVal ) { swap ( arr , i , n - 1 ) ; break ; } } int andVal = arr [ 0 ] ; for ( int i = 1 ; i < n - 1 ; i ++ ) { andVal &= arr [ i ] ; } if ( andVal == arr [ n - 1 ] ) printArr ( arr , n ) ; else System . out . print ( " - 1" ) ; } static int [ ] swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 5 , 3 , 3 } ; int n = arr . length ; findArrangement ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: andVal, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int maxOperations ( int X , int Y ) { if ( X > Y ) return - 1 ; int diff = Y - X ; if ( diff == 1 ) return - 1 ; if ( diff % 2 == 0 ) return ( diff / 2 ) ; return ( 1 + ( ( diff - 3 ) / 2 ) ) ; } public static void main ( String [ ] args ) { int X = 5 , Y = 16 ; System . out . println ( maxOperations ( X , Y ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { final static int DIGITS = 10 ; final static int MAX = 10000 ; final static int MOD = 1000000007 ; static int dp [ ] [ ] = new int [ MAX ] [ DIGITS ] ; static int cnt [ ] [ ] = new int [ MAX ] [ DIGITS ] ; static void precompute ( ) { for ( int i = 0 ; i < DIGITS ; i ++ ) { dp [ 1 ] [ i ] = i ; cnt [ 1 ] [ i ] = 1 ; } for ( int i = 2 ; i < MAX ; i ++ ) { for ( int j = 0 ; j < DIGITS ; j ++ ) { for ( int k = 0 ; k < DIGITS ; k ++ ) { if ( j != k ) { dp [ i ] [ j ] = dp [ i ] [ j ] + ( dp [ i - 1 ] [ k ] + ( cnt [ i - 1 ] [ k ] * j ) % MOD ) % MOD ; dp [ i ] [ j ] %= MOD ; cnt [ i ] [ j ] += cnt [ i - 1 ] [ k ] ; cnt [ i ] [ j ] %= MOD ; } } } } } public static void main ( String [ ] args ) { int x = 6 , y = 4 ; precompute ( ) ; System . out . println ( dp [ x ] [ y ] ) ; } }

Index/key variables: DIGITS, MAX, i, j, k, x, y
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
class GFG { static int N = 10000 ; static int MOD = 1000000007 ; static int [ ] F = new int [ N ] ; static void precompute ( ) { F [ 1 ] = 2 ; F [ 2 ] = 3 ; F [ 3 ] = 4 ; for ( int i = 4 ; i < N ; i ++ ) F [ i ] = ( F [ i - 1 ] + F [ i - 2 ] ) % MOD ; } public static void main ( String [ ] args ) { int n = 8 ; precompute ( ) ; System . out . println ( F [ n ] ) ; } }

Index/key variables: N, i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxSubArraySum ( int a [ ] , int size ) { int max_so_far = Integer . MIN_VALUE , max_ending_here = 0 ; for ( int i = 0 ; i < size ; i ++ ) { max_ending_here = max_ending_here + a [ i ] ; if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; if ( max_ending_here < 0 ) max_ending_here = 0 ; } return max_so_far ; } static double minimizedSum ( int a [ ] , int n , int K ) { int sum = maxSubArraySum ( a , n ) ; double totalSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) totalSum += a [ i ] ; if ( sum < 0 ) return totalSum ; totalSum = totalSum - sum + ( double ) sum / ( double ) K ; return totalSum ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , - 2 , 3 } ; int n = a . length ; int K = 2 ; System . out . println ( minimizedSum ( a , n , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, totalSum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int findMin ( int N ) { int digit = N % 10 ; switch ( digit ) { case 0 : if ( N >= 90 ) return 10 ; break ; case 1 : if ( N >= 81 ) return 9 ; break ; case 2 : if ( N >= 72 ) return 8 ; break ; case 3 : if ( N >= 63 ) return 7 ; break ; case 4 : if ( N >= 54 ) return 6 ; break ; case 5 : if ( N >= 45 ) return 5 ; break ; case 6 : if ( N >= 36 ) return 4 ; break ; case 7 : if ( N >= 27 ) return 3 ; break ; case 8 : if ( N >= 18 ) return 2 ; break ; case 9 : if ( N >= 9 ) return 1 ; break ; } return - 1 ; } public static void main ( String [ ] args ) { int N = 27 ; System . out . println ( findMin ( N ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void printArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } static void randomList ( int m , int n ) { int arr [ ] = new int [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ ( int ) ( Math . random ( ) * m ) ] ++ ; } printArr ( arr , m ) ; } public static void main ( String args [ ] ) { int m = 4 , n = 8 ; randomList ( m , n ) ; } }

Index/key variables: i, m
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int maxPartition ( String s ) { int n = s . length ( ) , P = 0 ; String current = " " , previous = " " ; for ( int i = 0 ; i < n ; i ++ ) { current += s . charAt ( i ) ; if ( ! current . equals ( previous ) ) { previous = current ; current = " " ; P ++ ; } } return P ; } public static void main ( String [ ] args ) { String s = " geeksforgeeks " ; int ans = maxPartition ( s ) ; System . out . println ( ans ) ; } }

Accumulator variables: P, current, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static void main ( String [ ] args ) { int N = 4 , i , j , min ; System . out . println ( " Value ▁ of ▁ N : ▁ " + N ) ; for ( i = 1 ; i <= N ; i ++ ) { for ( j = 1 ; j <= N ; j ++ ) { min = i < j ? i : j ; System . out . print ( N - min + 1 ) ; } for ( j = N - 1 ; j >= 1 ; j -- ) { min = i < j ? i : j ; System . out . print ( N - min + 1 ) ; } System . out . println ( ) ; } } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findMissingPositive ( int arr [ ] , int n ) { int m = 1 ; HashSet < Integer > x = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( m < arr [ i ] ) { x . add ( arr [ i ] ) ; } else if ( m == arr [ i ] ) { m = m + 1 ; while ( x . contains ( m ) ) { x . remove ( m ) ; m = m + 1 ; } } } return m ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , - 7 , 6 , 8 , 1 , - 10 , 15 } ; int n = arr . length ; System . out . println ( findMissingPositive ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean prime ( int n ) { if ( n == 1 ) return false ; for ( int i = 2 ; i * i <= n ; ++ i ) if ( n % i == 0 ) return false ; return true ; } static int Min_Sum ( int n ) { if ( prime ( n ) ) return 1 ; if ( n % 2 == 0 ) return 2 ; else { if ( prime ( n - 2 ) ) return 2 ; else return 3 ; } } public static void main ( String [ ] args ) { int n = 27 ; System . out . println ( Min_Sum ( n ) ) ; } }

Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int find_maximum_value ( int a [ ] , int n ) { int sum = 0 ; int minimum = Integer . MAX_VALUE ; int pos = 0 , neg = 0 ; for ( int i = 0 ; i < n ; i ++ ) { minimum = Math . min ( minimum , Math . abs ( a [ i ] ) ) ; sum += Math . abs ( a [ i ] ) ; if ( a [ i ] >= 0 ) pos += 1 ; else neg += 1 ; } if ( pos > 0 && neg > 0 ) return sum ; return ( sum - 2 * minimum ) ; } public static void main ( String [ ] args ) { int [ ] a = { 5 , 4 , 6 , 2 } ; int n = a . length ; System . out . println ( find_maximum_value ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, neg, pos, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String find_number ( int N , int K ) { String r ; if ( N % 100 == 0 ) { N += 1 ; r = String . valueOf ( N ) ; } else { r = String . valueOf ( N ) ; } for ( int i = 1 ; i <= K ; i ++ ) r += "00" ; return r ; } public static void main ( String [ ] args ) { int N = 1000 , K = 2 ; String ans = find_number ( N , K ) ; System . out . println ( ans ) ; } }

Accumulator variables: N, i, r
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class Sol { static int countPairs ( String s ) { Set < Character > st = new HashSet < Character > ( ) ; st . add ( ' a ' ) ; st . add ( ' e ' ) ; st . add ( ' i ' ) ; st . add ( ' o ' ) ; st . add ( ' u ' ) ; int count = 0 ; int n = s . length ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( st . contains ( s . charAt ( i ) ) && ! st . contains ( s . charAt ( i + 1 ) ) ) count ++ ; } return count ; } public static void main ( String args [ ] ) { String s = " geeksforgeeks " ; System . out . println ( countPairs ( s ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: Sol
Java program:
import java . io . * ; class GFG { static void solve ( int d1 , int d2 , int d3 ) { int maxx = Math . max ( d1 , Math . max ( d2 , d3 ) ) ; int sum = ( d1 + d2 + d3 ) ; if ( 2 * maxx > sum sum % 2 == 1 ) { System . out . print ( " - 1" ) ; return ; } int x1 = 0 , y1 = 0 ; int x2 = d1 , y2 = 0 ; int x3 = ( d1 + d2 - d3 ) / 2 ; int y3 = ( d2 + d3 - d1 ) / 2 ; System . out . print ( " ( " + x1 + " , ▁ " + y1 + " ) , ▁ ( " + x2 + " , ▁ " + y2 + " ) ▁ and ▁ ( " + x3 + " , ▁ " + y3 + " ) " ) ; } public static void main ( String [ ] args ) { int d1 = 3 , d2 = 4 , d3 = 5 ; solve ( d1 , d2 , d3 ) ; } }

Class/struct names: GFG
Java program:
import static java . lang . Integer . max ; import java . util . * ; class GFG { static int maxSize ( Vector < Integer > v , int n ) { v . add ( 0 ) ; v . add ( 100001 ) ; n += 2 ; Collections . sort ( v ) ; int mx = 0 ; for ( int i = 1 ; i < n - 1 ; i ++ ) { int L = v . get ( i - 1 ) + 1 ; int R = v . get ( i + 1 ) - 1 ; int cnt = R - L + 1 ; mx = max ( mx , cnt ) ; } return mx ; } public static void main ( String [ ] args ) { Integer arr [ ] = { 200 , 10 , 5 } ; Vector v = new Vector ( Arrays . asList ( arr ) ) ; int n = v . size ( ) ; System . out . println ( maxSize ( v , n ) ) ; } }

Accumulator variables: i, n
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int maxLength ( int a [ ] , int n ) { int sum = 0 , len = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } { return n ; } for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] % 2 == 1 ) { len = Math . max ( len , Math . max ( n - i - 1 , i ) ) ; } } return len ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 2 , 3 , 2 } ; int n = a . length ; System . out . println ( maxLength ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void solve ( long n ) { long initial_array [ ] [ ] = new long [ ( int ) n - 1 ] [ ( int ) n - 1 ] , final_array [ ] [ ] = new long [ ( int ) n ] [ ( int ) n ] ; for ( long i = 0 ; i < n - 1 ; ++ i ) initial_array [ 0 ] [ ( int ) i ] = i + 1 ; for ( long i = 1 ; i < n - 1 ; ++ i ) for ( long j = 0 ; j < n - 1 ; ++ j ) initial_array [ ( int ) i ] [ ( int ) j ] = initial_array [ ( int ) i - 1 ] [ ( int ) ( ( int ) j + 1 ) % ( ( int ) n - 1 ) ] ; for ( long i = 0 ; i < n - 1 ; ++ i ) for ( long j = 0 ; j < n - 1 ; ++ j ) final_array [ ( int ) i ] [ ( int ) j ] = initial_array [ ( int ) i ] [ ( int ) j ] ; for ( long i = 0 ; i < n ; ++ i ) final_array [ ( int ) i ] [ ( int ) n - 1 ] = final_array [ ( int ) n - 1 ] [ ( int ) i ] = 0 ; for ( long i = 0 ; i < n ; ++ i ) { long t0 = final_array [ ( int ) i ] [ ( int ) i ] ; long t1 = final_array [ ( int ) i ] [ ( int ) n - 1 ] ; long s = final_array [ ( int ) i ] [ ( int ) i ] ; final_array [ ( int ) i ] [ ( int ) i ] = final_array [ ( int ) i ] [ ( int ) n - 1 ] ; final_array [ ( int ) i ] [ ( int ) n - 1 ] = s ; final_array [ ( int ) n - 1 ] [ ( int ) i ] = t0 ; } for ( long i = 0 ; i < n ; ++ i ) { for ( long j = 0 ; j < n ; ++ j ) System . out . print ( final_array [ ( int ) i ] [ ( int ) j ] + " ▁ " ) ; System . out . println ( ) ; } } public static void main ( String args [ ] ) { long n = 5 ; solve ( n ) ; } }

Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findPerm ( int n , Vector < Integer > differences ) { Vector < Integer > ans = new Vector < Integer > ( ) ; ans . clear ( ) ; ans . add ( 0 ) ; int x = 0 ; for ( int i = 0 ; i <= n - 2 ; ++ i ) { int diff = differences . get ( i ) ; x = x + diff ; ans . add ( x ) ; } Vector < Integer > anss = new Vector < Integer > ( ) ; for ( Integer obj : ans ) anss . add ( obj ) ; Collections . sort ( ans ) ; int flag = - 1 ; for ( int i = 1 ; i <= n - 1 ; ++ i ) { int res = ans . get ( i ) - ans . get ( i - 1 ) ; if ( res != 1 ) { flag = 0 ; } } if ( flag == 0 ) { System . out . print ( - 1 ) ; return ; } else { Map < Integer , Integer > mpp = new HashMap < > ( ) ; mpp . clear ( ) ; int j = 1 ; Vector < Integer > value_at_index = new Vector < Integer > ( ) ; for ( Integer x1 : ans ) { mpp . put ( x1 , j ) ; ++ j ; } for ( Integer x2 : anss ) { value_at_index . add ( mpp . get ( x2 ) ) ; } for ( Integer x3 : value_at_index ) { System . out . print ( x3 + " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { Vector < Integer > differences = new Vector < Integer > ( ) ; differences . add ( 2 ) ; differences . add ( - 3 ) ; differences . add ( 2 ) ; int n = differences . size ( ) + 1 ; findPerm ( n , differences ) ; } }

Iterator variables: i, obj, x1, x2, x3
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int getMinVal ( int p , int q ) { if ( q % p == 0 ) return p ; return - 1 ; } public static void main ( String [ ] args ) { int p = 24 , q = 48 ; System . out . println ( getMinVal ( p , q ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . Arrays ; class GfG { static boolean isPalindrome ( String str , int i , int j ) { while ( i < j ) { if ( str . charAt ( i ) != str . charAt ( j ) ) return false ; i ++ ; j -- ; } return true ; } static int countPrimePalindrome ( String str , int len ) { boolean [ ] prime = new boolean [ len + 1 ] ; Arrays . fill ( prime , true ) ; prime [ 0 ] = prime [ 1 ] = false ; for ( int p = 2 ; p * p <= len ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * p ; i <= len ; i += p ) prime [ i ] = false ; } } int count = 0 ; for ( int j = 2 ; j <= len ; j ++ ) { if ( prime [ j ] ) { for ( int i = 0 ; i + j - 1 < len ; i ++ ) { if ( isPalindrome ( str , i , i + j - 1 ) ) count ++ ; } } } return count ; } public static void main ( String [ ] args ) { String s = " geeksforgeeks " ; int len = s . length ( ) ; System . out . println ( countPrimePalindrome ( s , len ) ) ; } }

Index/key variables: i, j, p
Accumulator variables: count, i, j, p
Iterator variables: i, j, p
Class/struct names: GfG
Java program:
class GFG { static int minOperations ( int N ) { double x = Math . log ( N ) / Math . log ( 2 ) ; int ans = ( int ) ( Math . ceil ( x ) ) ; return ans ; } public static void main ( String [ ] args ) { int N = 10 ; System . out . println ( minOperations ( N ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int find_greatest_divisor ( int l , int r ) { if ( l == r ) { return l ; } return 1 ; } public static void main ( String [ ] args ) { int l = 2 , r = 12 ; System . out . println ( find_greatest_divisor ( l , r ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static double getProbability ( double p , double q ) { p /= 100 ; q /= 100 ; double probability = ( p * p + q * q ) / ( p + q ) ; return probability ; } public static void main ( String [ ] args ) { double p , q ; p = 80 ; q = 40 ; System . out . println ( getProbability ( p , q ) ) ; } }

Accumulator variables: p, q
Class/struct names: GFG
Java program:
class GFG { static boolean check ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 1 ) { return true ; } } return false ; } public static void main ( String args [ ] ) { int arr [ ] = { 3 , 9 , 12 , 13 , 15 } ; int n = arr . length ; if ( check ( arr , n ) ) { System . out . println ( " Odd ▁ Bit - wise ▁ OR " ) ; } else { System . out . println ( " Even ▁ Bit - wise ▁ OR " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void main ( String args [ ] ) { String st = "10010111" ; char [ ] str = st . toCharArray ( ) ; int lengthh = st . length ( ) ; int i = lengthh - 1 ; while ( str [ i ] == '1' ) { str [ i ] = '0' ; i -- ; } if ( i >= 0 ) str [ i ] = '1' ; System . out . print ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Class/struct names: GFG
Java program:
class GFG { public static void main ( String [ ] args ) { int n = 800000 ; double t = ( double ) System . nanoTime ( ) ; long sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += i ; t = ( double ) System . nanoTime ( ) - t ; System . out . println ( " sum ▁ is : ▁ " + Double . toString ( sum ) ) ; System . out . println ( " time ▁ taken ▁ by ▁ normal ▁ loops : " + Double . toString ( t / Math . pow ( 10.0 , 9.0 ) ) ) ; t = ( double ) System . nanoTime ( ) ; sum = 0 ; for ( int i = 1 ; i <= n ; i += 8 ) { sum += i ; sum += ( i + 1 ) ; sum += ( i + 2 ) ; sum += ( i + 3 ) ; sum += ( i + 4 ) ; sum += ( i + 5 ) ; sum += ( i + 6 ) ; sum += ( i + 7 ) ; } t = ( double ) System . nanoTime ( ) - t ; System . out . println ( " sum ▁ is : ▁ " + Double . toString ( sum ) ) ; System . out . println ( " time ▁ taken ▁ by ▁ normal ▁ loops : " + Double . toString ( t / Math . pow ( 10.0 , 9.0 ) ) ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int _log ( double x , double base ) { return ( int ) ( Math . log ( x ) / Math . log ( base ) ) ; } static double recursiveLogStar ( double n , double b ) { if ( n > 1.0 ) return 1.0 + recursiveLogStar ( _log ( n , b ) , b ) ; else return 0 ; } public static void main ( String [ ] args ) { int n = 100 , base = 5 ; System . out . println ( " Log * ( " + n + " ) ▁ = ▁ " + recursiveLogStar ( n , base ) ) ; } }

Class/struct names: GFG
Java program:
public static int iterativeLogStar ( double n , double b ) { int count = 0 ; while ( n >= 1 ) { n = _log ( n , b ) ; count ++ ; } return count ; }

Accumulator variables: count
Java program:
static void function ( int n ) { int count = 0 ; for ( int i = n / 2 ; i <= n ; i ++ ) for ( int j = 1 ; j <= n ; j = 2 * j ) for ( int k = 1 ; k <= n ; k = k * 2 ) count ++ ; }

Accumulator variables: count, i
Iterator variables: i, j, k
Java program:
import java . io . * ; public class GFG { static int findMaximum ( int arr [ ] , int size ) { int i = 0 , j = size - 1 , mid ; while ( i <= j ) { mid = i + ( j - i ) / 2 ; if ( arr [ mid ] < 0 ) i = mid + 1 ; else if ( arr [ mid ] > 0 ) j = mid - 1 ; } return Math . max ( i , size - i ) ; } public static void main ( String [ ] args ) { int arr [ ] = { - 9 , - 7 , - 4 , 1 , 5 , 8 , 9 } ; int N = arr . length ; System . out . println ( findMaximum ( arr , N ) ) ; } }

Index/key variables: mid
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static double maxKth ( int arr [ ] , int N , int C , int K ) { if ( N + C < K ) { return - 1 ; } int iter = 300 ; double l = 0 , r = 1000000000.0 ; while ( iter -- > 0 ) { double mid = ( l + r ) * 0.5 ; double a = 0 ; double b = 0 ; for ( int i = 0 ; i < N ; i ++ ) { a += ( int ) ( ( double ) arr [ i ] / mid ) ; if ( ( double ) arr [ i ] >= mid ) { b ++ ; } } if ( a >= K && b + C >= K ) { l = mid ; } else { r = mid ; } } return l ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 8 } ; int K = 1 , C = 1 ; int N = arr . length ; System . out . println ( maxKth ( arr , N , C , K ) ) ; } }

Index/key variables: i
Accumulator variables: a, b, i, iter
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . Arrays ; class GFG { static boolean isPossibleToSelect ( int [ ] arr , int N , int dif , int K ) { int count = 1 ; int prev = arr [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ i ] >= ( prev + dif ) ) { count ++ ; if ( count == K ) return true ; prev = arr [ i ] ; } } return false ; } static int binarySearch ( int [ ] arr , int left , int right , int K , int N ) { int ans = 1 ; while ( left <= right ) { int dif = left + ( right - left ) / 2 ; if ( isPossibleToSelect ( arr , N , dif , K ) ) { ans = Math . max ( ans , dif ) ; left = dif + 1 ; } else right = dif - 1 ; } return ans ; } public static void main ( String [ ] args ) { int N , K ; N = 7 ; K = 4 ; int [ ] arr = { 1 , 4 , 9 , 0 , 2 , 13 , 3 } ; Arrays . sort ( arr ) ; System . out . println ( binarySearch ( arr , 0 , arr [ N - 1 ] , K , N ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . util . Arrays ; class GFG { static int cal ( int arr [ ] , int mid ) { int chocolate = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] >= mid ) chocolate += arr [ i ] - mid ; } return chocolate ; } static int maximumCut ( int arr [ ] , int K ) { int low = 0 ; int high = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; while ( low <= high ) { int mid = ( low + high ) / 2 ; int chocolate = cal ( arr , mid ) ; if ( chocolate == K ) return mid ; else if ( chocolate < K ) high = mid - 1 ; else { low = mid + 1 ; if ( mid > high ) high = mid ; } } return high ; } public static void main ( String [ ] args ) { int K = 7 ; int arr [ ] = { 15 , 20 , 8 , 17 } ; System . out . println ( maximumCut ( arr , K ) ) ; } }

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