dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static int reversDigits ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } static boolean isPerfectSquare ( double x ) { double sr = Math . sqrt ( x ) ; return ( ( sr - Math . floor ( sr ) ) == 0 ) ; } static boolean isRare ( int N ) { int reverseN = reversDigits ( N ) ; if ( reverseN == N ) return false ; return isPerfectSquare ( N + reverseN ) && isPerfectSquare ( N - reverseN ) ; } public static void main ( String [ ] args ) { int n = 65 ; if ( isRare ( n ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void calc_ans ( int l , int r ) { Vector < Integer > power2 = new Vector < Integer > ( ) , power3 = new Vector < Integer > ( ) ; int mul2 = 1 ; while ( mul2 <= r ) { power2 . add ( mul2 ) ; mul2 *= 2 ; } int mul3 = 1 ; while ( mul3 <= r ) { power3 . add ( mul3 ) ; mul3 *= 3 ; } Vector < Integer > power23 = new Vector < Integer > ( ) ; for ( int x = 0 ; x < power2 . size ( ) ; x ++ ) { for ( int y = 0 ; y < power3 . size ( ) ; y ++ ) { int mul = power2 . get ( x ) * power3 . get ( y ) ; if ( mul == 1 ) continue ; if ( mul <= r ) power23 . add ( mul ) ; } } int ans = 0 ; for ( int x : power23 ) { if ( x >= l && x <= r ) ans ++ ; } System . out . print ( ans + "NEW_LINE"); } public static void main ( String [ ] args ) { int l = 1 , r = 10 ; calc_ans ( l , r ) ; } }

Accumulator variables: ans, mul2, mul3, x, y
Iterator variables: x, y
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int nCr ( int n , int r ) { if ( r > n ) return 0 ; return fact ( n ) / ( fact ( r ) * fact ( n - r ) ) ; } static int fact ( int n ) { int res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res = res * i ; return res ; } static int countSubsequences ( int arr [ ] , int n , int k ) { int countOdd = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 1 ) countOdd ++ ; } int ans = nCr ( n , k ) - nCr ( countOdd , k ) ; return ans ; } public static void main ( String args [ ] ) { int arr [ ] = { 2 , 4 } ; int K = 1 ; int N = arr . length ; System . out . println ( countSubsequences ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: countOdd, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void first_digit ( int x , int y ) { int length = ( int ) ( Math . log ( x ) / Math . log ( y ) + 1 ) ; int first_digit = ( int ) ( x / Math . pow ( y , length - 1 ) ) ; System . out . println ( first_digit ) ; } public static void main ( String args [ ] ) { int X = 55 , Y = 3 ; first_digit ( X , Y ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void checkIfCurzonNumber ( long N ) { double powerTerm , productTerm ; powerTerm = Math . pow ( 2 , N ) + 1 ; productTerm = 2 * N + 1 ; if ( powerTerm % productTerm == 0 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } public static void main ( String [ ] args ) { long N = 5 ; checkIfCurzonNumber ( N ) ; N = 10 ; checkIfCurzonNumber ( N ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int minCount ( int n ) { int [ ] hasharr = { 10 , 3 , 6 , 9 , 2 , 5 , 8 , 1 , 4 , 7 } ; if ( n > 69 ) return hasharr [ n % 10 ] ; else { if ( n >= hasharr [ n % 10 ] * 7 ) return ( hasharr [ n % 10 ] ) ; else return - 1 ; } } public static void main ( String [ ] args ) { int n = 38 ; System . out . println ( minCount ( n ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void modifiedBinaryPattern ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { if ( j == 1 j == i ) System . out . print ( 1 ) ; else System . out . print ( 0 ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int n = 7 ; modifiedBinaryPattern ( n ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void findRealAndImag ( String s ) { int l = s . length ( ) ; int i ; if ( s . indexOf ( ' + ' ) != - 1 ) { i = s . indexOf ( ' + ' ) ; } else { i = s . indexOf ( ' - ' ) ; } String real = s . substring ( 0 , i ) ; String imaginary = s . substring ( i + 1 , l - 1 ) ; System . out . println ( " Real ▁ part : ▁ " + real ) ; System . out . println ( " Imaginary ▁ part : ▁ " + imaginary ) ; } public static void main ( String [ ] args ) { String s = "3 + 4i " ; findRealAndImag ( s ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int highestPower ( int n , int k ) { int i = 0 ; int a = ( int ) Math . pow ( n , i ) ; while ( a <= k ) { i += 1 ; a = ( int ) Math . pow ( n , i ) ; } return i - 1 ; } static int b [ ] = new int [ 50 ] ; static int PowerArray ( int n , int k ) { while ( k > 0 ) { int t = highestPower ( n , k ) ; if ( b [ t ] > 0 ) { System . out . print ( - 1 ) ; return 0 ; } else b [ t ] = 1 ; k -= Math . pow ( n , t ) ; } for ( int i = 0 ; i < 50 ; i ++ ) { if ( b [ i ] > 0 ) { System . out . print ( i + " , ▁ " ) ; } } return 0 ; } public static void main ( String [ ] args ) { int N = 3 ; int K = 40 ; PowerArray ( N , K ) ; } }

Index/key variables: i, t
Accumulator variables: i, k
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static final int N = 10005 ; static void SieveOfEratosthenes ( Vector < Boolean > composite ) { for ( int i = 0 ; i < N ; i ++ ) { composite . add ( i , false ) ; } for ( int p = 2 ; p * p < N ; p ++ ) { if ( ! composite . get ( p ) ) { for ( int i = p * 2 ; i < N ; i += p ) { composite . add ( i , true ) ; } } } } static int sumOfElements ( int arr [ ] , int n ) { Vector < Boolean > composite = new Vector < Boolean > ( ) ; for ( int i = 0 ; i < N ; i ++ ) composite . add ( false ) ; SieveOfEratosthenes ( composite ) ; HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) if ( mp . containsKey ( arr [ i ] ) ) { mp . put ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } else { mp . put ( arr [ i ] , 1 ) ; } int sum = 0 ; for ( Map . Entry < Integer , Integer > it : mp . entrySet ( ) ) { if ( composite . get ( it . getValue ( ) ) ) { sum += ( it . getKey ( ) ) ; } } return sum ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 1 , 1 , 1 , 3 , 3 , 2 , 4 } ; int n = arr . length ; System . out . print ( sumOfElements ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, p, sum
Iterator variables: i, p
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void remove ( int arr [ ] , int n ) { HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . containsKey ( arr [ i ] ) ) { mp . put ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } else { mp . put ( arr [ i ] , 1 ) ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( ( mp . containsKey ( arr [ i ] ) && mp . get ( arr [ i ] ) % 2 == 1 ) ) continue ; System . out . print ( arr [ i ] + " , ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 3 , 3 , 2 , 2 , 4 , 7 , 7 } ; int n = arr . length ; remove ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void getmax ( int arr [ ] , int n , int x ) { int s = 0 ; for ( int i = 0 ; i < n ; i ++ ) { s = s + arr [ i ] ; } System . out . print ( Math . min ( s , x ) ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int x = 5 ; int arr_size = arr . length ; getmax ( arr , arr_size , x ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void shortestLength ( int n , int x [ ] , int y [ ] ) { int answer = 0 ; int i = 0 ; while ( n != 0 && i < x . length ) { if ( x [ i ] + y [ i ] > answer ) answer = x [ i ] + y [ i ] ; i ++ ; } System . out . println ( " Length ▁ - > ▁ " + answer ) ; System . out . println ( " Path ▁ - > ▁ " + " ( ▁ 1 , ▁ " + answer + " ▁ ) " + " and ▁ ( ▁ " + answer + " , ▁ 1 ▁ ) " ) ; } public static void main ( String [ ] args ) { int n = 4 ; int x [ ] = new int [ ] { 1 , 4 , 2 , 1 } ; int y [ ] = new int [ ] { 4 , 1 , 1 , 2 } ; shortestLength ( n , x , y ) ; } }

Index/key variables: i
Accumulator variables: i
Class/struct names: GFG
Java program:
class GFG { static void FindPoints ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 , int x4 , int y4 ) { int x5 = Math . max ( x1 , x3 ) ; int y5 = Math . max ( y1 , y3 ) ; int x6 = Math . min ( x2 , x4 ) ; int y6 = Math . min ( y2 , y4 ) ; if ( x5 > x6 y5 > y6 ) { System . out . println ( " No ▁ intersection " ) ; return ; } System . out . print ( " ( " + x5 + " , ▁ " + y5 + " ) ▁ " ) ; System . out . print ( " ( " + x6 + " , ▁ " + y6 + " ) ▁ " ) ; int x7 = x5 ; int y7 = y6 ; System . out . print ( " ( " + x7 + " , ▁ " + y7 + " ) ▁ " ) ; int x8 = x6 ; int y8 = y5 ; System . out . print ( " ( " + x8 + " , ▁ " + y8 + " ) ▁ " ) ; } public static void main ( String args [ ] ) { int x1 = 0 , y1 = 0 , x2 = 10 , y2 = 8 ; int x3 = 2 , y3 = 3 , x4 = 7 , y4 = 9 ; FindPoints ( x1 , y1 , x2 , y2 , x3 , y3 , x4 , y4 ) ; } }

Class/struct names: GFG
Java program:
class GFG { static class Point { float x , y ; Point ( ) { x = y = 0 ; } Point ( float a , float b ) { x = a ; y = b ; } } ; static void printCorners ( Point p , Point q , float l ) { Point a = new Point ( ) , b = new Point ( ) , c = new Point ( ) , d = new Point ( ) ; if ( p . x == q . x ) { a . x = ( float ) ( p . x - ( l / 2.0 ) ) ; a . y = p . y ; d . x = ( float ) ( p . x + ( l / 2.0 ) ) ; d . y = p . y ; b . x = ( float ) ( q . x - ( l / 2.0 ) ) ; b . y = q . y ; c . x = ( float ) ( q . x + ( l / 2.0 ) ) ; c . y = q . y ; } else if ( p . y == q . y ) { a . y = ( float ) ( p . y - ( l / 2.0 ) ) ; a . x = p . x ; d . y = ( float ) ( p . y + ( l / 2.0 ) ) ; d . x = p . x ; b . y = ( float ) ( q . y - ( l / 2.0 ) ) ; b . x = q . x ; c . y = ( float ) ( q . y + ( l / 2.0 ) ) ; c . x = q . x ; } else { float m = ( p . x - q . x ) / ( q . y - p . y ) ; float dx = ( float ) ( ( l / Math . sqrt ( 1 + ( m * m ) ) ) * 0.5 ) ; float dy = m * dx ; a . x = p . x - dx ; a . y = p . y - dy ; d . x = p . x + dx ; d . y = p . y + dy ; b . x = q . x - dx ; b . y = q . y - dy ; c . x = q . x + dx ; c . y = q . y + dy ; } System . out . print ( ( int ) a . x + " , ▁ " + ( int ) a . y + " NEW_LINE" + ( int ) b . x + " , ▁ " + ( int ) b . y + "NEW_LINE" + ( int ) c . x + " , ▁ " + ( int ) c . y + " NEW_LINE" + ( int ) d . x + " , ▁ " + ( int ) d . y + "NEW_LINE"); } public static void main ( String [ ] args ) { Point p1 = new Point ( 1 , 0 ) , q1 = new Point ( 1 , 2 ) ; printCorners ( p1 , q1 , 2 ) ; Point p = new Point ( 1 , 1 ) , q = new Point ( - 1 , - 1 ) ; printCorners ( p , q , ( float ) ( 2 * Math . sqrt ( 2 ) ) ) ; } }

Class/struct names: GFG, Point
Java program:
class GFG { public static int minimumCost ( int arr [ ] , int N , int X , int Y ) { int even_count = 0 , odd_count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ( arr [ i ] & 1 ) > 0 && ( i % 2 == 0 ) ) { odd_count ++ ; } if ( ( arr [ i ] % 2 ) == 0 && ( i & 1 ) > 0 ) { even_count ++ ; } } int cost1 = X * Math . min ( odd_count , even_count ) ; int cost2 = Y * ( Math . max ( odd_count , even_count ) - Math . min ( odd_count , even_count ) ) ; int cost3 = ( odd_count + even_count ) * Y ; return Math . min ( cost1 + cost2 , cost3 ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 5 , 3 , 7 , 2 , 1 } , X = 10 , Y = 2 ; int N = arr . length ; System . out . println ( minimumCost ( arr , N , X , Y ) ) ; } }

Index/key variables: i
Accumulator variables: even_count, i, odd_count
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int findMinMax ( int [ ] a ) { int min_val = 1000000000 ; for ( int i = 1 ; i < a . length ; ++ i ) { min_val = Math . min ( min_val , a [ i ] * a [ i - 1 ] ) ; } return min_val ; } public static void main ( String [ ] args ) { int [ ] arr = { 6 , 4 , 5 , 6 , 2 , 4 , 1 } ; System . out . println ( findMinMax ( arr ) ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class GFG { static int sum ; static class TreeNode { int data ; TreeNode left ; TreeNode right ; TreeNode ( int data ) { this . data = data ; this . left = null ; this . right = null ; } } ; static void kDistanceDownSum ( TreeNode root , int k ) { if ( root == null k < 0 ) return ; if ( k == 0 ) { sum += root . data ; return ; } kDistanceDownSum ( root . left , k - 1 ) ; kDistanceDownSum ( root . right , k - 1 ) ; } static int kDistanceSum ( TreeNode root , int target , int k ) { if ( root == null ) return - 1 ; if ( root . data == target ) { kDistanceDownSum ( root . left , k - 1 ) ; return 0 ; } int dl = - 1 ; if ( target < root . data ) { dl = kDistanceSum ( root . left , target , k ) ; } if ( dl != - 1 ) { if ( dl + 1 == k ) sum += root . data ; return - 1 ; } int dr = - 1 ; if ( target > root . data ) { dr = kDistanceSum ( root . right , target , k ) ; } if ( dr != - 1 ) { if ( dr + 1 == k ) sum += root . data ; else kDistanceDownSum ( root . left , k - dr - 2 ) ; return 1 + dr ; } return - 1 ; } static TreeNode insertNode ( int data , TreeNode root ) { if ( root == null ) { TreeNode node = new TreeNode ( data ) ; return node ; } else if ( data > root . data ) { root . right = insertNode ( data , root . right ) ; } else if ( data <= root . data ) { root . left = insertNode ( data , root . left ) ; } return root ; } static void findSum ( TreeNode root , int target , int K ) { sum = 0 ; kDistanceSum ( root , target , K ) ; System . out . print ( sum ) ; } public static void main ( String [ ] args ) { TreeNode root = null ; int N = 11 ; int tree [ ] = { 3 , 1 , 7 , 0 , 2 , 5 , 10 , 4 , 6 , 9 , 8 } ; for ( int i = 0 ; i < N ; i ++ ) { root = insertNode ( tree [ i ] , root ) ; } int target = 7 ; int K = 2 ; findSum ( root , target , K ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG, TreeNode
Java program:
import java . io . * ; class GFG { static int itemType ( int n ) { int count = 0 ; for ( int day = 1 ; ; day ++ ) { for ( int type = day ; type > 0 ; type -- ) { count += type ; if ( count >= n ) return type ; } } } public static void main ( String [ ] args ) { int N = 10 ; System . out . println ( itemType ( N ) ) ; } }

Accumulator variables: count, day, type
Iterator variables: day, type
Class/struct names: GFG
Java program:
class GFG { static int FindSum ( int [ ] arr , int N ) { int res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int power = ( int ) ( Math . log ( arr [ i ] ) / Math . log ( 2 ) ) ; int LesserValue = ( int ) Math . pow ( 2 , power ) ; int LargerValue = ( int ) Math . pow ( 2 , power + 1 ) ; if ( ( arr [ i ] - LesserValue ) == ( LargerValue - arr [ i ] ) ) { res += arr [ i ] ; } } return res ; } public static void main ( String [ ] args ) { int [ ] arr = { 10 , 24 , 17 , 3 , 8 } ; int N = arr . length ; System . out . println ( FindSum ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static void findLast ( int mat [ ] [ ] ) { int m = 3 ; int n = 3 ; Set < Integer > rows = new HashSet < Integer > ( ) ; Set < Integer > cols = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ( mat [ i ] [ j ] > 0 ) ) { rows . add ( i ) ; cols . add ( j ) ; } } } int avRows = m - rows . size ( ) ; int avCols = n - cols . size ( ) ; int choices = Math . min ( avRows , avCols ) ; if ( ( choices & 1 ) != 0 ) System . out . println ( " P1" ) ; else System . out . println ( " P2" ) ; } public static void main ( String [ ] args ) { int mat [ ] [ ] = { { 1 , 0 , 0 } , { 0 , 0 , 0 } , { 0 , 0 , 1 } } ; findLast ( mat ) ; } }

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 . * ; class GFG { static final int MOD = 1000000007 ; static void sumOfBinaryNumbers ( int n ) { int ans = 0 ; int one = 1 ; while ( true ) { if ( n <= 1 ) { ans = ( ans + n ) % MOD ; break ; } int x = ( int ) ( Math . log ( n ) / Math . log ( 2 ) ) ; int cur = 0 ; int add = ( int ) ( Math . pow ( 2 , ( x - 1 ) ) ) ; for ( int i = 1 ; i <= x ; i ++ ) { cur = ( cur + add ) % MOD ; add = ( add * 10 % MOD ) ; } ans = ( ans + cur ) % MOD ; int rem = n - ( int ) ( Math . pow ( 2 , x ) ) + 1 ; int p = ( int ) Math . pow ( 10 , x ) ; p = ( p * ( rem % MOD ) ) % MOD ; ans = ( ans + p ) % MOD ; n = rem - 1 ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { int N = 3 ; sumOfBinaryNumbers ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void nearestFibonacci ( int num ) { if ( num == 0 ) { System . out . print ( 0 ) ; return ; } int first = 0 , second = 1 ; int third = first + second ; while ( third <= num ) { first = second ; second = third ; third = first + second ; } int ans = ( Math . abs ( third - num ) >= Math . abs ( second - num ) ) ? second : third ; System . out . print ( ans ) ; } public static void main ( String [ ] args ) { int N = 17 ; nearestFibonacci ( N ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static boolean checkPermutation ( int ans [ ] , int a [ ] , int n ) { int Max = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { Max = Math . max ( Max , ans [ i ] ) ; if ( Max != a [ i ] ) return false ; } return true ; } static void findPermutation ( int a [ ] , int n ) { int ans [ ] = new int [ n ] ; HashMap < Integer , Integer > um = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! um . containsKey ( a [ i ] ) ) { ans [ i ] = a [ i ] ; um . put ( a [ i ] , i ) ; } } ArrayList < Integer > v = new ArrayList < > ( ) ; int j = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ! um . containsKey ( i ) ) { v . add ( i ) ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( ans [ i ] == 0 ) { ans [ i ] = v . get ( j ) ; j ++ ; } } if ( checkPermutation ( ans , a , n ) ) { for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( ans [ i ] + " ▁ " ) ; } } else System . out . println ( " - 1" ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 3 , 4 , 5 , 5 } ; int N = arr . length ; findPermutation ( arr , N ) ; } }

Index/key variables: i, n
Accumulator variables: i, j
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . Map ; import java . util . HashMap ; class GFG { public static void countEqualElementPairs ( int arr [ ] , int N ) { HashMap < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { Integer k = map . get ( arr [ i ] ) ; map . put ( arr [ i ] , ( k == null ) ? 1 : k + 1 ) ; } int total = 0 ; for ( Map . Entry < Integer , Integer > e : map . entrySet ( ) ) { total += ( e . getValue ( ) * ( e . getValue ( ) - 1 ) ) / 2 ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( total - ( map . get ( arr [ i ] ) - 1 ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 2 , 1 , 2 } ; int N = 5 ; countEqualElementPairs ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, total
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static int count ( int N ) { int sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sum += 7 * Math . pow ( 8 , i - 1 ) ; } return sum ; } public static void main ( String [ ] args ) { int N = 4 ; System . out . println ( count ( N ) ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean isPalindrome ( int n ) { String str = String . valueOf ( n ) ; int s = 0 , e = str . length ( ) - 1 ; while ( s < e ) { if ( str . charAt ( s ) != str . charAt ( e ) ) { return false ; } s ++ ; e -- ; } return true ; } static void palindromicDivisors ( int n ) { Vector < Integer > PalindromDivisors = new Vector < Integer > ( ) ; for ( int i = 1 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) { if ( isPalindrome ( i ) ) { PalindromDivisors . add ( i ) ; } } else { if ( isPalindrome ( i ) ) { PalindromDivisors . add ( i ) ; } if ( isPalindrome ( n / i ) ) { PalindromDivisors . add ( n / i ) ; } } } } Collections . sort ( PalindromDivisors ) ; for ( int i = 0 ; i < PalindromDivisors . size ( ) ; i ++ ) { System . out . print ( PalindromDivisors . get ( i ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int n = 66 ; palindromicDivisors ( n ) ; } }

Accumulator variables: e, i, s
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int findMinDel ( int [ ] arr , int n ) { int min_num = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) min_num = Math . min ( arr [ i ] , min_num ) ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) if ( arr [ i ] == min_num ) cnt ++ ; return n - cnt ; } public static void main ( String [ ] args ) { int arr [ ] = { 3 , 3 , 2 } ; int n = arr . length ; System . out . print ( findMinDel ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int cntSubArr ( int [ ] arr , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int curr_gcd = 0 ; for ( int j = i ; j < n ; j ++ ) { curr_gcd = __gcd ( curr_gcd , arr [ j ] ) ; ans += ( curr_gcd == 1 ) ? 1 : 0 ; } } return ans ; } static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 1 } ; int n = arr . length ; System . out . println ( cntSubArr ( arr , n ) ) ; } }

Index/key variables: j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void print_primes_till_N ( int N ) { int i , j , flag ; System . out . println ( " Prime ▁ numbers ▁ between ▁ 1 ▁ and ▁ " + N + " ▁ are : " ) ; for ( i = 1 ; i <= N ; i ++ ) { if ( i == 1 i == 0 ) continue ; flag = 1 ; for ( j = 2 ; j <= i / 2 ; ++ j ) { if ( i % j == 0 ) { flag = 0 ; break ; } } if ( flag == 1 ) System . out . print ( i + " ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 100 ; print_primes_till_N ( N ) ; } }

Accumulator variables: i
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int MAX = 32 ; static int findX ( int A , int B ) { int X = 0 ; for ( int bit = 0 ; bit < MAX ; bit ++ ) { int tempBit = 1 << bit ; int bitOfX = A & B & tempBit ; X += bitOfX ; } return X ; } public static void main ( String [ ] args ) { int A = 11 , B = 13 ; System . out . println ( findX ( A , B ) ) ; } }

Accumulator variables: X, bit
Iterator variables: bit
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int cntSubSets ( int arr [ ] , int n ) { int maxVal = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == maxVal ) cnt ++ ; } return ( int ) ( Math . pow ( 2 , cnt ) - 1 ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 1 , 2 } ; int n = arr . length ; System . out . println ( cntSubSets ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG