dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static class pair { int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void smallestNumberLeftInPQ ( int arr [ ] , int N ) { PriorityQueue < Integer > pq = new PriorityQueue < > ( ( x , y ) -> Integer . compare ( y , x ) ) ; Vector < pair > pairsArr = new Vector < > ( ) ; 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 ( ) ; pq . add ( ( X + Y + 1 ) / 2 ) ; pairsArr . add ( new pair ( X , Y ) ) ; } System . out . print ( " { " + pq . peek ( ) + " } , ▁ " ) ; int sz = pairsArr . size ( ) ; for ( int i = 0 ; i < sz ; i ++ ) { if ( i == 0 ) { System . out . print ( " { ▁ " ) ; } System . out . print ( " ( " + pairsArr . get ( i ) . first + " , ▁ " + pairsArr . get ( i ) . second + " ) " ) ; if ( i != sz - 1 ) { System . out . print ( " , ▁ " ) ; } if ( i == sz - 1 ) { System . out . print ( " ▁ } " ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 2 , 1 } ; int N = arr . length ; smallestNumberLeftInPQ ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
class GFG { static boolean dfs ( int residue , int curStep , int [ ] wt , int [ ] arr , int N , int steps ) { if ( curStep >= steps ) return true ; for ( int i = 0 ; i < N ; i ++ ) { if ( curStep - 1 < 0 || ( arr [ i ] > residue && arr [ i ] != wt [ curStep - 1 ] ) ) { wt [ curStep ] = arr [ i ] ; if ( dfs ( arr [ i ] - residue , curStep + 1 , wt , arr , N , steps ) ) return true ; } } return false ; } static void printWeightOnScale ( int [ ] arr , int N , int steps ) { int [ ] wt = new int [ steps ] ; if ( dfs ( 0 , 0 , wt , arr , N , steps ) ) { for ( int i = 0 ; i < steps ; i ++ ) System . out . print ( wt [ i ] + " ▁ " ) ; System . out . println ( ) ; } else System . out . println ( " Not ▁ Possible " ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 5 , 6 } ; int N = arr . length ; int steps = 10 ; printWeightOnScale ( arr , N , steps ) ; } }

Index/key variables: curStep, i, steps
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findSum ( int [ ] S , int n , int x ) { int [ ] [ ] table = new int [ n + 1 ] [ x + 1 ] ; for ( int i = 1 ; i <= x ; i ++ ) { table [ 0 ] [ i ] = Integer . MAX_VALUE - 1 ; } for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= x ; j ++ ) { if ( S [ i - 1 ] > j ) { table [ i ] [ j ] = table [ i - 1 ] [ j ] ; } else { table [ i ] [ j ] = Math . min ( table [ i - 1 ] [ j ] , table [ i ] [ j - S [ i - 1 ] ] + 1 ) ; } } } return ( table [ n ] [ x ] > n ) ? - 1 : table [ n ] [ x ] ; } static void minRemovals ( int [ ] arr , int n , int m , int x ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; } int requied_Sum = 0 ; if ( sum % m < x ) requied_Sum = m + sum % m - x ; else requied_Sum = sum % m - x ; System . out . print ( findSum ( arr , n , requied_Sum ) ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 1 , 2 } ; int n = arr . length ; int m = 4 , x = 2 ; minRemovals ( arr , n , m , x % m ) ; } }

Index/key variables: i, j, n, x
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class Main { public static int minChange ( String s , int n ) { int L [ ] = new int [ 26 ] ; int R [ ] = new int [ 26 ] ; for ( int i = 0 ; i < n / 2 ; i ++ ) { char ch = s . charAt ( i ) ; L [ ch - ' a ' ] ++ ; } for ( int i = n / 2 ; i < n ; i ++ ) { char ch = s . charAt ( i ) ; R [ ch - ' a ' ] ++ ; } int count = n ; for ( char ch = ' a ' ; ch <= ' z ' ; ch ++ ) { count = Math . min ( count , n - L [ ch - ' a ' ] - R [ ch - ' a ' ] ) ; } int change = n / 2 ; for ( int d = 0 ; d + 1 < 26 ; d ++ ) { change -= L [ d ] ; change += R [ d ] ; count = Math . min ( count , change ) ; } change = n / 2 ; for ( int d = 0 ; d + 1 < 26 ; d ++ ) { change -= R [ d ] ; change += L [ d ] ; count = Math . min ( change , count ) ; } return count ; } public static void main ( String [ ] args ) { String S = " aababc " ; int N = S . length ( ) ; System . out . println ( minChange ( S , N ) ) ; } }

Index/key variables: d
Accumulator variables: ch, change, d, i
Iterator variables: ch, d, i
Class/struct names: Main
Java program:
import java . util . * ; class GFG { static String longestPalinSub ( String str ) { int N = str . length ( ) ; int [ ] hash = new int [ 256 ] ; for ( int i = 0 ; i < N ; i ++ ) { hash [ str . charAt ( i ) ] ++ ; } StringBuilder res1 = new StringBuilder ( ) ; StringBuilder res2 = new StringBuilder ( ) ; for ( int i = 0 ; i < 256 ; i ++ ) { for ( int j = 0 ; j < hash [ i ] / 2 ; j ++ ) { res1 . append ( ( char ) i ) ; } for ( int j = ( hash [ i ] + 1 ) / 2 ; j < hash [ i ] ; j ++ ) { res2 . append ( ( char ) i ) ; } } StringBuilder tmp = res2 . reverse ( ) ; StringBuilder res3 = new StringBuilder ( ) ; boolean f = false ; for ( int i = 0 ; i < 256 ; i ++ ) { if ( hash [ i ] % 2 == 1 ) { if ( ! f ) { res1 . append ( ( char ) i ) ; f = true ; } else { res3 . append ( ( char ) i ) ; } } } return ( res1 . toString ( ) + tmp . toString ( ) + res3 . toString ( ) ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; System . out . println ( longestPalinSub ( str ) ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: f
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static int No_Of_subsequences ( HashMap < Integer , Integer > mp ) { int count = 0 ; int left = 0 ; for ( Map . Entry < Integer , Integer > x : mp . entrySet ( ) ) { mp . replace ( x . getKey ( ) , x . getValue ( ) + left ) ; count += ( x . getValue ( ) / x . getKey ( ) ) ; left = x . getValue ( ) % x . getKey ( ) ; } return count ; } public static void maximumsubsequences ( int [ ] arr , int n ) { HashMap < Integer , Integer > mp = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . containsKey ( arr [ i ] ) ) { mp . replace ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } else { mp . put ( arr [ i ] , 1 ) ; } } System . out . println ( No_Of_subsequences ( mp ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 1 , 1 } ; int N = arr . length ; maximumsubsequences ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean check ( List < Integer > arr , ArrayList < List < Integer > > pieces ) { Map < Integer , Integer > m = new HashMap < > ( ) ; for ( int i = 0 ; i < arr . size ( ) ; i ++ ) m . put ( arr . get ( i ) , i ) ; for ( int i = 0 ; i < pieces . size ( ) ; i ++ ) { if ( pieces . get ( i ) . size ( ) == 1 && m . containsKey ( pieces . get ( i ) . get ( 0 ) ) ) { continue ; } else if ( pieces . get ( i ) . size ( ) > 1 && m . containsKey ( pieces . get ( i ) . get ( 0 ) ) ) { int idx = m . get ( pieces . get ( i ) . get ( 0 ) ) ; idx ++ ; if ( idx >= arr . size ( ) ) return false ; for ( int j = 1 ; j < pieces . get ( i ) . size ( ) ; j ++ ) { if ( arr . get ( idx ) . equals ( pieces . get ( i ) . get ( j ) ) ) { idx ++ ; if ( idx >= arr . size ( ) && j < pieces . get ( i ) . size ( ) - 1 ) return false ; } else { return false ; } } } else { return false ; } } return true ; } public static void main ( String [ ] args ) { List < Integer > arr = Arrays . asList ( 1 , 2 , 4 , 3 ) ; ArrayList < List < Integer > > pieces = new ArrayList < > ( ) ; pieces . add ( Arrays . asList ( 1 ) ) ; pieces . add ( Arrays . asList ( 4 , 3 ) ) ; pieces . add ( Arrays . asList ( 2 ) ) ; if ( check ( arr , pieces ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }

Accumulator variables: i, idx, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void makeArraySumEqual ( int a [ ] , int N ) { int count_0 = 0 , count_1 = 0 ; int odd_sum = 0 , even_sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( a [ i ] == 0 ) count_0 ++ ; else count_1 ++ ; if ( ( i + 1 ) % 2 == 0 ) even_sum += a [ i ] ; else if ( ( i + 1 ) % 2 > 0 ) odd_sum += a [ i ] ; } if ( odd_sum == even_sum ) { for ( int i = 0 ; i < N ; i ++ ) System . out . print ( a [ i ] + " ▁ " ) ; } else { if ( count_0 >= N / 2 ) { for ( int i = 0 ; i < count_0 ; i ++ ) System . out . print ( "0 ▁ " ) ; } else { int is_Odd = count_1 % 2 ; count_1 -= is_Odd ; for ( int i = 0 ; i < count_1 ; i ++ ) System . out . print ( "1 ▁ " ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 1 , 0 } ; int N = arr . length ; makeArraySumEqual ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: count_0, count_1, even_sum, i, odd_sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int maxm = 10001 ; static boolean prime [ ] ; static int prime_number [ ] ; static void SieveOfEratosthenes ( ) { Arrays . fill ( prime , true ) ; for ( int p = 2 ; p * p < maxm ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i < maxm ; i += p ) prime [ i ] = false ; } } prime [ 0 ] = false ; prime [ 1 ] = false ; } static void num_prime ( ) { prime_number [ 0 ] = 0 ; for ( int i = 1 ; i <= maxm ; i ++ ) { int tmp ; if ( prime [ i ] == true ) { tmp = 1 ; } else { tmp = 0 ; } prime_number [ i ] = prime_number [ i - 1 ] + tmp ; } } static void min_steps ( int arr [ ] , int n ) { SieveOfEratosthenes ( ) ; num_prime ( ) ; if ( n == 1 ) { System . out . println ( "0" ) ; } else if ( n == 2 ) { System . out . println ( "1" ) ; } else { System . out . println ( prime_number [ n ] - 1 + ( n - 2 ) ) ; } } public static void main ( String [ ] args ) { prime = new boolean [ maxm + 1 ] ; prime_number = new int [ maxm + 1 ] ; int arr [ ] = { 5 , 4 , 3 , 2 , 1 } ; int N = arr . length ; min_steps ( arr , N ) ; } }

Index/key variables: i, n, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findWinner ( int a [ ] , int n ) { int win = 0 ; if ( n % 2 == 0 ) win = 1 ; else win = 0 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( i % 2 == 1 ) { if ( win == 0 && a [ i ] > 1 ) win = 1 ; } else { if ( win == 1 && a [ i ] > 1 ) win = 0 ; } } if ( win == 0 ) System . out . print ( " A " ) ; else System . out . print ( " B " ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 1 , 2 } ; int N = arr . length ; findWinner ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean isReachable ( long x1 , long y1 , long x2 , long y2 ) { while ( x2 > x1 && y2 > y1 ) { if ( x2 > y2 ) x2 %= y2 ; else y2 %= x2 ; } if ( x2 == x1 ) return ( y2 - y1 ) >= 0 && ( y2 - y1 ) % x1 == 0 ; else if ( y2 == y1 ) return ( x2 - x1 ) >= 0 && ( x2 - x1 ) % y1 == 0 ; else return false ; } public static void main ( String [ ] args ) { long source_x = 2 , source_y = 10 ; long dest_x = 26 , dest_y = 12 ; if ( isReachable ( source_x , source_y , dest_x , dest_y ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void checkWinner ( int N , int K ) { if ( N % ( K + 1 ) > 0 ) { System . out . print ( " A " ) ; } else { System . out . print ( " B " ) ; } } public static void main ( String [ ] args ) { int N = 50 ; int K = 10 ; checkWinner ( N , K ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static boolean [ ] isprime = new boolean [ 2000010 ] ; static void SieveOfEratosthenes ( int n ) { Arrays . fill ( isprime , true ) ; isprime [ 1 ] = false ; for ( int p = 2 ; p * p <= n ; p ++ ) { if ( isprime [ p ] == true ) { for ( int i = p * p ; i <= n ; i += p ) isprime [ i ] = false ; } } } static int KDistinctPrime ( int arr [ ] , int n , int k ) { SieveOfEratosthenes ( 2000000 ) ; Map < Integer , Integer > cnt = new HashMap < > ( ) ; int result = - 1 ; for ( int i = 0 , j = - 1 ; i < n ; ++ i ) { int x = arr [ i ] ; if ( isprime [ x ] ) { cnt . put ( x , cnt . getOrDefault ( x , 0 ) + 1 ) ; if ( cnt . get ( x ) == 1 ) { -- k ; } } while ( k < 0 ) { x = arr [ ++ j ] ; if ( isprime [ x ] ) { cnt . put ( x , cnt . getOrDefault ( x , 0 ) - 1 ) ; if ( cnt . get ( x ) == 0 ) { ++ k ; } } } if ( k == 0 ) result = Math . max ( result , i - j ) ; } return result ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; int K = 3 ; int N = arr . length ; System . out . println ( KDistinctPrime ( arr , N , K ) ) ; } }

Index/key variables: i, p, x
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . util . Arrays ; import java . util . Vector ; class GFG { static final int MAX_SIZE = 1000005 ; static void SieveOfEratosthenes ( Vector < Integer > StorePrimes ) { boolean [ ] IsPrime = new boolean [ MAX_SIZE ] ; Arrays . fill ( IsPrime , true ) ; for ( int p = 2 ; p * p < MAX_SIZE ; p ++ ) { if ( IsPrime [ p ] == true ) { for ( int i = p * p ; i < MAX_SIZE ; i += p ) IsPrime [ i ] = false ; } } for ( int p = 2 ; p < MAX_SIZE ; p ++ ) if ( IsPrime [ p ] ) StorePrimes . add ( p ) ; } static int Smallest_non_Prime ( Vector < Integer > StorePrimes , int N ) { int x = StorePrimes . get ( N ) ; return x * x ; } public static void main ( String [ ] args ) { int N = 3 ; Vector < Integer > StorePrimes = new Vector < Integer > ( ) ; SieveOfEratosthenes ( StorePrimes ) ; System . out . print ( Smallest_non_Prime ( StorePrimes , N ) ) ; } }

Index/key variables: MAX_SIZE, i, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static void printSubset ( long n , int k ) { ArrayList < Long > answer = new ArrayList < > ( ) ; while ( n > 0 ) { long p = ( long ) ( Math . log ( n ) / Math . log ( 2 ) ) ; ; answer . add ( ( long ) ( Math . pow ( k , p ) ) ) ; n %= ( int ) Math . pow ( 2 , p ) ; } Collections . sort ( answer ) ; for ( Long x : answer ) { System . out . print ( x + " ▁ " ) ; } } public static void main ( String [ ] args ) { long n = 5 ; int k = 4 ; printSubset ( n , k ) ; } }

Iterator variables: x
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int maxN = 100000 ; @ SuppressWarnings ( " unchecked " ) static Vector < Integer > [ ] graph = new Vector [ maxN ] ; static int [ ] indegree = new int [ maxN ] ; static int [ ] job = new int [ maxN ] ; static void addEdge ( int u , int v ) { graph [ u ] . add ( v ) ; indegree [ v ] ++ ; } static void printOrder ( int n , int m ) { Queue < Integer > q = new LinkedList < > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( indegree [ i ] == 0 ) { q . add ( i ) ; job [ i ] = 1 ; } } while ( ! q . isEmpty ( ) ) { int cur = q . peek ( ) ; q . remove ( ) ; for ( int adj : graph [ cur ] ) { indegree [ adj ] -- ; if ( indegree [ adj ] == 0 ) { job [ adj ] = 1 + job [ cur ] ; q . add ( adj ) ; } } } for ( int i = 1 ; i <= n ; i ++ ) System . out . print ( job [ i ] + " ▁ " ) ; System . out . print ( "NEW_LINE"); } public static void main ( String [ ] args ) { int n , m ; n = 10 ; m = 13 ; for ( int i = 0 ; i < graph . length ; i ++ ) graph [ i ] = new Vector < Integer > ( ) ; addEdge ( 1 , 3 ) ; addEdge ( 1 , 4 ) ; addEdge ( 1 , 5 ) ; addEdge ( 2 , 3 ) ; addEdge ( 2 , 8 ) ; addEdge ( 2 , 9 ) ; addEdge ( 3 , 6 ) ; addEdge ( 4 , 6 ) ; addEdge ( 4 , 8 ) ; addEdge ( 5 , 8 ) ; addEdge ( 6 , 7 ) ; addEdge ( 7 , 8 ) ; addEdge ( 8 , 10 ) ; printOrder ( n , m ) ; } }

Index/key variables: adj, cur, i, maxN, u, v
Accumulator variables: i
Iterator variables: adj, i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int getLeftmostBit ( int n ) { int m = 0 ; while ( n > 1 ) { n = n >> 1 ; m ++ ; } return m ; } static int getNextLeftmostBit ( int n , int m ) { int temp = 1 << m ; while ( n < temp ) { temp = temp >> 1 ; m -- ; } return m ; } static int countSetBit ( int n ) { int m = getLeftmostBit ( n ) ; return _countSetBit ( n , m ) ; } static int _countSetBit ( int n , int m ) { if ( n == 0 ) return 0 ; m = getNextLeftmostBit ( n , m ) ; if ( n == ( ( int ) 1 << ( m + 1 ) ) - 1 ) return ( int ) ( m + 1 ) * ( 1 << m ) ; n = n - ( 1 << m ) ; return ( ( n + 1 ) + countSetBit ( n ) + m * ( 1 << ( m - 1 ) ) ) ; } static int countSetBits ( int L , int R ) { return Math . abs ( countSetBit ( R ) - countSetBit ( L - 1 ) ) ; } public static void main ( String [ ] args ) { int L = 3 , R = 5 ; System . out . print ( " Total ▁ set ▁ bit ▁ count ▁ is ▁ " + countSetBits ( L , R ) ) ; } }

Accumulator variables: m
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void printPermutation ( int arr [ ] , int n ) { ArrayList < Integer > odd = new ArrayList < Integer > ( ) ; ArrayList < Integer > even = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) even . add ( arr [ i ] ) ; else odd . add ( arr [ i ] ) ; } int size_odd = odd . size ( ) ; int size_even = even . size ( ) ; if ( size_odd > size_even + 1 ) System . out . println ( " - 1" ) ; else { int i = 0 ; int j = 0 ; while ( i < size_odd && j < size_even ) { System . out . print ( odd . get ( i ) + " ▁ " ) ; ++ i ; System . out . print ( even . get ( j ) + " ▁ " ) ; ++ j ; } while ( i < size_odd ) { System . out . print ( odd . get ( i ) + " ▁ " ) ; ++ i ; } while ( j < size_even ) { System . out . print ( even . get ( j ) + " ▁ " ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 6 , 7 , 9 , 8 , 10 , 11 } ; int N = arr . length ; printPermutation ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void find ( int n ) { System . out . println ( n / 2 ) ; } public static void main ( String [ ] args ) { int n = 5 ; find ( n ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int [ ] [ ] rem = new int [ 11 ] [ 11 ] ; static int countPairs ( int [ ] a , int n , int k ) { int [ ] len = new int [ n ] ; int [ ] p = new int [ 11 ] ; p [ 0 ] = 1 ; for ( int i = 1 ; i <= 10 ; i ++ ) { p [ i ] = ( p [ i - 1 ] * 10 ) % k ; } for ( int i = 0 ; i < n ; i ++ ) { int x = a [ i ] ; while ( x > 0 ) { len [ i ] ++ ; x /= 10 ; } rem [ len [ i ] ] [ a [ i ] % k ] ++ ; } int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 1 ; j <= 10 ; j ++ ) { int r = ( a [ i ] * p [ j ] ) % k ; int xr = ( k - r ) % k ; ans += rem [ j ] [ xr ] ; if ( len [ i ] == j && ( r + a [ i ] % k ) % k == 0 ) ans -- ; } } return ans ; } public static void main ( String [ ] args ) { int [ ] a = { 4 , 5 , 2 } ; int n = a . length , k = 2 ; System . out . println ( countPairs ( a , n , k ) ) ; } }

Index/key variables: i, j, n, xr
Accumulator variables: ans, i, j, x
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int countDigitSum ( int N , int K ) { int l = ( int ) Math . pow ( 10 , N - 1 ) , r = ( int ) Math . pow ( 10 , N ) - 1 ; int count = 0 ; for ( int i = l ; i <= r ; i ++ ) { int num = i ; int digits [ ] = new int [ N ] ; for ( int j = N - 1 ; j >= 0 ; j -- ) { digits [ j ] = num % 10 ; num /= 10 ; } int sum = 0 , flag = 0 ; for ( int j = 0 ; j < K ; j ++ ) sum += digits [ j ] ; for ( int j = K ; j < N ; j ++ ) { if ( sum - digits [ j - K ] + digits [ j ] != sum ) { flag = 1 ; break ; } } if ( flag == 0 ) { count ++ ; } } return count ; } public static void main ( String [ ] args ) { int N = 2 , K = 1 ; System . out . print ( countDigitSum ( N , K ) ) ; } }

Index/key variables: N, j
Accumulator variables: count, i, j, num, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { private static List < Integer > calculate ( int [ ] arr ) { int n = arr . length ; List < Integer > ans = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < arr . length ; j ++ ) { sum += Math . abs ( arr [ i ] - arr [ j ] ) ; } ans . add ( sum ) ; } return ans ; } public static void main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 5 , 6 } ; System . out . println ( calculate ( arr ) ) ; } }

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 k ; static void dfs ( Vector < Integer > graph [ ] , boolean visited [ ] , int x ) { for ( int i = 0 ; i < graph [ x ] . size ( ) ; i ++ ) { if ( ! visited [ graph [ x ] . get ( i ) ] ) { ( k ) ++ ; visited [ graph [ x ] . get ( i ) ] = true ; dfs ( graph , visited , graph [ x ] . get ( i ) ) ; } } } static int countNonAccessible ( Vector < Integer > graph [ ] , int N ) { boolean [ ] visited = new boolean [ N * N + N ] ; int ans = 0 ; for ( int i = 1 ; i <= N * N ; i ++ ) { if ( ! visited [ i ] ) { visited [ i ] = true ; int k = 1 ; dfs ( graph , visited , i ) ; ans += k * ( N * N - k ) ; } } return ans ; } static void insertpath ( Vector < Integer > graph [ ] , int N , int x1 , int y1 , int x2 , int y2 ) { int a = ( x1 - 1 ) * N + y1 ; int b = ( x2 - 1 ) * N + y2 ; graph [ a ] . add ( b ) ; graph [ b ] . add ( a ) ; } public static void main ( String args [ ] ) { int N = 2 ; Vector [ ] graph = new Vector [ N * N + 1 ] ; for ( int i = 1 ; i <= N * N ; i ++ ) graph [ i ] = new Vector < Integer > ( ) ; insertpath ( graph , N , 1 , 1 , 1 , 2 ) ; insertpath ( graph , N , 1 , 2 , 2 , 2 ) ; System . out . println ( countNonAccessible ( graph , N ) ) ; } }

Index/key variables: a, b, i, x
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findMinimum ( String s ) { int n = s . length ( ) ; int [ ] x = new int [ n + 1 ] ; StringBuilder s2 = new StringBuilder ( s ) ; s2 . reverse ( ) ; String s3 = s2 . toString ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s3 . charAt ( i ) == '1' ) { if ( x [ i ] == 1 ) { x [ i + 1 ] = 1 ; x [ i ] = 0 ; } else if ( 1 <= i && ( i & x [ i - 1 ] ) == 1 ) { x [ i + 1 ] = 1 ; x [ i - 1 ] = - 1 ; } else x [ i ] = 1 ; } } int c = 0 ; for ( int i = 0 ; i <= n ; i ++ ) { if ( x [ i ] != 0 ) c ++ ; } System . out . println ( c ) ; } public static void main ( String [ ] args ) { String str = "111" ; findMinimum ( str ) ; } }

Index/key variables: i
Accumulator variables: c, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean splitIntoFibonacciHelper ( int pos , String S , ArrayList < Long > seq ) { if ( pos == S . length ( ) && ( seq . size ( ) >= 3 ) ) { return true ; } long num = 0 ; for ( int i = pos ; i < S . length ( ) ; i ++ ) { num = num * 10 + ( S . charAt ( i ) - '0' ) ; if ( num > Integer . MAX_VALUE ) break ; if ( S . charAt ( pos ) == '0' && i > pos ) break ; if ( seq . size ( ) > 2 && ( num > ( ( long ) seq . get ( seq . size ( ) - 1 ) + ( long ) seq . get ( seq . size ( ) - 2 ) ) ) ) break ; if ( seq . size ( ) < 2 || ( num == ( ( long ) seq . get ( seq . size ( ) - 1 ) + ( long ) seq . get ( seq . size ( ) - 2 ) ) ) ) { seq . add ( num ) ; if ( splitIntoFibonacciHelper ( i + 1 , S , seq ) ) return true ; seq . remove ( seq . size ( ) - 1 ) ; } } return false ; } static void splitIntoFibonacci ( String S ) { ArrayList < Long > seq = new ArrayList < > ( ) ; splitIntoFibonacciHelper ( 0 , S , seq ) ; if ( seq . size ( ) >= 3 ) { for ( int i = 0 ; i < seq . size ( ) ; i ++ ) System . out . print ( seq . get ( i ) + " ▁ " ) ; } else { System . out . print ( " - 1" ) ; } } public static void main ( String [ ] args ) { String S = "11235813" ; splitIntoFibonacci ( S ) ; } }

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