dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { public static int good_pairs ( String [ ] str , int N ) { int arr [ ] = new int [ 32 ] ; int strCount = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int Weight = 0 ; for ( int j = 0 ; j < str [ i ] . length ( ) ; j ++ ) { switch ( str [ i ] . charAt ( j ) ) { case ' a ' : Weight = Weight | 1 ; break ; case ' e ' : Weight = Weight | 2 ; break ; case ' i ' : Weight = Weight | 4 ; break ; case ' o ' : Weight = Weight | 8 ; break ; case ' u ' : Weight = Weight | 16 ; break ; } } arr [ Weight ] ++ ; } for ( int i = 0 ; i < 32 ; i ++ ) { for ( int j = i + 1 ; j < 32 ; j ++ ) { if ( ( i j ) == 31 ) strCount += arr [ i ] * arr [ j ] ; } } strCount += ( arr [ 31 ] * ( arr [ 31 ] - 1 ) ) / 2 ; return strCount ; } public static void main ( String [ ] args ) { String str [ ] = { " aaweiolkju " , " oxdfgujkmi " } ; int N = str . length ; System . out . println ( good_pairs ( str , N ) ) ; } }

Index/key variables: Weight, i, j
Accumulator variables: i, j, strCount
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void solve ( List < Integer > arr , int r , int c ) { int idx = 1 ; int [ ] [ ] dp = new int [ r ] ; for ( int i = 0 ; i < r ; i ++ ) { if ( i % 2 == 0 ) { for ( int j = 0 ; j < c ; j ++ ) { if ( arr . get ( idx - 1 ) == 0 ) idx ++ ; dp [ i ] [ j ] = idx ; arr . set ( idx - 1 , arr . get ( idx - 1 ) - 1 ) ; } } else { for ( int j = c - 1 ; j >= 0 ; j -- ) { if ( arr . get ( idx - 1 ) == 0 ) idx ++ ; dp [ i ] [ j ] = idx ; arr . set ( idx - 1 , arr . get ( idx - 1 ) - 1 ) ; } } } for ( int i = 0 ; i < r ; ++ i ) { for ( int j = 0 ; j < c ; ++ j ) { System . out . print ( dp [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int r = 3 , c = 5 ; int n = 5 ; List < Integer > arr = Arrays . asList ( 1 , 2 , 3 , 4 , 5 ) ; solve ( arr , r , c ) ; } }

Index/key variables: i, j, r
Accumulator variables: i, idx, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . Scanner ; public class Check { public static int count ( int k , String s ) { int ar [ ] = new int [ s . length ( ) ] ; int end = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '1' ) { for ( int j = i ; j < s . length ( ) && j <= i + k ; j ++ ) { ar [ j ] = - 1 ; end = j ; } i = end ; } } end = 0 ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == '1' ) { for ( int j = i ; j >= 0 && j >= i - k ; j -- ) { ar [ j ] = - 1 ; end = j ; } i = end ; } } int ans = 0 ; end = 0 ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { if ( ar [ j ] == 0 ) { ans ++ ; for ( int g = j ; g <= j + k && g < s . length ( ) ; g ++ ) { ar [ g ] = - 1 ; end = g ; } j = end - 1 ; } } return ans ; } public static void main ( String [ ] args ) { int K = 2 ; String s = "000000" ; System . out . println ( count ( K , s ) ) ; } }

Index/key variables: g, j
Accumulator variables: ans, g, i, j
Iterator variables: g, i, j
Class/struct names: Check
Java program:
import java . util . * ; class GFG { static final int row = 6 ; static final int col = 7 ; static int [ ] [ ] vis = new int [ row + 1 ] [ col + 1 ] ; static int id ; static int diameter = 0 , length = 0 ; static int x = 0 , y = 0 ; static int dx [ ] = { - 1 , 1 , 0 , 0 } ; static int dy [ ] = { 0 , 0 , - 1 , 1 } ; static void dfs ( int a , int b , int lis [ ] [ ] ) { vis [ a ] [ b ] = id ; length ++ ; if ( length > diameter ) { x = a ; y = b ; diameter = length ; } for ( int j = 0 ; j < 4 ; j ++ ) { int cx = a + dx [ j ] ; int cy = b + dy [ j ] ; if ( cx < 0 cy < 0 cx >= row cy >= col lis [ cx ] [ cy ] == 0 vis [ cx ] [ cy ] > 0 ) { continue ; } dfs ( cx , cy , lis ) ; } vis [ a ] [ b ] = 0 ; length -- ; } static void findMaximumLength ( int lis [ ] [ ] ) { id ++ ; length = 0 ; diameter = 0 ; for ( int i = 0 ; i < row ; i ++ ) { for ( int j = 0 ; j < col ; j ++ ) { if ( lis [ i ] [ j ] != 0 ) { dfs ( i , j , lis ) ; i = row ; break ; } } } id ++ ; length = 0 ; diameter = 0 ; dfs ( x , y , lis ) ; System . out . print ( diameter ) ; } public static void main ( String [ ] args ) { int grid [ ] [ ] = { { 0 , 0 , 0 , 0 , 0 , 0 , 0 } , { 0 , 1 , 0 , 1 , 0 , 0 , 0 } , { 0 , 1 , 0 , 1 , 0 , 0 , 0 } , { 0 , 1 , 0 , 1 , 0 , 1 , 0 } , { 0 , 1 , 1 , 1 , 1 , 1 , 0 } , { 0 , 0 , 0 , 1 , 0 , 0 , 0 } } ; findMaximumLength ( grid ) ; } }

Index/key variables: a, b, cx, cy, i, j
Accumulator variables: i, id, j, length
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static String get_last_two_digit ( int N ) { if ( N % 4 == 0 ) return "01" ; else if ( N % 4 == 1 ) return "07" ; else if ( N % 4 == 2 ) return "49" ; return "43" ; } public static void main ( String [ ] args ) { int N = 12 ; System . out . println ( get_last_two_digit ( N ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void getSubsequence ( int [ ] ar ) { int N = ar . length ; Vector < Integer > ans = new Vector < Integer > ( ) ; ans . add ( ar [ 0 ] ) ; for ( int i = 1 ; i < N - 1 ; i ++ ) { if ( ar [ i ] > ar [ i - 1 ] ) { if ( i < N - 1 && ar [ i ] <= ar [ i + 1 ] ) { continue ; } else { ans . add ( ar [ i ] ) ; } } else { if ( i < N - 1 && ar [ i + 1 ] < ar [ i ] ) { continue ; } else { ans . add ( ar [ i ] ) ; } } } ans . add ( ar [ N - 1 ] ) ; for ( int it : ans ) System . out . print ( it + " ▁ " ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 3 , 5 } ; getSubsequence ( arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, it
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int curMax ; static int dfs ( Vector < Integer > g [ ] , int u , int v ) { int max1 = 0 , max2 = 0 , total = 0 ; for ( int i = 0 ; i < g [ u ] . size ( ) ; i ++ ) { if ( g [ u ] . get ( i ) == v ) continue ; total = Math . max ( total , dfs ( g , g [ u ] . get ( i ) , u ) ) ; if ( curMax > max1 ) { max2 = max1 ; max1 = curMax ; } else max2 = Math . max ( max2 , curMax ) ; } total = Math . max ( total , max1 + max2 ) ; curMax = max1 + 1 ; return total ; } static int maxProductOfTwoPaths ( Vector < Integer > g [ ] , int N ) { int res = Integer . MIN_VALUE ; int path1 , path2 ; for ( int i = 1 ; i < N + 2 ; i ++ ) { for ( int j = 0 ; j < g [ i ] . size ( ) ; j ++ ) { curMax = 0 ; path1 = dfs ( g , g [ i ] . get ( j ) , i ) ; curMax = 0 ; path2 = dfs ( g , i , g [ i ] . get ( j ) ) ; res = Math . max ( res , path1 * path2 ) ; } } return res ; } static void addEdge ( Vector < Integer > g [ ] , int u , int v ) { g [ u ] . add ( v ) ; g [ v ] . add ( u ) ; } public static void main ( String [ ] args ) { int edges [ ] [ ] = { { 1 , 8 } , { 2 , 6 } , { 3 , 1 } , { 5 , 3 } , { 7 , 8 } , { 8 , 4 } , { 8 , 6 } } ; int N = edges . length ; @ SuppressWarnings ( " unchecked " ) Vector < Integer > [ ] g = new Vector [ N + 2 ] ; for ( int i = 0 ; i < g . length ; i ++ ) g [ i ] = new Vector < Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) addEdge ( g , edges [ i ] [ 0 ] , edges [ i ] [ 1 ] ) ; System . out . print ( maxProductOfTwoPaths ( g , N ) + "NEW_LINE"); } }

Index/key variables: i, u, v
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int Minsteps ( int n ) { int ans = 0 ; while ( n > 1 ) { if ( n % 5 == 0 ) { ans ++ ; n = n / 5 ; continue ; } else if ( n % 4 == 0 ) { ans ++ ; n = n / 4 ; continue ; } else if ( n % 3 == 0 ) { ans ++ ; n = n / 3 ; continue ; } else if ( n % 2 == 0 ) { ans ++ ; n = n / 2 ; continue ; } return - 1 ; } return ans ; } public static void main ( String [ ] args ) { int n = 10 ; System . out . print ( Minsteps ( n ) ) ; } }

Accumulator variables: ans
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minDifference ( int num ) { StringBuilder maximum = new StringBuilder ( Integer . toString ( num ) ) ; StringBuilder minimum = new StringBuilder ( Integer . toString ( num ) ) ; int n = maximum . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( maximum . charAt ( i ) != '9' ) { char digit = maximum . charAt ( i ) ; for ( int j = i ; j < n ; j ++ ) { if ( maximum . charAt ( j ) == digit ) maximum . setCharAt ( j , '9' ) ; } break ; } } if ( minimum . charAt ( 0 ) == '1' ) { for ( int i = 1 ; i < n ; i ++ ) { if ( minimum . charAt ( i ) - '0' > 1 ) { char digit = minimum . charAt ( i ) ; for ( int j = i ; j < n ; j ++ ) { if ( digit == minimum . charAt ( j ) ) minimum . setCharAt ( j , '0' ) ; } break ; } } } else { char digit = minimum . charAt ( 0 ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( minimum . charAt ( i ) == digit ) minimum . setCharAt ( i , '1' ) ; } } return ( Integer . parseInt ( maximum . toString ( ) ) - Integer . parseInt ( minimum . toString ( ) ) ) ; } public static void main ( String [ ] args ) { int N = 1101157 ; System . out . println ( minDifference ( N ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void checkDivisible ( int x , int k ) { int g = __gcd ( x , k ) ; k /= g ; if ( x % k == 0 ) { System . out . print ( "YESNEW_LINE"); } else { System . out . print ( "NONEW_LINE"); } } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void main ( String [ ] args ) { int x = 6 , k = 9 ; checkDivisible ( x , k ) ; } }

Accumulator variables: k
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . Arrays ; class GFG { static int MinimumValue ( int arr [ ] , int n ) { Arrays . sort ( arr ) ; int minXor = Integer . MAX_VALUE ; int val = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { val = arr [ i ] ^ arr [ i + 1 ] ; minXor = Math . min ( minXor , val ) ; } return minXor ; } public static void main ( String [ ] args ) { int N = 6 ; int [ ] A = new int [ ] { 12 , 3 , 14 , 5 , 9 , 8 } ; System . out . print ( MinimumValue ( A , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int maxNormalSubString ( char [ ] P , char [ ] Q , int K , int N ) { if ( K == 0 ) return 0 ; int count = 0 ; int left = 0 , right = 0 ; int ans = 0 ; while ( right < N ) { while ( right < N && count <= K ) { int pos = P [ right ] - ' a ' ; if ( Q [ pos ] == '0' ) { if ( count + 1 > K ) break ; else count ++ ; } right ++ ; if ( count <= K ) ans = Math . max ( ans , right - left ) ; } while ( left < right ) { int pos = P [ left ] - ' a ' ; left ++ ; if ( Q [ pos ] == '0' ) count -- ; if ( count < K ) break ; } } return ans ; } public static void main ( String [ ] args ) { String P = " giraffe " , Q = "01111001111111111011111111" ; int K = 2 ; int N = P . length ( ) ; System . out . print ( maxNormalSubString ( P . toCharArray ( ) , Q . toCharArray ( ) , K , N ) ) ; } }

Index/key variables: left, pos, right
Accumulator variables: count, left, right
Class/struct names: GFG
Java program:
class GFG { static int countOperations ( int arr [ ] , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] % 2 == 1 ) { arr [ i ] ++ ; arr [ i + 1 ] ++ ; count += 2 ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 1 ) return - 1 ; } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 4 , 5 , 6 } ; int n = arr . length ; System . out . print ( countOperations ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countPairs ( int arr [ ] , int k ) { Arrays . sort ( arr ) ; int pair = 0 ; int index = 0 ; while ( index < arr . length - 1 ) { if ( arr [ index + 1 ] - arr [ index ] <= k ) { pair += 1 ; index += 2 ; } else { index += 1 ; } } return pair ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 4 , 3 , 7 , 5 } ; int k = 2 ; int count = countPairs ( arr , k ) ; System . out . println ( count ) ; } }

Index/key variables: index
Accumulator variables: index, pair
Class/struct names: GFG
Java program:
class GFG { static int maxProfit ( int profitA [ ] , int profitB [ ] , int n ) { int preSum [ ] = new int [ n ] ; preSum [ 0 ] = profitA [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { preSum [ i ] = preSum [ i - 1 ] + profitA [ i ] ; } int suffSum [ ] = new int [ n ] ; suffSum [ n - 1 ] = profitB [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) { suffSum [ i ] = suffSum [ i + 1 ] + profitB [ i ] ; } int res = preSum [ n - 1 ] ; for ( int i = 1 ; i < n - 1 ; i ++ ) { res = Math . max ( res , preSum [ i ] + suffSum [ i + 1 ] ) ; } res = Math . max ( res , suffSum [ 0 ] ) ; return res ; } public static void main ( String [ ] args ) { int profitA [ ] = { 2 , 3 , 2 } ; int profitB [ ] = { 10 , 30 , 40 } ; int n = profitA . length ; System . out . println ( maxProfit ( profitA , profitB , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void findpath ( int N , int a [ ] ) { if ( a [ 0 ] == 1 ) { System . out . print ( ( N + 1 ) + " ▁ " ) ; for ( int i = 1 ; i <= N ; i ++ ) System . out . print ( ( i ) + " ▁ " ) ; return ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( a [ i ] == 0 && a [ i + 1 ] == 1 ) { for ( int j = 1 ; j <= i ; j ++ ) System . out . print ( ( j ) + " ▁ " ) ; System . out . print ( ( N + 1 ) + " ▁ " ) ; for ( int j = i + 1 ; j <= N ; j ++ ) System . out . print ( ( j ) + " ▁ " ) ; return ; } } for ( int i = 1 ; i <= N ; i ++ ) System . out . print ( ( i ) + " ▁ " ) ; System . out . print ( ( N + 1 ) + " ▁ " ) ; } public static void main ( String [ ] args ) { int N = 3 , arr [ ] = { 0 , 1 , 0 } ; findpath ( N , arr ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class Pair < V , E > { V first ; E second ; Pair ( V first , E second ) { this . first = first ; this . second = second ; } } class GFG { static int minEdges ( Vector < Pair < Integer , Integer > > v , int n ) { int [ ] [ ] adj = new int [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i < v . size ( ) ; i ++ ) { adj [ v . elementAt ( i ) . first ] [ v . elementAt ( i ) . second ] = 1 ; adj [ v . elementAt ( i ) . second ] [ v . elementAt ( i ) . first ] = 1 ; } int edgesNeeded = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = i + 1 ; j <= n ; j ++ ) { for ( int k = j + 1 ; k <= n ; k ++ ) { if ( adj [ i ] [ j ] == 1 && adj [ j ] [ k ] == 1 && adj [ k ] [ i ] == 1 ) return 0 ; if ( ! ( adj [ i ] [ j ] == 1 adj [ j ] [ k ] == 1 adj [ k ] [ i ] == 1 ) ) edgesNeeded = Math . min ( edgesNeeded , 3 ) ; else { if ( ( adj [ i ] [ j ] == 1 && adj [ j ] [ k ] == 1 ) || ( adj [ j ] [ k ] == 1 && adj [ k ] [ i ] == 1 ) || ( adj [ k ] [ i ] == 1 && adj [ i ] [ j ] == 1 ) ) { edgesNeeded = 1 ; } else edgesNeeded = Math . min ( edgesNeeded , 2 ) ; } } } } return edgesNeeded ; } public static void main ( String [ ] args ) { int n = 3 ; Vector < Pair < Integer , Integer > > v = new Vector < > ( Arrays . asList ( new Pair < > ( 1 , 2 ) , new Pair < > ( 1 , 3 ) ) ) ; System . out . println ( minEdges ( v , n ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG, Pair
Java program:
import java . util . ArrayList ; class Graph { static int res ; static void dfs ( int u , int parent , int totalSum , ArrayList < Integer > [ ] edge , int subtree [ ] ) { int sum = subtree [ u ] ; for ( int i = 0 ; i < edge [ u ] . size ( ) ; i ++ ) { int v = edge [ u ] . get ( i ) ; if ( v != parent ) { dfs ( v , u , totalSum , edge , subtree ) ; sum += subtree [ v ] ; } } subtree [ u ] = sum ; if ( u != 0 && Math . abs ( totalSum - 2 * sum ) < res ) res = Math . abs ( totalSum - 2 * sum ) ; } static int getMinSubtreeSumDifference ( int vertex [ ] , int [ ] [ ] edges , int N ) { int totalSum = 0 ; int [ ] subtree = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { subtree [ i ] = vertex [ i ] ; totalSum += vertex [ i ] ; } @ SuppressWarnings ( " unchecked " ) ArrayList < Integer > [ ] edge = new ArrayList [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { edge [ i ] = new ArrayList < > ( ) ; } for ( int i = 0 ; i < N - 1 ; i ++ ) { edge [ edges [ i ] [ 0 ] ] . add ( edges [ i ] [ 1 ] ) ; edge [ edges [ i ] [ 1 ] ] . add ( edges [ i ] [ 0 ] ) ; } dfs ( 0 , - 1 , totalSum , edge , subtree ) ; return res ; } public static void main ( String [ ] args ) { res = Integer . MAX_VALUE ; int [ ] vertex = { 4 , 2 , 1 , 6 , 3 , 5 , 2 } ; int [ ] [ ] edges = { { 0 , 1 } , { 0 , 2 } , { 0 , 3 } , { 2 , 4 } , { 2 , 5 } , { 3 , 6 } } ; int N = vertex . length ; System . out . println ( getMinSubtreeSumDifference ( vertex , edges , N ) ) ; } }

Index/key variables: N, i, u, v
Accumulator variables: i, sum, totalSum
Iterator variables: i
Class/struct names: Graph
Java program:
import java . util . PriorityQueue ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int FindMinOperation ( int [ ] a , int n , int k ) { PriorityQueue < Integer > Q = new PriorityQueue < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) Q . add ( a [ i ] ) ; int ans = 0 ; while ( true ) { if ( Q . peek ( ) >= k ) break ; if ( Q . size ( ) < 2 ) return - 1 ; int x = Q . peek ( ) ; Q . poll ( ) ; int y = Q . peek ( ) ; Q . poll ( ) ; int z = ( x * y ) / gcd ( x , y ) ; Q . add ( z ) ; ans ++ ; } return ans ; } public static void main ( String [ ] args ) { int [ ] a = { 3 , 5 , 7 , 6 , 8 } ; int k = 8 ; int n = a . length ; System . out . println ( FindMinOperation ( a , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
using System ; using System . Collections ; class GfG { class GFG { public static String Check ( int a [ ] [ ] , int b [ ] [ ] , int n , int m ) { for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < m ; j ++ ) if ( a [ i ] [ j ] > b [ i ] [ j ] ) { int temp = a [ i ] [ j ] ; a [ i ] [ j ] = b [ i ] [ j ] ; b [ i ] [ j ] = temp ; } for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < m - 1 ; j ++ ) if ( a [ i ] [ j ] >= a [ i ] [ j + 1 ] b [ i ] [ j ] >= b [ i ] [ j + 1 ] ) return " No " ; for ( int i = 0 ; i < n - 1 ; i ++ ) for ( int j = 0 ; j < m ; j ++ ) if ( a [ i ] [ j ] >= a [ i + 1 ] [ j ] b [ i ] [ j ] >= b [ i + 1 ] [ j ] ) return " No " ; return " Yes " ; } public static void main ( String [ ] args ) { int n = 2 , m = 2 ; int a [ ] [ ] = { { 2 , 10 } , { 11 , 5 } } ; int b [ ] [ ] = { { 9 , 4 } , { 3 , 12 } } ; System . out . print ( Check ( a , b , n , m ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, GfG
Java program:
class GFG { static String smallestString ( int N , int [ ] A ) { char ch = ' a ' ; String S = " " ; if ( N < 1 A [ 0 ] != 1 ) { S = " - 1" ; return S ; } S += ch ; ch ++ ; for ( int i = 1 ; i < N ; i ++ ) { int diff = A [ i ] - A [ i - 1 ] ; if ( diff > 1 diff < 0 A [ i ] > 26 ) { S = " - 1" ; return S ; } else if ( diff == 0 ) S += ' a ' ; else { S += ch ; ch ++ ; } } return S ; } public static void main ( String args [ ] ) { int [ ] arr = { 1 , 1 , 2 , 3 , 3 } ; int n = arr . length ; System . out . println ( smallestString ( n , arr ) ) ; } }

Index/key variables: i
Accumulator variables: S, ch, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean canBePicked ( int digits [ ] , int num ) { int copyDigits [ ] = digits . clone ( ) ; while ( num > 0 ) { int digit = num % 10 ; if ( copyDigits [ digit ] == 0 ) return false ; else copyDigits [ digit ] -- ; num /= 10 ; } return true ; } static int countAlphabets ( int n ) { int i , count = 0 ; int digits [ ] = new int [ 10 ] ; while ( n > 0 ) { int digit = n % 10 ; digits [ digit ] ++ ; n /= 10 ; } for ( i = ' a ' ; i <= ' z ' ; i ++ ) if ( canBePicked ( digits , i ) ) count ++ ; for ( i = ' A ' ; i <= ' Z ' ; i ++ ) if ( canBePicked ( digits , i ) ) count ++ ; return count ; } public static void main ( String [ ] args ) { int n = 1623455078 ; System . out . println ( countAlphabets ( n ) ) ; } }

Index/key variables: digit
Accumulator variables: count, i, n, num
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { int greatestKBits ( int X , int K ) { int set_bit_count = Integer . bitCount ( X ) ; if ( set_bit_count <= K ) return X ; int diff = set_bit_count - K ; for ( int i = 0 ; i < diff ; i ++ ) X &= ( X - 1 ) ; return X ; } public static void main ( String [ ] args ) { int X = 21 , K = 2 ; GFG g = new GFG ( ) ; System . out . print ( g . greatestKBits ( X , K ) ) ; } }

Accumulator variables: X, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class Solution { static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } static void findTwoNumbers ( int sum , int gcd ) { if ( __gcd ( gcd , sum - gcd ) == gcd && sum != gcd ) System . out . println ( " a ▁ = ▁ " + Math . min ( gcd , sum - gcd ) + " , ▁ b ▁ = ▁ " + ( int ) ( sum - Math . min ( gcd , sum - gcd ) ) ) ; else System . out . println ( - 1 ) ; } public static void main ( String args [ ] ) { int sum = 8 ; int gcd = 2 ; findTwoNumbers ( sum , gcd ) ; } }

Class/struct names: Solution
Java program:
import java . util . * ; class GFG { static int findMaxDistance ( int numOfCities , int station [ ] , int n ) { boolean hasStation [ ] = new boolean [ numOfCities + 1 ] ; for ( int city = 0 ; city < n ; city ++ ) { hasStation [ station [ city ] ] = true ; } int dist = 0 ; int maxDist = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { maxDist = Math . min ( station [ i ] , maxDist ) ; } for ( int city = 0 ; city < numOfCities ; city ++ ) { if ( hasStation [ city ] == true ) { maxDist = Math . max ( ( dist + 1 ) / 2 , maxDist ) ; dist = 0 ; } else dist += 1 ; } return Math . max ( maxDist , dist ) ; } public static void main ( String args [ ] ) { int numOfCities = 6 ; int station [ ] = { 3 , 1 } ; int n = station . length ; System . out . println ( " Max ▁ Distance : " + findMaxDistance ( numOfCities , station , n ) ) ; } }

Index/key variables: city, i
Accumulator variables: city, dist, i
Iterator variables: city, i
Class/struct names: GFG
Java program:
class GFG { static void split ( int x , int n ) { if ( x < n ) System . out . print ( " - 1 ▁ " ) ; else if ( x % n == 0 ) { for ( int i = 0 ; i < n ; i ++ ) System . out . print ( ( x / n ) + " ▁ " ) ; } else { int zp = n - ( x % n ) ; int pp = x / n ; for ( int i = 0 ; i < n ; i ++ ) { if ( i >= zp ) System . out . print ( ( pp + 1 ) + " ▁ " ) ; else System . out . print ( pp + " ▁ " ) ; } } } public static void main ( String [ ] args ) { int x = 5 ; int n = 3 ; split ( x , n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static long cal_minimum_time ( long X ) { long t = 0 ; long sum = 0 ; while ( sum < X ) { t ++ ; sum = sum + t ; } return t ; } public static void main ( String [ ] args ) { long n = 6 ; long ans = cal_minimum_time ( n ) ; System . out . println ( " The ▁ minimum ▁ time ▁ required ▁ is ▁ : ▁ " + ans ) ; } }

Accumulator variables: t
Class/struct names: GFG
Java program:
public class Improve { public static void main ( String args [ ] ) { String s = " ABCdcba " ; int u [ ] = new int [ 26 ] ; int n = s . length ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( Character . isUpperCase ( s . charAt ( i ) ) ) { u [ s . charAt ( i ) - 65 ] += 1 ; } else { u [ s . charAt ( i ) - 97 ] -= 1 ; } } boolean f1 = true ; int po = 0 ; int ne = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( u [ i ] > 0 ) po += u [ i ] ; if ( u [ i ] < 0 ) ne += u [ i ] ; } if ( po == 0 && ne == 0 ) System . out . println ( " YES " ) ; else if ( po == 1 && ne == 0 ) System . out . println ( " YES " ) ; else if ( po == 0 && ne == - 1 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

Index/key variables: i
Accumulator variables: i, ne, po
Iterator variables: i
Boolean variables: f1
Class/struct names: Improve