dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static int countSubArraySignChange ( int arr [ ] , int N ) { HashMap < Integer , Integer > prefixCount = new HashMap < Integer , Integer > ( ) ; HashMap < Integer , Integer > suffixCount = new HashMap < Integer , Integer > ( ) ; int total = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { total += arr [ i ] ; if ( suffixCount . containsKey ( arr [ i ] ) ) { suffixCount . put ( arr [ i ] , suffixCount . get ( arr [ i ] ) + 1 ) ; } else { suffixCount . put ( arr [ i ] , 1 ) ; } } int prefixSum = 0 ; int suffixSum = 0 ; int count = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { prefixSum += arr [ i ] ; if ( prefixCount . containsKey ( arr [ i ] ) ) { prefixCount . put ( arr [ i ] , prefixCount . get ( arr [ i ] ) + 1 ) ; } else { prefixCount . put ( arr [ i ] , 1 ) ; } suffixSum = total - prefixSum ; if ( suffixCount . containsKey ( arr [ i ] ) ) { suffixCount . put ( arr [ i ] , suffixCount . get ( arr [ i ] ) - 1 ) ; } int diff = prefixSum - suffixSum ; if ( diff % 2 == 0 ) { int x = ( prefixCount . containsKey ( diff / 2 ) ? prefixCount . get ( diff / 2 ) : 0 ) + ( suffixCount . containsKey ( - diff / 2 ) ? suffixCount . get ( - diff / 2 ) : 0 ) ; count = count + x ; } } return count ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 2 , - 3 , 3 } ; int N = arr . length ; System . out . print ( countSubArraySignChange ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, prefixSum, total
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countCommonChar ( int ind , String S ) { int cnt = 0 ; HashSet < Character > ls = new HashSet < Character > ( ) ; HashSet < Character > rs = new HashSet < Character > ( ) ; for ( int i = 0 ; i < ind ; ++ i ) { ls . add ( S . charAt ( i ) ) ; } for ( int i = ind ; i < S . length ( ) ; ++ i ) { rs . add ( S . charAt ( i ) ) ; } for ( char v : ls ) { if ( rs . contains ( v ) ) { ++ cnt ; } } return cnt ; } static void partitionStringWithMaxCom ( String S ) { int ans = 0 ; for ( int i = 1 ; i < S . length ( ) ; ++ i ) { ans = Math . max ( ans , countCommonChar ( i , S ) ) ; } System . out . print ( ans + "NEW_LINE"); } public static void main ( String [ ] args ) { String str = " aabbca " ; partitionStringWithMaxCom ( str ) ; } }

Iterator variables: i, v
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void countMaxCommonChar ( char [ ] S ) { LinkedHashSet < Character > Q = new LinkedHashSet < > ( ) ; int res = 1 ; HashMap < Character , Integer > freq = new HashMap < > ( ) ; for ( int i = 0 ; i < S . length ; i ++ ) { if ( freq . containsKey ( S [ i ] ) ) { freq . put ( S [ i ] , freq . get ( S [ i ] ) + 1 ) ; } else { freq . put ( S [ i ] , 1 ) ; } } for ( int i = 0 ; i < S . length ; i ++ ) { if ( freq . containsKey ( S [ i ] ) ) { freq . put ( S [ i ] , freq . get ( S [ i ] ) - 1 ) ; } if ( ! freq . containsKey ( S [ i ] ) ) { Q . remove ( S [ i ] ) ; } else { Q . add ( S [ i ] ) ; } int curr = Q . size ( ) - 1 ; res = Math . max ( res , curr ) ; } System . out . print ( res + "NEW_LINE"); } public static void main ( String [ ] args ) { String str = " aabbca " ; countMaxCommonChar ( str . toCharArray ( ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static int longestSubarray ( String s ) { s += '0' ; int i ; int res = 0 ; int prev_one = 0 ; int curr_one = 0 ; int numberOfZeros = 0 ; for ( i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '1' ) { curr_one += 1 ; } else { numberOfZeros += 1 ; prev_one += curr_one ; res = Math . max ( res , prev_one ) ; prev_one = curr_one ; curr_one = 0 ; } } if ( numberOfZeros == 1 ) { res -= 1 ; } return res ; } public static void main ( String [ ] args ) { String S = "1101" ; System . out . println ( longestSubarray ( S ) ) ; } }

Accumulator variables: curr_one, i, numberOfZeros, prev_one, res, s
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int longestSubarray ( String s ) { int i = 0 , j = 0 , k = 1 ; for ( j = 0 ; j < s . length ( ) ; ++ j ) { if ( s . charAt ( j ) == '0' ) k -- ; if ( k < 0 && s . charAt ( i ++ ) == '0' ) k ++ ; } return j - i - 1 ; } public static void main ( String [ ] args ) { String S = "011101101" ; System . out . print ( longestSubarray ( S ) ) ; } }

Accumulator variables: i, k
Iterator variables: j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String SmallestString ( String s , char c ) { for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) > c ) { String temp = s ; s = s . substring ( 0 , i ) ; s += c ; s += temp . substring ( i , temp . length ( ) ) ; return s ; } } s += c ; return s ; } public static void main ( String args [ ] ) { String S = " acd " ; char C = ' b ' ; System . out . println ( SmallestString ( S , C ) ) ; } }

Accumulator variables: i, s
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void LarUnEl ( int arr [ ] , int N ) { HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { map . put ( arr [ i ] , map . getOrDefault ( arr [ i ] , 0 ) + 1 ) ; } int LNRElem = Integer . MIN_VALUE ; int ind = - 1 ; for ( int i = 0 ; i < N ; i ++ ) { if ( map . get ( arr [ i ] ) == 1 && arr [ i ] > LNRElem ) { ind = i ; LNRElem = arr [ i ] ; } } if ( ind == - 1 ) { System . out . println ( ind ) ; return ; } System . out . println ( arr [ ind ] ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 3 , 1 , 8 , 8 , 4 } ; int N = arr . length ; LarUnEl ( arr , N ) ; } }

Index/key variables: i, ind
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void countShifts ( String str ) { int firstOne = - 1 ; int lastOne = - 1 ; int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == '1' ) { if ( firstOne == - 1 ) firstOne = i ; lastOne = i ; } } if ( ( firstOne == - 1 ) || ( firstOne == lastOne ) ) { System . out . print ( 0 ) ; return ; } for ( int i = firstOne ; i <= lastOne ; i ++ ) { if ( str . charAt ( i ) == '0' ) { count ++ ; } } System . out . println ( count ) ; } public static void main ( String [ ] args ) { String str = "00110111011" ; countShifts ( str ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static boolean checkSubsequenceUtil ( int arr [ ] , int L , int R , int N ) { for ( int i = 0 ; i < L ; i ++ ) if ( arr [ i ] == arr [ L ] ) return true ; for ( int i = R + 1 ; i < N ; i ++ ) if ( arr [ i ] == arr [ R ] ) return true ; return false ; } static void checkSubsequence ( int arr [ ] , int L , int R , int N ) { if ( checkSubsequenceUtil ( arr , L , R , N ) ) { System . out . print ( "YESNEW_LINE"); } else { System . out . print ( "NONEW_LINE"); } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 7 , 12 , 1 , 7 , 5 , 10 , 11 , 42 } ; int N = arr . length ; int L = 3 , R = 6 ; checkSubsequence ( arr , L , R , N ) ; } }

Index/key variables: L, R, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Node { int data ; Node next ; Node prev ; } ; static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . prev = null ; new_node . next = head_ref ; if ( head_ref != null ) { head_ref . prev = new_node ; } head_ref = new_node ; return head_ref ; } static int search ( Node head_ref , int x ) { Node temp = head_ref ; int pos = 0 ; while ( temp . data != x && temp . next != null ) { pos ++ ; temp = temp . next ; } if ( temp . data != x ) return - 1 ; return ( pos + 1 ) ; } public static void main ( String [ ] args ) { Node head = null ; int X = 8 ; head = push ( head , 14 ) ; head = push ( head , 9 ) ; head = push ( head , 8 ) ; head = push ( head , 15 ) ; head = push ( head , 18 ) ; System . out . print ( search ( head , X ) ) ; } }

Accumulator variables: pos
Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { static void largestSubarray ( int [ ] arr , int N , int K ) { int count = 0 ; int len = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] < K ) { count += 1 ; } else { len = Math . max ( len , count ) ; count = 0 ; } } if ( count != 0 ) { len = Math . max ( len , count ) ; } System . out . println ( len ) ; } public static void main ( String [ ] args ) { int [ ] arr = { 1 , 8 , 3 , 5 , 2 , 2 , 1 , 13 } ; int N = arr . length ; int K = 6 ; largestSubarray ( arr , N , K ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static void findPair ( int A [ ] , int N ) { int right_prod [ ] = new int [ N ] ; int flag = 0 ; right_prod [ N - 1 ] = A [ N - 1 ] ; for ( int i = N - 2 ; i >= 0 ; i -- ) right_prod [ i ] = right_prod [ i + 1 ] * A [ i ] ; int total_prod = right_prod [ 0 ] ; int product ; for ( int i = 1 ; i < N - 1 ; i ++ ) { product = 1 ; for ( int j = i ; j < N - 1 ; j ++ ) { product *= A [ j ] ; if ( gcd ( product , right_prod [ j + 1 ] ) == 1 || gcd ( product , total_prod / right_prod [ i ] ) == 1 ) { flag = 1 ; System . out . println ( " ( " + ( i - 1 ) + " , ▁ " + ( j + 1 ) + " ) " ) ; break ; } } if ( flag == 1 ) break ; } if ( flag == 0 ) System . out . print ( - 1 ) ; } public static void main ( String [ ] args ) { int arr [ ] = { 2 , 4 , 1 , 3 , 7 } ; int N = arr . length ; findPair ( arr , N ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j, product
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void countString ( String S ) { int count = 0 ; for ( char it : S . toCharArray ( ) ) { if ( it == '0' && count > 0 ) { count -- ; } else { count ++ ; } } System . out . print ( ( 1 << count ) - 1 ) ; } public static void main ( String [ ] args ) { String S = "1001" ; countString ( S ) ; } }

Accumulator variables: count
Iterator variables: it
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static void replaceDuplicates ( String [ ] names ) { HashMap < String , Integer > hash = new HashMap < > ( ) ; for ( int i = 0 ; i < names . length ; i ++ ) { if ( ! hash . containsKey ( names [ i ] ) ) hash . put ( names [ i ] , 1 ) ; else { int count = hash . get ( names [ i ] ) ; hash . put ( names [ i ] , hash . get ( names [ i ] ) + 1 ) ; names [ i ] += Integer . toString ( count ) ; } } for ( int i = 0 ; i < names . length ; i ++ ) { System . out . print ( names [ i ] + ' ▁ ' ) ; } } public static void main ( String [ ] args ) { String [ ] str = { " aa " , " bb " , " cc " , " bb " , " aa " , " aa " , " aa " } ; replaceDuplicates ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static void convert_to_allzeroes ( String str , int a , int b ) { int len = str . length ( ) ; int left_1 , i = 0 ; while ( i < len && str . charAt ( i ) == '0' ) i ++ ; left_1 = i ; int right_1 ; i = len - 1 ; while ( i >= 0 && str . charAt ( i ) == '0' ) i -- ; right_1 = i ; if ( left_1 == len && right_1 == - 1 ) { System . out . print ( 0 ) ; return ; } int cost = a , zeroes ; for ( i = left_1 ; i <= right_1 ; i ++ ) { zeroes = 0 ; while ( i < len && str . charAt ( i ) == '0' ) { zeroes ++ ; i ++ ; } if ( zeroes != 0 ) cost += Math . min ( zeroes * b , a ) ; } System . out . print ( cost ) ; } public static void main ( String [ ] args ) { String str = "01101110" ; int A = 5 , B = 1 ; convert_to_allzeroes ( str , A , B ) ; } }

Accumulator variables: cost, i, zeroes
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class solution { static int MinDistK ( int arr [ ] , int N , int K ) { int res = Integer . MAX_VALUE ; int dist = 0 ; for ( int i = 0 ; i <= ( N - K ) ; i ++ ) { if ( arr [ i ] >= 0 && arr [ i + K - 1 ] >= 0 ) { dist = Math . max ( arr [ i ] , arr [ i + K - 1 ] ) ; } else { dist = Math . abs ( arr [ i ] ) + Math . abs ( arr [ i + K - 1 ] ) + Math . min ( Math . abs ( arr [ i ] ) , Math . abs ( arr [ i + K - 1 ] ) ) ; } res = Math . min ( res , dist ) ; } return res ; } public static void main ( String args [ ] ) { int K = 3 ; int arr [ ] = { - 30 , - 10 , 10 , 20 , 50 } ; int N = arr . length ; System . out . println ( MinDistK ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: solution
Java program:
import java . util . * ; class solution { static int min1 ( int a [ ] , int n ) { int minIndex = 0 , minValue = a [ 0 ] , i ; for ( i = 1 ; i < n ; i ++ ) { if ( a [ i ] < minValue ) { minValue = a [ i ] ; minIndex = i ; } } return minIndex ; } static int maximizeMin ( int A [ ] , int N , int S , int M ) { int minIndex , left , right , i , j ; for ( i = 0 ; i < M ; i ++ ) { minIndex = min1 ( A , N ) ; A [ minIndex ] ++ ; left = minIndex - 1 ; right = minIndex + 1 ; for ( j = 0 ; j < S - 1 ; j ++ ) { if ( left == - 1 ) A [ right ++ ] ++ ; else if ( right == N ) A [ left -- ] ++ ; else { if ( A [ left ] < A [ right ] ) A [ left -- ] ++ ; else A [ right ++ ] ++ ; } } } minIndex = min1 ( A , N ) ; return A [ minIndex ] ; } public static void main ( String args [ ] ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; int N = arr . length ; int S = 2 , M = 3 ; System . out . print ( maximizeMin ( arr , N , S , M ) ) ; } }

Index/key variables: i, left, minIndex, right
Accumulator variables: i, j, left, right
Iterator variables: i, j
Class/struct names: solution
Java program:
import java . util . * ; class GFG { static int sumOfPathNodes ( int N ) { if ( N == 1 ) { return 1 ; } else if ( N == 2 N == 3 ) { return N + 1 ; } Vector < Integer > arr = new Vector < > ( ) ; arr . add ( 1 ) ; int k = 1 ; boolean flag = true ; while ( k < N ) { if ( flag == true ) { k *= 2 ; flag = false ; } else { k *= 4 ; flag = true ; } if ( k > N ) { break ; } arr . add ( k ) ; } int len = arr . size ( ) ; int [ ] prefix = new int [ len ] ; prefix [ 0 ] = 1 ; for ( int i = 1 ; i < len ; ++ i ) { prefix [ i ] = arr . get ( i ) + prefix [ i - 1 ] ; } int it = lowerBound ( prefix , 0 , len , N ) + 1 ; int ind = it - prefix [ 0 ] ; int final_ans = 0 ; int temp = N ; while ( ind > 1 ) { int val = temp - prefix [ ind - 1 ] ; if ( ind % 2 != 0 ) { temp = prefix [ ind - 2 ] + ( val + 1 ) / 2 ; } else { temp = prefix [ ind - 2 ] + ( val + 3 ) / 4 ; } -- ind ; final_ans += temp ; } final_ans += ( N + 1 ) ; return final_ans ; } static int lowerBound ( int [ ] a , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( element > a [ middle ] ) low = middle + 1 ; else high = middle ; } return low ; } public static void main ( String [ ] args ) { int N = 13 ; System . out . print ( sumOfPathNodes ( N ) + "NEW_LINE"); } }

Index/key variables: i, len, middle
Accumulator variables: final_ans, k
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean checkPointRange ( int arr [ ] [ ] , int X , int Y , int N ) { for ( int i = 0 ; i < N ; i ++ ) { double dist = Math . sqrt ( ( arr [ i ] [ 0 ] - X ) * ( arr [ i ] [ 0 ] - X ) + ( arr [ i ] [ 1 ] - Y ) * ( arr [ i ] [ 1 ] - Y ) ) ; if ( dist <= arr [ i ] [ 2 ] ) { return true ; } } return false ; } public static void main ( String [ ] args ) { int arr [ ] [ ] = { { 1 , 1 , 3 } , { 10 , 10 , 3 } , { 15 , 15 , 15 } } ; int X = 5 , Y = 5 ; int N = arr . length ; if ( checkPointRange ( arr , X , Y , N ) ) { System . out . print ( " True " ) ; } else { System . out . print ( " False " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void findWinner ( int arr [ ] , int N ) { int odd = 0 ; int even = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] % 2 == 1 ) { odd ++ ; } else { even ++ ; } } if ( even == 0 ) { if ( odd % 2 == 0 ) { System . out . println ( " Player ▁ 2" ) ; } else if ( odd % 2 == 1 ) { System . out . println ( " Player ▁ 1" ) ; } } else if ( even == 1 && odd % 2 == 1 ) { System . out . println ( " Player ▁ 1" ) ; } else { System . out . println ( - 1 ) ; } } public static void main ( String args [ ] ) { int arr [ ] = { 3 , 1 , 9 , 7 } ; int N = arr . length ; findWinner ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static void rearrangeArrMaxcntMinima ( int arr [ ] , int N ) { Arrays . sort ( arr ) ; int left = 0 ; int right = N / 2 ; while ( left < N / 2 right < N ) { if ( right < N ) { System . out . print ( arr [ right ] + " ▁ " ) ; right ++ ; } if ( left < N / 2 ) { System . out . print ( arr [ left ] + " ▁ " ) ; left ++ ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 } ; int N = arr . length ; rearrangeArrMaxcntMinima ( arr , N ) ; } }

Index/key variables: left, right
Accumulator variables: left, right
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MOD = ( int ) 1e9 + 7 ; static int minJumps ( String seats ) { Vector < Integer > position = new Vector < > ( ) ; int count = 0 ; int len = seats . length ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( seats . charAt ( i ) == ' x ' ) { position . add ( i - count ) ; count ++ ; } } if ( count == len count == 0 ) return 0 ; int med_index = ( count - 1 ) / 2 ; int med_val = position . get ( med_index ) ; int ans = 0 ; for ( int i = 0 ; i < position . size ( ) ; i ++ ) { ans = ( ans % MOD + Math . abs ( position . get ( i ) - med_val ) % MOD ) % MOD ; } return ans % MOD ; } public static void main ( String [ ] args ) { String S = " . . . . x . . xx . . . x . . " ; System . out . print ( minJumps ( S ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int singlePrimeFactor ( int N ) { HashSet < Integer > disPrimeFact = new HashSet < > ( ) ; for ( int i = 2 ; i * i <= N ; ++ i ) { while ( N % i == 0 ) { disPrimeFact . add ( i ) ; N /= i ; } } if ( N != 1 ) { disPrimeFact . add ( N ) ; } if ( disPrimeFact . size ( ) == 1 ) { for ( int i : disPrimeFact ) return i ; } return - 1 ; } static int cntsingleFactorPair ( int arr [ ] , int N ) { int countOf1 = 0 ; HashMap < Integer , Integer > mp = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) { countOf1 ++ ; continue ; } int factorValue = singlePrimeFactor ( arr [ i ] ) ; if ( factorValue == - 1 ) { continue ; } else { if ( mp . containsKey ( factorValue ) ) mp . put ( factorValue , mp . get ( factorValue ) + 1 ) ; else mp . put ( factorValue , 1 ) ; } } int res = 0 ; for ( Map . Entry < Integer , Integer > it : mp . entrySet ( ) ) { int X = it . getValue ( ) ; res += countOf1 * X + ( X * ( X - 1 ) ) / 2 ; } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 } ; int N = arr . length ; System . out . print ( cntsingleFactorPair ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: N, countOf1, i, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MincntBothPalin ( char [ ] str1 , char [ ] str2 , int N ) { int i = 0 ; int j = N - 1 ; int cntOp = 0 ; while ( i < j ) { if ( str1 [ i ] == str1 [ j ] && str2 [ i ] != str2 [ j ] ) { cntOp += 1 ; } else if ( str1 [ i ] != str1 [ j ] && str2 [ i ] == str2 [ j ] ) { cntOp += 1 ; } else if ( str1 [ i ] != str1 [ j ] && str2 [ i ] != str2 [ j ] ) { if ( str1 [ i ] == str2 [ j ] && str2 [ i ] == str1 [ j ] ) { cntOp += 1 ; } else { cntOp += 2 ; } } i += 1 ; j -= 1 ; } return cntOp ; } public static void main ( String [ ] args ) { String str1 = " dbba " ; String str2 = " abcd " ; int N = str1 . length ( ) ; System . out . print ( MincntBothPalin ( str1 . toCharArray ( ) , str2 . toCharArray ( ) , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: cntOp, i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int power ( int x , int N ) { int res = 1 ; while ( N > 0 ) { if ( ( N & 1 ) != 0 ) { res = ( res * x ) ; } x = ( x * x ) ; N = N >> 1 ; } return res ; } static void findValX_Y ( int N ) { if ( N <= 1 ) { System . out . println ( - 1 ) ; return ; } int xMax ; xMax = ( int ) Math . log ( N ) ; int yMax ; yMax = ( int ) ( Math . log ( N ) / Math . log ( 5.0 ) ) ; for ( int i = 1 ; i <= xMax ; i ++ ) { for ( int j = 1 ; j <= yMax ; j ++ ) { int a = power ( 2 , i ) ; int b = power ( 5 , j ) ; if ( a + b == N ) { System . out . print ( i + " ▁ " + j ) ; return ; } } } System . out . println ( " - 1" ) ; } public static void main ( String args [ ] ) { int N = 129 ; findValX_Y ( N ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countPairs ( int v1 [ ] , int v2 [ ] , int n , int m , int k ) { int count = 0 ; if ( n <= m ) { Arrays . sort ( v1 ) ; for ( int j = 0 ; j < m ; j ++ ) { int index = lowerBound ( v1 , 0 , n , v2 [ j ] - k ) ; count += index ; } } else { Arrays . sort ( v2 ) ; for ( int i = 0 ; i < n ; i ++ ) { int index = upperBound ( v2 , 0 , m , v1 [ i ] + k ) ; count += m - index ; } } return count ; } static int lowerBound ( int [ ] a , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( element > a [ middle ] ) low = middle + 1 ; else high = middle ; } return low ; } static int upperBound ( int [ ] a , int low , int high , int element ) { while ( low < high ) { int middle = low + ( high - low ) / 2 ; if ( a [ middle ] > element ) high = middle ; else low = middle + 1 ; } return low ; } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 9 , 1 , 8 } ; int brr [ ] = { 10 , 12 , 7 , 4 , 2 , 3 } ; int K = 3 ; int N = arr . length ; int M = brr . length ; System . out . print ( countPairs ( arr , brr , N , M , K ) ) ; } }

Index/key variables: i, j, middle
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Node { int key ; Vector < Node > child = new Vector < > ( ) ; } ; static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; return temp ; } static void Siblings ( Node root , int value ) { int flag = 0 ; if ( root == null ) return ; Queue < Node > q = new LinkedList < > ( ) ; q . add ( root ) ; while ( ! q . isEmpty ( ) ) { Node temp = q . peek ( ) ; q . remove ( ) ; for ( int i = 0 ; i < temp . child . size ( ) ; i ++ ) { if ( temp . child . get ( i ) . key == value ) { flag = 1 ; for ( int j = 0 ; j < temp . child . size ( ) ; j ++ ) { if ( value != temp . child . get ( j ) . key ) System . out . print ( temp . child . get ( j ) . key + " ▁ " ) ; } break ; } q . add ( temp . child . get ( i ) ) ; } } if ( flag == 0 ) System . out . print ( " No ▁ siblings ! ! " ) ; } static Node constructTree ( ) { Node root = newNode ( 10 ) ; ( root . child ) . add ( newNode ( 20 ) ) ; ( root . child ) . add ( newNode ( 30 ) ) ; ( root . child ) . add ( newNode ( 40 ) ) ; ( root . child . get ( 0 ) . child ) . add ( newNode ( 50 ) ) ; ( root . child . get ( 0 ) . child ) . add ( newNode ( 60 ) ) ; ( root . child . get ( 1 ) . child ) . add ( newNode ( 70 ) ) ; ( root . child . get ( 1 ) . child ) . add ( newNode ( 80 ) ) ; ( root . child . get ( 2 ) . child ) . add ( newNode ( 90 ) ) ; ( root . child . get ( 2 ) . child ) . add ( newNode ( 100 ) ) ; ( root . child . get ( 2 ) . child ) . add ( newNode ( 110 ) ) ; return root ; } public static void main ( String [ ] args ) { Node root = constructTree ( ) ; int X = 30 ; Siblings ( root , X ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, Node