dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static Dictionary < string , int > dp = new Dictionary < string , int > ( ) ; static int checkEqualSumUtil ( int [ ] arr , int N , int sm1 , int sm2 , int sm3 , int j ) { string s = sm1 . ToString ( ) + " _ " + sm2 . ToString ( ) + j . ToString ( ) ; if ( j == N ) { if ( sm1 == sm2 && sm2 == sm3 ) return 1 ; else return 0 ; } if ( dp . ContainsKey ( s ) ) return dp [ s ] ; else { int l = checkEqualSumUtil ( arr , N , sm1 + arr [ j ] , sm2 , sm3 , j + 1 ) ; int m = checkEqualSumUtil ( arr , N , sm1 , sm2 + arr [ j ] , sm3 , j + 1 ) ; int r = checkEqualSumUtil ( arr , N , sm1 , sm2 , sm3 + arr [ j ] , j + 1 ) ; dp [ s ] = Math . Max ( Math . Max ( l , m ) , r ) ; return dp [ s ] ; } } static void checkEqualSum ( int [ ] arr , int N ) { int sum1 , sum2 , sum3 ; sum1 = sum2 = sum3 = 0 ; if ( checkEqualSumUtil ( arr , N , sum1 , sum2 , sum3 , 0 ) == 1 ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } public static void Main ( string [ ] args ) { int [ ] arr = { 17 , 34 , 59 , 23 , 17 , 67 , 57 , 2 , 18 , 59 , 1 } ; int N = arr . Length ; checkEqualSum ( arr , N ) ; } }

Index/key variables: j, s
Class/struct names: GFG
C# program:
using System ; class GFG { static void precompute ( int [ ] nextpos , int [ ] arr , int N ) { nextpos [ N - 1 ] = N ; for ( int i = N - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] == arr [ i + 1 ] ) nextpos [ i ] = nextpos [ i + 1 ] ; else nextpos [ i ] = i + 1 ; } } static void findIndex ( int [ , ] query , int [ ] arr , int N , int Q ) { int [ ] nextpos = new int [ N ] ; precompute ( nextpos , arr , N ) ; for ( int i = 0 ; i < Q ; i ++ ) { int l , r , x ; l = query [ i , 0 ] ; r = query [ i , 1 ] ; x = query [ i , 2 ] ; int ans = - 1 ; if ( arr [ l ] != x ) ans = l ; else { int d = nextpos [ l ] ; if ( d <= r ) ans = d ; } Console . Write ( ans + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int N , Q ; N = 6 ; Q = 3 ; int [ ] arr = { 1 , 2 , 1 , 1 , 3 , 5 } ; int [ , ] query = { { 0 , 3 , 1 } , { 1 , 5 , 2 } , { 2 , 3 , 1 } } ; findIndex ( query , arr , N , Q ) ; } }

Index/key variables: N, i, l
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static long mod = 10000000007L ; static long countWays ( string s , string t , int k ) { int n = s . Length ; int a = 0 , b = 0 ; for ( int i = 0 ; i < n ; i ++ ) { string p = s . Substring ( i , n - i ) + s . Substring ( 0 , i ) ; if ( p == t ) a ++ ; else b ++ ; } long [ ] dp1 = new long [ k + 1 ] ; long [ ] dp2 = new long [ k + 1 ] ; if ( s == t ) { dp1 [ 0 ] = 1 ; dp2 [ 0 ] = 0 ; } else { dp1 [ 0 ] = 0 ; dp2 [ 0 ] = 1 ; } for ( int i = 1 ; i <= k ; i ++ ) { dp1 [ i ] = ( ( dp1 [ i - 1 ] * ( a - 1 ) ) % mod + ( dp2 [ i - 1 ] * a ) % mod ) % mod ; dp2 [ i ] = ( ( dp1 [ i - 1 ] * ( b ) ) % mod + ( dp2 [ i - 1 ] * ( b - 1 ) ) % mod ) % mod ; } return dp1 [ k ] ; } public static void Main ( string [ ] args ) { string S = " ab " , T = " ab " ; int K = 2 ; Console . Write ( countWays ( S , T , K ) ) ; } }

Index/key variables: i, k
Accumulator variables: a, b, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minOperation ( int k ) { int [ ] dp = new int [ k + 1 ] ; for ( int i = 1 ; i <= k ; i ++ ) { dp [ i ] = dp [ i - 1 ] + 1 ; if ( i % 2 == 0 ) { dp [ i ] = Math . Min ( dp [ i ] , dp [ i / 2 ] + 1 ) ; } } return dp [ k ] ; } public static void Main ( ) { int K = 12 ; Console . Write ( minOperation ( K ) ) ; } }

Index/key variables: i, k
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int maxSum ( int p0 , int p1 , int [ ] a , int pos , int n ) { if ( pos == n ) { if ( p0 == p1 ) return p0 ; else return 0 ; } int ans = maxSum ( p0 , p1 , a , pos + 1 , n ) ; ans = Math . Max ( ans , maxSum ( p0 + a [ pos ] , p1 , a , pos + 1 , n ) ) ; ans = Math . Max ( ans , maxSum ( p0 , p1 + a [ pos ] , a , pos + 1 , n ) ) ; return ans ; } public static void Main ( string [ ] args ) { int n = 4 ; int [ ] a = { 1 , 2 , 3 , 6 } ; Console . WriteLine ( maxSum ( 0 , 0 , a , 0 , n ) ) ; } }

Index/key variables: pos
Class/struct names: GFG
C# program:
using System ; class GFG { static int INT_MIN = int . MinValue ; static int maxSum ( int [ ] a , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum += a [ i ] ; int limit = 2 * sum + 1 ; int [ , ] dp = new int [ n + 1 , limit ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < limit ; j ++ ) dp [ i , j ] = INT_MIN ; } dp [ 0 , sum ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 0 ; j < limit ; j ++ ) { if ( ( j - a [ i - 1 ] ) >= 0 && dp [ i - 1 , j - a [ i - 1 ] ] != INT_MIN ) dp [ i , j ] = Math . Max ( dp [ i , j ] , dp [ i - 1 , j - a [ i - 1 ] ] + a [ i - 1 ] ) ; if ( ( j + a [ i - 1 ] ) < limit && dp [ i - 1 , j + a [ i - 1 ] ] != INT_MIN ) dp [ i , j ] = Math . Max ( dp [ i , j ] , dp [ i - 1 , j + a [ i - 1 ] ] ) ; if ( dp [ i - 1 , j ] != INT_MIN ) dp [ i , j ] = Math . Max ( dp [ i , j ] , dp [ i - 1 , j ] ) ; } } return dp [ n , sum ] ; } public static void Main ( ) { int n = 4 ; int [ ] a = { 1 , 2 , 3 , 6 } ; Console . WriteLine ( maxSum ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] fib = new int [ 100005 ] ; static void computeFibonacci ( ) { fib [ 0 ] = 1 ; fib [ 1 ] = 1 ; for ( int i = 2 ; i < 100005 ; i ++ ) { fib [ i ] = fib [ i - 1 ] + fib [ i - 2 ] ; } } static int countString ( string str ) { int ans = 1 ; int cnt = 1 ; for ( int i = 1 ; i < str . Length ; i ++ ) { if ( str [ i ] == str [ i - 1 ] ) { cnt ++ ; } else { ans = ans * fib [ cnt ] ; cnt = 1 ; } } ans = ans * fib [ cnt ] ; return ans ; } public static void Main ( string [ ] args ) { string str = " abdllldefkkkk " ; computeFibonacci ( ) ; Console . WriteLine ( countString ( str ) ) ; } }

Index/key variables: cnt, i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int MAX = 1000 ; static void printGolombSequence ( int N ) { int [ ] arr = new int [ MAX ] ; for ( int i = 0 ; i < MAX ; i ++ ) arr [ i ] = 0 ; int cnt = 0 ; arr [ 0 ] = 0 ; arr [ 1 ] = 1 ; Dictionary < int , int > M = new Dictionary < int , int > ( ) ; M . Add ( 2 , 2 ) ; for ( int i = 2 ; i <= N ; i ++ ) { if ( cnt == 0 ) { arr [ i ] = 1 + arr [ i - 1 ] ; cnt = M [ arr [ i ] ] ; cnt -- ; } else { arr [ i ] = arr [ i - 1 ] ; cnt -- ; } if ( M . ContainsKey ( i ) ) { M [ i ] = arr [ i ] ; } else { M . Add ( i , arr [ i ] ) ; } } for ( int i = 1 ; i <= N ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } static void Main ( ) { int N = 11 ; printGolombSequence ( N ) ; } }

Index/key variables: MAX, i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int number_of_ways ( int n ) { int [ ] includes_3 = new int [ n + 1 ] ; int [ ] not_includes_3 = new int [ n + 1 ] ; includes_3 [ 3 ] = 1 ; not_includes_3 [ 1 ] = 1 ; not_includes_3 [ 2 ] = 2 ; not_includes_3 [ 3 ] = 3 ; for ( int i = 4 ; i <= n ; i ++ ) { includes_3 [ i ] = includes_3 [ i - 1 ] + includes_3 [ i - 2 ] + not_includes_3 [ i - 3 ] ; not_includes_3 [ i ] = not_includes_3 [ i - 1 ] + not_includes_3 [ i - 2 ] ; } return includes_3 [ n ] ; } public static void Main ( String [ ] args ) { int n = 7 ; Console . Write ( number_of_ways ( n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int MAX = 100000 ; static int [ ] divisors = new int [ MAX ] ; static void generateDivisors ( int n ) { for ( int i = 1 ; i <= Math . Sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) { divisors [ i ] ++ ; } else { divisors [ i ] ++ ; divisors [ n / i ] ++ ; } } } } static int findMaxMultiples ( int [ ] arr , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . Max ( divisors [ arr [ i ] ] , ans ) ; generateDivisors ( arr [ i ] ) ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 8 , 1 , 28 , 4 , 2 , 6 , 7 } ; int n = arr . Length ; Console . Write ( findMaxMultiples ( arr , n ) ) ; } }

Index/key variables: MAX, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int n = 3 ; static int maxV = 20 ; static int [ , , ] dp = new int [ n , n , maxV ] ; static int [ , , ] v = new int [ n , n , maxV ] ; static int countWays ( int i , int j , int x , int [ , ] arr ) { if ( i == n j == n ) { return 0 ; } x = ( x & arr [ i , j ] ) ; if ( x == 0 ) { return 0 ; } if ( i == n - 1 && j == n - 1 ) { return 1 ; } if ( v [ i , j , x ] == 1 ) { return dp [ i , j , x ] ; } v [ i , j , x ] = 1 ; dp [ i , j , x ] = countWays ( i + 1 , j , x , arr ) + countWays ( i , j + 1 , x , arr ) ; return dp [ i , j , x ] ; } public static void Main ( ) { int [ , ] arr = { { 1 , 2 , 1 } , { 1 , 1 , 0 } , { 2 , 1 , 1 } } ; Console . WriteLine ( countWays ( 0 , 0 , arr [ 0 , 0 ] , arr ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 3 ; static int FindMaximumSum ( int ind , int kon , int [ ] a , int [ ] b , int [ ] c , int n , int [ , ] dp ) { if ( ind == n ) return 0 ; if ( dp [ ind , kon ] != - 1 ) return dp [ ind , kon ] ; int ans = ( int ) ( - 1e9 + 5 ) ; if ( kon == 0 ) { ans = Math . Max ( ans , b [ ind ] + FindMaximumSum ( ind + 1 , 1 , a , b , c , n , dp ) ) ; ans = Math . Max ( ans , c [ ind ] + FindMaximumSum ( ind + 1 , 2 , a , b , c , n , dp ) ) ; } else if ( kon == 1 ) { ans = Math . Max ( ans , a [ ind ] + FindMaximumSum ( ind + 1 , 0 , a , b , c , n , dp ) ) ; ans = Math . Max ( ans , c [ ind ] + FindMaximumSum ( ind + 1 , 2 , a , b , c , n , dp ) ) ; } else if ( kon == 2 ) { ans = Math . Max ( ans , a [ ind ] + FindMaximumSum ( ind + 1 , 1 , a , b , c , n , dp ) ) ; ans = Math . Max ( ans , b [ ind ] + FindMaximumSum ( ind + 1 , 0 , a , b , c , n , dp ) ) ; } return dp [ ind , kon ] = ans ; } public static void Main ( ) { int [ ] a = { 6 , 8 , 2 , 7 , 4 , 2 , 7 } ; int [ ] b = { 7 , 8 , 5 , 8 , 6 , 3 , 5 } ; int [ ] c = { 8 , 3 , 2 , 6 , 8 , 4 , 1 } ; int n = a . Length ; int [ , ] dp = new int [ n , N ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { dp [ i , j ] = - 1 ; } } int x = FindMaximumSum ( 0 , 0 , a , b , c , n , dp ) ; int y = FindMaximumSum ( 0 , 1 , a , b , c , n , dp ) ; int z = FindMaximumSum ( 0 , 2 , a , b , c , n , dp ) ; Console . WriteLine ( Math . Max ( x , Math . Max ( y , z ) ) ) ; } }

Index/key variables: ind
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int mod = 1000000007 ; static int noOfBinaryStrings ( int N , int k ) { int [ ] dp = new int [ 100002 ] ; for ( int i = 1 ; i <= k - 1 ; i ++ ) { dp [ i ] = 1 ; } dp [ k ] = 2 ; for ( int i = k + 1 ; i <= N ; i ++ ) { dp [ i ] = ( dp [ i - 1 ] + dp [ i - k ] ) % mod ; } return dp [ N ] ; } public static void Main ( ) { int N = 4 ; int K = 2 ; Console . WriteLine ( noOfBinaryStrings ( N , K ) ) ; } }

Index/key variables: N, i, k
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int findWaysToPair ( int p ) { int [ ] dp = new int [ p + 1 ] ; dp [ 1 ] = 1 ; dp [ 2 ] = 2 ; for ( int i = 3 ; i <= p ; i ++ ) { dp [ i ] = dp [ i - 1 ] + ( i - 1 ) * dp [ i - 2 ] ; } return dp [ p ] ; } public static void Main ( string [ ] args ) { int p = 3 ; Console . WriteLine ( findWaysToPair ( p ) ) ; } }

Index/key variables: i, p
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int CountWays ( int n ) { if ( n == 0 ) { return 1 ; } if ( n == 1 ) { return 1 ; } if ( n == 2 ) { return 1 + 1 ; } return CountWays ( n - 1 ) + CountWays ( n - 3 ) ; } static public void Main ( ) { int n = 5 ; Console . WriteLine ( CountWays ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > factors ( int n ) { List < int > v = new List < int > ( ) ; v . Add ( 1 ) ; for ( int i = 2 ; i <= Math . Sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { v . Add ( i ) ; if ( n / i != i ) { v . Add ( n / i ) ; } } } return v ; } static Boolean checkAbundant ( int n ) { List < int > v ; int sum = 0 ; v = factors ( n ) ; for ( int i = 0 ; i < v . Count ; i ++ ) { sum += v [ i ] ; } if ( sum > n ) return true ; else return false ; } static Boolean checkSemiPerfect ( int n ) { List < int > v ; v = factors ( n ) ; v . Sort ( ) ; int r = v . Count ; Boolean [ , ] subset = new Boolean [ r + 1 , n + 1 ] ; for ( int i = 0 ; i <= r ; i ++ ) subset [ i , 0 ] = true ; for ( int i = 1 ; i <= n ; i ++ ) subset [ 0 , i ] = false ; for ( int i = 1 ; i <= r ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { if ( j < v [ i - 1 ] ) subset [ i , j ] = subset [ i - 1 , j ] ; else { subset [ i , j ] = subset [ i - 1 , j ] || subset [ i - 1 , j - v [ i - 1 ] ] ; } } } if ( ( subset [ r , n ] ) == false ) return false ; else return true ; } static Boolean checkweird ( int n ) { if ( checkAbundant ( n ) == true && checkSemiPerfect ( n ) == false ) return true ; else return false ; } public static void Main ( String [ ] args ) { int n = 70 ; if ( checkweird ( n ) ) Console . WriteLine ( " Weird ▁ Number " ) ; else Console . WriteLine ( " Not ▁ Weird ▁ Number " ) ; } }

Index/key variables: i
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxSubArraySumRepeated ( int [ ] a , int n , int k ) { int max_so_far = 0 ; int max_ending_here = 0 ; for ( int i = 0 ; i < n * k ; i ++ ) { max_ending_here = max_ending_here + a [ i % n ] ; 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 ; } public static void Main ( ) { int [ ] a = { 10 , 20 , - 30 , - 1 } ; int n = a . Length ; int k = 3 ; Console . Write ( " Maximum ▁ contiguous ▁ sum ▁ is ▁ " + maxSubArraySumRepeated ( a , n , k ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int longOddEvenIncSeq ( int [ ] arr , int n ) { int [ ] lioes = new int [ n ] ; int maxLen = 0 ; for ( int i = 0 ; i < n ; i ++ ) lioes [ i ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) for ( int j = 0 ; j < i ; j ++ ) if ( arr [ i ] > arr [ j ] && ( arr [ i ] + arr [ j ] ) % 2 != 0 && lioes [ i ] < lioes [ j ] + 1 ) lioes [ i ] = lioes [ j ] + 1 ; for ( int i = 0 ; i < n ; i ++ ) if ( maxLen < lioes [ i ] ) maxLen = lioes [ i ] ; return maxLen ; } public static void Main ( ) { int [ ] arr = new int [ ] { 1 , 12 , 2 , 22 , 5 , 30 , 31 , 14 , 17 , 11 } ; int n = 10 ; Console . Write ( " Longest ▁ Increasing ▁ Odd " + " ▁ Even ▁ Subsequence : ▁ " + longOddEvenIncSeq ( arr , n ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static bool isOperator ( char op ) { return ( op == ' + ' op == ' * ' ) ; } static void printMinAndMaxValueOfExp ( string exp ) { List < int > num = new List < int > ( ) ; List < char > opr = new List < char > ( ) ; string tmp = " " ; for ( int i = 0 ; i < exp . Length ; i ++ ) { if ( isOperator ( exp [ i ] ) ) { opr . Add ( exp [ i ] ) ; num . Add ( int . Parse ( tmp ) ) ; tmp = " " ; } else { tmp += exp [ i ] ; } } num . Add ( int . Parse ( tmp ) ) ; int len = num . Count ; int [ , ] minVal = new int [ len , len ] ; int [ , ] maxVal = new int [ len , len ] ; for ( int i = 0 ; i < len ; i ++ ) { for ( int j = 0 ; j < len ; j ++ ) { minVal [ i , j ] = Int32 . MaxValue ; maxVal [ i , j ] = 0 ; if ( i == j ) { minVal [ i , j ] = maxVal [ i , j ] = num [ i ] ; } } } for ( int L = 2 ; L <= len ; L ++ ) { for ( int i = 0 ; i < len - L + 1 ; i ++ ) { int j = i + L - 1 ; for ( int k = i ; k < j ; k ++ ) { int minTmp = 0 , maxTmp = 0 ; if ( opr [ k ] == ' + ' ) { minTmp = minVal [ i , k ] + minVal [ k + 1 , j ] ; maxTmp = maxVal [ i , k ] + maxVal [ k + 1 , j ] ; } else if ( opr [ k ] == ' * ' ) { minTmp = minVal [ i , k ] * minVal [ k + 1 , j ] ; maxTmp = maxVal [ i , k ] * maxVal [ k + 1 , j ] ; } if ( minTmp < minVal [ i , j ] ) minVal [ i , j ] = minTmp ; if ( maxTmp > maxVal [ i , j ] ) maxVal [ i , j ] = maxTmp ; } } } Console . Write ( " Minimum ▁ value ▁ : ▁ " + minVal [ 0 , len - 1 ] + " , ▁ Maximum ▁ value ▁ : ▁ " + maxVal [ 0 , len - 1 ] ) ; } static public void Main ( ) { string expression = "1 + 2*3 + 4*5" ; printMinAndMaxValueOfExp ( expression ) ; } }

Index/key variables: i, k
Accumulator variables: L, i, j, k, tmp
Iterator variables: L, i, j, k
Class/struct names: GFG
C# program:
using System ; class GFG { static int MatrixChainOrder ( int [ ] p , int i , int j ) { if ( i == j ) return 0 ; int min = int . MaxValue ; for ( int k = i ; k < j ; k ++ ) { int count = MatrixChainOrder ( p , i , k ) + MatrixChainOrder ( p , k + 1 , j ) + p [ i - 1 ] * p [ k ] * p [ j ] ; if ( count < min ) min = count ; } return min ; } public static void Main ( ) { int [ ] arr = new int [ ] { 1 , 2 , 3 , 4 , 3 } ; int n = arr . Length ; Console . Write ( " Minimum ▁ number ▁ of ▁ multiplications ▁ is ▁ " + MatrixChainOrder ( arr , 1 , n - 1 ) ) ; } }

Index/key variables: j, k
Accumulator variables: k
Iterator variables: k
Class/struct names: GFG
C# program:
using System ; class GFG { static void flipBitsOfAandB ( int A , int B ) { A = A ^ ( A & B ) ; B = B ^ ( A & B ) ; Console . Write ( A + " ▁ " + B ) ; } public static void Main ( String [ ] args ) { int A = 10 , B = 20 ; flipBitsOfAandB ( A , B ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int TotalHammingDistance ( int n ) { int i = 1 , sum = 0 ; while ( n / i > 0 ) { sum = sum + n / i ; i = i * 2 ; } return sum ; } public static void Main ( ) { int N = 9 ; Console . Write ( TotalHammingDistance ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int m = 1000000007 ; static void solve ( long n ) { long s = 0 ; for ( int l = 1 ; l <= n ; ) { int r = ( int ) ( n / ( Math . Floor ( ( double ) n / l ) ) ) ; int x = ( ( ( r % m ) * ( ( r + 1 ) % m ) ) / 2 ) % m ; int y = ( ( ( l % m ) * ( ( l - 1 ) % m ) ) / 2 ) % m ; int p = ( int ) ( ( n / l ) % m ) ; s = ( s + ( ( ( x - y ) % m ) * p ) % m + m ) % m ; s %= m ; l = r + 1 ; } Console . Write ( ( s + m ) % m ) ; } public static void Main ( String [ ] args ) { long n = 12 ; solve ( n ) ; } }

Iterator variables: l
Class/struct names: GFG
C# program:
using System ; class GFG { static int min_time_to_cut ( int N ) { if ( N == 0 ) return 0 ; return ( int ) Math . Ceiling ( Math . Log ( N ) / Math . Log ( 2 ) ) ; } public static void Main ( ) { int N = 100 ; Console . Write ( min_time_to_cut ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findDistinctSums ( int n ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = i ; j <= n ; j ++ ) { s . Add ( i + j ) ; } } return s . Count ; } public static void Main ( String [ ] args ) { int N = 3 ; Console . Write ( findDistinctSums ( N ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int printPattern ( int i , int j , int n ) { if ( j >= n ) { return 0 ; } if ( i >= n ) { return 1 ; } if ( j == i j == n - 1 - i ) { if ( i == n - 1 - j ) { Console . Write ( " / " ) ; } else { Console . Write ( " \ \" ) ; } } else { Console . Write ( " * " ) ; } if ( printPattern ( i , j + 1 , n ) == 1 ) { return 1 ; } Console . WriteLine ( ) ; return printPattern ( i + 1 , 0 , n ) ; } public static void Main ( String [ ] args ) { int N = 9 ; printPattern ( 0 , 0 , N ) ; } }

Class/struct names: GFG
C# program:
using System ; class GfG { private static int [ ] zArray ( int [ ] arr ) { int [ ] z ; int n = arr . Length ; z = new int [ n ] ; int r = 0 , l = 0 ; for ( int k = 1 ; k < n ; k ++ ) { if ( k > r ) { r = l = k ; while ( r < n && arr [ r ] == arr [ r - l ] ) r ++ ; z [ k ] = r - l ; r -- ; } else { int k1 = k - l ; if ( z [ k1 ] < r - k + 1 ) z [ k ] = z [ k1 ] ; else { l = k ; while ( r < n && arr [ r ] == arr [ r - l ] ) r ++ ; z [ k ] = r - l ; r -- ; } } } return z ; } private static int [ ] mergeArray ( int [ ] A , int [ ] B ) { int n = A . Length ; int m = B . Length ; int [ ] z ; int [ ] c = new int [ n + m + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) c [ i ] = B [ i ] ; c [ m ] = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) c [ m + i + 1 ] = A [ i ] ; z = zArray ( c ) ; return z ; } private static void findZArray ( int [ ] A , int [ ] B , int n ) { int flag = 0 ; int [ ] z ; z = mergeArray ( A , B ) ; for ( int i = 0 ; i < z . Length ; i ++ ) { if ( z [ i ] == n ) { Console . Write ( ( i - n - 1 ) + " ▁ " ) ; flag = 1 ; } } if ( flag == 0 ) { Console . WriteLine ( " Not ▁ Found " ) ; } } public static void Main ( ) { int [ ] A = { 1 , 2 , 3 , 2 , 3 , 2 } ; int [ ] B = { 2 , 3 } ; int n = B . Length ; findZArray ( A , B , n ) ; } }

Index/key variables: i, k, k1, m, n, r
Accumulator variables: i, k, r
Iterator variables: i, k
Class/struct names: GfG
C# program:
using System ; class GfG { static int getCount ( String a , String b ) { if ( b . Length % a . Length != 0 ) return - 1 ; int count = b . Length / a . Length ; String str = " " ; for ( int i = 0 ; i < count ; i ++ ) { str = str + a ; } if ( str . Equals ( b ) ) return count ; return - 1 ; } public static void Main ( String [ ] args ) { String a = " geeks " ; String b = " geeksgeeks " ; Console . WriteLine ( getCount ( a , b ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GfG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool check ( String S1 , String S2 ) { int n1 = S1 . Length ; int n2 = S2 . Length ; Dictionary < int , int > mp = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n1 ; i ++ ) { if ( mp . ContainsKey ( ( int ) S1 [ i ] ) ) { mp [ ( int ) S1 [ i ] ] = mp [ ( int ) S1 [ i ] ] + 1 ; } else { mp . Add ( ( int ) S1 [ i ] , 1 ) ; } } for ( int i = 0 ; i < n2 ; i ++ ) { if ( mp . ContainsKey ( ( int ) S2 [ i ] ) ) { mp [ ( int ) S2 [ i ] ] = mp [ ( int ) S2 [ i ] ] - 1 ; } else if ( mp . ContainsKey ( S2 [ i ] - 1 ) && mp . ContainsKey ( S2 [ i ] - 2 ) ) { mp [ S2 [ i ] - 1 ] = mp [ S2 [ i ] - 1 ] - 1 ; mp [ S2 [ i ] - 2 ] = mp [ S2 [ i ] - 2 ] - 1 ; } else { return false ; } } return true ; } public static void Main ( String [ ] args ) { String S1 = " abbat " ; String S2 = " cat " ; if ( check ( S1 , S2 ) ) Console . Write ( " YES " ) ; else Console . Write ( " NO " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int countPattern ( string str ) { int len = str . Length ; bool oneSeen = false ; for ( int i = 0 ; i < len ; i ++ ) { char getChar = str [ i ] ; if ( getChar == '1' && oneSeen == true ) { if ( str [ i - 1 ] == '0' ) { count ++ ; } } if ( getChar == '1' && oneSeen == false ) { oneSeen = true ; } if ( getChar != '0' && str [ i ] != '1' ) { oneSeen = false ; } } return count ; } public static void Main ( string [ ] args ) { string str = "100001abc101" ; Console . WriteLine ( countPattern ( str ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Boolean variables: oneSeen
Class/struct names: GFG