dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . io . * ; import java . util . * ; class GFG { static int digiSum ( int a ) { int sum = 0 ; while ( a != 0 ) { sum += a % 10 ; a = a / 10 ; } return sum ; } static boolean isPrime ( int r ) { boolean s = true ; for ( int i = 2 ; i * i <= r ; i ++ ) { if ( r % i == 0 ) { s = false ; break ; } } return s ; } static boolean isMorannumber ( int n ) { int dup = n ; int sum = digiSum ( dup ) ; if ( n % sum == 0 ) { int c = n / sum ; if ( isPrime ( c ) ) { return true ; } } return false ; } static void FirstKMorannumber ( int [ ] a , int n , int k ) { int X = k ; Arrays . sort ( a ) ; TreeSet < Integer > s = new TreeSet < Integer > ( ) ; for ( int i = n - 1 ; i >= 0 && k > 0 ; i -- ) { if ( isMorannumber ( a [ i ] ) ) { s . add ( a [ i ] ) ; k -- ; } } if ( k > 0 ) { System . out . println ( X + " ▁ Moran ▁ numbers ▁ are " + " ▁ not ▁ present ▁ in ▁ the ▁ array " ) ; return ; } for ( int value : s ) System . out . print ( value + " , ▁ " ) ; System . out . print ( "NEW_LINE"); } public static void main ( String [ ] args ) { int [ ] A = { 34 , 198 , 21 , 42 , 63 , 45 , 22 , 44 , 43 } ; int K = 4 ; int N = A . length ; FirstKMorannumber ( A , N , K ) ; } }

Index/key variables: i
Accumulator variables: i, k, sum
Iterator variables: i, value
Boolean variables: s
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countPair ( int [ ] arr , int n ) { Map < Integer , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) m . put ( arr [ i ] , m . getOrDefault ( arr [ i ] , 0 ) + 1 ) ; int ans = 0 ; for ( int i = 0 ; i < 31 ; i ++ ) { int key = ( int ) Math . pow ( 2 , i ) ; for ( int j = 0 ; j < arr . length ; j ++ ) { int k = key - arr [ j ] ; ans += m . getOrDefault ( k , 0 ) ; if ( k == arr [ j ] ) ans ++ ; } } return ans / 2 ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , - 1 , 2 , 3 } ; int n = arr . length ; System . out . println ( countPair ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static boolean isdivisible ( StringBuilder newstr , long K ) { long num = 0 ; for ( int i = 0 ; i < newstr . length ( ) ; i ++ ) { num = num * 10 + newstr . charAt ( i ) - '0' ; } if ( num % K == 0 ) return true ; else return false ; } static void findLargestNo ( String str , StringBuilder newstr , StringBuilder ans , int index , long K ) { if ( index == str . length ( ) ) { if ( isdivisible ( newstr , K ) ) { if ( ( newstr . toString ( ) . compareTo ( ans . toString ( ) ) > 0 && ans . length ( ) == newstr . length ( ) ) || newstr . length ( ) > ans . length ( ) ) { ans . setLength ( 0 ) ; ans . append ( newstr ) ; } } return ; } StringBuilder x = new StringBuilder ( newstr . toString ( ) + str . charAt ( index ) ) ; findLargestNo ( str , x , ans , index + 1 , K ) ; findLargestNo ( str , newstr , ans , index + 1 , K ) ; } public static void main ( String [ ] args ) { String str = "121400" ; StringBuilder ans = new StringBuilder ( ) , newstr = new StringBuilder ( ) ; long K = 8 ; findLargestNo ( str , newstr , ans , 0 , K ) ; if ( ans . toString ( ) != " " ) System . out . println ( ans ) ; else System . out . println ( - 1 ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . io . * ; class GFG { static ArrayList < Integer > findRockSample ( int ranges [ ] [ ] , int n , int r , int arr [ ] ) { ArrayList < Integer > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < r ; i ++ ) { int c = 0 ; int l = ranges [ i ] [ 0 ] ; int h = ranges [ i ] [ 1 ] ; for ( int j = 0 ; j < arr . length ; j ++ ) { if ( l <= arr [ j ] && arr [ j ] <= h ) c += 1 ; } a . add ( c ) ; } return a ; } public static void main ( String args [ ] ) { int n = 5 ; int r = 2 ; int arr [ ] = { 400 , 567 , 890 , 765 , 987 } ; int ranges [ ] [ ] = { { 300 , 380 } , { 800 , 1000 } } ; ArrayList < Integer > answer = new ArrayList < > ( ) ; answer = findRockSample ( ranges , n , r , arr ) ; for ( int i = 0 ; i < answer . size ( ) ; i ++ ) System . out . print ( answer . get ( i ) + " ▁ " ) ; System . out . println ( ) ; } }

Index/key variables: i, j
Accumulator variables: c, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GfG { static class Node { int key ; Node left , right ; } static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = null ; temp . right = null ; return ( temp ) ; } static boolean isleaf ( Node curr_node ) { return ( curr_node . left == null && curr_node . right == null ) ; } static int deepestOddLevelDepthUtil ( Node curr_node , int curr_level ) { if ( curr_node == null ) return 0 ; curr_level += 1 ; if ( curr_level % 2 != 0 && isleaf ( curr_node ) ) return curr_level ; return Math . max ( deepestOddLevelDepthUtil ( curr_node . left , curr_level ) , deepestOddLevelDepthUtil ( curr_node . right , curr_level ) ) ; } static int deepestOddLevelDepth ( Node curr_node ) { return deepestOddLevelDepthUtil ( curr_node , 0 ) ; } public static void main ( String [ ] args ) { Node root = newNode ( 10 ) ; root . left = newNode ( 28 ) ; root . right = newNode ( 13 ) ; root . right . left = newNode ( 14 ) ; root . right . right = newNode ( 15 ) ; root . right . right . left = newNode ( 23 ) ; root . right . right . right = newNode ( 24 ) ; System . out . println ( deepestOddLevelDepth ( root ) ) ; } }

Accumulator variables: curr_level
Class/struct names: GfG, Node
Java program:
import java . util . * ; @ SuppressWarnings ( " unchecked " ) class GFG { static void findNumbers ( String st , ArrayList result , int prev , int n , int K ) { if ( st . length ( ) == n ) { result . add ( Integer . parseInt ( st ) ) ; return ; } if ( st . length ( ) == n - 1 ) { if ( prev - K >= 0 ) { String pt = " " ; pt += ( char ) ( prev - K + 48 ) ; findNumbers ( st + pt , result , prev - K , n , K ) ; } if ( K != 0 && prev + K < 10 ) { String pt = " " ; pt += ( char ) ( prev + K + 48 ) ; findNumbers ( st + pt , result , prev + K , n , K ) ; } } else { for ( int j = 1 ; j <= 9 ; j ++ ) { String pt = " " ; pt += ( char ) ( j + 48 ) ; findNumbers ( st + pt , result , prev , n , K ) ; } } } static ArrayList numDifference ( int N , int K ) { ArrayList res = new ArrayList ( ) ; String st = " " ; if ( N == 1 && K == 0 ) { res . add ( 0 ) ; } else if ( N == 1 && K > 0 ) { return res ; } for ( int i = 1 ; i < 10 ; i ++ ) { String temp = " " ; temp += ( char ) ( 48 + i ) ; findNumbers ( st + temp , res , i , N , K ) ; st = " " ; } return res ; } static void numDifferenceUtil ( int N , int K ) { ArrayList res = new ArrayList ( ) ; res = numDifference ( N , K ) ; for ( int i = 0 ; i < res . size ( ) ; i ++ ) { System . out . print ( res . get ( i ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 2 , K = 9 ; numDifferenceUtil ( N , K ) ; } }

Accumulator variables: i, j, pt, temp
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findMinBulletShots ( int [ ] [ ] points ) { Arrays . sort ( points , ( a , b ) -> a [ 1 ] - b [ 1 ] ) ; if ( points . length == 0 ) return 0 ; int cnt = 1 ; int curr = points [ 0 ] [ 1 ] ; for ( int j = 1 ; j < points . length ; j ++ ) { if ( curr < points [ j ] [ 0 ] ) { cnt ++ ; curr = points [ j ] [ 1 ] ; } } return cnt ; } public static void main ( String [ ] args ) { int [ ] [ ] bricks = { { 5000 , 900000 } , { 1 , 100 } , { 150 , 499 } } ; System . out . print ( findMinBulletShots ( bricks ) ) ; } }

Index/key variables: j
Accumulator variables: cnt, j
Iterator variables: j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void countMaximum ( Integer [ ] a , int n ) { Arrays . sort ( a , Collections . reverseOrder ( ) ) ; int count = 0 ; int mark = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( ( a [ i ] + n >= mark ) ) { count += 1 ; } mark = Math . max ( mark , a [ i ] + i + 1 ) ; } System . out . print ( count ) ; } public static void main ( String [ ] args ) { Integer arr [ ] = { 8 , 9 , 6 } ; int N = arr . length ; countMaximum ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String reverse ( String input ) { char [ ] a = input . toCharArray ( ) ; int l , r = a . length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . valueOf ( a ) ; } static char findKthChar ( int n , int k ) { String prev = " A " ; String cur = " " ; if ( n == 1 ) { return ' A ' ; } for ( int j = 2 ; j <= n ; j ++ ) { cur = prev + " B " ; for ( int i = 0 ; i < prev . length ( ) ; i ++ ) { if ( prev . charAt ( i ) == ' A ' ) { prev . replace ( prev . charAt ( i ) , ' B ' ) ; } else { prev . replace ( prev . charAt ( i ) , ' A ' ) ; } } prev = reverse ( prev ) ; cur += prev ; prev = cur ; } return cur . charAt ( k ) ; } public static void main ( String [ ] args ) { int N = 4 ; int K = 3 ; System . out . print ( findKthChar ( N , K ) ) ; } }

Index/key variables: l, r
Accumulator variables: cur, i, j, l, r
Iterator variables: i, j, l
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxSubarray ( int [ ] a , int k ) { int n = a . length ; int answer = 0 ; int start = 0 ; long s = 0 ; Deque < Integer > dq = new LinkedList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int x = a [ i ] ; while ( ! dq . isEmpty ( ) && a [ dq . peek ( ) ] <= x ) dq . poll ( ) ; dq . add ( i ) ; s += x ; long cost = ( long ) a [ dq . peekFirst ( ) ] * ( answer + 1 ) - s ; if ( cost <= ( long ) k ) answer ++ ; else { if ( dq . peekFirst ( ) == start ) dq . pollFirst ( ) ; s -= a [ start ++ ] ; } } return answer ; } public static void main ( String [ ] args ) { int [ ] a = { 2 , 2 , 4 } ; int k = 10 ; System . out . println ( maxSubarray ( a , k ) ) ; } }

Index/key variables: i
Accumulator variables: answer, i, s, start
Iterator variables: i
Class/struct names: GFG
Java program:
class Node { int data ; Node left , right ; Node ( int item ) { data = item ; left = right = null ; } } class BinaryTree { Node root ; int depthOfOddLeafUtil ( Node node , int level ) { if ( node == null ) return 0 ; if ( node . left == null && node . right == null && ( level & 1 ) != 0 ) return level ; return Math . max ( depthOfOddLeafUtil ( node . left , level + 1 ) , depthOfOddLeafUtil ( node . right , level + 1 ) ) ; } int depthOfOddLeaf ( Node node ) { int level = 1 , depth = 0 ; return depthOfOddLeafUtil ( node , level ) ; } public static void main ( String args [ ] ) { int k = 45 ; BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . right . left = new Node ( 5 ) ; tree . root . right . right = new Node ( 6 ) ; tree . root . right . left . right = new Node ( 7 ) ; tree . root . right . right . right = new Node ( 8 ) ; tree . root . right . left . right . left = new Node ( 9 ) ; tree . root . right . right . right . right = new Node ( 10 ) ; tree . root . right . right . right . right . left = new Node ( 11 ) ; System . out . println ( tree . depthOfOddLeaf ( tree . root ) + " ▁ is ▁ the ▁ required ▁ depth " ) ; } }

Class/struct names: BinaryTree, Node
Java program:
import java . io . * ; class GFG { static String canSplitArray ( int arr [ ] , int n , int k ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] <= k ) { return " No " ; } } return " Yes " ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , 6 , 1 , 8 , 16 } ; int N = arr . length ; int K = 3 ; System . out . println ( canSplitArray ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int smallSumSubset ( List < Integer > data , int target , int maxVal ) { int sum = 0 ; for ( Integer i : data ) sum += i ; if ( target <= 0 ) return 0 ; else if ( sum < target ) return maxVal ; else if ( sum == target ) return data . size ( ) ; else if ( data . get ( 0 ) >= target ) return 1 ; else if ( data . get ( 0 ) < target ) { List < Integer > temp = new ArrayList < > ( ) ; for ( int i = 1 ; i < data . size ( ) ; i ++ ) temp . add ( data . get ( i ) ) ; return Math . min ( smallSumSubset ( temp , target , maxVal ) , 1 + smallSumSubset ( temp , target - data . get ( 0 ) , maxVal ) ) ; } return - 1 ; } public static void main ( String [ ] args ) { List < Integer > data = Arrays . asList ( 3 , 1 , 7 , 1 , 2 ) ; int target = 11 ; int val = smallSumSubset ( data , target , data . size ( ) + 1 ) ; if ( val > data . size ( ) ) System . out . println ( - 1 ) ; else System . out . println ( val ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean swapXandY ( char [ ] str , int X , int Y ) { int N = str . length ; X = X + Y ; Y = X - Y ; X = X - Y ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == ' p ' ) { str [ i ] = ' r ' ; } else if ( str [ i ] == ' r ' ) { str [ i ] = ' p ' ; } } return true ; } static int maxCost ( String str , int X , int Y ) { int N = str . length ( ) ; if ( Y > X ) { swapXandY ( str . toCharArray ( ) , X , Y ) ; } int res = 0 ; int countP = 0 ; int countR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( str . charAt ( i ) == ' p ' ) { countP ++ ; } else if ( str . charAt ( i ) == ' r ' ) { if ( countP > 0 ) { countP -- ; res += X ; } else countR ++ ; } else { res += Math . min ( countP , countR ) * Y ; countP = 0 ; countR = 0 ; } } res += Math . min ( countP , countR ) * Y ; return res ; } public static void main ( String [ ] args ) { String str = " abppprrr " ; int X = 5 , Y = 4 ; System . out . print ( maxCost ( str , X , Y ) ) ; } }

Index/key variables: i
Accumulator variables: countP, countR, i, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class Main { public static void uniqueElement ( int arr [ ] ) { int x = arr [ 0 ] ; int flag = 1 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] != x ) { flag = 0 ; break ; } } if ( flag == 1 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 9 , 9 , 9 , 9 , 9 , 9 , 9 } ; uniqueElement ( arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Main
Java program:
class GFG { static int maxCount ( int [ ] freq , int maxi , int mini ) { int n = freq . length - 1 ; int ans = 0 ; for ( int sum = 2 * mini ; sum <= 2 * maxi ; ++ sum ) { int possiblePair = 0 ; for ( int firElement = 1 ; firElement < ( sum + 1 ) / 2 ; firElement ++ ) { if ( sum - firElement <= maxi ) { possiblePair += Math . min ( freq [ firElement ] , freq [ sum - firElement ] ) ; } } if ( sum % 2 == 0 ) { possiblePair += freq [ sum / 2 ] / 2 ; } ans = Math . max ( ans , possiblePair ) ; } return ans ; } static int countofPairs ( int [ ] a ) { int n = a . length ; int [ ] freq = new int [ n + 1 ] ; int maxi = - 1 ; int mini = n + 1 ; for ( int i = 0 ; i < n ; i ++ ) { maxi = Math . max ( maxi , a [ i ] ) ; mini = Math . min ( mini , a [ i ] ) ; } for ( int i = 0 ; i < n ; ++ i ) freq [ a [ i ] ] ++ ; return maxCount ( freq , maxi , mini ) ; } public static void main ( String [ ] args ) { int [ ] a = { 1 , 2 , 4 , 3 , 3 , 5 , 6 } ; System . out . print ( countofPairs ( a ) + "NEW_LINE"); } }

Index/key variables: firElement, i
Accumulator variables: firElement, i, possiblePair
Iterator variables: firElement, i, sum
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int getMaxSum ( int a [ ] , int n ) { int dp [ ] [ ] = new int [ n ] [ 2 ] ; dp [ 0 ] [ 0 ] = a [ 0 ] ; dp [ 0 ] [ 1 ] = a [ 0 ] * a [ 0 ] ; int max_sum = Math . max ( dp [ 0 ] [ 0 ] , dp [ 0 ] [ 1 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { dp [ i ] [ 0 ] = Math . max ( a [ i ] , dp [ i - 1 ] [ 0 ] + a [ i ] ) ; dp [ i ] [ 1 ] = Math . max ( dp [ i - 1 ] [ 1 ] + a [ i ] , a [ i ] * a [ i ] ) ; dp [ i ] [ 1 ] = Math . max ( dp [ i ] [ 1 ] , dp [ i - 1 ] [ 0 ] + a [ i ] * a [ i ] ) ; max_sum = Math . max ( max_sum , dp [ i ] [ 1 ] ) ; max_sum = Math . max ( max_sum , dp [ i ] [ 0 ] ) ; } return max_sum ; } public static void main ( String [ ] args ) { int n = 5 ; int a [ ] = { 1 , - 5 , 8 , 12 , - 8 } ; System . out . println ( getMaxSum ( a , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int subArraylen ( int arr [ ] , int n , int K ) { HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; mp . put ( arr [ 0 ] , 0 ) ; for ( int i = 1 ; i < n ; i ++ ) { arr [ i ] = arr [ i ] + arr [ i - 1 ] ; mp . put ( arr [ i ] , i ) ; } int len = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < K ) continue ; else { int x = K - arr [ i ] ; if ( x == 0 ) len = Math . min ( len , i ) ; if ( mp . containsValue ( x ) ) continue ; else { len = Math . min ( len , i ) ; } } } return len ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 4 , 3 , 2 , 4 , 1 } ; int n = arr . length ; int K = 7 ; int len = subArraylen ( arr , n , K ) ; if ( len == Integer . MAX_VALUE ) { System . out . print ( " - 1" ) ; } else { System . out . print ( len + "NEW_LINE"); } } }

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 left , right ; } ; static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } static int maxOddLevelDepth ( Node root ) { if ( root == null ) return 0 ; Queue < Node > q = new LinkedList < > ( ) ; q . add ( root ) ; int result = Integer . MAX_VALUE ; int level = 0 ; while ( ! q . isEmpty ( ) ) { int size = q . size ( ) ; level += 1 ; while ( size > 0 ) { Node temp = q . peek ( ) ; q . remove ( ) ; if ( temp . left == null && temp . right == null && ( level % 2 != 0 ) ) { result = level ; } if ( temp . left != null ) { q . add ( temp . left ) ; } if ( temp . right != null ) { q . add ( temp . right ) ; } size -= 1 ; } } return result ; } public static void main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . right . left = newNode ( 5 ) ; root . right . right = newNode ( 6 ) ; root . right . left . right = newNode ( 7 ) ; root . right . right . right = newNode ( 8 ) ; root . right . left . right . left = newNode ( 9 ) ; root . right . right . right . right = newNode ( 10 ) ; root . right . right . right . right . left = newNode ( 11 ) ; int result = maxOddLevelDepth ( root ) ; if ( result == Integer . MAX_VALUE ) System . out . println ( " No ▁ leaf ▁ node ▁ at ▁ odd ▁ level " ) ; else { System . out . print ( result ) ; System . out . println ( " ▁ is ▁ the ▁ required ▁ depth ▁ " ) ; } } }

Accumulator variables: level, size
Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { static int prime [ ] = new int [ 100001 ] ; static void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < 100001 ; i ++ ) prime [ i ] = 1 ; int p = 2 ; while ( p * p <= 100000 ) { if ( prime [ p ] == 1 ) { for ( int i = p * p ; i < 100001 ; i += p ) prime [ i ] = 0 ; } p += 1 ; } } static int join ( int a , int b ) { int mul = 1 ; int bb = b ; while ( b != 0 ) { mul *= 10 ; b /= 10 ; } a *= mul ; a += bb ; return a ; } static void fibonacciOfPrime ( int n1 , int n2 ) { SieveOfEratosthenes ( ) ; Vector < Integer > initial = new Vector < > ( ) ; for ( int i = n1 ; i <= n2 ; i ++ ) if ( prime [ i ] == 1 ) initial . add ( i ) ; Vector < Integer > now = new Vector < > ( ) ; for ( int i = 0 ; i < initial . size ( ) ; i ++ ) { for ( int j = 0 ; j < initial . size ( ) ; j ++ ) { int a = ( int ) initial . get ( i ) ; int b = ( int ) initial . get ( j ) ; if ( a != b ) { int c = join ( a , b ) ; now . add ( c ) ; } } } Vector < Integer > current = new Vector < > ( ) ; for ( int i = 0 ; i < now . size ( ) ; i ++ ) if ( prime [ ( int ) now . get ( i ) ] == 1 ) current . add ( ( int ) now . get ( i ) ) ; int cnt [ ] = new int [ 1000009 ] ; for ( int i = 0 ; i < 1000001 ; i ++ ) cnt [ i ] = 0 ; Vector < Integer > current_set = new Vector < > ( ) ; for ( int i = 0 ; i < current . size ( ) ; i ++ ) { cnt [ ( int ) current . get ( i ) ] ++ ; if ( cnt [ ( int ) current . get ( i ) ] == 1 ) current_set . add ( ( int ) current . get ( i ) ) ; } long first = 1000000000 ; for ( int i = 0 ; i < current_set . size ( ) ; i ++ ) first = Math . min ( first , ( int ) current_set . get ( i ) ) ; long second = 0 ; for ( int i = 0 ; i < current_set . size ( ) ; i ++ ) second = Math . max ( second , ( int ) current_set . get ( i ) ) ; int count = current_set . size ( ) - 1 ; long curr = 1 ; long c = 0 ; while ( curr < count ) { c = first + second ; first = second ; second = c ; curr += 1 ; } System . out . println ( c ) ; } public static void main ( String [ ] args ) { int x = 2 ; int y = 40 ; fibonacciOfPrime ( x , y ) ; } }

Index/key variables: i, p
Accumulator variables: a, b, curr, i, j, mul, p
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countElements ( int arr [ ] , int n , int k ) { Stack < Integer > s = new Stack < Integer > ( ) ; int [ ] next_greater = new int [ n + 1 ] ; Arrays . fill ( next_greater , n ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . isEmpty ( ) ) { s . add ( i ) ; continue ; } while ( ! s . isEmpty ( ) && arr [ s . peek ( ) ] < arr [ i ] ) { next_greater [ s . peek ( ) ] = i ; s . pop ( ) ; } s . add ( i ) ; } int count = 0 ; int maxi = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { if ( next_greater [ i ] - i > k && maxi < arr [ i ] ) { maxi = Math . max ( maxi , arr [ i ] ) ; count ++ ; } } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 2 , 3 , 6 , 4 , 3 , 2 } ; int K = 2 ; int n = arr . length ; System . out . print ( countElements ( arr , n , K ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static void maxLengthOf1s ( int arr [ ] , int n ) { int prefix [ ] = new int [ n ] ; for ( int i = 2 ; i < n ; i ++ ) { if ( arr [ i - 2 ] == 1 ) prefix [ i ] = prefix [ i - 1 ] + 1 ; else prefix [ i ] = 0 ; } int suffix [ ] = new int [ n ] ; for ( int i = n - 3 ; i >= 0 ; i -- ) { if ( arr [ i + 2 ] == 1 ) suffix [ i ] = suffix [ i + 1 ] + 1 ; else suffix [ i ] = 0 ; } int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { ans = Math . max ( ans , prefix [ i + 1 ] + suffix [ i ] ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int n = 6 ; int arr [ ] = { 1 , 1 , 1 , 0 , 1 , 1 } ; maxLengthOf1s ( arr , n ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minOperations ( String s ) { int n = s . length ( ) ; int pos = - 1 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '1' ) { pos = i ; break ; } } if ( pos == - 1 ) { return 0 ; } int last = 1 ; int ans = 1 ; for ( int i = pos + 1 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '0' ) { if ( last == 1 ) { ans ++ ; last = 0 ; } } else { if ( last == 0 ) { ans ++ ; last = 1 ; } } } return ans ; } public static void main ( String [ ] args ) { String s = "10111" ; System . out . println ( minOperations ( s ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG