dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
public class RatMaze { static int N ; void printSolution ( int sol [ ] [ ] ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) System . out . print ( " ▁ " + sol [ i ] [ j ] + " ▁ " ) ; System . out . println ( ) ; } } boolean isSafe ( int maze [ ] [ ] , int x , int y ) { return ( x >= 0 && x < N && y >= 0 && y < N && maze [ x ] [ y ] == 1 ) ; } boolean solveMaze ( int maze [ ] [ ] ) { int sol [ ] [ ] = new int [ N ] [ N ] ; if ( solveMazeUtil ( maze , 0 , 0 , sol ) == false ) { System . out . print ( " Solution ▁ doesn ' t ▁ exist " ) ; return false ; } printSolution ( sol ) ; return true ; } boolean solveMazeUtil ( int maze [ ] [ ] , int x , int y , int sol [ ] [ ] ) { if ( x == N - 1 && y == N - 1 && maze [ x ] [ y ] == 1 ) { sol [ x ] [ y ] = 1 ; return true ; } if ( isSafe ( maze , x , y ) == true ) { if ( sol [ x ] [ y ] == 1 ) return false ; sol [ x ] [ y ] = 1 ; if ( solveMazeUtil ( maze , x + 1 , y , sol ) ) return true ; if ( solveMazeUtil ( maze , x , y + 1 , sol ) ) return true ; if ( solveMazeUtil ( maze , x - 1 , y , sol ) ) return true ; if ( solveMazeUtil ( maze , x , y - 1 , sol ) ) return true ; sol [ x ] [ y ] = 0 ; return false ; } return false ; } public static void main ( String args [ ] ) { RatMaze rat = new RatMaze ( ) ; int maze [ ] [ ] = { { 1 , 0 , 0 , 0 } , { 1 , 1 , 0 , 1 } , { 0 , 1 , 0 , 0 } , { 1 , 1 , 1 , 1 } } ; N = maze . length ; rat . solveMaze ( maze ) ; } }

Index/key variables: N, i, j, x, y
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: RatMaze
Java program:
public class GFG { static int V = 4 ; static void printSolution ( int [ ] color ) { System . out . println ( " Solution ▁ Exists : " + " ▁ Following ▁ are ▁ the ▁ assigned ▁ colors ▁ " ) ; for ( int i = 0 ; i < V ; i ++ ) System . out . print ( " ▁ " + color [ i ] ) ; System . out . println ( ) ; } static boolean isSafe ( boolean [ ] [ ] graph , int [ ] color ) { for ( int i = 0 ; i < V ; i ++ ) for ( int j = i + 1 ; j < V ; j ++ ) if ( graph [ i ] [ j ] && color [ j ] == color [ i ] ) return false ; return true ; } static boolean graphColoring ( boolean [ ] [ ] graph , int m , int i , int [ ] color ) { if ( i == V ) { if ( isSafe ( graph , color ) ) { printSolution ( color ) ; return true ; } return false ; } for ( int j = 1 ; j <= m ; j ++ ) { color [ i ] = j ; if ( graphColoring ( graph , m , i + 1 , color ) ) return true ; color [ i ] = 0 ; } return false ; } public static void main ( String [ ] args ) { boolean [ ] [ ] graph = { { false , true , true , true } , { true , false , true , false } , { true , true , false , true } , { true , false , true , false } , } ; int m = 3 ; int [ ] color = new int [ V ] ; for ( int i = 0 ; i < V ; i ++ ) color [ i ] = 0 ; if ( ! graphColoring ( graph , m , 0 , color ) ) System . out . println ( " Solution ▁ does ▁ not ▁ exist " ) ; } }

Index/key variables: V, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class Node { int color = 1 ; Set < Integer > edges = new HashSet < Integer > ( ) ; } class GFG { static int canPaint ( ArrayList < Node > nodes , int n , int m ) { ArrayList < Integer > visited = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n + 1 ; i ++ ) { visited . add ( 0 ) ; } int maxColors = 1 ; for ( int sv = 1 ; sv <= n ; sv ++ ) { if ( visited . get ( sv ) > 0 ) { continue ; } visited . set ( sv , 1 ) ; Queue < Integer > q = new LinkedList < > ( ) ; q . add ( sv ) ; while ( q . size ( ) != 0 ) { int top = q . peek ( ) ; q . remove ( ) ; for ( int it : nodes . get ( top ) . edges ) { if ( nodes . get ( top ) . color == nodes . get ( it ) . color ) { nodes . get ( it ) . color += 1 ; } maxColors = Math . max ( maxColors , Math . max ( nodes . get ( top ) . color , nodes . get ( it ) . color ) ) ; if ( maxColors > m ) return 0 ; if ( visited . get ( it ) == 0 ) { visited . set ( it , 1 ) ; q . remove ( it ) ; } } } } return 1 ; } public static void main ( String [ ] args ) { int n = 4 ; int [ ] [ ] graph = { { 0 , 1 , 1 , 1 } , { 1 , 0 , 1 , 0 } , { 1 , 1 , 0 , 1 } , { 1 , 0 , 1 , 0 } } ; int m = 3 ; ArrayList < Node > nodes = new ArrayList < Node > ( ) ; for ( int i = 0 ; i < n + 1 ; i ++ ) { nodes . add ( new Node ( ) ) ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( graph [ i ] [ j ] > 0 ) { nodes . get ( i ) . edges . add ( i ) ; nodes . get ( j ) . edges . add ( j ) ; } } } System . out . println ( canPaint ( nodes , n , m ) ) ; } }

Index/key variables: i, j
Accumulator variables: color, i, j, sv
Iterator variables: i, it, j, sv
Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { static int cntMaxOperationToMakeN_1_0 ( int [ ] arr , int N ) { int cntOp = 0 ; PriorityQueue < Integer > PQ = new PriorityQueue < Integer > ( ( a , b ) -> b - a ) ; for ( int i = 0 ; i < N ; i ++ ) { PQ . add ( arr [ i ] ) ; } while ( PQ . size ( ) > 1 ) { int X = PQ . peek ( ) ; PQ . remove ( ) ; int Y = PQ . peek ( ) ; PQ . remove ( ) ; X -- ; Y -- ; if ( X != 0 ) { PQ . add ( X ) ; } if ( Y != 0 ) { PQ . add ( Y ) ; } cntOp += 1 ; } return cntOp ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int N = arr . length ; System . out . print ( cntMaxOperationToMakeN_1_0 ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: X, Y, cntOp, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void flippingBits ( long N , long K ) { long X = ( 1 << ( K - 1 ) ) - 1 ; N = X - N ; System . out . print ( N ) ; } public static void main ( String [ ] args ) { long N = 1 , K = 8 ; flippingBits ( N , K ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void generateMatrix ( int N ) { int odd = 1 ; int even = 2 ; int [ ] [ ] mat = new int [ N + 1 ] [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { if ( ( i + j ) % 2 == 0 ) { mat [ i ] [ j ] = odd ; odd += 2 ; } else { mat [ i ] [ j ] = even ; even += 2 ; } } } for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { System . out . print ( mat [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int N = 4 ; generateMatrix ( N ) ; } }

Index/key variables: i, j
Accumulator variables: even, i, j, odd
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void build ( int tree [ ] , int arr [ ] , int start , int end , int index ) { if ( start == end ) { if ( start % 2 == 0 ) { tree [ index ] = arr [ start ] ; } else { tree [ index ] = - arr [ start ] ; } return ; } int mid = start + ( end - start ) / 2 ; build ( tree , arr , start , mid , 2 * index + 1 ) ; build ( tree , arr , mid + 1 , end , 2 * index + 2 ) ; tree [ index ] = tree [ 2 * index + 1 ] + tree [ 2 * index + 2 ] ; } static void update ( int tree [ ] , int index , int start , int end , int pos , int val ) { if ( start == end ) { if ( start % 2 == 0 ) { tree [ index ] = val ; } else { tree [ index ] = - val ; } return ; } int mid = start + ( end - start ) / 2 ; if ( mid >= pos ) { update ( tree , 2 * index + 1 , start , mid , pos , val ) ; } else { update ( tree , 2 * index + 2 , mid + 1 , end , pos , val ) ; } tree [ index ] = tree [ 2 * index + 1 ] + tree [ 2 * index + 2 ] ; } static int FindSum ( int tree [ ] , int start , int end , int L , int R , int index ) { if ( L > end R < start ) { return 0 ; } if ( L <= start && R >= end ) { return tree [ index ] ; } int mid = start + ( end - start ) / 2 ; int X = FindSum ( tree , start , mid , L , R , 2 * index + 1 ) ; int Y = FindSum ( tree , mid + 1 , end , L , R , 2 * index + 2 ) ; return X + Y ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int N = arr . length ; int tree [ ] = new int [ 4 * N + 5 ] ; Arrays . fill ( tree , 0 ) ; build ( tree , arr , 0 , N - 1 , 0 ) ; int Q [ ] [ ] = { { 2 , 0 , 3 } , { 1 , 1 , 5 } , { 2 , 1 , 2 } } ; int cntQuey = 3 ; for ( int i = 0 ; i < cntQuey ; i ++ ) { if ( Q [ i ] [ 0 ] == 1 ) { update ( tree , 0 , 0 , N - 1 , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] ) ; } else { if ( Q [ i ] [ 1 ] % 2 == 0 ) { System . out . print ( FindSum ( tree , 0 , N - 1 , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] , 0 ) + " ▁ " ) ; } else { System . out . print ( - FindSum ( tree , 0 , N - 1 , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] , 0 ) + " ▁ " ) ; } } } } }

Index/key variables: i, index, start
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void minimumSubarrays ( int [ ] arr , int n ) { char current = ' N ' ; int answer = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( current == ' N ' ) { if ( arr [ i ] < arr [ i - 1 ] ) { current = ' D ' ; } else if ( arr [ i ] == arr [ i - 1 ] ) { current = ' N ' ; } else { current = ' I ' ; } } else if ( current == ' I ' ) { if ( arr [ i ] >= arr [ i - 1 ] ) { current = ' I ' ; } else { current = ' N ' ; answer += 1 ; } } else { if ( arr [ i ] <= arr [ i - 1 ] ) { current = ' D ' ; } else { current = ' N ' ; answer += 1 ; } } } System . out . print ( answer ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 9 , 5 , 4 , 6 , 8 } ; int n = arr . length ; minimumSubarrays ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: answer, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void ConstMatrix ( int [ ] [ ] mat , int N , int M , int A , int B ) { if ( N * M != A * B ) return ; int idx = 0 ; int [ ] [ ] res = new int [ A ] [ B ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { res [ idx / B ] [ idx % B ] = mat [ i ] [ j ] ; idx ++ ; } } for ( int i = 0 ; i < A ; i ++ ) { for ( int j = 0 ; j < B ; j ++ ) System . out . print ( res [ i ] [ j ] + " ▁ " ) ; System . out . print ( "NEW_LINE"); } } public static void main ( String [ ] args ) { int mat [ ] [ ] = { { 1 , 2 , 3 , 4 , 5 , 6 } } ; int A = 2 ; int B = 3 ; int N = mat . length ; int M = mat [ 0 ] . length ; ConstMatrix ( mat , N , M , A , B ) ; } }

Index/key variables: A, B, i, j
Accumulator variables: i, idx, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printFinalPrices ( int [ ] arr ) { Stack < Integer > minStk = new Stack < > ( ) ; int n = arr . length ; int [ ] reduce = new int [ n ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( ! minStk . isEmpty ( ) ) { if ( minStk . peek ( ) <= arr [ i ] ) { reduce [ i ] = minStk . peek ( ) ; } else { while ( ! minStk . isEmpty ( ) && ( minStk . peek ( ) > arr [ i ] ) ) { minStk . pop ( ) ; } if ( ! minStk . isEmpty ( ) ) { reduce [ i ] = minStk . peek ( ) ; } } } minStk . add ( arr [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) System . out . print ( arr [ i ] - reduce [ i ] + " ▁ " ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 8 , 4 , 6 , 2 , 3 } ; printFinalPrices ( arr ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void constructArray ( int A [ ] , int N ) { int [ ] left = new int [ N + 1 ] ; int [ ] right = new int [ N + 1 ] ; int [ ] X = new int [ N + 1 ] ; int [ ] Y = new int [ N + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { X [ i ] = left [ A [ i ] ] ; left [ A [ i ] ] ++ ; } for ( int i = N - 1 ; i >= 0 ; i -- ) { Y [ i ] = right [ A [ i ] ] ; right [ A [ i ] ] ++ ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( Y [ i ] - X [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int A [ ] = { 3 , 2 , 1 , 2 , 3 } ; int N = A . length ; constructArray ( A , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Node { int data ; Node next ; } ; static Node head ; static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head_ref ; head_ref = new_node ; return head_ref ; } static int largestElement ( Node head_ref ) { int Max = Integer . MIN_VALUE ; Node head = head_ref ; while ( head != null ) { if ( Max < head . data ) { Max = head . data ; } head = head . next ; } return Max ; } static HashSet < Integer > createHashMap ( int Max ) { HashSet < Integer > hashmap = new HashSet < > ( ) ; int prev = 0 ; int curr = 1 ; hashmap . add ( prev ) ; hashmap . add ( curr ) ; while ( curr <= Max ) { int temp = curr + prev ; hashmap . add ( temp ) ; prev = curr ; curr = temp ; } return hashmap ; } static double meanofnodes ( ) { int Max = largestElement ( head ) ; HashSet < Integer > hashmap = createHashMap ( Max ) ; Node curr = head ; int cnt = 0 ; double sum = 0.0 ; while ( curr != null ) { if ( ( curr . data ) % 2 == 1 ) { if ( hashmap . contains ( curr . data ) ) { cnt ++ ; sum += curr . data ; hashmap . remove ( curr . data ) ; } } curr = curr . next ; } return ( sum / cnt ) ; } public static void main ( String [ ] args ) { head = null ; head = push ( head , 5 ) ; head = push ( head , 21 ) ; head = push ( head , 8 ) ; head = push ( head , 12 ) ; head = push ( head , 3 ) ; head = push ( head , 13 ) ; head = push ( head , 144 ) ; head = push ( head , 6 ) ; System . out . print ( meanofnodes ( ) ) ; } }

Accumulator variables: cnt, sum
Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { static void findNumbers ( int n ) { int i = 0 ; while ( i <= n ) { System . out . print ( 2 * i * i + 4 * i + 1 + i % 2 + " ▁ " ) ; i ++ ; } } public static void main ( String [ ] args ) { int n = 6 ; findNumbers ( n ) ; } }

Accumulator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int computeSalary ( int basic , char grade ) { double allowance ; double hra , da , pf ; hra = 0.2 * basic ; da = 0.5 * basic ; pf = 0.11 * basic ; if ( grade == ' A ' ) { allowance = 1700.0 ; } else if ( grade == ' B ' ) { allowance = 1500.0 ; } else { allowance = 1300.0 ; } double gross ; gross = Math . round ( basic + hra + da + allowance - pf ) ; return ( int ) gross ; } public static void main ( String [ ] args ) { int basic = 10000 ; char grade = ' A ' ; System . out . println ( computeSalary ( basic , grade ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void Queries ( int arr [ ] , int N , int [ ] [ ] Q ) { Vector < Integer > dq = new Vector < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { dq . add ( arr [ i ] ) ; } int sz = Q . length ; for ( int i = 0 ; i < sz ; i ++ ) { if ( Q [ i ] [ 0 ] == 0 ) { int front = dq . get ( 0 ) ; dq . remove ( 0 ) ; dq . add ( front ) ; } else if ( Q [ i ] [ 0 ] == 1 ) { int back = dq . elementAt ( dq . size ( ) - 1 ) ; dq . remove ( dq . size ( ) - 1 ) ; dq . add ( 0 , back ) ; } else if ( Q [ i ] [ 0 ] == 2 ) { dq . set ( Q [ i ] [ 1 ] , Q [ i ] [ 2 ] ) ; } else { System . out . print ( dq . get ( Q [ i ] [ 1 ] ) + " ▁ " ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int N = arr . length ; int [ ] [ ] Q = { { 0 } , { 1 } , { 3 , 1 } , { 2 , 2 , 54 } , { 3 , 2 } } ; Queries ( arr , N , Q ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int smallSubarray ( int arr [ ] , int n , int total_sum ) { Map < Integer , Integer > m = new HashMap < Integer , Integer > ( ) ; int length = Integer . MAX_VALUE ; int prefixSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { prefixSum += arr [ i ] ; if ( prefixSum == total_sum ) { length = Math . min ( length , i + 1 ) ; } m . put ( prefixSum , i ) ; if ( m . containsKey ( prefixSum - total_sum ) ) { length = Math . min ( length , i - m . get ( prefixSum - total_sum ) ) ; } } return length ; } static int smallestSubarrayremoved ( int arr [ ] , int n , int k ) { int total_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > k ) { arr [ i ] = 1 ; } else if ( arr [ i ] < k ) { arr [ i ] = - 1 ; } else { arr [ i ] = 0 ; } total_sum += arr [ i ] ; } if ( total_sum == 0 ) { return 0 ; } else { return smallSubarray ( arr , n , total_sum ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 12 , 16 , 12 , 13 , 10 } ; int K = 13 ; int n = arr . length ; System . out . println ( smallestSubarrayremoved ( arr , n , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, prefixSum, total_sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static String balancedTernary ( int n ) { String output = " " ; while ( n > 0 ) { int rem = n % 3 ; n = n / 3 ; if ( rem == 2 ) { rem = - 1 ; n ++ ; } output = ( rem == 0 ? '0' : ( rem == 1 ) ? '1' : ' Z ' ) + output ; } return output ; } public static void main ( String [ ] args ) { int n = 238 ; System . out . print ( " Equivalent ▁ Balanced ▁ Ternary ▁ of ▁ " + n + " ▁ is : ▁ " + balancedTernary ( n ) ) ; } }

Accumulator variables: n
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int spt = 0 ; static int count ( Vector < Integer > arr , int min_i ) { int count = 0 ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) if ( min_i == arr . get ( i ) ) count ++ ; return count ; } static void printVector ( Vector < Integer > arr ) { int min_i = Integer . MAX_VALUE ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) min_i = Math . min ( min_i , arr . elementAt ( i ) ) ; int freq = count ( arr , min_i ) ; spt += freq ; } static void findWays ( Vector < Integer > arr , int i , int n ) { if ( n == 0 ) printVector ( arr ) ; for ( int j = i ; j <= n ; j ++ ) { arr . add ( j ) ; findWays ( arr , j , n - j ) ; arr . remove ( arr . size ( ) - 1 ) ; } } static void spt_function ( int n ) { Vector < Integer > arr = new Vector < > ( ) ; findWays ( arr , 1 , n ) ; System . out . print ( spt ) ; } public static void main ( String [ ] args ) { int N = 4 ; spt_function ( N ) ; } }

Accumulator variables: count, i, j, spt
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int x , y ; static int gcd_extend ( int a , int b ) { if ( b == 0 ) { x = 1 ; y = 0 ; return a ; } else { int g = gcd_extend ( b , a % b ) ; int x1 = x , y1 = y ; x = y1 ; y = x1 - ( a / b ) * y1 ; return g ; } } static void print_solution ( int a , int b , int c ) { if ( a == 0 && b == 0 ) { if ( c == 0 ) { System . out . print ( " Infinite ▁ Solutions ▁ " + " Exist " + "NEW_LINE"); } else { System . out . print ( " No ▁ Solution ▁ exists " + "NEW_LINE"); } } int gcd = gcd_extend ( a , b ) ; if ( c % gcd != 0 ) { System . out . print ( " No ▁ Solution ▁ exists " + "NEW_LINE"); } else { System . out . print ( " x ▁ = ▁ " + x * ( c / gcd ) + " , ▁ y ▁ = ▁ " + y * ( c / gcd ) + "NEW_LINE"); } } public static void main ( String [ ] args ) { int a , b , c ; a = 4 ; b = 18 ; c = 10 ; print_solution ( a , b , c ) ; } }

Class/struct names: GFG
Java program:
class GFG { static boolean check ( int x ) { return x != 0 && ( ( x & ( x - 1 ) ) == 0 ) ; } static int count ( int arr [ ] , int n ) { int cnt = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( check ( arr [ i ] & arr [ j ] ) ) cnt ++ ; } } return cnt ; } public static void main ( String [ ] args ) { int arr [ ] = new int [ ] { 6 , 4 , 2 , 3 } ; int n = arr . length ; System . out . print ( count ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static boolean isPrime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) if ( n % i == 0 ) return false ; return true ; } static int takeSum ( int a [ ] [ ] ) { int sum = 0 ; for ( int i = 0 ; i < 4 ; i ++ ) for ( int j = 0 ; j < 5 ; j ++ ) sum += a [ i ] [ j ] ; return sum ; } static boolean checkIndex ( int n , int m , int a [ ] [ ] ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( isPrime ( i + j ) ) { if ( ! isPrime ( a [ i ] [ j ] ) ) return false ; } } } return true ; } public static void main ( String [ ] args ) { int n = 4 , m = 5 ; int a [ ] [ ] = { { 1 , 2 , 3 , 2 , 2 } , { 2 , 2 , 7 , 7 , 7 } , { 7 , 7 , 21 , 7 , 10 } , { 2 , 2 , 3 , 6 , 7 } } ; int sum = takeSum ( a ) ; if ( isPrime ( sum ) && checkIndex ( n , m , a ) ) { System . out . print ( " YES " + "NEW_LINE"); } else { System . out . print ( " NO " + "NEW_LINE"); } } }

Index/key variables: i, j
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countPairs ( int [ ] A , int n ) { int count = 0 , i , j ; for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { if ( ( A [ i ] % 2 == 0 && A [ j ] % 2 == 0 ) || ( A [ i ] % 2 != 0 && A [ j ] % 2 != 0 ) ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { int [ ] A = { 1 , 2 , 3 , 1 , 3 } ; int n = A . length ; System . out . println ( countPairs ( A , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int smallestNum ( int n ) { return ( int ) ( ( n * n % 9 + 1 ) * Math . pow ( 10 , n * n / 9 ) - 1 ) ; } public static void main ( String [ ] args ) { int n = 4 ; System . out . print ( smallestNum ( n ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void findNthTerm ( int n ) { System . out . println ( n * ( 5 * n + 3 ) / 2 ) ; } public static void main ( String [ ] args ) { int N = 4 ; findNthTerm ( N ) ; } } findNthTerm ( N ) ; } }

Class/struct names: GFG
Java program:
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 boolean isWeaklyPrimeNum ( int N ) { if ( ! isPrime ( N ) ) return false ; String s = String . valueOf ( N ) ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { char [ ] str = s . toCharArray ( ) ; for ( int i = 0 ; i <= 9 ; i ++ ) { char c = ( char ) ( '0' + i ) ; str [ j ] = c ; int Num = Integer . valueOf ( String . valueOf ( str ) ) ; if ( str [ j ] != s . charAt ( j ) && isPrime ( Num ) ) { return false ; } } } return true ; } public static void main ( String [ ] args ) { int n = 294001 ; if ( isWeaklyPrimeNum ( n ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
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 boolean isUnPrimeableNum ( int N ) { if ( isPrime ( N ) ) return false ; String s = String . valueOf ( N ) ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { char [ ] str = s . toCharArray ( ) ; for ( int i = 0 ; i <= 9 ; i ++ ) { char c = ( char ) ( '0' + i ) ; str [ j ] = c ; int Num = Integer . valueOf ( new String ( str ) ) ; if ( str [ j ] != s . charAt ( j ) && isPrime ( Num ) ) { return false ; } } } return true ; } public static void main ( String [ ] args ) { int n = 200 ; if ( isUnPrimeableNum ( n ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

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