dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; 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 [ left ] != c && left < len ) { left ++ ; leftCount ++ ; } right = left + 1 ; while ( freq != ( k - 1 ) && ( right - 1 ) < len ) { if ( s [ right ] == c ) freq ++ ; right ++ ; } while ( left < len && ( right - 1 ) < len ) { while ( s [ left ] != c && left < len ) { left ++ ; leftCount ++ ; } while ( right < len && s [ right ] != c ) { if ( s [ right ] == c ) freq ++ ; right ++ ; rightCount ++ ; } result = result + ( leftCount + 1 ) * ( rightCount + 1 ) ; freq = k - 1 ; leftCount = 0 ; rightCount = 0 ; left ++ ; right ++ ; } return result ; } static public void Main ( ) { string s = "3123231" ; char c = '3' ; int k = 2 ; Console . WriteLine ( countSubString ( s , c , k ) ) ; } }

Index/key variables: left, right
Accumulator variables: freq, left, leftCount, right, rightCount
Class/struct names: GFG
C# program:
using System ; 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 [ j ] == x + 48 test [ j ] == y + 48 ) { newtest += test [ 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 [ 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 [ 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 test = "13134422" ; int MOD = 1000000007 ; Console . WriteLine ( 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
C# program:
using System ; 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 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: sol
C# program:
using System ; 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 ; Console . WriteLine ( countPairs ( str . ToCharArray ( ) , k ) ) ; } }

Index/key variables: MAX, i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPalin ( int i , int j , int k , int l , int p , int q , String s ) { int start = i , end = q ; while ( start < end ) { if ( s [ start ] != s [ end ] ) { return false ; } start ++ ; if ( start == j + 1 ) { start = k ; } end -- ; if ( end == p - 1 ) { end = l ; } } return true ; } static int countSubStr ( String s ) { int count = 0 ; int n = s . Length ; for ( int i = 0 ; i < n - 2 ; i ++ ) { for ( int j = i ; j < n - 2 ; j ++ ) { for ( int k = j + 1 ; k < n - 1 ; k ++ ) { for ( int l = k ; l < n - 1 ; l ++ ) { for ( int p = l + 1 ; p < n ; p ++ ) { for ( int q = p ; q < n ; q ++ ) { if ( isPalin ( i , j , k , l , p , q , s ) ) { count ++ ; } } } } } } } return count ; } public static void Main ( String [ ] args ) { String s = " abca " ; Console . WriteLine ( countSubStr ( s ) ) ; } }

Index/key variables: end, start
Accumulator variables: count, end, i, j, k, l, p, q, start
Iterator variables: i, j, k, l, p, q
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPrime ( int n ) { if ( n == 0 n == 1 ) { return false ; } for ( int i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { return false ; } } return true ; } static int sumAscii ( string str , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isPrime ( i + 1 ) ) { sum += ( int ) ( str [ i ] ) ; } } return sum ; } public static void Main ( ) { string str = " geeksforgeeks " ; int n = str . Length ; Console . WriteLine ( sumAscii ( str , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > [ ] graph = new List < int > [ 100 ] ; static String [ ] weight = new String [ 100 ] ; static bool Pangram ( String x ) { Dictionary < char , int > mp = new Dictionary < char , int > ( ) ; int n = x . Length ; for ( int i = 0 ; i < n ; i ++ ) { if ( mp . ContainsKey ( x [ i ] ) ) { mp [ x [ i ] ] = mp [ x [ i ] ] + 1 ; } else { mp . Add ( x [ i ] , 1 ) ; } } if ( mp . Count == 26 ) return true ; else return false ; } static int countTotalPangram ( int n ) { int cnt = 0 ; for ( int i = 1 ; i <= n ; i ++ ) if ( Pangram ( weight [ i ] ) ) cnt ++ ; return cnt ; } static void dfs ( int node , int parent ) { foreach ( int to in graph [ node ] ) { if ( to == parent ) continue ; dfs ( to , node ) ; weight [ node ] += weight [ to ] ; } } public static void Main ( String [ ] args ) { int n = 6 ; weight [ 1 ] = " abcde " ; weight [ 2 ] = " fghijkl " ; weight [ 3 ] = " abcdefg " ; weight [ 4 ] = " mnopqr " ; weight [ 5 ] = " stuvwxy " ; weight [ 6 ] = " zabcdef " ; for ( int i = 0 ; i < graph . Length ; i ++ ) graph [ i ] = new List < int > ( ) ; graph [ 1 ] . Add ( 2 ) ; graph [ 2 ] . Add ( 3 ) ; graph [ 2 ] . Add ( 4 ) ; graph [ 1 ] . Add ( 5 ) ; graph [ 5 ] . Add ( 6 ) ; dfs ( 1 , 1 ) ; Console . Write ( countTotalPangram ( n ) ) ; } }

Index/key variables: i, node, to
Accumulator variables: cnt, i
Iterator variables: i, to
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int cnt = 0 ; static List < int > [ ] graph = new List < int > [ 100 ] ; static String [ ] weight = new String [ 100 ] ; static bool uniqueChars ( char [ ] arr ) { Dictionary < char , int > mp = new Dictionary < char , int > ( ) ; int n = arr . Length ; for ( int i = 0 ; i < n ; i ++ ) if ( mp . ContainsKey ( arr [ i ] ) ) { mp [ arr [ i ] ] = mp [ arr [ i ] ] + 1 ; } else { mp . Add ( arr [ i ] , 1 ) ; } if ( mp . Count == arr . Length ) return true ; else return false ; } static void dfs ( int node , int parent ) { if ( uniqueChars ( weight [ node ] . ToCharArray ( ) ) ) cnt += 1 ; foreach ( int to in graph [ node ] ) { if ( to == parent ) continue ; dfs ( to , node ) ; } } public static void Main ( String [ ] args ) { for ( int i = 0 ; i < 100 ; i ++ ) graph [ i ] = new List < int > ( ) ; weight [ 1 ] = " abc " ; weight [ 2 ] = " aba " ; weight [ 3 ] = " bcb " ; weight [ 4 ] = " moh " ; weight [ 5 ] = " aa " ; graph [ 1 ] . Add ( 2 ) ; graph [ 2 ] . Add ( 3 ) ; graph [ 2 ] . Add ( 4 ) ; graph [ 1 ] . Add ( 5 ) ; dfs ( 1 , 1 ) ; Console . Write ( cnt ) ; } }

Index/key variables: i, node
Accumulator variables: cnt, i
Iterator variables: i, to
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isValid ( string s ) { if ( ( s . IndexOf ( " geek " ) != - 1 ) && ( s . IndexOf ( " keeg " , s . IndexOf ( " geek " ) + 4 ) != - 1 ) ) return true ; return false ; } public static void Main ( ) { string s = " geekeekeeg " ; if ( isValid ( s ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int MAX = 256 ; static String lastNonRepeating ( String str , int n ) { int [ ] freq = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) freq [ str [ i ] ] ++ ; for ( int i = n - 1 ; i >= 0 ; i -- ) { char ch = str [ i ] ; if ( freq [ ch ] == 1 ) return ( " " + ch ) ; } return " - 1" ; } public static void Main ( String [ ] args ) { String str = " GeeksForGeeks " ; int n = str . Length ; Console . WriteLine ( lastNonRepeating ( str , n ) ) ; } }

Index/key variables: MAX, ch, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findCount ( string s , int n , int a , int b ) { int res = 0 ; for ( int i = 0 ; i < b ; i ++ ) { if ( i == a ) { if ( s [ n - i - 1 ] != '1' ) res += 1 ; } else { if ( s [ n - i - 1 ] != '0' ) res += 1 ; } } return res ; } static public void Main ( ) { string str = "1001011001" ; int N = str . Length ; int A = 3 , B = 6 ; Console . WriteLine ( findCount ( str , N , A , B ) ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int NUM = 31 ; static void positions ( string str , int n ) { for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( ( str [ i ] & NUM ) + " ▁ " ) ; } } public static void Main ( ) { string str = " Geeks " ; int n = str . Length ; positions ( str , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Text ; class GFG { static void permute ( StringBuilder str , int l , int r ) { if ( l == r ) { if ( str . ToString ( ) . IndexOf ( " AB " ) == - 1 ) { Console . Write ( str . ToString ( ) + " ▁ " ) ; } return ; } for ( int i = l ; i <= r ; i ++ ) { char tmp = str [ l ] ; str [ l ] = str [ i ] ; str [ i ] = tmp ; permute ( str , l + 1 , r ) ; tmp = str [ l ] ; str [ l ] = str [ i ] ; str [ i ] = tmp ; } } static void Main ( string [ ] arg ) { string str = " ABC " ; StringBuilder s = new StringBuilder ( str ) ; permute ( s , 0 , str . Length - 1 ) ; } }

Index/key variables: i, l
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int lenoflongestnonpalindrome ( String s ) { int max1 = 1 , len = 0 ; char [ ] new_str = s . ToCharArray ( ) ; for ( int i = 0 ; i < new_str . Length - 1 ; i ++ ) { if ( new_str [ i ] == new_str [ i + 1 ] ) len = 0 ; else if ( i > 0 && ( new_str [ i + 1 ] == new_str [ i - 1 ] ) ) len = 1 ; len ++ ; } if ( max1 == 1 ) return 0 ; else return max1 ; } public static void Main ( String [ ] args ) { String s = " synapse " ; Console . WriteLine ( lenoflongestnonpalindrome ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i, len
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String makePalindrome ( char [ ] str ) { int i = 0 , j = str . Length - 1 ; while ( i <= j ) { if ( str [ i ] == ' * ' && str [ j ] == ' * ' ) { str [ i ] = ' a ' ; str [ j ] = ' a ' ; } else if ( str [ j ] == ' * ' ) str [ j ] = str [ i ] ; else if ( str [ i ] == ' * ' ) str [ i ] = str [ j ] ; else if ( str [ i ] != str [ j ] ) return " - 1" ; i ++ ; j -- ; } return String . Join ( " " , str ) ; } public static void Main ( String [ ] args ) { char [ ] str = " na * an " . ToCharArray ( ) ; Console . WriteLine ( makePalindrome ( str ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int calcScore ( String str ) { int score = 0 ; int len = str . Length ; for ( int i = 0 ; i < len ; ) { int chunkSize = 1 ; char currentChar = str [ i ++ ] ; while ( i < len && str [ i ] == currentChar ) { chunkSize ++ ; i ++ ; } if ( currentChar == '1' ) score += ( int ) Math . Pow ( chunkSize , 2 ) ; else score -= ( int ) Math . Pow ( chunkSize , 2 ) ; } return score ; } public static void Main ( String [ ] args ) { String str = "11011" ; Console . WriteLine ( calcScore ( str ) ) ; } }

Index/key variables: i
Accumulator variables: chunkSize, i, score
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSubString ( char [ ] 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 [ left ] != c && left < len ) { left ++ ; leftCount ++ ; } right = left + 1 ; while ( freq != ( k - 1 ) && ( right - 1 ) < len ) { if ( s [ right ] == c ) freq ++ ; right ++ ; } while ( left < len && ( right - 1 ) < len ) { while ( s [ left ] != c && left < len ) { left ++ ; leftCount ++ ; } while ( right < len && s [ right ] != c ) { if ( s [ 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 = " abada " ; char c = ' a ' ; int k = 2 ; Console . WriteLine ( countSubString ( s . ToCharArray ( ) , c , k ) ) ; } }

Index/key variables: left, right
Accumulator variables: freq, left, leftCount, right, rightCount
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 4 ; static int performQueries ( int l , int r , int [ , ] prefix ) { l -- ; r -- ; bool flag = false ; int count = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { int cnt = prefix [ r , i ] ; if ( l > 0 ) cnt -= prefix [ l - 1 , i ] ; if ( cnt % 2 == 1 ) { flag = true ; count += cnt - 1 ; } else count += cnt ; } if ( flag ) count += 1 ; return count ; } static void preCalculate ( string s , int [ , ] prefix ) { int n = s . Length ; for ( int i = 0 ; i < n ; i ++ ) { prefix [ i , s [ i ] - ' a ' ] ++ ; } for ( int i = 1 ; i < n ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) prefix [ i , j ] += prefix [ i - 1 , j ] ; } } public static void Main ( ) { string s = " amim " ; int [ , ] prefix = new int [ N , 26 ] ; preCalculate ( s , prefix ) ; int [ , ] queries = { { 1 , 4 } , { 3 , 4 } } ; int q = queries . Length ; for ( int i = 0 ; i < q ; i ++ ) { Console . WriteLine ( performQueries ( queries [ i , 0 ] , queries [ i , 1 ] , prefix ) ) ; } } }

Index/key variables: i
Accumulator variables: cnt, count, i, j, l, r
Iterator variables: i, j
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isValid ( String str , int n ) { if ( ! ( ( str [ 0 ] >= ' a ' && str [ 0 ] <= ' z ' ) || ( str [ 0 ] >= ' A ' && str [ 0 ] <= ' Z ' ) str [ 0 ] == ' _ ' ) ) return false ; for ( int i = 1 ; i < str . Length ; i ++ ) { if ( ! ( ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) || ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) || ( str [ i ] >= '0' && str [ i ] <= '9' ) str [ i ] == ' _ ' ) ) return false ; } return true ; } public static void Main ( String [ ] args ) { String str = " _ geeks123" ; int n = str . Length ; if ( isValid ( str , n ) ) Console . WriteLine ( " Valid " ) ; else Console . WriteLine ( " Invalid " ) ; } }

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 bool check ( String s , int l ) { List < int > pos = new List < int > ( ) ; for ( int i = 0 ; i < l ; i ++ ) { if ( s [ i ] == '1' ) { pos . Add ( i ) ; } } int t = pos . Count ; for ( int i = 1 ; i < t ; i ++ ) { if ( ( pos [ i ] - pos [ i - 1 ] ) != ( pos [ 1 ] - pos [ 0 ] ) ) return false ; } return true ; } public static void Main ( String [ ] args ) { String s = "100010001000" ; int l = s . Length ; if ( check ( s , l ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String FirstAndLast ( String str ) { char [ ] ch = str . ToCharArray ( ) ; for ( int i = 0 ; i < ch . Length ; i ++ ) { int k = i ; while ( i < ch . Length && ch [ i ] != ' ▁ ' ) i ++ ; ch [ k ] = ( char ) ( ch [ k ] >= ' a ' && ch [ k ] <= ' z ' ? ( ( int ) ch [ k ] - 32 ) : ( int ) ch [ k ] ) ; ch [ i - 1 ] = ( char ) ( ch [ i - 1 ] >= ' a ' && ch [ i - 1 ] <= ' z ' ? ( ( int ) ch [ i - 1 ] - 32 ) : ( int ) ch [ i - 1 ] ) ; } return new String ( ch ) ; } public static void Main ( String [ ] args ) { String str = " Geeks ▁ for ▁ Geeks " ; Console . WriteLine ( str ) ; Console . WriteLine ( FirstAndLast ( str ) ) ; } }

Index/key variables: i, k
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findM ( String s , int x ) { int cnt = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] - '0' != x ) cnt ++ ; } return cnt ; } public static void Main ( ) { String s = "3662123" ; int x = 6 ; Console . Write ( findM ( s , x ) ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void FirstAndLast ( string str ) { int i ; for ( i = 0 ; i < str . Length ; i ++ ) { if ( i == 0 ) Console . Write ( str [ i ] ) ; if ( i == str . Length - 1 ) Console . Write ( str [ i ] ) ; if ( str [ i ] == ' ▁ ' ) { Console . Write ( str [ i - 1 ] + " ▁ " + str [ i + 1 ] ) ; } } } public static void Main ( ) { string str = " Geeks ▁ for ▁ Geeks " ; FirstAndLast ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] compute_lps ( string s ) { int n = s . Length ; int [ ] lps = new int [ n ] ; int len = 0 ; lps [ 0 ] = 0 ; int i = 1 ; while ( i < n ) { if ( s [ i ] == s [ len ] ) { len ++ ; lps [ i ] = len ; i ++ ; } else { if ( len != 0 ) len = lps [ len - 1 ] ; else { lps [ i ] = 0 ; i ++ ; } } } return lps ; } static void Longestsubstring ( string s ) { int [ ] lps = compute_lps ( s ) ; int n = s . Length ; if ( lps [ n - 1 ] == 0 ) { Console . WriteLine ( - 1 ) ; return ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( lps [ i ] == lps [ n - 1 ] ) { Console . WriteLine ( s . Substring ( 0 , lps [ i ] ) ) ; return ; } } if ( lps [ lps [ n - 1 ] - 1 ] == 0 ) Console . WriteLine ( - 1 ) ; else Console . WriteLine ( s . Substring ( 0 , lps [ lps [ n - 1 ] - 1 ] ) ) ; } public static void Main ( ) { string s = " fixprefixsuffix " ; Longestsubstring ( s ) ; } }

Index/key variables: i, len, n
Accumulator variables: i, len
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 64 ; static int getBitmask ( char [ ] s ) { int temp = 0 ; for ( int j = 0 ; j < s . Length ; j ++ ) { switch ( s [ j ] ) { case ' s ' : temp = temp | ( 1 ) ; break ; case ' t ' : temp = temp | ( 2 ) ; break ; case ' r ' : temp = temp | ( 4 ) ; break ; case ' i ' : temp = temp | ( 8 ) ; break ; case ' n ' : temp = temp | ( 16 ) ; break ; case ' g ' : temp = temp | ( 32 ) ; break ; default : break ; } } return temp ; } static int countPairs ( String [ ] arr , int n ) { int [ ] bitMask = new int [ MAX ] ; for ( int i = 0 ; i < n ; i ++ ) bitMask [ getBitmask ( arr [ i ] . ToCharArray ( ) ) ] ++ ; int cnt = 0 ; for ( int i = 0 ; i < MAX ; i ++ ) { for ( int j = i ; j < MAX ; j ++ ) { if ( ( i j ) == ( MAX - 1 ) ) { if ( i == j ) cnt += ( ( bitMask [ i ] * bitMask [ i ] - 1 ) / 2 ) ; else cnt += ( bitMask [ i ] * bitMask [ j ] ) ; } } } return cnt ; } public static void Main ( String [ ] args ) { String [ ] arr = { " strrr " , " string " , " gstrin " } ; int n = arr . Length ; Console . WriteLine ( countPairs ( arr , n ) ) ; } }

Index/key variables: MAX, i, j
Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countOcc ( string s ) { int cnt = 0 ; for ( int i = 0 ; i < s . Length - 3 ; i ++ ) { int c = 0 , l = 0 , a = 0 , p = 0 ; for ( int j = i ; j < i + 4 ; j ++ ) { switch ( s [ j ] ) { case ' c ' : c ++ ; break ; case ' l ' : l ++ ; break ; case ' a ' : a ++ ; break ; case ' p ' : p ++ ; break ; } } if ( c == 1 && l == 1 && a == 1 && p == 1 ) cnt ++ ; } return cnt ; } public static void Main ( ) { string s = " clapc " ; Console . Write ( countOcc ( s . ToLower ( ) ) ) ; } }

Index/key variables: j
Accumulator variables: a, c, cnt, i, j, l, p
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GfG { static int calculateWays ( String s , int n , int l , int r ) { int [ ] freq = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( i < l i > r ) freq [ s [ i ] - ' a ' ] ++ ; } int ways = 1 ; for ( int i = l ; i <= r ; i ++ ) { if ( freq [ s [ i ] - ' a ' ] != 0 ) { ways = ways * freq [ s [ i ] - ' a ' ] ; freq [ s [ i ] - ' a ' ] -- ; } else { ways = 0 ; break ; } } return ways ; } public static void Main ( ) { String s = " cabcaab " ; int n = s . Length ; int l = 1 , r = 3 ; Console . WriteLine ( calculateWays ( s , n , l , r ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; class GFG { static char findKthChar ( String s , int k ) { int len = s . Length ; int i = 0 ; int total_len = 0 ; while ( i < len ) { if ( char . IsLetter ( s [ i ] ) ) { total_len ++ ; if ( total_len == k ) return s [ i ] ; i ++ ; } else { int n = 0 ; while ( i < len && ! char . IsLetter ( s [ i ] ) ) { n = n * 10 + ( s [ i ] - '0' ) ; i ++ ; } int next_total_len = total_len * n ; if ( k <= next_total_len ) { int pos = k % total_len ; if ( pos == 0 ) { pos = total_len ; } return findKthChar ( s , pos ) ; } else { total_len = next_total_len ; } } } return ' ▁ ' ; } public static void Main ( String [ ] args ) { String s = " ab2c3" ; int k = 5 ; Console . WriteLine ( findKthChar ( s , k ) ) ; } }

Index/key variables: i
Accumulator variables: i, total_len
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check_char ( string st , char ch ) { int l = st . Length ; for ( int i = 0 ; i < l ; i ++ ) { if ( st [ i ] == ch ) return true ; } return false ; } static char find_avg ( string st ) { int i , sm = 0 ; int l = st . Length ; char ch ; for ( i = 0 ; i < l ; i ++ ) { ch = st [ i ] ; sm = sm + ( int ) ( ch ) ; } int avg = ( int ) ( Math . Floor ( ( double ) ( sm / l ) ) ) ; return ( ( char ) ( avg ) ) ; } public static void Main ( ) { string st = " ag23sdfa " ; char ch = find_avg ( st ) ; Console . WriteLine ( ch ) ; if ( check_char ( st , ch ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void asciiToSentence ( String str , int len ) { int num = 0 ; for ( int i = 0 ; i < len ; i ++ ) { num = num * 10 + ( str [ i ] - '0' ) ; if ( num >= 32 && num <= 122 ) { char ch = ( char ) num ; Console . Write ( ch ) ; num = 0 ; } } } public static void Main ( ) { String str = "7110110110711510211111471101101107115" ; int len = str . Length ; asciiToSentence ( str , len ) ; } }

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 int countDistinctCode ( String str ) { HashSet < String > codes = new HashSet < String > ( ) ; for ( int i = 0 ; i < str . Length - 1 ; i ++ ) codes . Add ( str . Substring ( i , 2 ) ) ; return codes . Count ; } public static void Main ( String [ ] args ) { String str = " UPUP " ; Console . Write ( countDistinctCode ( str ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG