dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int distinctNumbers ( int [ ] arr , int m , int n ) { Dictionary < int , int > count = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) if ( count . ContainsKey ( arr [ i ] ) ) { count [ arr [ i ] ] = count [ arr [ i ] ] + 1 ; } else { count . Add ( arr [ i ] , 1 ) ; } int [ ] fre_arr = new int [ n + 1 ] ; foreach ( int it in count . Values ) { fre_arr [ it ] ++ ; } int ans = count . Count ; for ( int i = 1 ; i <= n ; i ++ ) { int temp = fre_arr [ i ] ; if ( temp == 0 ) continue ; int t = Math . Min ( temp , m / i ) ; ans -= t ; m -= i * t ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 1 , 5 , 3 , 5 , 1 , 3 } ; int n = arr . Length ; int m = 2 ; Console . WriteLine ( distinctNumbers ( arr , m , n ) ) ; } }

Index/key variables: i, it
Accumulator variables: ans, i, m
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { static int M = 4 ; static int N = 5 ; public static void no_of_moves ( int [ , ] Matrix , int x , int y ) { int moves = 0 ; for ( int i = 0 ; i < M ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { if ( Matrix [ i , j ] != 0 ) { moves += Math . Abs ( x - i ) ; moves += Math . Abs ( y - j ) ; } } } Console . WriteLine ( moves ) ; } public static void Main ( String [ ] args ) { int x = 3 ; int y = 2 ; int [ , ] Matrix = { { 1 , 0 , 1 , 1 , 0 } , { 0 , 1 , 1 , 0 , 1 } , { 0 , 0 , 1 , 1 , 0 } , { 1 , 1 , 1 , 0 , 0 } } ; no_of_moves ( Matrix , x , y ) ; } }

Accumulator variables: i, j, moves
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void removeAll ( int [ ] arr , int n ) { if ( arr [ 0 ] < arr [ n - 1 ] ) Console . Write ( " YES " ) ; else Console . Write ( " NO " ) ; } public static void Main ( String [ ] args ) { int [ ] Arr = { 10 , 4 , 7 , 1 , 3 , 6 } ; int size = Arr . Length ; removeAll ( Arr , size ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static void FindSubarray ( int [ ] arr , int n ) { if ( n == 1 ) { Console . WriteLine ( " No ▁ such ▁ subarray ! " ) ; } int [ ] vis = new int [ n + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) vis [ i ] = - 1 ; vis [ arr [ 0 ] ] = 0 ; int len = int . MaxValue , flag = 0 ; int start = 0 , end = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int t = arr [ i ] ; if ( vis [ t ] != - 1 ) { int distance = i - vis [ t ] + 1 ; if ( distance < len ) { len = distance ; start = vis [ t ] ; end = i ; } flag = 1 ; } vis [ t ] = i ; } if ( flag == 0 ) Console . WriteLine ( " No ▁ such ▁ subarray ! " ) ; else { for ( int i = start ; i <= end ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 2 , 4 , 5 } ; int n = arr . Length ; FindSubarray ( arr , n ) ; } }

Index/key variables: i, t
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int countSubstrings ( String s ) { int n = s . Length ; int answer = ( n * ( n - 1 ) ) / 2 ; int cnt = 1 ; List < int > v = new List < int > ( ) ; for ( int i = 1 ; i < n ; i ++ ) { if ( s [ i ] == s [ i - 1 ] ) cnt ++ ; else { v . Add ( cnt ) ; cnt = 1 ; } } if ( cnt > 0 ) v . Add ( cnt ) ; for ( int i = 0 ; i < v . Count - 1 ; i ++ ) { answer -= ( v [ i ] + v [ i + 1 ] - 1 ) ; } return answer ; } public static void Main ( String [ ] args ) { String s = "00111" ; Console . Write ( countSubstrings ( s ) ) ; } }

Index/key variables: i
Accumulator variables: answer, cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int get_palindrome_time ( string str ) { int hh , mm ; hh = ( str [ 0 ] - 48 ) * 10 + ( str [ 1 ] - 48 ) ; mm = ( str [ 3 ] - 48 ) * 10 + ( str [ 4 ] - 48 ) ; int requiredTime = 0 ; while ( hh % 10 != mm / 10 hh / 10 != mm % 10 ) { ++ mm ; if ( mm == 60 ) { mm = 0 ; ++ hh ; } if ( hh == 24 ) hh = 0 ; ++ requiredTime ; } return requiredTime ; } public static void Main ( string [ ] args ) { string str = "05:39" ; Console . Write ( get_palindrome_time ( str ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maximumSubarraySum ( int [ ] a , int n , List < List < int > > subarrays ) { int i , maxsum = 0 ; int [ ] prefixArray = new int [ n ] ; for ( i = 0 ; i < subarrays . Count ; ++ i ) { prefixArray [ subarrays [ i ] [ 0 ] - 1 ] ++ ; prefixArray [ subarrays [ i ] [ 1 ] ] -- ; } for ( i = 1 ; i < n ; i ++ ) { prefixArray [ i ] += prefixArray [ i - 1 ] ; } Array . Sort ( prefixArray ) ; Array . Sort ( a ) ; for ( i = 0 ; i < n ; i ++ ) maxsum += a [ i ] * prefixArray [ i ] ; return maxsum ; } static void Main ( ) { int n = 6 ; int [ ] a = { 4 , 1 , 2 , 1 , 9 , 2 } ; List < List < int > > subarrays = new List < List < int > > ( ) ; subarrays . Add ( new List < int > { 1 , 2 } ) ; subarrays . Add ( new List < int > { 1 , 3 } ) ; subarrays . Add ( new List < int > { 1 , 4 } ) ; subarrays . Add ( new List < int > { 3 , 4 } ) ; Console . WriteLine ( maximumSubarraySum ( a , n , subarrays ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, maxsum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxProfit ( int [ ] value , int N , int K ) { Array . Sort ( value ) ; int maxval = value [ N - 1 ] ; int maxProfit = 0 ; int curr_val ; do { curr_val = 0 ; for ( int i = 0 ; i < N ; i ++ ) { curr_val += value [ i ] ; if ( curr_val <= K ) { maxProfit = Math . Max ( curr_val + maxval * ( i + 1 ) , maxProfit ) ; } } } while ( next_permutation ( value ) ) ; return maxProfit ; } static bool next_permutation ( int [ ] p ) { for ( int a = p . Length - 2 ; a >= 0 ; -- a ) if ( p [ a ] < p [ a + 1 ] ) for ( int b = p . Length - 1 ; ; -- b ) if ( p [ b ] > p [ a ] ) { int t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; for ( ++ a , b = p . Length - 1 ; a < b ; ++ a , -- b ) { t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; } return true ; } return false ; } static void Main ( ) { int N = 4 , K = 6 ; int [ ] values = { 5 , 2 , 7 , 3 } ; Console . WriteLine ( maxProfit ( values , N , K ) ) ; } }

Index/key variables: a, b, i
Accumulator variables: curr_val, i
Iterator variables: a, b, i
Class/struct names: GFG
C# program:
using System ; class GFG { static void minValue ( int n ) { while ( ( int ) Math . Sqrt ( n ) == Math . Sqrt ( n ) && n > 1 ) { n = ( int ) ( Math . Sqrt ( n ) ) ; } for ( int i = ( int ) ( Math . Sqrt ( n ) ) ; i > 1 ; i -- ) { while ( n % ( i * i ) == 0 ) n /= i ; } Console . Write ( n ) ; } public static void Main ( ) { int N = 20 ; minValue ( N ) ; } }

Accumulator variables: i, n
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool isPalindrome ( int l , int r , string s ) { while ( l <= r ) { if ( s [ l ] != s [ r ] ) return false ; l ++ ; r -- ; } return true ; } public static int numWays ( string s ) { int n = s . Length ; int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( isPalindrome ( 0 , i , s ) && isPalindrome ( i + 1 , n - 1 , s ) ) { ans ++ ; } } return ans ; } public static void Main ( string [ ] args ) { string S = " aaaaa " ; Console . Write ( numWays ( S ) ) ; } }

Index/key variables: l, r
Accumulator variables: ans, i, l, r
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findDirection ( int n , int m ) { if ( n > m ) { if ( m % 2 == 0 ) Console . Write ( " Up STRNEWLINE " ) ; else Console . Write ( " Down STRNEWLINE " ) ; } else { if ( n % 2 == 0 ) Console . Write ( " Left STRNEWLINE " ) ; else Console . Write ( " Right STRNEWLINE " ) ; } } public static void Main ( ) { int n = 3 , m = 3 ; findDirection ( n , m ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int maxModulosum ( int [ ] a , int n ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } return sum - n ; } public static void Main ( String [ ] args ) { int [ ] a = new int [ ] { 3 , 4 , 6 } ; int n = a . Length ; Console . Write ( maxModulosum ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { public static int getMinJumps ( string s ) { ArrayList ones = new ArrayList ( ) ; int jumps = 0 , median = 0 , ind = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( s [ i ] == '1' ) ones . Add ( i ) ; } if ( ones . Count == 0 ) return jumps ; median = ( int ) ones [ ones . Count / 2 ] ; ind = median ; for ( int i = ind ; i >= 0 ; i -- ) { if ( s [ i ] == '1' ) { jumps += ind - i ; ind -- ; } } ind = median ; for ( int i = ind ; i < s . Length ; i ++ ) { if ( s [ i ] == '1' ) { jumps += i - ind ; ind ++ ; } } return jumps ; } public static void Main ( string [ ] args ) { string S = "00100000010011" ; Console . Write ( getMinJumps ( S ) ) ; } }

Index/key variables: i
Accumulator variables: i, ind, jumps
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int N = ( int ) ( 1e5 + 5 ) ; static List < int > [ ] v = new List < int > [ N ] ; static int [ ] val = new int [ N ] ; static int [ ] answer = new int [ N ] ; static int n ; static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static void DFS ( int node , int parent ) { answer [ node ] = val [ node ] ; foreach ( int child in v [ node ] ) { if ( child == parent ) continue ; DFS ( child , node ) ; answer [ node ] = gcd ( answer [ node ] , answer [ child ] ) ; } } static void preprocess ( ) { DFS ( 1 , - 1 ) ; } static void findGCD ( int [ ] queries , int q ) { preprocess ( ) ; for ( int i = 0 ; i < q ; i ++ ) { int GCD = answer [ queries [ i ] ] ; Console . Write ( " For ▁ subtree ▁ of ▁ " + queries [ i ] + " , ▁ GCD ▁ = ▁ " + GCD + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { n = 5 ; for ( int i = 0 ; i < v . Length ; i ++ ) v [ i ] = new List < int > ( ) ; v [ 1 ] . Add ( 2 ) ; v [ 2 ] . Add ( 1 ) ; v [ 1 ] . Add ( 3 ) ; v [ 3 ] . Add ( 1 ) ; v [ 3 ] . Add ( 4 ) ; v [ 4 ] . Add ( 3 ) ; v [ 3 ] . Add ( 5 ) ; v [ 5 ] . Add ( 3 ) ; val [ 1 ] = 2 ; val [ 2 ] = 3 ; val [ 3 ] = 4 ; val [ 4 ] = 8 ; val [ 5 ] = 16 ; int [ ] queries = { 2 , 3 , 1 } ; int q = queries . Length ; findGCD ( queries , q ) ; } }

Index/key variables: N, child, i, node
Accumulator variables: i
Iterator variables: child, i
Class/struct names: GFG
C# program:
using System ; class GFG { static void makeZero ( int x , int y , int a , int b ) { if ( x > y ) { int temp = x ; x = y ; y = temp ; } int tot_cost = ( y - x ) * a ; int cost1 = 2 * x * a ; int cost2 = x * b ; tot_cost += Math . Min ( cost1 , cost2 ) ; Console . Write ( tot_cost ) ; } public static void Main ( ) { int X = 1 , Y = 3 ; int cost1 = 391 , cost2 = 555 ; makeZero ( X , Y , cost1 , cost2 ) ; } }

Accumulator variables: tot_cost
Class/struct names: GFG
C# program:
using System ; class GFG { public static void splitFraction ( int n , int d ) { long [ ] ar = new long [ n ] ; long first = d + n - 1 ; ar [ 0 ] = first ; for ( int i = 1 ; i < n ; i ++ ) { ar [ i ] = first * ( -- first ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( ar [ i ] % n == 0 ) { Console . Write ( "1 / " + ar [ i ] / n + " , ▁ " ) ; } else { Console . Write ( n + " / " + ar [ i ] + " , ▁ " ) ; } } } public static void Main ( String [ ] args ) { int N = 4 ; int D = 2 ; splitFraction ( N , D ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int numPairs ( int [ ] arr , int n ) { int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( arr [ j ] % arr [ i ] == 0 ) ans ++ ; } } return ans ; } public static void Main ( ) { int [ ] arr = { 1 , 1 , 2 , 2 , 3 , 3 } ; int n = arr . Length ; Console . Write ( numPairs ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check ( int [ ] arr , int n ) { bool flag = true ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < n - i ) { flag = false ; } } if ( flag ) { return true ; } else { return false ; } } static public void Main ( String [ ] args ) { int [ ] arr1 = { 11 , 11 , 11 , 11 } ; int n1 = arr1 . Length ; if ( check ( arr1 , n1 ) ) { Console . Write ( " Yes " + " STRNEWLINE " ) ; } else { Console . Write ( " No " + " STRNEWLINE " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int BalancedPartition ( string str , int n ) { if ( n == 0 ) return 0 ; int r = 0 , l = 0 ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' R ' ) { r ++ ; } else if ( str [ i ] == ' L ' ) { l ++ ; } if ( r == l ) { ans ++ ; } } return ans ; } public static void Main ( ) { string str = " LLRRRLLRRL " ; int n = str . Length ; Console . Write ( BalancedPartition ( str , n ) + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: ans, i, l, r
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minOccupiedPosition ( int [ ] A , int n ) { int minPos = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( A [ i ] > 0 ) { ++ minPos ; i += 2 ; } } return minPos ; } static void Main ( ) { int [ ] A = { 8 , 0 , 7 , 0 , 0 , 6 } ; int n = A . Length ; Console . WriteLine ( minOccupiedPosition ( A , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinimumK ( int [ ] a , int n , int S ) { int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; } return ( int ) Math . Ceiling ( ( ( S + 1 ) * 1.0 ) / ( sum * 1.0 ) ) ; } public static void Main ( String [ ] args ) { int [ ] a = { 10 , 7 , 8 , 10 , 12 , 19 } ; int n = a . Length ; int S = 200 ; Console . Write ( findMinimumK ( a , n , S ) ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int largestNum ( int n ) { int num = 0 ; for ( int i = 0 ; i <= 32 ; i ++ ) { int x = ( 1 << i ) ; if ( ( x - 1 ) <= n ) num = ( 1 << i ) - 1 ; else break ; } return num ; } public static void Main ( ) { int N = 345 ; Console . Write ( largestNum ( N ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findString ( int N , int K ) { for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( ( char ) ( ' A ' + i % K ) ) ; } } public static void Main ( String [ ] args ) { int N = 10 ; int K = 3 ; findString ( N , K ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int count ( String s ) { int N , i , cnt = 0 , ans = 0 ; N = s . Length ; for ( i = 0 ; i < N ; i ++ ) { if ( s [ i ] == ' R ' ) cnt ++ ; if ( s [ i ] == ' L ' ) ans += cnt ; } return ans ; } public static void Main ( String [ ] args ) { String s = " RRLL " ; Console . Write ( count ( s ) ) ; } }

Index/key variables: i
Accumulator variables: ans, cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void segments ( int n ) { if ( n == 1 n == 0 ) { return ; } if ( n % 2 == 0 ) { Console . Write ( "1" ) ; segments ( n - 2 ) ; } else if ( n % 2 == 1 ) { Console . Write ( "7" ) ; segments ( n - 3 ) ; } } public static void Main ( ) { int n ; n = 11 ; segments ( n ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinimumSubsequences ( String A , String B ) { int numberOfSubsequences = 1 ; int sizeOfB = B . Length ; int sizeOfA = A . Length ; int inf = 1000000 ; int [ , ] next = new int [ 26 , sizeOfB ] ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 0 ; j < sizeOfB ; j ++ ) { next [ i , j ] = inf ; } } for ( int i = 0 ; i < sizeOfB ; i ++ ) { next [ B [ i ] - ' a ' , i ] = i ; } for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = sizeOfB - 2 ; j >= 0 ; j -- ) { if ( next [ i , j ] == inf ) { next [ i , j ] = next [ i , j + 1 ] ; } } } int pos = 0 ; int I = 0 ; while ( I < sizeOfA ) { if ( pos == 0 && next [ A [ I ] - ' a ' , pos ] == inf ) { numberOfSubsequences = - 1 ; break ; } else if ( pos < sizeOfB && next [ A [ I ] - ' a ' , pos ] < inf ) { int nextIndex = next [ A [ I ] - ' a ' , pos ] + 1 ; pos = nextIndex ; I ++ ; } else { numberOfSubsequences ++ ; pos = 0 ; } } return numberOfSubsequences ; } public static void Main ( String [ ] args ) { String A = " aacbe " ; String B = " aceab " ; Console . Write ( findMinimumSubsequences ( A , B ) ) ; } }

Index/key variables: I, i
Accumulator variables: I, i, j, numberOfSubsequences
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void horizontalFill ( int [ ] records , int [ ] tape , int nt ) { int sum = 0 ; int Retrieval_Time = 0 ; double Mrt ; int current = 0 ; List < int > v = new List < int > ( ) ; for ( int i = 0 ; i < nt ; i ++ ) { v . Clear ( ) ; Retrieval_Time = 0 ; sum = 0 ; Console . Write ( " tape ▁ " + ( i + 1 ) + " ▁ : ▁ [ ▁ " ) ; sum += records [ current ] ; while ( sum <= tape [ i ] ) { Console . Write ( records [ current ] + " ▁ " ) ; v . Add ( records [ current ] ) ; current ++ ; sum += records [ current ] ; } Console . Write ( " ] " ) ; for ( int j = 0 ; j < v . Count ; j ++ ) { Retrieval_Time += v [ j ] * ( v . Count - j ) ; } Mrt = ( double ) Retrieval_Time / v . Count ; Console . Write ( " TABSYMBOL MRT ▁ : ▁ " + Mrt + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int [ ] records = { 15 , 2 , 8 , 23 , 45 , 50 , 60 , 120 } ; int [ ] tape = { 25 , 80 , 160 } ; int n = records . Length ; int m = tape . Length ; Array . Sort ( records ) ; horizontalFill ( records , tape , m ) ; } }

Index/key variables: current, i, j
Accumulator variables: Retrieval_Time, current, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { readonly static int MAX_SIZE = 10 ; static void convolution ( int [ ] x , int [ ] h , int n , int m ) { int [ ] row_vec = new int [ MAX_SIZE ] ; int [ ] col_vec = new int [ MAX_SIZE ] ; int [ ] out_ = new int [ MAX_SIZE ] ; int [ , ] circular_shift_mat = new int [ MAX_SIZE , MAX_SIZE ] ; int maxSize = n > m ? n : m ; for ( int i = 0 ; i < maxSize ; i ++ ) { if ( i >= n ) { row_vec [ i ] = 0 ; } else { row_vec [ i ] = x [ i ] ; } } for ( int i = 0 ; i < maxSize ; i ++ ) { if ( i >= m ) { col_vec [ i ] = 0 ; } else { col_vec [ i ] = h [ i ] ; } } int k = 0 , d = 0 ; for ( int i = 0 ; i < maxSize ; i ++ ) { int curIndex = k - d ; for ( int j = 0 ; j < maxSize ; j ++ ) { circular_shift_mat [ j , i ] = row_vec [ curIndex % maxSize ] ; curIndex ++ ; } k = maxSize ; d ++ ; } for ( int i = 0 ; i < maxSize ; i ++ ) { for ( int j = 0 ; j < maxSize ; j ++ ) { out_ [ i ] += circular_shift_mat [ i , j ] * col_vec [ j ] ; } Console . Write ( out_ [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] x = { 5 , 7 , 3 , 2 } ; int n = x . Length ; int [ ] h = { 1 , 5 } ; int m = h . Length ; convolution ( x , h , n , m ) ; } }

Index/key variables: MAX_SIZE, i, j
Accumulator variables: curIndex, d, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int max_palindrome ( string [ ] s , int n ) { int flag = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] . Length % 2 != 0 ) { flag = 1 ; } } if ( flag == 1 ) { return n ; } int z = 0 ; int o = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < s [ i ] . Length ; j ++ ) { if ( s [ i ] [ j ] == '0' ) z += 1 ; else o += 1 ; } } if ( o % 2 == 0 && z % 2 == 0 ) { return n ; } else { return n - 1 ; } } public static void Main ( ) { int n = 3 ; string [ ] s = { "1110" , "100110" , "010101" } ; Console . WriteLine ( max_palindrome ( s , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, o, z
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minCost ( int [ ] cost , int n ) { int totalCost = 0 ; int boardingBus = 0 ; for ( int i = 1 ; i < n ; i ++ ) { if ( cost [ boardingBus ] > cost [ i ] ) { totalCost += ( ( i - boardingBus ) * cost [ boardingBus ] ) ; boardingBus = i ; } } totalCost += ( ( n - boardingBus ) * cost [ boardingBus ] ) ; return totalCost ; } public static void Main ( String [ ] args ) { int [ ] cost = { 4 , 7 , 8 , 3 , 4 } ; int n = cost . Length ; Console . Write ( minCost ( cost , n ) ) ; } }

Index/key variables: boardingBus, i
Accumulator variables: i, totalCost
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minFlipsSub ( String [ ] mat , int i , int j ) { int cnt0 = 0 , cnt1 = 0 ; if ( mat [ i ] [ j ] == '1' ) cnt1 ++ ; else cnt0 ++ ; if ( mat [ i ] [ j + 1 ] == '1' ) cnt1 ++ ; else cnt0 ++ ; if ( mat [ i + 1 ] [ j ] == '1' ) cnt1 ++ ; else cnt0 ++ ; if ( mat [ i + 1 ] [ j + 1 ] == '1' ) cnt1 ++ ; else cnt0 ++ ; return Math . Min ( cnt0 , cnt1 ) ; } static int minFlips ( String [ ] mat , int r , int c ) { int res = int . MaxValue ; for ( int i = 0 ; i < r - 1 ; i ++ ) { for ( int j = 0 ; j < c - 1 ; j ++ ) { res = Math . Min ( res , minFlipsSub ( mat , i , j ) ) ; } } return res ; } public static void Main ( String [ ] args ) { String [ ] mat = { "0101" , "0101" , "0101" } ; int r = mat . Length ; int c = mat . GetLength ( 0 ) ; Console . Write ( minFlips ( mat , r , c ) ) ; } }

Index/key variables: i, j
Accumulator variables: cnt0, cnt1, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int findK ( int n , int k ) { int pos ; if ( n % 2 == 0 ) { pos = n / 2 ; } else { pos = ( n / 2 ) + 1 ; } if ( k <= pos ) { return ( k * 2 - 1 ) ; } else return ( ( k - pos ) * 2 ) ; } static int countSetBits ( int n , int k ) { int kth = findK ( n , k ) ; int count = 0 ; while ( kth > 0 ) { count += kth & 1 ; kth >>= 1 ; } return count ; } public static void Main ( String [ ] args ) { int n = 18 , k = 12 ; Console . WriteLine ( countSetBits ( n , k ) ) ; } }

Accumulator variables: count
Class/struct names: GFG
C# program:
using System ; class GFG { static int minCost ( string str1 , string str2 , int n ) { int cost = 0 ; char [ ] array = str1 . ToCharArray ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( str1 [ i ] != str2 [ i ] ) { if ( i < n - 1 && str1 [ i + 1 ] != str2 [ i + 1 ] ) { char temp = array [ i ] ; array [ i ] = array [ i + 1 ] ; array [ i + 1 ] = temp ; cost ++ ; } else { cost ++ ; } } } return cost ; } static public void Main ( ) { string str1 = " abb " , str2 = " bba " ; int n = str1 . Length ; Console . WriteLine ( minCost ( str1 , str2 , n ) ) ; } }

Index/key variables: i
Accumulator variables: cost, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void find_set ( int n ) { if ( n <= 2 ) { Console . WriteLine ( " - 1" ) ; return ; } int sum1 = ( n * ( n - 1 ) ) / 2 ; int sum2 = n ; Console . WriteLine ( sum1 + " ▁ " + sum2 ) ; } public static void Main ( ) { int n = 8 ; find_set ( n ) ; } }

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 int lcm ( int n , int m ) { return ( n * m ) / gcd ( n , m ) ; } public static void Main ( String [ ] args ) { int n = 2 , m = 3 , k = 5 ; Console . WriteLine ( k / lcm ( n , m ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool CheckForSequence ( int [ ] arr , int n , int k ) { for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( k >= arr [ i ] ) k -= arr [ i ] ; } if ( k != 0 ) return false ; else return true ; } public static void Main ( ) { int [ ] A = { 1 , 3 , 7 , 15 , 31 } ; int n = A . Length ; Console . WriteLine ( CheckForSequence ( A , n , 18 ) ? " True " : " False " ) ; } }

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