dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { final static int maxin = 10001 ; static int divisors [ ] = new int [ maxin + 1 ] ; static void Calc_Max_Div ( int arr [ ] , int n ) { int vis [ ] = new int [ maxin + 1 ] ; for ( int i = 0 ; i < maxin + 1 ; i ++ ) vis [ i ] = 1 ; vis [ 0 ] = vis [ 1 ] = 0 ; for ( int i = 1 ; i <= maxin ; i ++ ) divisors [ i ] = i ; for ( int i = 4 ; i <= maxin ; i += 2 ) { vis [ i ] = 0 ; divisors [ i ] = i / 2 ; } for ( int i = 3 ; i <= maxin ; i += 2 ) { if ( divisors [ i ] != i ) { divisors [ i ] = i / divisors [ i ] ; } if ( vis [ i ] == 1 ) { for ( int j = i * i ; j < maxin ; j += i ) { vis [ j ] = 0 ; if ( divisors [ j ] == j ) divisors [ j ] = i ; } } } for ( int i = 0 ; i < n ; i ++ ) { if ( divisors [ arr [ i ] ] == arr [ i ] ) System . out . print ( " - 1 ▁ " ) ; else System . out . print ( divisors [ arr [ i ] ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 5 , 6 , 7 , 8 , 9 , 10 } ; int n = arr . length ; Calc_Max_Div ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int sumOfDigit ( int n , int b ) { int unitDigit , sum = 0 ; while ( n > 0 ) { unitDigit = n % b ; sum += unitDigit ; n = n / b ; } return sum ; } public static void main ( String [ ] args ) { int n = 50 ; int b = 2 ; System . out . print ( sumOfDigit ( n , b ) ) ; } }

Accumulator variables: sum
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int nthDigit ( int a , int n , int b ) { for ( int i = 1 ; i < n ; i ++ ) a = a / b ; return a % b ; } public static void main ( String [ ] args ) { int a = 100 ; int n = 3 ; int b = 4 ; System . out . print ( nthDigit ( a , n , b ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int MAX = 100001 ; static ArrayList < Integer > primes ; static void initialize ( ) { boolean [ ] numbers = new boolean [ MAX + 1 ] ; int n = MAX ; for ( int i = 2 ; i * i <= n ; i ++ ) if ( ! numbers [ i ] ) for ( int j = i * i ; j <= n ; j += i ) numbers [ j ] = true ; for ( int i = 2 ; i <= n ; i ++ ) if ( numbers [ i ] == false ) primes . add ( i ) ; } static void findNums ( int num ) { boolean ans = false ; int first = - 1 , second = - 1 , third = - 1 ; for ( int i = 0 ; i < num ; i ++ ) { first = primes . get ( i ) ; for ( int j = 0 ; j < num ; j ++ ) { second = primes . get ( j ) ; third = num - first - second ; if ( Collections . binarySearch ( primes , third ) >= 0 ) { ans = true ; break ; } } if ( ans ) break ; } if ( ans ) System . out . println ( first + " ▁ " + second + " ▁ " + third ) ; else System . out . println ( - 1 ) ; } public static void main ( String [ ] args ) { int n = 101 ; primes = new ArrayList < > ( ) ; initialize ( ) ; findNums ( n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: ans
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printmaxSubseq ( int arr [ ] , int n ) { int i ; for ( i = 0 ; i < n ; i ++ ) { if ( i + 1 < n && arr [ i ] < arr [ i + 1 ] ) System . out . print ( arr [ i ] + " ▁ " ) ; else System . out . print ( arr [ i ] + "NEW_LINE"); } } public static void main ( String [ ] args ) { int arr [ ] = { 9 , 8 , 11 , 13 , 10 , 15 , 14 , 16 , 20 , 5 } ; int n = arr . length ; printmaxSubseq ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countSum ( int N , int L , int R ) { if ( L > R ) { return 0 ; } if ( N == 1 ) { return R - L + 1 ; } if ( N > 1 ) { return ( N - 2 ) * ( R - L ) + 1 ; } return 0 ; } public static void main ( String [ ] args ) { int N = 4 , L = 4 , R = 6 ; System . out . print ( countSum ( N , L , R ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int INT_MAX = Integer . MAX_VALUE ; static int solve ( int arr [ ] , int n , int k ) { int minx = INT_MAX ; int i ; for ( i = 0 ; i < n ; i ++ ) { minx = Math . min ( minx , arr [ i ] ) ; } int decrements = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( ( arr [ i ] - minx ) % k != 0 ) { return - 1 ; } else { decrements += ( ( arr [ i ] - minx ) / k ) ; } } return decrements ; } public static void main ( String [ ] args ) { int n , k ; n = 3 ; k = 3 ; int arr [ ] = { 12 , 9 , 15 } ; System . out . println ( solve ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: decrements, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int binomialCoeff ( int n , int k ) { int [ ] C = new int [ k + 1 ] ; C [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = Math . min ( i , k ) ; j > 0 ; j -- ) C [ j ] = C [ j ] + C [ j - 1 ] ; } return C [ k ] ; } static int count_of_subarrays ( int N ) { int count = binomialCoeff ( 2 * N - 1 , N ) ; return count ; } public static void main ( String [ ] args ) { int N = 3 ; System . out . print ( count_of_subarrays ( N ) + "NEW_LINE"); } }

Index/key variables: j, k
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int usingBinarySearch ( int start , int end , int N , int S ) { if ( start >= end ) return start ; int mid = start + ( end - start ) / 2 ; int totalSum = ( N * ( N + 1 ) ) / 2 ; int midSum = ( mid * ( mid + 1 ) ) / 2 ; if ( ( totalSum - midSum ) <= S ) { return usingBinarySearch ( start , mid , N , S ) ; } return usingBinarySearch ( mid + 1 , end , N , S ) ; } public static void main ( String [ ] args ) { int N , S ; N = 5 ; S = 11 ; System . out . println ( N - usingBinarySearch ( 1 , N , N , S ) + 1 ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void distribution ( int n , int k , int l , int r , int S , int Sk ) { int a [ ] = new int [ n ] ; int len = k , temp , rem , s ; int diff = S - Sk ; for ( int i = 0 ; i < len ; i ++ ) { temp = Sk / k ; rem = Sk % k ; if ( temp + rem >= l && temp + rem <= r ) { a [ i ] = temp ; } else if ( temp + rem > r ) { a [ i ] = r ; } else if ( temp + rem < r ) { System . out . print ( " - 1" ) ; return ; } Sk = Sk - a [ i ] ; k = k - 1 ; } if ( Sk > 0 ) { System . out . print ( " - 1" ) ; return ; } if ( len != 0 ) { k = n - len ; for ( int i = len ; i < n ; i ++ ) { temp = diff / k ; rem = diff % k ; if ( temp + rem >= l && temp + rem <= r ) { a [ i ] = temp ; } else if ( temp + rem > r ) { a [ i ] = r ; } else if ( temp + rem < r ) { System . out . print ( " - 1" ) ; return ; } diff = diff - a [ i ] ; k = k - 1 ; } if ( diff != 0 ) { System . out . print ( " - 1" ) ; return ; } } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( a [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int n = 5 , k = 3 , l = 1 , r = 5 , S = 13 , Sk = 9 ; distribution ( n , k , l , r , S , Sk ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int INT_MAX = Integer . MAX_VALUE ; static int min_index ( int p [ ] , int n ) { int ans = 0 ; int mini = INT_MAX ; for ( int i = 0 ; i < n ; i ++ ) { if ( p [ i ] <= mini ) mini = p [ i ] ; if ( mini == p [ i ] ) ans ++ ; } return ans ; } public static void main ( String [ ] args ) { int P [ ] = { 4 , 2 , 5 , 1 , 3 } ; int n = P . length ; System . out . println ( min_index ( P , n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void equal_xor_sum ( int arr [ ] , int n ) { int Sum = 0 ; int Xor = 0 ; for ( int i = 0 ; i < n ; i ++ ) { Sum = Sum + arr [ i ] ; Xor = Xor ^ arr [ i ] ; } if ( Sum == Xor ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 6 , 3 , 7 , 10 } ; int n = arr . length ; equal_xor_sum ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static final int MAX = 10 ; static int countPalindromes ( int n , int m , int matrix [ ] [ ] ) { int count = n * m ; int length_of_sequence_row ; int length_of_sequence_column ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { length_of_sequence_row = Math . min ( j , m - 1 - j ) ; length_of_sequence_column = Math . min ( i , n - i - 1 ) ; for ( int k = 1 ; k <= length_of_sequence_row ; k ++ ) { if ( matrix [ i ] [ j - k ] == matrix [ i ] [ j + k ] ) { count ++ ; } else { break ; } } for ( int k = 1 ; k <= length_of_sequence_column ; k ++ ) { if ( matrix [ i - k ] [ j ] == matrix [ i + k ] [ j ] ) { count ++ ; } else { break ; } } } } return count ; } public static void main ( String [ ] args ) { int m = 3 , n = 3 ; int matrix [ ] [ ] = { { 2 , 1 , 2 } , { 1 , 1 , 1 } , { 2 , 1 , 2 } } ; System . out . print ( countPalindromes ( n , m , matrix ) + "NEW_LINE"); } } `

Index/key variables: i, j
Accumulator variables: count, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
class GFG { static int set_bits ( int n ) { int count = 0 ; while ( n > 0 ) { count += n % 2 ; n /= 2 ; } return count ; } static int minSteps ( int n ) { int ans = 0 ; while ( n != 1 ) { if ( n % 2 == 0 ) n /= 2 ; else if ( n == 3 || set_bits ( n - 1 ) < set_bits ( n + 1 ) ) n -- ; else n ++ ; ans ++ ; } return ans ; } public static void main ( String [ ] args ) { int n = 15 ; System . out . print ( minSteps ( n ) ) ; } }

Accumulator variables: ans, count, n
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minimumNo ( int n ) { int ans = 0 ; Stack < Integer > stack1 = new Stack < Integer > ( ) ; Stack < Integer > stack2 = new Stack < Integer > ( ) ; while ( n != 0 ) { int r = n % 10 ; if ( r % 2 == 0 ) { stack1 . add ( r ) ; } else { stack2 . add ( r ) ; } n = n / 10 ; } while ( ! stack1 . isEmpty ( ) && ! stack2 . isEmpty ( ) ) { if ( stack1 . peek ( ) < stack2 . peek ( ) ) { ans = ans * 10 + stack1 . peek ( ) ; stack1 . pop ( ) ; } else { ans = ans * 10 + stack2 . peek ( ) ; stack2 . pop ( ) ; } } while ( ! stack1 . isEmpty ( ) ) { ans = ans * 10 + stack1 . peek ( ) ; stack1 . pop ( ) ; } while ( ! stack2 . isEmpty ( ) ) { ans = ans * 10 + stack2 . peek ( ) ; stack2 . pop ( ) ; } return ans ; } public static void main ( String [ ] args ) { int n1 = 64432 ; System . out . print ( minimumNo ( n1 ) + "NEW_LINE"); int n2 = 3137 ; System . out . print ( minimumNo ( n2 ) + "NEW_LINE"); } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int power ( int a , int b ) { int result = 1 ; while ( b > 0 ) { if ( b % 2 == 1 ) { result = result * a ; } a = a * a ; b = b / 2 ; } return result ; } static int factorial ( int n ) { int fact = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { fact = fact * i ; } return fact ; } static void findNoOfArrays ( int [ ] a , int n ) { int sum = 0 , s1 , c = 0 ; HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < 2 * n ; i ++ ) { if ( mp . get ( a [ i ] ) == null ) mp . put ( a [ i ] , 1 ) ; else mp . put ( a [ i ] , mp . get ( a [ i ] ) + 1 ) ; sum = sum + a [ i ] ; } boolean isArrayPossible = true ; int ans = factorial ( n - 1 ) ; s1 = sum / ( n + 1 ) ; if ( mp . get ( s1 ) >= 2 ) { mp . replace ( s1 , mp . get ( s1 ) - 2 ) ; } else { isArrayPossible = false ; } if ( isArrayPossible ) { for ( Map . Entry < Integer , Integer > m : mp . entrySet ( ) ) { if ( m . getKey ( ) == s1 - m . getKey ( ) ) { if ( mp . get ( m . getKey ( ) ) % 2 != 0 ) { isArrayPossible = false ; break ; } } if ( m . getKey ( ) != s1 - m . getKey ( ) ) { if ( mp . get ( m . getKey ( ) ) != mp . get ( s1 - m . getKey ( ) ) ) { isArrayPossible = false ; break ; } } if ( m . getValue ( ) > 0 ) { if ( m . getKey ( ) != s1 - m . getKey ( ) ) { c = c + m . getValue ( ) ; ans = ans * power ( 2 , m . getValue ( ) ) ; ans = ans / factorial ( m . getValue ( ) ) ; mp . replace ( m . getKey ( ) , 0 ) ; mp . replace ( s1 - m . getKey ( ) , 0 ) ; } if ( m . getKey ( ) == s1 - m . getKey ( ) ) { c = c + m . getValue ( ) / 2 ; ans = ans / factorial ( m . getValue ( ) / 2 ) ; mp . replace ( m . getKey ( ) , 0 ) ; } } } } if ( c < n - 1 && isArrayPossible == false ) { System . out . println ( "0" ) ; } else { System . out . println ( ans ) ; } } public static void main ( String args [ ] ) { int [ ] arr1 = { 5 , 2 , 3 , 5 } ; int n1 = arr1 . length ; findNoOfArrays ( arr1 , n1 / 2 ) ; int [ ] arr2 = { - 1 , - 1 , - 1 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 } ; int n2 = arr2 . length ; findNoOfArrays ( arr2 , n2 / 2 ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: isArrayPossible
Class/struct names: GFG
Java program:
class GFG { static int lcm ( int a , int b ) { return ( a / __gcd ( a , b ) * b ) ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } static void findNums ( int x ) { int ans = - 1 ; for ( int i = 1 ; i <= Math . sqrt ( x ) ; i ++ ) { if ( x % i == 0 && lcm ( i , x / i ) == x ) { ans = i ; } } System . out . print ( ans + " ▁ " + ( x / ans ) ) ; } public static void main ( String [ ] args ) { int x = 12 ; findNums ( x ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { final static int MAXN = 1000000 ; static int max_element ( int [ ] A , int n ) { int max = A [ 0 ] ; for ( int i = 0 ; i < n ; i ++ ) if ( A [ i ] > max ) max = A [ i ] ; return max ; } static int maxCommonElement ( int A [ ] , int D [ ] , int N ) { int cnt [ ] = new int [ MAXN ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = A [ i ] ; j < MAXN ; j += D [ i ] ) cnt [ j ] ++ ; } int ans = 0 ; int com = 0 ; for ( int i = 0 ; i < MAXN ; i ++ ) { if ( cnt [ i ] > ans ) { ans = cnt [ i ] ; com = i ; } } return com ; } public static void main ( String args [ ] ) { int A [ ] = { 13 , 1 , 2 , 5 } , D [ ] = { 5 , 10 , 1 , 12 } ; int N = A . length ; System . out . println ( maxCommonElement ( A , D , N ) ) ; } }

Index/key variables: MAXN, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findTrailingZeros ( int n ) { if ( ( n & 1 ) == 1 ) return 0 ; else { int ans = 0 ; n /= 2 ; while ( n != 0 ) { ans += n / 5 ; n /= 5 ; } return ans ; } } public static void main ( String [ ] args ) { int n = 12 ; System . out . println ( findTrailingZeros ( n ) ) ; } }

Accumulator variables: ans, n
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . Math ; class GFG { static int maxGCD ( int N , int K ) { int minSum = ( K * ( K + 1 ) ) / 2 ; if ( N < minSum ) return - 1 ; int i = ( int ) Math . sqrt ( N ) ; int res = 1 ; while ( i >= 1 ) { if ( N % i == 0 ) { if ( i >= minSum ) res = Math . max ( res , N / i ) ; if ( N / i >= minSum ) res = Math . max ( res , i ) ; } i -- ; } return res ; } public static void main ( String [ ] args ) { int N = 18 , K = 3 ; System . out . println ( maxGCD ( N , K ) ) ; } }

Accumulator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static double r1 , r2 , r3 ; static double area ( double a , double b , double c ) { double p = ( a + b + c ) / 2 ; return Math . sqrt ( p ) * Math . sqrt ( p - a ) * Math . sqrt ( p - b ) * Math . sqrt ( p - c ) ; } static double binary_search ( ) { double s = area ( r1 + r2 , r2 + r3 , r3 + r1 ) ; double l = 0 , h = s / ( r1 + r2 + r3 ) ; while ( h - l >= 1.e-7 ) { double mid = ( l + h ) / 2 ; double s1 = area ( mid + r1 , mid + r2 , r1 + r2 ) ; double s2 = area ( mid + r1 , mid + r3 , r1 + r3 ) ; double s3 = area ( mid + r2 , mid + r3 , r2 + r3 ) ; if ( s1 + s2 + s3 < s ) { l = mid ; } else { h = mid ; } } return ( l + h ) / 2 ; } public static void main ( String [ ] args ) { r1 = 1.0 ; r2 = 2.0 ; r3 = 3.0 ; System . out . printf ( " % .6f " , binary_search ( ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static void main ( String [ ] args ) { double r1 , r2 , r3 ; r1 = 1 ; r2 = 2 ; r3 = 3 ; double r4 = ( r1 * r2 * r3 ) / ( r1 * r2 + r2 * r3 + r1 * r3 + 2.0 * Math . sqrt ( r1 * r2 * r3 * ( r1 + r2 + r3 ) ) ) ; System . out . printf ( " % .6f " , r4 ) ; } }

Class/struct names: GFG
Java program:
public class GFG { static boolean checkZeroArray ( int [ ] arr , int n ) { int sum = 0 , maximum = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + arr [ i ] ; maximum = Math . max ( maximum , arr [ i ] ) ; } if ( sum % 2 == 0 && maximum <= sum / 2 ) return true ; return false ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 1 , 2 , 2 } ; int n = arr . length ; if ( checkZeroArray ( arr , n ) == true ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean subArray ( int [ ] arr , int n , int m ) { int i ; HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( i = 0 ; i < n ; i ++ ) { mp . put ( arr [ i ] , i + 1 ) ; } int sumcur = 0 ; int p = Integer . MAX_VALUE ; Vector < Integer > ans = new Vector < Integer > ( ) ; for ( i = 1 ; i <= m ; i ++ ) { sumcur += mp . get ( i ) ; p = Math . min ( p , mp . get ( i ) ) ; int val = p * i - i + ( i * ( i + 1 ) ) / 2 ; if ( i == m ) { if ( val == sumcur ) { return true ; } else return false ; } } return false ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 1 , 3 , 2 , 6 } ; int n = arr . length ; int m = 3 ; if ( subArray ( arr , n , m ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, sumcur
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean isPalindrome ( String s ) { int left = 0 , right = s . length ( ) - 1 ; while ( left <= right ) { if ( s . charAt ( left ) != s . charAt ( right ) ) { return false ; } left ++ ; right -- ; } return true ; } static long getSum ( int n ) { int start = ( int ) Math . pow ( 10 , n - 1 ) ; int end = ( int ) ( Math . pow ( 10 , n ) - 1 ) ; long sum = 0 ; for ( int i = start ; i <= end ; i ++ ) { String s = String . valueOf ( i ) ; if ( isPalindrome ( s ) ) { sum += i ; } } return sum ; } public static void main ( String [ ] args ) { int n = 1 ; long ans = getSum ( n ) ; System . out . print ( ans ) ; } }

Accumulator variables: i, left, right, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static double getSum ( int n ) { double sum = 0 ; if ( n == 1 ) { sum = 45.0 ; } else { sum = ( 99.0 / 2.0 ) * Math . pow ( 10 , n - 1 ) * Math . pow ( 10 , ( n - 1 ) / 2 ) ; } return sum ; } public static void main ( String [ ] args ) { int n = 3 ; double ans = getSum ( n ) ; System . out . print ( ans ) ; } }

Class/struct names: GFG
Java program:
class GFG { static long countPairs ( int arr [ ] , int n ) { long count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ i ] * arr [ j ] == arr [ i ] + arr [ j ] ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 0 , 3 , 2 , 0 } ; int n = arr . length ; System . out . println ( countPairs ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static long countPairs ( int arr [ ] , int n ) { int countZero = 0 ; int countTwo = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 0 ) countZero ++ ; else if ( arr [ i ] == 2 ) countTwo ++ ; } long pair0 = ( countZero * ( countZero - 1 ) ) / 2 ; long pair2 = ( countTwo * ( countTwo - 1 ) ) / 2 ; return pair0 + pair2 ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 0 , 3 , 2 , 0 } ; int n = arr . length ; System . out . println ( countPairs ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: countTwo, countZero, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int cntSubSeq ( int arr [ ] , int n ) { int pos_count = 0 ; int neg_count = 0 ; int result ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 ) pos_count ++ ; if ( arr [ i ] < 0 ) neg_count ++ ; } result = ( int ) Math . pow ( 2 , pos_count ) ; if ( neg_count > 0 ) result *= Math . pow ( 2 , neg_count - 1 ) ; result -= 1 ; return result ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , - 3 , - 1 , 4 } ; int n = arr . length ; System . out . print ( cntSubSeq ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, neg_count, pos_count, result
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int findMin ( int arr [ ] , int n ) { int m = 0 ; for ( int i = 0 ; i < n ; i ++ ) m = Math . max ( m , arr [ i ] ) ; int freq [ ] = new int [ m + 2 ] ; for ( int i = 0 ; i < n ; i ++ ) freq [ arr [ i ] ] ++ ; for ( int i = 1 ; i <= m + 1 ; i ++ ) { int j = i ; int cnt = 0 ; while ( j <= m ) { cnt += freq [ j ] ; j += i ; } if ( cnt == 0 ) return i ; } return m + 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 12 , 6 } ; int n = arr . length ; System . out . println ( findMin ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: cnt, i, j
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int findMin ( int arr [ ] , int n ) { int m = 0 ; for ( int i = 0 ; i < n ; i ++ ) m = Math . max ( m , arr [ i ] ) ; int cnt [ ] = new int [ m + 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 1 ; j * j <= arr [ i ] ; j ++ ) { if ( arr [ i ] % j == 0 ) { if ( j * j == arr [ i ] ) cnt [ j ] ++ ; else { cnt [ j ] ++ ; cnt [ arr [ i ] / j ] ++ ; } } } } for ( int i = 1 ; i <= m + 1 ; i ++ ) if ( cnt [ i ] == 0 ) { return i ; } return - 1 ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 12 , 6 } ; int n = arr . length ; System . out . println ( findMin ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static float findNumber ( int N , int S ) { float i = ( ( ( float ) ( N ) * ( float ) ( N + 1 ) ) / 4 ) - ( ( float ) ( S + 1 ) / 2 ) ; return i ; } static void check ( int N , int S ) { float i = findNumber ( N , S ) ; int integerI = ( int ) i ; if ( i - integerI == 0 ) System . out . println ( " Yes : ▁ " + integerI + " , ▁ " + ( integerI + 1 ) ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { int N = 4 , S = 3 ; check ( N , S ) ; N = 5 ; S = 3 ; check ( N , S ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int sz = ( int ) 1e5 ; static boolean [ ] isPrime = new boolean [ sz + 1 ] ; static void sieve ( ) { for ( int i = 0 ; i < sz + 1 ; i ++ ) isPrime [ i ] = 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 void printArray ( int arr [ ] , int len ) { for ( int i = 0 ; i < len ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } static void removePrimes ( int arr [ ] , int len ) { sieve ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( isPrime [ arr [ i ] ] ) { for ( int j = i ; j < len - 1 ; j ++ ) { arr [ j ] = arr [ j + 1 ] ; } i -- ; len -- ; } } printArray ( arr , len ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 6 , 5 , 3 , 8 , 7 , 10 , 11 , 14 , 15 } ; int len = arr . length ; removePrimes ( arr , len ) ; } }

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