dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . ArrayList ; class GFG { public static boolean possible ( int x , int S , int N ) { int minSum = ( x * ( x + 1 ) ) / 2 ; int maxSum = ( x * ( ( 2 * N ) - x + 1 ) ) / 2 ; if ( S < minSum S > maxSum ) { return false ; } return true ; } public static void findPermutation ( int N , int L , int R , int S ) { int x = R - L + 1 ; if ( ! possible ( x , S , N ) ) { System . out . print ( - 1 ) ; return ; } else { ArrayList < Integer > v = new ArrayList < > ( ) ; for ( int i = N ; i >= 1 ; -- i ) { if ( ( S - i ) >= 0 && possible ( x - 1 , S - i , i - 1 ) ) { S = S - i ; x -- ; v . add ( i ) ; } if ( S == 0 ) { break ; } } if ( S != 0 ) { System . out . print ( - 1 ) ; return ; } ArrayList < Integer > v1 = new ArrayList < Integer > ( ) ; for ( int i = 1 ; i <= N ; ++ i ) { boolean it = v . contains ( i ) ; if ( ! it ) { v1 . add ( i ) ; } } int j = 0 , f = 0 ; for ( int i = 1 ; i < L ; ++ i ) { System . out . print ( v1 . get ( j ) + " ▁ " ) ; j ++ ; } for ( int i = L ; i <= R ; ++ i ) { System . out . print ( v . get ( f ) + " ▁ " ) ; f ++ ; } for ( int i = R + 1 ; i <= N ; ++ i ) { System . out . print ( v1 . get ( j ) + " ▁ " ) ; j ++ ; } } return ; } public static void main ( String args [ ] ) { int N + C3 : AC3 = 6 , L = 3 , R = 5 , S = 8 ; findPermutation ( N , L , R , S ) ; } }

Accumulator variables: f, j, x
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . ArrayList ; import java . util . Map ; import java . util . TreeMap ; class GFG { public static void skipIndices ( int N , int T , int arr [ ] ) { int sum = 0 ; TreeMap < Integer , Integer > count = new TreeMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int d = sum + arr [ i ] - T ; int k = 0 ; if ( d > 0 ) { for ( Map . Entry < Integer , Integer > u : count . descendingMap ( ) . entrySet ( ) ) { int j = u . getKey ( ) ; int x = j * count . get ( j ) ; if ( d <= x ) { k += ( d + j - 1 ) / j ; break ; } k += count . get ( j ) ; d -= x ; } } sum += arr [ i ] ; if ( count . containsKey ( arr [ i ] ) ) { count . put ( arr [ i ] , count . get ( arr [ i ] ) + 1 ) ; } else { count . put ( arr [ i ] , 1 ) ; } System . out . print ( k + " ▁ " ) ; } } public static void main ( String args [ ] ) { int N = 7 ; int T = 15 ; int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 } ; skipIndices ( N , T , arr ) ; } }

Index/key variables: i
Accumulator variables: d, i, k, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int countTriplets ( int N , int K ) { if ( K % 2 == 0 ) { int x = N / K ; int y = ( N + ( K / 2 ) ) / K ; return x * x * x + y * y * y ; } else { int x = N / K ; return x * x * x ; } } public static void main ( String [ ] args ) { int N = 2 , K = 2 ; System . out . print ( countTriplets ( N , K ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void main ( String [ ] args ) { String S = " geeksforg " ; System . out . println ( maxNumPalindrome ( S ) ) ; } static int maxNumPalindrome ( String S ) { int i = 0 ; int [ ] freq = new int [ 26 ] ; int freqPair = 0 ; int len = S . length ( ) / 3 ; while ( i < S . length ( ) ) { freq [ S . charAt ( i ) - ' a ' ] ++ ; i ++ ; } for ( i = 0 ; i < 26 ; i ++ ) { freqPair += ( freq [ i ] / 2 ) ; } return Math . min ( freqPair , len ) ; } }

Index/key variables: i
Accumulator variables: freqPair, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int height ( int s , Vector < Integer > adj [ ] , int [ ] visited ) { visited [ s ] = 1 ; int h = 0 ; for ( int child : adj [ s ] ) { if ( visited [ child ] == 0 ) { h = Math . max ( h , 1 + height ( child , adj , visited ) ) ; } } return h ; } static int minimumGroups ( Vector < Integer > adj [ ] , int N ) { int [ ] visited = new int [ N + 1 ] ; int groups = Integer . MIN_VALUE ; for ( int i = 1 ; i <= N ; i ++ ) { if ( visited [ i ] == 0 ) { int comHeight ; comHeight = height ( i , adj , visited ) ; groups = Math . max ( groups , comHeight ) ; } } return groups ; } static void addEdge ( Vector < Integer > adj [ ] , int u , int v ) { adj [ u ] . add ( v ) ; adj [ v ] . add ( u ) ; } public static void main ( String [ ] args ) { int N = 5 ; Vector < Integer > [ ] adj = new Vector [ N + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) adj [ i ] = new Vector < Integer > ( ) ; addEdge ( adj , 1 , 2 ) ; addEdge ( adj , 3 , 2 ) ; addEdge ( adj , 4 , 3 ) ; System . out . print ( minimumGroups ( adj , N ) ) ; } }

Index/key variables: child, i, s, u, v
Accumulator variables: i
Iterator variables: child, i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int ans ; static void subsetSum ( Vector < Integer > c ) { int L = c . size ( ) ; int mul = ( int ) Math . pow ( 2 , L - 1 ) ; for ( int i = 0 ; i < c . size ( ) ; i ++ ) ans += c . get ( i ) * mul ; } static void subsetGen ( int [ ] arr , int i , int n , Vector < Integer > c ) { if ( i == n ) { subsetSum ( c ) ; return ; } subsetGen ( arr , i + 1 , n , c ) ; c . add ( arr [ i ] ) ; subsetGen ( arr , i + 1 , n , c ) ; c . remove ( 0 ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 } ; int n = arr . length ; Vector < Integer > c = new Vector < Integer > ( ) ; subsetGen ( arr , 0 , n , c ) ; System . out . println ( ans ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int getMaxValue ( int arr [ ] , int arr_size ) { int i , first , second ; if ( arr_size < 2 ) { return 0 ; } first = second = Integer . MIN_VALUE ; for ( i = 0 ; i < arr_size ; i ++ ) { if ( arr [ i ] > first ) { second = first ; first = arr [ i ] ; } else if ( arr [ i ] > second && arr [ i ] != first ) { second = arr [ i ] ; } } if ( second == Integer . MIN_VALUE ) { return 0 ; } else { return second ; } } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 5 , 1 , 8 } ; int n = arr . length ; System . out . println ( getMaxValue ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int maximumResult ( int a , int b , int c ) { int countOfNegative = 0 ; int sum = a + b + c ; int product = a * b * c ; int largest = ( a > b ) ? ( ( a > c ) ? a : c ) : ( ( b > c ) ? b : c ) ; int smallest = ( a < b ) ? ( ( a < c ) ? a : c ) : ( ( b < c ) ? b : c ) ; if ( a < 0 ) countOfNegative ++ ; if ( b < 0 ) countOfNegative ++ ; if ( c < 0 ) countOfNegative ++ ; switch ( countOfNegative ) { case 0 : return ( sum - largest ) * largest ; case 1 : return ( product / smallest ) + smallest ; case 2 : return ( product / largest ) + largest ; case 3 : return ( sum - smallest ) * smallest ; } return - 1 ; } public static void main ( String [ ] args ) { int a = - 2 , b = - 1 , c = - 4 ; System . out . print ( maximumResult ( a , b , c ) ) ; } }

Accumulator variables: countOfNegative
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int check ( int n , List < Integer > marks ) { Integer x = Collections . max ( marks ) ; int bonus = 100 - x ; int c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( marks . get ( i ) + bonus >= 50 ) c += 1 ; } return c ; } public static void main ( String [ ] args ) { int n = 5 ; List < Integer > marks = Arrays . asList ( 0 , 21 , 83 , 45 , 64 ) ; System . out . println ( check ( n , marks ) ) ; } }

Accumulator variables: c, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int find_sum ( int n , int k ) { int total_sum = ( n * ( n + 1 ) ) / 2 ; int power = k ; while ( power <= n ) { total_sum -= power ; power *= k ; } return total_sum ; } public static void main ( String [ ] args ) { int n = 11 , k = 2 ; System . out . println ( find_sum ( n , k ) ) ; } }

Accumulator variables: power, total_sum
Class/struct names: GFG
Java program:
import java . util . * ; class Solution { static final int MAX = 10000 ; static int hashTable [ ] = new int [ MAX ] ; static int minOperations ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; for ( int i = 0 ; i < n ; i ++ ) hashTable [ arr [ i ] ] ++ ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( hashTable [ arr [ i ] ] != 0 ) { for ( int j = i ; j < n ; j ++ ) if ( arr [ j ] % arr [ i ] == 0 ) hashTable [ arr [ j ] ] = 0 ; res ++ ; } } return res ; } public static void main ( String args [ ] ) { int arr [ ] = { 4 , 6 , 2 , 8 , 7 , 21 , 24 , 49 , 44 } ; int n = arr . length ; System . out . print ( minOperations ( arr , n ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: Solution
Java program:
import java . util . * ; class GFG { static boolean ifPossible ( int arr [ ] , int n ) { int copy [ ] = Arrays . copyOf ( arr , arr . length ) ; Arrays . sort ( copy ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! ( arr [ i ] == copy [ i ] ) && ! ( arr [ n - 1 - i ] == copy [ i ] ) ) return false ; } return true ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 7 , 6 , 4 , 5 , 3 , 2 , 8 } ; int n = arr . length ; if ( ifPossible ( arr , n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class Process { public Process ( int pid , int bt , int art ) { this . pid = pid ; this . bt = bt ; this . art = art ; } } public class GFG { static void findWaitingTime ( Process proc [ ] , int n , int wt [ ] ) { int rt [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) rt [ i ] = proc [ i ] . bt ; int complete = 0 , t = 0 , minm = Integer . MAX_VALUE ; int shortest = 0 , finish_time ; boolean check = false ; while ( complete != n ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ( proc [ j ] . art <= t ) && ( rt [ j ] < minm ) && rt [ j ] > 0 ) { minm = rt [ j ] ; shortest = j ; check = true ; } } if ( check == false ) { t ++ ; continue ; } rt [ shortest ] -- ; minm = rt [ shortest ] ; if ( minm == 0 ) minm = Integer . MAX_VALUE ; if ( rt [ shortest ] == 0 ) { complete ++ ; check = false ; finish_time = t + 1 ; wt [ shortest ] = finish_time - proc [ shortest ] . bt - proc [ shortest ] . art ; if ( wt [ shortest ] < 0 ) wt [ shortest ] = 0 ; } t ++ ; } } static void findTurnAroundTime ( Process proc [ ] , int n , int wt [ ] , int tat [ ] ) { for ( int i = 0 ; i < n ; i ++ ) tat [ i ] = proc [ i ] . bt + wt [ i ] ; } static void findavgTime ( Process proc [ ] , int n ) { int wt [ ] = new int [ n ] , tat [ ] = new int [ n ] ; int total_wt = 0 , total_tat = 0 ; findWaitingTime ( proc , n , wt ) ; findTurnAroundTime ( proc , n , wt , tat ) ; System . out . println ( " Processes ▁ " + " ▁ Burst ▁ time ▁ " + " ▁ Waiting ▁ time ▁ " + " ▁ Turn ▁ around ▁ time " ) ; for ( int i = 0 ; i < n ; i ++ ) { total_wt = total_wt + wt [ i ] ; total_tat = total_tat + tat [ i ] ; System . out . println ( " ▁ " + proc [ i ] . pid + " TABSYMBOL TABSYMBOL " + proc [ i ] . bt + " TABSYMBOL TABSYMBOL ▁ " + wt [ i ] + " TABSYMBOL TABSYMBOL " + tat [ i ] ) ; } System . out . println ( " Average ▁ waiting ▁ time ▁ = ▁ " + ( float ) total_wt / ( float ) n ) ; System . out . println ( " Average ▁ turn ▁ around ▁ time ▁ = ▁ " + ( float ) total_tat / ( float ) n ) ; } public static void main ( String [ ] args ) { Process proc [ ] = { new Process ( 1 , 6 , 1 ) , new Process ( 2 , 8 , 1 ) , new Process ( 3 , 7 , 2 ) , new Process ( 4 , 3 , 3 ) } ; findavgTime ( proc , proc . length ) ; } }

Index/key variables: i, j, n, shortest
Accumulator variables: complete, i, j, t
Iterator variables: i, j
Boolean variables: check
Class/struct names: GFG, Process
Java program:
import java . io . * ; class GFG { static int MAX = 100001 ; static int minimumDeletions ( int A [ ] , int N ) { int [ ] [ ] dp = new int [ N ] [ MAX ] ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = 0 ; j < MAX ; j ++ ) dp [ i ] [ j ] = 0 ; for ( int i = 0 ; i < N ; i ++ ) { dp [ i ] [ 0 ] = 1 ; for ( int j = i - 1 ; j >= 0 ; j -- ) { if ( A [ i ] >= A [ j ] ) { int diff = A [ i ] - A [ j ] ; for ( int k = 0 ; k <= diff ; k ++ ) { dp [ i ] = Math . max ( dp [ i ] , dp [ j ] [ k ] + 1 ) ; } } } } int maxSetSize = - 1 ; for ( int i = 0 ; i < MAX ; i ++ ) maxSetSize = Math . max ( maxSetSize , dp [ N - 1 ] [ i ] ) ; return N - maxSetSize ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 4 , 5 , 7 , 20 , 21 } ; int N = A . length ; System . out . println ( minimumDeletions ( A , N ) ) ; } }

Index/key variables: MAX, N, i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; public class Main { static int findNumberOfStrings ( int N ) { Vector < Integer > counts = new Vector < Integer > ( ) ; for ( int i = 0 ; i < 5 ; i ++ ) { counts . add ( 1 ) ; } for ( int i = 2 ; i <= N ; i ++ ) { for ( int j = 3 ; j >= 0 ; j -- ) counts . set ( j , counts . get ( j ) + counts . get ( j + 1 ) ) ; } int ans = 0 ; for ( Integer c : counts ) ans += c ; return ans ; } public static void main ( String [ ] args ) { int N = 2 ; System . out . print ( findNumberOfStrings ( N ) ) ; } }

Accumulator variables: ans, i, j
Iterator variables: c, i, j
Class/struct names: Main
Java program:
import java . util . * ; public class Main { static int dp [ ] [ ] = new int [ 1000 + 5 ] [ 9000 + 5 ] ; static int mod = 1000000007 ; public static int countNumbers ( int n , int x , int y , int sum ) { for ( int i [ ] : dp ) Arrays . fill ( i , - 1 ) ; if ( n == 0 ) { return check ( sum , x , y ) ; } if ( dp [ n ] [ sum ] != - 1 ) { return dp [ n ] [ sum ] % mod ; } int option1 = countNumbers ( n - 1 , x , y , sum + x ) % mod ; int option2 = countNumbers ( n - 1 , x , y , sum + y ) % mod ; return dp [ n ] [ sum ] = ( option1 + option2 ) % mod ; } public static int check ( int sum , int x , int y ) { while ( sum > 0 ) { int ln = sum % 10 ; if ( ln != x && ln != y ) { return 0 ; } sum /= 10 ; } return 1 ; } public static void main ( String args [ ] ) { int N = 3 , X = 1 , Y = 5 ; System . out . println ( countNumbers ( N , X , Y , 0 ) % mod ) ; } }

Index/key variables: n, sum
Accumulator variables: sum
Class/struct names: Main
Java program:
import java . util . * ; public class Main { public static int solve ( int a [ ] [ ] , String s , int n , int prev , int mask , int [ ] [ ] dp ) { if ( mask == 0 ) return 0 ; if ( dp [ mask ] [ prev + 1 ] != - 1 ) return dp [ mask ] [ prev + 1 ] ; int ans = 10000 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int id = s . charAt ( i ) - ' a ' ; if ( check ( mask , id ) ) { if ( prev == - 1 ) { ans = Math . min ( ans , solve ( a , s , n , id , mask ^ ( 1 << id ) , dp ) ) ; } else { ans = Math . min ( ans , a [ prev ] [ id ] + solve ( a , s , n , id , mask ^ ( 1 << id ) , dp ) ) ; } } } dp [ mask ] [ prev + 1 ] = ans ; return ans ; } public static boolean check ( int mask , int i ) { int c = ( mask & ( 1 << i ) ) ; return c != 0 ; } static void generatePermutation ( int mask , int n , int a [ ] [ ] , String s ) { int dp [ ] [ ] = new int [ ( 1 << n ) + 5 ] [ n + 5 ] ; for ( int i [ ] : dp ) Arrays . fill ( i , - 1 ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int id = s . charAt ( i ) - ' a ' ; mask |= ( 1 << id ) ; } System . out . println ( solve ( a , s , n , - 1 , mask , dp ) ) ; } public static void main ( String args [ ] ) { int N = 5 ; String str = " abcde " ; int mat [ ] [ ] = { { 0 , 5 , 1 , 5 , 3 } , { 4 , 0 , 9 , 4 , 2 } , { 7 , 9 , 0 , 10 , 7 } , { 1 , 2 , 8 , 0 , 2 } , { 3 , 9 , 7 , 7 , 0 } } ; generatePermutation ( 0 , N , mat , str ) ; } }

Index/key variables: id, mask, prev
Accumulator variables: i, mask
Iterator variables: i
Class/struct names: Main
Java program:
import java . util . * ; public class Main { static int inf = 10000000 ; public static int minCost ( int a [ ] , int i , int j , int k , int [ ] prefix , int [ ] [ ] dp ) { if ( i >= j ) return 0 ; if ( dp [ i ] [ j ] != - 1 ) return dp [ i ] [ j ] ; int best_cost = inf ; for ( int pos = i ; pos < j ; pos ++ ) { int left = minCost ( a , i , pos , k , prefix , dp ) ; int right = minCost ( a , pos + 1 , j , k , prefix , dp ) ; best_cost = Math . min ( best_cost , left + right + ( k * Combine ( prefix , i , j ) ) ) ; } return dp [ i ] [ j ] = best_cost ; } public static int [ ] preprocess ( int [ ] a , int n ) { int p [ ] = new int [ n ] ; p [ 0 ] = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) p [ i ] = p [ i - 1 ] + a [ i ] ; return p ; } public static int Combine ( int [ ] p , int i , int j ) { if ( i == 0 ) return p [ j ] ; else return p [ j ] - p [ i - 1 ] ; } public static void main ( String args [ ] ) { int n = 4 ; int a [ ] = { 4 , 5 , 6 , 7 } ; int k = 3 ; int dp [ ] [ ] = new int [ n + 1 ] [ n + 1 ] ; for ( int i [ ] : dp ) Arrays . fill ( i , - 1 ) ; int prefix [ ] = preprocess ( a , n ) ; System . out . println ( minCost ( a , 0 , n - 1 , k , prefix , dp ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, pos
Iterator variables: i, pos
Class/struct names: Main
Java program:
class GFG { static int minOperations ( int n ) { int dp [ ] = new int [ n + 1 ] ; dp [ 1 ] = 0 ; for ( int i = 2 ; i <= n ; i ++ ) { dp [ i ] = Integer . MAX_VALUE ; if ( i % 2 == 0 ) { int x = dp [ i / 2 ] ; if ( x + 1 < dp [ i ] ) { dp [ i ] = x + 1 ; } } if ( i % 3 == 0 ) { int x = dp [ i / 3 ] ; if ( x + 1 < dp [ i ] ) { dp [ i ] = x + 1 ; } } int x = dp [ i - 1 ] ; if ( x + 1 < dp [ i ] ) { dp [ i ] = x + 1 ; } } return dp [ n ] ; } public static void main ( String [ ] args ) { int n = 15 ; System . out . print ( minOperations ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int ReverseBitonic ( int arr [ ] , int N ) { int i , j ; int [ ] lds = new int [ N ] ; for ( i = 0 ; i < N ; i ++ ) { lds [ i ] = 1 ; } for ( i = 1 ; i < N ; i ++ ) { for ( j = 0 ; j < i ; j ++ ) { if ( arr [ i ] < arr [ j ] && lds [ i ] < lds [ j ] + 1 ) { lds [ i ] = lds [ j ] + 1 ; } } } int [ ] lis = new int [ N ] ; for ( i = 0 ; i < N ; i ++ ) { lis [ i ] = 1 ; } for ( i = N - 2 ; i >= 0 ; i -- ) { for ( j = N - 1 ; j > i ; j -- ) { if ( arr [ i ] < arr [ j ] && lis [ i ] < lis [ j ] + 1 ) { lis [ i ] = lis [ j ] + 1 ; } } } int max = lis [ 0 ] + lds [ 0 ] - 1 ; for ( i = 1 ; i < N ; i ++ ) { if ( lis [ i ] + lds [ i ] - 1 > max ) { max = lis [ i ] + lds [ i ] - 1 ; } } return max ; } public static void main ( String [ ] args ) { int arr [ ] = { 0 , 8 , 4 , 12 , 2 , 10 , 6 , 14 , 1 , 9 , 5 , 13 , 3 , 11 , 7 , 15 } ; int N = arr . length ; System . out . println ( " Length ▁ of ▁ LBS ▁ is ▁ " + ReverseBitonic ( arr , N ) ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . ArrayList ; class GFG { static boolean findPath ( ArrayList < ArrayList < Integer > > maze , int xpos , int ypos , boolean key ) { if ( xpos < 0 || xpos >= maze . size ( ) || ypos < 0 || ypos >= maze . size ( ) ) return false ; if ( maze . get ( xpos ) . get ( ypos ) == '1' ) { if ( key == true ) if ( xpos == maze . size ( ) - 1 && ypos == maze . size ( ) - 1 ) return true ; return findPath ( maze , xpos + 1 , ypos , false ) || findPath ( maze , xpos , ypos + 1 , false ) ; } if ( xpos == maze . size ( ) - 1 && ypos == maze . size ( ) - 1 ) return true ; return findPath ( maze , xpos + 1 , ypos , key ) || findPath ( maze , xpos , ypos + 1 , key ) ; } static boolean mazeProb ( ArrayList < ArrayList < Integer > > maze , int xpos , int ypos ) { boolean key = true ; if ( findPath ( maze , xpos , ypos , key ) ) return true ; return false ; } public static void main ( String [ ] args ) { int size = 3 ; ArrayList < ArrayList < Integer > > maze = new ArrayList < ArrayList < Integer > > ( size ) ; for ( int i = 0 ; i < size ; i ++ ) { maze . add ( new ArrayList < Integer > ( ) ) ; } maze . get ( 0 ) . add ( 0 ) ; maze . get ( 0 ) . add ( 0 ) ; maze . get ( 0 ) . add ( 1 ) ; maze . get ( 1 ) . add ( 1 ) ; maze . get ( 1 ) . add ( 0 ) ; maze . get ( 1 ) . add ( 1 ) ; maze . get ( 2 ) . add ( 1 ) ; maze . get ( 2 ) . add ( 1 ) ; maze . get ( 2 ) . add ( 0 ) ; if ( mazeProb ( maze , 0 , 0 ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Boolean variables: key
Class/struct names: GFG
Java program:
import java . util . * ; class GfG { static int FindMinimumCost ( int ind , int a [ ] , int n , int k , int dp [ ] ) { if ( ind == ( n - 1 ) ) return 0 ; else if ( dp [ ind ] != - 1 ) return dp [ ind ] ; else { int ans = Integer . MAX_VALUE ; for ( int i = 1 ; i <= k ; i ++ ) { if ( ind + i < n ) ans = Math . min ( ans , Math . abs ( a [ ind + i ] - a [ ind ] ) + FindMinimumCost ( ind + i , a , n , k , dp ) ) ; else break ; } return dp [ ind ] = ans ; } } public static void main ( String [ ] args ) { int a [ ] = { 10 , 30 , 40 , 50 , 20 } ; int k = 3 ; int n = a . length ; int dp [ ] = new int [ n ] ; Arrays . fill ( dp , - 1 ) ; System . out . println ( FindMinimumCost ( 0 , a , n , k , dp ) ) ; } }

Index/key variables: ind, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
Java program:
class GFG { static final int MAX = 100000 ; static long prefix [ ] = new long [ MAX ] ; static void sieve_modified ( ) { for ( int i = 2 ; i < MAX ; i += 2 ) { for ( int j = i ; j < MAX ; j += i ) prefix [ j ] += i ; } for ( int i = 1 ; i < MAX ; i ++ ) prefix [ i ] += prefix [ i - 1 ] ; } static long sumEvenFactors ( int L , int R ) { return ( prefix [ R ] - prefix [ L - 1 ] ) ; } public static void main ( String args [ ] ) { sieve_modified ( ) ; int l = 6 , r = 10 ; System . out . print ( sumEvenFactors ( l , r ) ) ; } }

Index/key variables: MAX, R, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int M = 20 ; static int dp [ ] [ ] [ ] [ ] = new int [ M ] [ 165 ] [ M ] [ 2 ] ; static int n , m ; static int count ( int pos , int sum , int rem , int tight , int nonz , Vector < Integer > num ) { if ( pos == num . size ( ) ) { if ( rem == 0 && sum == n ) return 1 ; return 0 ; } if ( dp [ pos ] [ sum ] [ rem ] [ tight ] != - 1 ) return dp [ pos ] [ sum ] [ rem ] [ tight ] ; int ans = 0 ; int limit = ( tight != 0 ? 9 : num . get ( pos ) ) ; for ( int d = 0 ; d <= limit ; d ++ ) { if ( d == 0 && nonz != 0 ) continue ; int currSum = sum + d ; int currRem = ( rem * 10 + d ) % m ; int currF = ( tight != 0 || ( d < num . get ( pos ) ) ) ? 1 : 0 ; ans += count ( pos + 1 , currSum , currRem , currF , ( nonz != 0 d != 0 ) ? 1 : 0 , num ) ; } return dp [ pos ] [ sum ] [ rem ] [ tight ] = ans ; } static int solve ( int x ) { Vector < Integer > num = new Vector < Integer > ( ) ; while ( x != 0 ) { num . add ( x % 10 ) ; x /= 10 ; } Collections . reverse ( num ) ; for ( int i = 0 ; i < M ; i ++ ) for ( int j = 0 ; j < 165 ; j ++ ) for ( int k = 0 ; k < M ; k ++ ) for ( int l = 0 ; l < 2 ; l ++ ) dp [ i ] [ j ] [ k ] [ l ] = - 1 ; return count ( 0 , 0 , 0 , 0 , 0 , num ) ; } public static void main ( String args [ ] ) { int L = 1 , R = 100 ; n = 8 ; m = 2 ; System . out . print ( solve ( R ) - solve ( L ) ) ; } }

Index/key variables: M, i, j, k, l, pos, rem, sum, tight
Accumulator variables: ans, d, i, j, k, l, x
Iterator variables: d, i, j, k, l
Class/struct names: GFG