dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static int NO_OF_CHARS = 256 ; static boolean areAnagram ( char [ ] str1 , char [ ] str2 ) { int [ ] count = new int [ NO_OF_CHARS ] ; int i ; for ( i = 0 ; i < str1 . length ; i ++ ) { count [ str1 [ i ] - ' a ' ] ++ ; count [ str2 [ i ] - ' a ' ] -- ; } if ( str1 . length != str2 . length ) return false ; for ( i = 0 ; i < NO_OF_CHARS ; i ++ ) if ( count [ i ] != 0 ) { return false ; } return true ; } public static void main ( String [ ] args ) { char str1 [ ] = " geeksforgeeks " . toCharArray ( ) ; char str2 [ ] = " forgeeksgeeks " . toCharArray ( ) ; if ( areAnagram ( str1 , str2 ) ) System . out . print ( " The ▁ two ▁ strings ▁ are ▁ " + " anagram ▁ of ▁ each ▁ other " ) ; else System . out . print ( " The ▁ two ▁ strings ▁ are ▁ " + " not ▁ anagram ▁ of ▁ each ▁ other " ) ; } }

Index/key variables: NO_OF_CHARS, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { public static int firstNonRepeating ( String str ) { int [ ] fi = new int [ 256 ] ; for ( int i = 0 ; i < 256 ; i ++ ) fi [ i ] = - 1 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( fi [ str . charAt ( i ) ] == - 1 ) { fi [ str . charAt ( i ) ] = i ; } else { fi [ str . charAt ( i ) ] = - 2 ; } } int res = Integer . MAX_VALUE ; for ( int i = 0 ; i < 256 ; i ++ ) { if ( fi [ i ] >= 0 ) res = Math . min ( res , fi [ i ] ) ; } if ( res == Integer . MAX_VALUE ) return - 1 ; else return res ; } public static void main ( String args [ ] ) { String str ; str = " geeksforgeeks " ; int firstIndex = firstNonRepeating ( str ) ; if ( firstIndex == - 1 ) System . out . println ( " Either ▁ all ▁ characters ▁ are ▁ repeating ▁ or ▁ string ▁ is ▁ empty " ) ; else System . out . println ( " First ▁ non - repeating ▁ character ▁ is ▁ " + str . charAt ( firstIndex ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class IndexOf { public static String unique ( String s ) { String str = new String ( ) ; int len = s . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { char c = s . charAt ( i ) ; if ( str . indexOf ( c ) < 0 ) { str += c ; } } return str ; } public static void main ( String [ ] args ) { String s = " geeksforgeeks " ; System . out . println ( unique ( s ) ) ; } }

Accumulator variables: i, str
Iterator variables: i
Class/struct names: IndexOf
Java program:
import java . io . * ; import java . util . * ; class GFG { static int isPerfect ( int x ) { int sum_div = 1 ; for ( int i = 2 ; i <= x / 2 ; ++ i ) { if ( x % i == 0 ) { sum_div += i ; } } if ( sum_div == x ) { return 1 ; } else return 0 ; } static void subsetSum ( int [ ] arr , int l , int r , int sum ) { if ( l > r ) { if ( isPerfect ( sum ) != 0 ) { System . out . print ( sum + " ▁ " ) ; } return ; } subsetSum ( arr , l + 1 , r , sum + arr [ l ] ) ; subsetSum ( arr , l + 1 , r , sum ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 5 , 4 , 6 } ; int N = arr . length ; subsetSum ( arr , 0 , N - 1 , 0 ) ; } }

Index/key variables: l
Accumulator variables: sum_div
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class Gfg { static void PartitionSub ( int arr [ ] , int i , int N , int K , int nos , ArrayList < ArrayList < Integer > > v ) { if ( i >= N ) { if ( nos == K ) { for ( int x = 0 ; x < v . size ( ) ; x ++ ) { System . out . print ( " { ▁ " ) ; for ( int y = 0 ; y < v . get ( x ) . size ( ) ; y ++ ) { System . out . print ( v . get ( x ) . get ( y ) ) ; if ( y == v . get ( x ) . size ( ) - 1 ) { System . out . print ( " ▁ " ) ; } else { System . out . print ( " , ▁ " ) ; } } if ( x == v . size ( ) - 1 ) { System . out . print ( " } " ) ; } else { System . out . print ( " } , ▁ " ) ; } } System . out . println ( ) ; ; } return ; } for ( int j = 0 ; j < K ; j ++ ) { if ( v . get ( j ) . size ( ) > 0 ) { v . get ( j ) . add ( arr [ i ] ) ; PartitionSub ( arr , i + 1 , N , K , nos , v ) ; v . get ( j ) . remove ( v . get ( j ) . size ( ) - 1 ) ; } else { v . get ( j ) . add ( arr [ i ] ) ; PartitionSub ( arr , i + 1 , N , K , nos + 1 , v ) ; v . get ( j ) . remove ( v . get ( j ) . size ( ) - 1 ) ; break ; } } } static void partKSubsets ( int arr [ ] , int N , int K ) { ArrayList < ArrayList < Integer > > v = new ArrayList < > ( ) ; for ( int i = 0 ; i < K ; i ++ ) v . add ( new ArrayList < > ( ) ) ; if ( K == 0 K > N ) { System . out . println ( " Not ▁ Possible " ) ; } else { System . out . println ( " The ▁ Subset ▁ Combinations ▁ are : ▁ " ) ; PartitionSub ( arr , 0 , N , K , 0 , v ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int K = 2 ; int N = arr . length ; partKSubsets ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: i, j, x, y
Iterator variables: i, j, x, y
Class/struct names: Gfg
Java program:
import java . io . * ; import java . util . * ; class GFG { static final int MAX = 100 ; static int [ ] store = new int [ MAX ] ; static int n ; static int [ ] [ ] graph = new int [ MAX ] [ MAX ] ; static int [ ] d = new int [ MAX ] ; static int ans ; static void SieveOfEratosthenes ( boolean prime [ ] , int p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } static boolean is_clique ( int b ) { for ( int i = 1 ; i < b ; i ++ ) { for ( int j = i + 1 ; j < b ; j ++ ) if ( graph [ store [ i ] ] [ store [ j ] ] == 0 ) return false ; } return true ; } static void primeCliques ( int i , int l , boolean prime [ ] ) { for ( int j = i + 1 ; j <= n ; j ++ ) { store [ l ] = j ; if ( is_clique ( l + 1 ) ) { if ( prime [ l ] ) ans ++ ; primeCliques ( j , l + 1 , prime ) ; } } } public static void main ( String [ ] args ) { int edges [ ] [ ] = { { 1 , 2 } , { 2 , 3 } , { 3 , 1 } , { 4 , 3 } , { 4 , 5 } , { 5 , 3 } } ; int size = edges . length ; n = 5 ; boolean [ ] prime = new boolean [ n + 1 ] ; Arrays . fill ( prime , true ) ; SieveOfEratosthenes ( prime , n ) ; for ( int i = 0 ; i < size ; i ++ ) { graph [ edges [ i ] [ 0 ] ] [ edges [ i ] [ 1 ] ] = 1 ; graph [ edges [ i ] [ 1 ] ] [ edges [ i ] [ 0 ] ] = 1 ; d [ edges [ i ] [ 0 ] ] ++ ; d [ edges [ i ] [ 1 ] ] ++ ; } ans = 0 ; primeCliques ( 0 , 1 , prime ) ; System . out . println ( ans ) ; } }

Index/key variables: MAX, i, j, l, p
Accumulator variables: ans, i, j, p
Iterator variables: i, j, p
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int dim = 3 ; static class Node { int data ; Node next ; Node prev ; Node up ; Node down ; } ; static Node createNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . next = null ; temp . prev = null ; temp . up = null ; temp . down = null ; return temp ; } static Node constructDoublyListUtil ( int mtrx [ ] [ ] , int i , int j , Node curr ) { if ( i >= dim j >= dim ) { return null ; } Node temp = createNode ( mtrx [ i ] [ j ] ) ; temp . prev = curr ; temp . up = curr ; temp . next = constructDoublyListUtil ( mtrx , i , j + 1 , temp ) ; temp . down = constructDoublyListUtil ( mtrx , i + 1 , j , temp ) ; return temp ; } static Node constructDoublyList ( int mtrx [ ] [ ] ) { return constructDoublyListUtil ( mtrx , 0 , 0 , null ) ; } static void display ( Node head ) { Node rPtr ; Node dPtr = head ; while ( dPtr != null ) { rPtr = dPtr ; while ( rPtr != null ) { System . out . print ( rPtr . data + " ▁ " ) ; rPtr = rPtr . next ; } System . out . print ( "NEW_LINE"); dPtr = dPtr . down ; } } public static void main ( String args [ ] ) { int mtrx [ ] [ ] = { { 1 , 2 , 3 } , { 4 , 5 , 6 } , { 7 , 8 , 9 } } ; Node list = constructDoublyList ( mtrx ) ; display ( list ) ; } }

Index/key variables: i, j
Class/struct names: GFG, Node
Java program:
import java . util . * ; import java . lang . * ; class GFG { static class Node { int key ; Node left , right ; } static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = temp . right = null ; return ( temp ) ; } static int find_x ( int n ) { if ( n == 1 ) return 1 ; double num , den , p ; num = Math . log10 ( n ) ; int x = 0 , no = 0 ; for ( int i = 2 ; i <= n ; i ++ ) { den = Math . log10 ( i ) ; p = num / den ; no = ( int ) ( Math . pow ( i , ( int ) p ) ) ; if ( Math . abs ( no - n ) < 1e-6 ) { x = i ; break ; } } return x ; } static boolean is_key ( int n , int x ) { double p ; p = Math . log10 ( n ) / Math . log10 ( x ) ; int no = ( int ) ( Math . pow ( x , ( int ) p ) ) ; if ( n == no ) return true ; return false ; } static int evenPaths ( Node node , int count , int x ) { if ( node == null || ! is_key ( node . key , x ) ) { return count ; } if ( node . left == null && node . right == null ) { count ++ ; } count = evenPaths ( node . left , count , x ) ; return evenPaths ( node . right , count , x ) ; } static int countExpPaths ( Node node , int x ) { return evenPaths ( node , 0 , x ) ; } public static void main ( String [ ] args ) { Node root = newNode ( 27 ) ; root . left = newNode ( 9 ) ; root . right = newNode ( 81 ) ; root . left . left = newNode ( 3 ) ; root . left . right = newNode ( 10 ) ; root . right . left = newNode ( 70 ) ; root . right . right = newNode ( 243 ) ; root . right . right . left = newNode ( 81 ) ; root . right . right . right = newNode ( 909 ) ; int x = find_x ( root . key ) ; System . out . println ( countExpPaths ( root , x ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { static int N = 1000001 ; static int c , n , m , a , b ; static void dfs ( int a , int b , Vector < Integer > v [ ] , int vis [ ] ) { vis [ a ] = 1 ; c ++ ; for ( int i : v [ a ] ) { if ( vis [ i ] == 0 && i != b ) dfs ( i , b , v , vis ) ; } } static void Calculate ( Vector < Integer > v [ ] ) { int [ ] vis = new int [ n + 1 ] ; Arrays . fill ( vis , 0 ) ; c = 0 ; dfs ( a , b , v , vis ) ; int ans1 = n - c - 1 ; Arrays . fill ( vis , 0 ) ; c = 0 ; dfs ( b , a , v , vis ) ; int ans2 = n - c - 1 ; System . out . print ( ans1 * ans2 + "NEW_LINE"); } public static void main ( String [ ] args ) { n = 7 ; m = 7 ; a = 3 ; b = 5 ; int edges [ ] [ ] = { { 1 , 2 } , { 2 , 3 } , { 3 , 4 } , { 4 , 5 } , { 5 , 6 } , { 6 , 7 } , { 7 , 5 } } ; Vector < Integer > [ ] v = new Vector [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { v [ i ] = new Vector < Integer > ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { v [ edges [ i ] [ 0 ] ] . add ( edges [ i ] [ 1 ] ) ; v [ edges [ i ] [ 1 ] ] . add ( edges [ i ] [ 0 ] ) ; } Calculate ( v ) ; } }

Index/key variables: a, i
Accumulator variables: c, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int tsp ( int [ ] [ ] graph , boolean [ ] v , int currPos , int n , int count , int cost , int ans ) { if ( count == n && graph [ currPos ] [ 0 ] > 0 ) { ans = Math . min ( ans , cost + graph [ currPos ] [ 0 ] ) ; return ans ; } for ( int i = 0 ; i < n ; i ++ ) { if ( v [ i ] == false && graph [ currPos ] [ i ] > 0 ) { v [ i ] = true ; ans = tsp ( graph , v , i , n , count + 1 , cost + graph [ currPos ] [ i ] , ans ) ; v [ i ] = false ; } } return ans ; } public static void main ( String [ ] args ) { int n = 4 ; int [ ] [ ] graph = { { 0 , 10 , 15 , 20 } , { 10 , 0 , 35 , 25 } , { 15 , 35 , 0 , 30 } , { 20 , 25 , 30 , 0 } } ; boolean [ ] v = new boolean [ n ] ; v [ 0 ] = true ; int ans = Integer . MAX_VALUE ; ans = tsp ( graph , v , 0 , n , 1 , 0 , ans ) ; System . out . println ( ans ) ; } }

Index/key variables: currPos, i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void printTheArray ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } System . out . println ( ) ; } static void generateAllBinaryStrings ( int n , int arr [ ] , int i ) { if ( i == n ) { printTheArray ( arr , n ) ; return ; } arr [ i ] = 0 ; generateAllBinaryStrings ( n , arr , i + 1 ) ; arr [ i ] = 1 ; generateAllBinaryStrings ( n , arr , i + 1 ) ; } public static void main ( String args [ ] ) { int n = 4 ; int [ ] arr = new int [ n ] ; generateAllBinaryStrings ( n , arr , 0 ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . HashMap ; class GFG { static void printResult ( char [ ] result , int len ) { for ( int i = 0 ; i <= len ; i ++ ) System . out . print ( result [ i ] ) ; System . out . println ( ) ; } static void stringCombination ( char [ ] result , char [ ] str , int [ ] count , int level , int size , int length ) { if ( level == size ) return ; for ( int i = 0 ; i < length ; i ++ ) { if ( count [ i ] == 0 ) continue ; count [ i ] -- ; result [ level ] = str [ i ] ; printResult ( result , level ) ; stringCombination ( result , str , count , level + 1 , size , length ) ; count [ i ] ++ ; } } static void combination ( String str ) { HashMap < Character , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) mp . put ( str . charAt ( i ) , mp . get ( str . charAt ( i ) ) == null ? 1 : mp . get ( str . charAt ( i ) ) + 1 ) ; char [ ] input = new char [ mp . size ( ) ] ; int [ ] count = new int [ mp . size ( ) ] ; char [ ] result = new char [ str . length ( ) ] ; int i = 0 ; for ( HashMap . Entry < Character , Integer > entry : mp . entrySet ( ) ) { input [ i ] = entry . getKey ( ) ; count [ i ] = entry . getValue ( ) ; i ++ ; } int length = mp . size ( ) ; int size = str . length ( ) ; stringCombination ( result , input , count , 0 , size , length ) ; } public static void main ( String [ ] args ) { String str = " ABC " ; combination ( str ) ; } }

Index/key variables: i, level
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Vector ; class Test { static void allCombinationsRec ( Vector < Integer > arr , int elem , int n ) { if ( elem > n ) { for ( int i : arr ) System . out . print ( i + " ▁ " ) ; System . out . println ( ) ; return ; } for ( int i = 0 ; i < 2 * n ; i ++ ) { if ( arr . get ( i ) == - 1 && ( i + elem + 1 ) < 2 * n && arr . get ( i + elem + 1 ) == - 1 ) { arr . set ( i , elem ) ; arr . set ( i + elem + 1 , elem ) ; allCombinationsRec ( arr , elem + 1 , n ) ; arr . set ( i , - 1 ) ; arr . set ( i + elem + 1 , - 1 ) ; } } } static void allCombinations ( int n ) { Vector < Integer > arr = new Vector < > ( ) ; for ( int i = 0 ; i < 2 * n ; i ++ ) { arr . add ( - 1 ) ; } int elem = 1 ; allCombinationsRec ( arr , elem , n ) ; } public static void main ( String [ ] args ) { int n = 3 ; allCombinations ( n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: Test
Java program:
import java . util . concurrent . ThreadLocalRandom ; class GFG { public static final int N = 8 ; public static final int cx [ ] = { 1 , 1 , 2 , 2 , - 1 , - 1 , - 2 , - 2 } ; public static final int cy [ ] = { 2 , - 2 , 1 , - 1 , 2 , - 2 , 1 , - 1 } ; boolean limits ( int x , int y ) { return ( ( x >= 0 && y >= 0 ) && ( x < N && y < N ) ) ; } boolean isempty ( int a [ ] , int x , int y ) { return ( limits ( x , y ) ) && ( a [ y * N + x ] < 0 ) ; } int getDegree ( int a [ ] , int x , int y ) { int count = 0 ; for ( int i = 0 ; i < N ; ++ i ) if ( isempty ( a , ( x + cx [ i ] ) , ( y + cy [ i ] ) ) ) count ++ ; return count ; } Cell nextMove ( int a [ ] , Cell cell ) { int min_deg_idx = - 1 , c , min_deg = ( N + 1 ) , nx , ny ; int start = ThreadLocalRandom . current ( ) . nextInt ( 1000 ) % N ; for ( int count = 0 ; count < N ; ++ count ) { int i = ( start + count ) % N ; nx = cell . x + cx [ i ] ; ny = cell . y + cy [ i ] ; if ( ( isempty ( a , nx , ny ) ) && ( c = getDegree ( a , nx , ny ) ) < min_deg ) { min_deg_idx = i ; min_deg = c ; } } if ( min_deg_idx == - 1 ) return null ; nx = cell . x + cx [ min_deg_idx ] ; ny = cell . y + cy [ min_deg_idx ] ; a [ ny * N + nx ] = a [ ( cell . y ) * N + ( cell . x ) ] + 1 ; cell . x = nx ; cell . y = ny ; return cell ; } void print ( int a [ ] ) { for ( int i = 0 ; i < N ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) System . out . printf ( " % d TABSYMBOL " , a [ j * N + i ] ) ; System . out . printf ( "NEW_LINE"); } } boolean neighbour ( int x , int y , int xx , int yy ) { for ( int i = 0 ; i < N ; ++ i ) if ( ( ( x + cx [ i ] ) == xx ) && ( ( y + cy [ i ] ) == yy ) ) return true ; return false ; } boolean findClosedTour ( ) { int a [ ] = new int [ N * N ] ; for ( int i = 0 ; i < N * N ; ++ i ) a [ i ] = - 1 ; int sx = 3 ; int sy = 2 ; Cell cell = new Cell ( sx , sy ) ; Cell ret = null ; for ( int i = 0 ; i < N * N - 1 ; ++ i ) { ret = nextMove ( a , cell ) ; if ( ret == null ) return false ; } if ( ! neighbour ( ret . x , ret . y , sx , sy ) ) return false ; print ( a ) ; return true ; } public static void main ( String [ ] args ) { while ( ! new GFG ( ) . findClosedTour ( ) ) { ; } } } class Cell { int x ; int y ; public Cell ( int x , int y ) { this . x = x ; this . y = y ; } }

Index/key variables: i, min_deg_idx
Accumulator variables: count
Iterator variables: count, i, j
Class/struct names: Cell, GFG
Java program:
import java . util . * ; public class NQueenSolution { static List < List < Integer > > result = new ArrayList < List < Integer > > ( ) ; public void solveBoard ( char [ ] [ ] board , int row , int rowmask , int ldmask , int rdmask ) { int n = board . length ; int all_rows_filled = ( 1 << n ) - 1 ; if ( rowmask == all_rows_filled ) { List < Integer > v = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( board [ i ] [ j ] == ' Q ' ) v . add ( j + 1 ) ; } } result . add ( v ) ; return ; } int safe = all_rows_filled & ( ~ ( rowmask ldmask rdmask ) ) ; while ( safe > 0 ) { int p = safe & ( - safe ) ; int col = ( int ) ( Math . log ( p ) / Math . log ( 2 ) ) ; board [ row ] [ col ] = ' Q ' ; solveBoard ( board , row + 1 , rowmask | p , ( ldmask p ) << 1 , ( rdmask p ) >> 1 ) ; safe = safe & ( safe - 1 ) ; board [ row ] [ col ] = ' ▁ ' ; } } public void printBoard ( char [ ] [ ] board ) { for ( int i = 0 ; i < board . length ; i ++ ) { System . out . print ( " ▁ " ) ; for ( int j = 0 ; j < board [ i ] . length ; j ++ ) { System . out . print ( board [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String args [ ] ) { int n = 4 ; char board [ ] [ ] = new char [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { board [ i ] [ j ] = ' ▁ ' ; } } int rowmask = 0 , ldmask = 0 , rdmask = 0 ; int row = 0 ; NQueenSolution solution = new NQueenSolution ( ) ; result . clear ( ) ; solution . solveBoard ( board , row , rowmask , ldmask , rdmask ) ; System . out . println ( result ) ; } }

Index/key variables: col, i, j, n, row
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: NQueenSolution
Java program:
import java . io . * ; class GFG { static boolean fillUtil ( int res [ ] , int curr , int n ) { if ( curr == 0 ) return true ; int i ; for ( i = 0 ; i < 2 * n - curr - 1 ; i ++ ) { if ( res [ i ] == 0 && res [ i + curr + 1 ] == 0 ) { res [ i ] = res [ i + curr + 1 ] = curr ; if ( fillUtil ( res , curr - 1 , n ) ) return true ; res [ i ] = res [ i + curr + 1 ] = 0 ; } } return false ; } static void fill ( int n ) { int res [ ] = new int [ 2 * n ] ; int i ; for ( i = 0 ; i < 2 * n ; i ++ ) res [ i ] = 0 ; if ( fillUtil ( res , n , n ) ) { for ( i = 0 ; i < 2 * n ; i ++ ) System . out . print ( res [ i ] + " ▁ " ) ; } else System . out . print ( " Not ▁ Possible " ) ; } public static void main ( String [ ] args ) { fill ( 7 ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
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 } } ; 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:
class GFG { static void FastDoubling ( int n , int [ ] res ) { int a , b , c , d ; int MOD = 1000000007 ; if ( n == 0 ) { res [ 0 ] = 0 ; res [ 1 ] = 1 ; return ; } FastDoubling ( ( n / 2 ) , res ) ; a = res [ 0 ] ; b = res [ 1 ] ; c = 2 * b - a ; if ( c < 0 ) c += MOD ; c = ( a * c ) % MOD ; d = ( a * a + b * b ) % MOD ; if ( n % 2 == 0 ) { res [ 0 ] = c ; res [ 1 ] = d ; } else { res [ 0 ] = d ; res [ 1 ] = c + d ; } } public static void main ( String [ ] args ) { int N = 6 ; int res [ ] = new int [ 2 ] ; FastDoubling ( N , res ) ; System . out . print ( res [ 0 ] ) ; } }

Accumulator variables: c
Class/struct names: GFG
Java program:
class GFG { static int count ( int arr [ ] , int low , int high , int x ) { if ( ( low > high ) || ( low == high && arr [ low ] != x ) ) return 0 ; if ( low == high && arr [ low ] == x ) return 1 ; return count ( arr , low , ( low + high ) / 2 , x ) + count ( arr , 1 + ( low + high ) / 2 , high , x ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 30 , 1 , 42 , 5 , 56 , 3 , 56 , 9 } ; int n = arr . length ; int x = 56 ; System . out . print ( count ( arr , 0 , n - 1 , x ) ) ; } }

Index/key variables: low
Class/struct names: GFG
Java program:
class GFG { static int a , b ; static int [ ] swap ( int [ ] arr , int i , int j ) { int temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; return arr ; } static int Partition ( int arr [ ] , int l , int r ) { int lst = arr [ r ] , i = l , j = l ; while ( j < r ) { if ( arr [ j ] < lst ) { arr = swap ( arr , i , j ) ; i ++ ; } j ++ ; } arr = swap ( arr , i , r ) ; return i ; } static int randomPartition ( int arr [ ] , int l , int r ) { int n = r - l + 1 ; int pivot = ( int ) ( Math . random ( ) % n ) ; arr = swap ( arr , l + pivot , r ) ; return Partition ( arr , l , r ) ; } static int MedianUtil ( int arr [ ] , int l , int r , int k ) { if ( l <= r ) { int partitionIndex = randomPartition ( arr , l , r ) ; if ( partitionIndex == k ) { b = arr [ partitionIndex ] ; if ( a != - 1 ) return Integer . MIN_VALUE ; } else if ( partitionIndex == k - 1 ) { a = arr [ partitionIndex ] ; if ( b != - 1 ) return Integer . MIN_VALUE ; } if ( partitionIndex >= k ) return MedianUtil ( arr , l , partitionIndex - 1 , k ) ; else return MedianUtil ( arr , partitionIndex + 1 , r , k ) ; } return Integer . MIN_VALUE ; } static void findMedian ( int arr [ ] , int n ) { int ans ; a = - 1 ; b = - 1 ; if ( n % 2 == 1 ) { MedianUtil ( arr , 0 , n - 1 , n / 2 ) ; ans = b ; } else { MedianUtil ( arr , 0 , n - 1 , n / 2 ) ; ans = ( a + b ) / 2 ; } System . out . print ( " Median ▁ = ▁ " + ans ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 12 , 3 , 5 , 7 , 4 , 19 , 26 } ; int n = arr . length ; findMedian ( arr , n ) ; } }

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