dhyuti-n/xlcost-variable-roles huggingface dataset:
Java program:
import java . util . * ; class GFG { static String decToBinary ( int n ) { int [ ] binaryNum = new int [ 32 ] ; int i = 0 ; while ( n > 0 ) { binaryNum [ i ] = n % 2 ; n = n / 2 ; i ++ ; } String binary = " " ; for ( int j = i - 1 ; j >= 0 ; j -- ) { binary += String . valueOf ( binaryNum [ j ] ) ; } return binary ; } static int countFreq ( String pat , String txt ) { int M = pat . length ( ) ; int N = txt . length ( ) ; int res = 0 ; for ( int i = 0 ; i <= N - M ; i ++ ) { int j ; for ( j = 0 ; j < M ; j ++ ) { if ( txt . charAt ( i + j ) != pat . charAt ( j ) ) { break ; } } if ( j == M ) { res ++ ; j = 0 ; } } return res ; } static void findOccurrence ( int arr [ ] , int n , String pattern ) { for ( int i = 0 ; i < n ; i ++ ) { String binary = decToBinary ( arr [ i ] ) ; System . out . print ( countFreq ( pattern , binary ) + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 5 , 106 , 7 , 8 } ; String pattern = "10" ; int n = arr . length ; findOccurrence ( arr , n , pattern ) ; } }

Index/key variables: i, j
Accumulator variables: binary, i, j, res
Iterator variables: i, j
Class/struct names: GFG
Java program:
import java . util . Vector ; class GFG { static boolean canBeBalanced ( String s , int n ) { if ( n % 2 == 1 ) return false ; String k = " ( " ; k += s + " ) " ; Vector < String > d = new Vector < > ( ) ; for ( int i = 0 ; i < k . length ( ) ; i ++ ) { if ( k . charAt ( i ) == ' ( ' ) d . add ( " ( " ) ; else { if ( d . size ( ) != 0 ) d . remove ( d . size ( ) - 1 ) ; else return false ; } } if ( d . isEmpty ( ) ) return true ; return false ; } public static void main ( String [ ] args ) { String s = " ) ( ( ) " ; int n = s . length ( ) ; if ( canBeBalanced ( s , n ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Accumulator variables: i, k
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; class GFG { static void find_winner ( String str , int n ) { String str1 = " " , str2 = " " ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { str1 += str . charAt ( i ) ; } else { str2 += str . charAt ( i ) ; } } char a [ ] = str1 . toCharArray ( ) ; Arrays . sort ( a ) ; char b [ ] = str2 . toCharArray ( ) ; Arrays . sort ( b ) ; str1 = new String ( a ) ; str2 = new String ( b ) ; if ( str1 . compareTo ( str2 ) < 0 ) System . out . print ( " A " ) ; else if ( str1 . compareTo ( str2 ) > 0 ) System . out . print ( " B " ) ; else System . out . print ( " Tie " ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int n = str . length ( ) ; find_winner ( str , n ) ; } }

Accumulator variables: i, str1, str2
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int Find_Index ( String str1 , String str2 ) { int n = str1 . length ( ) ; int m = str2 . length ( ) ; int l = 0 ; int r = 0 ; if ( n != m + 1 ) { return - 1 ; } for ( int i = 0 ; i < m ; i ++ ) { if ( str1 . charAt ( i ) == str2 . charAt ( i ) ) { l += 1 ; } else { break ; } } int i = n - 1 ; int j = m - 1 ; while ( i >= 0 && j >= 0 && str1 . charAt ( i ) == str2 . charAt ( j ) ) { r += 1 ; i -= 1 ; j -= 1 ; } if ( l + r < m ) { return - 1 ; } else { i = Math . max ( n - r , 1 ) ; j = Math . min ( l + 1 , n ) ; return ( j - i + 1 ) ; } } public static void main ( String [ ] args ) { String str1 = " aaa " , str2 = " aa " ; System . out . println ( Find_Index ( str1 , str2 ) ) ; } }

Accumulator variables: i, j, l, r
Iterator variables: i
Class/struct names: GFG
Java program:
public class GFG { static void expandString ( String strin ) { String temp = " " ; int j ; for ( int i = 0 ; i < strin . length ( ) ; i ++ ) { if ( strin . charAt ( i ) >= 0 ) { int num = strin . charAt ( i ) - '0' ; if ( strin . charAt ( i + 1 ) == ' ( ' ) { for ( j = i + 1 ; strin . charAt ( j ) != ' ) ' ; j ++ ) { if ( ( strin . charAt ( j ) >= ' a ' && strin . charAt ( j ) <= ' z ' ) || ( strin . charAt ( j ) >= ' A ' && strin . charAt ( j ) <= ' Z ' ) ) { temp += strin . charAt ( j ) ; } } for ( int k = 1 ; k <= num ; k ++ ) { System . out . print ( temp ) ; } num = 0 ; temp = " " ; if ( j < strin . length ( ) ) { i = j ; } } } } } public static void main ( String args [ ] ) { String strin = "3 ( ab ) 4 ( cd ) " ; expandString ( strin ) ; } }

Accumulator variables: i, j, k, temp
Iterator variables: i, j, k
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static String findPrefix ( String str1 , String str2 ) { boolean pos = false ; while ( str1 . length ( ) > 0 ) { if ( ! str2 . contains ( str1 ) ) str1 = str1 . substring ( 0 , str1 . length ( ) - 1 ) ; else { pos = str2 . contains ( str1 ) ; break ; } } if ( pos == false ) return " - 1" ; return str1 ; } public static void main ( String [ ] args ) { String str1 = " geeksfor " ; String str2 = " forgeeks " ; System . out . println ( findPrefix ( str1 , str2 ) ) ; } }

Boolean variables: pos
Class/struct names: GFG
Java program:
import java . util . PriorityQueue ; class GFG { static String getSmallestStr ( String S , int K ) { String X = " " ; PriorityQueue < Character > pq = new PriorityQueue < > ( ) ; int i , n = S . length ( ) ; K = Math . min ( K , n ) ; for ( i = 0 ; i < K ; i ++ ) pq . add ( S . charAt ( i ) ) ; while ( ! pq . isEmpty ( ) ) { X += pq . peek ( ) ; pq . remove ( ) ; if ( i < S . length ( ) ) pq . add ( S . charAt ( i ) ) ; i ++ ; } return X ; } public static void main ( String [ ] args ) { String S = " geeksforgeeks " ; int K = 5 ; System . out . println ( getSmallestStr ( S , K ) ) ; } }

Accumulator variables: X, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static void roundToNearest ( StringBuilder str , int n ) { if ( str . toString ( ) == " " ) return ; if ( str . charAt ( n - 1 ) - '0' <= 5 ) { str . setCharAt ( n - 1 , '0' ) ; System . out . print ( str . substring ( 0 , n ) ) ; } else { int carry = 0 ; str . setCharAt ( n - 1 , '0' ) ; int i = n - 2 ; carry = 1 ; while ( i >= 0 && carry == 1 ) { int currentDigit = str . charAt ( i ) - '0' ; currentDigit += carry ; if ( currentDigit > 9 ) { carry = 1 ; currentDigit = 0 ; } else carry = 0 ; str . setCharAt ( i , ( char ) ( currentDigit + '0' ) ) ; i -- ; } if ( carry == 1 ) System . out . print ( carry ) ; System . out . print ( str . substring ( 0 , n ) ) ; } } public static void main ( String [ ] args ) { StringBuilder str = new StringBuilder ( "99999999999999993" ) ; int n = str . length ( ) ; roundToNearest ( str , n ) ; } }

Accumulator variables: currentDigit, i
Class/struct names: GFG
Java program:
class GFG { static boolean isDigit ( char ch ) { if ( ch >= '0' && ch <= '9' ) return true ; return false ; } static int nextNonDigit ( String str , int i ) { while ( i < str . length ( ) && isDigit ( str . charAt ( i ) ) ) { i ++ ; } if ( i >= str . length ( ) ) return - 1 ; return i ; } static void appendRepeated ( StringBuilder sb , String str , int times ) { for ( int i = 0 ; i < times ; i ++ ) sb . append ( str ) ; } static String findString ( String str , int n ) { StringBuilder sb = new StringBuilder ( " " ) ; int startStr = nextNonDigit ( str , 0 ) ; while ( startStr != - 1 ) { int endStr = startStr ; while ( ( endStr + 1 ) < n && ! isDigit ( str . charAt ( endStr + 1 ) ) ) { endStr ++ ; } int startNum = endStr + 1 ; if ( startNum == - 1 ) break ; int endNum = startNum ; while ( ( endNum + 1 ) < n && isDigit ( str . charAt ( endNum + 1 ) ) ) { endNum ++ ; } int num = Integer . parseInt ( str . substring ( startNum , endNum + 1 ) ) ; appendRepeated ( sb , str . substring ( startStr , endStr + 1 ) , num ) ; startStr = nextNonDigit ( str , endStr + 1 ) ; } return sb . toString ( ) ; } public static void main ( String [ ] args ) { String str = " g1ee1ks1for1g1e2ks1" ; int n = str . length ( ) ; System . out . println ( findString ( str , n ) ) ; } }

Accumulator variables: endNum, endStr, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { public static String replacePi ( String s ) { if ( s . length ( ) == 0 || s . length ( ) == 1 ) return s ; if ( s . charAt ( 0 ) == ' p ' && s . charAt ( 1 ) == ' i ' ) { String smallOutput = replacePi ( s . substring ( 2 ) ) ; return "3.14" + smallOutput ; } else { String smallOutput = replacePi ( s . substring ( 1 ) ) ; return s . charAt ( 0 ) + smallOutput ; } } public static void main ( String [ ] args ) { String s = " pipppiiipi " ; String result = replacePi ( s ) ; System . out . println ( result ) ; } }

Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int MAX = 26 ; static String smallestStr ( char [ ] str , int n ) { int i , j = 0 ; int [ ] chk = new int [ MAX ] ; for ( i = 0 ; i < MAX ; i ++ ) chk [ i ] = - 1 ; for ( i = 0 ; i < n ; i ++ ) { if ( chk [ str [ i ] - ' a ' ] == - 1 ) chk [ str [ i ] - ' a ' ] = i ; } for ( i = 0 ; i < n ; i ++ ) { boolean flag = false ; for ( j = 0 ; j < str [ i ] - ' a ' ; j ++ ) { if ( chk [ j ] > chk [ str [ i ] - ' a ' ] ) { flag = true ; break ; } } if ( flag ) break ; } if ( i < n ) { char ch1 = str [ i ] ; char ch2 = ( char ) ( j + ' a ' ) ; for ( i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ch1 ) str [ i ] = ch2 ; else if ( str [ i ] == ch2 ) str [ i ] = ch1 ; } } return String . valueOf ( str ) ; } public static void main ( String [ ] args ) { String str = " ccad " ; int n = str . length ( ) ; System . out . println ( smallestStr ( str . toCharArray ( ) , n ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
Java program:
class GFG { static int longest_substring ( String s , int k ) { int n = s . length ( ) ; if ( k > 1 ) { s += s ; n *= 2 ; } int ans = 0 ; int i = 0 ; while ( i < n ) { int x = 0 ; while ( i < n && s . charAt ( i ) == '0' ) { x ++ ; i ++ ; } ans = Math . max ( ans , x ) ; i ++ ; } if ( k == 1 ans != n ) return ans ; else return ( ans / 2 ) * k ; } public static void main ( String [ ] args ) { String s = "010001000" ; int k = 4 ; System . out . println ( longest_substring ( s , k ) ) ; } }

Accumulator variables: i, n, s, x
Class/struct names: GFG
Java program:
class GFG { static int Occurrence ( String s , int position ) { int count = 0 ; for ( int i = 0 ; i < position - 1 ; i ++ ) if ( s . charAt ( i ) == s . charAt ( position - 1 ) ) count ++ ; return count ; } public static void main ( String [ ] args ) { String s = " ababababab " ; int p = 9 ; System . out . println ( Occurrence ( s , p ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static int countOccurrence ( String s , int position ) { int [ ] alpha = new int [ 26 ] ; int [ ] b = new int [ s . length ( ) ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { b [ i ] = alpha [ ( int ) s . charAt ( i ) - 97 ] ; alpha [ ( int ) s . charAt ( i ) - 97 ] ++ ; } return b [ position - 1 ] ; } public static void main ( String [ ] args ) { String s = " ababababab " ; int p = 9 ; System . out . println ( countOccurrence ( s , p ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int MAX = 26 ; public static boolean canBeMapped ( String s1 , int l1 , String s2 , int l2 ) { if ( l1 != l2 ) return false ; int [ ] freq1 = new int [ MAX ] ; int [ ] freq2 = new int [ MAX ] ; for ( int i = 0 ; i < l1 ; i ++ ) freq1 [ s1 . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < l2 ; i ++ ) freq2 [ s2 . charAt ( i ) - ' a ' ] ++ ; for ( int i = 0 ; i < MAX ; i ++ ) { if ( freq1 [ i ] == 0 ) continue ; boolean found = false ; for ( int j = 0 ; j < MAX ; j ++ ) { if ( freq1 [ i ] == freq2 [ j ] ) { freq2 [ j ] = - 1 ; found = true ; break ; } } if ( ! found ) return false ; } return true ; } public static void main ( String [ ] args ) { String s1 = " axx " ; String s2 = " cbc " ; int l1 = s1 . length ( ) ; int l2 = s2 . length ( ) ; if ( canBeMapped ( s1 , l1 , s2 , l2 ) ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: found
Class/struct names: GFG
Java program:
import java . util . HashSet ; class GFG { static HashSet < String > stringSet = new HashSet < > ( ) ; public static void find_permutation ( String str1 , String str2 , int len1 , int len2 , int i , int j , String res ) { if ( res . length ( ) == len1 + len2 ) { stringSet . add ( res ) ; return ; } if ( i < len1 ) find_permutation ( str1 , str2 , len1 , len2 , i + 1 , j , res + str1 . charAt ( i ) ) ; if ( j < len2 ) find_permutation ( str1 , str2 , len1 , len2 , i , j + 1 , res + str2 . charAt ( j ) ) ; } public static void print_set ( ) { for ( String s : stringSet ) System . out . println ( s ) ; } public static void main ( String [ ] args ) { String str1 = " aa " , str2 = " ab " ; int len1 = str1 . length ( ) ; int len2 = str2 . length ( ) ; find_permutation ( str1 , str2 , len1 , len2 , 0 , 0 , " " ) ; print_set ( ) ; } }

Iterator variables: s
Class/struct names: GFG
Java program:
class GFG { public static void generateStr ( String a , String b , String s , int count , int len ) { if ( count == len ) { System . out . println ( s ) ; return ; } generateStr ( a . substring ( 1 ) , b . substring ( 1 ) , s + a . charAt ( 0 ) , count + 1 , len ) ; generateStr ( a . substring ( 1 ) , b . substring ( 1 ) , s + b . charAt ( 0 ) , count + 1 , len ) ; } public static void main ( String [ ] args ) { String a = " abc " , b = " def " ; int n = a . length ( ) ; generateStr ( a , b , " " , 0 , n ) ; } }

Class/struct names: GFG
Java program:
class GFG { static int countSubStr ( char [ ] s , int n ) { int count = 0 ; for ( int i = 0 ; i < n - 2 { if ( s [ i ] == '0' && s [ i + 1 ] == '1' && s [ i + 2 ] == '0' ) { count ++ ; i += 3 ; } else if ( s [ i ] == '1' && s [ i + 1 ] == '0' && s [ i + 2 ] == '1' ) { count ++ ; i += 3 ; } else { i ++ ; } } return count ; } public static void main ( String [ ] args ) { char [ ] s = "10101010101" . toCharArray ( ) ; int n = s . length ; System . out . println ( countSubStr ( s , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . HashSet ; class geeks { public static int countTotalDistinct ( String str ) { int cnt = 0 ; HashSet < String > items = new HashSet < > ( ) ; for ( int i = 0 ; i < str . length ( ) ; ++ i ) { String temp = " " ; HashSet < Character > ans = new HashSet < > ( ) ; for ( int j = i ; j < str . length ( ) ; ++ j ) { temp = temp + str . charAt ( j ) ; ans . add ( str . charAt ( j ) ) ; if ( ! items . contains ( temp ) ) { items . add ( temp ) ; cnt += ans . size ( ) ; } } } return cnt ; } public static void main ( String [ ] args ) { String str = " ABCA " ; System . out . println ( countTotalDistinct ( str ) ) ; } }

Accumulator variables: cnt
Iterator variables: i, j
Class/struct names: geeks
Java program:
import java . util . * ; class GFG { static void division_of_string ( char [ ] str , int k ) { int n = str . length ; Map < Character , Boolean > has = new HashMap < > ( ) ; int ans = 0 , cnt = 0 , i = 0 ; while ( i < n ) { if ( ! has . containsKey ( str [ i ] ) ) { cnt ++ ; has . put ( str [ i ] , true ) ; } if ( cnt == k ) { ans = i ; break ; } i ++ ; } i ++ ; has . clear ( ) ; cnt = 0 ; while ( i < n ) { if ( ! has . containsKey ( str [ i ] ) ) { cnt ++ ; has . put ( str [ i ] , true ) ; } if ( cnt == k ) { break ; } i ++ ; } if ( cnt < k ) { System . out . println ( " Not ▁ possible " ) ; } else { i = 0 ; while ( i <= ans ) { System . out . print ( str [ i ] ) ; i ++ ; } System . out . println ( " " ) ; while ( i < n ) { System . out . print ( str [ i ] ) ; i ++ ; } System . out . println ( " " ) ; } System . out . println ( " " ) ; } public static void main ( String [ ] args ) { String str = " geeksforgeeks " ; int k = 4 ; division_of_string ( str . toCharArray ( ) , k ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Class/struct names: GFG
Java program:
import java . util . * ; class GFG { static boolean isVowel ( char c ) { return ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) ; } static int countSubstringsUtil ( char [ ] s ) { int count = 0 ; Map < Character , Integer > mp = new HashMap < > ( ) ; int n = s . length ; int start = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . containsKey ( s [ i ] ) ) { mp . put ( s [ i ] , mp . get ( s [ i ] ) + 1 ) ; } else { mp . put ( s [ i ] , 1 ) ; } while ( mp . containsKey ( ' a ' ) && mp . containsKey ( ' e ' ) && mp . containsKey ( ' i ' ) && mp . containsKey ( ' o ' ) && mp . containsKey ( ' u ' ) && mp . get ( ' a ' ) > 0 && mp . get ( ' e ' ) > 0 && mp . get ( ' i ' ) > 0 && mp . get ( ' o ' ) > 0 && mp . get ( ' u ' ) > 0 ) { count += n - i ; mp . put ( s [ start ] , mp . get ( s [ start ] ) - 1 ) ; start ++ ; } } return count ; } static int countSubstrings ( String s ) { int count = 0 ; String temp = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( isVowel ( s . charAt ( i ) ) ) { temp += s . charAt ( i ) ; } else { if ( temp . length ( ) > 0 ) count += countSubstringsUtil ( temp . toCharArray ( ) ) ; temp = " " ; } } if ( temp . length ( ) > 0 ) count += countSubstringsUtil ( temp . toCharArray ( ) ) ; return count ; } public static void main ( String [ ] args ) { String s = " aeouisddaaeeiouua " ; System . out . println ( countSubstrings ( s ) ) ; } }

Index/key variables: i, start
Accumulator variables: count, i, start, temp
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static String removeDuplicates ( String S ) { String ans = " " ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { if ( ans . isEmpty ( ) || ans . charAt ( ans . length ( ) - 1 ) != S . charAt ( i ) ) ans += S . charAt ( i ) ; else if ( ans . charAt ( ans . length ( ) - 1 ) == S . charAt ( i ) ) ans = ans . substring ( 0 , ans . length ( ) - 1 ) ; } return ans ; } public static void main ( String [ ] args ) { String str = " keexxllx " ; System . out . println ( removeDuplicates ( str ) ) ; } }

Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static String swap ( String str , int i , int j ) { StringBuilder sb = new StringBuilder ( str ) ; sb . setCharAt ( i , str . charAt ( j ) ) ; sb . setCharAt ( j , str . charAt ( i ) ) ; return sb . toString ( ) ; } static String reverseWords ( String str ) { int start = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' ▁ ' || i == str . length ( ) - 1 ) { int end ; if ( i == str . length ( ) - 1 ) end = i ; else end = i - 1 ; while ( start < end ) { str = swap ( str , start , end ) ; start ++ ; end -- ; } start = i + 1 ; } } return str ; } public static void main ( String args [ ] ) { String str = " Geeks ▁ for ▁ Geeks " ; System . out . println ( reverseWords ( str ) ) ; } }

Accumulator variables: end, i, start
Iterator variables: i
Class/struct names: GFG
Java program:
import java . util . Arrays ; import java . util . Stack ; class GFG { static void reverse ( String k ) { Stack < String > s = new Stack < > ( ) ; String [ ] token = k . split ( " ▁ " ) ; for ( int i = 0 ; i < token . length ; i ++ ) { s . push ( token [ i ] ) ; } while ( ! s . empty ( ) ) { System . out . print ( s . peek ( ) + " ▁ " ) ; s . pop ( ) ; } } public static void main ( String [ ] args ) { String k = " geeks ▁ for ▁ geeks " ; reverse ( k ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
Java program:
class GFG { static int countSubString ( String s , char c , int k ) { int leftCount = 0 , rightCount = 0 ; int left = 0 , right = 0 ; int freq = 0 ; int result = 0 , len = s . length ( ) ; while ( s . charAt ( left ) != c && left < len ) { left ++ ; leftCount ++ ; } right = left + 1 ; while ( freq != ( k - 1 ) && ( right - 1 ) < len ) { if ( s . charAt ( right ) == c ) { freq ++ ; } right ++ ; } while ( left < len && ( right - 1 ) < len ) { while ( s . charAt ( left ) != c && left < len ) { left ++ ; leftCount ++ ; } while ( right < len && s . charAt ( right ) != c ) { if ( s . charAt ( right ) == c ) { freq ++ ; } right ++ ; rightCount ++ ; } result = result + ( leftCount + 1 ) * ( rightCount + 1 ) ; freq = k - 1 ; leftCount = 0 ; rightCount = 0 ; left ++ ; right ++ ; } return result ; } public static void main ( String args [ ] ) { String s = "3123231" ; char c = '3' ; int k = 2 ; System . out . println ( countSubString ( s , c , k ) ) ; } }

Accumulator variables: freq, left, leftCount, right, rightCount
Class/struct names: GFG
Java program:
import java . io . * ; class GFG { static int solve ( String test , int MOD ) { int size = test . length ( ) ; int total = 0 ; for ( int i = 0 ; i <= 8 ; i ++ ) { int x = i ; int y = i + 1 ; String newtest = " " ; for ( int j = 0 ; j < size ; j ++ ) { if ( test . charAt ( j ) == x + 48 || test . charAt ( j ) == y + 48 ) { newtest += test . charAt ( j ) ; } } if ( newtest . length ( ) > 0 ) { int size1 = newtest . length ( ) ; int [ ] prefix = new int [ size1 ] ; for ( int j = 0 ; j < size1 ; j ++ ) { prefix [ j ] = 0 ; if ( newtest . charAt ( j ) == y + 48 ) { prefix [ j ] ++ ; } } for ( int j = 1 ; j < size1 ; j ++ ) { prefix [ j ] += prefix [ j - 1 ] ; } int count = 0 ; int firstcount = 0 ; int ss = 0 ; int prev = 0 ; for ( int j = 0 ; j < size1 ; j ++ ) { if ( newtest . charAt ( j ) == x + 48 ) { count ++ ; firstcount ++ ; } else { ss += count * count ; int pairsum = ( firstcount * firstcount - ss ) / 2 ; int temp = pairsum ; pairsum -= prev ; prev = temp ; int secondway = prefix [ size1 - 1 ] ; if ( j != 0 ) secondway -= prefix [ j - 1 ] ; int answer = count * ( count - 1 ) * secondway * ( secondway - 1 ) ; answer /= 4 ; answer += ( pairsum * secondway * ( secondway - 1 ) ) / 2 ; total += answer ; count = 0 ; } } } } return total ; } public static void main ( String [ ] args ) { String test = "13134422" ; int MOD = 1000000007 ; System . out . println ( solve ( test , MOD ) ) ; } }

Index/key variables: j, size1
Accumulator variables: answer, count, firstcount, i, j, newtest, pairsum, secondway, ss, total
Iterator variables: i, j
Class/struct names: GFG
Java program:
class sol { static boolean isPossible ( int l , int m , int x , int y ) { if ( l * m == x + y ) return true ; return false ; } public static void main ( String args [ ] ) { int l = 3 , m = 2 , x = 4 , y = 2 ; if ( isPossible ( l , m , x , y ) ) System . out . print ( " Yes " ) ; else System . out . print ( " No " ) ; } }

Class/struct names: sol
Java program:
import java . util . Arrays ; class GFG { static int MAX = 26 ; static int countPairs ( char [ ] str , int k ) { int n = str . length ; int [ ] freq = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) { freq [ str [ i ] - ' a ' ] ++ ; } int cnt = 0 ; if ( k == 0 ) { for ( int i = 0 ; i < MAX ; i ++ ) { if ( freq [ i ] > 1 ) { cnt += ( ( freq [ i ] * ( freq [ i ] - 1 ) ) / 2 ) ; } } } else { for ( int i = 0 ; i < MAX ; i ++ ) { if ( freq [ i ] > 0 && i + k < MAX && freq [ i + k ] > 0 ) { cnt += ( freq [ i ] * freq [ i + k ] ) ; } } ; } return cnt ; } public static void main ( String [ ] args ) { String str = " abcdab " ; int k = 0 ; System . out . println ( countPairs ( str . toCharArray ( ) , k ) ) ; } }

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