dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static int Find ( int [ ] parent , int a ) { return parent [ a ] = ( parent [ a ] == a ) ? a : ( Find ( parent , parent [ a ] ) ) ; } static void Union ( int [ ] parent , int [ ] rank , int [ ] maxValue , int a , int b ) { a = Find ( parent , a ) ; b = Find ( parent , b ) ; if ( a == b ) return ; if ( rank [ a ] == rank [ b ] ) { rank [ a ] ++ ; } if ( rank [ a ] < rank [ b ] ) { int temp = a ; a = b ; b = temp ; } parent [ b ] = a ; maxValue [ a ] = Math . max ( maxValue [ a ] , maxValue [ b ] ) ; } static void findMaxValueOfSet ( int [ ] [ ] arr , int [ ] queries , int R , int N , int M ) { int [ ] parent = new int [ R + 1 ] ; int [ ] rank = new int [ R + 1 ] ; int [ ] maxValue = new int [ R + 1 ] ; for ( int i = 1 ; i < R + 1 ; i ++ ) { parent [ i ] = maxValue [ i ] = i ; } for ( int i = 0 ; i < N ; i ++ ) { Union ( parent , rank , maxValue , arr [ i ] [ 0 ] , arr [ i ] [ 1 ] ) ; } for ( int i = 0 ; i < M ; i ++ ) { int P = Find ( parent , queries [ i ] ) ; System . out . print ( maxValue [ P ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int R = 5 ; int [ ] [ ] arr = { { 1 , 2 } , { 2 , 3 } , { 4 , 5 } } ; int [ ] queries = { 2 , 4 , 1 , 3 } ; int N = arr . length ; int M = queries . length ; findMaxValueOfSet ( arr , queries , R , N , M ) ; } }

Index/key variables: P, a, b, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxAns = Integer . MIN_VALUE ; static int Find ( int [ ] parent , int a ) { return parent [ a ] = ( parent [ a ] == a ) ? a : ( Find ( parent , parent [ a ] ) ) ; } static void Union ( int [ ] parent , int [ ] rank , int [ ] setSum , int a , int b ) { a = Find ( parent , a ) ; b = Find ( parent , b ) ; if ( a == b ) return ; if ( rank [ a ] > rank [ b ] ) rank [ a ] ++ ; if ( rank [ b ] > rank [ a ] ) { int x = a ; a = b ; b = x ; } parent [ b ] = a ; setSum [ a ] += setSum [ b ] ; } static void maxValues ( int [ ] arr , int [ ] queries , int N ) { int [ ] parent = new int [ N + 1 ] ; int [ ] rank = new int [ N + 1 ] ; int [ ] setSum = new int [ N + 1 ] ; Vector < Integer > currMax = new Vector < Integer > ( ) ; for ( int i = 1 ; i < N + 1 ; i ++ ) { parent [ i ] = - 1 ; setSum [ i ] = arr [ i - 1 ] ; } currMax . add ( 0 ) ; for ( int i = N - 1 ; i > 0 ; i -- ) { if ( parent [ queries [ i ] ] == - 1 ) { parent [ queries [ i ] ] = queries [ i ] ; } if ( queries [ i ] - 1 >= 0 && parent [ queries [ i ] - 1 ] != - 1 ) { Union ( parent , rank , setSum , queries [ i ] , queries [ i ] - 1 ) ; } if ( queries [ i ] + 1 <= N && parent [ queries [ i ] + 1 ] != - 1 ) { Union ( parent , rank , setSum , queries [ i ] , queries [ i ] + 1 ) ; } maxAns = Math . max ( setSum [ queries [ i ] ] , maxAns ) ; currMax . add ( maxAns ) ; } for ( int i = currMax . size ( ) - 1 ; i >= 0 ; i -- ) { System . out . print ( currMax . get ( i ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 2 , 5 } ; int [ ] queries = { 3 , 4 , 1 , 2 } ; int N = arr . length ; maxValues ( arr , queries , N ) ; } }

Index/key variables: a, b, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class Main { static class Node { public int val ; public Vector < Node > child ; public Node ( int key ) { val = key ; child = new Vector < Node > ( ) ; } } static Node newNode ( int key ) { Node temp = new Node ( key ) ; return temp ; } static void zigzagLevelOrder ( Node root ) { if ( root == null ) return ; Vector < Vector < Integer > > result = new Vector < Vector < Integer > > ( ) ; Vector < Node > q = new Vector < Node > ( ) ; q . add ( root ) ; while ( q . size ( ) > 0 ) { int size = q . size ( ) ; Vector < Integer > curLevel = new Vector < Integer > ( ) ; for ( int i = 0 ; i < size ; i ++ ) { Node node = q . get ( 0 ) ; q . remove ( 0 ) ; curLevel . add ( node . val ) ; for ( int j = 0 ; j < ( node . child ) . size ( ) ; j ++ ) q . add ( node . child . get ( j ) ) ; } result . add ( curLevel ) ; } for ( int i = 0 ; i < result . size ( ) ; i ++ ) { if ( ( i + 1 ) % 2 == 0 ) { Collections . reverse ( result . get ( i ) ) ; } for ( int j = 0 ; j < result . get ( i ) . size ( ) ; j ++ ) System . out . print ( result . get ( i ) . get ( j ) + " ▁ " ) ; System . out . println ( ) ; } } public static void main ( String [ ] args ) { Node root = newNode ( 1 ) ; ( root . child ) . add ( newNode ( 2 ) ) ; ( root . child ) . add ( newNode ( 3 ) ) ; ( root . child . get ( 0 ) . child ) . add ( newNode ( 4 ) ) ; ( root . child . get ( 0 ) . child ) . add ( newNode ( 5 ) ) ; ( root . child . get ( 1 ) . child ) . add ( newNode ( 6 ) ) ; ( root . child . get ( 1 ) ) . child . add ( newNode ( 7 ) ) ; ( root . child . get ( 1 ) . child ) . add ( newNode ( 8 ) ) ; zigzagLevelOrder ( root ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Main, Node
Java program:
import java . util . * ; class GFG { static int canPossibleReplacement ( int N , int [ ] arr ) { int S = 0 ; int i ; for ( i = 0 ; i < arr . length ; i ++ ) S += arr [ i ] ; int P = 1 ; for ( i = 0 ; i < arr . length ; i ++ ) { P *= i ; } for ( int x : arr ) { int y = ( S - x ) / ( P / x - 1 ) ; if ( ( S - x + y ) == ( P * y ) / x ) return 1 ; } return 0 ; } public static void main ( String [ ] args ) { int N = 3 ; int arr [ ] = { 1 , 3 , 4 } ; if ( canPossibleReplacement ( N , arr ) == 1 ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Index/key variables: i
Accumulator variables: P, S, i
Iterator variables: i, x
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static String checkSameDigits ( int N ) { int length = ( ( int ) Math . log10 ( N ) ) + 1 ; int M = ( ( int ) Math . pow ( 10 , length ) - 1 ) / ( 10 - 1 ) ; M *= N % 10 ; if ( M == N ) return " Yes " ; return " No " ; } public static void main ( String args [ ] ) throws IOException { int N = 222 ; System . out . println ( checkSameDigits ( N ) ) ; } }

Accumulator variables: M
Class/struct names: GFG
Java program:
import java . util . * ; public class Main { static int maxSumPath = 0 ; static class Node { public int val ; public Vector < Node > child ; public Node ( int key ) { val = key ; child = new Vector < Node > ( ) ; } } static Node newNode ( int key ) { Node temp = new Node ( key ) ; return temp ; } static void DFS ( Node root , int sum ) { if ( root . child . size ( ) == 0 ) { maxSumPath = Math . max ( maxSumPath , sum ) ; return ; } for ( int i = 0 ; i < root . child . size ( ) ; i ++ ) { DFS ( root . child . get ( i ) , sum + root . child . get ( i ) . val ) ; } } public static void main ( String [ ] args ) { Node root = newNode ( 1 ) ; ( root . child ) . add ( newNode ( 2 ) ) ; ( root . child ) . add ( newNode ( 3 ) ) ; ( root . child . get ( 0 ) . child ) . add ( newNode ( 4 ) ) ; ( root . child . get ( 1 ) . child ) . add ( newNode ( 6 ) ) ; ( root . child . get ( 0 ) . child ) . add ( newNode ( 5 ) ) ; ( root . child . get ( 1 ) ) . child . add ( newNode ( 7 ) ) ; ( root . child . get ( 1 ) . child ) . add ( newNode ( 8 ) ) ; DFS ( root , root . val ) ; System . out . print ( maxSumPath ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: Main, Node
Java program:
import java . io . * ; class GFG { static void countTriplets ( int size , int queries , int [ ] arr , int [ ] [ ] Q ) { int [ ] arr_even = new int [ size + 1 ] ; int [ ] arr_odd = new int [ size + 1 ] ; int even = 0 ; int odd = 0 ; arr_even [ 0 ] = 0 ; arr_odd [ 0 ] = 0 ; for ( int i = 0 ; i < size ; i ++ ) { if ( arr [ i ] % 2 == 1 ) { odd ++ ; } else { even ++ ; } arr_even [ i + 1 ] = even ; arr_odd [ i + 1 ] = odd ; } for ( int i = 0 ; i < queries ; i ++ ) { int l = Q [ i ] [ 0 ] , r = Q [ i ] [ 1 ] ; odd = arr_odd [ r ] - arr_odd [ l - 1 ] ; even = arr_even [ r ] - arr_even [ l - 1 ] ; int ans = ( even * ( even - 1 ) * ( even - 2 ) ) / 6 + ( odd * ( odd - 1 ) / 2 ) * even ; System . out . print ( ans + " ▁ " ) ; } } public static void main ( String [ ] args ) { int N = 6 , Q = 2 ; int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; int [ ] [ ] queries = { { 1 , 3 } , { 2 , 5 } } ; countTriplets ( N , Q , arr , queries ) ; } }

Index/key variables: i, r
Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int maxRightmostElement ( int N , int k , int p , int arr [ ] ) { while ( k > 0 ) { for ( int i = N - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] >= p ) { arr [ i ] = arr [ i ] - p ; arr [ i + 1 ] = arr [ i + 1 ] + p ; break ; } } k -- ; } return arr [ N - 1 ] ; } public static void main ( String [ ] args ) { int N = 4 , k = 5 , p = 2 ; int arr [ ] = { 3 , 8 , 1 , 4 } ; System . out . println ( maxRightmostElement ( N , k , p , arr ) ) ; } }

Index/key variables: i
Accumulator variables: i, k
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int nCr ( int n , int r , int f [ ] ) { if ( n < r ) { return 0 ; } return f [ n ] / ( f [ r ] * f [ n - r ] ) ; } static int findMean ( int N , int X ) { int [ ] f = new int [ N + 1 ] ; f [ 0 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { f [ i ] = f [ i - 1 ] * i ; } int total = nCr ( N , X , f ) ; int count = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { count += nCr ( N - i , X - 1 , f ) * i ; } double E_X = ( double ) ( count ) / ( double ) ( total ) ; System . out . print ( String . format ( " % .6f " , E_X ) ) ; return 0 ; } public static void main ( String [ ] args ) { int N = 3 , X = 2 ; findMean ( N , X ) ; } }

Index/key variables: i, n, r
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int maximumNumberofpairs ( int n , int arr [ ] ) { int x = 0 ; int y = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) { x ++ ; } else { y ++ ; } } int answer = Math . min ( x , y ) ; if ( Math . abs ( x - y ) >= 2 ) { answer ++ ; } return answer ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 4 , 6 , 5 , 10 , 12 } ; int n = arr . length ; System . out . println ( maximumNumberofpairs ( n , arr ) ) ; } }

Index/key variables: i
Accumulator variables: answer, i, x, y
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void pairwiseProductSum ( int a [ ] , int l , int r ) { int sum = 0 ; for ( int j = l - 1 ; j <= r - 1 ; j ++ ) { for ( int k = j + 1 ; k <= r - 1 ; k ++ ) { sum += ( a [ j ] * a [ k ] ) ; } } System . out . print ( sum + "NEW_LINE"); } static void updateArray ( int [ ] a , int p , int x ) { a [ p - 1 ] = x ; } static void solveQueries ( int [ ] a , int n , int Q , int query [ ] [ ] ) { for ( int i = 0 ; i < Q ; i ++ ) { if ( query [ i ] [ 0 ] == 1 ) pairwiseProductSum ( a , query [ i ] [ 1 ] , query [ i ] [ 2 ] ) ; else updateArray ( a , query [ i ] [ 1 ] , query [ i ] [ 2 ] ) ; } } public static void main ( String [ ] args ) { int A [ ] = { 5 , 7 , 2 , 3 , 1 } ; int N = A . length ; int Q = 3 ; int query [ ] [ ] = { { 1 , 1 , 3 } , { 2 , 2 , 5 } , { 1 , 2 , 5 } } ; solveQueries ( A , N , Q , query ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k, sum
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MaxBit = 32 ; static void possiblePair ( int X , int Y ) { int Z = Y - X ; if ( Z < 0 ) { System . out . print ( " - 1" ) ; } for ( int k = 0 ; k < MaxBit ; k ++ ) { int bit1 = ( Z >> k ) & 1 ; int bit2 = ( Z >> k ) & 1 ; if ( bit1 != 0 && bit2 == 0 ) { System . out . print ( " - 1" ) ; } } System . out . print ( Z + " ▁ " + X ) ; } public static void main ( String [ ] args ) { int X = 7 , Y = 11 ; possiblePair ( X , Y ) ; } }

Accumulator variables: k
Iterator variables: k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void maxFrequencySubarrayUtil ( int [ ] A , int N , int M ) { int i = 0 ; HashMap < Integer , Integer > m = new HashMap < Integer , Integer > ( ) ; int val = 0 ; for ( ; i < M ; i ++ ) { if ( m . containsKey ( A [ i ] ) ) { m . put ( A [ i ] , m . get ( A [ i ] ) + 1 ) ; } else { m . put ( A [ i ] , 1 ) ; } val = Math . max ( val , m . get ( A [ i ] ) ) ; } System . out . print ( val + " ▁ " ) ; for ( i = M ; i < N ; i ++ ) { if ( m . containsKey ( i - M ) ) { m . put ( i - M , m . get ( i - M ) - 1 ) ; } if ( m . containsKey ( A [ i ] ) ) { m . put ( A [ i ] , m . get ( A [ i ] ) + 1 ) ; } else { m . put ( A [ i ] , 1 ) ; } val = 0 ; for ( Map . Entry < Integer , Integer > x : m . entrySet ( ) ) { val = Math . max ( val , x . getValue ( ) ) ; } System . out . print ( val + " ▁ " ) ; } } public static void main ( String [ ] args ) { int [ ] A = { 1 , 1 , 2 , 2 , 3 , 5 } ; int N = A . length ; int M = 4 ; maxFrequencySubarrayUtil ( A , N , M ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static int maximumPairs ( int [ ] a , int n ) { HashMap < Integer , Integer > freq = new HashMap < Integer , Integer > ( ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int c = a [ i ] ; if ( freq . containsKey ( c ) ) { freq . put ( c , freq . get ( c ) + 1 ) ; } else { freq . put ( c , 1 ) ; } } PriorityQueue < Integer > pq = new PriorityQueue < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq . containsKey ( a [ i ] ) ) { pq . add ( freq . get ( a [ i ] ) ) ; freq . remove ( a [ i ] ) ; } } while ( pq . size ( ) > 1 ) { int freq1 = pq . poll ( ) ; int freq2 = pq . poll ( ) ; count ++ ; freq1 -- ; freq2 -- ; if ( freq1 > 0 ) pq . add ( freq1 ) ; if ( freq2 > 0 ) pq . add ( freq2 ) ; } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 2 , 4 , 1 , 4 , 3 } ; int N = 6 ; System . out . println ( maximumPairs ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: count, freq1, freq2, i
Iterator variables: i
Class/struct names: GFG
Java program:
public class Main { static class Node { public int data ; public Node left , right ; public Node ( int val ) { data = val ; left = right = null ; } } static Node getNewNode ( int val ) { Node newNode = new Node ( val ) ; return newNode ; } static Node buildPerfectBT_helper ( int preStart , int preEnd , int [ ] pre ) { if ( preStart > preEnd ) return null ; Node root = getNewNode ( pre [ preStart ] ) ; if ( preStart == preEnd ) return root ; int leftPreStart = preStart + 1 ; int rightPreStart = leftPreStart + ( preEnd - leftPreStart + 1 ) / 2 ; int leftPreEnd = rightPreStart - 1 ; int rightPreEnd = preEnd ; root . left = buildPerfectBT_helper ( leftPreStart , leftPreEnd , pre ) ; root . right = buildPerfectBT_helper ( rightPreStart , rightPreEnd , pre ) ; return root ; } static Node buildPerfectBT ( int [ ] pre , int size ) { return buildPerfectBT_helper ( 0 , size - 1 , pre ) ; } static void printInorder ( Node root ) { if ( root == null ) return ; printInorder ( root . left ) ; System . out . print ( root . data + " ▁ " ) ; printInorder ( root . right ) ; } public static void main ( String [ ] args ) { int [ ] pre = { 1 , 2 , 4 , 5 , 3 , 6 , 7 } ; int N = pre . length ; Node root = buildPerfectBT ( pre , N ) ; System . out . print ( " Inorder ▁ traversal ▁ of ▁ the ▁ tree : ▁ " ) ; printInorder ( root ) ; } }

Index/key variables: preStart
Class/struct names: Main, Node
Java program:
import java . util . * ; public class Main { static int N = 3 ; static Vector < Vector < Integer > > adj = new Vector < Vector < Integer > > ( ) ; static Vector < Boolean > visited ; static int ans ; static void addEdges ( int u , int v ) { adj . get ( u ) . add ( v ) ; adj . get ( v ) . add ( u ) ; } static void DFSUtil ( int u , boolean foo , boolean foo1 , boolean [ ] initial , boolean [ ] finall ) { visited . set ( u , true ) ; if ( ( initial [ u - 1 ] ^ foo ) ^ finall [ u - 1 ] == true ) { ans += 1 ; foo ^= true ; } for ( int i = 0 ; i < adj . get ( u ) . size ( ) ; i ++ ) { if ( visited . get ( adj . get ( u ) . get ( i ) ) == false ) DFSUtil ( adj . get ( u ) . get ( i ) , foo1 , foo , initial , finall ) ; } } static void DFS ( int V , boolean [ ] initial , boolean [ ] finall ) { ans = 0 ; visited = new Vector < Boolean > ( ) ; for ( int i = 0 ; i < V ; i ++ ) { visited . add ( false ) ; } for ( int u = 1 ; u <= 1 ; u ++ ) { if ( visited . get ( u ) == false ) DFSUtil ( u , false , false , initial , finall ) ; } System . out . print ( ans ) ; } static void countOperations ( int N , boolean [ ] initial , boolean [ ] finall , int [ ] [ ] Edges ) { for ( int i = 0 ; i < N - 1 ; i ++ ) { addEdges ( Edges [ i ] [ 0 ] , Edges [ i ] [ 1 ] ) ; } DFS ( N + 1 , initial , finall ) ; } public static void main ( String [ ] args ) { for ( int i = 0 ; i < N + 1 ; i ++ ) { adj . add ( new Vector < Integer > ( ) ) ; } int [ ] [ ] Edges = { { 1 , 2 } , { 1 , 3 } } ; boolean [ ] initial = { true , true , false } ; boolean [ ] finall = { false , true , true } ; countOperations ( N , initial , finall , Edges ) ; } }

Index/key variables: i
Accumulator variables: ans, foo, i, u
Iterator variables: i, u
Class/struct names: Main
Java program:
import java . util . * ; class GFG { static class pair < T , V > { T first ; V second ; } static pair < Integer , Integer > make_pair ( int f , int s ) { pair < Integer , Integer > p = new pair < > ( ) ; p . first = f ; p . second = s ; return p ; } static int countOperations ( int N , int M ) { boolean [ ] visited = new boolean [ 100001 ] ; Arrays . fill ( visited , false ) ; Queue < pair < Integer , Integer > > Q = new LinkedList < > ( ) ; Q . add ( make_pair ( N , 0 ) ) ; visited [ N ] = true ; while ( ! Q . isEmpty ( ) ) { int aux = Q . peek ( ) . first ; int cont = Q . peek ( ) . second ; Q . remove ( ) ; if ( aux == M ) return cont ; for ( int i = 2 ; i * i <= aux ; i ++ ) if ( aux % i == 0 ) { if ( aux + i <= M && ! visited [ aux + i ] ) { Q . add ( make_pair ( aux + i , cont + 1 ) ) ; visited [ aux + i ] = true ; } if ( aux + aux / i <= M && ! visited [ aux + aux / i ] ) { Q . add ( make_pair ( aux + aux / i , cont + 1 ) ) ; visited [ aux + aux / i ] = true ; } } } return - 1 ; } public static void main ( String [ ] args ) { int N = 4 , M = 24 ; System . out . println ( countOperations ( N , M ) ) ; } }

Index/key variables: N
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, pair
Java program:
import java . util . * ; public class GFG { static Vector < Vector < Integer > > adj ; static boolean [ ] visited ; static int num ; static void dfs ( int v ) { visited [ v ] = true ; num ++ ; for ( int i = 0 ; i < adj . get ( v ) . size ( ) ; i ++ ) { if ( ! visited [ adj . get ( v ) . get ( i ) ] ) { dfs ( adj . get ( v ) . get ( i ) ) ; } } } static void numberOfPairs ( int N , int [ ] [ ] arr ) { adj = new Vector < Vector < Integer > > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { adj . add ( new Vector < Integer > ( ) ) ; } for ( int i = 0 ; i < 2 ; i ++ ) { adj . get ( arr [ i ] [ 0 ] ) . add ( arr [ i ] [ 1 ] ) ; adj . get ( arr [ i ] [ 1 ] ) . add ( arr [ i ] [ 0 ] ) ; } visited = new boolean [ N ] ; Arrays . fill ( visited , false ) ; Vector < Integer > v = new Vector < Integer > ( ) ; num = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( ! visited [ i ] ) { dfs ( i ) ; v . add ( num ) ; num = 0 ; } } int ans = N * ( N - 1 ) / 2 + 1 ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { ans -= ( v . get ( i ) * ( v . get ( i ) - 1 ) / 2 ) + 1 ; } System . out . print ( ans ) ; } public static void main ( String [ ] args ) { int N = 6 ; int [ ] [ ] arr = { { 0 , 1 } , { 0 , 2 } , { 2 , 5 } } ; numberOfPairs ( N , arr ) ; } }

Index/key variables: N, i, v
Accumulator variables: ans, i, num
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; public class MyClass { static int MAX = 100005 ; static int isPerfect ( long N ) { long sum = 1 ; for ( long i = 2 ; i * i <= N ; i ++ ) { if ( N % i == 0 ) { if ( i * i != N ) sum = sum + i + N / i ; else sum = sum + i ; } } if ( sum == N && N != 1 ) return 1 ; return 0 ; } static void Query ( int arr [ ] [ ] , int N ) { int [ ] prefix = new int [ MAX + 1 ] ; Arrays . fill ( prefix , 0 ) ; for ( int i = 2 ; i <= MAX ; i ++ ) { prefix [ i ] = prefix [ i - 1 ] + isPerfect ( i ) ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( prefix [ arr [ i ] [ 1 ] ] - prefix [ arr [ i ] [ 0 ] - 1 ] + " ▁ " ) ; } } public static void main ( String args [ ] ) { int [ ] [ ] arr = { { 1 , 1000 } , { 1000 , 2000 } , { 2000 , 3000 } } ; int N = arr . length ; Query ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: MyClass
Java program:
import java . io . * ; class GFG { static int minSteps ( int N ) { int ans = 0 ; for ( int d = 2 ; d * d <= N ; d ++ ) { while ( N % d == 0 ) { ans += d ; N /= d ; } } if ( N != 1 ) { ans += N ; } return ans ; } public static void main ( String [ ] args ) { int N = 3 ; minSteps ( N ) ; System . out . println ( minSteps ( N ) ) ; } }

Accumulator variables: N, ans, d
Iterator variables: d
Class/struct names: GFG
Java program:
import java . awt . * ; import java . util . * ; class GFG { static class pair < T , V > { T first ; V second ; } static void Create_Rectangle ( ArrayList < String > arr , int n ) { pair < Integer , Integer > p1 = new pair < > ( ) ; p1 . first = - 1 ; p1 . second = - 1 ; pair < Integer , Integer > p2 = new pair < > ( ) ; p2 . first = - 1 ; p2 . second = - 1 ; pair < Integer , Integer > p3 = new pair < > ( ) ; pair < Integer , Integer > p4 = new pair < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( arr . get ( i ) . charAt ( j ) == '1' ) if ( p1 . first == - 1 ) { p1 . first = i ; p1 . second = j ; } else { p2 . first = i ; p2 . second = j ; } } } p3 = p1 ; p4 = p2 ; if ( p1 . first . intValue ( ) == ( p2 . first ) . intValue ( ) ) { p3 . first = ( p1 . first + 1 ) % n ; p4 . first = ( p2 . first + 1 ) % n ; } else if ( p1 . second . intValue ( ) == ( p2 . second ) . intValue ( ) ) { p3 . second = ( p1 . second + 1 ) % n ; p4 . second = ( p2 . second + 1 ) % n ; } else { int temp = p3 . first ; p3 . first = p4 . first ; p4 . first = temp ; } for ( int i = 0 ; i < n ; i ++ ) { if ( i == p3 . first ) { for ( int j = 0 ; j < n ; j ++ ) { if ( j == p3 . second ) System . out . print ( '1' ) ; else System . out . print ( arr . get ( i ) . charAt ( j ) ) ; } } else if ( i == p4 . first ) { for ( int j = 0 ; j < n ; j ++ ) { if ( j == p4 . second ) System . out . print ( '1' ) ; else System . out . print ( arr . get ( i ) . charAt ( j ) ) ; } } else System . out . print ( arr . get ( i ) ) ; System . out . println ( ) ; } } public static void main ( String [ ] args ) { int n = 4 ; ArrayList < String > arr = new ArrayList < > ( ) ; arr . add ( "0010" ) ; arr . add ( "0000" ) ; arr . add ( "1000" ) ; arr . add ( "0000" ) ; Create_Rectangle ( arr , n ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, pair
Java program:
import java . io . * ; class GFG { public static int SumOfPrimeDivisors ( int n ) { int sum = 0 ; if ( n % 2 == 0 ) { sum = sum + 2 ; } while ( n % 2 == 0 ) { n = n / 2 ; } for ( int i = 3 ; i <= Math . sqrt ( n ) ; i = i + 2 ) { if ( n % i == 0 ) { sum = sum + i ; } while ( n % i == 0 ) { n = n / i ; } } if ( n > 2 ) { sum = sum + n ; } return sum ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . println ( SumOfPrimeDivisors ( n ) ) ; } }

Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int countOfBase ( int N ) { int count = 0 ; for ( int i = 2 ; i <= N ; ++ i ) { int highestPower = ( int ) ( Math . log ( N ) / Math . log ( i ) ) ; int firstDigit = N / ( int ) Math . pow ( i , highestPower ) ; if ( firstDigit == 1 ) { ++ count ; } } return count ; } public static void main ( String [ ] args ) { int N = 6 ; System . out . println ( countOfBase ( N ) ) ; } }

Iterator variables: i
Class/struct names: GFG