dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countStrings ( String S , String [ ] list ) { HashSet < char > valid = new HashSet < char > ( ) ; foreach ( char x in S . ToCharArray ( ) ) { valid . Add ( x ) ; } int cnt = 0 ; for ( int i = 0 ; i < list . Length ; i ++ ) { int j = 0 ; for ( j = 0 ; j < list [ i ] . Length ; j ++ ) { if ( valid . Contains ( list [ i ] [ j ] ) ) continue ; else break ; } if ( j == list [ i ] . Length ) cnt ++ ; } return cnt ; } public static void Main ( String [ ] args ) { String [ ] arr = { " ab " , " aab " , " abaaaa " , " bbd " } ; String S = " ab " ; Console . Write ( countStrings ( S , arr ) + " STRNEWLINE " ) ; } }

Index/key variables: i, j
Accumulator variables: cnt, i, j
Iterator variables: i, j, x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minLength ( String str , int N , String K , int M ) { Stack < char > stackOfChar = new Stack < char > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { stackOfChar . Push ( str [ i ] ) ; if ( stackOfChar . Count >= M ) { String l = " " ; for ( int j = M - 1 ; j >= 0 ; j -- ) { if ( K [ j ] != stackOfChar . Peek ( ) ) { int f = 0 ; while ( f != l . Length ) { stackOfChar . Push ( l [ f ] ) ; f ++ ; } break ; } else { l = stackOfChar . Peek ( ) + l ; stackOfChar . Pop ( ) ; } } } } return stackOfChar . Count ; } public static void Main ( String [ ] args ) { String S1 = " fffoxoxoxfxo " ; String S2 = " fox " ; int N = S1 . Length ; int M = S2 . Length ; Console . Write ( minLength ( S1 , N , S2 , M ) ) ; } }

Index/key variables: f, i, j
Accumulator variables: f, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static void palindrome_prod ( String N ) { List < int > palindrome_list = new List < int > ( ) ; for ( int i = 101 ; i < 1000 ; i ++ ) { for ( int j = 121 ; j < 1000 ; j += ( i % 11 == 0 ) ? 1 : 11 ) { int n = i * j ; String x = String . Join ( " " , n ) ; String y = x ; reverse ( y ) ; if ( x == y ) { if ( n < Int32 . Parse ( N ) ) { palindrome_list . Add ( i * j ) ; } } } } Console . Write ( palindrome_list . Max ( ) ) ; } static String reverse ( String input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = a . Length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . Join ( " " , a ) ; } public static void Main ( String [ ] args ) { String N = "101110" ; palindrome_prod ( N ) ; } }

Index/key variables: l, r
Accumulator variables: i, j, l, r
Iterator variables: i, j, l
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isEqualStrings ( string [ ] arr , int N ) { int M = arr [ 0 ] . Length ; int [ ] cntFreq = new int [ 256 ] ; for ( int i = 0 ; i < N ; i ++ ) { cntFreq [ i ] = 0 ; } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { cntFreq [ arr [ i ] [ j ] - ' a ' ] += 1 ; } } for ( int i = 0 ; i < 256 ; i ++ ) { if ( cntFreq [ i ] % N != 0 ) { return false ; } } return true ; } public static void Main ( ) { string [ ] arr = { " aab " , " bbc " , " cca " } ; int N = arr . Length ; if ( isEqualStrings ( arr , N ) ) { Console . WriteLine ( " YES " ) ; } else { Console . WriteLine ( " NO " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void PrintStack ( Stack < char > s ) { if ( s . Count == 0 ) return ; char x = s . Peek ( ) ; s . Pop ( ) ; PrintStack ( s ) ; Console . Write ( ( char ) x ) ; s . Push ( x ) ; } static void minString ( String s ) { Stack < char > Stack = new Stack < char > ( ) ; Stack . Push ( s [ 0 ] ) ; for ( int i = 1 ; i < s . Length ; i ++ ) { if ( Stack . Count == 0 ) { Stack . Push ( s [ i ] ) ; } else { if ( Stack . Peek ( ) == s [ i ] ) { Stack . Pop ( ) ; } else { Stack . Push ( s [ i ] ) ; } } } PrintStack ( Stack ) ; } public static void Main ( String [ ] args ) { String str = "101001" ; minString ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int count_of_accident ( String a , String b ) { int n = a . Length , m = b . Length ; if ( n > m ) return ( m * ( m + 1 ) ) / 2 ; else return ( n * ( n + 1 ) ) / 2 + ( m - n ) * n ; } static double count_of_collision ( String a , String b ) { int n = a . Length , m = b . Length ; double answer = 0 ; int count_of_truck_in_lane_b = 0 ; for ( int i = 0 ; i < m ; i ++ ) if ( b [ i ] == ' T ' ) count_of_truck_in_lane_b ++ ; for ( int i = 0 ; i < n && i < m ; i ++ ) { if ( a [ i ] == ' T ' ) answer += count_of_truck_in_lane_b ; if ( b [ i ] == ' T ' ) count_of_truck_in_lane_b -- ; } return answer ; } static void findProbability ( String a , String b ) { int total_outcome = count_of_accident ( a , b ) ; double favourable_outcome = count_of_collision ( a , b ) ; Console . Write ( " { 0 : F4 } " , favourable_outcome / total_outcome ) ; } public static void Main ( String [ ] args ) { String S = " TCCBCTTB " , T = " BTCCBBTT " ; findProbability ( S , T ) ; } }

Index/key variables: i
Accumulator variables: answer, count_of_truck_in_lane_b, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int power ( int x , int y , int p ) { int res = 1 ; x = x % p ; if ( x == 0 ) return 0 ; while ( y > 0 ) { if ( ( y & 1 ) == 1 ) res = ( res * x ) % p ; y = y >> 1 ; x = ( x * x ) % p ; } return res ; } public static void Main ( ) { int N = 3 ; int flag , k , m = 0 ; if ( ( N == 1 ) || ( N == 2 ) ) Console . Write ( 62 ) ; else m = 1000000000 + 7 ; if ( N % 2 == 0 ) { k = N / 2 ; flag = 1 ; } else { k = ( N - 1 ) / 2 ; flag = 0 ; } if ( flag != 0 ) { int a = power ( 62 , k , m ) ; Console . Write ( a ) ; } else { int a = power ( 62 , ( k + 1 ) , m ) ; Console . Write ( a ) ; } } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int lenOflongestReqSubstr ( String s , int N ) { Dictionary < int , int > ind = new Dictionary < int , int > ( ) ; int mask = 0 ; ind . Add ( 0 , - 1 ) ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int val = s [ i ] - '0' ; mask ^= ( 1 << val ) ; if ( ind . ContainsKey ( mask ) ) { ans = Math . Max ( ans , i - ind [ mask ] ) ; } else ind . Add ( mask , i ) ; } return ans ; } public static void Main ( String [ ] args ) { String s = "223015150" ; int N = s . Length ; Console . Write ( lenOflongestReqSubstr ( s , N ) ) ; } }

Index/key variables: i, mask
Accumulator variables: i, mask
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int uniqueMorseRep ( String [ ] arr ) { String [ ] morseCode = { " . - " , " - . . . " , " - . - . " , " - . . " , " . " , " . . - . " , " - - . " , " . . . . " , " . . " , " . - - - " , " - . - " , " . - . . " , " - - " , " - . " , " - - - " , " . - - . " , " - - . - " , " . - . " , " . . . " , " - " , " . . - " , " . . . - " , " . - - " , " - . . - " , " - . - - " , " - - . . " } ; HashSet < String > st = new HashSet < String > ( ) ; int N = arr . Length ; for ( int i = 0 ; i < N ; i ++ ) { String temp = " " ; int M = arr [ i ] . Length ; for ( int j = 0 ; j < M ; j ++ ) { temp += morseCode [ arr [ i ] [ j ] - ' a ' ] ; } st . Add ( temp ) ; } return st . Count ; } public static void Main ( String [ ] args ) { String [ ] arr = { " gig " , " zeg " , " gin " , " msn " } ; Console . Write ( uniqueMorseRep ( arr ) + " STRNEWLINE " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, temp
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static void findFreq ( String str , int N ) { int [ ] freq = new int [ 256 ] ; int max = 0 ; char charMax = '0' ; for ( int i = 0 ; i < N ; i ++ ) { char ch = str [ i ] ; freq [ ch ] ++ ; if ( freq [ ch ] >= max ) { max = freq [ ch ] ; charMax = ch ; } Console . WriteLine ( charMax + " ▁ - > ▁ " + max ) ; } } public static void Main ( String [ ] args ) { String str = " abbc " ; int N = str . Length ; findFreq ( str , N ) ; } }

Index/key variables: ch, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinCost ( string str , int pos ) { int n = str . Length ; char [ ] charArray = str . ToCharArray ( ) ; if ( pos >= n / 2 ) { Array . Reverse ( charArray ) ; pos = n - pos - 1 ; } int left , right ; left = right = pos ; for ( int i = pos ; i >= 0 ; -- i ) { if ( charArray [ i ] != charArray [ n - i - 1 ] ) { left = i ; } } for ( int i = pos ; i < n / 2 ; ++ i ) { if ( charArray [ i ] != charArray [ n - i - 1 ] ) { right = i ; } } int ans = 0 ; for ( int i = left ; i <= right ; ++ i ) { if ( charArray [ i ] != charArray [ n - i - 1 ] ) ans += 1 ; } int dis = Math . Min ( ( 2 * ( pos - left ) + ( right - pos ) ) , ( 2 * ( right - pos ) + ( pos - left ) ) ) ; ans = ans + dis ; return ans ; } public static void Main ( ) { string S = " bass " ; int P = 3 ; Console . Write ( findMinCost ( S , P ) ) ; } }

Index/key variables: i
Accumulator variables: ans
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minCost ( string s , int n ) { int minValue = 100000000 ; for ( int i = 0 ; i <= 25 ; i ++ ) { int cnt = 0 ; for ( int j = 0 ; j < n ; j ++ ) { cnt += Math . Min ( Math . Abs ( i - ( s [ j ] - ' a ' ) ) , 26 - Math . Abs ( i - ( s [ j ] - ' a ' ) ) ) ; } minValue = Math . Min ( minValue , cnt ) ; } return minValue ; } public static void Main ( ) { string str = " geeksforgeeks " ; int N = str . Length ; Console . WriteLine ( minCost ( str , N ) ) ; } }

Index/key variables: j
Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static String reverse ( String input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = a . Length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . Join ( " " , a ) ; } static void max_len ( String [ ] s , int N , int M ) { HashSet < String > set_str = new HashSet < String > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { set_str . Add ( s [ i ] ) ; } List < String > left_ans = new List < String > ( ) ; List < String > right_ans = new List < String > ( ) ; String mid = " " ; for ( int i = 0 ; i < N ; i ++ ) { String t = s [ i ] ; t = reverse ( t ) ; if ( t == s [ i ] ) { mid = t ; } else if ( set_str . Contains ( t ) ) { left_ans . Add ( s [ i ] ) ; right_ans . Add ( t ) ; set_str . Remove ( s [ i ] ) ; set_str . Remove ( t ) ; } } foreach ( String x in left_ans ) { Console . Write ( x ) ; } Console . Write ( mid ) ; right_ans . Reverse ( ) ; foreach ( String x in right_ans ) { Console . Write ( x ) ; } } public static void Main ( String [ ] args ) { int N = 4 , M = 3 ; String [ ] s = { " omg " , " bbb " , " ffd " , " gmo " } ; max_len ( s , N , M ) ; } }

Index/key variables: i, l, r
Accumulator variables: i, l, r
Iterator variables: i, l, x
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimum_length ( int x1 , int y1 , int x2 , int y2 , string str ) { int n = str . Length ; int pos1 , pos2 , pos3 , pos4 ; pos1 = - 1 ; pos2 = - 1 ; pos3 = - 1 ; pos4 = - 1 ; if ( x1 == x2 && y1 == y2 ) { Console . WriteLine ( "0" ) ; } else { for ( int i = 0 ; i < n ; i ++ ) { if ( x2 > x1 ) { if ( str [ i ] == ' E ' ) { x1 = x1 + 1 ; if ( x1 == x2 ) { pos1 = i ; } } } if ( x2 < x1 ) { if ( str [ i ] == ' W ' ) { x1 = x1 - 1 ; if ( x1 == x2 ) { pos2 = i ; } } } if ( y2 > y1 ) { if ( str [ i ] == ' N ' ) { y1 = y1 + 1 ; if ( y1 == y2 ) { pos3 = i ; } } } if ( y2 < y1 ) { if ( str [ i ] == ' S ' ) { y1 = y1 - 1 ; if ( y1 == y2 ) { pos4 = i ; } } } } int z ; z = Math . Max ( pos1 , Math . Max ( Math . Max ( pos2 , pos3 ) , pos4 ) ) ; if ( x1 == x2 && y1 == y2 ) { Console . WriteLine ( z + 1 ) ; } else { Console . WriteLine ( " - 1" ) ; } } } public static void Main ( ) { string str = " SESNW " ; int x1 = 0 , x2 = 1 , y1 = 0 , y2 = 1 ; minimum_length ( x1 , y1 , x2 , y2 , str ) ; } }

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 String ShortenString ( String str1 ) { Stack < char > st = new Stack < char > ( ) ; int i = 0 ; while ( i < str1 . Length ) { if ( st . Count == 0 || ( st . Count != 0 && str1 [ i ] != st . Peek ( ) ) ) { st . Push ( str1 [ i ] ) ; i ++ ; } else { if ( st . Count != 0 ) st . Pop ( ) ; i ++ ; } } if ( st . Count == 0 ) { return ( " Empty ▁ String " ) ; } else { String short_String = " " ; while ( st . Count != 0 ) { short_String = st . Peek ( ) + short_String ; st . Pop ( ) ; } return ( short_String ) ; } } public static void Main ( String [ ] args ) { String str1 = " azzxzy " ; Console . Write ( ShortenString ( str1 ) ) ; } }

Index/key variables: i
Accumulator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int fact ( int n ) { int res = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { res = res * i ; } return res ; } static int distinctWays ( string str1 , string str2 ) { int n = str1 . Length ; int m = str2 . Length ; if ( n == m ) { return 2 * fact ( n ) * fact ( m ) ; } return fact ( n ) * fact ( m ) ; } public static void Main ( ) { string str1 = " aegh " ; string str2 = " rsw " ; Console . Write ( distinctWays ( str1 , str2 ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static string len ( long A , long B ) { string res = " " ; long log = 0 ; do { log = ( long ) ( Math . Log ( B ) / Math . Log ( 2 ) ) ; if ( log != 0 ) { res += A + " < < " + log ; } else { res += A ; break ; } B = B - ( long ) Math . Pow ( 2 , log ) ; if ( B != 0 ) { res += " + " ; } else break ; } while ( log != 0 ) ; return res ; } public static void minimumString ( long A , long B ) { string res1 = len ( A , B ) ; string res2 = len ( B , A ) ; if ( res1 . Length > res2 . Length ) { Console . WriteLine ( res2 ) ; } else { Console . WriteLine ( res1 ) ; } } public static void Main ( ) { long A = 6 ; long B = 10 ; minimumString ( A , B ) ; } }

Accumulator variables: res
Class/struct names: GFG
C# program:
using System ; class GFG { static void countSubString ( String s ) { int res = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { int x = 0 ; for ( int j = i ; j < s . Length ; j ++ ) { int temp = 1 << s [ j ] - ' a ' ; x ^= temp ; if ( ( x & ( x - 1 ) ) == 0 ) res ++ ; } } Console . Write ( res ) ; } public static void Main ( String [ ] args ) { String str = " aaa " ; countSubString ( str ) ; } }

Index/key variables: j
Accumulator variables: i, j, res, x
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void countSubString ( String s ) { int answer = 0 ; Dictionary < int , int > m = new Dictionary < int , int > ( ) ; m . Add ( 0 , 1 ) ; int x = 0 ; for ( int j = 0 ; j < s . Length ; j ++ ) { x ^= 1 << ( s [ j ] - ' a ' ) ; answer += m . ContainsKey ( x ) ? m [ x ] : 0 ; for ( int i = 0 ; i < 26 ; ++ i ) { answer += m . ContainsKey ( x ^ ( 1 << i ) ) ? m [ x ^ ( 1 << i ) ] : 0 ; } if ( m . ContainsKey ( x ) ) m [ x ] = m [ x ] + 1 ; else m . Add ( x , 1 ) ; } Console . Write ( answer ) ; } public static void Main ( String [ ] args ) { String str = " abab " ; countSubString ( str ) ; } }

Index/key variables: j, x
Accumulator variables: answer, j, x
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void printResult ( List < int > result ) { result . Reverse ( ) ; int i = 0 ; while ( i < result . Count ) { Console . Write ( result [ i ] ) ; i ++ ; } } static void sumOfLargeNumbers ( String [ ] v , int k , int N ) { List < List < int > > x = new List < List < int > > ( 1000 ) ; for ( int i = 0 ; i < k ; i ++ ) x . Add ( new List < int > ( ) ) ; for ( int i = 0 ; i < k ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { x [ i ] . Add ( v [ i ] [ j ] - '0' ) ; } } int carry = 0 ; List < int > result = new List < int > ( ) ; for ( int i = N - 1 ; i >= 0 ; i -- ) { int sum = 0 ; for ( int j = 0 ; j < k ; j ++ ) sum += x [ j ] [ i ] ; sum += carry ; int temp = sum ; int count = 0 ; while ( temp > 9 ) { temp = temp % 10 ; count ++ ; } long l = ( long ) Math . Pow ( 10 , count ) ; if ( l != 1 ) carry = ( int ) ( sum / l ) ; sum = sum % 10 ; result . Add ( sum ) ; } while ( carry != 0 ) { int a = carry % 10 ; result . Add ( a ) ; carry = carry / 10 ; } printResult ( result ) ; } public static void Main ( String [ ] args ) { int K = 10 ; int N = 5 ; String [ ] arr = { "1111111111" , "1111111111" , "1111111111" , "1111111111" , "1111111111" } ; sumOfLargeNumbers ( arr , N , K ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void printRev ( string str ) { Stack st = new Stack ( ) ; String [ ] separator = { " ▁ " } ; string [ ] ss = str . Split ( separator , int . MaxValue , StringSplitOptions . RemoveEmptyEntries ) ; foreach ( string temp in ss ) { st . Push ( temp ) ; } while ( st . Count > 0 ) { Console . Write ( st . Peek ( ) + " ▁ " ) ; st . Pop ( ) ; } } public static void Main ( string [ ] args ) { string str ; str = " geeks ▁ quiz ▁ practice ▁ code " ; printRev ( str ) ; } }

Iterator variables: temp
Class/struct names: GFG
C# program:
using System ; class GFG { static int countOfSubstringWithOnlyOnes ( string s ) { int res = 0 , count = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { count = s [ i ] == '1' ? count + 1 : 0 ; res = ( res + count ) ; } return res ; } public static void Main ( string [ ] args ) { string s = "0110111" ; Console . Write ( countOfSubstringWithOnlyOnes ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly long mod = 1000000007 ; static long binExp ( long Base , long power ) { long x = 1 ; while ( power != 0 ) { if ( power % 2 == 1 ) x = ( ( x % mod ) * ( Base % mod ) ) % mod ; Base = ( ( Base % mod ) * ( Base % mod ) ) % mod ; power = power / 2 ; } return x ; } static long fact ( long num ) { long result = 1 ; for ( long i = 1 ; i <= num ; ++ i ) { result = ( ( result % mod ) * ( i % mod ) ) % mod ; } return result ; } static long calculate_nCi ( long N , long i ) { long nfact = fact ( N ) ; long ifact = fact ( i ) ; long dfact = fact ( N - i ) ; long inv_ifact = binExp ( ifact , mod - 2 ) ; long inv_dfact = binExp ( dfact , mod - 2 ) ; long denm = ( ( inv_ifact % mod ) * ( inv_dfact % mod ) ) % mod ; long answer = ( ( nfact % mod ) * ( denm % mod ) ) % mod ; return answer ; } static void countSubstring ( long N , long s , long k ) { long allWays = binExp ( 26 , N ) ; long noWays = 0 ; for ( long i = 0 ; i < s ; ++ i ) { long nCi = calculate_nCi ( N , i ) ; long remaining = binExp ( 25 , N - i ) ; long multiply = ( ( nCi % mod ) * ( remaining % mod ) ) % mod ; noWays = ( ( noWays % mod ) + ( multiply % mod ) ) % mod ; } long answer = ( ( allWays % mod ) - ( noWays % mod ) ) % mod ; if ( answer < 0 ) answer += mod ; Console . WriteLine ( answer ) ; } public static void Main ( String [ ] args ) { String str = " abc " ; long k = 2 ; long s = str . Length ; long N = s + k ; countSubstring ( N , s , k ) ; } }

Accumulator variables: answer
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 1000000 + 5 ; static int [ ] prefix = new int [ N ] ; static int [ ] sum = new int [ N ] ; static int isSpecial ( char c , char [ ] special ) { foreach ( char i in special ) if ( i == c ) return 1 ; return 0 ; } static double countRatio ( char [ ] s , char [ ] special ) { int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { prefix [ i ] = ( isSpecial ( s [ i ] , special ) ) ; if ( i > 0 ) prefix [ i ] += prefix [ i - 1 ] ; } for ( int i = 0 ; i < n ; i ++ ) { sum [ i ] = prefix [ i ] ; if ( i > 0 ) sum [ i ] += sum [ i - 1 ] ; } double ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int count = sum [ n - 1 ] - ( i > 1 ? sum [ i - 2 ] : 0 ) ; count -= ( i < n ? sum [ n - i - 1 ] : 0 ) ; ans += ( double ) count / ( double ) i ; } return ans ; } public static void Main ( String [ ] args ) { String s = " abcd " ; char [ ] special = { ' b ' , ' c ' } ; double ans = countRatio ( s . ToCharArray ( ) , special ) ; Console . WriteLine ( " { 0 : F6 } " , ans ) ; } }

Index/key variables: N, i
Accumulator variables: ans, count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void count_minimum ( string s ) { int n = s . Length ; int ans = 0 ; int i = 0 ; while ( i < n ) { int j = i ; while ( j < n && s [ j ] == s [ i ] ) { j ++ ; } int diff = j - i ; ans += diff / 2 ; i = j ; } Console . WriteLine ( ans ) ; } static void Main ( ) { string str = " caaab " ; count_minimum ( str ) ; } }

Index/key variables: i, j
Accumulator variables: ans, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int min_cost ( string st ) { string vow = " aeiou " ; int cost = 0 ; for ( int i = 0 ; i < st . Length ; i ++ ) { List < int > costs = new List < int > ( ) ; for ( int j = 0 ; j < 5 ; j ++ ) costs . Add ( Math . Abs ( st [ i ] - vow [ j ] ) ) ; int minx = Int32 . MaxValue ; foreach ( int x in costs ) { if ( x < minx ) { minx = x ; } } cost += minx ; } return cost ; } public static void Main ( ) { string str = " abcde " ; Console . WriteLine ( min_cost ( str ) ) ; } }

Index/key variables: i, j
Accumulator variables: cost, i, j
Iterator variables: i, j, x
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPalindrome ( string str ) { int l = 0 ; int h = str . Length - 1 ; while ( h > l ) { if ( str [ l ++ ] != str [ h -- ] ) return false ; } return true ; } static string makeOddString ( string str ) { string odd = " " ; for ( int i = 1 ; i < str . Length ; i += 2 ) { odd += str [ i ] ; } return odd ; } static string makeevenString ( string str ) { string even = " " ; for ( int i = 0 ; i < str . Length ; i += 2 ) { even += str [ i ] ; } return even ; } static void checkevenOddPalindrome ( string str ) { string odd = makeOddString ( str ) ; string even = makeevenString ( str ) ; if ( isPalindrome ( odd ) && isPalindrome ( even ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } public static void Main ( ) { string str = " abzzab " ; checkevenOddPalindrome ( str ) ; } }

Index/key variables: i
Accumulator variables: even, h, i, l, odd
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long count_Strings ( long n ) { int x = 1 ; for ( int i = 1 ; i < n ; i ++ ) { x = ( 1 << x ) ; } return x - 1 ; } public static void Main ( String [ ] args ) { long n = 3 ; Console . Write ( count_Strings ( n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void decrypt ( String Str , int Start , int End ) { if ( Start > End ) { return ; } int mid = ( Start + End ) >> 1 ; Console . Write ( Str [ mid ] ) ; decrypt ( Str , mid + 1 , End ) ; decrypt ( Str , Start , mid - 1 ) ; } public static void Main ( ) { int N = 4 ; String Str = " abcd " ; decrypt ( Str , 0 , N - 1 ) ; Console . Write ( " STRNEWLINE " ) ; N = 6 ; Str = " gyuitp " ; decrypt ( Str , 0 , N - 1 ) ; } }

Index/key variables: mid
Class/struct names: GFG