dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
class GFG { static int M = 4 ; static int N = 5 ; public static void no_of_moves ( int [ ] [ ] Matrix , int x , int y ) { int moves = 0 ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( Matrix [ i ] [ j ] != 0 ) { moves += Math . abs ( x - i ) ; moves += Math . abs ( y - j ) ; } } } System . out . println ( moves ) ; } public static void main ( String [ ] args ) { int x = 3 ; int y = 2 ; int [ ] [ ] Matrix = { { 1 , 0 , 1 , 1 , 0 } , { 0 , 1 , 1 , 0 , 1 } , { 0 , 0 , 1 , 1 , 0 } , { 1 , 1 , 1 , 0 , 0 } } ; int num = 1 ; no_of_moves ( Matrix , x , y ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, moves
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static void removeAll ( int arr [ ] , int n ) { if ( arr [ 0 ] < arr [ n - 1 ] ) System . out . print ( " YES " ) ; else System . out . print ( " NO " ) ; } public static void main ( String [ ] args ) { int Arr [ ] = { 10 , 4 , 7 , 1 , 3 , 6 } ; int size = Arr . length ; removeAll ( Arr , size ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static void FindSubarray ( int [ ] arr , int n ) { if ( n == 1 ) { System . out . println ( " No ▁ such ▁ subarray ! " ) ; } int [ ] vis = new int [ n + 1 ] ; Arrays . fill ( vis , - 1 ) ; vis [ arr [ 0 ] ] = 0 ; int len = Integer . MAX_VALUE , flag = 0 ; int start = 0 , end = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int t = arr [ i ] ; if ( vis [ t ] != - 1 ) { int distance = i - vis [ t ] + 1 ; if ( distance < len ) { len = distance ; start = vis [ t ] ; end = i ; } flag = 1 ; } vis [ t ] = i ; } if ( flag == 0 ) System . out . println ( " No ▁ such ▁ subarray ! " ) ; else { for ( int i = start ; i <= end ; i ++ ) System . out . print ( arr [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 3 , 2 , 4 , 5 } ; int n = arr . length ; FindSubarray ( arr , n ) ; } }

Index/key variables: i, t
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { public static int countSubstrings ( String s ) { int n = s . length ( ) ; int answer = ( n * ( n - 1 ) ) / 2 ; int cnt = 1 ; Vector < Integer > v = new Vector < Integer > ( ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i - 1 ) ) cnt ++ ; else { v . add ( cnt ) ; cnt = 1 ; } } if ( cnt > 0 ) v . add ( cnt ) ; for ( int i = 0 ; i < v . size ( ) - 1 ; i ++ ) { answer -= ( v . get ( i ) + v . get ( i + 1 ) - 1 ) ; } return answer ; } public static void main ( String [ ] args ) { String s = "00111" ; System . out . print ( countSubstrings ( s ) ) ; } }

Accumulator variables: answer, cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static int get_palindrome_time ( String str ) { int hh , mm ; hh = ( str . charAt ( 0 ) - 48 ) * 10 + ( str . charAt ( 1 ) - 48 ) ; mm = ( str . charAt ( 3 ) - 48 ) * 10 + ( str . charAt ( 4 ) - 48 ) ; int requiredTime = 0 ; while ( hh % 10 != mm / 10 hh / 10 != mm % 10 ) { ++ mm ; if ( mm == 60 ) { mm = 0 ; ++ hh ; } if ( hh == 24 ) hh = 0 ; ++ requiredTime ; } return requiredTime ; } public static void main ( String [ ] args ) { String str = "05:39" ; System . out . println ( get_palindrome_time ( str ) ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int maximumSubarraySum ( int a [ ] , int n , ArrayList < List < Integer > > subarrays ) { int i , maxsum = 0 ; int [ ] prefixArray = new int [ n ] ; for ( i = 0 ; i < subarrays . size ( ) ; ++ i ) { prefixArray [ subarrays . get ( i ) . get ( 0 ) - 1 ] ++ ; prefixArray [ subarrays . get ( i ) . get ( 1 ) ] -- ; } for ( i = 1 ; i < n ; i ++ ) { prefixArray [ i ] += prefixArray [ i - 1 ] ; } Arrays . sort ( prefixArray ) ; Arrays . sort ( a ) ; for ( i = 0 ; i < n ; i ++ ) maxsum += a [ i ] * prefixArray [ i ] ; return maxsum ; } public static void main ( String [ ] args ) { int n = 6 ; int a [ ] = { 4 , 1 , 2 , 1 , 9 , 2 } ; ArrayList < List < Integer > > subarrays = new ArrayList < > ( ) ; subarrays . add ( Arrays . asList ( 1 , 2 ) ) ; subarrays . add ( Arrays . asList ( 1 , 3 ) ) ; subarrays . add ( Arrays . asList ( 1 , 4 ) ) ; subarrays . add ( Arrays . asList ( 3 , 4 ) ) ; System . out . println ( maximumSubarraySum ( a , n , subarrays ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, maxsum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int maxProfit ( int [ ] value , int N , int K ) { Arrays . sort ( value ) ; int maxval = value [ N - 1 ] ; int maxProfit = 0 ; int curr_val ; do { curr_val = 0 ; for ( int i = 0 ; i < N ; i ++ ) { curr_val += value [ i ] ; if ( curr_val <= K ) { maxProfit = Math . max ( curr_val + maxval * ( i + 1 ) , maxProfit ) ; } } } while ( next_permutation ( value ) ) ; return maxProfit ; } static boolean next_permutation ( int [ ] p ) { for ( int a = p . length - 2 ; a >= 0 ; -- a ) if ( p [ a ] < p [ a + 1 ] ) for ( int b = p . length - 1 ; ; -- b ) if ( p [ b ] > p [ a ] ) { int t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; for ( ++ a , b = p . length - 1 ; a < b ; ++ a , -- b ) { t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; } return true ; } return false ; } public static void main ( String [ ] args ) { int N = 4 , K = 6 ; int [ ] values = { 5 , 2 , 7 , 3 } ; System . out . print ( maxProfit ( values , N , K ) ) ; } }

Index/key variables: a, b, i
Accumulator variables: curr_val, i
Iterator variables: a, b, i
Class/struct names: GFG
Java program:
import java . lang . Math ; class GFG { static void minValue ( int n ) { while ( ( int ) Math . sqrt ( n ) == Math . sqrt ( n ) && n > 1 ) { n = ( int ) ( Math . sqrt ( n ) ) ; } for ( int i = ( int ) ( Math . sqrt ( n ) ) ; i > 1 ; i -- ) { while ( n % ( i * i ) == 0 ) n /= i ; } System . out . println ( n ) ; } public static void main ( String args [ ] ) { int N = 20 ; minValue ( N ) ; } }

Accumulator variables: i, n
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static boolean isPalindrome ( int l , int r , String s ) { while ( l <= r ) { if ( s . charAt ( l ) != s . charAt ( r ) ) return false ; l ++ ; r -- ; } return true ; } public static int numWays ( String s ) { int n = s . length ( ) ; int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( isPalindrome ( 0 , i , s ) && isPalindrome ( i + 1 , n - 1 , s ) ) { ans ++ ; } } return ans ; } public static void main ( String args [ ] ) { String S = " aaaaa " ; System . out . println ( numWays ( S ) ) ; } }

Accumulator variables: ans, i, l, r
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void findDirection ( int n , int m ) { if ( n > m ) { if ( m % 2 == 0 ) System . out . print ( "UpNEW_LINE"); else System . out . print ( "DownNEW_LINE"); } else { if ( n % 2 == 0 ) System . out . print ( "LeftNEW_LINE"); else System . out . print ( "RightNEW_LINE"); } } public static void main ( String [ ] args ) { int n = 3 , m = 3 ; findDirection ( n , m ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int maxModulosum ( int a [ ] , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } return sum - n ; } public static void main ( String [ ] args ) { int a [ ] = new int [ ] { 3 , 4 , 6 } ; int n = a . length ; System . out . println ( maxModulosum ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static int getMinJumps ( String s ) { Vector < Integer > ones = new Vector < Integer > ( ) ; int jumps = 0 , median = 0 , ind = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '1' ) ones . add ( i ) ; } if ( ones . size ( ) == 0 ) return jumps ; median = ( int ) ones . get ( ones . size ( ) / 2 ) ; ind = median ; for ( int i = ind ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == '1' ) { jumps += ind - i ; ind -- ; } } ind = median ; for ( int i = ind ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '1' ) { jumps += i - ind ; ind ++ ; } } return jumps ; } public static void main ( String [ ] args ) { String S = "00100000010011" ; System . out . println ( getMinJumps ( S ) ) ; } }

Accumulator variables: i, ind, jumps
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int N = ( int ) ( 1e5 + 5 ) ; static Vector < Integer > [ ] v = new Vector [ N ] ; static int [ ] val = new int [ N ] ; static int [ ] answer = new int [ N ] ; static int n ; static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static void DFS ( int node , int parent ) { answer [ node ] = val [ node ] ; for ( int child : v [ node ] ) { if ( child == parent ) continue ; DFS ( child , node ) ; answer [ node ] = gcd ( answer [ node ] , answer [ child ] ) ; } } static void preprocess ( ) { DFS ( 1 , - 1 ) ; } static void findGCD ( int queries [ ] , int q ) { preprocess ( ) ; for ( int i = 0 ; i < q ; i ++ ) { int GCD = answer [ queries [ i ] ] ; System . out . print ( " For ▁ subtree ▁ of ▁ " + queries [ i ] + " , ▁ GCD ▁ = ▁ " + GCD + "NEW_LINE"); } } public static void main ( String [ ] args ) { n = 5 ; for ( int i = 0 ; i < v . length ; i ++ ) v [ i ] = new Vector < Integer > ( ) ; v [ 1 ] . add ( 2 ) ; v [ 2 ] . add ( 1 ) ; v [ 1 ] . add ( 3 ) ; v [ 3 ] . add ( 1 ) ; v [ 3 ] . add ( 4 ) ; v [ 4 ] . add ( 3 ) ; v [ 3 ] . add ( 5 ) ; v [ 5 ] . add ( 3 ) ; val [ 1 ] = 2 ; val [ 2 ] = 3 ; val [ 3 ] = 4 ; val [ 4 ] = 8 ; val [ 5 ] = 16 ; int queries [ ] = { 2 , 3 , 1 } ; int q = queries . length ; findGCD ( queries , q ) ; } }

Index/key variables: N, child, i, node
Accumulator variables: i
Iterator variables: child, i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void makeZero ( int x , int y , int a , int b ) { if ( x > y ) { int temp = x ; x = y ; y = temp ; } int tot_cost = ( y - x ) * a ; int cost1 = 2 * x * a ; int cost2 = x * b ; tot_cost += Math . min ( cost1 , cost2 ) ; System . out . print ( tot_cost ) ; } public static void main ( String args [ ] ) { int X = 1 , Y = 3 ; int cost1 = 391 , cost2 = 555 ; makeZero ( X , Y , cost1 , cost2 ) ; } }

Accumulator variables: tot_cost
Class/struct names: GFG
Java program:
import java . util . Scanner ; class Solution { public static void splitFraction ( int n , int d ) { long ar [ ] = new long [ n ] ; long first = d + n - 1 ; ar [ 0 ] = first ; for ( int i = 1 ; i < n ; i ++ ) { ar [ i ] = first * ( -- first ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( ar [ i ] % n == 0 ) { System . out . print ( "1 / " + ar [ i ] / n + " , ▁ " ) ; } else { System . out . print ( n + " / " + ar [ i ] + " , ▁ " ) ; } } } public static void main ( String [ ] args ) throws Exception { int N = 4 ; int D = 2 ; splitFraction ( N , D ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: Solution
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int numPairs ( int arr [ ] , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] % arr [ i ] == 0 ) ans ++ ; } } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 1 , 2 , 2 , 3 , 3 } ; int n = arr . length ; System . out . println ( numPairs ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static boolean check ( int [ ] arr , int n ) { boolean flag = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < n - i ) { flag = false ; } } if ( flag ) { return true ; } else { return false ; } } public static void main ( String [ ] args ) { int arr1 [ ] = { 11 , 11 , 11 , 11 } ; int n1 = arr1 . length ; if ( check ( arr1 , n1 ) ) { System . out . print ( " Yes " + "NEW_LINE"); } else { System . out . print ( " No " + "NEW_LINE"); } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int BalancedPartition ( String str , int n ) { if ( n == 0 ) return 0 ; int r = 0 , l = 0 ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str . charAt ( i ) == ' R ' ) { r ++ ; } else if ( str . charAt ( i ) == ' L ' ) { l ++ ; } if ( r == l ) { ans ++ ; } } return ans ; } public static void main ( String [ ] args ) { String str = " LLRRRLLRRL " ; int n = str . length ( ) ; System . out . print ( BalancedPartition ( str , n ) + "NEW_LINE"); } }

Accumulator variables: ans, i, l, r
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int minOccupiedPosition ( int A [ ] , int n ) { int minPos = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( A [ i ] > 0 ) { ++ minPos ; i += 2 ; } } return minPos ; } public static void main ( String [ ] args ) { int A [ ] = { 8 , 0 , 7 , 0 , 0 , 6 } ; int n = A . length ; System . out . print ( minOccupiedPosition ( A , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . Math ; class GFG { static int findMinimumK ( int a [ ] , int n , int S ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } return ( int ) Math . ceil ( ( ( S + 1 ) * 1.0 ) / ( sum * 1.0 ) ) ; } public static void main ( String [ ] args ) { int a [ ] = { 10 , 7 , 8 , 10 , 12 , 19 } ; int n = a . length ; int S = 200 ; System . out . print ( findMinimumK ( a , n , S ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int largestNum ( int n ) { int num = 0 ; for ( int i = 0 ; i <= 32 ; i ++ ) { int x = ( 1 << i ) ; if ( ( x - 1 ) <= n ) num = ( 1 << i ) - 1 ; else break ; } return num ; } public static void main ( String args [ ] ) { int N = 345 ; System . out . print ( largestNum ( N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void findString ( int N , int K ) { for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( ( char ) ( ' A ' + i % K ) ) ; } } public static void main ( String [ ] args ) { int N = 10 ; int K = 3 ; findString ( N , K ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int count ( String s ) { int N , i , cnt = 0 , ans = 0 ; N = s . length ( ) ; for ( i = 0 ; i < N ; i ++ ) { if ( s . charAt ( i ) == ' R ' ) cnt ++ ; if ( s . charAt ( i ) == ' L ' ) ans += cnt ; } return ans ; } static public void main ( String [ ] args ) { String s = " RRLL " ; System . out . println ( count ( s ) ) ; } }

Accumulator variables: ans, cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void segments ( int n ) { if ( n == 1 n == 0 ) { return ; } if ( n % 2 == 0 ) { System . out . print ( "1" ) ; segments ( n - 2 ) ; } else if ( n % 2 == 1 ) { System . out . print ( "7" ) ; segments ( n - 3 ) ; } } public static void main ( String [ ] args ) { int n ; n = 11 ; segments ( n ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int findMinimumSubsequences ( String A , String B ) { int numberOfSubsequences = 1 ; int sizeOfB = B . length ( ) ; int sizeOfA = A . length ( ) ; int inf = 1000000 ; int [ ] [ ] next = new int [ 26 ] [ sizeOfB ] ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 0 ; j < sizeOfB ; j ++ ) { next [ i ] [ j ] = inf ; } } for ( int i = 0 ; i < sizeOfB ; i ++ ) { next [ B . charAt ( i ) - ' a ' ] [ i ] = i ; } for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = sizeOfB - 2 ; j >= 0 ; j -- ) { if ( next [ i ] [ j ] == inf ) { next [ i ] [ j ] = next [ i ] [ j + 1 ] ; } } } int pos = 0 ; int i = 0 ; while ( i < sizeOfA ) { if ( pos == 0 && next [ A . charAt ( i ) - ' a ' ] [ pos ] == inf ) { numberOfSubsequences = - 1 ; break ; } else if ( pos < sizeOfB && next [ A . charAt ( i ) - ' a ' ] [ pos ] < inf ) { int nextIndex = next [ A . charAt ( i ) - ' a ' ] [ pos ] + 1 ; pos = nextIndex ; i ++ ; } else { numberOfSubsequences ++ ; pos = 0 ; } } return numberOfSubsequences ; } public static void main ( String [ ] args ) { String A = " aacbe " ; String B = " aceab " ; System . out . print ( findMinimumSubsequences ( A , B ) ) ; } }

Index/key variables: i, j, pos, sizeOfB
Accumulator variables: i, j, numberOfSubsequences
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void horizontalFill ( int records [ ] , int tape [ ] , int nt ) { int sum = 0 ; int Retrieval_Time = 0 ; double Mrt ; int current = 0 ; Vector < Integer > v = new Vector < Integer > ( ) ; for ( int i = 0 ; i < nt ; i ++ ) { v . clear ( ) ; Retrieval_Time = 0 ; sum = 0 ; System . out . print ( " tape ▁ " + ( i + 1 ) + " ▁ : ▁ [ ▁ " ) ; sum += records [ current ] ; while ( sum <= tape [ i ] ) { System . out . print ( records [ current ] + " ▁ " ) ; v . add ( records [ current ] ) ; current ++ ; sum += records [ current ] ; } System . out . print ( " ] " ) ; for ( int j = 0 ; j < v . size ( ) ; j ++ ) { Retrieval_Time += v . get ( j ) * ( v . size ( ) - j ) ; } Mrt = ( double ) Retrieval_Time / v . size ( ) ; System . out . print ( " TABSYMBOL MRT ▁ : ▁ " + Mrt + "NEW_LINE"); } } public static void main ( String [ ] args ) { int records [ ] = { 15 , 2 , 8 , 23 , 45 , 50 , 60 , 120 } ; int tape [ ] = { 25 , 80 , 160 } ; int n = records . length ; int m = tape . length ; Arrays . sort ( records ) ; horizontalFill ( records , tape , m ) ; } }

Index/key variables: current, i
Accumulator variables: Retrieval_Time, current, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { final static int MAX_SIZE = 10 ; static void convolution ( int [ ] x , int [ ] h , int n , int m ) { int row_vec [ ] = new int [ MAX_SIZE ] ; int col_vec [ ] = new int [ MAX_SIZE ] ; int out [ ] = new int [ MAX_SIZE ] ; int circular_shift_mat [ ] [ ] = new int [ MAX_SIZE ] [ MAX_SIZE ] ; int maxSize = n > m ? n : m ; for ( int i = 0 ; i < maxSize ; i ++ ) { if ( i >= n ) { row_vec [ i ] = 0 ; } else { row_vec [ i ] = x [ i ] ; } } for ( int i = 0 ; i < maxSize ; i ++ ) { if ( i >= m ) { col_vec [ i ] = 0 ; } else { col_vec [ i ] = h [ i ] ; } } int k = 0 , d = 0 ; for ( int i = 0 ; i < maxSize ; i ++ ) { int curIndex = k - d ; for ( int j = 0 ; j < maxSize ; j ++ ) { circular_shift_mat [ j ] [ i ] = row_vec [ curIndex % maxSize ] ; curIndex ++ ; } k = maxSize ; d ++ ; } for ( int i = 0 ; i < maxSize ; i ++ ) { for ( int j = 0 ; j < maxSize ; j ++ ) { out [ i ] += circular_shift_mat [ i ] [ j ] * col_vec [ j ] ; } System . out . print ( out [ i ] + " ▁ " ) ; } } public static void main ( String [ ] args ) { int x [ ] = { 5 , 7 , 3 , 2 } ; int n = x . length ; int h [ ] = { 1 , 5 } ; int m = h . length ; convolution ( x , h , n , m ) ; } }

Index/key variables: MAX_SIZE, i, j
Accumulator variables: curIndex, d, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int max_palindrome ( String [ ] s , int n ) { int flag = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] . length ( ) % 2 != 0 ) { flag = 1 ; } } if ( flag == 1 ) { return n ; } int z = 0 ; int o = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < s [ i ] . length ( ) ; j ++ ) { if ( s [ i ] . charAt ( j ) == '0' ) z += 1 ; else o += 1 ; } } if ( o % 2 == 0 && z % 2 == 0 ) { return n ; } else { return n - 1 ; } } public static void main ( String [ ] args ) { int n = 3 ; String s [ ] = { "1110" , "100110" , "010101" } ; System . out . println ( max_palindrome ( s , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, o, z
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int minCost ( int [ ] cost , int n ) { int totalCost = 0 ; int boardingBus = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( cost [ boardingBus ] > cost [ i ] ) { totalCost += ( ( i - boardingBus ) * cost [ boardingBus ] ) ; boardingBus = i ; } } totalCost += ( ( n - boardingBus ) * cost [ boardingBus ] ) ; return totalCost ; } public static void main ( String [ ] args ) { int [ ] cost = { 4 , 7 , 8 , 3 , 4 } ; int n = cost . length ; System . out . print ( minCost ( cost , n ) ) ; } }

Index/key variables: boardingBus, i
Accumulator variables: i, totalCost
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int minFlipsSub ( String mat [ ] , int i , int j ) { int cnt0 = 0 , cnt1 = 0 ; if ( mat [ i ] . charAt ( j ) == '1' ) cnt1 ++ ; else cnt0 ++ ; if ( mat [ i ] . charAt ( j + 1 ) == '1' ) cnt1 ++ ; else cnt0 ++ ; if ( mat [ i + 1 ] . charAt ( j ) == '1' ) cnt1 ++ ; else cnt0 ++ ; if ( mat [ i + 1 ] . charAt ( j + 1 ) == '1' ) cnt1 ++ ; else cnt0 ++ ; return Math . min ( cnt0 , cnt1 ) ; } static int minFlips ( String mat [ ] , int r , int c ) { int res = Integer . MAX_VALUE ; for ( int i = 0 ; i < r - 1 ; i ++ ) { for ( int j = 0 ; j < c - 1 ; j ++ ) { res = Math . min ( res , minFlipsSub ( mat , i , j ) ) ; } } return res ; } public static void main ( String [ ] args ) { String mat [ ] = { "0101" , "0101" , "0101" } ; int r = mat . length ; int c = mat [ 0 ] . length ( ) ; System . out . print ( minFlips ( mat , r , c ) ) ; } }

Index/key variables: i
Accumulator variables: cnt0, cnt1, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
class GFG { static int findK ( int n , int k ) { int pos ; if ( n % 2 == 0 ) { pos = n / 2 ; } else { pos = ( n / 2 ) + 1 ; } if ( k <= pos ) { return ( k * 2 - 1 ) ; } else return ( ( k - pos ) * 2 ) ; } static int countSetBits ( int n , int k ) { int kth = findK ( n , k ) ; int count = 0 ; while ( kth > 0 ) { count += kth & 1 ; kth >>= 1 ; } return count ; } public static void main ( String [ ] args ) { int n = 18 , k = 12 ; System . out . println ( countSetBits ( n , k ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minCost ( char [ ] str1 , char [ ] str2 , int n ) { int cost = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str1 [ i ] != str2 [ i ] ) { if ( i < n - 1 && str1 [ i + 1 ] != str2 [ i + 1 ] ) { swap ( str1 , i , i + 1 ) ; cost ++ ; } else { cost ++ ; } } } return cost ; } static void swap ( char [ ] arr , int i , int j ) { char temp = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = temp ; } public static void main ( String [ ] args ) { String str1 = " abb " , str2 = " bba " ; int n = str1 . length ( ) ; System . out . println ( minCost ( str1 . toCharArray ( ) , str2 . toCharArray ( ) , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: cost, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static void find_set ( int n ) { if ( n <= 2 ) { System . out . println ( " - 1" ) ; return ; } int sum1 = ( n * ( n - 1 ) ) / 2 ; int sum2 = n ; System . out . println ( sum1 + " ▁ " + sum2 ) ; } public static void main ( String [ ] args ) { int n = 8 ; find_set ( n ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; import java . io . * ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int lcm ( int n , int m ) { return ( n * m ) / gcd ( n , m ) ; } public static void main ( String [ ] args ) { int n = 2 , m = 3 , k = 5 ; System . out . print ( k / lcm ( n , m ) ) ; } }

Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static boolean CheckForSequence ( int arr [ ] , int n , int k ) { for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( k >= arr [ i ] ) k -= arr [ i ] ; } if ( k != 0 ) return false ; else return true ; } public static void main ( String [ ] args ) { int A [ ] = { 1 , 3 , 7 , 15 , 31 } ; int n = A . length ; System . out . println ( CheckForSequence ( A , n , 18 ) ? " True " : " False " ) ; } }

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