dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static string digits = "0123456789" , sign = " + - " ; static string dot = " . " , ex = " eE " ; static int [ , ] dfa = new int [ 11 , 5 ] ; static void makeDFA ( ) { dfa [ 0 , 0 ] = 1 ; dfa [ 1 , 0 ] = 1 ; dfa [ 1 , 2 ] = 3 ; dfa [ 1 , 3 ] = 2 ; dfa [ 1 , 4 ] = 6 ; dfa [ 3 , 0 ] = 4 ; dfa [ 4 , 0 ] = 4 ; dfa [ 4 , 3 ] = 5 ; dfa [ 4 , 4 ] = 6 ; dfa [ 6 , 0 ] = 8 ; dfa [ 6 , 1 ] = 7 ; dfa [ 7 , 0 ] = 8 ; dfa [ 8 , 0 ] = 8 ; dfa [ 8 , 3 ] = 9 ; } static void buildDFA ( ) { for ( int i = 0 ; i < 11 ; i ++ ) for ( int j = 0 ; j < 5 ; j ++ ) dfa [ i , j ] = 10 ; makeDFA ( ) ; } static void checkDFA ( string s ) { buildDFA ( ) ; int currentstate = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( digits . IndexOf ( s [ i ] ) != - 1 ) currentstate = dfa [ currentstate , 0 ] ; else if ( sign . IndexOf ( s [ i ] ) != - 1 ) currentstate = dfa [ currentstate , 1 ] ; else if ( dot . IndexOf ( s [ i ] ) != - 1 ) currentstate = dfa [ currentstate , 2 ] ; else if ( ex . IndexOf ( s [ i ] ) != - 1 ) currentstate = dfa [ currentstate , 4 ] ; else currentstate = dfa [ currentstate , 3 ] ; } if ( currentstate == 1 currentstate == 4 currentstate == 8 ) { Console . WriteLine ( " Unsigned ▁ integer " ) ; } else { Console . WriteLine ( " Not ▁ an ▁ unsigned ▁ integer " ) ; } } public static void Main ( string [ ] args ) { string S = "1729" ; checkDFA ( S ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { static void printSentence ( string S ) { string [ ] nums = { " " , " " , " ABC " , " DEF " , " GHI " , " JKL " , " MNO " , " PQRS " , " TUV " , " WXYZ " } ; char [ ] str = S . ToCharArray ( ) ; int i = 0 ; while ( i < str . Length ) { if ( str [ i ] == ' . ' ) { i ++ ; continue ; } int count = 0 ; while ( i + 1 < str . Length && str [ i ] == str [ i + 1 ] ) { if ( count == 2 && ( ( str [ i ] >= '2' && str [ i ] <= '6' ) || ( str [ i ] == '8' ) ) ) break ; else if ( count == 3 && ( str [ i ] == '7' str [ i ] == '9' ) ) break ; count ++ ; i ++ ; if ( i == str . Length ) break ; } if ( str [ i ] == '7' str [ i ] == '9' ) { Console . Write ( nums [ str [ i ] - 48 ] [ count % 4 ] ) ; } else { Console . Write ( nums [ str [ i ] - 48 ] [ count % 3 ] ) ; } i ++ ; } } public static void Main ( string [ ] args ) { string str = "234" ; printSentence ( str ) ; } }

Index/key variables: i
Accumulator variables: count, i
Class/struct names: GFG
C# program:
using System ; public class GFG { static string getString ( int N ) { string ans = " " ; while ( N >= 26 ) { ans += ' z ' ; N -= 26 ; } ans += ( char ) ( N + ' a ' - 1 ) ; return ans ; } public static void Main ( string [ ] args ) { int N = 30 ; Console . WriteLine ( getString ( N ) ) ; } }

Accumulator variables: N, ans
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void countSamePrefixSuffix ( string s , int n ) { string prefix = " " ; for ( int i = 0 ; i < n - 1 ; i ++ ) { prefix += s [ i ] ; string suffix = s . Substring ( n - 1 - i , i + 1 ) ; if ( prefix == suffix ) { Console . Write ( prefix . Length + " ▁ " ) ; } } } public static void Main ( ) { string S = " ababababab " ; int N = S . Length ; countSamePrefixSuffix ( S , N ) ; } }

Index/key variables: i
Accumulator variables: i, prefix
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static void countStringPairs ( string [ ] a , int n ) { int ans = 0 ; Dictionary < string , int > s = new Dictionary < string , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! s . ContainsKey ( a [ i ] ) ) s . Add ( a [ i ] , 0 ) ; s [ a [ i ] ] ++ ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { char [ ] p = ( a [ i ] ) . ToCharArray ( ) ; char [ ] q = ( a [ j ] ) . ToCharArray ( ) ; if ( p [ 0 ] != q [ 0 ] ) { char t = p [ 0 ] ; p [ 0 ] = q [ 0 ] ; q [ 0 ] = t ; if ( ! s . ContainsKey ( new string ( p ) ) && ! s . ContainsKey ( new string ( q ) ) ) { ans ++ ; } } } } Console . WriteLine ( ans ) ; } static public void Main ( ) { string [ ] arr = { " good " , " bad " , " food " } ; int N = arr . Length ; countStringPairs ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void minimumMoves ( string s , int n , int k ) { if ( n % 2 == 1 ) { Console . WriteLine ( " No " ) ; return ; } int countOpen = 0 , countClose = 0 ; foreach ( char ch in s . ToCharArray ( ) ) if ( ch == ' ( ' ) countOpen ++ ; else if ( ch == ' ) ' ) countClose ++ ; if ( countOpen != countClose ) { Console . WriteLine ( " No " ) ; return ; } int ans = 0 ; int cnt = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( s [ i ] == ' ( ' ) ++ cnt ; else { -- cnt ; if ( cnt < 0 ) { cnt = 0 ; ++ ans ; } } } if ( ans <= k ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } static void Main ( ) { string S = " ) ( " ; int K = 1 ; minimumMoves ( S , S . Length , K ) ; } }

Index/key variables: i
Accumulator variables: countClose, countOpen
Iterator variables: ch, i
Class/struct names: GFG
C# program:
using System ; class GFG { static void checkPalindrome ( string s ) { int [ ] a = new int [ 26 ] ; int o = 0 , e = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) a [ s [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( a [ i ] == 1 ) o ++ ; else if ( a [ i ] % 2 == 0 && a [ i ] != 0 ) e += ( a [ i ] / 2 ) ; } if ( e >= o ) Console . WriteLine ( " Yes " ) ; else { o = o - e ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( o <= 0 ) break ; if ( o > 0 && a [ i ] % 2 == 1 && a [ i ] > 2 ) { int k = o ; o = o - a [ i ] / 2 ; if ( o > 0 2 * k + 1 == a [ i ] ) { o ++ ; a [ i ] = 1 ; } } } if ( o <= 0 ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } } static void Main ( ) { string S = " abbbaddzcz " ; checkPalindrome ( S ) ; } }

Index/key variables: i
Accumulator variables: e, i, o
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void maximumTime ( string str ) { char [ ] s = str . ToCharArray ( ) ; if ( s [ 0 ] == ' _ ' ) { if ( ( s [ 1 ] == ' _ ' ) || ( s [ 1 ] >= '0' && s [ 1 ] < '4' ) ) { s [ 0 ] = '2' ; } else { s [ 0 ] = '1' ; } } if ( s [ 1 ] == ' _ ' ) { if ( s [ 0 ] == '2' ) { s [ 1 ] = '3' ; } else { s [ 1 ] = '9' ; } } if ( s [ 3 ] == ' _ ' ) { s [ 3 ] = '5' ; } if ( s [ 4 ] == ' _ ' ) { s [ 4 ] = '9' ; } for ( int i = 0 ; i < s . Length ; i ++ ) Console . Write ( s [ i ] ) ; } static public void Main ( ) { string S = "0 _ : 4 _ " ; maximumTime ( S ) ; } }

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 void nearestPowerOfTwoUtil ( Dictionary < char , int > freq ) { foreach ( KeyValuePair < char , int > entry in freq ) { char key = entry . Key ; Console . Write ( key + " ▁ - > ▁ " ) ; int lg = ( int ) ( Math . Log ( freq [ key ] / Math . Log ( 2 ) ) ) ; int a = ( int ) Math . Pow ( 2 , lg ) ; int b = ( int ) Math . Pow ( 2 , lg + 1 ) ; if ( ( freq [ key ] - a ) < ( b - freq [ key ] ) ) { Console . Write ( a + " STRNEWLINE " ) ; } else { Console . Write ( b + " STRNEWLINE " ) ; } } } static void nearestPowerOfTwo ( string S ) { int N = S . Length ; Dictionary < char , int > freq = new Dictionary < char , int > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( freq . ContainsKey ( S [ i ] ) ) freq [ S [ i ] ] += 1 ; else freq [ S [ i ] ] = 1 ; } nearestPowerOfTwoUtil ( freq ) ; } public static void Main ( ) { string N = "16333331163" ; nearestPowerOfTwo ( N ) ; } }

Index/key variables: i, key
Accumulator variables: i
Iterator variables: entry, i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static int lcm ( int a , int b ) { return ( a / gcd ( a , b ) ) * b ; } static void findSmallestString ( string s , string t ) { int n = s . Length , m = t . Length ; int l = lcm ( n , m ) ; string s1 = " " , t1 = " " ; for ( int i = 0 ; i < l / n ; i ++ ) { s1 += s ; } for ( int i = 0 ; i < l / m ; i ++ ) { t1 += t ; } if ( s1 == t1 ) Console . WriteLine ( s1 ) ; else Console . WriteLine ( - 1 ) ; } public static void Main ( String [ ] args ) { string S = " baba " , T = " ba " ; findSmallestString ( S , T ) ; } }

Accumulator variables: i, s1, t1
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minRemovals ( string str , int N ) { int ans = 0 ; bool X = false ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == '0' ) { ans ++ ; while ( str [ i ] == '0' ) { i ++ ; } } else { X = true ; } } if ( ! X ) return 1 ; if ( str [ 0 ] == '0' && str [ N - 1 ] == '0' ) { ans -- ; } return ans ; } public static void Main ( ) { string S = "11010001" ; int N = S . Length ; Console . Write ( minRemovals ( S , N ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Boolean variables: X
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int minimumDeletions ( string s ) { int right_0 = ( int ) s . Split ( '0' ) . Length - 1 ; int left_1 = 0 ; int n = s . Length ; int res = Int32 . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '0' ) { right_0 -= 1 ; } else { left_1 += 1 ; } res = Math . Min ( res , right_0 + left_1 ) ; } return res ; } public static void Main ( String [ ] args ) { string s = "001101" ; int count = minimumDeletions ( s ) ; Console . WriteLine ( count ) ; } }

Index/key variables: i
Accumulator variables: i, left_1, right_0
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int canMakeSame ( string s1 , string s2 ) { int ans = 0 ; if ( s1 . Length != s2 . Length ) { return - 1 ; } int N = s1 . Length ; for ( int i = 0 ; i < N ; i ++ ) { if ( s1 [ i ] != s2 [ i ] ) { while ( i < s1 . Length && s1 [ i ] != s2 [ i ] ) { i ++ ; } ans ++ ; } } return ans ; } public static void Main ( string [ ] args ) { string S1 = "100001" ; string S2 = "110111" ; Console . Write ( canMakeSame ( S1 , S2 ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int convert ( String str ) { str = str . Substring ( 0 , 2 ) + str . Substring ( 3 ) ; int h1 = ( int ) str [ 1 ] - '0' ; int h2 = ( int ) str [ 0 ] - '0' ; int hh = ( h2 * 10 + h1 % 10 ) ; int time = 0 ; if ( str [ 5 ] == ' A ' ) { if ( hh == 12 ) time += Int32 . Parse ( str . Substring ( 2 , 2 ) ) ; else { time += Int32 . Parse ( str . Substring ( 0 , 2 ) ) ; } } else { if ( hh == 12 ) { time += Int32 . Parse ( str . Substring ( 0 , 4 ) ) ; } else { time += Int32 . Parse ( str . Substring ( 0 , 4 ) ) ; time += 1200 ; } } return time ; } static int countOverlap ( String [ , ] arr , int n , String p ) { int ans = 0 ; int M = convert ( p ) ; for ( int i = 0 ; i < n ; i ++ ) { int L = convert ( arr [ i , 0 ] ) ; int R = convert ( arr [ i , 1 ] ) ; if ( ( L <= M && M <= R ) || ( M >= R && M <= L ) ) ans ++ ; } return ans ; } public static void Main ( String [ ] args ) { String [ , ] arr = new String [ , ] { { "12:00 : AM " , "11:55 : PM " } , { "12:01 : AM " , "11:50 : AM " } , { "12:30 : AM " , "12:00 : PM " } , { "11:57 : AM " , "11:59 : PM " } } ; String P = "12:01 : PM " ; int N = arr . GetLength ( 0 ) ; Console . WriteLine ( countOverlap ( arr , N , P ) ) ; } }

Accumulator variables: ans, i, time
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int count ( String S , int X , int Y ) { int N = S . Length ; int temp_x = 0 , temp_y = 0 ; int count = 0 ; HashSet < String > s = new HashSet < String > ( ) ; s . Add ( ( X + " # " + Y ) ) ; for ( int i = 0 ; i < N ; i ++ ) { temp_x = X ; temp_y = Y ; if ( S [ i ] == ' U ' ) { X ++ ; } else if ( S [ i ] == ' D ' ) { X -- ; } else if ( S [ i ] == ' R ' ) { Y ++ ; } else { Y -- ; } if ( s . Contains ( ( temp_x + X ) + " # " + ( temp_y + Y ) ) ) { count ++ ; } else { s . Add ( ( temp_x + X ) + " # " + ( temp_y + Y ) ) ; } } return count ; } public static void Main ( String [ ] args ) { String S = " RDDUDL " ; int X = 0 , Y = 0 ; Console . Write ( count ( S , X , Y ) ) ; } }

Index/key variables: i
Accumulator variables: X, Y, count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void countTotalFrequencies ( string S1 , string S2 ) { HashSet < char > bset = new HashSet < char > ( ) ; foreach ( char x in S1 ) bset . Add ( x ) ; int count = 0 ; foreach ( char x in S2 ) { if ( bset . Contains ( x ) ) count += 1 ; } Console . Write ( count ) ; } static void Main ( ) { string S1 = " geEksFOR " ; string S2 = " GeEksforgeEKS " ; countTotalFrequencies ( S1 , S2 ) ; } }

Accumulator variables: count
Iterator variables: x
Class/struct names: GFG
C# program:
using System ; public class GFG { static int nonDecreasing ( char [ ] s ) { int size = s . Length ; char c = ' a ' ; for ( int i = 0 ; i < size ; i ++ ) { if ( s [ i ] == ' ? ' ) { continue ; } else if ( ( s [ i ] != ' ? ' ) && ( s [ i ] < c ) ) { return 0 ; } else { c = s [ i ] ; } } return 1 ; } public static void Main ( String [ ] args ) { String S = " abb ? xy ? " ; if ( nonDecreasing ( S . ToCharArray ( ) ) == 1 ) Console . Write ( " Yes " + " STRNEWLINE " ) ; else Console . Write ( " No " + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void min_length ( string str ) { int n = str . Length ; int total_zeros = 0 ; int total_ones = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '0' ) { total_zeros ++ ; } else { total_ones ++ ; } } int ans = Math . Min ( total_zeros , total_ones ) ; int cur_zeros = 0 , cur_ones = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { char x = str [ i ] ; if ( x == '0' ) { cur_zeros ++ ; } else { cur_ones ++ ; } ans = Math . Min ( ans , cur_ones + ( total_zeros - cur_zeros ) ) ; } Console . WriteLine ( ans ) ; } static public void Main ( ) { string str = "10011" ; min_length ( str ) ; } }

Index/key variables: i
Accumulator variables: cur_ones, cur_zeros, i, total_ones, total_zeros
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static String make_palindrome ( String S1 , String S2 , String S3 ) { int maskA = 0 , maskC = 0 ; foreach ( char i in S1 . ToCharArray ( ) ) maskA |= ( 1 << ( i - ' a ' ) ) ; foreach ( char i in S3 . ToCharArray ( ) ) maskC |= ( 1 << ( i - ' a ' ) ) ; if ( ( maskA & maskC ) > 0 ) return " YES " ; return " NO " ; } public static void Main ( String [ ] args ) { String S1 = " adcb " , S2 = " bcdb " , S3 = " abe " ; Console . Write ( make_palindrome ( S1 , S2 , S3 ) ) ; } }

Accumulator variables: maskA, maskC
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int SIZE = 26 ; static bool longHelper ( int [ ] freq1 , int [ ] freq2 ) { for ( int i = 0 ; i < SIZE ; ++ i ) { if ( freq1 [ i ] != freq2 [ i ] ) { return false ; } } return true ; } static void longCommomPrefixAnagram ( string s1 , string s2 , int n1 , int n2 ) { int [ ] freq1 = new int [ 26 ] ; int [ ] freq2 = new int [ 26 ] ; int ans = 0 ; int mini_len = Math . Min ( n1 , n2 ) ; for ( int i = 0 ; i < mini_len ; ++ i ) { freq1 [ s1 [ i ] - ' a ' ] ++ ; freq2 [ s2 [ i ] - ' a ' ] ++ ; if ( longHelper ( freq1 , freq2 ) ) { ans = i + 1 ; } } Console . Write ( ans ) ; } static void Main ( ) { string str1 = " abaabcdezzwer " ; string str2 = " caaabbttyh " ; int N = str1 . Length ; int M = str2 . Length ; longCommomPrefixAnagram ( str1 , str2 , N , M ) ; } }

Index/key variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findRank ( string s ) { int N = s . Length ; string bin = " " ; for ( int i = 0 ; i < N ; i ++ ) { if ( s [ i ] == '0' ) bin += "0" ; else bin += "1" ; } int X = 1 << N ; int res = 0 , val = 1 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( bin [ i ] == '1' ) res += ( val ) ; val *= 2 ; } int Y = res ; int ans = X + Y - 1 ; Console . Write ( ans ) ; } public static void Main ( ) { string S = "001" ; findRank ( S ) ; } }

Index/key variables: i
Accumulator variables: bin, i, res, val
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int GCD ( int lena , int lenb ) { if ( lena == 0 ) return lenb ; if ( lenb == 0 ) return lena ; if ( lena == lenb ) return lena ; if ( lena > lenb ) return GCD ( lena - lenb , lenb ) ; return GCD ( lena , lenb - lena ) ; } static String StringGCD ( String a , String b ) { int gcd = GCD ( a . Length , b . Length ) ; if ( a . Substring ( 0 , gcd ) . Equals ( b . Substring ( 0 , gcd ) ) ) { int x = ( ( int ) b . Length / gcd ) ; int y = ( ( int ) a . Length / gcd ) ; String r = " " , s = " " ; while ( x -- > 0 ) s += a ; while ( y -- > 0 ) r += b ; if ( s . Equals ( r ) ) return a . Substring ( 0 , gcd ) ; } return " - 1" ; } public static void Main ( String [ ] args ) { String a = " geeksgeeks " ; String b = " geeks " ; Console . Write ( StringGCD ( a , b ) ) ; } }

Accumulator variables: r, s, x, y
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static long scoreOfParentheses ( String S ) { Stack < String > s = new Stack < String > ( ) ; int i = 0 ; long ans = 0 ; while ( i < S . Length ) { if ( S [ i ] == ' ( ' ) s . Push ( " ( " ) ; else { if ( s . Peek ( ) == " ( " ) { s . Pop ( ) ; s . Push ( "1" ) ; } else { long count = 0 ; while ( s . Peek ( ) != " ( " ) { count += Int32 . Parse ( s . Peek ( ) ) ; s . Pop ( ) ; } s . Pop ( ) ; s . Push ( String . Join ( " " , 2 * count ) ) ; } } i ++ ; } while ( s . Count != 0 ) { ans += Int32 . Parse ( s . Peek ( ) ) ; s . Pop ( ) ; } return ans ; } public static void Main ( String [ ] args ) { String S1 = " ( ( ) ( ( ) ) ) " ; Console . Write ( scoreOfParentheses ( S1 ) + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: ans, count, i
Class/struct names: GFG
C# program:
using System ; class GFG { static void countMinMoves ( string str ) { int n = str . Length ; int [ ] a = new int [ n ] ; int j , ans = 0 , i , sum = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ) ' ) { a [ i ] += sum - 1 ; } else { a [ i ] += sum + 1 ; } sum = a [ i ] ; } if ( sum == 0 ) { i = 1 ; while ( i < n ) { j = i - 1 ; while ( i < n && a [ i ] != 0 ) i ++ ; if ( i < n && a [ i - 1 ] < 0 ) { ans += i - j ; if ( j == 0 ) ans ++ ; } i ++ ; } Console . WriteLine ( ans ) ; } else Console . WriteLine ( " - 1" ) ; } public static void Main ( ) { string str = " ) ( ( ) " ; countMinMoves ( str ) ; } }

Index/key variables: i, n
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool canBeBalanced ( String sequence ) { if ( sequence . Length % 2 == 1 ) return false ; Stack < char > stack_ = new Stack < char > ( ) ; Stack < char > stack2_ = new Stack < char > ( ) ; int countOpen = 0 , countClosed = 0 ; int countSymbol = 0 ; for ( int i = 0 ; i < sequence . Length ; i ++ ) { if ( sequence [ i ] == ' ) ' ) { countClosed ++ ; if ( stack_ . Count == 0 ) { return false ; } else { stack_ . Pop ( ) ; } } else { if ( sequence [ i ] == ' $ ' ) { countSymbol ++ ; } else { countOpen ++ ; } stack_ . Push ( sequence [ i ] ) ; } } for ( int i = sequence . Length - 1 ; i >= 0 ; i -- ) { if ( sequence [ i ] == ' ( ' ) { if ( stack2_ . Count == 0 ) { return false ; } else { stack2_ . Pop ( ) ; } } else { stack2_ . Push ( sequence [ i ] ) ; } } int extra = Math . Abs ( countClosed - countOpen ) ; if ( countSymbol < extra ) { return false ; } else { countSymbol -= extra ; if ( countSymbol % 2 == 0 ) { return true ; } } return false ; } public static void Main ( String [ ] args ) { String S = " ( ) ( $ " ; if ( canBeBalanced ( S ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: i
Accumulator variables: countClosed, countOpen, countSymbol, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void maxDiffFreq ( List < Tuple < int , int > > queries , string S ) { int N = S . Length ; int Q = queries . Count ; for ( int i = 0 ; i < Q ; ++ i ) { int l = queries [ i ] . Item1 - 1 ; int r = queries [ i ] . Item2 - 1 ; int [ ] freq = new int [ 26 ] ; for ( int j = l ; j <= r ; j ++ ) { freq [ S [ j ] - ' a ' ] ++ ; } int mx = 0 ; int mn = 99999999 ; for ( int j = 0 ; j < 26 ; j ++ ) { mx = Math . Max ( mx , freq [ j ] ) ; if ( freq [ j ] != 0 ) mn = Math . Min ( mn , freq [ j ] ) ; } Console . WriteLine ( mx - mn ) ; } } static void Main ( ) { string S = " abaabac " ; List < Tuple < int , int > > queries = new List < Tuple < int , int > > ( ) ; queries . Add ( new Tuple < int , int > ( 2 , 6 ) ) ; queries . Add ( new Tuple < int , int > ( 1 , 7 ) ) ; maxDiffFreq ( queries , S ) ; } }

Index/key variables: i, j
Accumulator variables: j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countSubstrings ( string str ) { Dictionary < Tuple < Tuple < int , int > , Tuple < int , int > > , int > mp = new Dictionary < Tuple < Tuple < int , int > , Tuple < int , int > > , int > ( ) ; if ( mp . ContainsKey ( new Tuple < Tuple < int , int > , Tuple < int , int > > ( new Tuple < int , int > ( 0 , 0 ) , new Tuple < int , int > ( 0 , 0 ) ) ) ) { mp [ new Tuple < Tuple < int , int > , Tuple < int , int > > ( new Tuple < int , int > ( 0 , 0 ) , new Tuple < int , int > ( 0 , 0 ) ) ] ++ ; } else { mp [ new Tuple < Tuple < int , int > , Tuple < int , int > > ( new Tuple < int , int > ( 0 , 0 ) , new Tuple < int , int > ( 0 , 0 ) ) ] = 1 ; } int p = 0 ; int q = 0 ; int r = 0 ; int s = 0 ; int cntSub = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] == ' a ' ) { p ++ ; int Y = Math . Min ( Math . Min ( s , r ) , Math . Min ( p , q ) ) ; p -= Y ; q -= Y ; r -= Y ; s -= Y ; } else if ( str [ i ] == ' b ' ) { q ++ ; int Y = Math . Min ( Math . Min ( p , q ) , Math . Min ( r , s ) ) ; p -= Y ; q -= Y ; r -= Y ; s -= Y ; } else if ( str [ i ] == ' c ' ) { r ++ ; int Y = Math . Min ( Math . Min ( p , q ) , Math . Min ( r , s ) ) ; p -= Y ; q -= Y ; r -= Y ; s -= Y ; } else if ( str [ i ] == ' d ' ) { s ++ ; int Y = Math . Min ( Math . Min ( p , q ) , Math . Min ( r , s ) ) ; p -= Y ; q -= Y ; r -= Y ; s -= Y ; } if ( mp . ContainsKey ( new Tuple < Tuple < int , int > , Tuple < int , int > > ( new Tuple < int , int > ( p , q ) , new Tuple < int , int > ( r , s ) ) ) ) { mp [ new Tuple < Tuple < int , int > , Tuple < int , int > > ( new Tuple < int , int > ( p , q ) , new Tuple < int , int > ( r , s ) ) ] ++ ; } else { mp [ new Tuple < Tuple < int , int > , Tuple < int , int > > ( new Tuple < int , int > ( p , q ) , new Tuple < int , int > ( r , s ) ) ] = 1 ; } } foreach ( KeyValuePair < Tuple < Tuple < int , int > , Tuple < int , int > > , int > e in mp ) { int freq = e . Value ; cntSub += ( freq ) * ( freq - 1 ) / 2 ; } return cntSub ; } static void Main ( ) { string str = " abcdefg " ; Console . WriteLine ( countSubstrings ( str ) ) ; } }

Index/key variables: i
Accumulator variables: cntSub, i, p, q, r, s
Iterator variables: e, i
Class/struct names: GFG