dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static int N = 3 ; static int M = 3 ; static void intializeDiff ( int D [ ] [ ] , int A [ ] [ ] ) { for ( int i = 0 ; i < N ; i ++ ) { D [ i ] [ 0 ] = A [ i ] [ 0 ] ; D [ i ] [ M ] = 0 ; } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 1 ; j < M ; j ++ ) D [ i ] [ j ] = A [ i ] [ j ] - A [ i ] [ j - 1 ] ; } } static void update ( int D [ ] [ ] , int k , int r1 , int c1 , int r2 , int c2 ) { for ( int i = r1 ; i <= r2 ; i ++ ) { D [ i ] [ c1 ] += k ; D [ i ] [ c2 + 1 ] -= k ; } } static void printArray ( int A [ ] [ ] , int D [ ] [ ] ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( j == 0 ) A [ i ] [ j ] = D [ i ] [ j ] ; else A [ i ] [ j ] = D [ i ] [ j ] + A [ i ] [ j - 1 ] ; System . out . print ( A [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; } } static void performQueries ( int A [ ] [ ] , Vector < Vector < Integer > > Queries ) { int D [ ] [ ] = new int [ N ] [ M + 1 ] ; intializeDiff ( D , A ) ; int Q = Queries . size ( ) ; for ( int i = 0 ; i < Q ; i ++ ) { update ( D , Queries . get ( i ) . get ( 0 ) , Queries . get ( i ) . get ( 1 ) , Queries . get ( i ) . get ( 2 ) , Queries . get ( i ) . get ( 3 ) , Queries . get ( i ) . get ( 4 ) ) ; } printArray ( A , D ) ; } public static void main ( String [ ] args ) { int A [ ] [ ] = { { 1 , 2 , 3 } , { 1 , 1 , 0 } , { 4 , - 2 , 2 } } ; Vector < Vector < Integer > > Queries = new Vector < Vector < Integer > > ( ) ; Vector < Integer > list1 = new Vector < Integer > ( ) ; list1 . add ( 2 ) ; list1 . add ( 0 ) ; list1 . add ( 0 ) ; list1 . add ( 1 ) ; list1 . add ( 1 ) ; Vector < Integer > list2 = new Vector < Integer > ( ) ; list2 . add ( - 1 ) ; list2 . add ( 1 ) ; list2 . add ( 0 ) ; list2 . add ( 2 ) ; list2 . add ( 2 ) ; Queries . add ( list1 ) ; Queries . add ( list2 ) ; performQueries ( A , Queries ) ; } }

Index/key variables: M, N, c1, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; import java . io . * ; import java . lang . * ; class GFG { static int onesComplement ( int n , int maxElement ) { int bits = ( int ) Math . floor ( ( Math . log ( maxElement ) / Math . log ( 2 ) ) ) + 1 ; return ( ( 1 << bits ) - 1 ) ^ n ; } static int findNumber ( int arr [ ] , int n ) { int res = 0 ; int maxElement = 0 ; for ( int i = 0 ; i < n ; i ++ ) { res = res ^ arr [ i ] ; if ( maxElement < arr [ i ] ) maxElement = arr [ i ] ; } res = onesComplement ( res , maxElement ) ; return ( res ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int N = arr . length ; System . out . print ( findNumber ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int [ ] calculateFactorial ( int N ) { int [ ] fact = new int [ N + 1 ] ; fact [ 0 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { fact [ i ] = fact [ i - 1 ] * i ; } return fact ; } static int cntWaysSelection ( int arr [ ] , int N , int K , int L , int R ) { int cntWays = 0 ; int cntNum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] >= L && arr [ i ] <= R ) { cntNum ++ ; } } int [ ] fact = calculateFactorial ( cntNum ) ; for ( int i = K ; i <= cntNum ; i ++ ) { cntWays += fact [ cntNum ] / ( fact [ i ] * fact [ cntNum - i ] ) ; } return cntWays ; } public static void main ( String [ ] args ) { int arr [ ] = { 12 , 4 , 6 , 13 , 5 , 10 } ; int N = arr . length ; int K = 3 ; int L = 4 ; int R = 10 ; System . out . print ( cntWaysSelection ( arr , N , K , L , R ) ) ; } }

Index/key variables: cntNum, i
Accumulator variables: cntNum, cntWays, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int TotalAndPair ( int arr [ ] , int N ) { int totalAND = ( 1 << 30 ) - 1 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { totalAND &= arr [ i ] & arr [ j ] ; } } return totalAND ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 12 , 15 } ; int N = arr . length ; System . out . print ( TotalAndPair ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, totalAND
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int smallestDivisorGr1 ( int N ) { for ( int i = 2 ; i <= Math . sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) { return i ; } } return N ; } static int findValOfNWithOperat ( int N , int K ) { for ( int i = 1 ; i <= K ; i ++ ) { N += smallestDivisorGr1 ( N ) ; } return N ; } public static void main ( String [ ] args ) { int N = 6 , K = 4 ; System . out . print ( findValOfNWithOperat ( N , K ) ) ; } }

Accumulator variables: N, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int M = 1000000007 ; static int findTripleSum ( int A , int B , int C ) { int sum = 0 ; for ( int i = 1 ; i <= A ; i ++ ) { for ( int j = 1 ; j <= B ; j ++ ) { for ( int k = 1 ; k <= C ; k ++ ) { int prod = ( ( ( i % M ) * ( j % M ) ) % M * ( k % M ) ) % M ; sum = ( sum + prod ) % M ; } } } return sum ; } public static void main ( String args [ ] ) { int A = 10 ; int B = 100 ; int C = 1000 ; System . out . println ( findTripleSum ( A , B , C ) ) ; } }

Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int M = 1000000007 ; static long power ( long x , long N ) { long res = 1 ; while ( N > 0 ) { if ( N % 2 == 1 ) { res = ( res * x ) % M ; } x = ( x * x ) % M ; N = N >> 1 ; } return res ; } static long modinv ( long X ) { return power ( X , M - 2 ) ; } static long findTripleSum ( long A , long B , long C ) { long MMI = modinv ( 8 ) ; long res = 0 ; res = ( ( ( ( A % M * ( A + 1 ) % M ) % M * ( B % M * ( B + 1 ) % M ) % M ) % M * ( C % M * ( C + 1 ) % M ) % M ) % M * MMI ) % M ; return res ; } public static void main ( String [ ] args ) { long A = 10 ; long B = 100 ; long C = 1000 ; System . out . print ( findTripleSum ( A , B , C ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int getMaximum ( int N , int M , int [ ] [ ] mat ) { int global_max = Integer . MIN_VALUE ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { int row_min = Integer . MAX_VALUE ; for ( int k = 0 ; k < M ; k ++ ) { int m = Math . max ( mat [ i ] [ k ] , mat [ j ] [ k ] ) ; row_min = Math . min ( row_min , m ) ; } global_max = Math . max ( global_max , row_min ) ; } } return global_max ; } public static void main ( String [ ] args ) { int [ ] [ ] mat = { { 5 , 0 , 3 , 1 , 2 } , { 1 , 8 , 9 , 1 , 3 } , { 1 , 2 , 3 , 4 , 5 } , { 9 , 1 , 0 , 3 , 7 } , { 2 , 3 , 0 , 6 , 3 } , { 6 , 4 , 1 , 7 , 0 } } ; int N = 6 , M = 5 ; System . out . println ( getMaximum ( N , M , mat ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
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 makeTree ( Vector < Integer > tree [ ] , pair edges [ ] , int N ) { for ( int i = 0 ; i < N - 1 ; i ++ ) { int u = edges [ i ] . first ; int v = edges [ i ] . second ; tree [ u ] . add ( v ) ; } } static pair dfs ( int node , Vector < Integer > tree [ ] ) { int mex = 0 ; int size = 1 ; for ( int u : tree [ node ] ) { pair temp = dfs ( u , tree ) ; mex = Math . max ( mex , temp . first ) ; size += temp . second ; } return new pair ( mex + size , size ) ; } public static void main ( String [ ] args ) { int N = 7 ; pair edges [ ] = { new pair ( 1 , 4 ) , new pair ( 1 , 5 ) , new pair ( 5 , 2 ) , new pair ( 5 , 3 ) , new pair ( 4 , 7 ) , new pair ( 7 , 6 ) } ; @ SuppressWarnings ( " unchecked " ) Vector < Integer > [ ] tree = new Vector [ N + 1 ] ; for ( int i = 0 ; i < tree . length ; i ++ ) tree [ i ] = new Vector < Integer > ( ) ; makeTree ( tree , edges , N ) ; System . out . print ( ( dfs ( 1 , tree ) . first ) ) ; } }

Index/key variables: i, node, u
Accumulator variables: i, size
Iterator variables: i, u
Class/struct names: GFG, pair
Java program:
import java . util . * ; class GFG { static int divisorCount ( int n ) { int x = 0 ; for ( int i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i == n / i ) x ++ ; else x += 2 ; } } return x ; } static int minvalue_y ( int x ) { int a = divisorCount ( x ) ; int y = x + 1 ; while ( ( a & 1 ) == ( divisorCount ( y ) & 1 ) ) y ++ ; return y ; } public static void main ( String [ ] args ) { int x = 5 ; System . out . println ( minvalue_y ( x ) ) ; } }

Accumulator variables: i, x, y
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minvalue_y ( int x ) { int n = ( int ) Math . sqrt ( x ) ; if ( n * n == x ) return x + 1 ; return ( int ) Math . pow ( n + 1 , 2 ) ; } public static void main ( String [ ] args ) { int x = 5 ; System . out . print ( minvalue_y ( x ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int alternatingSumOfFirst_N ( int N ) { int alternateSum = 0 ; if ( N % 2 == 0 ) { alternateSum = ( - N ) / 2 ; } else { alternateSum = ( N + 1 ) / 2 ; } return alternateSum ; } public static void main ( String [ ] args ) { int N = 6 ; System . out . print ( alternatingSumOfFirst_N ( N ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minStartValue ( int [ ] nums ) { int minValue = 0 ; int sum = 0 ; for ( int n : nums ) { sum += n ; minValue = Math . min ( minValue , sum ) ; } int startValue = 1 - minValue ; return startValue ; } public static void main ( String [ ] args ) { int [ ] nums = { - 3 , 2 , - 3 , 4 , 2 } ; System . out . println ( minStartValue ( nums ) ) ; } }

Accumulator variables: sum
Iterator variables: n
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countSubArrayRemove ( int [ ] arr , int N ) { HashMap < Integer , Integer > prefix_element_count = new HashMap < Integer , Integer > ( ) ; HashMap < Integer , Integer > suffix_element_count = new HashMap < Integer , Integer > ( ) ; int total_sum_of_elements = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { total_sum_of_elements += arr [ i ] ; if ( ! suffix_element_count . containsKey ( arr [ i ] ) ) suffix_element_count . put ( arr [ i ] , 1 ) ; else suffix_element_count . put ( arr [ i ] , suffix_element_count . get ( arr [ i ] ) + 1 ) ; } int prefix_sum = 0 ; int suffix_sum = 0 ; int count_subarray_equal_sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { prefix_sum += arr [ i ] ; if ( ! prefix_element_count . containsKey ( arr [ i ] ) ) prefix_element_count . put ( arr [ i ] , 1 ) ; else prefix_element_count . put ( arr [ i ] , prefix_element_count . get ( arr [ i ] ) + 1 ) ; suffix_sum = total_sum_of_elements - prefix_sum ; if ( ! suffix_element_count . containsKey ( arr [ i ] ) ) suffix_element_count . put ( arr [ i ] , 0 ) ; else suffix_element_count . put ( arr [ i ] , suffix_element_count . get ( arr [ i ] ) - 1 ) ; int difference = prefix_sum - suffix_sum ; int number_of_subarray_at_i_split = 0 ; if ( prefix_element_count . containsKey ( difference ) ) number_of_subarray_at_i_split = prefix_element_count . get ( difference ) ; if ( suffix_element_count . containsKey ( - difference ) ) number_of_subarray_at_i_split += suffix_element_count . get ( - difference ) ; count_subarray_equal_sum += number_of_subarray_at_i_split ; } return count_subarray_equal_sum ; } public static void main ( String args [ ] ) { int [ ] arr = { 1 , 2 , 1 , 1 , 3 , 1 } ; int N = arr . length ; System . out . println ( countSubArrayRemove ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: count_subarray_equal_sum, i, number_of_subarray_at_i_split, prefix_sum, total_sum_of_elements
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int countXORSetBitsAdjElemRange1_N ( int N ) { int total_set_bits = 0 ; int bit_Position = 1 ; while ( N != 0 ) { total_set_bits += ( ( N + 1 ) / 2 * bit_Position ) ; N -= ( N + 1 ) / 2 ; bit_Position ++ ; } return total_set_bits ; } public static void main ( String [ ] args ) { int N = 4 ; System . out . println ( countXORSetBitsAdjElemRange1_N ( N ) ) ; } }

Accumulator variables: N, bit_Position, total_set_bits
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int checkPerfectSquare ( int N ) { if ( N <= 0 ) { return 0 ; } double sq = Math . sqrt ( N ) ; if ( Math . floor ( sq ) == Math . ceil ( sq ) ) { return 1 ; } return 0 ; } static boolean checktwoSidesareRighTriangle ( int A , int B ) { boolean checkTriangle = false ; if ( checkPerfectSquare ( A * A + B * B ) != 0 ) { checkTriangle = true ; } if ( checkPerfectSquare ( A * A - B * B ) != 0 ) { checkTriangle = true ; } if ( checkPerfectSquare ( B * B - A * A ) != 0 ) { checkTriangle = true ; } return checkTriangle ; } public static void main ( String [ ] args ) { int A = 3 , B = 4 ; if ( checktwoSidesareRighTriangle ( A , B ) ) { System . out . print ( " Yes " ) ; } else { System . out . print ( " No " ) ; } } }

Boolean variables: checkTriangle
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int array_sum ( int arr [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; return sum ; } static int countOperations ( int arr [ ] , int N ) { int count_zeros = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 0 ) count_zeros ++ ; } int sum = array_sum ( arr , N ) ; if ( count_zeros != 0 ) return count_zeros ; if ( sum == 0 ) return 1 ; return 0 ; } public static void main ( String [ ] args ) { int arr [ ] = { - 1 , - 1 , 0 , 0 } ; int N = arr . length ; System . out . print ( countOperations ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: count_zeros, i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int TotalBitwiseORPair ( int arr [ ] , int N ) { int totalOR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { totalOR |= arr [ i ] ; } return totalOR ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 12 , 15 } ; int N = arr . length ; System . out . print ( TotalBitwiseORPair ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, totalOR
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findDifference ( int [ ] p , int [ ] q , int N ) { int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) A [ i ] = i + 1 ; boolean IsCorrect ; int a = 1 , b = 1 ; do { IsCorrect = true ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] != p [ i ] ) { IsCorrect = false ; break ; } } if ( IsCorrect ) break ; a ++ ; } while ( next_permutation ( A ) ) ; for ( int i = 0 ; i < N ; i ++ ) A [ i ] = i + 1 ; do { IsCorrect = true ; for ( int i = 0 ; i < N ; i ++ ) { if ( A [ i ] != q [ i ] ) { IsCorrect = false ; break ; } } if ( IsCorrect ) break ; b ++ ; } while ( next_permutation ( A ) ) ; System . out . print ( Math . abs ( a - b ) + "NEW_LINE"); } static boolean next_permutation ( int [ ] p ) { for ( int a = p . length - 2 ; a >= 0 ; -- a ) if ( p [ a ] < p [ a + 1 ] ) for ( int b = p . length - 1 ; ; -- b ) if ( p [ b ] > p [ a ] ) { int t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; for ( ++ a , b = p . length - 1 ; a < b ; ++ a , -- b ) { t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; } return true ; } return false ; } public static void main ( String [ ] args ) { int [ ] p = { 1 , 3 , 2 } ; int [ ] q = { 3 , 1 , 2 } ; int n = p . length ; findDifference ( p , q , n ) ; } }

Index/key variables: N, a, b, i
Accumulator variables: a, b, i
Iterator variables: a, b, i
Boolean variables: IsCorrect
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printFinalArray ( int [ ] a , int n , int [ ] operations , int p , int capacity ) { int i , curr = 0 ; boolean picked = false ; for ( i = 0 ; i < p ; i ++ ) { int s = operations [ i ] ; boolean flag = false ; switch ( s ) { case 1 : if ( curr != 0 ) curr -- ; break ; case 2 : if ( curr != n - 1 ) curr ++ ; break ; case 3 : if ( picked == false && a [ curr ] != 0 ) { picked = true ; a [ curr ] -- ; } break ; case 4 : if ( picked == true && a [ curr ] != capacity ) { picked = false ; a [ curr ] ++ ; } break ; default : flag = true ; } if ( flag == true ) break ; } for ( i = 0 ; i < n ; i ++ ) { System . out . print ( a [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int capacity = 5 ; int a [ ] = { 2 , 5 , 2 } ; int N = a . length ; int operations [ ] = { 3 , 2 , 4 , 1 , 4 , 5 } ; int M = operations . length ; printFinalArray ( a , N , operations , M , capacity ) ; } }

Index/key variables: curr, i
Accumulator variables: curr, i
Iterator variables: i
Boolean variables: flag, picked
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static boolean isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static void CheckSumPrime ( int [ ] A , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { String s = Integer . toString ( A [ i ] ) ; sum += s . length ( ) ; } if ( isPrime ( sum ) == true ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } public static void main ( String [ ] args ) { int [ ] A = { 1 , 11 , 12 } ; int N = A . length ; CheckSumPrime ( A , N ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int power ( int x , int N ) { int res = 1 ; while ( N > 0 ) { if ( N % 2 == 1 ) { res = ( res * x ) ; } x = ( x * x ) ; N = N >> 1 ; } return res ; } static void probablityPrimeprod ( int N ) { int N_E = 3 * N ; int N_S = power ( 6 , N ) ; System . out . print ( N_E + " ▁ / ▁ " + N_S ) ; } public static void main ( String [ ] args ) { int N = 2 ; probablityPrimeprod ( N ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . Math ; class GFG { static boolean checkPalindrome ( int N ) { int rev = 0 ; int temp = N ; while ( N != 0 ) { rev = rev * 10 + N % 10 ; N = N / 10 ; } N = temp ; if ( N == rev ) { return true ; } return false ; } static int closestSmallerPalindrome ( int N ) { do { N -- ; } while ( N >= 0 && ! checkPalindrome ( N ) ) ; return N ; } public static void main ( String [ ] args ) { int N = 4000 ; System . out . println ( closestSmallerPalindrome ( N ) ) ; } }

Accumulator variables: N
Class/struct names: GFG
Java program:
class GFG { static int MinimumOperationReq ( int N ) { int cntDecr = 0 ; int temp = N ; while ( temp > 0 ) { int X = ( int ) Math . sqrt ( temp ) ; if ( X * X == temp ) { break ; } temp = temp - 2 ; cntDecr += 1 ; } int cntIncr = 0 ; while ( true ) { int X = ( int ) Math . sqrt ( N ) ; if ( X * X == N ) { break ; } N = N + 2 ; cntIncr += 1 ; } return Math . min ( cntIncr , cntDecr ) ; } public static void main ( String args [ ] ) { int N = 15 ; System . out . print ( MinimumOperationReq ( N ) ) ; } }

Accumulator variables: cntDecr, cntIncr
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int M = 1000000007 ; static long power ( long x , long N ) { long res = 1 ; while ( N > 0 ) { if ( N % 2 == 1 ) { res = ( res * x ) % M ; } x = ( x * x ) % M ; N = N >> 1 ; } return res ; } static long moduloInverse ( long X ) { return power ( X , M - 2 ) ; } static long F_1 ( long N , long F_N ) { long P_2 = power ( 2 , N - 1 ) ; long modInv = moduloInverse ( P_2 ) ; long res ; res = ( ( modInv % M ) * ( F_N % M ) ) % M ; return res ; } public static void main ( String [ ] args ) { long N = 3 ; long F_N = 6 ; System . out . print ( F_1 ( N , F_N ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static Vector < Integer > arr = new Vector < Integer > ( ) ; static int effect ; static void add ( int x ) { arr . add ( x ) ; } static void update ( int x ) { effect = effect ^ x ; } static void computeResults ( ) { for ( int i = 0 ; i < arr . size ( ) ; i ++ ) { arr . set ( i , arr . get ( i ) ^ effect ) ; System . out . print ( arr . get ( i ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { arr = new Vector < Integer > ( ) ; arr . add ( 0 ) ; effect = 0 ; add ( 5 ) ; update ( 2 ) ; computeResults ( ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . awt . Point ; class GFG { public static void findSubArray ( Vector < Integer > arr , int k ) { Point ans = new Point ( 0 , 0 ) ; int i , sum = 0 ; for ( i = 0 ; i < k ; i ++ ) { sum += arr . get ( i ) ; } int found = 0 ; if ( sum % 3 == 0 ) { ans = new Point ( 0 , i - 1 ) ; found = 1 ; } for ( int j = i ; j < arr . size ( ) ; j ++ ) { if ( found == 1 ) break ; sum = sum + arr . get ( j ) - arr . get ( j - k ) ; if ( sum % 3 == 0 ) { ans = new Point ( j - k + 1 , j ) ; found = 1 ; } } if ( found == 0 ) ans = new Point ( - 1 , 0 ) ; if ( ans . x == - 1 ) { System . out . print ( - 1 ) ; } else { for ( i = ans . x ; i <= ans . y ; i ++ ) { System . out . print ( arr . get ( i ) + " ▁ " ) ; } } } public static void main ( String [ ] args ) { Vector < Integer > arr = new Vector < Integer > ( ) ; arr . add ( 84 ) ; arr . add ( 23 ) ; arr . add ( 45 ) ; arr . add ( 12 ) ; arr . add ( 56 ) ; arr . add ( 82 ) ; int K = 3 ; findSubArray ( arr , K ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void calculateFact ( int fact [ ] , int N ) { fact [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { fact [ i ] = fact [ i - 1 ] * i ; } } static int nCr ( int fact [ ] , int N , int R ) { if ( R > N ) return 0 ; int res = fact [ N ] / fact [ R ] ; res /= fact [ N - R ] ; return res ; } static int countWays ( Vector < Integer > arr , int fact [ ] ) { int N = arr . size ( ) ; if ( N <= 2 ) { return 1 ; } Vector < Integer > leftSubTree = new Vector < Integer > ( ) ; Vector < Integer > rightSubTree = new Vector < Integer > ( ) ; int root = arr . get ( 0 ) ; for ( int i = 1 ; i < N ; i ++ ) { if ( arr . get ( i ) < root ) { leftSubTree . add ( arr . get ( i ) ) ; } else { rightSubTree . add ( arr . get ( i ) ) ; } } int N1 = leftSubTree . size ( ) ; int N2 = rightSubTree . size ( ) ; int countLeft = countWays ( leftSubTree , fact ) ; int countRight = countWays ( rightSubTree , fact ) ; return nCr ( fact , N - 1 , N1 ) * countLeft * countRight ; } public static void main ( String [ ] args ) { int [ ] a = { 3 , 4 , 5 , 1 , 2 } ; Vector < Integer > arr = new Vector < Integer > ( ) ; for ( int i : a ) arr . add ( i ) ; int N = a . length ; int [ ] fact = new int [ N ] ; calculateFact ( fact , N ) ; System . out . print ( countWays ( arr , fact ) ) ; } }

Index/key variables: N, R, i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int sumOfProd ( int arr [ ] , int N ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; } return sum * sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 1 , 5 , 4 } ; int N = arr . length ; System . out . print ( sumOfProd ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int rev ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } static boolean check ( int n ) { return 2 * rev ( n ) == n + 1 ; } public static void main ( String [ ] args ) { int n = 73 ; if ( check ( n ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Class/struct names: GFG