dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int EulerTotientFunction ( int limit ) { int copy = limit ; List < int > primes = new List < int > ( ) ; for ( int i = 2 ; i * i <= limit ; i ++ ) { if ( limit % i == 0 ) { while ( limit % i == 0 ) { limit /= i ; } primes . Add ( i ) ; } } if ( limit >= 2 ) { primes . Add ( limit ) ; } int ans = copy ; foreach ( int it in primes ) { ans = ( ans / it ) * ( it - 1 ) ; } return ans ; } static void CountGCD ( int m , int k ) { if ( m % k != 0 ) { Console . Write ( 0 + " STRNEWLINE " ) ; return ; } if ( m == k ) { Console . Write ( 2 + " STRNEWLINE " ) ; return ; } int limit = m / k ; int ans = EulerTotientFunction ( limit ) ; Console . Write ( ans + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int M = 9 ; int K = 1 ; CountGCD ( M , K ) ; } }

Accumulator variables: i, limit
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { static long product ( int [ , ] mat , int n ) { long d1 = 0 , d2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { d1 += mat [ i , i ] ; d2 += mat [ i , n - i - 1 ] ; } return 1L * d1 * d2 ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 5 , 8 , 1 } , { 5 , 10 , 3 } , { - 6 , 17 , - 9 } } ; int n = mat . GetLength ( 0 ) ; Console . Write ( product ( mat , n ) ) ; } }

Accumulator variables: d1, d2, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static float getPercentile ( int rank , int students ) { float result = ( float ) ( students - rank ) / students * 100 ; return result ; } public static void Main ( String [ ] args ) { int your_rank = 805 ; int total_students = 97481 ; Console . Write ( getPercentile ( your_rank , total_students ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int fib ( int n ) { double phi = ( 1 + Math . Sqrt ( 5 ) ) / 2 ; return ( int ) Math . Round ( Math . Pow ( phi , n ) / Math . Sqrt ( 5 ) ) ; } static int calculateSum ( int l , int r ) { int sum = fib ( r + 2 ) - fib ( l + 1 ) ; return sum ; } static int sumFibonacci ( int k ) { int l = ( k * ( k - 1 ) ) / 2 ; int r = l + k ; int sum = calculateSum ( l , r - 1 ) ; return sum ; } public static void Main ( ) { int k = 3 ; Console . Write ( sumFibonacci ( k ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class Sum { void sumOfPrevK ( int N , int K ) { int [ ] arr = new int [ N ] ; arr [ 0 ] = 1 ; for ( int i = 1 ; i < N ; i ++ ) { int j = i - 1 , count = 0 , sum = 0 ; while ( j >= 0 && count < K ) { sum += arr [ j ] ; j -- ; count ++ ; } arr [ i ] = sum ; } for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { Sum s = new Sum ( ) ; int N = 10 , K = 4 ; s . sumOfPrevK ( N , K ) ; } }

Index/key variables: N, i, j
Accumulator variables: count, i, j, sum
Iterator variables: i
Class/struct names: Sum
C# program:
using System ; public class Sum { void sumOfPrevK ( int N , int K ) { int [ ] arr = new int [ N ] ; int prevsum = 0 ; arr [ 0 ] = 1 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( i < K ) { arr [ i + 1 ] = arr [ i ] + prevsum ; prevsum = arr [ i + 1 ] ; } else { arr [ i + 1 ] = arr [ i ] + prevsum - arr [ i + 1 - K ] ; prevsum = arr [ i + 1 ] ; } } for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { Sum s = new Sum ( ) ; int N = 8 , K = 3 ; s . sumOfPrevK ( N , K ) ; } }

Index/key variables: N, i
Accumulator variables: i
Iterator variables: i
Class/struct names: Sum
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) { return a ; } return gcd ( b , a % b ) ; } static void findMaxGCD ( int [ ] arr , int n ) { int maxGCD = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int val = gcd ( arr [ i ] , arr [ i + 1 ] ) ; if ( val > maxGCD ) { maxGCD = val ; } } Console . Write ( maxGCD + " STRNEWLINE " ) ; } public static void Main ( ) { int [ ] arr = { 3 , 18 , 9 , 9 , 5 , 15 , 8 , 7 , 6 , 9 } ; int n = arr . Length ; findMaxGCD ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSum ( int [ ] arr , int n , int left , int right ) { int k = right - left ; int d = arr [ 1 ] - arr [ 0 ] ; int ans = arr [ left - 1 ] * ( k + 1 ) ; ans = ans + ( d * ( k * ( k + 1 ) ) ) / 2 ; return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 6 , 8 , 10 , 12 , 14 , 16 } ; int queries = 3 ; int [ , ] q = { { 2 , 4 } , { 2 , 6 } , { 5 , 6 } } ; int n = arr . Length ; for ( int i = 0 ; i < queries ; i ++ ) Console . Write ( findSum ( arr , n , q [ i , 0 ] , q [ i , 1 ] ) + " STRNEWLINE " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool subarrayPossible ( int [ ] arr , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += arr [ i ] ; if ( sum <= 0 ) return true ; } sum = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { sum += arr [ i ] ; if ( sum <= 0 ) return true ; } return false ; } public static void Main ( String [ ] args ) { int [ ] arr = { 10 , 5 , - 12 , 7 , - 10 , 20 , 30 , - 10 , 50 , 60 } ; int size = arr . Length ; if ( subarrayPossible ( arr , size ) ) Console . Write ( " Yes " + " STRNEWLINE " ) ; else Console . Write ( " No " + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static float y ( float x ) { float num = 1 ; float denom = ( float ) 1.0 + x * x ; return num / denom ; } static float WeedleRule ( float a , float b ) { float h = ( b - a ) / 6 ; float sum = 0 ; sum = sum + ( ( ( 3 * h ) / 10 ) * ( y ( a ) + y ( a + 2 * h ) + 5 * y ( a + h ) + 6 * y ( a + 3 * h ) + y ( a + 4 * h ) + 5 * y ( a + 5 * h ) + y ( a + 6 * h ) ) ) ; return sum ; } public static void Main ( ) { float a = 0 , b = 6 ; float num = WeedleRule ( a , b ) ; Console . Write ( " f ( x ) ▁ = ▁ " + num ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPrime ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static int findSmallest ( int N ) { if ( N == 0 ) return 2 ; if ( N == 1 ) return 1 ; int prime = N , counter = 0 ; bool found = false ; while ( ! found ) { if ( isPrime ( prime ) ) found = true ; else { prime ++ ; counter ++ ; } } return counter ; } public static void Main ( ) { int N = 10 ; Console . Write ( findSmallest ( N ) ) ; } }

Accumulator variables: counter, prime
Iterator variables: i
Boolean variables: found
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int limit = 1000000 ; static int [ ] position = new int [ limit + 1 ] ; static void sieve ( ) { position [ 0 ] = - 1 ; position [ 1 ] = - 1 ; int pos = 0 ; for ( int i = 2 ; i <= limit ; i ++ ) { if ( position [ i ] == 0 ) { position [ i ] = ++ pos ; for ( int j = i * 2 ; j <= limit ; j += i ) position [ j ] = - 1 ; } } } public static void Main ( String [ ] args ) { sieve ( ) ; int n = 11 ; Console . Write ( position [ n ] ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static double maxSubArraySum ( double [ ] a , int size ) { double max_so_far = Int32 . MinValue , max_ending_here = 0 ; for ( int i = 0 ; i < size ; i ++ ) { max_ending_here = max_ending_here + a [ i ] ; if ( max_so_far < max_ending_here ) max_so_far = max_ending_here ; if ( max_ending_here < 0 ) max_ending_here = 0 ; } return max_so_far ; } static void minPossibleSum ( double [ ] a , int n , double x ) { double mxSum = maxSubArraySum ( a , n ) ; double sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } sum = sum - mxSum + mxSum / x ; Console . Write ( sum + " STRNEWLINE " ) ; } public static void Main ( ) { int N = 3 ; double X = 2 ; double [ ] A = { 1 , - 2 , 3 } ; minPossibleSum ( A , N , X ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static bool checkPermutation ( int [ ] arr , int n ) { long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += arr [ i ] ; int [ ] prefix = new int [ n + 1 ] ; prefix [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) prefix [ i ] = prefix [ i - 1 ] + arr [ i ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { long lsum = prefix [ i ] ; long rsum = sum - prefix [ i ] ; long l_len = i + 1 , r_len = n - i - 1 ; if ( ( ( 2 * lsum ) == ( l_len * ( l_len + 1 ) ) ) && ( ( 2 * rsum ) == ( r_len * ( r_len + 1 ) ) ) ) return true ; } return false ; } static void printPermutations ( int [ ] arr , int n , int l1 , int l2 ) { for ( int i = 0 ; i < l1 ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } Console . WriteLine ( ) ; for ( int i = l1 ; i < n ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } static void findPermutations ( int [ ] arr , int n ) { if ( ! checkPermutation ( arr , n ) ) { Console . Write ( " Not ▁ Possible " ) ; return ; } int l1 = 0 , l2 = 0 ; l1 = arr . Max ( ) ; l2 = n - l1 ; HashSet < int > s1 = new HashSet < int > ( ) , s2 = new HashSet < int > ( ) ; for ( int i = 0 ; i < l1 ; i ++ ) s1 . Add ( arr [ i ] ) ; for ( int i = l1 ; i < n ; i ++ ) s2 . Add ( arr [ i ] ) ; if ( s1 . Count == l1 && s2 . Count == l2 ) printPermutations ( arr , n , l1 , l2 ) ; else { l1 = l1 + l2 ; l2 = l1 - l2 ; l1 = l1 - l2 ; printPermutations ( arr , n , l1 , l2 ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 1 , 10 , 2 } ; int n = arr . Length ; findPermutations ( 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 reverse ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } static int countReverse ( int [ ] arr , int n ) { int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( reverse ( arr [ i ] ) == arr [ j ] ) { res ++ ; } return res ; } public static void Main ( String [ ] arr ) { int [ ] a = { 16 , 61 , 12 , 21 , 25 } ; int n = a . Length ; Console . Write ( countReverse ( a , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, res
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int reverse ( int num ) { int rev_num = 0 ; while ( num > 0 ) { rev_num = rev_num * 10 + num % 10 ; num = num / 10 ; } return rev_num ; } static int countReverse ( int [ ] arr , int n ) { Dictionary < int , int > freq = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { if ( freq . ContainsKey ( arr [ i ] ) ) { freq [ arr [ i ] ] ++ ; } else { freq . Add ( arr [ i ] , 1 ) ; } } int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq . ContainsKey ( arr [ i ] ) ) { freq [ arr [ i ] ] -- ; } else { freq . Add ( arr [ i ] , - 1 ) ; } if ( freq . ContainsKey ( reverse ( arr [ i ] ) ) ) { res += freq [ reverse ( arr [ i ] ) ] ; } } return res ; } static void Main ( ) { int [ ] a = { 16 , 61 , 12 , 21 , 25 } ; int n = a . Length ; Console . WriteLine ( countReverse ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int MOD = 1000000007 ; static int rangeSum ( int l , int r ) { int a = 1 , b = 9 , res = 0 ; for ( int i = 1 ; i <= 10 ; i ++ ) { int L = Math . Max ( l , a ) ; int R = Math . Min ( r , b ) ; if ( L <= R ) { int sum = ( L + R ) * ( R - L + 1 ) / 2 ; res += ( int ) Math . Pow ( i , i ) * ( sum % MOD ) ; res %= MOD ; } a = a * 10 ; b = b * 10 + 9 ; } return res ; } public static void Main ( String [ ] args ) { int l = 98 , r = 102 ; Console . Write ( rangeSum ( l , r ) ) ; } }

Accumulator variables: i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int TrialDivision ( int N ) { int i = 2 ; int k = ( int ) Math . Ceiling ( Math . Sqrt ( N ) ) ; while ( i <= k ) { if ( N % i == 0 ) return 0 ; i += 1 ; } return 1 ; } public static void Main ( ) { int N = 49 ; int p = TrialDivision ( N ) ; if ( p != 0 ) Console . Write ( " Prime " ) ; else Console . Write ( " Composite " ) ; } }

Accumulator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void isPossible ( int [ ] A , int n , int k ) { int countOfTwo = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( A [ i ] % 2 == 0 ) { countOfTwo ++ ; } } if ( k == 0 && countOfTwo == n ) Console . Write ( " NO " ) ; else if ( countOfTwo >= k ) { Console . Write ( " Yes " ) ; } else Console . Write ( " No " ) ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 4 , 5 } ; int K = 2 ; int n = arr . Length ; isPossible ( arr , n , K ) ; } }

Index/key variables: i
Accumulator variables: countOfTwo, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int pairs ( int n ) { int [ , ] c = new int [ 10 , 10 ] ; int tmp = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i >= tmp * 10 ) tmp *= 10 ; c [ i / tmp , i % 10 ] ++ ; } int ans = 0 ; for ( int i = 1 ; i < 10 ; i ++ ) for ( int j = 1 ; j < 10 ; j ++ ) ans += c [ i , j ] * c [ j , i ] ; return ans ; } public static void Main ( String [ ] args ) { int n = 25 ; Console . Write ( pairs ( n ) ) ; } }

Accumulator variables: ans, i, j, tmp
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countWays ( int A , int B , int C ) { int minAddA = Math . Max ( 0 , ( C + B - A + 2 ) / 2 ) ; int count_ways = Math . Max ( C - minAddA + 1 , 0 ) ; return count_ways ; } public static void Main ( String [ ] args ) { int A = 3 , B = 5 , C = 5 ; Console . Write ( countWays ( A , B , C ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static void createHash ( HashSet < int > hash , int maxElement ) { int prev = 0 , curr = 1 ; hash . Add ( prev ) ; hash . Add ( curr ) ; while ( curr <= maxElement ) { int temp = curr + prev ; hash . Add ( temp ) ; prev = curr ; curr = temp ; } } static int gcdFibonacciFreq ( int [ ] arr , int n ) { HashSet < int > hash = new HashSet < int > ( ) ; createHash ( hash , hash . Count > 0 ? hash . Max ( ) : 0 ) ; int i ; Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( i = 0 ; i < n ; i ++ ) { if ( m . ContainsKey ( arr [ i ] ) ) { m [ arr [ i ] ] = m [ arr [ i ] ] + 1 ; } else { m . Add ( arr [ i ] , 1 ) ; } } int gcd = 0 ; foreach ( KeyValuePair < int , int > it in m ) { if ( hash . Contains ( it . Value ) ) { gcd = __gcd ( gcd , it . Key ) ; } } return gcd ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 3 , 6 , 5 , 6 , 6 , 5 , 5 } ; int n = arr . Length ; Console . Write ( gcdFibonacciFreq ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { static void printSeries ( int N ) { int ith_term = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { ith_term = i % 2 == 0 ? 2 * i * i + 1 : 2 * i * i - 1 ; Console . Write ( ith_term + " , ▁ " ) ; } } public static void Main ( ) { int N = 7 ; printSeries ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findNthTerm ( int N ) { int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( i % 2 == 0 ) { ans = ans + 6 ; } else { ans = ans + 2 ; } } Console . Write ( ans + " STRNEWLINE " ) ; } public static void Main ( ) { int N = 3 ; findNthTerm ( N ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int size = 10001 ; static int [ ] prime = new int [ size ] ; static int [ ] freq = new int [ size ] ; static void sieve ( int a , int b ) { prime [ 1 ] = 1 ; for ( int i = 2 ; i * i < size ; i ++ ) { if ( prime [ i ] == 0 ) { for ( int j = i * 2 ; j < size ; j += i ) prime [ j ] = 1 ; } } for ( int p = 1 ; p < size ; p ++ ) { for ( int q = 1 ; q < size ; q ++ ) { if ( prime [ p ] == 0 && prime [ q ] == 0 && a * p + b * q < size ) { freq [ a * p + b * q ] ++ ; } } } } public static void Main ( string [ ] args ) { int queries = 2 , a = 1 , b = 2 ; sieve ( a , b ) ; int [ ] arr = { 15 , 25 } ; for ( int i = 0 ; i < queries ; i ++ ) { Console . Write ( freq [ arr [ i ] ] + " ▁ " ) ; } } }

Index/key variables: i, j, p, q, size
Accumulator variables: i, j, p, q
Iterator variables: i, j, p, q
Class/struct names: GFG
C# program:
using System ; class GFG { static void printSeriesSum ( int N ) { double sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( ( i & 1 ) == 0 ) { sum += ( double ) i / ( i + 1 ) ; } else { sum -= ( double ) i / ( i + 1 ) ; } } Console . WriteLine ( sum ) ; } public static void Main ( string [ ] args ) { int N = 10 ; printSeriesSum ( N ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printSeriesSum ( int N ) { double sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sum += Math . Pow ( i , i - 1 ) ; } Console . Write ( sum + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int N = 5 ; printSeriesSum ( N ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printSumSeries ( int N ) { float sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sum += ( float ) 1.0 / ( 2 * i - 1 ) ; } Console . WriteLine ( sum ) ; } public static void Main ( string [ ] args ) { int N = 6 ; printSumSeries ( N ) ; } }

Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void printSeriesSum ( int N ) { double sum = 0 ; int a = 1 ; int cnt = 0 ; bool flag = true ; sum += a ; while ( cnt < N ) { int nextElement ; if ( flag == true ) { nextElement = a * 2 ; sum += nextElement ; flag = ! flag ; } else { nextElement = a * 3 / 2 ; sum += nextElement ; flag = ! flag ; } a = nextElement ; cnt ++ ; } Console . WriteLine ( sum ) ; } public static void Main ( string [ ] args ) { int N = 8 ; printSeriesSum ( N ) ; } }

Accumulator variables: cnt, sum
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static string sumBaseB ( string a , string b , int base_var ) { int len_a , len_b ; len_a = a . Length ; len_b = b . Length ; string sum , s ; s = " " ; sum = " " ; int diff ; diff = Math . Abs ( len_a - len_b ) ; for ( int i = 1 ; i <= diff ; i ++ ) s += "0" ; if ( len_a < len_b ) a = s + a ; else b = s + b ; int curr , carry = 0 ; for ( int i = Math . Max ( len_a , len_b ) - 1 ; i > - 1 ; i -- ) { curr = carry + ( a [ i ] - '0' ) + ( b [ i ] - '0' ) ; carry = curr / base_var ; curr = curr % base_var ; sum = ( char ) ( curr + '0' ) + sum ; } if ( carry > 0 ) sum = ( char ) ( carry + '0' ) + sum ; return sum ; } public static void Main ( string [ ] args ) { string a , b , sum ; int base_var ; a = "123" ; b = "234" ; base_var = 6 ; sum = sumBaseB ( a , b , base_var ) ; Console . WriteLine ( sum ) ; } }

Index/key variables: i
Accumulator variables: i, s
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void MinimumSwapOperations ( string s ) { bool zero_exist = false ; bool multiple_of_2 = false ; int sum = 0 ; int index_of_zero = 0 ; bool more_zero = false ; for ( int i = 0 ; i < s . Length ; i ++ ) { int val = s [ i ] - '0' ; if ( zero_exist == true ) more_zero = true ; if ( val == 0 ) { zero_exist = true ; index_of_zero = i ; } sum += val ; } if ( zero_exist == false sum % 3 != 0 ) { Console . WriteLine ( " - 1" ) ; return ; } for ( int i = 0 ; i < s . Length ; i ++ ) { int val = s [ i ] - '0' ; if ( val % 2 == 0 && i != index_of_zero ) multiple_of_2 = true ; } if ( multiple_of_2 == false ) { Console . WriteLine ( " - 1" ) ; return ; } int last_val = s [ ( s . Length - 1 ) - '0' ] ; int second_last_val = s [ ( s . Length - 2 ) - '0' ] ; if ( last_val == 0 && second_last_val % 2 == 0 ) Console . WriteLine ( 0 ) ; else if ( ( last_val == 0 && second_last_val % 2 != 0 ) || ( last_val % 2 == 0 && second_last_val == 0 ) ) Console . WriteLine ( 1 ) ; else if ( more_zero == true && ( last_val == 0 && second_last_val % 2 != 0 ) ) Console . WriteLine ( 1 ) ; else Console . WriteLine ( 2 ) ; } public static void Main ( string [ ] args ) { string N = "20" ; MinimumSwapOperations ( N ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Boolean variables: more_zero, multiple_of_2, zero_exist
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPalindrome ( long x ) { String num = String . Join ( " " , x ) ; bool result = true ; int i = 0 ; int j = num . Length - 1 ; while ( i < j && result ) { result = num [ i ++ ] == num [ j -- ] ; } return result ; } public static void find ( int nDigits ) { long lowerBound = ( long ) Math . Pow ( 10 , nDigits - 1 ) ; long upperBound = ( lowerBound * 10 ) - 1 ; long resultP = 0 , resultQ = 0 , resultR = 0 ; for ( long p = upperBound ; p > lowerBound ; p -= 11 ) { while ( p % 11 != 0 ) { p -- ; } for ( long q = upperBound ; q > lowerBound ; q -- ) { long t = p * q ; if ( t > resultR && isPalindrome ( t ) ) { resultP = p ; resultQ = q ; resultR = t ; break ; } } } Console . WriteLine ( resultR ) ; } public static void Main ( String [ ] args ) { int N = 2 ; find ( N ) ; } }

Accumulator variables: i, j, p, q
Iterator variables: p, q
Boolean variables: result
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 1000 ; static int [ ] max_prime = new int [ MAX ] ; static int [ ] min_prime = new int [ MAX ] ; static void sieve ( int n ) { for ( int i = 2 ; i < n ; ++ i ) { if ( min_prime [ i ] > 0 ) { continue ; } min_prime [ i ] = i ; max_prime [ i ] = i ; int j = i + i ; while ( j < n ) { if ( min_prime [ j ] == 0 ) { min_prime [ j ] = i ; } max_prime [ j ] = i ; j += i ; } } } static int findCost ( int A , int B , int C , int X ) { sieve ( MAX ) ; int N , M ; if ( X == 1 ) { return - 1 ; } int min_cost = C + X ; int cost_for_prime = A ; N = max_prime [ X ] ; if ( N != X ) { M = X / N ; cost_for_prime += M ; min_cost = Math . Min ( min_cost , cost_for_prime ) ; } M = min_prime [ X ] ; N = X / M ; if ( N != min_prime [ N ] ) { int cost_for_comp = B + M ; min_cost = Math . Min ( min_cost , cost_for_comp ) ; } return min_cost ; } public static void Main ( string [ ] args ) { int A = 7 , B = 11 , C = 2 , X = 20 ; Console . WriteLine ( findCost ( A , B , C , X ) ) ; } }

Index/key variables: MAX, N, X, i, j
Accumulator variables: cost_for_prime, j
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static double countdigits ( int n , int k ) { if ( n == 0 ) return 0 ; int digit = n % 10 ; if ( digit == k ) return 1 + countdigits ( n / 10 , k ) ; return countdigits ( n / 10 , k ) ; } static public void Main ( ) { int n = 1000 ; int k = 0 ; Console . WriteLine ( countdigits ( n , k ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void printModulus ( int X , int Y ) { int n = Math . Max ( X , Y ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( X % i == Y % i ) Console . Write ( i + " ▁ " ) ; } } public static void Main ( ) { int X , Y ; X = 10 ; Y = 20 ; printModulus ( X , Y ) ; } }

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