dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int firstNonRepeating ( String str ) { int NO_OF_CHARS = 256 ; int [ ] arr = new int [ NO_OF_CHARS ] ; for ( int i = 0 ; i < NO_OF_CHARS ; i ++ ) arr [ i ] = - 1 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( arr [ str [ i ] ] == - 1 ) arr [ str [ i ] ] = i ; else arr [ str [ i ] ] = - 2 ; } int res = int . MaxValue ; for ( int i = 0 ; i < NO_OF_CHARS ; i ++ ) if ( arr [ i ] >= 0 ) res = Math . Min ( res , arr [ i ] ) ; return res ; } public static void Main ( ) { String str = " geeksforgeeks " ; int index = firstNonRepeating ( str ) ; if ( index == int . MaxValue ) Console . Write ( " Either ▁ all ▁ characters ▁ are ▁ " + " repeating ▁ or ▁ string ▁ is ▁ empty " ) ; else Console . Write ( " First ▁ non - repeating ▁ character " + " ▁ is ▁ " + str [ index ] ) ; } }

Index/key variables: NO_OF_CHARS, i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static String minimize ( string str ) { string mstr = " ▁ " ; int l , i ; int [ ] flagchar = new int [ 26 ] ; char ch ; l = str . Length ; for ( i = 0 ; i < str . Length ; i ++ ) { ch = str [ i ] ; if ( flagchar [ ch - 97 ] == 0 ) { mstr = mstr + ch ; flagchar [ ch - 97 ] = 1 ; } } } static void replaceMinimizeUtil ( string str ) { string minimizedStr , finalStr = " " ; int i , index , l ; char ch ; l = str . Length ; for ( i = 0 ; i < minimizedStr . Length ; i ++ ) { ch = minimizedStr [ i ] ; index = ( ch * ch ) % l ; finalStr = finalStr + str [ index ] ; } Console . Write ( " Final ▁ String : ▁ " + finalStr ) ; } public static void Main ( ) { string str = " geeks " ; replaceMinimizeUtil ( str ) ; } }

Index/key variables: i, index
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class LatinCipher { static void cipher ( String str ) { for ( int i = 0 ; i < str . Length ; i ++ ) { if ( ! char . IsLetter ( str [ i ] ) && str [ i ] != ' ▁ ' ) { Console . WriteLine ( " Enter ▁ only ▁ alphabets ▁ and ▁ space " ) ; return ; } } Console . WriteLine ( " Encrypted ▁ Code ▁ using ▁ Latin ▁ Alphabet " ) ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) { Console . Write ( str [ i ] - ' A ' + 1 + " ▁ " ) ; } else if ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) { Console . Write ( str [ i ] - ' a ' + 1 + " ▁ " ) ; } if ( str [ i ] == ' ▁ ' ) Console . Write ( str [ i ] ) ; } Console . WriteLine ( ) ; } public static void Main ( String [ ] args ) { String str = " geeksforgeeks " ; cipher ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: LatinCipher
C# program:
using System ; class GFG { public static bool checkPalin ( string word ) { int n = word . Length ; word = word . ToLower ( ) ; for ( int i = 0 ; i < n ; i ++ , n -- ) { if ( word [ i ] != word [ n - 1 ] ) { return false ; } } return true ; } public static int countPalin ( string str ) { str = str + " ▁ " ; string word = " " ; int count = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { char ch = str [ i ] ; if ( ch != ' ▁ ' ) { word = word + ch ; } else { if ( checkPalin ( word ) ) { count ++ ; } word = " " ; } } return count ; } public static void Main ( string [ ] args ) { Console . WriteLine ( countPalin ( " Madam ▁ " + " Arora ▁ teaches ▁ malayalam " ) ) ; Console . WriteLine ( countPalin ( " Nitin ▁ " + " speaks ▁ malayalam " ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, n
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int n ; public static string z ; public static string [ ] s = new string [ 100 ] ; public static char [ ] w ; public static char letter ; public static bool [ ] pre = new bool [ 100 ] ; public static void verify ( int position , int index ) { int l = z . Length ; int k = s [ index ] . Length ; if ( position + k > l ) { return ; } bool same = true ; for ( int i = position ; i < position + k ; i ++ ) { int n , n1 ; char ch = w [ i ] ; char ch1 = s [ index ] [ i - position ] ; if ( ch >= ' a ' && ch <= ' z ' ) { n = ch - ' a ' ; } else { n = ch - ' A ' ; } if ( ch1 >= ' a ' && ch1 <= ' z ' ) { n1 = ch1 - ' a ' ; } else { n1 = ch1 - ' A ' ; } if ( n != n1 ) { same = false ; } } if ( same == true ) { for ( int i = position ; i < position + k ; i ++ ) { pre [ i ] = true ; } return ; } } public static void solve ( ) { w = z . ToCharArray ( ) ; letter = ' d ' ; int l = z . Length ; int p = letter - ' a ' ; for ( int i = 0 ; i < 100 ; i ++ ) { pre [ i ] = false ; } for ( int i = 0 ; i < l ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { verify ( i , j ) ; } } for ( int i = 0 ; i < l ; i ++ ) { if ( pre [ i ] == true ) { if ( w [ i ] == letter ) { w [ i ] = ( letter == ' a ' ) ? ' b ' : ' a ' ; } else if ( w [ i ] == ( char ) ( ( int ) ' A ' + p ) ) { w [ i ] = ( letter == ' a ' ) ? ' B ' : ' A ' ; } else if ( w [ i ] >= ' a ' && w [ i ] <= ' z ' ) { w [ i ] = letter ; } else if ( w [ i ] >= ' A ' && w [ i ] <= ' Z ' ) { w [ i ] = ( char ) ( ( int ) ' A ' + p ) ; } } } Console . WriteLine ( w ) ; } public static void Main ( string [ ] args ) { n = 3 ; s [ 0 ] = " etr " ; s [ 1 ] = " ed " ; s [ 2 ] = " ied " ; z = " PEtrUnited " ; solve ( ) ; } }

Index/key variables: i, index
Accumulator variables: i, j
Iterator variables: i, j
Boolean variables: same
Class/struct names: GFG
C# program:
using System ; class GFG { static int round ( int n ) { int a = ( n / 10 ) * 10 ; int b = a + 10 ; return ( n - a > b - n ) ? b : a ; } public static void Main ( ) { int n = 4722 ; Console . WriteLine ( round ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int calculate ( String N ) { int len = N . Length ; int l = ( len ) / 2 ; int count = 0 ; for ( int i = 1 ; i <= l ; i ++ ) { String s = N . Substring ( 0 , i ) ; int l1 = s . Length ; String t = N . Substring ( i , l1 ) ; if ( s [ 0 ] == '0' t [ 0 ] == '0' ) continue ; if ( s . CompareTo ( t ) == 0 ) count ++ ; } return count ; } public static void Main ( String [ ] args ) { String N = "2202200" ; Console . Write ( calculate ( N ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countOccurrences ( string s , int K ) { int n = s . Length ; int C = 0 , c1 = 0 , c2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ' a ' ) c1 ++ ; if ( s [ i ] == ' b ' ) { c2 ++ ; C += c1 ; } } return C * K + ( K * ( K - 1 ) / 2 ) * c1 * c2 ; } public static void Main ( ) { string S = " abcb " ; int k = 2 ; Console . WriteLine ( countOccurrences ( S , k ) ) ; } }

Index/key variables: i
Accumulator variables: C, c1, c2, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static string findString ( int n , int k ) { string res = " " ; for ( int i = 0 ; i < k ; i ++ ) res = res + ( char ) ( ' a ' + i ) ; int count = 0 ; for ( int i = 0 ; i < n - k ; i ++ ) { res = res + ( char ) ( ' a ' + count ) ; count ++ ; if ( count == k ) count = 0 ; } return res ; } static public void Main ( ) { int n = 5 , k = 2 ; Console . WriteLine ( findString ( n , k ) ) ; } }

Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class CreditCard { public static void Main ( ) { long number = 5196081888500645L ; Console . Write ( number + " ▁ is ▁ " + ( isValid ( number ) ? " valid " : " invalid " ) ) ; } public static bool isValid ( long number ) { return ( getSize ( number ) >= 13 && getSize ( number ) <= 16 ) && ( prefixMatched ( number , 4 ) || prefixMatched ( number , 5 ) || prefixMatched ( number , 37 ) || prefixMatched ( number , 6 ) ) && ( ( sumOfDoubleEvenPlace ( number ) + sumOfOddPlace ( number ) ) % 10 == 0 ) ; } public static int sumOfDoubleEvenPlace ( long number ) { int sum = 0 ; String num = number + " " ; for ( int i = getSize ( number ) - 2 ; i >= 0 ; i -= 2 ) sum += getDigit ( int . Parse ( num [ i ] + " " ) * 2 ) ; return sum ; } public static int getDigit ( int number ) { if ( number < 9 ) return number ; return number / 10 + number % 10 ; } public static int sumOfOddPlace ( long number ) { int sum = 0 ; String num = number + " " ; for ( int i = getSize ( number ) - 1 ; i >= 0 ; i -= 2 ) sum += int . Parse ( num [ i ] + " " ) ; return sum ; } public static bool prefixMatched ( long number , int d ) { return getPrefix ( number , getSize ( d ) ) == d ; } public static int getSize ( long d ) { String num = d + " " ; return num . Length ; } public static long getPrefix ( long number , int k ) { if ( getSize ( number ) > k ) { String num = number + " " ; return long . Parse ( num . Substring ( 0 , k ) ) ; } return number ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: CreditCard
C# program:
using System ; using System . Collections . Generic ; public class GFG { public static bool isVowel ( char x ) { return ( x == ' a ' x == ' e ' x == ' i ' x == ' o ' x == ' u ' ) ; } public static void findSubstring ( string str ) { HashSet < char > hash = new HashSet < char > ( ) ; int start = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( isVowel ( str [ i ] ) == true ) { hash . Add ( str [ i ] ) ; if ( hash . Count == 5 ) { Console . Write ( str . Substring ( start , ( i + 1 ) - start ) + " ▁ " ) ; } } else { start = i + 1 ; hash . Clear ( ) ; } } } public static void Main ( string [ ] args ) { string str = " aeoibsddaeiouudb " ; findSubstring ( 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 { public static String concatenatedString ( String s1 , String s2 ) { String res = " " ; int i ; Dictionary < char , int > m = new Dictionary < char , int > ( ) ; for ( i = 0 ; i < s2 . Length ; i ++ ) if ( ! m . ContainsKey ( s2 [ i ] ) ) m . Add ( s2 [ i ] , 1 ) ; for ( i = 0 ; i < s1 . Length ; i ++ ) if ( ! m . ContainsKey ( s1 [ i ] ) ) res += s1 [ i ] ; else m [ s1 [ i ] ] = 2 ; for ( i = 0 ; i < s2 . Length ; i ++ ) if ( m [ s2 [ i ] ] == 1 ) res += s2 [ i ] ; return res ; } public static void Main ( String [ ] args ) { String s1 = " abcs " ; String s2 = " cxzca " ; Console . WriteLine ( concatenatedString ( s1 , s2 ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPS ( String str ) { String temp = " " ; String stf ; int count = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { for ( int j = i + 1 ; j <= str . Length ; j ++ ) { temp = str . Substring ( i , j - i ) ; if ( temp . Length >= 2 ) { stf = temp ; stf = reverse ( temp ) ; if ( stf . ToString ( ) . CompareTo ( temp ) == 0 ) count ++ ; } } } return count ; } static String reverse ( String input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = 0 ; 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 str = " abbaeae " ; Console . WriteLine ( countPS ( str ) ) ; } }

Index/key variables: l, r
Accumulator variables: count, i, j, l, r
Iterator variables: i, j, l
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Text ; class Subsequence { static HashSet < String > st = new HashSet < String > ( ) ; static void subsequence ( String str ) { for ( int i = 0 ; i < str . Length ; i ++ ) { if ( isVowel ( str [ i ] ) ) { for ( int j = ( str . Length - 1 ) ; j >= i ; j -- ) { if ( isConsonant ( str [ j ] ) ) { String str_sub = str . Substring ( i , j - i + 1 ) ; st . Add ( str_sub ) ; for ( int k = 1 ; k < str_sub . Length - 1 ; k ++ ) { StringBuilder sb = new StringBuilder ( str_sub ) ; sb . Remove ( k , 1 ) ; subsequence ( sb . ToString ( ) ) ; } } } } } } static bool isVowel ( char c ) { return ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) ; } static bool isConsonant ( char c ) { return ! isVowel ( c ) ; } public static void Main ( String [ ] args ) { String s = " xabcef " ; subsequence ( s ) ; foreach ( String str in st ) Console . Write ( str + " , ▁ " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, k
Iterator variables: i, j, k, str
Class/struct names: Subsequence
C# program:
using System ; class GFG { static String decode ( String str ) { String res = " " ; Boolean found = false ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] == ' ▁ ' ) { found = false ; continue ; } if ( ! found ) { if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) { res += ( char ) ( str [ i ] + 32 ) ; found = true ; } else if ( str [ i ] >= ' a ' && str [ i ] <= ' z ' ) { res += ( char ) str [ i ] ; found = true ; } } } return res ; } public static void Main ( String [ ] args ) { String str ; str = " A ▁ Step ▁ by ▁ Step ▁ Guide ▁ for ▁ Placement ▁ Preparation ▁ by ▁ GeeksforGeeks " ; Console . WriteLine ( " Enciphered ▁ Message : ▁ " + decode ( str ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Boolean variables: found
Class/struct names: GFG
C# program:
using System ; public class GFG { public static int isVowel ( char ch ) { ch = char . ToUpper ( ch ) ; if ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) { return 1 ; } else { return 0 ; } } public static int countVowels ( string str , int n ) { if ( n == 1 ) { return isVowel ( str [ n - 1 ] ) ; } return countVowels ( str , n - 1 ) + isVowel ( str [ n - 1 ] ) ; } public static void Main ( string [ ] args ) { string str = " abc ▁ de " ; Console . WriteLine ( countVowels ( str , str . Length ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Text ; class Test { static void printRotatedString ( String str ) { int n = str . Length ; StringBuilder sb = new StringBuilder ( str ) ; sb . Append ( str ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j != n ; j ++ ) Console . Write ( sb [ i + j ] ) ; Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { String str = " geeks " ; printRotatedString ( str ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: Test
C# program:
using System ; class GFG { static int M = 26 ; static int getIdx ( char ch ) { return ( ch - ' a ' ) ; } static bool allSame ( int [ ] freq , int N ) { int same = 0 ; int i ; for ( i = 0 ; i < N ; i ++ ) { if ( freq [ i ] > 0 ) { same = freq [ i ] ; break ; } } for ( int j = i + 1 ; j < N ; j ++ ) if ( freq [ j ] > 0 && freq [ j ] != same ) return false ; return true ; } static bool possibleSameCharFreqByOneRemoval ( string str ) { int l = str . Length ; int [ ] freq = new int [ M ] ; for ( int i = 0 ; i < l ; i ++ ) freq [ getIdx ( str [ i ] ) ] ++ ; if ( allSame ( freq , M ) ) return true ; for ( char c = ' a ' ; c <= ' z ' ; c ++ ) { int i = getIdx ( c ) ; if ( freq [ i ] > 0 ) { freq [ i ] -- ; if ( allSame ( freq , M ) ) return true ; freq [ i ] ++ ; } } return false ; } public static void Main ( ) { string str = " xyyzz " ; if ( possibleSameCharFreqByOneRemoval ( str ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: M, i, j
Accumulator variables: c, i, j
Iterator variables: c, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( string str ) { int n = str . Length ; int oddDigSum = 0 , evenDigSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) oddDigSum += ( str [ i ] - '0' ) ; else evenDigSum += ( str [ i ] - '0' ) ; } return ( ( oddDigSum - evenDigSum ) % 11 == 0 ) ; } public static void Main ( ) { String str = "76945" ; if ( check ( str ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: evenDigSum, i, oddDigSum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static readonly int ALPHABET_SIZE = 26 ; class TrieNode { public TrieNode [ ] children = new TrieNode [ ALPHABET_SIZE ] ; public int id ; public Boolean isLeaf ; public TrieNode ( ) { isLeaf = false ; pos = new List < int > ( ) ; for ( int i = 0 ; i < ALPHABET_SIZE ; i ++ ) children [ i ] = null ; } } static Boolean isPalindrome ( String str , int i , int len ) { while ( i < len ) { if ( str [ i ] != str [ len ] ) return false ; i ++ ; len -- ; } return true ; } static void insert ( TrieNode root , String key , int id ) { TrieNode pCrawl = root ; for ( int level = key . Length - 1 ; level >= 0 ; level -- ) { int index = key [ level ] - ' a ' ; if ( pCrawl . children [ index ] == null ) pCrawl . children [ index ] = new TrieNode ( ) ; if ( isPalindrome ( key , 0 , level ) ) ( pCrawl . pos ) . Add ( id ) ; pCrawl = pCrawl . children [ index ] ; } pCrawl . id = id ; pCrawl . pos . Add ( id ) ; pCrawl . isLeaf = true ; } static List < List < int > > result ; static void search ( TrieNode root , String key , int id ) { TrieNode pCrawl = root ; for ( int level = 0 ; level < key . Length ; level ++ ) { int index = key [ level ] - ' a ' ; if ( pCrawl . id >= 0 && pCrawl . id != id && isPalindrome ( key , level , key . Length - 1 ) ) { List < int > l = new List < int > ( ) ; l . Add ( id ) ; l . Add ( pCrawl . id ) ; result . Add ( l ) ; } if ( pCrawl . children [ index ] == null ) return ; pCrawl = pCrawl . children [ index ] ; } foreach ( int i in pCrawl . pos ) { if ( i == id ) continue ; List < int > l = new List < int > ( ) ; l . Add ( id ) ; l . Add ( i ) ; result . Add ( l ) ; } } static Boolean checkPalindromePair ( List < String > vect ) { TrieNode root = new TrieNode ( ) ; for ( int i = 0 ; i < vect . Count ; i ++ ) insert ( root , vect [ i ] , i ) ; result = new List < List < int > > ( ) ; for ( int i = 0 ; i < vect . Count ; i ++ ) { search ( root , vect [ i ] , i ) ; if ( result . Count > 0 ) return true ; } return false ; } public static void Main ( String [ ] args ) { List < String > vect = new List < String > ( ) { " geekf " , " geeks " , " or " , " keeg " , " abc " , " bc " } ; if ( checkPalindromePair ( vect ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: ALPHABET_SIZE, i, index, len, level
Accumulator variables: i, len, level
Iterator variables: i, level
Boolean variables: isLeaf
Class/struct names: GFG, TrieNode
C# program:
using System ; class GFG { static int hammingDist ( String str1 , String str2 ) { int i = 0 , count = 0 ; while ( i < str1 . Length ) { if ( str1 [ i ] != str2 [ i ] ) count ++ ; i ++ ; } return count ; } public static void Main ( ) { String str1 = " geekspractice " ; String str2 = " nerdspractise " ; Console . Write ( hammingDist ( str1 , str2 ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX_CHAR = 26 ; static bool arekAnagrams ( string str1 , string str2 , int k ) { int n = str1 . Length ; if ( str2 . Length != n ) return false ; int [ ] count1 = new int [ MAX_CHAR ] ; int [ ] count2 = new int [ MAX_CHAR ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) count1 [ str1 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < n ; i ++ ) count2 [ str2 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( count1 [ i ] > count2 [ i ] ) count = count + Math . Abs ( count1 [ i ] - count2 [ i ] ) ; return ( count <= k ) ; } public static void Main ( ) { string str1 = " anagram " ; string str2 = " grammar " ; int k = 2 ; if ( arekAnagrams ( str1 , str2 , k ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: MAX_CHAR, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int removeSpaces ( char [ ] str ) { int count = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) if ( str [ i ] != ' ▁ ' ) return count ; } public static void Main ( String [ ] args ) { char [ ] str = " g ▁ eeks ▁ for ▁ ge ▁ eeks ▁ " . ToCharArray ( ) ; int i = removeSpaces ( str ) ; Console . WriteLine ( String . Join ( " " , str ) . Substring ( 0 , i ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { int countSubStr ( char [ ] str , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == '1' ) m ++ ; } return m * ( m - 1 ) / 2 ; } public static void Main ( String [ ] args ) { GFG count = new GFG ( ) ; String strings = "00100101" ; char [ ] str = strings . ToCharArray ( ) ; int n = str . Length ; Console . Write ( count . countSubStr ( str , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, m
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int count9s ( String number ) { int count = 0 ; int n = number . Length ; for ( int i = 0 ; i < n ; i ++ ) { int sum = number [ i ] - '0' ; if ( number [ i ] == '9' ) count ++ ; for ( int j = i + 1 ; j < n ; j ++ ) { sum = ( sum + number [ j ] - '0' ) % 9 ; if ( sum == 0 ) count ++ ; } } return count ; } public static void Main ( ) { Console . WriteLine ( count9s ( "4189" ) ) ; Console . WriteLine ( count9s ( "1809" ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GfG { public static void generateGrayarr ( int n ) { if ( n <= 0 ) { return ; } List < string > arr = new List < string > ( ) ; arr . Add ( "0" ) ; arr . Add ( "1" ) ; int i , j ; for ( i = 2 ; i < ( 1 << n ) ; i = i << 1 ) { for ( j = i - 1 ; j >= 0 ; j -- ) { arr . Add ( arr [ j ] ) ; } for ( j = 0 ; j < i ; j ++ ) { arr [ j ] = "0" + arr [ j ] ; } for ( j = i ; j < 2 * i ; j ++ ) { arr [ j ] = "1" + arr [ j ] ; } } for ( i = 0 ; i < arr . Count ; i ++ ) { Console . WriteLine ( arr [ i ] ) ; } } public static void Main ( string [ ] args ) { generateGrayarr ( 3 ) ; } }

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 List < String > possiblePaths = new List < String > ( ) ; static String path = " " ; static readonly int MAX = 5 ; static bool isSafe ( int row , int col , int [ , ] m , int n , bool [ , ] visited ) { if ( row == - 1 row == n col == - 1 col == visited [ row , col ] m [ row , col ] == 0 ) return false ; return true ; } static void printPathUtil ( int row , int col , int [ , ] m , int n , bool [ , ] visited ) { if ( row == - 1 row == n col == - 1 col == visited [ row , col ] m [ row , col ] == 0 ) return ; if ( row == n - 1 && col == n - 1 ) { possiblePaths . Add ( path ) ; return ; } visited [ row , col ] = true ; if ( isSafe ( row + 1 , col , m , n , visited ) ) { path += ' D ' ; printPathUtil ( row + 1 , col , m , n , visited ) ; path = path . Substring ( 0 , path . Length - 1 ) ; } if ( isSafe ( row , col - 1 , m , n , visited ) ) { path += ' L ' ; printPathUtil ( row , col - 1 , m , n , visited ) ; path = path . Substring ( 0 , path . Length - 1 ) ; } if ( isSafe ( row , col + 1 , m , n , visited ) ) { path += ' R ' ; printPathUtil ( row , col + 1 , m , n , visited ) ; path = path . Substring ( 0 , path . Length - 1 ) ; } if ( isSafe ( row - 1 , col , m , n , visited ) ) { path += ' U ' ; printPathUtil ( row - 1 , col , m , n , visited ) ; path = path . Substring ( 0 , path . Length - 1 ) ; } visited [ row , col ] = false ; } static void printPath ( int [ , ] m , int n ) { bool [ , ] visited = new bool [ n , MAX ] ; printPathUtil ( 0 , 0 , m , n , visited ) ; for ( int i = 0 ; i < possiblePaths . Count ; i ++ ) Console . Write ( possiblePaths [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ , ] m = { { 1 , 0 , 0 , 0 , 0 } , { 1 , 1 , 1 , 1 , 1 } , { 1 , 1 , 1 , 0 , 1 } , { 0 , 0 , 0 , 0 , 1 } , { 0 , 0 , 0 , 0 , 1 } } ; int n = m . GetLength ( 0 ) ; printPath ( m , n ) ; } }

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