dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static String findString ( String s , int k ) { int n = s . length ( ) ; String ans = " ▁ " ; Stack < Integer > st = new Stack < > ( ) ; boolean [ ] vis = new boolean [ n ] ; Vector < boolean > vis ( n , false ) ; int count = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( s . charAt ( i ) == ' ( ' ) { st . add ( i ) ; } if ( count < k && s . charAt ( i ) == ' ) ' ) { vis [ st . peek ( ) ] = true ; st . pop ( ) ; vis [ i ] = true ; count += 2 ; } } for ( int i = 0 ; i < n ; ++ i ) { if ( vis [ i ] == true ) { ans += s . charAt ( i ) ; } } return ans ; } public static void main ( String [ ] args ) { String s = " ( ) ( ) ( ) " ; int K = 2 ; System . out . print ( findString ( s , K ) ) ; } }

Index/key variables: i, n
Accumulator variables: ans, count
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static HashMap < Integer , Boolean > mp = new HashMap < Integer , Boolean > ( ) ; static int max_v , rootIndex ; static class Node { int key ; Node left , right ; } ; static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = temp . right = null ; return ( temp ) ; } static Vector < Integer > findNodes ( Node root ) { if ( root == null ) { return new Vector < Integer > ( ) ; } Vector < Integer > left = findNodes ( root . left ) ; Vector < Integer > right = findNodes ( root . right ) ; Vector < Integer > combined = new Vector < Integer > ( ) ; int count = 0 ; for ( int i = 0 ; i < left . size ( ) ; i ++ ) { if ( left . get ( i ) < root . key ) { count += 1 ; } combined . add ( left . get ( i ) ) ; } for ( int i = 0 ; i < right . size ( ) ; i ++ ) { if ( right . get ( i ) < root . key ) { count += 1 ; } combined . add ( right . get ( i ) ) ; } combined . add ( root . key ) ; if ( count > max_v ) { rootIndex = root . key ; max_v = count ; } return combined ; } public static void main ( String [ ] args ) { Node root = newNode ( 3 ) ; root . left = newNode ( 4 ) ; root . right = newNode ( 6 ) ; root . right . left = newNode ( 4 ) ; root . right . right = newNode ( 5 ) ; root . left . left = newNode ( 10 ) ; root . left . right = newNode ( 2 ) ; max_v = 0 ; rootIndex = - 1 ; findNodes ( root ) ; System . out . print ( rootIndex ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { static int MaximumPath ( int [ ] [ ] grid ) { int N = grid . length ; int M = grid [ 0 ] . length ; int [ ] [ ] sum = new int [ N + 1 ] [ M + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= M ; j ++ ) { sum [ i ] [ j ] = Math . max ( sum [ i - 1 ] [ j ] , sum [ i ] [ j - 1 ] ) + grid [ i - 1 ] [ j - 1 ] ; } } return sum [ N ] [ M ] ; } public static void main ( String [ ] args ) { int [ ] [ ] grid = { { 1 , 2 } , { 3 , 5 } } ; System . out . print ( MaximumPath ( grid ) ) ; } }

Index/key variables: M, N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { static int Maxcost ( String s , int [ ] cost ) { ' ' ▁ Initialize ▁ the ▁ count ' '' int maxcost = 0 ; int i = 0 ; while ( i < s . length ( ) - 1 ) { if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) { if ( cost [ i ] > cost [ i + 1 ] ) maxcost += cost [ i ] ; else { maxcost += cost [ i + 1 ] ; cost [ i + 1 ] = cost [ i ] ; } } i ++ ; } return maxcost ; } public static void main ( String [ ] args ) { String s = " abaac " ; int [ ] cost = { 1 , 2 , 3 , 4 , 5 } ; System . out . print ( Maxcost ( s , cost ) ) ; } }

Index/key variables: i
Accumulator variables: i, maxcost
Class/struct names: GFG
Java program:
import java . util . * ; import java . awt . Point ; public class Main { static HashMap < Point , Integer > dp = new HashMap < Point , Integer > ( ) ; static int countMagicNumbers ( int idx , int sum , int [ ] a , int n , int m , int l , int r ) { if ( idx == n ) { int Temp = sum % m ; if ( Temp == l || Temp == r || ( Temp > l && Temp < r ) ) { dp . put ( new Point ( idx , sum ) , 1 ) ; return dp . get ( new Point ( idx , sum ) ) ; } else { dp . put ( new Point ( idx , sum ) , 0 ) ; return dp . get ( new Point ( idx , sum ) ) ; } } Point curr = new Point ( idx , sum ) ; if ( dp . containsKey ( curr ) ) return dp . get ( curr ) ; int ls = countMagicNumbers ( idx + 1 , sum + a [ idx ] , a , n , m , l , r ) ; int rs = countMagicNumbers ( idx + 1 , sum + ( a [ idx ] - 1 ) , a , n , m , l , r ) ; int temp1 = Math . max ( ls , rs ) ; int temp = sum % m ; if ( ( temp == l || temp == r || ( temp > l && temp < r ) ) && idx != 0 ) { temp1 += 1 ; } dp . put ( new Point ( idx , sum ) , temp1 ) ; return dp . get ( new Point ( idx , sum ) ) ; } public static void main ( String [ ] args ) { int N = 5 , M = 22 , L = 14 , R = 16 ; int [ ] arr = { 17 , 11 , 10 , 8 , 15 } ; System . out . print ( countMagicNumbers ( 0 , 0 , arr , N , M , L , R ) ) ; } }

Index/key variables: idx
Accumulator variables: temp1
Class/struct names: Main
Java program:
import java . util . * ; import java . lang . * ; class GFG { static boolean reachesBottom ( int [ ] [ ] a ) { int n = a . length ; int m = a [ 0 ] . length ; Deque < int [ ] > q = new LinkedList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( a [ i ] [ j ] == 1 ) { q . addFirst ( new int [ ] { i , j , 1 } ) ; } else if ( a [ i ] [ j ] == 2 ) { q . addLast ( new int [ ] { i , j , 2 } ) ; } a [ i ] [ j ] = 0 ; } } int dx [ ] = { - 1 , 0 , 1 , 0 } ; int dy [ ] = { 0 , 1 , 0 , - 1 } ; while ( ! q . isEmpty ( ) ) { int [ ] front = q . peekFirst ( ) ; q . removeFirst ( ) ; int i = front [ 0 ] , j = front [ 1 ] ; int t = front [ 2 ] ; if ( a [ i ] [ j ] == 1 ) continue ; a [ i ] [ j ] = 1 ; if ( t == 1 && ( i == n - 1 && j == m - 1 ) ) { return true ; } for ( int d = 0 ; d < 4 ; d ++ ) { int ni = i + dx [ d ] ; int nj = j + dy [ d ] ; if ( ni >= 0 && ni < n && nj >= 0 && nj < m ) { q . addLast ( new int [ ] { ni , nj , t } ) ; } } } return false ; } public static void main ( String [ ] args ) { int [ ] [ ] matrix = { { 0 , 2 , 0 } , { 0 , 1 , 0 } , { 0 , 2 , 0 } } ; if ( reachesBottom ( matrix ) ) { System . out . print ( " YES " ) ; } else { System . out . print ( " NO " ) ; } } }

Index/key variables: d, i, j
Accumulator variables: d, i, j
Iterator variables: d, i, j
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { public static int [ ] [ ] matrixMinimum ( int [ ] [ ] nums , int K ) { int N = nums . length ; int M = nums [ 0 ] . length ; int [ ] [ ] res = new int [ N - K + 1 ] [ M - K + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M - K + 1 ; j ++ ) { int min = Integer . MAX_VALUE ; for ( int k = j ; k < j + K ; k ++ ) { min = Math . min ( min , nums [ i ] [ k ] ) ; } nums [ i ] [ j ] = min ; } } for ( int j = 0 ; j < M ; j ++ ) { for ( int i = 0 ; i < N - K + 1 ; i ++ ) { int min = Integer . MAX_VALUE ; for ( int k = i ; k < i + K ; k ++ ) { min = Math . min ( min , nums [ k ] [ j ] ) ; } nums [ i ] [ j ] = min ; } } for ( int i = 0 ; i < N - K + 1 ; i ++ ) for ( int j = 0 ; j < M - K + 1 ; j ++ ) res [ i ] [ j ] = nums [ i ] [ j ] ; return res ; } public static void smallestinKsubmatrices ( int arr [ ] [ ] , int K ) { int [ ] [ ] res = matrixMinimum ( arr , K ) ; for ( int i = 0 ; i < res . length ; i ++ ) { for ( int j = 0 ; j < res [ 0 ] . length ; j ++ ) { System . out . print ( res [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; } } public static void main ( String [ ] args ) { int [ ] [ ] arr = { { - 1 , 5 , 4 , 1 , - 3 } , { 4 , 3 , 1 , 1 , 6 } , { 2 , - 2 , 5 , 3 , 1 } , { 8 , 5 , 1 , 9 , - 4 } , { 12 , 3 , 5 , 8 , 1 } } ; int K = 3 ; smallestinKsubmatrices ( arr , K ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static char find_kth_largest ( char [ ] str , int k ) { Arrays . sort ( str ) ; reverse ( str ) ; return str [ k - 1 ] ; } static char [ ] reverse ( char a [ ] ) { int i , n = a . length ; char t ; for ( i = 0 ; i < n / 2 ; i ++ ) { t = a [ i ] ; a [ i ] = a [ n - i - 1 ] ; a [ n - i - 1 ] = t ; } return a ; } static char printCharacter ( String str , int l , int r , int k ) { l = l - 1 ; r = r - 1 ; String temp = str . substring ( l , r - l + 1 ) ; char ans = find_kth_largest ( temp . toCharArray ( ) , k ) ; return ans ; } static void updateString ( char [ ] str , int pos , char s ) { int index = pos - 1 ; char c = s ; str [ index ] = c ; } public static void main ( String [ ] args ) { String str = " abcddef " ; int Q = 3 ; System . out . print ( printCharacter ( str , 1 , 2 , 2 ) + "NEW_LINE"); updateString ( str . toCharArray ( ) , 4 , ' g ' ) ; System . out . print ( printCharacter ( str , 1 , 5 , 4 ) + "NEW_LINE"); } }

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; import java . lang . * ; class GFG { static int minDiffSubArray ( int arr [ ] , int n ) { int total_sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) total_sum += arr [ i ] ; int prefix_sum = 0 ; int minDiff = Integer . MAX_VALUE ; for ( int i = 0 ; i < n - 1 ; i ++ ) { prefix_sum += arr [ i ] ; int diff = Math . abs ( ( total_sum - prefix_sum ) - prefix_sum ) ; if ( diff < minDiff ) minDiff = diff ; } return minDiff ; } public static void main ( String [ ] args ) { int [ ] arr = { 7 , 9 , 5 , 10 } ; int n = arr . length ; System . out . println ( minDiffSubArray ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, prefix_sum, total_sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int CtSubarr ( int [ ] arr , int N , int K ) { Set < Integer > st = new HashSet < Integer > ( ) ; int prefixSum = 0 ; st . add ( prefixSum ) ; int res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { prefixSum += arr [ i ] ; if ( st . contains ( prefixSum - K ) ) { res += 1 ; prefixSum = 0 ; st . clear ( ) ; st . add ( 0 ) ; } st . add ( prefixSum ) ; } return res ; } public static void main ( String [ ] args ) { int arr [ ] = { - 2 , 6 , 6 , 3 , 5 , 4 , 1 , 2 , 8 } ; int N = arr . length ; int K = 10 ; System . out . println ( CtSubarr ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, prefixSum, res
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean is_prime ( int n ) { if ( n <= 1 ) return false ; for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) return false ; } return true ; } static int count_prime_subarrays ( int ar [ ] , int n ) { int ans = 0 ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( is_prime ( ar [ i ] ) ) count ++ ; else { if ( count != 0 ) { ans += count * ( count + 1 ) / 2 ; count = 0 ; } } } if ( count != 0 ) ans += count * ( count + 1 ) / 2 ; return ans ; } public static void main ( String [ ] args ) { int N = 10 ; int [ ] ar = { 2 , 3 , 5 , 6 , 7 , 11 , 3 , 5 , 9 , 3 } ; System . out . print ( count_prime_subarrays ( ar , N ) ) ; } }

Index/key variables: i
Accumulator variables: ans, count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int minSteps ( int arr [ ] , int n , int k ) { int i , cnt = 0 ; int flag ; if ( k == 1 ) flag = 0 ; else flag = 1 ; for ( i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == flag ) { cnt ++ ; flag = ( flag + 1 ) % 2 ; } } return cnt ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 0 , 1 , 0 , 0 , 1 , 1 , 1 } ; int n = arr . length ; int k = 1 ; System . out . print ( minSteps ( arr , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . util . * ; class GFG { public static int minSum ( int a [ ] , int n , int k ) { PriorityQueue < Integer > maxheap = new PriorityQueue < > ( ( one , two ) -> two - one ) ; for ( int i = 0 ; i < n ; i ++ ) maxheap . add ( a [ i ] ) ; while ( maxheap . size ( ) > 0 && k > 0 ) { int max_ele = maxheap . poll ( ) ; maxheap . add ( max_ele / 2 ) ; k -= 1 ; } int sum = 0 ; while ( maxheap . size ( ) > 0 ) sum += maxheap . poll ( ) ; return sum ; } public static void main ( String [ ] args ) { int n = 4 ; int k = 3 ; int a [ ] = { 20 , 7 , 5 , 4 } ; System . out . println ( minSum ( a , n , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, k, sum
Iterator variables: i
Class/struct names: GFG
Java program:
import java . io . * ; import java . lang . * ; import java . util . * ; class GFG { static void add_seg ( int seg [ ] , int start , int end , int current , int index ) { if ( index > end index < start ) return ; if ( start == end ) { seg [ current ] = 1 ; return ; } int mid = ( start + end ) / 2 ; add_seg ( seg , start , mid , 2 * current + 1 , index ) ; add_seg ( seg , mid + 1 , end , 2 * current + 2 , index ) ; seg [ current ] = seg [ 2 * current + 1 ] + seg [ 2 * current + 2 ] ; } static int deleted ( int seg [ ] , int l , int r , int start , int end , int current ) { if ( end < l start > r ) return 0 ; if ( start >= l && end <= r ) return seg [ current ] ; int mid = ( start + end ) / 2 ; return deleted ( seg , l , r , start , mid , 2 * current + 1 ) + deleted ( seg , l , r , mid + 1 , end , 2 * current + 2 ) ; } static void sumOfIndices ( String s ) { int N = s . length ( ) ; int x = ( int ) ( Math . ceil ( Math . log ( N ) / Math . log ( 2 ) ) ) ; int seg_size = 2 * ( int ) Math . pow ( 2 , x ) - 1 ; int segment [ ] = new int [ seg_size ] ; int count = 0 ; TreeMap < Integer , ArrayDeque < Integer > > fre = new TreeMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int key = ( int ) ( s . charAt ( i ) ) ; ArrayDeque < Integer > que = fre . getOrDefault ( key , new ArrayDeque < > ( ) ) ; que . addLast ( i ) ; fre . put ( key , que ) ; } while ( ! fre . isEmpty ( ) ) { int it = fre . firstKey ( ) ; if ( fre . get ( it ) . size ( ) == 0 ) fre . remove ( it ) ; else { ArrayDeque < Integer > que = fre . get ( it ) ; int original_index = que . getFirst ( ) ; int curr_index = deleted ( segment , 0 , original_index - 1 , 0 , N - 1 , 0 ) ; int new_index = original_index - curr_index ; count += new_index + 1 ; add_seg ( segment , 0 , N - 1 , 0 , original_index ) ; que . removeFirst ( ) ; fre . put ( it , que ) ; } } System . out . println ( count ) ; } public static void main ( String [ ] args ) { String s = " geeksforgeeks " ; sumOfIndices ( s ) ; } }

Index/key variables: current, seg_size
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int spf [ ] = new int [ 100005 ] ; static boolean prime [ ] = new boolean [ 100005 ] ; static int dp [ ] = new int [ 100005 ] ; static void sieve ( ) { prime [ 0 ] = prime [ 1 ] = false ; for ( int i = 2 ; i < 100005 ; i ++ ) prime [ i ] = true ; for ( int i = 2 ; i * i < 100005 ; i ++ ) { if ( prime [ i ] ) { for ( int j = i * i ; j < 100005 ; j += i ) { prime [ j ] = false ; } } } } static void smallestPrimeFactors ( ) { for ( int i = 0 ; i < 100005 ; i ++ ) spf [ i ] = - 1 ; for ( int i = 2 ; i * i < 100005 ; i ++ ) { for ( int j = i ; j < 100005 ; j += i ) { if ( spf [ j ] == - 1 ) { spf [ j ] = i ; } } } } static int sumOfPrimeFactors ( int n ) { int ans = 0 ; while ( n > 1 ) { ans += spf [ n ] ; n /= spf [ n ] ; } return ans ; } static int findLength ( int n ) { if ( prime [ n ] ) { return 1 ; } if ( dp [ n ] != 0 ) { return dp [ n ] ; } int sum = sumOfPrimeFactors ( n ) ; return dp [ n ] = 1 + findLength ( sum ) ; } static int maxLength ( int n , int m ) { sieve ( ) ; smallestPrimeFactors ( ) ; int ans = Integer . MIN_VALUE ; for ( int i = n ; i <= m ; i ++ ) { if ( i == 4 ) { continue ; } ans = Math . max ( ans , findLength ( i ) ) ; } return ans ; } public static void main ( String [ ] args ) { int n = 2 , m = 14 ; System . out . print ( maxLength ( n , m ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: ans, i, j, n
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int largest_subarray ( int a [ ] , int n ) { HashMap < Integer , Integer > index = new HashMap < Integer , Integer > ( ) ; int ans = 0 ; for ( int i = 0 , j = 0 ; i < n ; i ++ ) { j = Math . max ( index . containsKey ( a [ i ] ) ? index . get ( a [ i ] ) : 0 , j ) ; ans = Math . max ( ans , i - j + 1 ) ; index . put ( a [ i ] , i + 1 ) ; } return ans ; } public static void main ( String [ ] args ) { int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 1 , 2 , 3 } ; int n = arr . length ; System . out . print ( largest_subarray ( 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 findWays ( int [ ] nums , int S ) { return dfs ( nums , S , 0 , 0 ) ; } static int dfs ( int [ ] nums , int S , int curr_sum , int index ) { if ( index == nums . length ) { if ( S == curr_sum ) return 1 ; else return 0 ; } return dfs ( nums , S , curr_sum + nums [ index ] , index + 1 ) + dfs ( nums , S , curr_sum - nums [ index ] , index + 1 ) ; } public static void main ( String [ ] args ) { int S = 3 ; int [ ] arr = new int [ ] { 1 , 2 , 3 , 4 , 5 } ; int answer = findWays ( arr , S ) ; System . out . println ( answer ) ; } }

Index/key variables: index
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Node { int key ; Node left , right ; } ; static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = temp . right = null ; return ( temp ) ; } static void frequencyCounts ( HashMap < Integer , Integer > map , Node root ) { if ( root == null ) return ; if ( map . containsKey ( root . key ) ) map . put ( root . key , map . get ( root . key ) + 1 ) ; else map . put ( root . key , 1 ) ; frequencyCounts ( map , root . left ) ; frequencyCounts ( map , root . right ) ; } static int computeDistance ( Node root , int value ) { if ( root == null ) { return - 1 ; } int left = computeDistance ( root . left , value ) ; int right = computeDistance ( root . right , value ) ; if ( left == - 1 && right == - 1 ) { if ( root . key == value ) { return 1 ; } else return - 1 ; } if ( left == - 1 ) { return right + 1 ; } if ( right == - 1 ) { return left + 1 ; } else { return 1 + Math . max ( left , right ) ; } } static void solve ( Node root , int dist ) { HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; frequencyCounts ( map , root ) ; int flag = 0 ; for ( Map . Entry < Integer , Integer > it : map . entrySet ( ) ) { if ( it . getValue ( ) > 1 ) { int result = computeDistance ( root , it . getKey ( ) ) ; if ( result > dist result == - 1 ) { flag = 1 ; break ; } } } if ( flag == 0 ) System . out . print ( "YesNEW_LINE"); else System . out . print ( "NoNEW_LINE"); } public static void main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . right = newNode ( 3 ) ; root . left . left = newNode ( 4 ) ; root . left . right = newNode ( 3 ) ; root . right . right = newNode ( 4 ) ; root . right . left = newNode ( 4 ) ; int dist = 7 ; solve ( root , dist ) ; } }

Class/struct names: GFG, Node
Java program:
import java . util . * ; class GFG { public static void findMinSum ( int A [ ] , int K ) { int n = A . length ; int minimum_sum = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int min = Integer . MAX_VALUE ; for ( int j = i + K ; j < n ; j ++ ) min = Math . min ( min , A [ j ] ) ; if ( min == Integer . MAX_VALUE ) continue ; minimum_sum = Math . min ( minimum_sum , A [ i ] + min ) ; } System . out . println ( minimum_sum ) ; } public static void main ( String [ ] args ) { int A [ ] = { 4 , 2 , 5 , 4 , 3 , 2 , 5 } ; int K = 3 ; findMinSum ( A , K ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static class Node { int data ; Node next ; } ; static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = ( head_ref ) ; ( head_ref ) = new_node ; return head_ref ; } static int distinctCount ( Node head_ref1 ) { Set < Integer > s = new HashSet < Integer > ( ) ; Node ptr1 = head_ref1 ; while ( ptr1 != null ) { s . add ( Math . abs ( ptr1 . data ) ) ; ptr1 = ptr1 . next ; } return s . size ( ) ; } public static void main ( String args [ ] ) { Node head1 = null ; head1 = push ( head1 , - 1 ) ; head1 = push ( head1 , - 2 ) ; head1 = push ( head1 , 0 ) ; head1 = push ( head1 , 4 ) ; head1 = push ( head1 , 5 ) ; head1 = push ( head1 , 8 ) ; int ans = distinctCount ( head1 ) ; System . out . println ( ans ) ; } }

Class/struct names: GFG, Node
Java program:
import java . util . * ; public class MinCostMaxFlow { boolean found [ ] ; int N ; int cap [ ] [ ] ; int flow [ ] [ ] ; int cost [ ] [ ] ; int dad [ ] , dist [ ] , pi [ ] ; static final int INF = Integer . MAX_VALUE / 2 - 1 ; boolean search ( int src , int sink ) { Arrays . fill ( found , false ) ; Arrays . fill ( dist , INF ) ; dist [ src ] = 0 ; while ( src != N ) { int best = N ; found [ src ] = true ; for ( int k = 0 ; k < N ; k ++ ) { if ( found [ k ] ) continue ; if ( flow [ k ] [ src ] != 0 ) { int val = dist [ src ] + pi [ src ] - pi [ k ] - cost [ k ] [ src ] ; if ( dist [ k ] > val ) { dist [ k ] = val ; dad [ k ] = src ; } } if ( flow [ src ] [ k ] < cap [ src ] [ k ] ) { int val = dist [ src ] + pi [ src ] - pi [ k ] + cost [ src ] [ k ] ; if ( dist [ k ] > val ) { dist [ k ] = val ; dad [ k ] = src ; } } if ( dist [ k ] < dist [ best ] ) best = k ; } src = best ; } for ( int k = 0 ; k < N ; k ++ ) pi [ k ] = Math . min ( pi [ k ] + dist [ k ] , INF ) ; return found [ sink ] ; } int [ ] getMaxFlow ( int cap [ ] [ ] , int cost [ ] [ ] , int src , int sink ) { this . cap = cap ; this . cost = cost ; N = cap . length ; found = new boolean [ N ] ; flow = new int [ N ] [ N ] ; dist = new int [ N + 1 ] ; dad = new int [ N ] ; pi = new int [ N ] ; int totflow = 0 , totcost = 0 ; while ( search ( src , sink ) ) { int amt = INF ; for ( int x = sink ; x != src ; x = dad [ x ] ) amt = Math . min ( amt , flow [ x ] [ dad [ x ] ] != 0 ? flow [ x ] [ dad [ x ] ] : cap [ dad [ x ] ] [ x ] - flow [ dad [ x ] ] [ x ] ) ; for ( int x = sink ; x != src ; x = dad [ x ] ) { if ( flow [ x ] [ dad [ x ] ] != 0 ) { flow [ x ] [ dad [ x ] ] -= amt ; totcost -= amt * cost [ x ] [ dad [ x ] ] ; } else { flow [ dad [ x ] ] [ x ] += amt ; totcost += amt * cost [ dad [ x ] ] [ x ] ; } } totflow += amt ; } return new int [ ] { totflow , totcost } ; } public static void main ( String args [ ] ) { MinCostMaxFlow flow = new MinCostMaxFlow ( ) ; int s = 0 , t = 4 ; int cap [ ] [ ] = { { 0 , 3 , 1 , 0 , 3 } , { 0 , 0 , 2 , 0 , 0 } , { 0 , 0 , 0 , 1 , 6 } , { 0 , 0 , 0 , 0 , 2 } , { 0 , 0 , 0 , 0 , 0 } } ; int cost [ ] [ ] = { { 0 , 1 , 0 , 0 , 2 } , { 0 , 0 , 0 , 3 , 0 } , { 0 , 0 , 0 , 0 , 0 } , { 0 , 0 , 0 , 0 , 1 } , { 0 , 0 , 0 , 0 , 0 } } ; int ret [ ] = flow . getMaxFlow ( cap , cost , s , t ) ; System . out . println ( ret [ 0 ] + " ▁ " + ret [ 1 ] ) ; } }

Index/key variables: N, best, k, sink, src, x
Accumulator variables: k, totcost, totflow
Iterator variables: k, x
Class/struct names: MinCostMaxFlow
Java program:
class GFG { static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } static int lcm ( int a , int b ) { return ( a * b ) / __gcd ( a , b ) ; } static int countPair ( int N ) { int count = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = 1 ; j <= N ; j ++ ) { if ( __gcd ( i , j ) + lcm ( i , j ) == N ) { count ++ ; } } } return count ; } public static void main ( String [ ] args ) { int N = 14 ; System . out . print ( countPair ( N ) ) ; } }

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