dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static int minOR ( int [ ] arr , int n ) { if ( n == 1 ) return 0 ; int [ ] pre = new int [ n ] ; int [ ] suf = new int [ n ] ; pre [ 0 ] = arr [ 0 ] ; suf [ n - 1 ] = arr [ n - 1 ] ; for ( int i = 1 ; i < n ; i ++ ) pre [ i ] = ( pre [ i - 1 ] arr [ i ] ) ; for ( int i = n - 2 ; i >= 0 ; i -- ) suf [ i ] = ( suf [ i + 1 ] arr [ i ] ) ; int ans = Math . min ( pre [ n - 2 ] , suf [ 1 ] ) ; for ( int i = 1 ; i < n - 1 ; i ++ ) ans = Math . min ( ans , ( pre [ i - 1 ] suf [ i + 1 ] ) ) ; return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 } ; int n = arr . length ; System . out . print ( minOR ( arr , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean isPossible ( int x , int y ) { if ( ( x - y ) == 1 ) return false ; return true ; } public static void main ( String [ ] args ) { int x = 100 , y = 98 ; if ( isPossible ( x , y ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int subgrids ( int N , int Z , int row [ ] , int col [ ] , int r , int d ) { Vector < Integer > conrow = new Vector < Integer > ( ) ; Vector < Integer > concol = new Vector < Integer > ( ) ; int K = ( int ) Math . sqrt ( Z ) ; conrow . add ( row [ 0 ] - 0 - 1 ) ; conrow . add ( N + 1 - row [ r - 1 ] - 1 ) ; for ( int i = 1 ; i < r ; i ++ ) { conrow . add ( row [ i ] - row [ i - 1 ] - 1 ) ; } concol . add ( col [ 0 ] - 0 - 1 ) ; concol . add ( N + 1 - col [ d - 1 ] - 1 ) ; for ( int i = 1 ; i < d ; i ++ ) { concol . add ( col [ i ] - col [ i - 1 ] - 1 ) ; } int row_size = conrow . size ( ) ; int col_size = concol . size ( ) ; int answer = 0 ; for ( int i = 0 ; i < row_size ; i ++ ) { for ( int j = 0 ; j < col_size ; j ++ ) { int total = ( concol . get ( j ) / K ) * ( conrow . get ( i ) / K ) ; answer += ( total ) ; } } return answer ; } public static void main ( String [ ] args ) { int N = 8 , Z = 4 ; int row [ ] = { 4 , 6 } ; int col [ ] = { 3 , 8 } ; int r = row . length ; int d = col . length ; System . out . print ( subgrids ( N , Z , row , col , r , d ) ) ; } }

Index/key variables: i
Accumulator variables: answer, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int countDigits ( int n ) { int cnt = 0 ; while ( n > 0 ) { cnt ++ ; n /= 10 ; } return cnt ; } static int digitPowSum ( int n ) { int sum = 0 ; int pw = countDigits ( n ) ; while ( n > 0 ) { int d = n % 10 ; sum += Math . pow ( d , pw ) ; pw -- ; n /= 10 ; } return sum ; } static int countNum ( int n ) { int count = 0 ; for ( int i = 0 ; i <= n ; i ++ ) { if ( i == digitPowSum ( i ) ) { count ++ ; } } return count ; } public static void main ( String [ ] args ) { int n = 200 ; System . out . println ( countNum ( n ) ) ; } }

Accumulator variables: cnt, count, i, n, pw, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void perfectSquares ( int l , int r ) { for ( int i = l ; i <= r ; i ++ ) { if ( Math . sqrt ( i ) == ( int ) Math . sqrt ( i ) ) System . out . print ( i + " ▁ " ) ; } } public static void main ( String [ ] args ) { int l = 2 , r = 24 ; perfectSquares ( l , r ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void perfectSquares ( float l , float r ) { int number = ( int ) Math . ceil ( Math . sqrt ( l ) ) ; int n2 = number * number ; number = ( number * 2 ) + 1 ; while ( ( n2 >= l && n2 <= r ) ) { System . out . print ( n2 + " ▁ " ) ; n2 = n2 + number ; number += 2 ; } } public static void main ( String [ ] args ) { int l = 2 , r = 24 ; perfectSquares ( l , r ) ; } }

Accumulator variables: number
Class/struct names: GFG
Java program:
class GFG { static int xorK ( int n , int k ) { int res = n ; for ( int i = 1 ; i < k ; i ++ ) res = ( res ^ n ) ; return n ; } public static void main ( String [ ] args ) { int n = 123 , k = 3 ; System . out . print ( xorK ( n , k ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findRemainders ( long n ) { HashSet < Long > vc = new HashSet < Long > ( ) ; for ( long i = 1 ; i <= Math . ceil ( Math . sqrt ( n ) ) ; i ++ ) vc . add ( n / i ) ; for ( long i = ( long ) ( n / Math . ceil ( Math . sqrt ( n ) ) - 1 ) ; i >= 0 ; i -- ) vc . add ( i ) ; for ( long it : vc ) System . out . print ( it + " ▁ " ) ; } public static void main ( String [ ] args ) { long n = 5 ; findRemainders ( n ) ; } }

Accumulator variables: i
Iterator variables: i, it
Class/struct names: GFG
Java program:
class GFG { static int MAX = 100005 ; static boolean [ ] prime = new boolean [ MAX ] ; static void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < MAX ; i ++ ) prime [ i ] = true ; prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p < MAX ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i < MAX ; i += p ) prime [ i ] = false ; } } } static int countPrimes ( int n ) { SieveOfEratosthenes ( ) ; int cnt = 0 ; for ( int i = 2 ; i < n ; i ++ ) { if ( prime [ i ] && prime [ i - 2 ] ) cnt ++ ; } return cnt ; } public static void main ( String [ ] args ) { int n = 11 ; System . out . print ( countPrimes ( n ) ) ; } }

Index/key variables: MAX, i, p
Accumulator variables: cnt, i, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
class GFG { static int MAX_VALID_YR = 9999 ; static int MIN_VALID_YR = 1800 ; static boolean isLeap ( int year ) { return ( ( ( year % 4 == 0 ) && ( year % 100 != 0 ) ) || ( year % 400 == 0 ) ) ; } static boolean isValidDate ( int d , int m , int y ) { if ( y > MAX_VALID_YR y < MIN_VALID_YR ) return false ; if ( m < 1 m > 12 ) return false ; if ( d < 1 d > 31 ) return false ; if ( m == 2 ) { if ( isLeap ( y ) ) return ( d <= 29 ) ; else return ( d <= 28 ) ; } if ( m == 4 m == 6 m == 9 m == 11 ) return ( d <= 30 ) ; return true ; } static void printPalindromeDates ( int y1 , int y2 ) { for ( int year = y1 ; year <= y2 ; year ++ ) { String str = String . valueOf ( year ) ; String rev = str ; rev = reverse ( rev ) ; int day = Integer . parseInt ( rev . substring ( 0 , 2 ) ) ; int month = Integer . parseInt ( rev . substring ( 2 , 2 + 2 ) ) ; if ( isValidDate ( day , month , year ) ) { System . out . print ( rev + str + "NEW_LINE"); } } } static String reverse ( String input ) { char [ ] a = input . toCharArray ( ) ; int l , r = a . length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . valueOf ( a ) ; } public static void main ( String [ ] args ) { int y1 = 2001 , y2 = 2005 ; printPalindromeDates ( y1 , y2 ) ; } }

Index/key variables: l, r
Accumulator variables: l, r, year
Iterator variables: l, year
Class/struct names: GFG
Java program:
class GFG { static int MAX = 10 ; static boolean distinctDigits ( int x ) { boolean [ ] present = new boolean [ MAX ] ; while ( x > 0 ) { int digit = x % 10 ; if ( present [ digit ] ) return false ; present [ digit ] = true ; x /= 10 ; } return true ; } static int findK ( int l , int r ) { int maxExp = Integer . MIN_VALUE ; int k = - 1 ; for ( int i = l ; i <= r ; i ++ ) { if ( distinctDigits ( i ) ) { int exp = ( l - i ) * ( i - r ) ; if ( exp >= maxExp ) { k = i ; maxExp = exp ; } } } return k ; } public static void main ( String [ ] args ) { int l = 50 , r = 60 ; System . out . print ( findK ( l , r ) ) ; } }

Index/key variables: MAX, digit
Accumulator variables: i, x
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void findPerm ( int Q [ ] , int n ) { int minval = 0 , qsum = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { qsum += Q [ i ] ; if ( qsum < minval ) minval = qsum ; } int [ ] P = new int [ n ] ; P [ 0 ] = 1 - minval ; boolean permFound = true ; for ( int i = 0 ; i < n - 1 ; i ++ ) { P [ i + 1 ] = P [ i ] + Q [ i ] ; if ( P [ i + 1 ] > n P [ i + 1 ] < 1 ) { permFound = false ; break ; } } if ( permFound ) { for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( P [ i ] + " ▁ " ) ; } } else { System . out . print ( - 1 ) ; } } public static void main ( String [ ] args ) { int Q [ ] = { - 2 , 1 } ; int n = 1 + Q . length ; findPerm ( Q , n ) ; } }

Index/key variables: i, n
Accumulator variables: i, qsum
Iterator variables: i
Boolean variables: permFound
Class/struct names: GFG
Java program:
import java . util . * ; import java . util . HashMap ; import java . util . Map ; class GFG { static String Hex ( int num ) { HashMap < Integer , Character > m = new HashMap < Integer , Character > ( ) ; char digit = '0' ; char c = ' a ' ; for ( int i = 0 ; i <= 15 ; i ++ ) { if ( i < 10 ) { m . put ( i , digit ) ; digit ++ ; } else { m . put ( i , c ) ; c ++ ; } } String res = " " ; if ( num == 0 ) { return "0" ; } if ( num > 0 ) { while ( num != 0 ) { res = m . get ( num % 16 ) + res ; num /= 16 ; } } else { int n = num ; while ( n != 0 ) { res = m . get ( n % 16 ) + res ; n /= 16 ; } } return res ; } public static void main ( String [ ] args ) { int x = 134 , y = - 1 , z = - 234 ; System . out . println ( " Hexa ▁ representation ▁ for " ) ; System . out . println ( x + " ▁ is ▁ " + Hex ( x ) ) ; System . out . println ( y + " ▁ is ▁ " + Hex ( y ) ) ; System . out . println ( z + " ▁ is ▁ " + Hex ( z ) ) ; } }

Accumulator variables: c, digit, i, n, num
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void findWinner ( int n ) { if ( ( n - 1 ) % 6 == 0 ) { System . out . println ( " Second ▁ Player ▁ wins ▁ the ▁ game " ) ; } else { System . out . println ( " First ▁ Player ▁ wins ▁ the ▁ game " ) ; } } public static void main ( String [ ] args ) { int n = 7 ; findWinner ( n ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int N = 100005 ; static final int mod = ( int ) ( 1e9 + 7 ) ; static long [ ] factorial = new long [ N ] ; static long [ ] modinverse = new long [ N ] ; static long power ( long a , int m1 ) { if ( m1 == 0 ) return 1 ; else if ( m1 == 1 ) return a ; else if ( m1 == 2 ) return ( 1L * a * a ) % mod ; else if ( m1 % 2 == 1 ) return ( 1L * a * power ( power ( a , m1 / 2 ) , 2 ) ) % mod ; else return power ( power ( a , m1 / 2 ) , 2 ) % mod ; } static void factorialfun ( ) { factorial [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) factorial [ i ] = ( 1L * factorial [ i - 1 ] * i ) % mod ; } static void modinversefun ( ) { modinverse [ N - 1 ] = ( int ) ( power ( factorial [ N - 1 ] , mod - 2 ) % mod ) ; for ( int i = N - 2 ; i >= 0 ; i -- ) modinverse [ i ] = ( 1 * modinverse [ i + 1 ] * ( i + 1 ) ) % mod ; } static long binomial ( int n , int r ) { if ( r > n ) return 0 ; long a = ( 1L * factorial [ n ] * modinverse [ n - r ] ) % mod ; a = ( 1 * a * modinverse [ r ] ) % mod ; return a ; } static void arrange_balls ( int n , int k ) { factorialfun ( ) ; modinversefun ( ) ; for ( int i = 1 ; i <= k ; i ++ ) System . out . print ( ( 1L * binomial ( n - k + 1 , i ) * binomial ( k - 1 , i - 1 ) ) % mod + " ▁ " ) ; } public static void main ( String [ ] args ) { int n = 5 , k = 3 ; arrange_balls ( n , k ) ; } }

Index/key variables: N, i, n, r
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int min_changes ( int a [ ] , int n ) { int ans_a = 0 , ans_b = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { if ( a [ i ] == 0 ) ans_a ++ ; else ans_b ++ ; } else { if ( a [ i ] == 0 ) ans_b ++ ; else ans_a ++ ; } } return Math . min ( ans_a , ans_b ) ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 0 , 0 , 1 , 0 , 0 , 1 , 0 } ; int n = a . length ; System . out . println ( min_changes ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans_a, ans_b, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void ans ( int n ) { if ( n == 1 ) System . out . println ( "1" ) ; else System . out . println ( "0" ) ; } public static void main ( String [ ] args ) { int n = 2 ; ans ( n ) ; } }

Class/struct names: GFG
Java program:
class GFG { static boolean isPossible ( int w , int h , int x , int y ) { if ( x * 2 == w && y * 2 == h ) return true ; return false ; } public static void main ( String [ ] args ) { int w = 1 , h = 2 , x = 1 , y = 2 ; if ( isPossible ( w , h , x , y ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Class/struct names: GFG
Java program:
class GFG { static String minNum ( char num [ ] , int k ) { int len = num . length ; if ( len == 0 k == 0 ) { String num_str = new String ( num ) ; return num_str ; } if ( len == 1 ) return "0" ; if ( num [ 0 ] != '1' ) { num [ 0 ] = '1' ; k -- ; } int i = 1 ; while ( k > 0 && i < len ) { if ( num [ i ] != '0' ) { num [ i ] = '0' ; k -- ; } i ++ ; } String num_str = new String ( num ) ; return num_str ; } public static void main ( String args [ ] ) { String num = "91945" ; int k = 3 ; System . out . println ( minNum ( num . toCharArray ( ) , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, k
Class/struct names: GFG
Java program:
class GFG { static int minsteps ( int n , int m ) { if ( m > n ) { return - 1 ; } else { return ( ( n + 1 ) / 2 + m - 1 ) / m * m ; } } public static void main ( String [ ] args ) { int n = 17 , m = 4 ; int ans = minsteps ( n , m ) ; System . out . println ( ans ) ; } }

Class/struct names: GFG
Java program:
class GFG { static class Node { int data ; Node next ; } ; static Node removeLeadingZeros ( Node a ) { if ( a != null && a . data == 0 ) return removeLeadingZeros ( a . next ) ; else return a ; } static int getSize ( Node a ) { int sz = 0 ; while ( a != null ) { a = a . next ; sz ++ ; } return sz ; } static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head_ref ; head_ref = new_node ; return head_ref ; } static int compare ( Node a , Node b ) { a = removeLeadingZeros ( a ) ; b = removeLeadingZeros ( b ) ; int lenA = getSize ( a ) ; int lenB = getSize ( b ) ; if ( lenA > lenB ) { return 1 ; } else if ( lenB > lenA ) { return - 1 ; } while ( a != null && b != null ) { if ( a . data > b . data ) return 1 ; else if ( a . data < b . data ) return - 1 ; a = a . next ; b = b . next ; } return 0 ; } public static void main ( String [ ] args ) { Node a = null ; a = push ( a , 7 ) ; a = push ( a , 6 ) ; a = push ( a , 5 ) ; Node b = null ; b = push ( b , 3 ) ; b = push ( b , 3 ) ; b = push ( b , 2 ) ; System . out . println ( compare ( a , b ) ) ; } }

Accumulator variables: sz
Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { static int sumArr ( int arr [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; return sum ; } static int sumModArr ( int arr [ ] , int n ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { int subSum = 0 ; for ( int j = i + 1 ; j < n ; j ++ ) { subSum += arr [ j ] ; } arr [ i ] -= subSum ; } return sumArr ( arr , n ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 40 , 25 , 12 , 10 } ; int n = arr . length ; System . out . println ( sumModArr ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, subSum, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int minHealth ( int health [ ] , int n ) { int gcd = 0 ; for ( int i = 0 ; i < n ; i ++ ) { gcd = __gcd ( gcd , health [ i ] ) ; } return gcd ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int health [ ] = { 5 , 6 , 1 , 2 , 3 , 4 } ; int n = health . length ; System . out . println ( minHealth ( health , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
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 constructArr ( int pair [ ] , int n ) { int size = ( 1 + ( int ) Math . sqrt ( 1 + 8 * n ) ) / 2 ; int [ ] arr = new int [ size ] ; arr [ 0 ] = ( int ) Math . sqrt ( ( pair [ 0 ] * pair [ 1 ] ) / pair [ size - 1 ] ) ; for ( int i = 1 ; i < size ; i ++ ) arr [ i ] = pair [ i - 1 ] / arr [ 0 ] ; printArr ( arr , size ) ; } public static void main ( String [ ] args ) { int pair [ ] = { 48 , 18 , 24 , 24 , 32 , 12 } ; int n = pair . length ; constructArr ( pair , n ) ; } }

Index/key variables: i, size
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void findPairs ( int arr [ ] , int n ) { int cntEven = 0 , cntOdd = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) cntEven ++ ; else cntOdd ++ ; } int evenPairs = 0 ; evenPairs += ( ( cntEven * ( cntEven - 1 ) ) / 2 ) ; evenPairs += ( ( cntOdd * ( cntOdd - 1 ) ) / 2 ) ; int oddPairs = 0 ; oddPairs += ( cntEven * cntOdd ) ; System . out . println ( " Odd ▁ pairs ▁ = ▁ " + oddPairs ) ; System . out . println ( " Even ▁ pairs ▁ = ▁ " + evenPairs ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = arr . length ; findPairs ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: cntEven, cntOdd, evenPairs, i, oddPairs
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MOD = 1000000007 ; static int factMod ( int n ) { long fact = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { fact *= ( i % MOD ) ; fact %= MOD ; } return ( int ) fact ; } static int countWays ( int n , int m ) { return factMod ( m ) ; } public static void main ( String args [ ] ) { int n = 2 , m = 2 ; System . out . print ( countWays ( n , m ) ) ; } }

Accumulator variables: fact, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int binomialCoeff ( int n , int k ) { int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } static int Fuss_catalan ( int n ) { int c = binomialCoeff ( 3 * n , n ) ; return c / ( 2 * n + 1 ) ; } public static void main ( String [ ] args ) { for ( int i = 0 ; i < 10 ; i ++ ) System . out . print ( Fuss_catalan ( i ) + " ▁ " ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean isComposite ( int n ) { for ( int i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) return true ; } return false ; } static int Power ( int x , int y , int p ) { int res = 1 ; x = x % p ; while ( y > 0 ) { if ( y % 2 == 1 ) { res = ( res * x ) % p ; } x = ( x * x ) % p ; } return res ; } static boolean isEulerPseudoprime ( int N , int A ) { if ( A <= 0 ) return false ; if ( N % 2 == 0 || ! isComposite ( N ) ) return false ; if ( __gcd ( A , N ) != 1 ) return false ; int mod = Power ( A , ( N - 1 ) / 2 , N ) ; if ( mod != 1 && mod != N - 1 ) return false ; return true ; } static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int N = 121 , A = 3 ; if ( isEulerPseudoprime ( N , A ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int sz = ( int ) 1e5 ; static boolean [ ] isPrime = new boolean [ sz + 1 ] ; static void sieve ( ) { Arrays . fill ( isPrime , true ) ; isPrime [ 0 ] = isPrime [ 1 ] = false ; for ( int i = 2 ; i * i <= sz ; i ++ ) { if ( isPrime [ i ] ) { for ( int j = i * i ; j < sz ; j += i ) { isPrime [ j ] = false ; } } } } static int minDifference ( int L , int R ) { int fst = 0 ; for ( int i = L ; i <= R ; i ++ ) { if ( isPrime [ i ] ) { fst = i ; break ; } } int snd = 0 ; for ( int i = fst + 1 ; i <= R ; i ++ ) { if ( isPrime [ i ] ) { snd = i ; break ; } } if ( snd == 0 ) return - 1 ; int diff = snd - fst ; int left = snd + 1 ; int right = R ; for ( int i = left ; i <= right ; i ++ ) { if ( isPrime [ i ] ) { if ( i - snd <= diff ) { fst = snd ; snd = i ; diff = snd - fst ; } } } return diff ; } public static void main ( String [ ] args ) { sieve ( ) ; int L = 21 , R = 50 ; System . out . println ( minDifference ( L , R ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int findCnt ( int [ ] arr , int n , int k ) { int ret = 0 ; int i = 0 ; while ( i < n ) { int j = i + 1 ; while ( j < n && arr [ j ] >= arr [ j - 1 ] ) j ++ ; int x = Math . max ( 0 , j - i - k + 1 ) ; ret += ( x * ( x + 1 ) ) / 2 ; i = j ; } return ret ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 4 , 3 , 2 , 1 } ; int n = arr . length ; int k = 2 ; System . out . println ( findCnt ( arr , n , k ) ) ; } }

Index/key variables: j
Accumulator variables: j, ret
Class/struct names: GFG
Java program:
class GFG { static int countElements ( int p [ ] , int n ) { int ans = 0 ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( p [ i - 1 ] > p [ i ] && p [ i ] > p [ i + 1 ] ) ans ++ ; else if ( p [ i - 1 ] < p [ i ] && p [ i ] < p [ i + 1 ] ) ans ++ ; } return ans ; } public static void main ( String [ ] args ) { int p [ ] = { 2 , 5 , 1 , 3 , 4 } ; int n = p . length ; System . out . println ( countElements ( p , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countNums ( int a , int b , int c , int d ) { int x = b / c - ( a - 1 ) / c ; int y = b / d - ( a - 1 ) / d ; int k = ( c * d ) / __gcd ( c , d ) ; int z = b / k - ( a - 1 ) / k ; return b - a + 1 - x - y + z ; } static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int a = 10 , b = 50 , c = 4 , d = 6 ; System . out . println ( countNums ( a , b , c , d ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int cntSubArrays ( int [ ] arr , int n , int k ) { int res = 0 ; int i = 0 ; while ( i < n ) { int j = i + 1 ; while ( j < n && arr [ j ] >= arr [ j - 1 ] ) j ++ ; res += Math . max ( j - i - k + 1 , 0 ) ; i = j ; } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 2 , 5 } ; int n = arr . length ; int k = 2 ; System . out . println ( cntSubArrays ( arr , n , k ) ) ; } }

Index/key variables: j
Accumulator variables: j, res
Class/struct names: GFG
Java program:
class GFG { static void last_digit ( int X , int Y ) { System . out . print ( X % Y ) ; } public static void main ( String [ ] args ) { int X = 55 , Y = 3 ; last_digit ( X , Y ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int countSquares ( int n ) { return ( int ) ( Math . pow ( n , 2 ) - ( 2 * n ) + 2 ) ; } public static void main ( String [ ] args ) { int n = 2 ; System . out . println ( countSquares ( n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int geometricMean ( int n ) { return ( int ) Math . sqrt ( n ) ; } public static void main ( String [ ] args ) { int n = 16 ; System . out . println ( geometricMean ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int two_sets ( int a [ ] , int n ) { Arrays . sort ( a ) ; return a [ n / 2 ] - a [ ( n / 2 ) - 1 ] ; } public static void main ( String [ ] args ) { int a [ ] = { 1 , 4 , 4 , 6 , 7 , 9 } ; int n = a . length ; System . out . println ( two_sets ( a , n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int cntPairs ( int a [ ] , int n ) { int odd = 0 , even = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] % 2 == 1 ) odd ++ ; else if ( ( a [ i ] / 2 ) % 2 == 1 ) even ++ ; } int ans = odd * even + ( odd * ( odd - 1 ) ) / 2 ; return ans ; } public static void main ( String [ ] args ) { int a [ ] = { 4 , 2 , 7 , 11 , 14 , 15 , 18 } ; int n = a . length ; System . out . println ( cntPairs ( a , n ) ) ; } }

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