dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static boolean [ ] dp = new boolean [ 1 << 20 ] ; static boolean isprime ( int n ) { if ( n == 1 ) return false ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { return false ; } } return true ; } static boolean solve ( int arr [ ] , int curr , int mask , int n ) { if ( isprime ( curr ) ) { if ( mask == ( 1 << n ) - 1 ) { return true ; } curr = 0 ; } if ( mask == ( 1 << n ) - 1 ) { if ( ! isprime ( curr ) ) { return false ; } } if ( dp [ mask ] ) return dp [ mask ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( mask & ( 1 << i ) ) == 0 ) { if ( solve ( arr , curr + arr [ i ] , mask 1 << i , n ) ) { return true ; } } } return dp [ mask ] = false ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 6 , 7 , 13 } ; int n = arr . length ; if ( solve ( arr , 0 , 0 , n ) ) { System . out . print ( " YES " ) ; } else { System . out . print ( " NO " ) ; } } }

Index/key variables: i, mask
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static Vector < Integer > dp = new Vector < > ( ) ; static int maxSum ( int i , Vector < Integer > subarr ) { if ( i >= subarr . size ( ) ) return 0 ; if ( dp . get ( i ) != - 1 ) return dp . get ( i ) ; dp . add ( i , Math . max ( maxSum ( i + 1 , subarr ) , subarr . get ( i ) + maxSum ( i + 2 , subarr ) ) ) ; return dp . get ( i ) ; } static void Func ( Vector < Integer > arr ) { Vector < Integer > subarr = new Vector < > ( ) ; subarr . addAll ( arr ) ; subarr . remove ( subarr . size ( ) - 1 ) ; dp . setSize ( subarr . size ( ) ) ; Collections . fill ( dp , - 1 ) ; int max1 = maxSum ( 0 , subarr ) ; subarr = arr ; subarr . remove ( 0 ) ; dp . clear ( ) ; dp . setSize ( subarr . size ( ) ) ; Collections . fill ( dp , - 1 ) ; int max2 = maxSum ( 0 , subarr ) ; System . out . print ( Math . max ( max1 , max2 ) + "NEW_LINE"); } public static void main ( String [ ] args ) { Vector < Integer > arr = new Vector < > ( ) ; arr . add ( 1 ) ; arr . add ( 2 ) ; arr . add ( 3 ) ; arr . add ( 1 ) ; Func ( arr ) ; }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int dim = 5 ; static void createTable ( int mtrx [ ] [ ] , int k , int p , int dp [ ] [ ] ) { dp [ 0 ] [ 0 ] = mtrx [ 0 ] [ 0 ] ; for ( int j = 1 ; j < dim ; j ++ ) { dp [ 0 ] [ j ] = mtrx [ 0 ] [ j ] + dp [ 0 ] [ j - 1 ] ; } for ( int i = 1 ; i < dim ; i ++ ) { dp [ i ] [ 0 ] = mtrx [ i ] [ 0 ] + dp [ i - 1 ] [ 0 ] ; } for ( int i = 1 ; i < dim ; i ++ ) { for ( int j = 1 ; j < dim ; j ++ ) { dp [ i ] [ j ] = mtrx [ i ] [ j ] + dp [ i - 1 ] [ j ] + dp [ i ] [ j - 1 ] - dp [ i - 1 ] [ j - 1 ] ; } } } static int countSubMatrixUtil ( int dp [ ] [ ] , int k , int p ) { int count = 0 ; int subMatSum = 0 ; for ( int i = k - 1 ; i < dim ; i ++ ) { for ( int j = k - 1 ; j < dim ; j ++ ) { if ( i == ( k - 1 ) || j == ( k - 1 ) ) { if ( i == ( k - 1 ) && j == ( k - 1 ) ) { subMatSum = dp [ i ] [ j ] ; } else if ( i == ( k - 1 ) ) { subMatSum = dp [ i ] [ j ] - dp [ i ] [ j - k ] ; } else { subMatSum = dp [ i ] [ j ] - dp [ i - k ] [ j ] ; } } else { subMatSum = dp [ i ] [ j ] - dp [ i - k ] [ j ] - dp [ i ] [ j - k ] + dp [ i - k ] [ j - k ] ; } if ( subMatSum >= p ) { count ++ ; } } } return count ; } static int countSubMatrix ( int mtrx [ ] [ ] , int k , int p ) { int [ ] [ ] dp = new int [ dim ] [ dim ] ; for ( int i = 0 ; i < dim ; i ++ ) { for ( int j = 0 ; j < dim ; j ++ ) { dp [ i ] [ j ] = 0 ; } } createTable ( mtrx , k , p , dp ) ; return countSubMatrixUtil ( dp , k , p ) ; } public static void main ( String [ ] args ) { int mtrx [ ] [ ] = { { 1 , 7 , 1 , 1 , 1 } , { 2 , 2 , 2 , 2 , 2 } , { 3 , 9 , 6 , 7 , 3 } , { 4 , 3 , 2 , 4 , 5 } , { 5 , 1 , 5 , 3 , 1 } } ; int k = 3 ; int p = 35 ; System . out . print ( countSubMatrix ( mtrx , k , p ) ) ; } }

Index/key variables: dim, i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void canMakePaliQueries ( String str , int [ ] [ ] Q ) { int n = str . length ( ) ; int [ ] [ ] dp = new int [ 26 ] [ n ] ; for ( int i = 0 ; i < 26 ; i ++ ) { char currentChar = ( char ) ( i + ' a ' ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( j == 0 ) { dp [ i ] [ j ] = ( str . charAt ( j ) == currentChar ) ? 1 : 0 ; } else { dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + ( ( str . charAt ( j ) == currentChar ) ? 1 : 0 ) ; } } } for ( int [ ] query : Q ) { int left = query [ 0 ] ; int right = query [ 1 ] ; int k = query [ 2 ] ; int unMatchedCount = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { int occurrence = dp [ i ] [ right ] - dp [ i ] [ left ] + ( str . charAt ( left ) == ( i + ' a ' ) ? 1 : 0 ) ; if ( occurrence % 2 == 1 ) unMatchedCount ++ ; } int ans = unMatchedCount / 2 ; if ( ans <= k ) { System . out . print ( "YESNEW_LINE"); } else { System . out . print ( "NONEW_LINE"); } } } public static void main ( String [ ] args ) { String str = " GeeksforGeeks " ; int [ ] [ ] Q = { { 1 , 5 , 3 } , { 5 , 7 , 0 } , { 8 , 11 , 3 } , { 3 , 10 , 5 } , { 0 , 9 , 5 } } ; canMakePaliQueries ( str , Q ) ; } }

Index/key variables: i, j, left, n, right
Accumulator variables: i, j, unMatchedCount
Iterator variables: i, j, query
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MAX = 100 ; static int dp [ ] [ ] [ ] = new int [ 1000 ] [ MAX ] [ MAX ] ; static int productDigitSum ( int x , int y ) { int sumx = 0 ; while ( x > 0 ) { sumx += ( x % 10 ) ; x /= 10 ; } int sumy = 0 ; while ( y > 0 ) { sumy += ( y % 10 ) ; y /= 10 ; } return ( sumx * sumy ) ; } static int solve ( int arr [ ] , int i , int len , int prev , int n , int k ) { if ( len == k ) return 0 ; if ( i == n ) return Integer . MIN_VALUE ; if ( dp [ i ] [ len ] [ prev ] != 0 ) return dp [ i ] [ len ] [ prev ] ; int inc = 0 , exc = 0 ; if ( ( len & 1 ) != 0 ) { inc = ( productDigitSum ( arr [ prev ] , arr [ i ] ) + solve ( arr , i + 1 , len + 1 , 0 , n , k ) ) ; } else { inc = solve ( arr , i + 1 , len + 1 , i , n , k ) ; } exc = solve ( arr , i + 1 , len , prev , n , k ) ; return dp [ i ] [ len ] [ prev ] = Math . max ( inc , exc ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 5 , 9 , 101 , 24 , 2 , 20 , 14 } ; int n = arr . length ; int k = 6 ; System . out . print ( solve ( arr , 0 , 0 , 0 , n , k ) ) ; } }

Index/key variables: MAX, i, len, prev
Accumulator variables: sumx, sumy, x, y
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static Vector < Integer > [ ] factors = new Vector [ 100005 ] ; static int [ ] dp = new int [ 100005 ] ; static void precompute ( ) { for ( int i = 0 ; i < factors . length ; i ++ ) factors [ i ] = new Vector < Integer > ( ) ; for ( int i = 1 ; i <= 100000 ; i ++ ) { for ( int j = i ; j <= 100000 ; j += i ) { factors [ j ] . add ( i ) ; } } } static int solve ( int arr [ ] , int k , int n ) { if ( k == n - 1 ) { return 0 ; } if ( k >= n ) { return Integer . MAX_VALUE ; } if ( dp [ k ] != 0 ) { return dp [ k ] ; } int ans = Integer . MAX_VALUE ; for ( int j : factors [ arr [ k ] ] ) { int res = solve ( arr , k + j , n ) ; if ( res != Integer . MAX_VALUE ) { ans = Math . min ( ans , res + 1 ) ; } } return dp [ k ] = ans ; } public static void main ( String [ ] args ) { precompute ( ) ; int arr [ ] = { 2 , 8 , 16 , 55 , 99 , 100 } ; int n = arr . length ; System . out . print ( solve ( arr , 0 , n ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
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 int maxDistance ( int [ ] [ ] grid ) { Vector < pair > one = new Vector < pair > ( ) ; int M = grid . length ; int N = grid [ 0 ] . length ; int ans = - 1 ; for ( int i = 0 ; i < M ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { if ( grid [ i ] [ j ] == 1 ) one . add ( new pair ( i , j ) ) ; } } if ( one . isEmpty ( ) || M * N == one . size ( ) ) return - 1 ; for ( int i = 0 ; i < M ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { if ( grid [ i ] [ j ] == 1 ) continue ; int dist = Integer . MAX_VALUE ; for ( pair p : one ) { int d = Math . abs ( p . first - i ) + Math . abs ( p . second - j ) ; dist = Math . min ( dist , d ) ; if ( dist <= ans ) break ; } ans = Math . max ( ans , dist ) ; } } return ans ; } public static void main ( String [ ] args ) { int [ ] [ ] arr = { { 0 , 0 , 1 } , { 0 , 0 , 0 } , { 0 , 0 , 0 } } ; System . out . print ( maxDistance ( arr ) + "NEW_LINE"); } }

Index/key variables: i, j
Iterator variables: i, j, p
Class/struct names: GFG, pair
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 int maxDistance ( int [ ] [ ] grid ) { Queue < pair > q = new LinkedList < pair > ( ) ; int M = grid . length ; int N = grid [ 0 ] . length ; int ans = - 1 ; int dirs [ ] [ ] = { { 0 , 1 } , { 1 , 0 } , { 0 , - 1 } , { - 1 , 0 } } ; for ( int i = 0 ; i < M ; ++ i ) { for ( int j = 0 ; j < N ; ++ j ) { if ( grid [ i ] [ j ] == 1 ) q . add ( new pair ( i , j ) ) ; } } if ( q . isEmpty ( ) || M * N == q . size ( ) ) return - 1 ; while ( q . size ( ) > 0 ) { int cnt = q . size ( ) ; while ( cnt -- > 0 ) { pair p = q . peek ( ) ; q . remove ( ) ; for ( int [ ] dir : dirs ) { int x = p . first + dir [ 0 ] ; int y = p . second + dir [ 1 ] ; if ( x < 0 x >= M y < 0 y >= N grid [ x ] [ y ] > 0 ) continue ; q . add ( new pair ( x , y ) ) ; grid [ x ] [ y ] = 1 ; } } ++ ans ; } return ans ; } public static void main ( String [ ] args ) { int [ ] [ ] arr = { { 0 , 0 , 1 } , { 0 , 0 , 0 } , { 0 , 0 , 1 } } ; System . out . print ( maxDistance ( arr ) + "NEW_LINE"); } }

Index/key variables: i, j, x, y
Accumulator variables: cnt
Iterator variables: dir, i, j
Class/struct names: GFG, pair
Java program:
import java . util . * ; class GFG { static int mod = ( int ) ( 1e9 + 7 ) ; static int [ ] [ ] dp ; static int f ( int n , int k ) { if ( n < k ) return 0 ; if ( n == k ) return 1 ; if ( k == 1 ) return 1 ; if ( dp [ n ] [ k ] != - 1 ) return dp [ n ] [ k ] ; return dp [ n ] [ k ] = ( ( k * f ( n - 1 , k ) ) % mod + ( f ( n - 1 , k - 1 ) ) % mod ) % mod ; } static long operation ( int n ) { dp = new int [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < n + 1 ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } long ans = 0 , fac = 1 ; for ( int k = 1 ; k <= n ; k ++ ) { fac *= k ; ans = ( ans + ( fac * f ( n , k ) ) % mod ) % mod ; } return ans ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . print ( operation ( n ) + "NEW_LINE"); } }

Index/key variables: i, j, k, n
Accumulator variables: fac, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
class GFG { static int CountSets ( int x , int pos ) { if ( x <= 0 ) { if ( pos == 0 ) return 1 ; else return 0 ; } if ( pos == 0 ) return 1 ; int answer = CountSets ( x - 1 , pos ) + CountSets ( x - 2 , pos - 1 ) ; return answer ; } static int CountOrderedSets ( int n ) { int [ ] factorial = new int [ 10000 ] ; factorial [ 0 ] = 1 ; for ( int i = 1 ; i < 10000 ; i ++ ) factorial [ i ] = factorial [ i - 1 ] * i ; int answer = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int sets = CountSets ( n , i ) * factorial [ i ] ; answer = answer + sets ; } return answer ; } public static void main ( String [ ] args ) { int N = 3 ; System . out . print ( CountOrderedSets ( N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int MaximumSum ( int a [ ] , int n ) { int [ ] [ ] dp = new int [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < n + 1 ; j ++ ) dp [ i ] [ j ] = Integer . MIN_VALUE ; } for ( int i = 0 ; i < n + 1 ; i ++ ) dp [ i ] [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { int val = Integer . MIN_VALUE ; if ( ( i - 2 >= 0 && dp [ i - 2 ] [ j - 1 ] != Integer . MIN_VALUE ) i - 2 < 0 ) { val = a [ i - 1 ] + ( i - 2 >= 0 ? dp [ i - 2 ] [ j - 1 ] : 0 ) ; } if ( i - 1 >= j ) { val = Math . max ( val , dp [ i - 1 ] [ j ] ) ; } dp [ i ] [ j ] = val ; } } return dp [ n ] [ n / 2 ] ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 2 , 3 , 4 , 5 , 6 } ; int N = A . length ; System . out . print ( MaximumSum ( A , N ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static HashSet < Integer > kPowKform = new HashSet < Integer > ( ) ; static int func ( int n ) { if ( n <= 0 ) return 0 ; if ( kPowKform . contains ( n ) ) return 1 ; int answer = 0 ; int x = n ; while ( x > 0 ) { int d = x % 10 ; if ( d != 0 ) { if ( func ( n - d * d ) == 1 ) { answer = 1 ; break ; } } x /= 10 ; } return answer ; } static void canBeConverted ( int n ) { if ( func ( n ) == 1 ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } public static void main ( String [ ] args ) { int N = 90 ; for ( int i = 1 ; i <= 8 ; i ++ ) { int val = 1 ; for ( int j = 1 ; j <= i ; j ++ ) val *= i ; kPowKform . add ( val ) ; } canBeConverted ( N ) ; } }

Accumulator variables: i, j, val, x
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean check ( Vector < Integer > v ) { HashSet < Integer > digits = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { HashSet < Integer > d = new HashSet < Integer > ( ) ; while ( v . get ( i ) > 0 ) { d . add ( v . get ( i ) % 10 ) ; v . set ( i , v . get ( i ) / 10 ) ; } for ( int it : d ) { if ( digits . contains ( it ) ) return false ; } for ( int it : d ) digits . add ( it ) ; } return true ; } static int numberOfSubarrays ( int a [ ] , int n ) { int answer = 0 ; for ( int i = 1 ; i < ( 1 << n ) ; i ++ ) { Vector < Integer > temp = new Vector < Integer > ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & ( 1 << j ) ) > 0 ) temp . add ( a [ j ] ) ; } if ( check ( temp ) ) answer ++ ; } return answer ; } public static void main ( String [ ] args ) { int N = 4 ; int A [ ] = { 1 , 12 , 23 , 34 } ; System . out . print ( numberOfSubarrays ( A , N ) ) ; } }

Index/key variables: j
Accumulator variables: answer, i, j
Iterator variables: i, it, j
Class/struct names: GFG
Java program:
import java . util . ArrayList ; import java . util . Arrays ; class Pair { int first , second ; public Pair ( int first , int second ) { this . first = first ; this . second = second ; } } class GFG { static final int MAX = 100005 ; static int totBackEdges ; static int [ ] countAdj = new int [ MAX ] ; static int [ ] small = new int [ MAX ] ; static int [ ] isPossible = new int [ MAX ] ; static int [ ] depth = new int [ MAX ] ; @ SuppressWarnings ( " unchecked " ) static ArrayList < Integer > [ ] adj = new ArrayList [ MAX ] ; static int [ ] vis = new int [ MAX ] ; static void change ( Pair p , int x ) { if ( p . second > x ) p . second = x ; if ( p . first > p . second ) { int tmp = p . first ; p . first = p . second ; p . second = tmp ; } } static Pair dfs ( int v , int p , int de ) { Pair answer = new Pair ( 100000000 , 100000000 ) ; depth [ v ] = de ; vis [ v ] = 1 ; isPossible [ v ] = 1 ; for ( int u : adj [ v ] ) { if ( ( u ^ p ) != 0 ) { if ( vis [ u ] == 0 ) { Pair x = dfs ( u , v , de + 1 ) ; small [ v ] += small [ u ] ; change ( answer , x . second ) ; change ( answer , x . first ) ; if ( x . second < de ) isPossible [ v ] = 0 ; } else if ( vis [ u ] == 1 ) { totBackEdges ++ ; countAdj [ v ] ++ ; countAdj [ u ] ++ ; small [ p ] ++ ; small [ u ] -- ; change ( answer , depth [ u ] ) ; } } } vis [ v ] = 2 ; return answer ; } static int minNodetoRemove ( int n , ArrayList < Pair > edges ) { for ( int i = 0 ; i < edges . size ( ) ; i ++ ) { adj [ edges . get ( i ) . first ] . add ( edges . get ( i ) . second ) ; adj [ edges . get ( i ) . second ] . add ( edges . get ( i ) . first ) ; } Arrays . fill ( vis , 0 ) ; totBackEdges = 0 ; for ( int v = 1 ; v <= n ; v ++ ) { if ( vis [ v ] == 0 ) dfs ( v , - 1 , 0 ) ; } if ( totBackEdges == 0 ) return - 1 ; int node = - 1 ; for ( int v = 1 ; v <= n ; v ++ ) { if ( ( countAdj [ v ] + small [ v ] == totBackEdges ) && isPossible [ v ] != 0 ) { node = v ; } if ( node != - 1 ) break ; } return node ; } public static void main ( String [ ] args ) { int N = 5 ; ArrayList < Pair > edges = new ArrayList < > ( ) ; for ( int i = 0 ; i < MAX ; i ++ ) { adj [ i ] = new ArrayList < > ( ) ; } edges . add ( new Pair ( 5 , 1 ) ) ; edges . add ( new Pair ( 5 , 2 ) ) ; edges . add ( new Pair ( 1 , 2 ) ) ; edges . add ( new Pair ( 2 , 3 ) ) ; edges . add ( new Pair ( 2 , 4 ) ) ; System . out . println ( minNodetoRemove ( N , edges ) ) ; } }

Index/key variables: MAX, i, p, u, v
Accumulator variables: i, totBackEdges, v
Iterator variables: i, u, v
Class/struct names: GFG, Pair
Java program:
import java . util . * ; class GFG { static final int N = 3 ; static final int M = 5 ; static int Large = ( int ) 1e6 ; static Vector < Integer > prime = new Vector < Integer > ( ) ; static void SieveOfEratosthenes ( ) { boolean [ ] isPrime = new boolean [ Large + 1 ] ; Arrays . fill ( isPrime , true ) ; for ( int p = 2 ; p * p <= Large ; p ++ ) { if ( isPrime [ p ] == true ) { for ( int i = p * 2 ; i <= Large ; i += p ) isPrime [ i ] = false ; } } for ( int p = 2 ; p <= Large ; p ++ ) if ( isPrime [ p ] ) prime . add ( p ) ; } static void Display ( int arr [ ] [ ] , int row ) { for ( int i = 0 ; i < M ; i ++ ) System . out . print ( arr [ row ] [ i ] + " ▁ " ) ; } static void countDivisorsMult ( int arr [ ] [ ] ) { HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; int row_no = 0 ; long max_factor = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { int no = arr [ i ] [ j ] ; for ( int k = 0 ; k < prime . size ( ) ; k ++ ) { while ( no > 1 && no % prime . get ( k ) == 0 ) { no /= prime . get ( k ) ; if ( mp . containsKey ( prime . get ( k ) ) ) mp . put ( prime . get ( k ) , prime . get ( k ) + 1 ) ; else mp . put ( prime . get ( k ) , 1 ) ; } if ( no == 1 ) break ; } } int res = 1 ; for ( Map . Entry < Integer , Integer > it : mp . entrySet ( ) ) { res *= ( it . getValue ( ) + 1L ) ; } if ( max_factor < res ) { row_no = i ; max_factor = res ; } mp . clear ( ) ; } Display ( arr , row_no ) ; } public static void main ( String [ ] args ) { int arr [ ] [ ] = { { 1 , 2 , 3 , 10 , 23 } , { 4 , 5 , 6 , 7 , 8 } , { 7 , 8 , 9 , 15 , 45 } } ; SieveOfEratosthenes ( ) ; countDivisorsMult ( arr ) ; } }

Index/key variables: i, j, p, row
Accumulator variables: i, j, k, no, p, res
Iterator variables: i, j, k, p
Class/struct names: GFG
Java program:
class GFG { static int isSquare ( int n ) { int k = ( int ) Math . sqrt ( n ) ; return k * k == n ? 1 : 0 ; } static int calculate ( int pos , int prev , int sum , int [ ] v ) { if ( pos == v . length ) return isSquare ( sum ) ; for ( int i = prev ; i <= 9 ; i ++ ) { v [ pos ] = i ; sum += i * i ; if ( calculate ( pos + 1 , i , sum , v ) != 0 ) return 1 ; sum -= i * i ; } return 0 ; } static String minValue ( int n ) { int [ ] v = new int [ n ] ; if ( calculate ( 0 , 1 , 0 , v ) != 0 ) { String answer = " " ; for ( int i = 0 ; i < v . length ; i ++ ) answer += ( char ) ( v [ i ] + '0' ) ; return answer ; } else return " - 1" ; } public static void main ( String [ ] args ) { int N = 2 ; System . out . println ( minValue ( N ) ) ; } }

Index/key variables: i, n, pos
Accumulator variables: answer, i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int checkOdd ( String number ) { int n = number . length ( ) ; int num = number . charAt ( n - 1 ) - '0' ; return ( num & 1 ) ; } static int splitIntoOdds ( String number ) { int numLen = number . length ( ) ; int splitDP [ ] = new int [ numLen + 1 ] ; for ( int i = 0 ; i < numLen + 1 ; i ++ ) splitDP [ i ] = - 1 ; for ( int i = 1 ; i <= numLen ; i ++ ) { if ( i <= 9 && ( checkOdd ( number . substring ( 0 , i ) ) == 1 ) ) splitDP [ i ] = 1 ; if ( splitDP [ i ] != - 1 ) { for ( int j = 1 ; j <= 9 && i + j <= numLen ; j ++ ) { if ( checkOdd ( number . substring ( i , i + j ) ) == 1 ) { if ( splitDP [ i + j ] == - 1 ) splitDP [ i + j ] = 1 + splitDP [ i ] ; else splitDP [ i + j ] = Math . min ( splitDP [ i + j ] , 1 + splitDP [ i ] ) ; } } } } return splitDP [ numLen ] ; } public static void main ( String [ ] args ) { System . out . println ( splitIntoOdds ( "123456789123456789123" ) ) ; } }

Index/key variables: i, numLen
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . ArrayList ; import java . util . Arrays ; class Graph { static int m , n , d ; static ArrayList < Integer > v = new ArrayList < > ( ) ; static final int k = ( int ) 1e9 + 7 ; static int [ ] [ ] [ ] dp = new int [ 2001 ] [ 2001 ] [ 2 ] ; static void init ( StringBuilder l ) { for ( int i = 0 ; i < 2001 ; i ++ ) { for ( int j = 0 ; j < 2001 ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) { dp [ i ] [ j ] [ k ] = - 1 ; } } } v . clear ( ) ; for ( int i = 0 ; i < l . length ( ) ; i ++ ) { v . add ( l . charAt ( i ) - '0' ) ; } n = l . length ( ) ; } static String number_minus_one ( StringBuilder a ) { String s = a . substring ( 1 ) ; String s1 = " " ; for ( int i = 0 ; i < s . length ( ) - 1 ; i ++ ) s1 += '0' ; if ( a . charAt ( 0 ) == '1' && s . compareTo ( s1 ) == 0 ) { int l = s . length ( ) ; a = new StringBuilder ( " " ) ; a . append ( '0' ) ; for ( int i = 0 ; i < l ; i ++ ) a . append ( '9' ) ; } else { for ( int i = a . length ( ) - 1 ; i >= 0 ; i -- ) { if ( a . charAt ( i ) == '0' ) a . setCharAt ( i , '9' ) ; else { a . setCharAt ( i , ( char ) ( ( ( a . charAt ( i ) - '0' ) - 1 ) + '0' ) ) ; break ; } } } return a . toString ( ) ; } static int fun ( int pos , int sum , int f ) { if ( pos == n ) { if ( sum == 0 ) { return 1 ; } return 0 ; } if ( dp [ pos ] [ sum ] [ f ] != - 1 ) return dp [ pos ] [ sum ] [ f ] ; int lmt = 9 ; if ( f == 0 ) lmt = v . get ( pos ) ; int ans = 0 ; for ( int i = 0 ; i <= lmt ; i ++ ) { if ( i == d && pos % 2 == 1 ) ans += 0 ; else if ( i != d && pos % 2 == 0 ) ans += 0 ; else { int new_f = f ; if ( f == 0 && i < lmt ) new_f = 1 ; int new_sum = sum ; new_sum *= 10 ; new_sum += i ; new_sum %= m ; ans += fun ( pos + 1 , new_sum , new_f ) ; ans %= k ; } } return dp [ pos ] [ sum ] [ f ] = ans ; } static void operations ( StringBuilder L , StringBuilder R ) { init ( R ) ; int ans = fun ( 0 , 0 , 0 ) ; L = new StringBuilder ( number_minus_one ( L ) ) ; init ( L ) ; ans -= fun ( 0 , 0 , 0 ) ; if ( ans < 0 ) ans += k ; System . out . println ( ans ) ; } public static void main ( String [ ] args ) { m = 2 ; d = 2 ; int Q = 1 ; StringBuilder [ ] [ ] arr = { { new StringBuilder ( "20" ) , new StringBuilder ( "32" ) } } ; for ( int i = 0 ; i < Q ; i ++ ) { operations ( arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ; } } }

Index/key variables: f, i, j, k, pos, sum
Accumulator variables: ans, i, j, k, new_sum, s1
Iterator variables: i, j, k
Class/struct names: Graph
Java program:
import java . util . * ; class GFG { static boolean checkPrime ( String number ) { int num = Integer . valueOf ( number ) ; for ( int i = 2 ; i * i <= num ; i ++ ) if ( ( num % i ) == 0 ) return false ; return true ; } static int splitIntoPrimes ( String number ) { if ( number . length ( ) == 0 ) return 0 ; if ( number . length ( ) <= 6 && checkPrime ( number ) ) return 1 ; else { int numLen = number . length ( ) ; int ans = 1000000 ; for ( int i = 1 ; i <= 6 && i <= numLen ; i ++ ) { if ( checkPrime ( number . substring ( 0 , i ) ) ) { int val = splitIntoPrimes ( number . substring ( i ) ) ; if ( val != - 1 ) { ans = Math . min ( ans , 1 + val ) ; } } } if ( ans == 1000000 ) return - 1 ; return ans ; } } public static void main ( String [ ] args ) { System . out . print ( splitIntoPrimes ( "13499315" ) + "NEW_LINE"); System . out . print ( splitIntoPrimes ( "43" ) + "NEW_LINE"); } }

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