dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int binpow ( int a , int b ) { int res = 1 ; while ( b > 0 ) { if ( b % 2 == 1 ) res = res * a ; a = a * a ; b /= 2 ; } return res ; } static int find ( int x ) { if ( x == 0 ) return 0 ; int p = ( int ) ( Math . Log ( x ) / Math . Log ( 2 ) ) ; return binpow ( 2 , p + 1 ) - 1 ; } static String getBinary ( int n ) { String ans = " " ; while ( n > 0 ) { int dig = n % 2 ; ans += dig ; n /= 2 ; } return ans ; } static int totalCountDifference ( int n ) { string ans = getBinary ( n ) ; int req = 0 ; for ( int i = 0 ; i < ans . Length ; i ++ ) { if ( ans [ i ] == '1' ) { req += find ( binpow ( 2 , i ) ) ; } } return req ; } public static void Main ( ) { int n = 5 ; Console . Write ( totalCountDifference ( n ) ) ; } }

Index/key variables: i
Accumulator variables: ans, b, i, n, req
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int Maximum_Length ( List < int > a ) { int [ ] counts = new int [ 11 ] ; int ans = 0 ; for ( int index = 0 ; index < a . Count ; index ++ ) { counts [ a [ index ] ] += 1 ; List < int > k = new List < int > ( ) ; foreach ( int i in counts ) if ( i != 0 ) k . Add ( i ) ; k . Sort ( ) ; if ( k . Count == 1 || ( k [ 0 ] == k [ k . Count - 2 ] && k [ k . Count - 1 ] - k [ k . Count - 2 ] == 1 ) || ( k [ 0 ] == 1 && k [ 1 ] == k [ k . Count - 1 ] ) ) ans = index ; } return ans + 1 ; } static void Main ( ) { List < int > a = new List < int > ( new int [ ] { 1 , 1 , 1 , 2 , 2 , 2 } ) ; Console . Write ( Maximum_Length ( a ) ) ; } }

Index/key variables: index
Accumulator variables: index
Iterator variables: i, index
Class/struct names: GFG
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static void print_gcd_online ( int n , int m , int [ , ] query , int [ ] arr ) { int max_gcd = 0 ; int i = 0 ; for ( i = 0 ; i < n ; i ++ ) max_gcd = gcd ( max_gcd , arr [ i ] ) ; for ( i = 0 ; i < m ; i ++ ) { query [ i , 0 ] -- ; arr [ query [ i , 0 ] ] /= query [ i , 1 ] ; max_gcd = gcd ( arr [ query [ i , 0 ] ] , max_gcd ) ; Console . WriteLine ( max_gcd ) ; } } public static void Main ( ) { int n = 3 ; int m = 3 ; int [ , ] query = new int [ m , 2 ] ; int [ ] arr = new int [ ] { 36 , 24 , 72 } ; query [ 0 , 0 ] = 1 ; query [ 0 , 1 ] = 3 ; query [ 1 , 0 ] = 3 ; query [ 1 , 1 ] = 12 ; query [ 2 , 0 ] = 2 ; query [ 2 , 1 ] = 4 ; print_gcd_online ( n , m , query , arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 1000000 ; static bool [ ] prime = new bool [ MAX + 1 ] ; static int [ ] sum = new int [ MAX + 1 ] ; static void SieveOfEratosthenes ( ) { for ( int i = 0 ; i <= MAX ; i ++ ) prime [ i ] = true ; for ( int i = 0 ; i <= MAX ; i ++ ) sum [ i ] = 0 ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= MAX ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= MAX ; i += p ) prime [ i ] = false ; } } for ( int i = 1 ; i <= MAX ; i ++ ) { if ( prime [ i ] == true ) sum [ i ] = 1 ; sum [ i ] += sum [ i - 1 ] ; } } public static void Main ( ) { SieveOfEratosthenes ( ) ; int l = 3 , r = 9 ; int c = ( sum [ r ] - sum [ l - 1 ] ) ; Console . WriteLine ( " Count : ▁ " + c ) ; } }

Index/key variables: i, p, r
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static float area ( float r ) { if ( r < 0 ) return - 1 ; float area = ( float ) ( 3.14 * Math . Pow ( r / ( 2 * Math . Sqrt ( 2 ) ) , 2 ) ) ; return area ; } static public void Main ( String [ ] args ) { float a = 5 ; Console . WriteLine ( area ( a ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 100005 ; static bool [ ] prime = new bool [ N ] ; static void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < N ; i ++ ) prime [ i ] = true ; prime [ 1 ] = false ; for ( int p = 2 ; p * p < N ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i < N ; i += p ) prime [ i ] = false ; } } } static int almostPrimes ( int n ) { int ans = 0 ; for ( int i = 6 ; i <= n ; i ++ ) { int c = 0 ; for ( int j = 2 ; j * j <= i ; j ++ ) { if ( i % j == 0 ) { if ( j * j == i ) { if ( prime [ j ] ) c ++ ; } else { if ( prime [ j ] ) c ++ ; if ( prime [ i / j ] ) c ++ ; } } } if ( c == 2 ) ans ++ ; } return ans ; } public static void Main ( ) { SieveOfEratosthenes ( ) ; int n = 21 ; Console . WriteLine ( almostPrimes ( n ) ) ; } }

Index/key variables: N, i, j, p
Accumulator variables: ans, c, i, j, p
Iterator variables: i, j, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int sumOfDigitsSingle ( int x ) { int ans = 0 ; while ( x != 0 ) { ans += x % 10 ; x /= 10 ; } return ans ; } static int closest ( int x ) { int ans = 0 ; while ( ans * 10 + 9 <= x ) ans = ans * 10 + 9 ; return ans ; } static int sumOfDigitsTwoParts ( int N ) { int A = closest ( N ) ; return sumOfDigitsSingle ( A ) + sumOfDigitsSingle ( N - A ) ; } public static void Main ( ) { int N = 35 ; Console . Write ( sumOfDigitsTwoParts ( N ) ) ; } }

Accumulator variables: ans, x
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPrime ( int p ) { double checkNumber = Math . Pow ( 2 , p ) - 1 ; double nextval = 4 % checkNumber ; for ( int i = 1 ; i < p - 1 ; i ++ ) nextval = ( nextval * nextval - 2 ) % checkNumber ; return ( nextval == 0 ) ; } static void Main ( ) { int p = 7 ; double checkNumber = Math . Pow ( 2 , p ) - 1 ; if ( isPrime ( p ) ) Console . WriteLine ( ( int ) checkNumber + " ▁ is ▁ Prime . " ) ; else Console . WriteLine ( ( int ) checkNumber + " ▁ is ▁ not ▁ Prime . " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void sieve ( int n , bool [ ] prime ) { for ( int p = 2 ; p * p <= n ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * 2 ; i < n ; i += p ) prime [ i ] = false ; } } } static void printSophieGermanNumber ( int n ) { bool [ ] prime = new bool [ 2 * n + 1 ] ; for ( int i = 0 ; i < prime . Length ; i ++ ) { prime [ i ] = true ; } sieve ( 2 * n + 1 , prime ) ; for ( int i = 2 ; i < n ; ++ i ) { if ( prime [ i ] && prime [ 2 * i + 1 ] ) Console . Write ( i + " ▁ " ) ; } } static void Main ( ) { int n = 25 ; printSophieGermanNumber ( n ) ; } }

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
class GFG { static double ucal ( double u , int n ) { if ( n == 0 ) return 1 ; double temp = u ; for ( int i = 1 ; i <= n / 2 ; i ++ ) temp = temp * ( u - i ) ; for ( int i = 1 ; i < n / 2 ; i ++ ) temp = temp * ( u + i ) ; return temp ; } static int fact ( int n ) { int f = 1 ; for ( int i = 2 ; i <= n ; i ++ ) f *= i ; return f ; } public static void Main ( ) { int n = 6 ; double [ ] x = { 25 , 26 , 27 , 28 , 29 , 30 } ; double [ , ] y = new double [ n , n ] ; y [ 0 , 0 ] = 4.000 ; y [ 1 , 0 ] = 3.846 ; y [ 2 , 0 ] = 3.704 ; y [ 3 , 0 ] = 3.571 ; y [ 4 , 0 ] = 3.448 ; y [ 5 , 0 ] = 3.333 ; for ( int i = 1 ; i < n ; i ++ ) for ( int j = 0 ; j < n - i ; j ++ ) y [ j , i ] = y [ j + 1 , i - 1 ] - y [ j , i - 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n - i ; j ++ ) System . Console . Write ( y [ i , j ] + " TABSYMBOL " ) ; System . Console . WriteLine ( " " ) ; } double value = 27.4 ; double sum = ( y [ 2 , 0 ] + y [ 3 , 0 ] ) / 2 ; int k ; k = n / 2 ; else double u = ( value - x [ k ] ) / ( x [ 1 ] - x [ 0 ] ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( ( i % 2 ) > 0 ) sum = sum + ( ( u - 0.5 ) * ucal ( u , i - 1 ) * y [ k , i ] ) / fact ( i ) ; else sum = sum + ( ucal ( u , i ) * ( y [ k , i ] + y [ -- k , i ] ) / ( fact ( i ) * 2 ) ) ; } System . Console . WriteLine ( " Value ▁ at ▁ " + value + " ▁ is ▁ " + System . Math . Round ( sum , 5 ) ) ; } }

Index/key variables: k
Accumulator variables: f, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int fibonacci ( int n ) { int a = 0 ; int b = 1 ; int c = 0 ; if ( n <= 1 ) return n ; for ( int i = 2 ; i <= n ; i ++ ) { c = a + b ; a = b ; b = c ; } return c ; } static bool isMultipleOf10 ( int n ) { int f = fibonacci ( 30 ) ; return ( f % 10 == 0 ) ; } public static void Main ( ) { int n = 30 ; if ( isMultipleOf10 ( n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool isPowerofTwo ( int n ) { if ( n == 0 ) return false ; if ( ( n & ( ~ ( n - 1 ) ) ) == n ) return true ; return false ; } public static void Main ( String [ ] args ) { if ( isPowerofTwo ( 30 ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; if ( isPowerofTwo ( 128 ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int nextPowerOf2 ( int n ) { int p = 1 ; if ( n != 0 && ( ( n & ( n - 1 ) ) == 0 ) ) return n ; while ( p < n ) p <<= 1 ; return p ; } static int memoryUsed ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; int nearest = nextPowerOf2 ( sum ) ; return nearest ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 2 } ; int n = arr . Length ; Console . WriteLine ( memoryUsed ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int toggleKthBit ( int n , int k ) { return ( n ^ ( 1 << ( k - 1 ) ) ) ; } public static void Main ( ) { int n = 5 , k = 1 ; Console . WriteLine ( toggleKthBit ( n , k ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int nextPowerOf2 ( int n ) { int count = 0 ; if ( n > 0 && ( n & ( n - 1 ) ) == 0 ) return n ; while ( n != 0 ) { n >>= 1 ; count += 1 ; } return 1 << count ; } public static void Main ( ) { int n = 0 ; Console . WriteLine ( nextPowerOf2 ( n ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; using System . Linq ; class GFG { static void variationStalinsort ( List < int > arr ) { int j = 0 ; while ( true ) { int moved = 0 ; for ( int i = 0 ; i < ( arr . Count - 1 - j ) ; i ++ ) { if ( arr [ i ] > arr [ i + 1 ] ) { int index ; int temp ; index = arr [ i ] ; temp = arr [ i + 1 ] ; arr . Remove ( index ) ; arr . Insert ( i , temp ) ; arr . Remove ( temp ) ; arr . Insert ( i + 1 , index ) ; moved ++ ; } } j ++ ; if ( moved == 0 ) { break ; } } foreach ( int i in arr ) Console . Write ( i + " ▁ " ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 2 , 1 , 4 , 3 , 6 , 5 , 8 , 7 , 10 , 9 } ; List < int > arr1 = new List < int > ( ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) arr1 . Add ( arr [ i ] ) ; variationStalinsort ( arr1 ) ; } }

Index/key variables: i
Accumulator variables: i, j, moved
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void printArray ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void sortArray ( int [ ] arr , int N ) { for ( int i = 0 ; i < N ; ) { if ( arr [ i ] == i + 1 ) { i ++ ; } else { int temp1 = arr [ i ] ; int temp2 = arr [ arr [ i ] - 1 ] ; arr [ i ] = temp2 ; arr [ temp1 - 1 ] = temp1 ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 5 , 3 , 4 } ; int N = arr . Length ; sortArray ( arr , N ) ; printArray ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int maximum ( int [ ] value , int [ ] weight , int weight1 , int flag , int K , int index ) { if ( index >= value . Length ) { return 0 ; } if ( flag == K ) { int skip = maximum ( value , weight , weight1 , flag , K , index + 1 ) ; int full = 0 ; if ( weight [ index ] <= weight1 ) { full = value [ index ] + maximum ( value , weight , weight1 - weight [ index ] , flag , K , index + 1 ) ; } return Math . Max ( full , skip ) ; } else { int skip = maximum ( value , weight , weight1 , flag , K , index + 1 ) ; int full = 0 ; int half = 0 ; if ( weight [ index ] <= weight1 ) { full = value [ index ] + maximum ( value , weight , weight1 - weight [ index ] , flag , K , index + 1 ) ; } if ( weight [ index ] / 2 <= weight1 ) { half = value [ index ] + maximum ( value , weight , weight1 - weight [ index ] / 2 , flag , K , index + 1 ) ; } return Math . Max ( full , Math . Max ( skip , half ) ) ; } } public static void Main ( String [ ] args ) { int [ ] value = { 17 , 20 , 10 , 15 } ; int [ ] weight = { 4 , 2 , 7 , 5 } ; int K = 1 ; int W = 4 ; Console . WriteLine ( maximum ( value , weight , W , 0 , K , 0 ) ) ; } }

Index/key variables: index
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int N = 1005 ; public class Node { public int data ; public Node left , right ; } ; public static Node newNode ( int data ) { Node node = new Node ( ) ; node . data = data ; node . left = node . right = null ; return node ; } static int [ , , ] dp = new int [ N , 5 , 5 ] ; static int minDominatingSet ( Node root , int covered , int compulsory ) { if ( root == null ) return 0 ; if ( root . left != null && root . right != null && covered > 0 ) compulsory = 1 ; if ( dp [ root . data , covered , compulsory ] != - 1 ) return dp [ root . data , covered , compulsory ] ; if ( compulsory > 0 ) { return dp [ root . data , covered , compulsory ] = 1 + minDominatingSet ( root . left , 1 , 0 ) + minDominatingSet ( root . right , 1 , 0 ) ; } if ( covered > 0 ) { return dp [ root . data , covered , compulsory ] = Math . Min ( 1 + minDominatingSet ( root . left , 1 , 0 ) + minDominatingSet ( root . right , 1 , 0 ) , minDominatingSet ( root . left , 0 , 0 ) + minDominatingSet ( root . right , 0 , 0 ) ) ; } int ans = 1 + minDominatingSet ( root . left , 1 , 0 ) + minDominatingSet ( root . right , 1 , 0 ) ; if ( root . left != null ) { ans = Math . Min ( ans , minDominatingSet ( root . left , 0 , 1 ) + minDominatingSet ( root . right , 0 , 0 ) ) ; } if ( root . right != null ) { ans = Math . Min ( ans , minDominatingSet ( root . left , 0 , 0 ) + minDominatingSet ( root . right , 0 , 1 ) ) ; } return dp [ root . data , covered , compulsory ] = ans ; } public static void Main ( String [ ] args ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < 5 ; j ++ ) { for ( int l = 0 ; l < 5 ; l ++ ) dp [ i , j , l ] = - 1 ; } } Node root = newNode ( 1 ) ; root . left = newNode ( 2 ) ; root . left . left = newNode ( 3 ) ; root . left . right = newNode ( 4 ) ; root . left . left . left = newNode ( 5 ) ; root . left . left . left . left = newNode ( 6 ) ; root . left . left . left . right = newNode ( 7 ) ; root . left . left . left . right . right = newNode ( 10 ) ; root . left . left . left . left . left = newNode ( 8 ) ; root . left . left . left . left . right = newNode ( 9 ) ; Console . Write ( minDominatingSet root , 0 , 0 ) + " STRNEWLINE " ) ; } }

Accumulator variables: i, j, l
Iterator variables: i, j, l
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int maxSum = 100 ; static int arrSize = 51 ; static int [ , ] dp = new int [ arrSize , maxSum ] ; static bool [ , ] visit = new bool [ arrSize , maxSum ] ; static int SubsetCnt ( int i , int s , int [ ] arr , int n ) { if ( i == n ) { if ( s == 0 ) { return 1 ; } else { return 0 ; } } if ( visit [ i , s + arrSize ] ) { return dp [ i , s + arrSize ] ; } visit [ i , s + arrSize ] = true ; dp [ i , s + arrSize ] = SubsetCnt ( i + 1 , s + arr [ i ] , arr , n ) + SubsetCnt ( i + 1 , s , arr , n ) ; return dp [ i , s + arrSize ] ; } public static void Main ( ) { int [ ] arr = { 2 , 2 , 2 , - 4 , - 4 } ; int n = arr . Length ; Console . WriteLine ( SubsetCnt ( 0 , 0 , arr , n ) ) ; } }

Index/key variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int MAX = 1000 ; static int waysToKAdjacentSetBits ( int [ , , ] dp , int n , int k , int currentIndex , int adjacentSetBits , int lastBit ) { if ( currentIndex == n ) { if ( adjacentSetBits == k ) return 1 ; return 0 ; } if ( dp [ currentIndex , adjacentSetBits , lastBit ] != - 1 ) { return dp [ currentIndex , adjacentSetBits , lastBit ] ; } int noOfWays = 0 ; if ( lastBit == 1 ) { noOfWays += waysToKAdjacentSetBits ( dp , n , k , currentIndex + 1 , adjacentSetBits + 1 , 1 ) ; noOfWays += waysToKAdjacentSetBits ( dp , n , k , currentIndex + 1 , adjacentSetBits , 0 ) ; } else if ( lastBit == 0 ) { noOfWays += waysToKAdjacentSetBits ( dp , n , k , currentIndex + 1 , adjacentSetBits , 1 ) ; noOfWays += waysToKAdjacentSetBits ( dp , n , k , currentIndex + 1 , adjacentSetBits , 0 ) ; } dp [ currentIndex , adjacentSetBits , lastBit ] = noOfWays ; return noOfWays ; } public static void Main ( String [ ] args ) { int n = 5 , k = 2 ; int [ , , ] dp = new int [ MAX , MAX , 2 ] ; for ( int i = 0 ; i < MAX ; i ++ ) for ( int j = 0 ; j < MAX ; j ++ ) for ( int k1 = 0 ; k1 < 2 ; k1 ++ ) dp [ i , j , k1 ] = - 1 ; int totalWays = waysToKAdjacentSetBits ( dp , n , k , 1 , 0 , 1 ) + waysToKAdjacentSetBits ( dp , n , k , 1 , 0 , 0 ) ; Console . Write ( " Number ▁ of ▁ ways ▁ = ▁ " + totalWays + " STRNEWLINE " ) ; } }

Accumulator variables: i, j, k1, noOfWays
Iterator variables: i, j, k1
Class/struct names: GFG
C# program:
using System ; class GFG { static void printTetra ( int n ) { if ( n < 0 ) return ; int first = 0 , second = 1 ; int third = 1 , fourth = 2 ; int curr = 0 ; if ( n == 0 ) Console . Write ( first ) ; else if ( n == 1 n == 2 ) Console . Write ( second ) ; else if ( n == 3 ) Console . Write ( fourth ) ; else { for ( int i = 4 ; i <= n ; i ++ ) { curr = first + second + third + fourth ; first = second ; second = third ; third = fourth ; fourth = curr ; } Console . Write ( curr ) ; } } static public void Main ( ) { int n = 10 ; printTetra ( n ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GfG { public static int countWays ( int n ) { int [ ] res = new int [ n + 2 ] ; res [ 0 ] = 1 ; res [ 1 ] = 1 ; res [ 2 ] = 2 ; for ( int i = 3 ; i <= n ; i ++ ) res [ i ] = res [ i - 1 ] + res [ i - 2 ] + res [ i - 3 ] ; return res [ n ] ; } public static void Main ( ) { int n = 4 ; Console . WriteLine ( countWays ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; class GFG { static int countWays ( int n ) { int a = 1 , b = 2 , c = 4 ; int d = 0 ; if ( n == 0 n == 1 n == 2 ) return n ; if ( n == 3 ) return c ; for ( int i = 4 ; i <= n ; i ++ ) { d = c + b + a ; a = b ; b = c ; c = d ; } return d ; } public static void Main ( String [ ] args ) { int n = 4 ; Console . Write ( countWays ( n ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static Boolean isPossible ( int [ ] elements , int sum ) { int [ ] dp = new int [ sum + 1 ] ; dp [ 0 ] = 1 ; for ( int i = 0 ; i < elements . Length ; i ++ ) { for ( int j = sum ; j >= elements [ i ] ; j -- ) { if ( dp [ j - elements [ i ] ] == 1 ) dp [ j ] = 1 ; } } if ( dp [ sum ] == 1 ) return true ; return false ; } public static void Main ( String [ ] args ) { int [ ] elements = { 6 , 2 , 5 } ; int sum = 7 ; if ( isPossible ( elements , sum ) ) Console . Write ( " YES " ) ; else Console . Write ( " NO " ) ; } }

Index/key variables: i, j, sum
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxTasks ( int [ ] high , int [ ] low , int n ) { if ( n <= 0 ) return 0 ; return Math . Max ( high [ n - 1 ] + maxTasks ( high , low , ( n - 2 ) ) , low [ n - 1 ] + maxTasks ( high , low , ( n - 1 ) ) ) ; } public static void Main ( ) { int n = 5 ; int [ ] high = { 3 , 6 , 8 , 7 , 6 } ; int [ ] low = { 1 , 5 , 4 , 5 , 3 } ; Console . Write ( maxTasks ( high , low , n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static int nCr ( int n , int r ) { if ( r > n ) return 0 ; if ( r > n - r ) r = n - r ; int mod = 1000000007 ; int [ ] arr = new int [ r ] ; for ( int i = n - r + 1 ; i <= n ; i ++ ) { arr [ i + r - n - 1 ] = i ; } long ans = 1 ; for ( int k = 1 ; k < r + 1 ; k ++ ) { int j = 0 , i = k ; while ( j < arr . Length ) { int x = gcd ( i , arr [ j ] ) ; if ( x > 1 ) { arr [ j ] /= x ; i /= x ; } if ( i == 1 ) break ; j += 1 ; } } foreach ( int i in arr ) ans = ( ans * i ) % mod ; return ( int ) ans ; } static public void Main ( ) { int n = 5 , r = 2 ; Console . WriteLine ( " Value ▁ of ▁ C ( " + n + " , ▁ " + r + " ) ▁ is ▁ " + nCr ( n , r ) + " STRNEWLINE " ) ; } }

Index/key variables: j, r
Accumulator variables: i, j, k
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static char FindKthChar ( string str , int K , int X ) { char ans = ' ▁ ' ; int sum = 0 ; for ( int i = 0 ; i < str . Length ; i ++ ) { int digit = ( int ) str [ i ] - 48 ; int range = ( int ) Math . Pow ( digit , X ) ; sum += range ; if ( K <= sum ) { ans = str [ i ] ; break ; } } return ans ; } public static void Main ( ) { string str = "123" ; int K = 9 ; int X = 3 ; char ans = FindKthChar ( str , K , X ) ; Console . Write ( ans ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static int totalPairs ( string s1 , string s2 ) { int count = 0 ; int [ ] arr1 = new int [ 7 ] ; int [ ] arr2 = new int [ 7 ] ; for ( int i = 0 ; i < s1 . Length ; i ++ ) { int set_bits = Convert . ToString ( ( int ) s1 [ i ] , 2 ) . Count ( c => c == '1' ) ; arr1 [ set_bits ] ++ ; } for ( int i = 0 ; i < s2 . Length ; i ++ ) { int set_bits = Convert . ToString ( ( int ) s2 [ i ] , 2 ) . Count ( c => c == '1' ) ; arr2 [ set_bits ] ++ ; } for ( int i = 1 ; i <= 6 ; i ++ ) count += ( arr1 [ i ] * arr2 [ i ] ) ; return count ; } static void Main ( ) { string s1 = " geeks " ; string s2 = " forgeeks " ; Console . WriteLine ( totalPairs ( s1 , s2 ) ) ; } }

Index/key variables: i, set_bits
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countSubstr ( string str , int n , char x , char y ) { int tot_count = 0 ; int count_x = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == x ) count_x ++ ; if ( str [ i ] == y ) tot_count += count_x ; } return tot_count ; } public static void Main ( ) { string str = " abbcaceghcak " ; int n = str . Length ; char x = ' a ' , y = ' c ' ; Console . Write ( " Count ▁ = ▁ " + countSubstr ( str , n , x , y ) ) ; } }

Index/key variables: i
Accumulator variables: count_x, i, tot_count
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int OUT = 0 ; static int IN = 1 ; static int countWords ( String str ) { int state = OUT ; int wc = 0 ; int i = 0 ; while ( i < str . Length ) { if ( str [ i ] == ' ▁ ' str [ i ] == ' STRNEWLINE ' str [ i ] == ' TABSYMBOL ' ) state = OUT ; else if ( state == OUT ) { state = IN ; ++ wc ; } ++ i ; } return wc ; } public static void Main ( ) { String str = " One ▁ two TABSYMBOL three STRNEWLINE ▁ four TABSYMBOL five ▁ " ; Console . WriteLine ( " No ▁ of ▁ words ▁ : ▁ " + countWords ( str ) ) ; } }

Index/key variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int nthEnneadecagonal ( int n ) { return ( 17 * n * n - 15 * n ) / 2 ; } static public void Main ( ) { int n = 6 ; Console . Write ( n + " th ▁ Enneadecagonal ▁ number ▁ : " ) ; Console . WriteLine ( nthEnneadecagonal ( n ) ) ; } }

Class/struct names: GFG