dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; public class GFG { static void findSubstring ( string S ) { string T = " " ; string ans = " " ; int l = 0 ; T += S [ 0 ] ; for ( int i = 1 ; i < S . Length ; i ++ ) { if ( Math . Abs ( S [ i ] - S [ i - 1 ] ) == 1 ) { l = T . Length ; if ( l > ans . Length ) { ans = T ; } T = " " ; T += S [ i ] ; } else { T += S [ i ] ; } } l = T . Length ; if ( l > ans . Length ) { ans = T ; } Console . Write ( ans ) ; } public static void Main ( String [ ] args ) { string S = " aabdml " ; findSubstring ( S ) ; } }

Index/key variables: i
Accumulator variables: T, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void findMinLength ( int [ ] arr , int N ) { int front = 0 , back = N - 1 ; while ( front < back ) { int x = arr [ front ] ; if ( arr [ front ] != arr [ back ] ) break ; while ( arr [ front ] == x && front <= back ) front ++ ; while ( arr [ back ] == x && front <= back ) back -- ; } Console . WriteLine ( back - front + 1 ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 2 , 3 , 3 , 1 , 2 , 2 , 1 } ; int N = arr . Length ; findMinLength ( arr , N ) ; } }

Index/key variables: back, front
Accumulator variables: back, front
Class/struct names: GFG
C# program:
using System ; public class GFG { static void prefixArr ( int [ ] arr , int [ , ] prefix , int N ) { for ( int i = 0 ; i < N ; i ++ ) { if ( i == 0 ) { prefix [ i , 0 ] = arr [ i ] ; prefix [ i , 1 ] = arr [ i ] ; } else { prefix [ i , 0 ] = Math . Max ( prefix [ i - 1 , 0 ] , arr [ i ] ) ; prefix [ i , 1 ] = Math . Min ( prefix [ i - 1 , 1 ] , arr [ i ] ) ; } } } static void suffixArr ( int [ ] arr , int [ , ] suffix , int N ) { for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( i == N - 1 ) { suffix [ i , 0 ] = arr [ i ] ; suffix [ i , 1 ] = arr [ i ] ; } else { suffix [ i , 0 ] = Math . Max ( suffix [ i + 1 , 0 ] , arr [ i ] ) ; suffix [ i , 1 ] = Math . Min ( suffix [ i + 1 , 1 ] , arr [ i ] ) ; } } } static void maxAndmin ( int [ , ] prefix , int [ , ] suffix , int N , int L , int R ) { int maximum , minimum ; if ( L == 0 && R == N - 1 ) { Console . WriteLine ( " No ▁ maximum ▁ and ▁ minimum ▁ value " ) ; return ; } else if ( L == 0 ) { maximum = suffix [ R + 1 , 0 ] ; minimum = suffix [ R + 1 , 1 ] ; } else if ( R == N - 1 ) { maximum = prefix [ L - 1 , 0 ] ; minimum = prefix [ R - 1 , 1 ] ; } else { maximum = Math . Max ( prefix [ L - 1 , 0 ] , suffix [ R + 1 , 0 ] ) ; minimum = Math . Min ( prefix [ L - 1 , 1 ] , suffix [ R + 1 , 1 ] ) ; } Console . WriteLine ( maximum + " ▁ " + minimum ) ; } static void MinMaxQueries ( int [ ] a , int [ , ] Q ) { int N = a . GetLength ( 0 ) ; int q = Q . GetLength ( 0 ) ; int [ , ] prefix = new int [ N , 2 ] ; int [ , ] suffix = new int [ N , 2 ] ; prefixArr ( a , prefix , N ) ; suffixArr ( a , suffix , N ) ; for ( int i = 0 ; i < q ; i ++ ) { int L = Q [ i , 0 ] ; int R = Q [ i , 1 ] ; maxAndmin ( prefix , suffix , N , L , R ) ; } } static public void Main ( ) { int [ ] arr = { 2 , 3 , 1 , 8 , 3 , 5 , 7 , 4 } ; int [ , ] queries = { { 4 , 6 } , { 0 , 4 } , { 3 , 7 } , { 2 , 5 } } ; MinMaxQueries ( arr , queries ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static string finddigits ( string s ) { int [ ] arr = new int [ 10 ] ; string ans = " " ; int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' z ' ) arr [ 0 ] ++ ; if ( s [ i ] == ' w ' ) arr [ 2 ] ++ ; if ( s [ i ] == ' g ' ) arr [ 8 ] ++ ; if ( s [ i ] == ' x ' ) arr [ 6 ] ++ ; if ( s [ i ] == ' v ' ) arr [ 5 ] ++ ; if ( s [ i ] == ' o ' ) arr [ 1 ] ++ ; if ( s [ i ] == ' s ' ) arr [ 7 ] ++ ; if ( s [ i ] == ' f ' ) arr [ 4 ] ++ ; if ( s [ i ] == ' h ' ) arr [ 3 ] ++ ; if ( s [ i ] == ' i ' ) arr [ 9 ] ++ ; } arr [ 7 ] -= arr [ 6 ] ; arr [ 5 ] -= arr [ 7 ] ; arr [ 4 ] -= arr [ 5 ] ; arr [ 1 ] -= ( arr [ 2 ] + arr [ 4 ] + arr [ 0 ] ) ; arr [ 3 ] -= arr [ 8 ] ; arr [ 9 ] -= ( arr [ 5 ] + arr [ 6 ] + arr [ 8 ] ) ; for ( int i = 0 ; i < 10 ; i ++ ) { for ( int j = 0 ; j < arr [ i ] ; j ++ ) { ans += ( char ) ( i + '0' ) ; } } return ans ; } static public void Main ( ) { string s = " owoftnuoer " ; Console . WriteLine ( finddigits ( s ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void check ( string s1 , string s2 ) { int s1_0 = 0 , s2_0 = 0 ; for ( int i = 0 ; i < s1 . Length ; i ++ ) { if ( s1 [ i ] == '0' ) { s1_0 ++ ; } if ( s2 [ i ] == '0' ) { s2_0 ++ ; } } if ( s1_0 != s2_0 ) { Console . WriteLine ( " NO " ) ; return ; } else { int Count1 = 0 , Count2 = 0 ; for ( int i = 0 ; i < s1 . Length ; i ++ ) { if ( s1 [ i ] == '0' ) { Count1 ++ ; } if ( s2 [ i ] == '0' ) { Count2 ++ ; } if ( Count1 < Count2 ) { Console . WriteLine ( " NO " ) ; return ; } } Console . WriteLine ( " YES " ) ; } } static void Main ( ) { string s1 = "100111" ; string s2 = "111010" ; check ( s1 , s2 ) ; s1 = "110100" ; s2 = "010101" ; check ( s1 , s2 ) ; } }

Index/key variables: i
Accumulator variables: Count1, Count2, i, s1_0, s2_0
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Text ; class GFG { static void isBinaryStringsEqual ( string str1 , string str2 ) { int str1Zeros = 0 , str1Ones = 0 ; int str2Zeros = 0 , str2Ones = 0 ; int flag = 0 ; int curStr1Ones = 0 ; for ( int i = 0 ; i < str1 . Length ; i ++ ) { if ( str1 [ i ] == '1' ) { str1Ones ++ ; } else if ( str1 [ i ] == '0' ) { str1Zeros ++ ; } if ( str2 [ i ] == '1' ) { str2Ones ++ ; } else if ( str2 [ i ] == '0' ) { str2Zeros ++ ; } } if ( str1Zeros != str2Zeros && str1Ones != str2Ones ) { Console . WriteLine ( " Not ▁ Possible " ) ; } else { for ( int i = 0 ; i < str1 . Length ; i ++ ) { if ( str1 [ i ] != str2 [ i ] ) { if ( str1 [ i ] == '0' && curStr1Ones > 0 ) { StringBuilder sb = new StringBuilder ( str1 ) ; sb [ i ] = '1' ; str1 = sb . ToString ( ) ; curStr1Ones -- ; } if ( str1 [ i ] == '0' && curStr1Ones == 0 ) { flag ++ ; break ; } if ( str1 [ i ] == '1' && str2 [ i ] == '0' ) { StringBuilder sb = new StringBuilder ( str1 ) ; sb [ i ] = '0' ; str1 = sb . ToString ( ) ; curStr1Ones ++ ; } } } if ( flag == 0 ) { Console . WriteLine ( " Possible " ) ; } else { Console . WriteLine ( " Not ▁ Possible " ) ; } } } static public void Main ( ) { string str1 = "0110" ; string str2 = "0011" ; isBinaryStringsEqual ( str1 , str2 ) ; } }

Index/key variables: i
Accumulator variables: curStr1Ones, flag, i, str1Ones, str1Zeros, str2Ones, str2Zeros
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int noOfValidKbers ( int K , int [ ] arr ) { HashSet < int > set = new HashSet < int > ( ) ; while ( K != 0 ) { set . Add ( K % 10 ) ; K = K / 10 ; } int count = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { int no = arr [ i ] ; bool flag = true ; while ( no != 0 ) { int digit = no % 10 ; if ( ! set . Contains ( digit ) ) { flag = false ; break ; } no = no / 10 ; } if ( flag == true ) { count ++ ; } } return count ; } public static void Main ( String [ ] args ) { int K = 12 ; int [ ] arr = { 1 , 12 , 1222 , 13 , 2 } ; Console . WriteLine ( noOfValidKbers ( K , arr ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxN = 100 ; static int [ ] Tree = new int [ 4 * maxN ] ; static void build ( int [ ] arr , int index , int s , int e ) { if ( s == e ) Tree [ index ] = arr [ s ] ; else { int m = ( s + e ) / 2 ; build ( arr , 2 * index , s , m ) ; build ( arr , 2 * index + 1 , m + 1 , e ) ; Tree [ index ] = Math . Max ( Tree [ 2 * index ] , Tree [ 2 * index + 1 ] ) ; } } static int atleast_x ( int index , int s , int e , int ql , int qr , int x ) { if ( ql > e qr < s ) return - 1 ; if ( s <= ql && e <= qr ) { if ( Tree [ index ] < x ) return - 1 ; while ( s != e ) { int m = ( s + e ) / 2 ; if ( Tree [ 2 * index ] >= x ) { e = m ; index = 2 * index ; } else { s = m + 1 ; index = 2 * index + 1 ; } } return s ; } int mm = ( s + e ) / 2 ; int val = atleast_x ( 2 * index , s , mm , ql , qr , x ) ; if ( val != - 1 ) return val ; return atleast_x ( 2 * index + 1 , mm + 1 , e , ql , qr , x ) ; } static void update ( int index , int s , int e , int new_val , int pos ) { if ( s == e ) Tree [ index ] = new_val ; else { int m = ( s + e ) / 2 ; if ( pos <= m ) { update ( 2 * index , s , m , new_val , pos ) ; } else { update ( 2 * index + 1 , m + 1 , e , new_val , pos ) ; } Tree [ index ] = Math . Max ( Tree [ 2 * index ] , Tree [ 2 * index + 1 ] ) ; } } static void printAnswer ( int [ ] arr , int n ) { build ( arr , 1 , 0 , n - 1 ) ; Console . WriteLine ( atleast_x ( 1 , 0 , n - 1 , 0 , n - 1 , 2 ) ) ; arr [ 2 ] = 5 ; update ( 1 , 0 , n - 1 , 5 , 2 ) ; Console . WriteLine ( atleast_x ( 1 , 0 , n - 1 , 0 , n - 1 , 4 ) ) ; Console . WriteLine ( atleast_x ( 1 , 0 , n - 1 , 0 , n - 1 , 0 ) ) ; } static void Main ( ) { int [ ] arr = { 1 , 3 , 2 , 4 , 6 } ; int N = arr . Length ; printAnswer ( arr , N ) ; } }

Index/key variables: index, s
Class/struct names: GFG
C# program:
using System ; class GFG { public class TreeNode { public int val ; public TreeNode left ; public TreeNode right ; public TreeNode ( int data ) { this . val = data ; left = null ; right = null ; } } ; static int find_ht ( TreeNode root ) { if ( root == null ) return 0 ; if ( root . left == null && root . right == null ) return 1 ; return Math . Max ( find_ht ( root . left ) , find_ht ( root . right ) ) + 1 ; } static TreeNode find_node ( TreeNode root , TreeNode req_node ) { if ( root == null ) return req_node ; int left_ht = find_ht ( root . left ) ; int right_ht = find_ht ( root . right ) ; if ( left_ht > right_ht ) { req_node = find_node ( root . left , req_node ) ; } else if ( right_ht > left_ht ) { req_node = find_node ( root . right , req_node ) ; } else { req_node = root ; return req_node ; } return req_node ; } public static void Main ( String [ ] args ) { TreeNode root = new TreeNode ( 1 ) ; root . left = new TreeNode ( 2 ) ; root . right = new TreeNode ( 3 ) ; TreeNode req_node = null ; req_node = find_node ( root , req_node ) ; Console . Write ( req_node . val ) ; } }

Class/struct names: GFG, TreeNode
C# program:
using System ; class GFG { static int maxEvenIntegers ( int [ ] arr , int N , int M ) { int ans = 0 ; for ( int i = 0 ; i <= N - M ; i ++ ) { int cnt = 0 ; for ( int j = 0 ; j < M ; j ++ ) { if ( arr [ i + j ] % 2 == 0 ) cnt ++ ; } ans = Math . Max ( ans , cnt ) ; } return ans ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 3 , 5 , 4 , 7 , 6 } ; int K = 3 ; int N = arr . Length ; Console . WriteLine ( maxEvenIntegers ( arr , N , K ) ) ; } }

Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countDiv ( int [ ] arr ) { int rem0 = 0 ; int rem1 = 0 ; int rem2 = 0 ; foreach ( int i in arr ) { int digitSum = 0 ; digitSum += i ; if ( digitSum % 3 == 0 ) { rem0 += 1 ; } else if ( digitSum % 3 == 1 ) { rem1 += 1 ; } else { rem2 += 1 ; } } return ( rem0 / 2 + Math . Min ( rem1 , rem2 ) ) ; } static void Main ( ) { int [ ] arr = { 5 , 3 , 2 , 8 , 7 } ; Console . Write ( countDiv ( arr ) ) ; } }

Accumulator variables: digitSum, rem0, rem1, rem2
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MaxNonEmpSubSeq ( int [ ] a , int n ) { int sum = 0 ; int max = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( max < a [ i ] ) { max = a [ i ] ; } } if ( max <= 0 ) { return max ; } for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] > 0 ) { sum += a [ i ] ; } } return sum ; } static void Main ( ) { int [ ] arr = { - 2 , 11 , - 4 , 2 , - 3 , - 10 } ; int N = arr . Length ; Console . WriteLine ( MaxNonEmpSubSeq ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long getcount ( long n , int k ) { long res = ( n >> ( k + 1 ) ) << k ; if ( ( ( n >> k ) & 1 ) != 0 ) res += n & ( ( 1 << k ) - 1 ) ; return res ; } static void Main ( ) { long N = 14 ; int K = 2 ; Console . WriteLine ( getcount ( N + 1 , K ) ) ; } }

Accumulator variables: res
Class/struct names: GFG
C# program:
using System ; class GFG { static void splitString ( string S , int N ) { char c = S [ N - 1 ] ; int f = 0 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( S [ i ] == c ) { f = 1 ; break ; } } if ( f != 0 ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( ) { string S = " abcdab " ; int N = S . Length ; splitString ( S , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static char longestLastingBulb ( List < int > onTime , string s ) { char ans ; int n = onTime . Count ; int maxDur = Int32 . MinValue ; int maxPos = Int32 . MinValue ; int currentDiff = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) { currentDiff = onTime [ i ] ; maxDur = currentDiff ; maxPos = i ; } else { currentDiff = onTime [ i ] - onTime [ i - 1 ] ; if ( maxDur < currentDiff ) { maxDur = currentDiff ; maxPos = i ; } else { if ( maxDur == currentDiff ) { char one = s [ i ] ; char two = s [ maxPos ] ; if ( one > two ) { maxDur = currentDiff ; maxPos = i ; } } } } } ans = s [ maxPos ] ; return ans ; } static void Main ( ) { string S = " spuda " ; List < int > arr = new List < int > ( new int [ ] { 12 , 23 , 36 , 46 , 62 } ) ; Console . Write ( longestLastingBulb ( arr , S ) ) ; } }

Index/key variables: i, maxPos
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printNGE ( int [ ] arr , int n ) { Stack < int > s = new Stack < int > ( ) ; int [ ] nge = new int [ n ] ; int i = 0 ; for ( i = 0 ; i < n ; i ++ ) { nge [ i ] = - 1 ; } i = 0 ; while ( i < 2 * n ) { while ( s . Count != 0 && arr [ i % n ] > arr [ s . Peek ( ) ] ) { nge [ s . Peek ( ) ] = arr [ i % n ] ; s . Pop ( ) ; } s . Push ( i % n ) ; i ++ ; } for ( i = 0 ; i < n ; i ++ ) { Console . Write ( nge [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , - 2 , 5 , 8 } ; int N = arr . Length ; printNGE ( arr , N ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = 100005 ; static void SieveOfEratosthenes ( bool [ ] prime , int p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } static int digitProduct ( int number ) { int res = 1 ; while ( number > 0 ) { res *= ( number % 10 ) ; number /= 10 ; } return res ; } static void DistinctCompositeDigitProduct ( int [ ] arr , int n ) { SortedSet < int > output = new SortedSet < int > ( ) ; bool [ ] prime = new bool [ N + 1 ] ; for ( int i = 0 ; i < N + 1 ; i ++ ) { prime [ i ] = true ; } SieveOfEratosthenes ( prime , N ) ; for ( int i = 0 ; i < n ; i ++ ) { int ans = digitProduct ( arr [ i ] ) ; if ( ans <= 1 ) { continue ; } if ( ! prime [ ans ] ) { output . Add ( ans ) ; } } Console . WriteLine ( output . Count ) ; } public static void Main ( ) { int [ ] arr = { 13 , 55 , 7 , 13 , 11 , 71 , 233 , 233 , 144 , 89 } ; int n = arr . Length ; DistinctCompositeDigitProduct ( arr , n ) ; } }

Index/key variables: ans, i, p
Accumulator variables: i, number, p, res
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static ArrayList simpleSieve ( int lmt , ArrayList prime ) { bool [ ] Sieve = new bool [ lmt + 1 ] ; Array . Fill ( Sieve , true ) ; Sieve [ 0 ] = Sieve [ 1 ] = false ; for ( int i = 2 ; i <= lmt ; ++ i ) { if ( Sieve [ i ] == true ) { prime . Add ( i ) ; for ( int j = i * i ; j <= lmt ; j += i ) { Sieve [ j ] = false ; } } } return prime ; } static bool [ ] SegmentedSieveFn ( int low , int high ) { int lmt = ( int ) ( Math . Sqrt ( high ) ) + 1 ; ArrayList prime = new ArrayList ( ) ; prime = simpleSieve ( lmt , prime ) ; int n = high - low + 1 ; bool [ ] segmentedSieve = new bool [ n + 1 ] ; Array . Fill ( segmentedSieve , true ) ; for ( int i = 0 ; i < prime . Count ; i ++ ) { int lowLim = ( int ) ( low / ( int ) prime [ i ] ) * ( int ) prime [ i ] ; if ( lowLim < low ) { lowLim += ( int ) prime [ i ] ; } for ( int j = lowLim ; j <= high ; j += ( int ) prime [ i ] ) { if ( j != ( int ) prime [ i ] ) { segmentedSieve [ j - low ] = false ; } } } return segmentedSieve ; } static int countPairsWhoseSumPrimeL_R ( int L , int R ) { bool [ ] segmentedSieve = SegmentedSieveFn ( L , R ) ; int cntPairs = 0 ; for ( int i = L ; i <= R ; i ++ ) { if ( segmentedSieve [ i - L ] ) { cntPairs += i / 2 ; } } return cntPairs ; } public static void Main ( ) { int L = 1 , R = 5 ; Console . Write ( countPairsWhoseSumPrimeL_R ( L , R ) ) ; } }

Index/key variables: i, j
Accumulator variables: cntPairs, i, j, lowLim
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int count_zeroes ( int n , string str ) { int cnt = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] == '0' ) cnt ++ ; } return cnt ; } static string kReducingStringUtil ( int n , int k , string str , int no_of_zeroes ) { int zeroes_in_2k = ( ( no_of_zeroes ) * ( 2 * k ) ) / n ; int ones_in_2k = 2 * k - zeroes_in_2k ; string temp_str = " " ; for ( int i = 0 ; i < ( zeroes_in_2k ) / 2 ; i ++ ) { temp_str += '0' ; } for ( int i = 0 ; i < ones_in_2k ; i ++ ) { temp_str += '1' ; } for ( int i = 0 ; i < ( zeroes_in_2k ) / 2 ; i ++ ) { temp_str += '0' ; } string final_str = " " ; for ( int i = 0 ; i < n / ( 2 * k ) ; i ++ ) { final_str += ( temp_str ) ; } for ( int i = 0 ; i < n % ( 2 * k ) ; i ++ ) { final_str += temp_str [ i ] ; } return final_str ; } static string kReducingString ( int n , int k , string str ) { int no_of_zeroes = count_zeroes ( n , str ) ; int no_of_ones = n - no_of_zeroes ; if ( no_of_zeroes == 0 no_of_zeroes == n ) { return str ; } if ( k == 1 ) { if ( no_of_zeroes == 0 no_of_zeroes == n ) { return str ; } else { return " Not ▁ Possible " ; } } bool check = false ; for ( int i = ( n / k ) ; i < n ; i += ( n / k ) ) { if ( no_of_zeroes == i no_of_ones == i ) { check = true ; break ; } } if ( check == false ) { return " Not ▁ Possible " ; } return kReducingStringUtil ( n , k , str , no_of_zeroes ) ; } public static void Main ( ) { string str = "0000100001100001" ; int K = 4 ; int N = str . Length ; Console . WriteLine ( kReducingString ( N , K , str ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, final_str, i, temp_str
Iterator variables: i
Boolean variables: check
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countSum ( int [ ] a , int n , int sum ) { int i , j ; int count = 0 ; Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( i = 0 ; i < n - 1 ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { int temp = a [ i ] + a [ j ] ; if ( temp < sum && m . ContainsKey ( sum - temp ) ) count += m [ sum - temp ] ; } for ( j = 0 ; j < i ; j ++ ) { int temp = a [ i ] + a [ j ] ; if ( temp < sum ) if ( m . ContainsKey ( temp ) ) m [ temp ] ++ ; else m . Add ( temp , 1 ) ; } } return count ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 5 , 3 , 1 , 2 , 4 } ; int S = 13 ; int N = arr . Length ; Console . Write ( countSum ( arr , N , S ) ) ; } }

Index/key variables: i, j, temp
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MOD = 1000000007 ; static long modPower ( long x , int y ) { long res = 1 ; x = x % MOD ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( y % 2 == 1 ) res = ( res * x ) % MOD ; y = y / 2 ; x = ( x * x ) % MOD ; } return res ; } static int countPairs ( long [ ] arr , int N ) { int pairCount = 0 ; Dictionary < long , int > hash = new Dictionary < long , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( hash . ContainsKey ( arr [ i ] ) ) { hash . Add ( arr [ i ] , hash [ arr [ i ] ] + 1 ) ; } else { hash . Add ( arr [ i ] , 1 ) ; } } for ( int i = 0 ; i < N ; i ++ ) { long modularInverse = modPower ( arr [ i ] , MOD - 2 ) ; if ( hash . ContainsKey ( modularInverse ) ) pairCount += hash [ modularInverse ] ; if ( arr [ i ] == modularInverse ) { pairCount -- ; } } return pairCount / 2 ; } public static void Main ( ) { long [ ] arr = { 2 , 236426 , 280311812 , 500000004 } ; int N = arr . Length ; Console . WriteLine ( countPairs ( arr , N ) ) ; } }

Index/key variables: i, modularInverse
Accumulator variables: i, pairCount
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static String check ( int [ ] arr , int n ) { Dictionary < int , int > hm = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { hm . Add ( arr [ i ] , 1 ) ; for ( int j = i + 1 ; j < n ; j ++ ) { if ( hm . ContainsKey ( arr [ j ] ) ) hm [ arr [ j ] ] ++ ; else hm . Add ( arr [ j ] , 1 ) ; bool flag = false ; foreach ( int k in hm . Values ) { if ( k == 1 ) { flag = true ; break ; } } if ( ! flag ) return " No " ; } hm . Clear ( ) ; } return " Yes " ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 1 } ; int N = arr . Length ; Console . WriteLine ( check ( arr , N ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j, k
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int find_index ( int [ ] arr , int n , int K ) { int start = 0 ; int end = n - 1 ; while ( start <= end ) { int mid = ( start + end ) / 2 ; if ( arr [ mid ] == K ) return mid ; else if ( arr [ mid ] < K ) start = mid + 1 ; else end = mid - 1 ; } return end + 1 ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 5 , 6 } ; int n = arr . Length ; int K = 2 ; Console . WriteLine ( find_index ( arr , n , K ) ) ; } }

Index/key variables: mid
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int computePos ( int [ ] arr , int n , int value ) { if ( value < arr [ 0 ] ) return 0 ; if ( value > arr [ n - 1 ] ) return n - 1 ; int start = 0 ; int end = n - 1 ; while ( start < end ) { int mid = ( start + end + 1 ) / 2 ; if ( arr [ mid ] >= value ) end = mid - 1 ; else start = mid ; } return start ; } static void countShift ( int [ ] arr , int n , List < List < int > > queries ) { foreach ( List < int > q in queries ) { int index = q [ 0 ] ; int update = q [ 1 ] ; int newElement = arr [ index ] + update ; int newIndex = computePos ( arr , n , newElement ) ; Console . Write ( Math . Abs ( newIndex - index ) + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 , 5 , 6 } ; int N = arr . Length ; List < List < int > > queries = new List < List < int > > ( ) ; List < int > v = new List < int > ( ) ; List < int > v1 = new List < int > ( ) ; v . Add ( 0 ) ; v . Add ( - 1 ) ; queries . Add ( v ) ; v1 . Add ( 4 ) ; v1 . Add ( - 11 ) ; queries . Add ( v1 ) ; countShift ( arr , N , queries ) ; } }

Index/key variables: index, mid
Iterator variables: q
Class/struct names: GFG