dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
public class Turns_to_reach_another_node { static int Count ; static class Node { Node left , right ; int key ; Node ( int key ) { this . key = key ; left = null ; right = null ; } } static Node findLCA ( Node root , int n1 , int n2 ) { if ( root == null ) return null ; if ( root . key == n1 root . key == n2 ) return root ; Node left_lca = findLCA ( root . left , n1 , n2 ) ; Node right_lca = findLCA ( root . right , n1 , n2 ) ; if ( left_lca != null && right_lca != null ) return root ; return ( left_lca != null ) ? left_lca : right_lca ; } static boolean CountTurn ( Node root , int key , boolean turn ) { if ( root == null ) return false ; if ( root . key == key ) return true ; if ( turn == true ) { if ( CountTurn ( root . left , key , turn ) ) return true ; if ( CountTurn ( root . right , key , ! turn ) ) { Count += 1 ; return true ; } } else { if ( CountTurn ( root . right , key , turn ) ) return true ; if ( CountTurn ( root . left , key , ! turn ) ) { Count += 1 ; return true ; } } return false ; } static int NumberOfTurn ( Node root , int first , int second ) { Node LCA = findLCA ( root , first , second ) ; if ( LCA == null ) return - 1 ; Count = 0 ; if ( LCA . key != first && LCA . key != second ) { if ( CountTurn ( LCA . right , second , false ) || CountTurn ( LCA . left , second , true ) ) ; if ( CountTurn ( LCA . left , first , true ) || CountTurn ( LCA . right , first , false ) ) ; return Count + 1 ; } if ( LCA . key == first ) { CountTurn ( LCA . right , second , false ) ; CountTurn ( LCA . left , second , true ) ; return Count ; } else { CountTurn ( LCA . right , first , false ) ; CountTurn ( LCA . left , first , true ) ; return Count ; } } public static void main ( String [ ] args ) { Node root = new Node ( 1 ) ; root . left = new Node ( 2 ) ; root . right = new Node ( 3 ) ; root . left . left = new Node ( 4 ) ; root . left . right = new Node ( 5 ) ; root . right . left = new Node ( 6 ) ; root . right . right = new Node ( 7 ) ; root . left . left . left = new Node ( 8 ) ; root . right . left . left = new Node ( 9 ) ; root . right . left . right = new Node ( 10 ) ; int turn = 0 ; if ( ( turn = NumberOfTurn ( root , 5 , 10 ) ) != 0 ) System . out . println ( turn ) ; else System . out . println ( " Not ▁ Possible " ) ; } }

Accumulator variables: Count
Class/struct names: Node, Turns_to_reach_another_node
Java program:
import java . util . * ; class GFG { static void checkTypeOfTriangle ( int a , int b , int c ) { int sqa = ( int ) Math . pow ( a , 2 ) ; int sqb = ( int ) Math . pow ( b , 2 ) ; int sqc = ( int ) Math . pow ( c , 2 ) ; if ( sqa == sqa + sqb sqb == sqa + sqc sqc == sqa + sqb ) { System . out . print ( " Right - angled ▁ Triangle " ) ; } else if ( sqa > sqc + sqb sqb > sqa + sqc sqc > sqa + sqb ) { System . out . print ( " Obtuse - angled ▁ Triangle " ) ; } else { System . out . print ( " Acute - angled ▁ Triangle " ) ; } } public static void main ( String [ ] args ) { int a , b , c ; a = 2 ; b = 2 ; c = 2 ; checkTypeOfTriangle ( a , b , c ) ; } }

Class/struct names: GFG
Java program:
class GFG { public static int Valid ( int a , int b , int c ) { if ( a + b + c == 180 && a != 0 && b != 0 && c != 0 ) return 1 ; else return 0 ; } public static void main ( String args [ ] ) { int a = 60 , b = 40 , c = 80 ; if ( ( Valid ( a , b , c ) ) == 1 ) System . out . print ( " Valid " ) ; else System . out . print ( " Invalid " ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static double trianglearea ( double a ) { if ( a < 0 ) return - 1 ; double area = ( 3 * Math . sqrt ( 3 ) * Math . pow ( a , 2 ) ) / 4 ; return area ; } public static void main ( String [ ] args ) { double a = 6 ; System . out . println ( trianglearea ( a ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class solution { static void equation_ellipse ( float x1 , float y1 , float a , float b , float c , float e ) { float t = a * a + b * b ; float a1 = t - e * ( a * a ) ; float b1 = t - e * ( b * b ) ; float c1 = ( - 2 * t * x1 ) - ( 2 * e * c * a ) ; float d1 = ( - 2 * t * y1 ) - ( 2 * e * c * b ) ; float e1 = - 2 * e * a * b ; float f1 = ( - e * c * c ) + ( t * x1 * x1 ) + ( t * y1 * y1 ) ; System . out . println ( " Equation ▁ of ▁ ellipse ▁ is ▁ " ) ; System . out . print ( a1 + " ▁ x ^ 2 ▁ + ▁ " + b1 + " ▁ y ^ 2 ▁ + ▁ " + c1 + " ▁ x ▁ + ▁ " + d1 + " ▁ y ▁ + ▁ " + e1 + " ▁ xy ▁ + ▁ " + f1 + " ▁ = ▁ 0" ) ; } public static void main ( String arr [ ] ) { float x1 = 1 , y1 = 1 , a = 1 , b = - 1 , c = 3 , e = ( float ) 0.5 * ( float ) 0.5 ; equation_ellipse ( x1 , y1 , a , b , c , e ) ; } }

Class/struct names: solution
Java program:
import java . util . * ; class GFG { static class Node { int data ; Node left , right , abtr ; } ; static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = node . abtr = null ; return node ; } static Vector < Node > even_ptrs = new Vector < > ( ) ; static Vector < Node > odd_ptrs = new Vector < > ( ) ; static void preorderTraversal ( Node root ) { if ( root == null ) return ; if ( root . data % 2 == 0 ) ( even_ptrs ) . add ( root ) ; else ( odd_ptrs ) . add ( root ) ; preorderTraversal ( root . left ) ; preorderTraversal ( root . right ) ; } static void createLoops ( Node root ) { preorderTraversal ( root ) ; int i ; for ( i = 1 ; i < even_ptrs . size ( ) ; i ++ ) even_ptrs . get ( i - 1 ) . abtr = even_ptrs . get ( i ) ; even_ptrs . get ( i - 1 ) . abtr = even_ptrs . get ( 0 ) ; for ( i = 1 ; i < odd_ptrs . size ( ) ; i ++ ) odd_ptrs . get ( i - 1 ) . abtr = odd_ptrs . get ( i ) ; odd_ptrs . get ( i - 1 ) . abtr = odd_ptrs . get ( 0 ) ; } static void traverseLoop ( Node start ) { Node curr = start ; do { System . out . print ( curr . data + " ▁ " ) ; curr = curr . abtr ; } while ( curr != start ) ; } public static void main ( String [ ] args ) { Node root = null ; root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 5 ) ; root . right . left = newNode ( 6 ) ; root . right . right = newNode ( 7 ) ; createLoops ( root ) ; System . out . print ( " Odd ▁ nodes : ▁ " ) ; traverseLoop ( root . right ) ; System . out . print ( " Even nodes : "); traverseLoop ( root . left ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
Java program:
import java . io . * ; class GFG { static double PI = 3.14 ; static double circle_inscribed ( int a ) { return PI * ( a * a ) / 12 ; } public static void main ( String [ ] args ) { int a = 4 ; System . out . println ( circle_inscribed ( a ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static void findVolume ( double u , double v , double w , double U , double V , double W , double b ) { double uPow = Math . pow ( u , 2 ) ; double vPow = Math . pow ( v , 2 ) ; double wPow = Math . pow ( w , 2 ) ; double UPow = Math . pow ( U , 2 ) ; double VPow = Math . pow ( V , 2 ) ; double WPow = Math . pow ( W , 2 ) ; double a = 4 * ( uPow * vPow * wPow ) - uPow * Math . pow ( ( vPow + wPow - UPow ) , 2 ) - vPow * Math . pow ( ( wPow + uPow - VPow ) , 2 ) - wPow * Math . pow ( ( uPow + vPow - WPow ) , 2 ) + ( vPow + wPow - UPow ) * ( wPow + uPow - VPow ) * ( uPow + vPow - WPow ) ; double vol = Math . sqrt ( a ) ; vol /= b ; System . out . printf ( " % .4f " , vol ) ; } public static void main ( String args [ ] ) { double u = 1000 , v = 1000 , w = 1000 ; double U = 3 , V = 4 , W = 5 ; double b = 12 ; findVolume ( u , v , w , U , V , W , b ) ; } }

Accumulator variables: vol
Class/struct names: GFG
Java program:
class GFG { static void makePolygon ( double a ) { double n = 360 / ( 180 - a ) ; if ( n == ( int ) n ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } public static void main ( String [ ] args ) { double a = 90 ; makePolygon ( a ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int getQuadrant ( int X , int Y , int R , int PX , int PY ) { if ( PX == X && PY == Y ) return 0 ; int val = ( int ) Math . pow ( ( PX - X ) , 2 ) + ( int ) Math . pow ( ( PY - Y ) , 2 ) ; if ( val > Math . pow ( R , 2 ) ) return - 1 ; if ( PX > X && PY >= Y ) return 1 ; if ( PX <= X && PY > Y ) return 2 ; if ( PX < X && PY <= Y ) return 3 ; if ( PX >= X && PY < Y ) return 4 ; return 0 ; } public static void main ( String [ ] args ) { int X = 0 , Y = 3 ; int R = 2 ; int PX = 1 , PY = 4 ; int ans = getQuadrant ( X , Y , R , PX , PY ) ; if ( ans == - 1 ) System . out . println ( " Lies ▁ Outside ▁ the ▁ circle " ) ; else if ( ans == 0 ) System . out . println ( " Coincides ▁ with ▁ centre " ) ; else System . out . println ( ans + " ▁ Quadrant " ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static long hexadecagonalNum ( long n ) { return ( ( 14 * n * n ) - 12 * n ) / 2 ; } public static void main ( String [ ] args ) { long n = 5 ; System . out . println ( n + " th ▁ " + " Hexadecagonal ▁ number ▁ : ▁ " + hexadecagonalNum ( n ) ) ; n = 9 ; System . out . println ( n + " th ▁ " + " Hexadecagonal ▁ number ▁ : ▁ " + hexadecagonalNum ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GfG { static class Node { int data ; Node left , right ; } static Node newNode ( int x ) { Node temp = new Node ( ) ; temp . data = x ; temp . left = null ; temp . right = null ; return temp ; } static boolean isLeaf ( Node t ) { return ( ( t . left == null ) && ( t . right == null ) ) ; } static void findFirstUnmatch ( Node root1 , Node root2 ) { if ( root1 == null root2 == null ) return ; Stack < Node > s1 = new Stack < Node > ( ) ; Stack < Node > s2 = new Stack < Node > ( ) ; s1 . push ( root1 ) ; s2 . push ( root2 ) ; while ( ! s1 . isEmpty ( ) || ! s2 . isEmpty ( ) ) { if ( s1 . isEmpty ( ) || s2 . isEmpty ( ) ) return ; Node temp1 = s1 . peek ( ) ; s1 . pop ( ) ; while ( temp1 != null && isLeaf ( temp1 ) != true ) { s1 . push ( temp1 . right ) ; s1 . push ( temp1 . left ) ; temp1 = s1 . peek ( ) ; s1 . pop ( ) ; } Node temp2 = s2 . peek ( ) ; s2 . pop ( ) ; while ( temp2 != null && isLeaf ( temp2 ) != true ) { s2 . push ( temp2 . right ) ; s2 . push ( temp2 . left ) ; temp2 = s2 . peek ( ) ; s2 . pop ( ) ; } if ( temp1 != null && temp2 != null ) { if ( temp1 . data != temp2 . data ) { System . out . println ( temp1 . data + " ▁ " + temp2 . data ) ; return ; } } } } public static void main ( String [ ] args ) { Node root1 = newNode ( 5 ) ; root1 . left = newNode ( 2 ) ; root1 . right = newNode ( 7 ) ; root1 . left . left = newNode ( 10 ) ; root1 . left . right = newNode ( 11 ) ; Node root2 = newNode ( 6 ) ; root2 . left = newNode ( 10 ) ; root2 . right = newNode ( 15 ) ; findFirstUnmatch ( root1 , root2 ) ; } }

Class/struct names: GfG, Node
Java program:
import java . io . * ; public class GFG { static int intersection ( int n ) { return n * ( n - 1 ) ; } public static void main ( String [ ] args ) throws IOException { System . out . println ( intersection ( 3 ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int perimeter ( int diameter , int height ) { return 2 * ( diameter + height ) ; } public static void main ( String [ ] args ) { int diameter = 5 ; int height = 10 ; System . out . println ( " Perimeter ▁ = ▁ " + perimeter ( diameter , height ) + " unitsNEW_LINE"); } }

Class/struct names: GFG
Java program:
public class ParallelogramPoints { public static void main ( String [ ] s ) { int ax = 5 , ay = 0 ; int bx = 1 , by = 1 ; int cx = 2 , cy = 5 ; System . out . println ( ax + bx - cx + " , ▁ " + ( ay + by - cy ) ) ; System . out . println ( ax + cx - bx + " , ▁ " + ( ay + cy - by ) ) ; System . out . println ( cx + bx - ax + " , ▁ " + ( cy + by - ax ) ) ; } }

Class/struct names: ParallelogramPoints
Java program:
class GFG { static float area ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 ) { return ( float ) Math . abs ( ( x1 * ( y2 - y3 ) + x2 * ( y3 - y1 ) + x3 * ( y1 - y2 ) ) / 2.0 ) ; } static boolean check ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 , int x4 , int y4 , int x , int y ) { float A = area ( x1 , y1 , x2 , y2 , x3 , y3 ) + area ( x1 , y1 , x4 , y4 , x3 , y3 ) ; float A1 = area ( x , y , x1 , y1 , x2 , y2 ) ; float A2 = area ( x , y , x2 , y2 , x3 , y3 ) ; float A3 = area ( x , y , x3 , y3 , x4 , y4 ) ; float A4 = area ( x , y , x1 , y1 , x4 , y4 ) ; return ( A == A1 + A2 + A3 + A4 ) ; } public static void main ( String [ ] args ) { if ( check ( 0 , 10 , 10 , 0 , 0 , - 10 , - 10 , 0 , 10 , 15 ) ) System . out . print ( " yes " ) ; else System . out . print ( " no " ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GfG { static class Node { int data ; Node left , right ; } static int maxOfLeftElement ( Node root ) { int res = Integer . MIN_VALUE ; if ( root == null ) return res ; if ( root . left != null ) res = root . left . data ; return Math . max ( maxOfLeftElement ( root . left ) , Math . max ( res , maxOfLeftElement ( root . right ) ) ) ; } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = null ; temp . right = null ; return temp ; } public static void main ( String [ ] args ) { Node root = newNode ( 7 ) ; root . left = newNode ( 6 ) ; root . right = newNode ( 5 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 3 ) ; root . right . left = newNode ( 2 ) ; root . right . right = newNode ( 1 ) ; System . out . println ( maxOfLeftElement ( root ) ) ; } }

Class/struct names: GfG, Node
Java program:
class GFG { static int findMaximumPieces ( int n ) { return 1 + n * ( n + 1 ) / 2 ; } public static void main ( String arg [ ] ) { System . out . print ( findMaximumPieces ( 3 ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static double sq ( double x ) { return ( ( x ) * ( x ) ) ; } static int EPS = ( int ) ( 1e-6 ) + 1 ; static int N = 5 ; static class point { int x , y ; point ( ) { } public point ( int x , int y ) { this . x = x ; this . y = y ; } } ; static class line { int a , b , c ; public line ( int a , int b , int c ) { this . a = a ; this . b = b ; this . c = c ; } } ; static double dist ( double x , double y , point p ) { return Math . sqrt ( sq ( x - p . x ) + sq ( y - p . y ) ) ; } static double compute ( point p [ ] , int n , line l , double X ) { double res = 0 ; double Y = - 1 * ( l . c + l . a * X ) / l . b ; for ( int i = 0 ; i < n ; i ++ ) res += dist ( X , Y , p [ i ] ) ; return res ; } static double findOptimumCostUtil ( point p [ ] , int n , line l ) { double low = - 1e6 ; double high = 1e6 ; while ( ( high - low ) > EPS ) { double mid1 = low + ( high - low ) / 3 ; double mid2 = high - ( high - low ) / 3 ; double dist1 = compute ( p , n , l , mid1 ) ; double dist2 = compute ( p , n , l , mid2 ) ; if ( dist1 < dist2 ) high = mid2 ; else low = mid1 ; } return compute ( p , n , l , ( low + high ) / 2 ) ; } static double findOptimumCost ( int points [ ] [ ] , line l ) { point [ ] p = new point [ N ] ; for ( int i = 0 ; i < N ; i ++ ) p [ i ] = new point ( points [ i ] [ 0 ] , points [ i ] [ 1 ] ) ; return findOptimumCostUtil ( p , N , l ) ; } public static void main ( String [ ] args ) { line l = new line ( 1 , - 1 , - 3 ) ; int points [ ] [ ] = { { - 3 , - 2 } , { - 1 , 0 } , { - 1 , 2 } , { 1 , 2 } , { 3 , 4 } } ; System . out . println ( findOptimumCost ( points , l ) ) ; } }

Index/key variables: N, i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG, line, point
Java program:
public class Main { static int factorTree ( int N ) { int height = 0 ; while ( N > 1 ) { boolean flag = false ; for ( int i = 2 ; i <= Math . sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) { N = N / i ; flag = true ; break ; } } height ++ ; if ( ! flag ) { break ; } } return height ; } public static void main ( String [ ] args ) { int N = 48 ; System . out . println ( factorTree ( N ) ) ; } }

Accumulator variables: height, i
Iterator variables: i
Boolean variables: flag
Class/struct names: Main
Java program:
import java . io . * ; class GFG { static int findMaxK ( int N ) { int p = ( int ) ( Math . log ( N ) / Math . log ( 2 ) ) ; return ( int ) Math . pow ( 2 , p ) ; } public static void main ( String [ ] args ) { int N = 5 ; System . out . println ( findMaxK ( N ) - 1 ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; public class Main { static int [ ] a ; static int [ ] seg_tree ; static int [ ] [ ] query ; static void build_tree ( int v , int tl , int tr ) { if ( tl != tr ) { if ( a [ tl ] == 0 ) seg_tree [ v ] = 1 ; else seg_tree [ v ] = 0 ; } else { int tm = ( tl + tr ) / 2 ; build_tree ( v * 2 , tl , tm ) ; build_tree ( v * 2 + 1 , tm + 1 , tr ) ; seg_tree [ v ] = seg_tree [ v * 2 ] + seg_tree [ v * 2 + 1 ] ; } } static int frequency_zero ( int v , int tl , int tr , int l , int r ) { if ( l > r ) return 0 ; if ( l == tl && r == tr ) { return seg_tree [ v ] ; } int tm = ( tl + tr ) / 2 ; return frequency_zero ( v * 2 , tl , tm , l , Math . min ( r , tm ) ) + frequency_zero ( v * 2 + 1 , tm + 1 , tr , Math . max ( l , tm + 1 ) , r ) ; } static void update ( int v , int tl , int tr , int pos , int new_val ) { if ( tl == tr ) { if ( new_val == 0 ) seg_tree [ v ] = 1 ; else seg_tree [ v ] = 0 ; } else { int tm = ( tl + tr ) / 2 ; if ( pos <= tm ) update ( v * 2 , tl , tm , pos , new_val ) ; else update ( v * 2 + 1 , tm + 1 , tr , pos , new_val ) ; seg_tree [ v ] = seg_tree [ v * 2 ] + seg_tree [ v * 2 + 1 ] ; } } static void solve ( int n , int q ) { int [ ] qu = { 5 , 3 , 6 } ; seg_tree = new int [ 4 * n + 1 ] ; Arrays . fill ( seg_tree , 0 ) ; build_tree ( 1 , 0 , n - 1 ) ; for ( int i = 0 ; i < qu . length ; i ++ ) { System . out . println ( qu [ i ] ) ; } for ( int i = q ; i < q ; i ++ ) { if ( query [ i - 1 ] [ 0 ] == 1 ) { int l = query [ i - 1 ] [ 1 ] ; int r = query [ i - 1 ] [ 2 ] ; System . out . println ( frequency_zero ( 1 , 0 , n - 1 , l , r ) ) ; } else { a [ query [ i - 1 ] [ 1 ] ] = query [ i - 1 ] [ 2 ] ; int pos = query [ i - 1 ] [ 1 ] ; int new_val = query [ i - 1 ] [ 2 ] ; update ( 1 , 0 , n - 1 , pos , new_val ) ; } } } public static void main ( String [ ] args ) { a = new int [ ] { 9 , 5 , 7 , 6 , 9 , 0 , 0 , 0 , 0 , 5 , 6 , 7 , 3 , 9 , 0 , 7 , 0 , 9 , 0 } ; int Q = 5 ; query = new int [ ] [ ] { { 1 , 5 , 14 } , { 2 , 6 , 1 } , { 1 , 0 , 8 } , { 2 , 13 , 0 } , { 1 , 6 , 18 } } ; int N = a . length ; solve ( N , Q ) ; } }

Index/key variables: i, tl, v
Accumulator variables: i
Iterator variables: i
Class/struct names: Main
Java program:
import java . util . * ; class GFG { static final int InF = 99999 ; static class number { int no ; int level ; number ( ) { } number ( int n , int l ) { this . no = n ; this . level = l ; } } ; static void findnthnumber ( int n ) { Queue < number > q = new LinkedList < > ( ) ; number r = new number ( 0 , 1 ) ; q . add ( r ) ; while ( ! q . isEmpty ( ) ) { number temp = q . peek ( ) ; q . remove ( ) ; if ( temp . no >= InF temp . no <= - InF ) break ; if ( temp . no == n ) { System . out . print ( " Found ▁ number ▁ n ▁ at ▁ level ▁ " + ( temp . level - 1 ) ) ; break ; } q . add ( new number ( temp . no + temp . level , temp . level + 1 ) ) ; q . add ( new number ( temp . no - temp . level , temp . level + 1 ) ) ; } } public static void main ( String [ ] args ) { findnthnumber ( 13 ) ; } }

Class/struct names: GFG, number
Java program:
import java . util . * ; class GFG { static boolean can_empty ( int a , int b , int c ) { if ( ( a + b + c ) % 4 != 0 ) return false ; else { int m = Math . min ( a , Math . min ( b , c ) ) ; if ( m < ( ( a + b + c ) / 4 ) ) return false ; } return true ; } public static void main ( String [ ] args ) { int a = 4 , b = 2 , c = 2 ; System . out . println ( can_empty ( a , b , c ) ? " true " : " false " ) ; a = 3 ; b = 4 ; c = 2 ; System . out . println ( can_empty ( a , b , c ) ? " true " : " false " ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static double Avgdifference ( double arr [ ] , int N , int K ) { double min = 1000000 , max = - 1 ; for ( int i = 0 ; i <= N - K ; i ++ ) { double sum = 0 ; for ( int j = 0 ; j < K ; j ++ ) { sum += arr [ i + j ] ; } if ( min > sum ) min = sum ; if ( max < sum ) max = sum ; } return ( max - min ) / K ; } public static void main ( String [ ] args ) { double arr [ ] = { 3 , 8 , 9 , 15 } ; int N = arr . length ; int K = 2 ; System . out . println ( Avgdifference ( arr , N , K ) ) ; } }

Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static Vector < Integer > find ( int n ) { Vector < Integer > ans = new Vector < > ( ) ; int sum = 0 ; int i = 1 ; int sign = ( n >= 0 ? 1 : - 1 ) ; n = Math . abs ( n ) ; for ( ; sum < n ; ) { ans . add ( sign * i ) ; sum += i ; i ++ ; } if ( sum > sign * n ) { if ( i % 2 != 0 ) { sum -= n ; if ( sum % 2 != 0 ) { ans . add ( sign * i ) ; sum += i ; i ++ ; } int a = ans . get ( ( sum / 2 ) - 1 ) ; ans . remove ( ( sum / 2 ) - 1 ) ; ans . add ( ( ( sum / 2 ) - 1 ) , a * ( - 1 ) ) ; } else { sum -= n ; if ( sum % 2 != 0 ) { sum -- ; ans . add ( sign * i ) ; ans . add ( sign * - 1 * ( i + 1 ) ) ; } ans . add ( ( sum / 2 ) - 1 , ans . get ( ( sum / 2 ) - 1 ) * - 1 ) ; } } return ans ; } public static void main ( String [ ] args ) { int n = 20 ; if ( n == 0 ) System . out . print ( "Minimum number of Steps: 0 Step sequence : 0 "); else { Vector < Integer > a = find ( n ) ; System . out . print ( " Minimum ▁ number ▁ of ▁ Steps : ▁ " + a . size ( ) + " Step sequence : "); for ( int i : a ) System . out . print ( i + " ▁ " ) ; } } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . awt . * ; import java . util . * ; class GFG { static class pair < T , V > { T first ; V second ; } static void MaxRange ( ArrayList < Integer > A , int n ) { int [ ] left = new int [ n ] ; int [ ] right = new int [ n ] ; Stack < pair < Integer , Integer > > s = new Stack < > ( ) ; pair < Integer , Integer > x = new pair < > ( ) ; x . first = Integer . MAX_VALUE ; x . second = - 1 ; s . push ( x ) ; for ( int i = 0 ; i < n ; i ++ ) { while ( s . peek ( ) . first < A . get ( i ) ) s . pop ( ) ; left [ i ] = s . peek ( ) . second ; pair < Integer , Integer > y = new pair < > ( ) ; y . first = A . get ( i ) ; y . second = i ; s . push ( y ) ; } while ( ! s . empty ( ) ) s . pop ( ) ; pair < Integer , Integer > k = new pair < > ( ) ; k . first = Integer . MAX_VALUE ; k . second = n ; s . push ( k ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { while ( s . peek ( ) . first < A . get ( i ) ) s . pop ( ) ; right [ i ] = s . peek ( ) . second ; pair < Integer , Integer > y = new pair < > ( ) ; y . first = A . get ( i ) ; y . second = i ; s . push ( y ) ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( left [ i ] + 1 ) ; System . out . print ( " ▁ " ) ; System . out . println ( right [ i ] - 1 ) ; } } public static void main ( String [ ] args ) { ArrayList < Integer > arr = new ArrayList < > ( ) ; arr . add ( 1 ) ; arr . add ( 3 ) ; arr . add ( 2 ) ; int n = arr . size ( ) ; MaxRange ( arr , n ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
import java . io . * ; class GFG { static int nthNumber ( int n ) { int divs [ ] = new int [ 1000000 ] ; boolean vis [ ] = new boolean [ 1000000 ] ; int cnt = 0 ; for ( int i = 2 ; cnt < n ; i ++ ) { if ( divs [ i ] == 0 ) { for ( int j = 2 * i ; j < 1000000 ; j += i ) { if ( vis [ j ] ) { continue ; } vis [ j ] = true ; int currNum = j ; int count = 0 ; while ( currNum % i == 0 ) { divs [ j ] ++ ; currNum = currNum / i ; count ++ ; } if ( currNum == 1 && count == 3 && divs [ j ] == 3 ) { cnt ++ ; } else if ( currNum != 1 && divs [ currNum ] == 0 && count == 1 && divs [ j ] == 1 ) { cnt ++ ; } if ( cnt == n ) { return j ; } } } } return - 1 ; } public static void main ( String [ ] args ) { int N = 24 ; System . out . println ( nthNumber ( N ) ) ; } }

Index/key variables: currNum, i, j
Accumulator variables: cnt, count, i, j
Iterator variables: i, j
Class/struct names: GFG