dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
public class Tree { private TreeNode root ; public Tree [ ] buildFromLinks ( String [ ] links ) { TreeNode [ ] nodes = new TreeNode [ 26 ] ; Tree [ ] forest = new Tree [ 26 ] ; for ( String link : links ) { String [ ] ends = link . split ( " ▁ " ) ; int start = ( int ) ( ends [ 0 ] . charAt ( 0 ) - ' a ' ) ; int end = ( int ) ( ends [ 1 ] . charAt ( 0 ) - ' a ' ) ; if ( nodes [ start ] == null ) { nodes [ start ] = new TreeNode ( ( char ) ( start + ' a ' ) ) ; forest [ start ] = new Tree ( nodes [ start ] ) ; } if ( nodes [ end ] == null ) nodes [ end ] = new TreeNode ( ( char ) ( end + ' a ' ) ) ; else forest [ end ] = null ; nodes [ start ] . addChild ( nodes [ end ] , end ) ; } return forest ; } public Tree ( TreeNode root ) { this . root = root ; } public static void printForest ( String [ ] links ) { Tree t = new Tree ( new TreeNode ( ' \0' ) ) ; for ( Tree t1 : t . buildFromLinks ( links ) ) { if ( t1 != null ) { t1 . root . printTreeIdented ( " " ) ; System . out . println ( " " ) ; } } } public static void main ( String [ ] args ) { String [ ] links1 = { " a ▁ b " , " b ▁ c " , " b ▁ d " , " a ▁ e " } ; System . out . println ( " - - - - - - - - - - - - ▁ Forest ▁ 1 ▁ - - - - - - - - - - - - - - - - " ) ; printForest ( links1 ) ; String [ ] links2 = { " a ▁ b " , " a ▁ g " , " b ▁ c " , " c ▁ d " , " d ▁ e " , " c ▁ f " , " z ▁ y " , " y ▁ x " , " x ▁ w " } ; System . out . println ( " - - - - - - - - - - - - ▁ Forest ▁ 2 ▁ - - - - - - - - - - - - - - - - " ) ; printForest ( links2 ) ; } } class TreeNode { TreeNode [ ] children ; char c ; public void addChild ( TreeNode n , int index ) { this . children [ index ] = n ; } public TreeNode ( char c ) { this . c = c ; this . children = new TreeNode [ 26 ] ; } public void printTreeIdented ( String indent ) { System . out . println ( indent + " - - > " + c ) ; for ( TreeNode child : children ) { if ( child != null ) child . printTreeIdented ( indent + " ▁ " ) ; } } }

Index/key variables: end, index, start
Iterator variables: child, link, t1
Class/struct names: Tree, TreeNode
Java program:
import java . util . * ; public class PrintPost { static int preIndex = 0 ; void printPost ( int [ ] in , int [ ] pre , int inStrt , int inEnd , HashMap < Integer , Integer > hm ) { if ( inStrt > inEnd ) return ; int inIndex = hm . get ( pre [ preIndex ++ ] ) ; printPost ( in , pre , inStrt , inIndex - 1 , hm ) ; printPost ( in , pre , inIndex + 1 , inEnd , hm ) ; System . out . print ( in [ inIndex ] + " ▁ " ) ; } void printPostMain ( int [ ] in , int [ ] pre ) { int n = pre . length ; HashMap < Integer , Integer > hm = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) hm . put ( in [ i ] , i ) ; printPost ( in , pre , 0 , n - 1 , hm ) ; } public static void main ( String ars [ ] ) { int in [ ] = { 4 , 2 , 5 , 1 , 3 , 6 } ; int pre [ ] = { 1 , 2 , 4 , 5 , 3 , 6 } ; PrintPost tree = new PrintPost ( ) ; tree . printPostMain ( in , pre ) ; } }

Index/key variables: i, inIndex
Accumulator variables: i, preIndex
Iterator variables: i
Class/struct names: PrintPost
Java program:
import java . util . HashMap ; import java . util . Map ; class GFG { static boolean issafe ( int m , int n , int i , int j ) { if ( i < 0 ) return false ; if ( j < 0 ) return false ; if ( i >= m ) return false ; if ( j >= n ) return false ; return true ; } static int [ ] endpoints ( int [ ] [ ] arr , int m , int n ) { int i = 0 ; int j = 0 ; int current_i = 0 ; int current_j = 0 ; char current_d = ' r ' ; Map < Character , Character > rcd = new HashMap < > ( ) ; rcd . put ( ' l ' , ' u ' ) ; rcd . put ( ' u ' , ' r ' ) ; rcd . put ( ' r ' , ' d ' ) ; rcd . put ( ' d ' , ' l ' ) ; while ( issafe ( m , n , i , j ) ) { current_i = i ; current_j = j ; if ( arr [ i ] [ j ] == 1 ) { char move_in = rcd . get ( current_d ) ; arr [ i ] [ j ] = 0 ; if ( move_in == ' u ' ) i -= 1 ; else if ( move_in == ' d ' ) i += 1 ; else if ( move_in == ' l ' ) j -= 1 ; else if ( move_in == ' r ' ) j += 1 ; current_d = move_in ; } else { if ( current_d == ' u ' ) i -= 1 ; else if ( current_d == ' d ' ) i += 1 ; else if ( current_d == ' l ' ) j -= 1 ; else if ( current_d == ' r ' ) j += 1 ; } } return new int [ ] { current_i , current_j } ; } public static void main ( String [ ] args ) { int M = 3 ; int N = 5 ; int [ ] [ ] arr = { { 0 , 1 , 1 , 1 , 0 } , { 1 , 0 , 1 , 0 , 1 } , { 1 , 1 , 1 , 0 , 0 } } ; int [ ] p = endpoints ( arr , M , N ) ; System . out . print ( " ( " + p [ 0 ] + " , ▁ " + p [ 1 ] + " ) " + "NEW_LINE"); } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void sumOfTwoPerfectCubes ( int N ) { HashMap < Integer , Integer > cubes = new HashMap < > ( ) ; for ( int i = 1 ; i * i * i <= N ; i ++ ) cubes . put ( ( i * i * i ) , i ) ; Iterator < Map . Entry < Integer , Integer > > itr = cubes . entrySet ( ) . iterator ( ) ; while ( itr . hasNext ( ) ) { Map . Entry < Integer , Integer > entry = itr . next ( ) ; int firstNumber = entry . getKey ( ) ; int secondNumber = N - entry . getKey ( ) ; if ( cubes . containsKey ( secondNumber ) ) { System . out . println ( " True " ) ; return ; } } System . out . println ( " False " ) ; } public static void main ( String [ ] args ) { int N = 28 ; sumOfTwoPerfectCubes ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int mod = 1000000007 ; static void countSets ( int arr [ ] , int n ) { int cnt = 0 ; int maxE = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( maxE < arr [ i ] ) maxE = arr [ i ] ; } int sieve [ ] = new int [ maxE + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) sieve [ arr [ i ] ] = 1 ; for ( int i = 1 ; i <= maxE ; i ++ ) { if ( sieve [ i ] != 0 ) { for ( int j = i * 2 ; j <= maxE ; j += i ) { if ( sieve [ j ] != 0 ) sieve [ j ] = ( sieve [ j ] + sieve [ i ] ) % mod ; } } } for ( int i = 0 ; i <= maxE ; i ++ ) cnt = ( cnt % mod + sieve [ i ] % mod ) % mod ; System . out . println ( cnt % mod ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 16 , 18 , 6 , 7 , 2 , 19 , 20 , 9 } ; int N = arr . length ; countSets ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static int MAX = 100001 ; static int spf [ ] ; static ArrayList < Integer > v [ ] ; static void sieve ( ) { for ( int i = 1 ; i < MAX ; i ++ ) spf [ i ] = i ; for ( int i = 4 ; i < MAX ; i = i + 2 ) spf [ i ] = 2 ; for ( int i = 3 ; i * i < MAX ; i ++ ) if ( spf [ i ] == i ) { for ( int j = i * i ; j < MAX ; j = j + i ) { if ( spf [ j ] == j ) spf [ j ] = i ; } } } static void DistPrime ( ) { for ( int i = 1 ; i < MAX ; i ++ ) { int idx = 1 ; int x = i ; if ( x != 1 ) v [ i ] . add ( spf [ x ] ) ; x = x / spf [ x ] ; while ( x != 1 ) { if ( v [ i ] . get ( idx - 1 ) != spf [ x ] ) { v [ i ] . add ( spf [ x ] ) ; idx += 1 ; } x = x / spf [ x ] ; } } } static void getFactorCount ( int arr [ ] , int N ) { spf = new int [ MAX ] ; v = new ArrayList [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) v [ i ] = new ArrayList < > ( ) ; sieve ( ) ; DistPrime ( ) ; for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( ( int ) v [ arr [ i ] ] . size ( ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 6 , 9 , 12 } ; int N = arr . length ; getFactorCount ( arr , N ) ; } }

Index/key variables: MAX, i, j, x
Accumulator variables: i, idx
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findDay ( int Y , int B ) { int lyear , rest , totaldays , day ; Y = ( Y - 1 ) - B ; lyear = Y / 4 ; rest = Y - lyear ; totaldays = ( rest * 365 ) + ( lyear * 366 ) + 1 ; day = ( totaldays % 7 ) ; if ( day == 0 ) System . out . println ( " Monday " ) ; else if ( day == 1 ) System . out . println ( " Tuesday " ) ; else if ( day == 2 ) System . out . println ( " Wednesday " ) ; else if ( day == 3 ) System . out . println ( " Thursday " ) ; else if ( day == 4 ) System . out . println ( " Friday " ) ; else if ( day == 5 ) System . out . println ( " Saturday " ) ; else if ( day == 6 ) System . out . println ( " Sunday " ) ; else System . out . println ( " INPUT ▁ YEAR ▁ IS ▁ WRONG ! " ) ; } public static void main ( String [ ] args ) { int Y = 2020 , B = 1900 ; findDay ( Y , B ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void printArray ( int arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } static void modifyArray ( int arr [ ] , int N , int Q [ ] [ ] , int cntQuery ) { int arr1 [ ] = new int [ N + 2 ] ; int arr2 [ ] = new int [ N + 2 ] ; for ( int i = 0 ; i < cntQuery ; i ++ ) { int L = Q [ i ] [ 0 ] + 1 , R = Q [ i ] [ 1 ] + 1 ; arr1 [ L ] ++ ; arr1 [ R + 1 ] -- ; arr2 [ R + 1 ] -= R - L + 1 ; } for ( int i = 1 ; i <= N ; i ++ ) arr1 [ i ] += arr1 [ i - 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) arr2 [ i ] += arr2 [ i - 1 ] + arr1 [ i ] ; for ( int i = 1 ; i <= N ; i ++ ) arr [ i - 1 ] = arr2 [ i ] ; printArray ( arr , N ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 0 , 0 , 0 , 0 } ; int N = arr . length ; int Q [ ] [ ] = { { 1 , 3 } , { 0 , 1 } } ; int cntQuery = Q . length ; modifyArray ( arr , N , Q , cntQuery ) ; } }

Index/key variables: L, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int findProduct ( int number_1 , int number_2 ) { if ( number_1 == Integer . MIN_VALUE number_2 == Integer . MIN_VALUE ) { return 0 ; } else return number_1 * number_2 ; } static ArrayList < Integer > calculateProduct ( ArrayList < ArrayList < Integer > > List , int index ) { int highest = Collections . max ( List . get ( index ) ) ; int lowest = Collections . min ( List . get ( index ) ) ; if ( index + 1 == List . size ( ) ) { if ( lowest < 0 && highest >= 0 ) { return ( new ArrayList < Integer > ( Arrays . asList ( highest , lowest ) ) ) ; } else if ( lowest <= 0 && highest <= 0 ) { return ( new ArrayList < Integer > ( Arrays . asList ( Integer . MIN_VALUE , lowest ) ) ) ; } else if ( lowest >= 0 && highest >= 0 ) { return ( new ArrayList < Integer > ( Arrays . asList ( highest , Integer . MIN_VALUE ) ) ) ; } } ArrayList < Integer > temp = calculateProduct ( List , index + 1 ) ; int positive = temp . get ( 0 ) ; int negative = temp . get ( 1 ) ; int highPos = findProduct ( highest , positive ) ; int highNeg = findProduct ( highest , negative ) ; int lowPos = findProduct ( lowest , positive ) ; int lowNeg = findProduct ( lowest , negative ) ; if ( lowest < 0 && highest >= 0 ) { return ( new ArrayList < Integer > ( Arrays . asList ( Math . max ( highPos , lowNeg ) , Math . min ( highNeg , lowPos ) ) ) ) ; } else if ( lowest <= 0 && highest <= 0 ) { return ( new ArrayList < Integer > ( Arrays . asList ( lowNeg , lowPos ) ) ) ; } else if ( lowest >= 0 && highest >= 0 ) { return ( new ArrayList < Integer > ( Arrays . asList ( Math . max ( lowPos , highPos ) , Math . min ( lowNeg , highNeg ) ) ) ) ; } return ( new ArrayList < Integer > ( Arrays . asList ( 0 , 0 ) ) ) ; } public static void main ( String [ ] args ) { int N = 2 ; ArrayList < ArrayList < Integer > > arr = new ArrayList < ArrayList < Integer > > ( ) ; arr . add ( new ArrayList < Integer > ( Arrays . asList ( - 3 , - 4 ) ) ) ; arr . add ( new ArrayList < Integer > ( Arrays . asList ( 1 , 2 , - 3 ) ) ) ; ArrayList < Integer > ans = calculateProduct ( arr , 0 ) ; System . out . println ( ans . get ( 0 ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void maxNumTrailNine ( int n , int d ) { int res = n ; int cntDigits = ( int ) Math . log10 ( n ) + 1 ; int p10 = 10 ; for ( int i = 1 ; i <= cntDigits ; i ++ ) { if ( n % p10 >= d ) { break ; } else { res = n - n % p10 - 1 ; } p10 = p10 * 10 ; } System . out . println ( res ) ; } public static void main ( String [ ] args ) { int n = 1025 , d = 6 ; maxNumTrailNine ( n , d ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MinimumNoOfWays ( int arr [ ] , int n ) { int mini_no_of_ways ; if ( n % 2 == 0 ) { mini_no_of_ways = n / 2 ; } else { mini_no_of_ways = n / 2 + 1 ; } return mini_no_of_ways ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 4 , 2 , 1 , 5 } ; int N = arr . length ; System . out . print ( MinimumNoOfWays ( arr , N ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int minChocolates ( int [ ] a , int n ) { int i = 0 , j = 0 ; int res = 0 , val = 1 ; while ( j < n - 1 ) { if ( a [ j ] > a [ j + 1 ] ) { j += 1 ; continue ; } if ( i == j ) res += val ; else { res += get_sum ( val , i , j ) ; } if ( a [ j ] < a [ j + 1 ] ) val += 1 ; else val = 1 ; j += 1 ; i = j ; } if ( i == j ) res += val ; else res += get_sum ( val , i , j ) ; return res ; } public static int get_sum ( int peak , int start , int end ) { int count = end - start + 1 ; peak = ( peak > count ) ? peak : count ; int s = peak + ( ( ( count - 1 ) * count ) >> 1 ) ; return s ; } } public static void main ( String [ ] args ) { int [ ] a = { 5 , 5 , 4 , 3 , 2 , 1 } ; int n = a . length ; System . out . print ( " Minimum ▁ number ▁ of ▁ chocolates ▁ = ▁ " + minChocolates ( a , n ) ) ; }

Index/key variables: j
Accumulator variables: j, res, val
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int [ ] RemoveElemArr ( int [ ] arr , int n , int k ) { if ( n == 0 n == 1 ) return arr ; int j = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( j < k arr [ i ] > arr [ j - k ] ) { arr [ j ++ ] = arr [ i ] ; } } while ( arr . length > j ) { arr = Arrays . copyOfRange ( arr , 0 , arr . length - 1 ) ; } return arr ; } static void printArray ( int [ ] arr ) { for ( int i = 0 ; i < arr . length ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } static void UtilRemov ( int [ ] arr , int n , int k ) { arr = RemoveElemArr ( arr , n , k ) ; printArray ( arr ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 2 , 3 , 4 , 4 , 4 , 5 , 5 } ; int k = 2 ; int n = arr . length ; UtilRemov ( arr , n , k ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void pairs_after_removing ( int arr [ ] , int N ) { int cntPairs = 0 ; Map < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { mp . put ( arr [ i ] , mp . getOrDefault ( arr [ i ] , 0 ) + 1 ) ; } for ( Map . Entry < Integer , Integer > element : mp . entrySet ( ) ) { int i = element . getKey ( ) ; cntPairs += mp . get ( i ) * ( mp . get ( i ) - 1 ) / 2 ; } for ( int i = 0 ; i < N ; i ++ ) { int pairs_after_arr_i_removed = cntPairs + 1 - mp . get ( arr [ i ] ) ; System . out . print ( pairs_after_arr_i_removed + " ▁ " ) ; } return ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 4 , 3 , 2 } ; int N = arr . length ; pairs_after_removing ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: cntPairs, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int smallestDivisorGr1 ( int N ) { for ( int i = 2 ; i <= Math . sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) { return i ; } } return N ; } static int findValOfNWithOperat ( int N , int K ) { if ( N % 2 == 0 ) { N += K * 2 ; } else { N += smallestDivisorGr1 ( N ) + ( K - 1 ) * 2 ; } return N ; } public static void main ( String [ ] args ) { int N = 6 , K = 4 ; System . out . print ( findValOfNWithOperat ( N , K ) ) ; } }

Accumulator variables: N, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int CntOfSubsetsByPartitioning ( int arr [ ] , int N ) { HashMap < Integer , Integer > freq = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( freq . containsKey ( arr [ i ] ) ) { freq . put ( arr [ i ] , freq . get ( arr [ i ] ) + 1 ) ; } else { freq . put ( arr [ i ] , 1 ) ; } } int freqGCD = 0 ; for ( Map . Entry < Integer , Integer > i : freq . entrySet ( ) ) { freqGCD = __gcd ( freqGCD , i . getValue ( ) ) ; } return ( N ) / freqGCD ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 4 , 3 , 2 , 1 } ; int N = arr . length ; System . out . print ( CntOfSubsetsByPartitioning ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; public class GFG { private static int r , c ; static int [ ] [ ] dir = { { 1 , 0 } , { - 1 , 0 } , { 0 , 1 } , { 0 , - 1 } , { - 1 , - 1 } , { - 1 , 1 } , { 1 , 1 } , { 1 , - 1 } } ; public static boolean valid ( int i , int j ) { if ( i >= 0 && j >= 0 && i < r && j < c ) return true ; return false ; } static int find ( int i , int j , int [ ] [ ] v ) { int s = 0 ; for ( int k = 0 ; k < 8 ; k ++ ) { int ni = i + dir [ k ] [ 0 ] , nj = j + dir [ k ] [ 1 ] ; if ( valid ( ni , nj ) ) s += v [ ni ] [ nj ] ; } return s ; } static void findsumofneighbors ( int [ ] [ ] M ) { int [ ] [ ] v = new int [ r ] ; for ( int i = 0 ; i < r ; i ++ ) { for ( int j = 0 ; j < c ; j ++ ) { v [ i ] [ j ] = find ( i , j , M ) ; System . out . print ( v [ i ] [ j ] + " ▁ " ) ; } System . out . println ( " " ) ; } } public static void main ( String [ ] args ) { int [ ] [ ] M = { { 1 , 4 , 1 } , { 2 , 4 , 5 } , { 3 , 1 , 2 } } ; r = M . length ; c = M [ 0 ] . length ; findsumofneighbors ( M ) ; } }

Index/key variables: i, j, k, ni, nj, r
Accumulator variables: i, j, k, s
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int mod = ( int ) ( 1e9 + 7 ) ; static int [ ] [ ] T = new int [ 2000 ] [ 2000 ] ; static int [ ] [ ] result = new int [ 2000 ] [ 2000 ] ; static void mul_2 ( int K ) { int [ ] [ ] temp = new int [ K + 1 ] [ K + 1 ] ; for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 1 ; j <= K ; j ++ ) { for ( int k = 1 ; k <= K ; k ++ ) { temp [ i ] [ j ] = ( temp [ i ] [ j ] + ( T [ i ] [ k ] * T [ k ] [ j ] ) % mod ) % mod ; } } } for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 1 ; j <= K ; j ++ ) { T [ i ] [ j ] = temp [ i ] [ j ] ; } } } static void mul_1 ( int K ) { int [ ] [ ] temp = new int [ K + 1 ] [ K + 1 ] ; for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 1 ; j <= K ; j ++ ) { for ( int k = 1 ; k <= K ; k ++ ) { temp [ i ] [ j ] = ( temp [ i ] [ j ] + ( result [ i ] [ k ] * T [ k ] [ j ] ) % mod ) % mod ; } } } for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 1 ; j <= K ; j ++ ) { result [ i ] [ j ] = temp [ i ] [ j ] ; } } } static void matrix_pow ( int K , int n ) { for ( int i = 1 ; i <= K ; i ++ ) { for ( int j = 1 ; j <= K ; j ++ ) { if ( i == j ) result [ i ] [ j ] = 1 ; } } while ( n > 0 ) { if ( n % 2 == 1 ) mul_1 ( K ) ; mul_2 ( K ) ; n /= 2 ; } } static int NthTerm ( int F [ ] , int C [ ] , int K , int n ) { for ( int i = 1 ; i <= K ; i ++ ) T [ i ] [ K ] = C [ K - i ] ; for ( int i = 1 ; i <= K ; i ++ ) T [ i + 1 ] [ i ] = 1 ; matrix_pow ( K , n ) ; int answer = 0 ; for ( int i = 1 ; i <= K ; i ++ ) { answer += F [ i - 1 ] * result [ i ] [ 1 ] ; } System . out . print ( answer + "NEW_LINE"); return 0 ; } public static void main ( String [ ] args ) { int F [ ] = { 1 , 2 , 3 } ; int C [ ] = { 1 , 1 , 1 } ; int K = 3 ; int N = 10 ; NthTerm ( F , C , K , N ) ; } }

Index/key variables: K, i, j, k
Accumulator variables: answer, i, j, k, n
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
class GFG { static double nthRoot ( int A , int N ) { double xPre = ( Math . random ( ) * 10 ) % 10 ; double eps = 1e-3 ; double delX = Integer . MAX_VALUE ; double xK = 0 ; while ( delX > eps ) { xK = ( ( N - 1.0 ) * xPre + ( double ) A / Math . pow ( xPre , N - 1 ) ) / ( double ) N ; delX = Math . abs ( xK - xPre ) ; xPre = xK ; } return xK ; } static float RMNValue ( int arr [ ] , int n , int k ) { int Nth = 0 ; float mean = 0 , root = 0 ; for ( int i = 0 ; i < n ; i ++ ) { Nth += Math . pow ( arr [ i ] , k ) ; } mean = ( Nth / ( float ) ( n ) ) ; root = ( float ) nthRoot ( ( int ) mean , k ) ; return root ; } public static void main ( String [ ] args ) { int arr [ ] = { 10 , 4 , 6 , 8 } ; int N = arr . length ; int K = 3 ; System . out . print ( RMNValue ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: Nth, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Stack ; class GFG { static Stack < Integer > addStack ( Stack < Integer > N1 , Stack < Integer > N2 ) { Stack < Integer > res = new Stack < Integer > ( ) ; int sum = 0 , rem = 0 ; while ( ! N1 . isEmpty ( ) && ! N2 . isEmpty ( ) ) { sum = ( rem + N1 . peek ( ) + N2 . peek ( ) ) ; res . add ( sum % 10 ) ; rem = sum / 10 ; N1 . pop ( ) ; N2 . pop ( ) ; } while ( ! N1 . isEmpty ( ) ) { sum = ( rem + N1 . peek ( ) ) ; res . add ( sum % 10 ) ; rem = sum / 10 ; N1 . pop ( ) ; } while ( ! N2 . isEmpty ( ) ) { sum = ( rem + N2 . peek ( ) ) ; res . add ( sum % 10 ) ; rem = sum / 10 ; N2 . pop ( ) ; } while ( rem > 0 ) { res . add ( rem ) ; rem /= 10 ; } while ( ! res . isEmpty ( ) ) { N1 . add ( res . peek ( ) ) ; res . pop ( ) ; } res = N1 ; return res ; } static void display ( Stack < Integer > res ) { int N = res . size ( ) ; String s = " " ; while ( ! res . isEmpty ( ) ) { s = String . valueOf ( res . peek ( ) ) + s ; res . pop ( ) ; } System . out . print ( s + "NEW_LINE"); } public static void main ( String [ ] args ) { Stack < Integer > N1 = new Stack < Integer > ( ) ; N1 . add ( 5 ) ; N1 . add ( 8 ) ; N1 . add ( 7 ) ; N1 . add ( 4 ) ; Stack < Integer > N2 = new Stack < Integer > ( ) ; N2 . add ( 2 ) ; N2 . add ( 1 ) ; N2 . add ( 3 ) ; Stack < Integer > res = addStack ( N1 , N2 ) ; display ( res ) ; } }

Accumulator variables: rem
Class/struct names: GFG
Java program:
class GFG { static boolean isPerfectSquare ( double x ) { double sr = Math . sqrt ( x ) ; return ( ( sr - Math . floor ( sr ) ) == 0 ) ; } static void checkFactors ( int x ) { if ( isPerfectSquare ( x ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } public static void main ( String [ ] args ) { int N = 36 ; checkFactors ( N ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int total_xor ; static void initialize_xor ( int arr [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { total_xor = total_xor ^ arr [ i ] ; } } static void find_xor ( int X , int Y ) { total_xor = total_xor ^ X ; total_xor = total_xor ^ Y ; System . out . print ( total_xor + "NEW_LINE"); } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 7 , 8 , 9 } ; int n = arr . length ; initialize_xor ( arr , n ) ; int [ ] [ ] Q = { { 5 , 6 } , { 8 , 1 } } ; for ( int i = 0 ; i < Q . length ; i ++ ) { find_xor ( Q [ i ] [ 0 ] , Q [ i ] [ 1 ] ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int isUgly ( int n ) { if ( n == 1 ) return 1 ; if ( n <= 0 ) return 0 ; if ( n % 2 == 0 ) { return ( isUgly ( n / 2 ) ) ; } if ( n % 3 == 0 ) { return ( isUgly ( n / 3 ) ) ; } if ( n % 5 == 0 ) { return ( isUgly ( n / 5 ) ) ; } return 0 ; } public static void main ( String args [ ] ) { int no = isUgly ( 14 ) ; if ( no == 1 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int maxGCD ( int N ) { for ( int i = 2 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) { return N / i ; } } return 1 ; } public static void main ( String [ ] args ) { int N = 33 ; System . out . println ( " Maximum ▁ Possible ▁ GCD ▁ " + " value ▁ is ▁ : ▁ " + maxGCD ( N ) ) ; } }

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