dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { public static int triacontakaidigonNum ( int n ) { return ( 30 * n * n - 28 * n ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( "3rd ▁ triacontakaidigon ▁ Number ▁ is ▁ = ▁ " + triacontakaidigonNum ( n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static int IcosihexagonalNum ( int n ) { return ( 24 * n * n - 22 * n ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( "3rd ▁ Icosihexagonal ▁ Number ▁ is ▁ = ▁ " + IcosihexagonalNum ( n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static int icosikaioctagonalNum ( int n ) { return ( 26 * n * n - 24 * n ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( "3rd ▁ icosikaioctagonal ▁ Number ▁ is ▁ = ▁ " + icosikaioctagonalNum ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int octacontagonNum ( int n ) { return ( 78 * n * n - 76 * n ) / 2 ; } public static void main ( String args [ ] ) { int n = 3 ; System . out . print ( "3rd ▁ octacontagon ▁ Number ▁ is ▁ = ▁ " + octacontagonNum ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int hectagonNum ( int n ) { return ( 98 * n * n - 96 * n ) / 2 ; } public static void main ( String args [ ] ) { int n = 3 ; System . out . print ( "3rd ▁ hectagon ▁ Number ▁ is ▁ = ▁ " + hectagonNum ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int tetracontagonNum ( int n ) { return ( 38 * n * n - 36 * n ) / 2 ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( "3rd ▁ tetracontagon ▁ Number ▁ is ▁ = ▁ " + tetracontagonNum ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . lang . Math ; class GFG1 { static void Perimeter ( double a , double b ) { double Perimeter ; Perimeter = ( double ) 2 * 3.14 * Math . sqrt ( ( a * a + b * b ) / ( 2 * 1.0 ) ) ; System . out . println ( " Perimeter : ▁ " + Perimeter ) ; } public static void main ( String [ ] args ) { double a = 3 , b = 2 ; Perimeter ( a , b ) ; } }

Class/struct names: GFG1
Java program:
import java . lang . Math ; class cfg { static double ReuleauxArea ( double a ) { if ( a < 0 ) return - 1 ; double A = 0.70477 * Math . pow ( a , 2 ) ; return A ; } public static void main ( String [ ] args ) { double a = 6 ; System . out . println ( ReuleauxArea ( a ) ) ; }

Class/struct names: cfg
Java program:
import java . io . * ; class GFG { static double hexagonside ( double a ) { if ( a < 0 ) return - 1 ; double x = ( 0.5176 * a ) ; return x ; } public static void main ( String [ ] args ) { double a = 6 ; System . out . println ( hexagonside ( a ) ) ; } }

Class/struct names: GFG
Java program:
class CLG { static float hexagonside ( float a ) { if ( a < 0 ) return - 1 ; float x = a / 3 ; return x ; } public static void main ( String [ ] args ) { float a = 6 ; System . out . println ( hexagonside ( a ) ) ; } }

Class/struct names: CLG
Java program:
class GFG { static int findSegment ( int n , int m , int [ ] segment_length ) { double meet_point = ( 1.0 * n ) / 2.0 ; int sum = 0 ; int segment_number = 0 ; for ( int i = 0 ; i < m ; i ++ ) { sum += segment_length [ i ] ; if ( ( double ) sum == meet_point ) { segment_number = - 1 ; break ; } if ( sum > meet_point ) { segment_number = i + 1 ; break ; } } return segment_number ; } public static void main ( String [ ] args ) { int n = 13 ; int m = 3 ; int [ ] segment_length = new int [ ] { 3 , 2 , 8 } ; int ans = findSegment ( n , m , segment_length ) ; System . out . println ( ans ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static long countMaxIntersect ( long n ) { return ( n ) * ( n - 1 ) / 2 ; } public static void main ( String args [ ] ) { long n = 8 ; System . out . println ( countMaxIntersect ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class solution { static float surfaceArea ( float a , float b , float h ) { return 5 * a * b + 5 * b * h ; } static float volume ( float b , float h ) { return ( 5 * b * h ) / 2 ; } public static void main ( String arr [ ] ) { float a = 5 ; float b = 3 ; float h = 7 ; System . out . println ( " surface ▁ area = ▁ " + surfaceArea ( a , b , h ) + " , ▁ " ) ; System . out . println ( " volume = ▁ " + volume ( b , h ) ) ; } }

Class/struct names: solution
Java program:
class solution { static int checkpoint ( int h , int k , int x , int y , int a ) { int p = ( int ) Math . pow ( ( y - k ) , 2 ) - 4 * a * ( x - h ) ; return p ; } public static void main ( String arr [ ] ) { int h = 0 , k = 0 , x = 2 , y = 1 , a = 4 ; if ( checkpoint ( h , k , x , y , a ) > 0 ) System . out . println ( " Outside " ) ; else if ( checkpoint ( h , k , x , y , a ) == 0 ) System . out . println ( " On ▁ the ▁ parabola " ) ; else System . out . println ( " Inside " ) ; } }

Class/struct names: solution
Java program:
import java . util . * ; class solution { static int checkpoint ( int h , int k , int x , int y , int a , int b ) { int p = ( ( int ) Math . pow ( ( x - h ) , 2 ) / ( int ) Math . pow ( a , 2 ) ) + ( ( int ) Math . pow ( ( y - k ) , 2 ) / ( int ) Math . pow ( b , 2 ) ) ; return p ; } public static void main ( String arr [ ] ) { int h = 0 , k = 0 , x = 2 , y = 1 , a = 4 , b = 5 ; if ( checkpoint ( h , k , x , y , a , b ) > 1 ) System . out . println ( " Outside " ) ; else if ( checkpoint ( h , k , x , y , a , b ) == 1 ) System . out . println ( " On ▁ the ▁ ellipse " ) ; else System . out . println ( " Inside " ) ; } }

Class/struct names: solution
Java program:
public class GFG { public static float circlearea ( double a , double b ) { if ( a < 0 b < 0 ) return - 1 ; float A = ( float ) ( ( 3.14 * Math . pow ( a , 2 ) * Math . pow ( b , 2 ) ) / ( 4 * ( Math . pow ( a , 2 ) + Math . pow ( b , 2 ) ) ) ) ; return A ; } public static void main ( String [ ] args ) { float a = 8 , b = 10 ; System . out . println ( circlearea ( a , b ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static float circlearea ( float l , float b ) { if ( l < 0 b < 0 ) return - 1 ; if ( l < b ) return ( float ) ( 3.14 * Math . pow ( l / 2 , 2 ) ) ; else return ( float ) ( 3.14 * Math . pow ( b / 2 , 2 ) ) ; } public static void main ( String [ ] args ) { float l = 4 , b = 8 ; System . out . println ( circlearea ( l , b ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int centered_cube ( int n ) { return ( 2 * n + 1 ) * ( n * n + n + 1 ) ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . print ( n + " th ▁ Centered " + " ▁ cube ▁ number : ▁ " ) ; System . out . println ( centered_cube ( n ) ) ; n = 10 ; System . out . print ( n + " th ▁ Centered " + " ▁ cube ▁ number : ▁ " ) ; System . out . println ( centered_cube ( n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void center ( int x1 , int x2 , int y1 , int y2 ) { System . out . print ( ( float ) ( x1 + x2 ) / 2 + " , ▁ " + ( float ) ( y1 + y2 ) / 2 ) ; } public static void main ( String arg [ ] ) { int x1 = - 9 , y1 = 3 , x2 = 5 , y2 = - 7 ; center ( x1 , x2 , y1 , y2 ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static void main ( String [ ] args ) { double side = 3 ; System . out . print ( " Volume ▁ of ▁ octahedron ▁ = ▁ " ) ; System . out . println ( vol_of_octahedron ( side ) ) ; } static double vol_of_octahedron ( double side ) { return ( ( side * side * side ) * ( Math . sqrt ( 2 ) / 3 ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GfG { public static float volumeOfEllipsoid ( float r1 , float r2 , float r3 ) { float pi = ( float ) 3.14 ; return ( float ) 1.33 * pi * r1 * r2 * r3 ; } public static void main ( String args [ ] ) { float r1 = ( float ) 2.3 , r2 = ( float ) 3.4 , r3 = ( float ) 5.7 ; System . out . println ( " volume ▁ of ▁ ellipsoid ▁ is ▁ : ▁ " + volumeOfEllipsoid ( r1 , r2 , r3 ) ) ; } }

Class/struct names: GfG
Java program:
import java . io . * ; class GFG { static double areaOctagon ( double side ) { return ( float ) ( 2 * ( 1 + Math . sqrt ( 2 ) ) * side * side ) ; } public static void main ( String arg [ ] ) { double side = 4 ; System . out . print ( " Area ▁ of ▁ Regular ▁ Octagon ▁ = ▁ " + areaOctagon ( side ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static double areaCube ( double a ) { return ( a * a * a ) ; } static double surfaceCube ( double a ) { return ( 6 * a * a ) ; } public static void main ( String [ ] args ) { double a = 5 ; System . out . println ( " Area ▁ = ▁ " + areaCube ( a ) ) ; System . out . println ( " Total ▁ surface ▁ area ▁ = ▁ " + surfaceCube ( a ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static class pair { double first , second ; public pair ( double first , double second ) { this . first = first ; this . second = second ; } } static pair mirrorImage ( double a , double b , double c , double x1 , double y1 ) { double temp = - 2 * ( a * x1 + b * y1 + c ) / ( a * a + b * b ) ; double x = temp * a + x1 ; double y = temp * b + y1 ; return new pair ( x , y ) ; } public static void main ( String [ ] args ) { double a = - 1.0 ; double b = 1.0 ; double c = 0.0 ; double x1 = 1.0 ; double y1 = 0.0 ; pair image = mirrorImage ( a , b , c , x1 , y1 ) ; System . out . print ( " Image ▁ of ▁ point ▁ ( " + x1 + " , ▁ " + y1 + " ) ▁ " ) ; System . out . print ( " by ▁ mirror ▁ ( " + a + " ) x ▁ + ▁ ( " + b + " ) y ▁ + ▁ ( " + c + " ) ▁ = ▁ 0 , ▁ is ▁ : " ) ; System . out . println ( " ( " + image . first + " , ▁ " + image . second + " ) " ) ; } }

Class/struct names: GFG, pair
Java program:
class Point { double x , y ; public Point ( double x , double y ) { this . x = x ; this . y = y ; } static void displayPoint ( Point p ) { System . out . println ( " ( " + p . x + " , ▁ " + p . y + " ) " ) ; } } class Test { static Point lineLineIntersection ( Point A , Point B , Point C , Point D ) { double a1 = B . y - A . y ; double b1 = A . x - B . x ; double c1 = a1 * ( A . x ) + b1 * ( A . y ) ; double a2 = D . y - C . y ; double b2 = C . x - D . x ; double c2 = a2 * ( C . x ) + b2 * ( C . y ) ; double determinant = a1 * b2 - a2 * b1 ; if ( determinant == 0 ) { return new Point ( Double . MAX_VALUE , Double . MAX_VALUE ) ; } else { double x = ( b2 * c1 - b1 * c2 ) / determinant ; double y = ( a1 * c2 - a2 * c1 ) / determinant ; return new Point ( x , y ) ; } } public static void main ( String args [ ] ) { Point A = new Point ( 1 , 1 ) ; Point B = new Point ( 4 , 4 ) ; Point C = new Point ( 1 , 8 ) ; Point D = new Point ( 2 , 4 ) ; Point intersection = lineLineIntersection ( A , B , C , D ) ; if ( intersection . x == Double . MAX_VALUE && intersection . y == Double . MAX_VALUE ) { System . out . println ( " The ▁ given ▁ lines ▁ AB ▁ and ▁ CD ▁ are ▁ parallel . " ) ; } else { System . out . print ( " The ▁ intersection ▁ of ▁ the ▁ given ▁ lines ▁ AB ▁ " + " and ▁ CD ▁ is : ▁ " ) ; Point . displayPoint ( intersection ) ; } } }

Class/struct names: Point, Test
Java program:
class GFG { static double minRevolutions ( double r , int x1 , int y1 , int x2 , int y2 ) { double d = Math . sqrt ( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ) ; return Math . ceil ( d / ( 2 * r ) ) ; } public static void main ( String arg [ ] ) { int r = 2 , x1 = 0 , y1 = 0 ; int x2 = 0 , y2 = 4 ; System . out . print ( ( int ) minRevolutions ( r , x1 , y1 , x2 , y2 ) ) ; } }

Class/struct names: GFG
Java program:
public class GFG { final static double eps = ( double ) 1e-6 ; static double getArea ( double base , double hypotenuse ) { double height = Math . sqrt ( hypotenuse * hypotenuse - base * base ) ; return 0.5 * base * height ; } static void printRightAngleTriangle ( int hypotenuse , int area ) { int hsquare = hypotenuse * hypotenuse ; double sideForMaxArea = Math . sqrt ( hsquare / 2.0 ) ; double maxArea = getArea ( sideForMaxArea , hypotenuse ) ; if ( area > maxArea ) { System . out . print ( " Not ▁ possible " ) ; return ; } double low = 0.0 ; double high = sideForMaxArea ; double base = 0 ; while ( Math . abs ( high - low ) > eps ) { base = ( low + high ) / 2.0 ; if ( getArea ( base , hypotenuse ) >= area ) { high = base ; } else { low = base ; } } double height = Math . sqrt ( hsquare - base * base ) ; System . out . println ( Math . round ( base ) + " ▁ " + Math . round ( height ) ) ; } static public void main ( String [ ] args ) { int hypotenuse = 5 ; int area = 6 ; printRightAngleTriangle ( hypotenuse , area ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int countLattice ( int r ) { if ( r <= 0 ) return 0 ; int result = 4 ; for ( int x = 1 ; x < r ; x ++ ) { int ySquare = r * r - x * x ; int y = ( int ) Math . sqrt ( ySquare ) ; if ( y * y == ySquare ) result += 4 ; } return result ; } public static void main ( String arg [ ] ) { int r = 5 ; System . out . println ( countLattice ( r ) ) ; } }

Accumulator variables: result, x
Iterator variables: x
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void main ( String [ ] args ) { int [ ] arr = { 3 , 6 , 3 , 2 , 1 , 3 , 9 } ; int K = 2 , M = 4 ; System . out . println ( countSubArrays ( arr , K , M ) ) ; } public static int countSubArrays ( int [ ] arr , int K , int M ) { int count = 0 ; int sum = 0 ; for ( int i = 0 ; i < K ; i ++ ) { sum += arr [ i ] ; } if ( sum >= K * M ) count ++ ; for ( int i = K ; i < arr . length ; i ++ ) { sum += ( arr [ i ] - arr [ i - K ] ) ; if ( sum >= K * M ) count ++ ; } return count ; } }

Index/key variables: i
Accumulator variables: count, i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void performQueries ( int n , int q , int k , int [ ] arr , int [ ] [ ] query ) { for ( int i = 1 ; i <= q ; i ++ ) { int count = 0 ; if ( query [ i - 1 ] [ 0 ] == 1 ) { for ( int j = query [ i - 1 ] [ 1 ] ; j <= query [ i - 1 ] [ 2 ] ; j ++ ) { if ( arr [ j ] == k ) count ++ ; } System . out . print ( count + "NEW_LINE"); } else { arr [ query [ i - 1 ] [ 1 ] ] = query [ i - 1 ] [ 2 ] ; } } } public static void main ( String [ ] args ) { int [ ] arr = { 9 , 5 , 7 , 6 , 9 , 0 , 0 , 0 , 0 , 5 , 6 , 7 , 3 , 9 , 0 , 7 , 0 , 9 , 0 } ; int Q = 5 ; int [ ] [ ] query = { { 1 , 5 , 14 } , { 2 , 6 , 1 } , { 1 , 0 , 8 } , { 2 , 13 , 0 } , { 1 , 6 , 18 } } ; int N = arr . length ; int K = 0 ; performQueries ( N , Q , K , arr , query ) ; } }

Index/key variables: j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int count ( int N ) { String a = Integer . toBinaryString ( N ) ; int m = a . length ( ) - 1 ; int res = ( int ) ( N - ( Math . pow ( 2 , m ) - 1 ) ) ; return res ; } public static void main ( String [ ] args ) { int N = 18 ; System . out . println ( count ( N ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int findSmallestNumK ( int n ) { int cummAnd = n ; int i = n - 1 ; while ( cummAnd != 0 ) { cummAnd = cummAnd & i ; if ( cummAnd == 0 ) { return i ; } i -- ; } return - 1 ; } public static void main ( String [ ] args ) { int N = 17 ; int lastNum = findSmallestNumK ( N ) ; int K = lastNum == - 1 ? lastNum : N - lastNum ; System . out . println ( K ) ; } }

Accumulator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int fact ( int n ) { if ( n == 1 n == 0 ) return 1 ; else return n * fact ( n - 1 ) ; } static int findValue ( int n , int r , int a ) { int k = ( a - 1 ) / fact ( n ) ; int answer = k ; for ( int i = 1 ; i < n + 1 ; i ++ ) answer = answer * ( n + r - i ) ; answer = answer + 1 ; return answer ; } public static void main ( String args [ ] ) { int N = 1 ; int A = 2 ; int R = 3 ; System . out . print ( findValue ( N , R , A ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static String NimGame ( int N , int A , int B ) { int sum = A + B ; if ( N % sum <= A - 1 ) return " Bob " ; else return " Alice " ; } public static void main ( String [ ] args ) { int N = 3 , A = 1 , B = 2 ; System . out . println ( NimGame ( N , A , B ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void countNo ( int A , int N , int L , int R ) { int ans = L - 1 + N + ( int ) Math . floor ( ( N - 1 ) / ( A - 1 ) ) ; if ( ans % A == 0 ) { ans = ans + 1 ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int A = 5 , N = 10 , L = 4 , R = 20 ; countNo ( A , N , L , R ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void compute ( int [ ] query ) { int [ ] v = new int [ 100001 ] ; int [ ] dp = new int [ 100001 ] ; v [ 1 ] = 1 ; v [ 2 ] = 0 ; dp [ 1 ] = 0 ; dp [ 2 ] = 0 ; for ( int i = 3 ; i < 100001 ; i ++ ) { if ( i % 2 != 0 ) { if ( ( i / 2 ) % 2 == 0 ) { v [ i ] = 1 ; dp [ i ] = dp [ i - 1 ] ; } else { v [ i ] = v [ i / 2 ] + 1 ; dp [ i ] = dp [ i - 1 ] + v [ i ] - 1 ; } } else { v [ i ] = 0 ; dp [ i ] = dp [ i - 1 ] ; } } for ( int x : query ) System . out . print ( dp [ x ] + "NEW_LINE"); } public static void main ( String [ ] args ) { int [ ] query = { 5 , 2 } ; compute ( query ) ; } }

Index/key variables: i, x
Accumulator variables: i
Iterator variables: i, x
Class/struct names: GFG
Java program:
import java . util . * ; import java . math . * ; class GFG { static BigInteger findCycles ( int N ) { BigInteger res , finalResult ; long val = 2 * N - 1 ; String st = String . valueOf ( val ) ; BigInteger str = new BigInteger ( st ) ; String n1 = String . valueOf ( ( N - 1 ) ) ; String n2 = String . valueOf ( ( N - 2 ) ) ; BigInteger a = new BigInteger ( n1 ) ; BigInteger b = new BigInteger ( n2 ) ; res = a . multiply ( b ) ; finalResult = res . add ( str ) ; return finalResult ; } public static void main ( String args [ ] ) throws Exception { int N = 5 ; System . out . println ( findCycles ( N ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int find ( int a [ ] , int n , int k ) { Vector < Integer > v = new Vector < Integer > ( ) ; for ( int i = 1 ; i < n ; ++ i ) { v . add ( a [ i - 1 ] - a [ i ] ) ; } Collections . sort ( v ) ; int res = a [ n - 1 ] - a [ 0 ] ; for ( int i = 0 ; i < k - 1 ; ++ i ) { res += v . get ( i ) ; } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 8 , 15 , 16 , 23 , 42 } ; int N = arr . length ; int K = 3 ; System . out . print ( find ( arr , N , K ) + "NEW_LINE"); } }

Index/key variables: i
Accumulator variables: res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class TestClass { public static long power ( long a , long b , long c ) { long result = 1 ; while ( b > 0 ) { if ( ( b & 1 ) = = 1 ) { result = ( result * a ) % c ; } b / = 2 ; a = ( a * a ) % c ; } return result ; } public static long calculate ( long X , long N ) { int a [ ] = new int [ 10 ] ; int cyclicity [ ] = new int [ 11 ] ; cyclicity [ 1 ] = 1 ; cyclicity [ 2 ] = 4 ; cyclicity [ 3 ] = 4 ; cyclicity [ 4 ] = 2 ; cyclicity [ 5 ] = 1 ; cyclicity [ 6 ] = 1 ; cyclicity [ 7 ] = 4 ; cyclicity [ 8 ] = 4 ; cyclicity [ 9 ] = 2 ; cyclicity [ 10 ] = 1 ; if ( N = = 0 N = = 1 ) { return ( X % 10 ) ; } else if ( N = = 2 N = = 3 N = = 4 ) { long temp = ( long ) 1e18 ; a [ 2 ] = 2 ; a [ 3 ] = 6 ; a [ 4 ] = 4 ; long v = X % 10 ; if ( v ! = 0 ) { int u = cyclicity [ ( int ) v ] ; int r = a [ ( int ) N ] % u ; if ( r = = 0 ) { if ( v = = 2 v = = 4 v = = 6 v = = 8 ) { return 6 ; } else if ( v = = 5 ) { return 5 ; } else if ( v = = 1 v = = 3 v = = 7 v = = 9 ) { return 1 ; } } else { return ( power ( v , r , temp ) % 10 ) ; } } else { return 0 ; } } return 1 ; } public static void main ( String args [ ] ) throws Exception { int X = 18 ; int N = 4 ; long result = calculate ( X , N ) ; System . out . println ( result ) ; } }

Class/struct names: TestClass
Java program:
import java . util . * ; class GFG { static int formQuadruplets ( Integer arr [ ] , int n ) { int ans = 0 , pairs = 0 ; pairs = n / 4 ; Arrays . sort ( arr , Collections . reverseOrder ( ) ) ; for ( int i = 0 ; i < n - pairs ; i += 3 ) { ans += arr [ i + 2 ] ; } return ans ; } public static void main ( String [ ] args ) { Integer arr [ ] = { 2 , 1 , 7 , 5 , 5 , 4 , 1 , 1 , 3 , 3 , 2 , 2 } ; int n = arr . length ; System . out . print ( formQuadruplets ( arr , n ) + "NEW_LINE"); } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void LIS ( int arr [ ] , int n ) { TreeMap < Integer , List < Integer > > m = new TreeMap < Integer , List < Integer > > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { List < Integer > indexes ; if ( m . containsKey ( arr [ i ] ) ) { indexes = m . get ( arr [ i ] ) ; } else { indexes = new ArrayList < Integer > ( ) ; } indexes . add ( i ) ; m . put ( arr [ i ] , indexes ) ; } int k = n ; int ans = 0 ; for ( Map . Entry < Integer , List < Integer > > it : m . entrySet ( ) ) { List < Integer > indexes = it . getValue ( ) ; if ( indexes . get ( indexes . size ( ) - 1 ) < k ) { k = indexes . get ( 0 ) ; ans ++ ; } else k = lower_bound ( indexes , k ) ; } System . out . println ( ans ) ; } static int lower_bound ( List < Integer > indexes , int k ) { int low = 0 , high = indexes . size ( ) - 1 ; while ( low < high ) { int mid = ( low + high ) / 2 ; if ( indexes . get ( mid ) < k ) low = mid + 1 ; else high = mid ; } return indexes . get ( low ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 2 , 1 , 2 } ; int n = arr . length ; LIS ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static void IsPossible ( int a , int b , int x , int y ) { int g = gcd ( x , y ) ; int initial = gcd ( a , b ) ; if ( initial == g ) { System . out . print ( "POSSIBLENEW_LINE"); } else { System . out . print ( "NOT POSSIBLENEW_LINE"); } } public static void main ( String args [ ] ) { int A = 1 , B = 2 , X = 4 , Y = 11 ; IsPossible ( A , B , X , Y ) ; A = 2 ; B = 2 ; X = 3 ; Y = 6 ; IsPossible ( A , B , X , Y ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int mod = 1000000007 ; static int waysToColor ( int arr [ ] , int n , int k ) { int powOf2 [ ] = new int [ 500 ] ; int [ ] [ ] c = new int [ 500 ] [ 500 ] ; for ( int i = 0 ; i <= n ; i ++ ) { c [ i ] [ 0 ] = 1 ; for ( int j = 1 ; j <= i ; j ++ ) { c [ i ] [ j ] = ( c [ i - 1 ] [ j ] + c [ i - 1 ] [ j - 1 ] ) % mod ; } } powOf2 [ 0 ] = powOf2 [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { powOf2 [ i ] = powOf2 [ i - 1 ] * 2 % mod ; } int rem = n - k ; arr [ k ++ ] = n + 1 ; Arrays . sort ( arr ) ; int answer = 1 ; for ( int i = 0 ; i < k ; i ++ ) { int x = arr [ i ] - ( i - 1 >= 0 ? arr [ i - 1 ] : 0 ) - 1 ; answer *= c [ rem ] [ x ] % mod * ( i != 0 && i != k - 1 ? powOf2 [ x ] : 1 ) % mod ; rem -= x ; } return answer ; } public static void main ( String [ ] args ) { int N = 6 ; int K = 3 ; int arr [ ] = { 1 , 2 , 6 , 0 } ; System . out . print ( waysToColor ( arr , N , K ) ) ; } }

Index/key variables: i, j, rem, x
Accumulator variables: answer, i, j, k, rem
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printArray ( int [ ] a , int n ) { Arrays . sort ( a ) ; int i = 0 ; int j = n - 1 ; while ( i <= j ) { if ( i == j ) { System . out . print ( a [ i ] + " ▁ " ) ; } else { System . out . print ( a [ j ] + " ▁ " ) ; System . out . print ( a [ i ] + " ▁ " ) ; } i = i + 1 ; j = j - 1 ; } System . out . println ( ) ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int n1 = arr1 . length ; printArray ( arr1 , n1 ) ; } }

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