dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static void minOperations ( String N ) { int even = 0 ; int odd = 0 ; for ( int it : N . toCharArray ( ) ) { if ( ( it - '0' ) % 2 == 0 ) { even ++ ; } else { odd ++ ; } } if ( odd == 0 odd == 1 ) { System . out . print ( " Not ▁ Possible " + "NEW_LINE"); } else { int ans = 0 ; for ( int it : N . toCharArray ( ) ) { if ( ( it - '0' ) % 2 == 0 ) { ans ++ ; } else { ans = 0 ; } } if ( odd % 2 != 0 ) { ans ++ ; } System . out . print ( ans + "NEW_LINE"); } } public static void main ( String [ ] args ) { String N = "12345" ; minOperations ( N ) ; } }

Accumulator variables: ans, even, odd
Iterator variables: it
Class/struct names: GFG
Java program:
class GFG { public static void FindwinnerOfGame ( String S ) { int cntZero = 0 ; int cntConOne = 0 ; int nimSum = 0 ; int N = S . length ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( S . charAt ( i ) == '1' ) { cntConOne += 1 ; } else { nimSum ^= cntConOne ; cntConOne = 0 ; cntZero ++ ; } } nimSum ^= cntConOne ; if ( cntZero % 2 == 0 ) { System . out . print ( " Tie " ) ; } else if ( nimSum != 0 ) { System . out . print ( " player ▁ 1" ) ; } else { System . out . print ( " player ▁ 2" ) ; } } public static void main ( String [ ] args ) { String S = "0110011" ; FindwinnerOfGame ( S ) ; } }

Accumulator variables: cntConOne, cntZero, i, nimSum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void generatepermutation ( int N ) { Vector < Integer > answer = new Vector < Integer > ( ) ; answer . add ( N ) ; for ( int i = 1 ; i < N ; i ++ ) { answer . add ( i ) ; } for ( int i : answer ) System . out . print ( i + " ▁ " ) ; } public static void main ( String [ ] args ) { int N = 4 ; generatepermutation ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void maxValueAtIndexK ( int N , int K , int M ) { int S1 = 0 , S2 = 0 ; S1 = K * ( K + 1 ) / 2 ; S2 = ( N - K - 1 ) * ( N - K ) / 2 ; int X = ( M + S1 + S2 ) / N ; System . out . println ( X ) ; } public static void main ( String [ ] args ) { int N = 3 , K = 1 , M = 7 ; maxValueAtIndexK ( N , K , M ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void farthestCellDistance ( int N , int M , int R , int C ) { int d1 = N + M - R - C ; int d2 = R + C - 2 ; int d3 = N - R + C - 1 ; int d4 = M - C + R - 1 ; int maxDistance = Math . max ( d1 , Math . max ( d2 , Math . max ( d3 , d4 ) ) ) ; System . out . println ( maxDistance ) ; } public static void main ( String [ ] args ) { int N = 15 , M = 12 , R = 1 , C = 6 ; farthestCellDistance ( N , M , R , C ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void maxSum ( int [ ] arr , int N ) { int ans = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { int t = i ; if ( t + arr [ i ] < N ) { arr [ i ] += arr [ t + arr [ i ] ] ; } } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( arr [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 7 , 1 , 8 } ; int N = arr . length ; maxSum ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int findInGrid ( int i , int j ) { if ( i == j ) return ( i * i - ( i - 1 ) ) ; else if ( i > j ) { if ( i % 2 == 0 ) return i * i - ( j - 1 ) ; else return ( i - 1 ) * ( i - 1 ) + 1 + ( j - 1 ) ; } else { if ( j % 2 == 0 ) return ( j - 1 ) * ( j - 1 ) + 1 + ( i - 1 ) ; else return j * j - ( i - 1 ) ; } } public static void main ( String [ ] args ) { int i = 3 , j = 4 ; System . out . println ( findInGrid ( i , j ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void minOpsToTurnArrToZero ( int [ ] arr , int N ) { Set < Integer > st = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( st . contains ( arr [ i ] ) arr [ i ] == 0 ) { continue ; } else { st . add ( arr [ i ] ) ; } } System . out . println ( st . size ( ) ) ; } public static void main ( String args [ ] ) { int arr [ ] = { 3 , 7 , 3 } ; int N = arr . length ; minOpsToTurnArrToZero ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } void splitArray ( int arr [ ] , int N ) { TreeMap < Integer , Integer > mp = new TreeMap < 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 G = 0 ; for ( Map . Entry < Integer , Integer > m : mp . entrySet ( ) ) { Integer i = m . getValue ( ) ; G = gcd ( G , i . intValue ( ) ) ; } if ( G > 1 ) System . out . print ( " YES " ) ; else System . out . print ( " NO " ) ; } public static void main ( String [ ] args ) { int [ ] arr = new int [ ] { 1 , 2 , 3 , 4 , 4 , 3 , 2 , 1 } ; int n = arr . length ; new GFG ( ) . splitArray ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static boolean CheckAllEqual ( int arr [ ] , int N ) { for ( int i = 1 ; i < N ; i ++ ) { if ( arr [ 0 ] != arr [ i ] ) { return false ; } } return true ; } static int minCntOperations ( int arr [ ] , int N ) { int Max = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) ; boolean isPower2 ; if ( ( int ) ( Math . ceil ( ( Math . log ( N ) / Math . log ( N ) ) ) ) == ( int ) ( Math . floor ( ( ( Math . log ( N ) / Math . log ( 2 ) ) ) ) ) ) { isPower2 = true ; } else { isPower2 = false ; } if ( isPower2 && CheckAllEqual ( arr , N ) ) { return ( int ) ( Math . log ( Max ) / Math . log ( 2 ) ) ; } else { return ( int ) Math . ceil ( Math . log ( Max ) / Math . log ( 2 ) ) + 1 ; } } public static void main ( String [ ] args ) { int [ ] arr = new int [ ] { 2 , 4 } ; int N = arr . length ; System . out . println ( minCntOperations ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: isPower2
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . Arrays ; class GFG { static String greatestReducedNumber ( String num , String s ) { Boolean [ ] vis_s = new Boolean [ 10 ] ; Arrays . fill ( vis_s , Boolean . FALSE ) ; for ( int i = 0 ; i < ( int ) s . length ( ) ; i ++ ) { vis_s [ ( int ) ( s . charAt ( i ) ) - 48 ] = true ; } int n = num . length ( ) ; int in = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( vis_s [ ( int ) num . charAt ( i ) - '0' ] ) { in = i ; break ; } } if ( in == - 1 ) { return num ; } for ( char dig = num . charAt ( in ) ; dig >= '0' ; dig -- ) { if ( vis_s [ ( int ) dig - '0' ] == false ) { num = num . substring ( 0 , in ) + dig + num . substring ( in + 1 , n ) ; break ; } } char LargestDig = '0' ; for ( char dig = '9' ; dig >= '0' ; dig -- ) { if ( vis_s [ dig - '0' ] == false ) { LargestDig = dig ; break ; } } for ( int i = in + 1 ; i < n ; i ++ ) { num = num . substring ( 0 , i ) + LargestDig ; } int Count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( num . charAt ( i ) == '0' ) Count ++ ; else break ; } num = num . substring ( Count , n ) ; if ( ( int ) num . length ( ) == 0 ) return "0" ; return num ; } public static void main ( String [ ] args ) { String N = "12345" ; String S = "23" ; System . out . print ( greatestReducedNumber ( N , S ) ) ; } }

Accumulator variables: Count, dig, i
Iterator variables: dig, i
Class/struct names: GFG
Java program:
class GFG { private static void minXOR ( int Arr [ ] , int N ) { for ( int i = 0 ; i < N ; i ++ ) { if ( Arr [ i ] == 2 ) { System . out . print ( ( Arr [ i ] ^ 3 ) + " ▁ " ) ; } else { System . out . print ( ( Arr [ i ] ^ 2 ) + " ▁ " ) ; } } } public static void main ( String [ ] args ) { int Arr [ ] = { 5 , 4 , 7 , 6 } ; int N = Arr . length ; minXOR ( Arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; import java . util . Arrays ; class GFG { static int [ ] findArray ( int n ) { int Arr [ ] = new int [ n + 1 ] ; Arr [ 0 ] = 0 ; Arr [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) { Arr [ i ] = Arr [ i / 2 ] ; } else { Arr [ i ] = Arr [ ( i - 1 ) / 2 ] + Arr [ ( i - 1 ) / 2 + 1 ] ; } } return Arr ; } static int maxElement ( int n ) { if ( n == 0 ) return 0 ; if ( n == 1 ) return 1 ; int [ ] Arr = findArray ( n ) ; int ans = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . max ( ans , Arr [ i ] ) ; } return ans ; } public static void main ( String args [ ] ) { int N = 7 ; System . out . println ( maxElement ( N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
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 void constGraphWithCon ( int N , int K ) { int Max = ( ( N - 1 ) * ( N - 2 ) ) / 2 ; if ( K > Max ) { System . out . print ( - 1 + "NEW_LINE"); return ; } Vector < pair > ans = new Vector < > ( ) ; for ( int i = 1 ; i < N ; i ++ ) { for ( int j = i + 1 ; j <= N ; j ++ ) { ans . add ( new pair ( i , j ) ) ; } } for ( int i = 0 ; i < ( N - 1 ) + Max - K ; i ++ ) { System . out . print ( ans . get ( i ) . first + " ▁ " + ans . get ( i ) . second + "NEW_LINE"); } } public static void main ( String [ ] args ) { int N = 5 , K = 3 ; constGraphWithCon ( N , K ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, pair
Java program:
import java . util . * ; class GFG { static int min_steps_required ( int n , int m , int r , int c ) { int i , j ; int corner_steps_req = Integer . MAX_VALUE ; i = 1 ; j = 1 ; corner_steps_req = Math . min ( corner_steps_req , Math . abs ( r - i ) + Math . abs ( j - c ) ) ; i = n ; j = 1 ; corner_steps_req = Math . min ( corner_steps_req , Math . abs ( r - i ) + Math . abs ( j - c ) ) ; i = 1 ; j = m ; corner_steps_req = Math . min ( corner_steps_req , Math . abs ( r - i ) + Math . abs ( j - c ) ) ; i = n ; j = m ; corner_steps_req = Math . min ( corner_steps_req , Math . abs ( r - i ) + Math . abs ( j - c ) ) ; int minimum_steps = Math . min ( 2 * ( n - 1 ) + m - 1 , 2 * ( m - 1 ) + n - 1 ) ; return minimum_steps + corner_steps_req ; } public static void main ( String [ ] args ) { int n = 3 ; int m = 2 ; int r = 1 ; int c = 1 ; System . out . print ( min_steps_required ( n , m , r , c ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int min_elements ( int arr [ ] , int N , int K ) { 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 ) ; } } Vector < Integer > Freq = new Vector < Integer > ( ) ; for ( Map . Entry < Integer , Integer > it : mp . entrySet ( ) ) { int i = it . getKey ( ) ; Freq . add ( mp . get ( i ) ) ; } Collections . sort ( Freq , Collections . reverseOrder ( ) ) ; int len = Freq . size ( ) ; if ( len <= K ) { return 0 ; } int cntMin = 0 ; for ( int i = K ; i < len ; i ++ ) { cntMin += Freq . get ( i ) ; } return cntMin ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 1 , 3 , 2 , 4 , 1 , 1 , 2 , 3 , 4 } ; int N = arr . length ; int K = 3 ; System . out . print ( min_elements ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: cntMin, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int sumzero ( int arr [ ] , int N , int K ) { int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; } if ( sum == 0 ) System . out . print ( " Yes " ) ; else if ( sum > 0 ) { if ( sum % K == 0 ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } else System . out . print ( " No " ) ; return 0 ; } public static void main ( String [ ] args ) { int K , N ; int arr1 [ ] = { 1 , - 6 , 2 , 2 } ; K = 1 ; N = arr1 . length ; sumzero ( arr1 , N , K ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int cntOnesArrWithGivenOp ( int arr [ ] , int N ) { int cntOnes = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = i - 1 ; j < N ; j += i ) { arr [ j ] = arr [ j ] == 0 ? 1 : 0 ; } } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) { cntOnes += 1 ; } } return cntOnes ; } public static void main ( String [ ] args ) { int arr [ ] = { 0 , 0 , 0 , 0 , 0 } ; int N = arr . length ; System . out . print ( cntOnesArrWithGivenOp ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: cntOnes, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int cntOnesArrWithGivenOp ( int arr [ ] , int N ) { int cntOnes = 0 ; cntOnes = ( int ) Math . sqrt ( N ) ; return cntOnes ; } public static void main ( String [ ] args ) { int arr [ ] = { 0 , 0 , 0 , 0 , 0 } ; int N = arr . length ; System . out . println ( cntOnesArrWithGivenOp ( arr , N ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . Math ; class GFG { static int cntKnightsAttackPawn ( int knights [ ] [ ] , int pawn [ ] , int M ) { int cntKnights = 0 ; for ( int i = 0 ; i < M ; i ++ ) { int X = Math . abs ( knights [ i ] [ 0 ] - pawn [ 0 ] ) ; int Y = Math . abs ( knights [ i ] [ 1 ] - pawn [ 1 ] ) ; if ( ( X == 1 && Y == 2 ) || ( X == 2 && Y == 1 ) ) { cntKnights ++ ; } } return cntKnights ; } public static void main ( String [ ] args ) { int [ ] [ ] knights = { { 0 , 4 } , { 4 , 5 } , { 1 , 4 } , { 3 , 1 } } ; int [ ] pawn = new int [ ] { 2 , 3 } ; int M = knights . length ; System . out . println ( cntKnightsAttackPawn ( knights , pawn , M ) ) ; } }

Index/key variables: i
Accumulator variables: cntKnights, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findWinnerGameRemoveGCD ( int arr [ ] , int n ) { HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 2 ; j * j <= arr [ i ] ; j ++ ) { if ( arr [ i ] % j == 0 ) { if ( mp . containsKey ( j ) ) { mp . put ( j , mp . get ( j ) + 1 ) ; } else { mp . put ( j , 1 ) ; } while ( arr [ i ] % j == 0 ) { arr [ i ] = arr [ i ] / j ; } } } if ( arr [ i ] > 1 ) { if ( mp . containsKey ( arr [ i ] ) ) { mp . put ( arr [ i ] , mp . get ( arr [ i ] ) + 1 ) ; } else { mp . put ( arr [ i ] , 1 ) ; } } } int maxCnt = 0 ; for ( Map . Entry < Integer , Integer > i : mp . entrySet ( ) ) { maxCnt = Math . max ( maxCnt , i . getValue ( ) ) ; } if ( n % 2 == 0 ) { if ( maxCnt >= n - 1 ) { System . out . print ( " Player ▁ 1" ) ; } else { System . out . print ( " Player ▁ 2" ) ; } } else { if ( maxCnt == n ) { System . out . print ( " Player ▁ 1" ) ; } else { System . out . print ( " Player ▁ 2" ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , 8 } ; int N = arr . length ; findWinnerGameRemoveGCD ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void maxksum ( int L , int R , int K ) { int N = ( R / 10 - L / 10 ) + 1 ; if ( K > N ) { System . out . print ( " - 1" ) ; return ; } R = R / 10 ; int X = R - K ; int sum = 10 * ( ( R * ( R + 1 ) ) / 2 - ( X * ( X + 1 ) ) / 2 ) ; System . out . print ( sum ) ; } public static void main ( String [ ] args ) { int L = 16 , R = 60 , K = 4 ; maxksum ( L , R , K ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void minimumSwaps ( int arr1 [ ] , int arr2 [ ] , int n ) { int sumArr1 = 0 , sumArr2 = 0 ; for ( int i = 0 ; i < n ; ++ i ) { sumArr1 += arr1 [ i ] ; sumArr2 += arr2 [ i ] ; } if ( sumArr1 % 2 == 0 && sumArr2 % 2 == 0 ) { System . out . print ( 0 ) ; return ; } if ( sumArr1 % 2 != 0 && sumArr2 % 2 != 0 ) { int flag = - 1 ; for ( int i = 0 ; i < n ; ++ i ) { if ( ( arr1 [ i ] + arr2 [ i ] ) % 2 == 1 ) { flag = 1 ; break ; } } System . out . print ( flag ) ; return ; } System . out . print ( - 1 ) ; } public static void main ( String [ ] args ) { int arr1 [ ] = { 11 , 14 , 20 , 2 } ; int arr2 [ ] = { 5 , 9 , 6 , 3 } ; int N = arr1 . length ; minimumSwaps ( arr1 , arr2 , N ) ; } }

Index/key variables: i
Accumulator variables: sumArr1, sumArr2
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void corpFlightBookings ( int [ ] [ ] Bookings , int N ) { int res [ ] = new int [ N ] ; for ( int i = 0 ; i < Bookings . length ; i ++ ) { int l = Bookings [ i ] [ 0 ] ; int r = Bookings [ i ] [ 1 ] ; int K = Bookings [ i ] [ 2 ] ; res [ l - 1 ] = res [ l - 1 ] + K ; if ( r <= res . length - 1 ) res [ r ] = ( - K ) + res [ r ] ; } for ( int i = 1 ; i < res . length ; i ++ ) res [ i ] = res [ i ] + res [ i - 1 ] ; for ( int i = 0 ; i < res . length ; i ++ ) { System . out . print ( res [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int bookings [ ] [ ] = { { 1 , 3 , 100 } , { 2 , 6 , 100 } , { 3 , 4 , 100 } } ; int N = 6 ; corpFlightBookings ( bookings , N ) ; } }

Index/key variables: N, i, r
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findXOR ( int n ) { switch ( n & 3 ) { case 0 : return n ; case 1 : return 1 ; case 2 : return n + 1 ; } return 0 ; } static void findOddXOR ( int n ) { if ( n % 2 == 0 ) System . out . print ( ( ( findXOR ( n ) ) ^ ( 2 * findXOR ( n / 2 ) ) ) ) ; else System . out . print ( ( ( findXOR ( n ) ) ^ ( 2 * findXOR ( ( n - 1 ) / 2 ) ) ) ) ; } public static void main ( String [ ] args ) { int N = 11 ; findOddXOR ( N ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findSmallestNumber ( int n ) { for ( int i = n ; i <= ( n + 2520 ) ; ++ i ) { int possible = 1 ; int temp = i ; while ( temp != 0 ) { if ( temp % 10 != 0 ) { int digit = temp % 10 ; if ( i % digit != 0 ) { possible = 0 ; break ; } } temp /= 10 ; } if ( possible == 1 ) { System . out . println ( i ) ; return ; } } } public static void main ( String [ ] args ) { int N = 31 ; findSmallestNumber ( N ) ; } }

Accumulator variables: temp
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void path_to_root ( int node ) { while ( node >= 1 ) { System . out . print ( node + " ▁ " ) ; node /= 2 ; } } public static void main ( String [ ] args ) { int N = 7 ; path_to_root ( N ) ; } }

Accumulator variables: node
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void findSmallestNumberPossible ( int N , int K ) { if ( N > 45 * K ) { System . out . print ( " - 1" ) ; return ; } StringBuilder res = new StringBuilder ( ) ; int count = 0 ; for ( int i = 9 ; i >= 1 { if ( count == K ) { i -- ; count = 0 ; } if ( N > i ) { N -= i ; res . append ( ( char ) ( '0' + i ) ) ; } else { res . append ( ( char ) ( '0' + N ) ) ; N = 0 ; break ; } count ++ ; } res . reverse ( ) ; System . out . print ( res . toString ( ) ) ; } public static void main ( String [ ] args ) { int N = 25 , K = 3 ; findSmallestNumberPossible ( N , K ) ; } }

Accumulator variables: N, count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static int minValue ( int [ ] arr , int n ) { Arrays . sort ( arr ) ; int minimum = arr [ 0 ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum = sum + ( arr [ i ] - minimum ) ; } return sum ; } static public void main ( String args [ ] ) { int [ ] arr = { 1 , 2 , 3 } ; int N = arr . length ; System . out . println ( minValue ( 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 result ( int n ) { if ( n > 45 ) { System . out . print ( - 1 ) ; return ; } String res = " " ; int digit = 9 ; while ( n > digit ) { res = ( char ) ( '0' + digit ) + res ; n -= digit ; digit -= 1 ; } if ( n > 0 ) { res = ( char ) ( '0' + n ) + res ; } System . out . print ( res ) ; } public static void main ( String [ ] args ) { int N = 19 ; result ( N ) ; } }

Accumulator variables: digit, n
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { public static int countEvenPairs ( int N , int M ) { int count = 0 ; int nEven = ( int ) Math . floor ( ( double ) N / 2 ) ; int nOdd = ( int ) Math . ceil ( ( double ) N / 2 ) ; int mEven = ( int ) Math . floor ( ( double ) M / 2 ) ; int mOdd = ( int ) Math . ceil ( ( double ) M / 2 ) ; count = nEven * mEven + nOdd * mOdd ; return count ; } public static void main ( String [ ] args ) { int N = 4 ; int M = 6 ; System . out . print ( countEvenPairs ( N , M ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static char lastRemovedCharacter ( char [ ] str ) { int n = str . length ; if ( n == 1 ) return str [ 0 ] ; if ( str [ n - 2 ] == '0' ) { return ( char ) ( '1' - str [ n - 1 ] + '0' ) ; } else return str [ n - 1 ] ; } public static void main ( String [ ] args ) { String str = "10010" ; System . out . print ( lastRemovedCharacter ( str . toCharArray ( ) ) ) ; } }

Class/struct names: GFG
Java program:
class GFG { static void findNumbers ( int aXORb , int aANDb , int aXORc , int aANDc , int bXORc , int bANDc ) { int a , b , c ; int aSUMb ; int aSUMc ; int bSUMc ; aSUMb = aXORb + aANDb * 2 ; aSUMc = aXORc + aANDc * 2 ; bSUMc = bXORc + bANDc * 2 ; a = ( aSUMb - bSUMc + aSUMc ) / 2 ; b = aSUMb - a ; c = aSUMc - a ; System . out . print ( " a ▁ = ▁ " + a ) ; System . out . print ( " , ▁ b ▁ = ▁ " + b ) ; System . out . print ( " , ▁ c ▁ = ▁ " + c ) ; } public static void main ( String [ ] args ) { int aXORb = 30 , aANDb = 0 , aXORc = 20 , aANDc = 10 , bXORc = 10 , bANDc = 20 ; findNumbers ( aXORb , aANDb , aXORc , aANDc , bXORc , bANDc ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findArray ( int N , int K ) { if ( N == 1 ) { System . out . print ( K + " ▁ " ) ; return ; } if ( N == 2 ) { System . out . print ( 0 + " ▁ " + K ) ; return ; } int P = N - 2 ; int Q = N - 1 ; int VAL = 0 ; for ( int i = 1 ; i <= ( N - 3 ) ; i ++ ) { System . out . print ( i + " ▁ " ) ; VAL ^= i ; } if ( VAL == K ) { System . out . print ( P + " ▁ " + Q + " ▁ " + ( P ^ Q ) ) ; } else { System . out . print ( 0 + " ▁ " + P + " ▁ " + ( P ^ K ^ VAL ) ) ; } } public static void main ( String [ ] args ) { int N = 4 , X = 6 ; findArray ( N , X ) ; } }

Accumulator variables: VAL, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int findNumber ( int N ) { int count = 0 ; while ( ( N & 1 ) == 1 ) { N = N >> 1 ; count ++ ; } return N << count ; } public static void main ( String [ ] args ) { int N = 39 ; System . out . println ( findNumber ( N ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int findNumber ( int N ) { return N & ( N + 1 ) ; } public static void main ( String [ ] args ) { int N = 39 ; System . out . print ( findNumber ( N ) ) ; } }

Class/struct names: GFG