dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void print_substring ( String s ) { int n = s . Length ; String str = " " ; if ( n == 0 ) { Console . Write ( " - 1" ) ; return ; } int [ ] last_pos = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) last_pos [ i ] = - 1 ; for ( int i = n - 1 ; i >= 0 ; -- i ) { if ( last_pos [ s [ i ] - ' a ' ] == - 1 ) { last_pos [ s [ i ] - ' a ' ] = i ; } } int minp = - 1 ; for ( int i = 0 ; i < n ; ++ i ) { int lp = last_pos [ s [ i ] - ' a ' ] ; minp = Math . Max ( minp , lp ) ; if ( i == minp ) { str += s [ i ] ; Console . Write ( str + ' ▁ ' ) ; minp = - 1 ; str = " " ; } else { str += s [ i ] ; } } } public static void Main ( String [ ] args ) { String S = " ababcbacadefegdehijhklij " ; print_substring ( S ) ; } }

Index/key variables: i
Accumulator variables: i, str
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void partitionString ( String s ) { int n = s . Length ; List < int > ans = new List < int > ( ) ; if ( n == 0 ) { Console . Write ( " - 1" ) ; return ; } int [ ] last_pos = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; ++ i ) { last_pos [ i ] = - 1 ; } for ( int i = n - 1 ; i >= 0 ; -- i ) { if ( last_pos [ s [ i ] - ' a ' ] == - 1 ) { last_pos [ s [ i ] - ' a ' ] = i ; } } int minp = - 1 , plen = 0 ; for ( int i = 0 ; i < n ; ++ i ) { int lp = last_pos [ s [ i ] - ' a ' ] ; minp = Math . Max ( minp , lp ) ; ++ plen ; if ( i == minp ) { ans . Add ( plen ) ; minp = - 1 ; plen = 0 ; } } for ( int i = 0 ; i < ( int ) ans . Count ; i ++ ) { Console . Write ( ans [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { String str = " acbbcc " ; partitionString ( str ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void solve ( string S ) { int count_0 = 0 , count_1 = 0 ; int prev = - 1 ; for ( int i = 0 ; i < S . Length ; i ++ ) { if ( S [ i ] == '0' ) count_0 ++ ; else if ( S [ i ] == '1' ) count_1 ++ ; } for ( int i = 0 ; i < S . Length ; i ++ ) { if ( S [ i ] == ' * ' ) continue ; else if ( S [ i ] == '0' && prev == - 1 ) { count_0 = count_0 + i ; prev = i ; } else if ( S [ i ] == '1' && prev == - 1 ) { prev = i ; } else if ( S [ prev ] == '1' && S [ i ] == '0' ) { count_0 = count_0 + ( i - prev - 1 ) / 2 ; count_1 = count_1 + ( i - prev - 1 ) / 2 ; prev = i ; } else if ( S [ prev ] == '1' && S [ i ] == '1' ) { count_1 = count_1 + ( i - prev - 1 ) ; prev = i ; } else if ( S [ prev ] == '0' && S [ i ] == '1' ) prev = i ; else if ( S [ prev ] == '0' && S [ i ] == '0' ) { count_0 = count_0 + ( i - prev - 1 ) ; prev = i ; } } if ( count_0 > count_1 ) Console . Write ( "0" ) ; else if ( count_1 > count_0 ) Console . Write ( "1" ) ; else { Console . Write ( " - 1" ) ; } } public static void Main ( ) { string str = " * *0 * * 1 * * *0" ; solve ( str ) ; } }

Index/key variables: i, prev
Accumulator variables: count_0, count_1, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minFirstTerm ( int X , int diff , int N ) { int first_term = int . MaxValue ; int low = 0 , high = N ; while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( X - mid * diff > 0 ) { first_term = X - mid * diff ; low = mid + 1 ; } else high = mid - 1 ; } return first_term ; } static void printAP ( int N , int X , int Y ) { if ( X > Y ) { X = X + Y ; Y = X - Y ; X = X - Y ; } int maxDiff = Y - X ; int first_term = int . MaxValue , diff = 0 ; for ( int i = 1 ; i * i <= maxDiff ; i ++ ) { if ( maxDiff % i == 0 ) { int diff1 = i ; int diff2 = maxDiff / diff1 ; int terms1 = diff2 + 1 ; int terms2 = diff1 + 1 ; int first_term1 = minFirstTerm ( X , diff1 , N - terms1 ) ; int first_term2 = minFirstTerm ( X , diff2 , N - terms2 ) ; if ( first_term1 < first_term ) { first_term = first_term1 ; diff = diff1 ; } if ( first_term2 < first_term ) { first_term = first_term2 ; diff = diff2 ; } } } for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( first_term + " ▁ " ) ; first_term += diff ; } } public static void Main ( String [ ] args ) { int N = 5 , X = 10 , Y = 15 ; printAP ( N , X , Y ) ; } }

Accumulator variables: first_term, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isCubeSum ( int n ) { for ( int i = 1 ; i * i * i <= n ; i ++ ) { if ( i * i * i + ( i + 1 ) * ( i + 1 ) * ( i + 1 ) == n ) return true ; } return false ; } public static void Main ( String [ ] args ) { int n = 35 ; if ( isCubeSum ( n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isSumCube ( int N ) { int a = ( int ) Math . Pow ( N , ( double ) 1 / 3 ) ; int b = a - 1 ; return ( ( a * a * a + b * b * b ) == N ) ; } public static void Main ( String [ ] args ) { int i = 35 ; if ( isSumCube ( i ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxweight ( int s , int e , Dictionary < int , int > pre ) { if ( s == e ) return 0 ; int ans = 0 ; for ( int i = s ; i < e ; i ++ ) { int left = pre [ i ] - pre [ s - 1 ] ; int right = pre [ e ] - pre [ i ] ; if ( left < right ) ans = Math . Max ( ans , left + maxweight ( s , i , pre ) ) ; if ( left == right ) { ans = Math . Max ( ans , Math . Max ( left + maxweight ( s , i , pre ) , right + maxweight ( i + 1 , e , pre ) ) ) ; } if ( left > right ) ans = Math . Max ( ans , right + maxweight ( i + 1 , e , pre ) ) ; } return ans ; } static void maxSum ( List < int > arr ) { Dictionary < int , int > pre = new Dictionary < int , int > ( ) ; pre . Add ( - 1 , 0 ) ; pre . Add ( 0 , arr [ 0 ] ) ; for ( int i = 1 ; i < arr . Count ; i ++ ) { if ( pre [ i - 1 ] != 0 ) pre . Add ( i , pre [ i - 1 ] + arr [ i ] ) ; else pre . Add ( i , arr [ i ] ) ; } Console . WriteLine ( maxweight ( 0 , arr . Count - 1 , pre ) ) ; } public static void Main ( String [ ] args ) { List < int > arr = new List < int > ( ) ; arr . Add ( 6 ) ; arr . Add ( 2 ) ; arr . Add ( 3 ) ; arr . Add ( 4 ) ; arr . Add ( 5 ) ; arr . Add ( 5 ) ; maxSum ( arr ) ; } }

Index/key variables: e, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static String largestTimeFromDigits ( int [ ] A ) { Dictionary < int , int > mp1 = new Dictionary < int , int > ( ) ; Dictionary < int , int > mp2 = new Dictionary < int , int > ( ) ; foreach ( int x in A ) { if ( mp1 . ContainsKey ( x ) ) mp1 [ x ] = mp1 [ x ] + 1 ; else mp1 . Add ( x , 1 ) ; } mp2 = new Dictionary < int , int > ( mp1 ) ; int hr = 23 , m = 59 , s = 59 ; while ( hr >= 0 ) { int h0 = hr / 10 , h1 = hr % 10 ; int m0 = m / 10 , m1 = m % 10 ; int s0 = s / 10 , s1 = s % 10 ; int p = 0 ; int [ ] arr = { h0 , h1 , m0 , m1 , s0 , s1 } ; foreach ( int it in arr ) { if ( mp1 . ContainsKey ( it ) && mp1 [ it ] > 0 ) { mp1 [ it ] = mp1 [ it ] - 1 ; } else { p = 1 ; } } if ( p == 0 ) { String st = " " ; st = String . Join ( " " , h0 ) + String . Join ( " " , h1 ) ; st += ' : ' + String . Join ( " " , m0 ) + String . Join ( " " , m1 ) ; st += ' : ' + String . Join ( " " , s0 ) + String . Join ( " " , s1 ) ; return st ; } mp1 = new Dictionary < int , int > ( mp2 ) ; if ( s == 0 ) { s = 59 ; m -- ; } else if ( m < 0 ) { m = 59 ; hr -- ; } if ( s > 0 ) { s -- ; } } return " - 1" ; } public static void Main ( String [ ] args ) { int [ ] v = { 0 , 2 , 1 , 9 , 3 , 2 } ; Console . Write ( largestTimeFromDigits ( v ) ) ; } }

Index/key variables: it, x
Accumulator variables: hr, m, s, st
Iterator variables: it, x
Class/struct names: GFG
C# program:
using System ; class GFG { static String palindromePrefix ( String S ) { int n = S . Length ; for ( int i = n - 1 ; i >= 0 ; i -- ) { String curr = S . Substring ( 0 , i + 1 ) ; int l = 0 , r = curr . Length - 1 ; bool is_palindrome = true ; while ( l < r ) { if ( curr [ l ] != curr [ r ] ) { is_palindrome = false ; break ; } l ++ ; r -- ; } if ( is_palindrome ) return curr ; } return " " ; } static String maxPalindrome ( String S ) { int n = S . Length ; if ( n <= 1 ) { return S ; } String pre = " " , suff = " " ; int i = 0 , j = n - 1 ; while ( S [ i ] == S [ j ] && i < j ) { i ++ ; j -- ; } i -- ; j ++ ; pre = S . Substring ( 0 , i + 1 ) ; suff = S . Substring ( j ) ; if ( j - i == 1 ) { return pre + suff ; } if ( j - i == 2 ) { String mid_char = S . Substring ( i + 1 , i + 2 ) ; return pre + mid_char + suff ; } String rem_str = S . Substring ( i + 1 , j ) ; String pre_of_rem_str = palindromePrefix ( rem_str ) ; rem_str = reverse ( rem_str ) ; String suff_of_rem_str = palindromePrefix ( rem_str ) ; if ( pre_of_rem_str . Length >= suff_of_rem_str . Length ) { return pre + pre_of_rem_str + suff ; } else { return pre + suff_of_rem_str + suff ; } } static String reverse ( String input ) { char [ ] a = input . ToCharArray ( ) ; int l , r = a . Length - 1 ; for ( l = 0 ; l < r ; l ++ , r -- ) { char temp = a [ l ] ; a [ l ] = a [ r ] ; a [ r ] = temp ; } return String . Join ( " " , a ) ; } public static void Main ( String [ ] args ) { String S = " geeksforskeeg " ; Console . Write ( maxPalindrome ( S ) ) ; } }

Index/key variables: i, j, l, r
Accumulator variables: i, j, l, r
Iterator variables: i, l
Boolean variables: is_palindrome
Class/struct names: GFG
C# program:
using System ; class GFG { static void countNumEnds ( int A , int L , int R ) { int temp , count = 0 , digits ; int cycle ; digits = ( int ) ( Math . Log10 ( A ) + 1 ) ; temp = ( int ) Math . Pow ( 10 , digits ) ; cycle = temp ; while ( temp <= R ) { if ( temp >= L ) count ++ ; temp += cycle ; } Console . Write ( count ) ; } public static void Main ( String [ ] args ) { int A = 2 , L = 2 , R = 20 ; countNumEnds ( A , L , R ) ; } }

Accumulator variables: count, temp
Class/struct names: GFG
C# program:
using System ; class GFG { public static int minOperations ( String s ) { int len = s . Length ; int result = 0 ; for ( int i = 0 ; i < len / 2 ; i ++ ) { int D1 = Math . Max ( s [ i ] , s [ len - 1 - i ] ) - Math . Min ( s [ i ] , s [ len - 1 - i ] ) ; int D2 = 26 - D1 ; result += Math . Min ( D1 , D2 ) ; } return result ; } public static void Main ( String [ ] args ) { String s = " abccdb " ; Console . WriteLine ( minOperations ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool findFactor ( int value , HashSet < int > factors ) { factors . Add ( value ) ; for ( int i = 2 ; i * i <= value ; i ++ ) { if ( value % i == 0 ) { if ( value / i == i ) { if ( factors . Contains ( i ) ) { return true ; } else { factors . Add ( i ) ; } } else { if ( factors . Contains ( i ) || factors . Contains ( value / i ) ) { return true ; } else { factors . Add ( i ) ; factors . Add ( value / i ) ; } } } } return false ; } static bool allCoprime ( int [ ] A , int n ) { bool all_coprime = true ; HashSet < int > factors = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( A [ i ] == 1 ) continue ; if ( findFactor ( A [ i ] , factors ) ) { all_coprime = false ; break ; } } return all_coprime ; } public static void Main ( String [ ] args ) { int [ ] A = { 3 , 5 , 11 , 7 , 19 } ; int arr_size = A . Length ; if ( allCoprime ( A , arr_size ) ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Boolean variables: all_coprime
Class/struct names: GFG
C# program:
using System ; using System . Linq ; class GFG { static double countSubSequence ( int [ ] arr , int n ) { int maximum = arr . Max ( ) ; int minimum = arr . Min ( ) ; if ( maximum == minimum ) return Math . Pow ( 2 , n ) - 1 ; int i = count ( arr , maximum ) ; int j = count ( arr , minimum ) ; double res = ( Math . Pow ( 2 , i ) - 1 ) * ( Math . Pow ( 2 , j ) - 1 ) * Math . Pow ( 2 , n - i - j ) ; return res ; } static int count ( int [ ] arr , int value ) { int sum = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) if ( arr [ i ] == value ) sum ++ ; return sum ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int n = arr . Length ; Console . WriteLine ( countSubSequence ( 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 transformSubsequence ( int n , int m , int [ ] A , int [ ] B ) { if ( B . Length == 0 ) return n ; int [ , ] dp = new int [ n + 1 , m + 1 ] ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int j = 0 ; j < m + 1 ; j ++ ) { if ( i == 0 j == 0 ) dp [ i , j ] = 0 ; else if ( A [ i - 1 ] == B [ j - 1 ] ) dp [ i , j ] = 1 + dp [ i - 1 , j - 1 ] ; else dp [ i , j ] = Math . Max ( dp [ i - 1 , j ] , dp [ i , j - 1 ] ) ; } } return n - dp [ n , m ] ; } public static void Main ( String [ ] args ) { int N = 5 ; int M = 6 ; int [ ] A = { 1 , 2 , 3 , 4 , 5 } ; int [ ] B = { 2 , 5 , 6 , 4 , 9 , 12 } ; Console . Write ( transformSubsequence ( N , M , A , B ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int checkForPerfectSquare ( int [ ] arr , int i , int j ) { int mid , sum = 0 ; for ( int m = i ; m <= j ; m ++ ) { sum += arr [ m ] ; } int low = 0 , high = sum / 2 ; while ( low <= high ) { mid = low + ( high - low ) / 2 ; if ( mid * mid == sum ) { return mid ; } else if ( mid * mid > sum ) { high = mid - 1 ; } else { low = mid + 1 ; } } return - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 19 , 33 , 48 , 90 , 100 } ; int L = 1 , R = 3 ; Console . Write ( checkForPerfectSquare ( arr , L , R ) ) ; } }

Index/key variables: m
Accumulator variables: m, sum
Iterator variables: m
Class/struct names: GFG
C# program:
using System ; class GFG { static int calcSubarray ( int [ ] A , int N ) { int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { bool flag = true ; int comm_diff = A [ i + 1 ] - A [ i ] ; for ( int k = i ; k < j ; k ++ ) { if ( A [ k + 1 ] - A [ k ] == comm_diff ) { continue ; } else { flag = false ; break ; } } if ( flag ) { count ++ ; } } } return count ; } public static void Main ( String [ ] args ) { int [ ] A = { 8 , 7 , 4 , 1 , 0 } ; int N = A . Length ; Console . Write ( calcSubarray ( A , N ) ) ; } }

Index/key variables: i, k
Accumulator variables: count, i, j, k
Iterator variables: i, j, k
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int maxSumSubarray ( int [ ] arr ) { int i = 0 , j = 1 ; HashSet < int > set = new HashSet < int > ( ) ; set . Add ( arr [ 0 ] ) ; int sum = arr [ 0 ] ; int maxsum = sum ; while ( i < arr . Length - 1 && j < arr . Length ) { if ( ! set . Contains ( arr [ j ] ) ) { sum = sum + arr [ j ] ; maxsum = Math . Max ( sum , maxsum ) ; set . Add ( arr [ j ++ ] ) ; } else { sum -= arr [ i ] ; set . Remove ( arr [ i ++ ] ) ; } } return maxsum ; } public static void Main ( String [ ] args ) { int [ ] arr = new int [ ] { 1 , 2 , 3 , 1 , 5 } ; int ans = maxSumSubarray ( arr ) ; Console . WriteLine ( ans ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, sum
Class/struct names: GFG
C# program:
using System ; class GFG { static int count_numbers ( int L , int R ) { int ans = 0 ; for ( int n = L ; n <= R ; n ++ ) { int no_of_bits = ( int ) ( Math . Log ( n ) + 1 ) ; int no_of_set_bits = bitCount ( n ) ; if ( no_of_bits - no_of_set_bits == 1 ) { ans ++ ; } } return ans ; } static int bitCount ( long x ) { int setBits = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; setBits ++ ; } return setBits ; } public static void Main ( String [ ] args ) { int L = 4 , R = 9 ; Console . Write ( count_numbers ( L , R ) ) ; } }

Accumulator variables: ans, n, setBits
Iterator variables: n
Class/struct names: GFG
C# program:
using System ; public class GFG { static int count_numbers ( int L , int R ) { int ans = 0 ; int LogR = ( int ) ( Math . Log ( R ) + 1 ) ; for ( int zero_bit = 0 ; zero_bit < LogR ; zero_bit ++ ) { int cur = 0 ; for ( int j = 0 ; j < zero_bit ; j ++ ) { cur |= ( 1 << j ) ; } for ( int j = zero_bit + 1 ; j < LogR ; j ++ ) { cur |= ( 1 << j ) ; if ( cur >= L && cur <= R ) { ans ++ ; } } } return ans ; } public static void Main ( String [ ] args ) { int L = 4 , R = 9 ; Console . Write ( count_numbers ( L , R ) ) ; } }

Accumulator variables: ans, cur, j, zero_bit
Iterator variables: j, zero_bit
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSum ( String s ) { int sum = 0 ; for ( int i = 0 ; i < s . Length ; i ++ ) { for ( int j = i + 1 ; j < s . Length ; j ++ ) { if ( s [ i ] == s [ j ] ) { sum += ( j - i ) ; } } } return sum ; } public static void Main ( String [ ] args ) { String s = " ttt " ; Console . Write ( findSum ( s ) + " STRNEWLINE " ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countElements ( int [ ] a , int n ) { int [ ] cnt = new int [ n + 1 ] ; int ans = 0 ; foreach ( int k in a ) { ++ cnt [ k ] ; } for ( int l = 0 ; l < n ; ++ l ) { int sum = 0 ; for ( int r = l ; r < n ; ++ r ) { sum += a [ r ] ; if ( l == r ) continue ; if ( sum <= n ) { ans += cnt [ sum ] ; cnt [ sum ] = 0 ; } } } return ans ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 1 , 1 , 1 , 1 } ; Console . WriteLine ( countElements ( a , a . Length ) ) ; } }

Index/key variables: k, r, sum
Accumulator variables: ans, sum
Iterator variables: k, l, r
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxGCD ( int n ) { int maxHcf = int . MinValue ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = i + 1 ; j <= n ; j ++ ) { maxHcf = Math . Max ( maxHcf , __gcd ( i , j ) ) ; } } return maxHcf ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } public static void Main ( String [ ] args ) { int n = 4 ; Console . Write ( maxGCD ( n ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxGCD ( int n ) { return ( n / 2 ) ; } public static void Main ( String [ ] args ) { int n = 4 ; Console . Write ( maxGCD ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static string removeOddIndexCharacters ( string s ) { string new_string = " " ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( i % 2 == 1 ) continue ; new_string += s [ i ] ; } return new_string ; } public static void Main ( ) { string str = " abcdef " ; str = removeOddIndexCharacters ( str ) ; Console . Write ( str ) ; } }

Index/key variables: i
Accumulator variables: i, new_string
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int longestGP ( int [ ] A , int N ) { if ( N < 2 ) return N ; int length = 1 , common_ratio = 1 ; int maxlength = 1 ; for ( int i = 0 ; i < N - 1 ; i ++ ) { if ( A [ i + 1 ] % A [ i ] == 0 ) { if ( A [ i + 1 ] / A [ i ] == common_ratio ) { length = length + 1 ; maxlength = Math . Max ( maxlength , length ) ; } else { common_ratio = A [ i + 1 ] / A [ i ] ; length = 2 ; } } else { maxlength = Math . Max ( maxlength , length ) ; length = 1 ; } } maxlength = Math . Max ( maxlength , length ) ; return maxlength ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 7 , 14 , 28 , 56 , 89 } ; int N = arr . Length ; Console . WriteLine ( longestGP ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int uncrossedLines ( int [ ] a , int [ ] b , int n , int m ) { int [ , ] dp = new int [ n + 1 , m + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= m ; j ++ ) { if ( i == 0 j == 0 ) dp [ i , j ] = 0 ; else if ( a [ i - 1 ] == b [ j - 1 ] ) dp [ i , j ] = 1 + dp [ i - 1 , j - 1 ] ; else dp [ i , j ] = Math . Max ( dp [ i - 1 , j ] , dp [ i , j - 1 ] ) ; } } return dp [ n , m ] ; } public static void Main ( String [ ] args ) { int [ ] A = { 3 , 9 , 2 } ; int [ ] B = { 3 , 2 , 9 } ; int N = A . Length ; int M = B . Length ; Console . Write ( uncrossedLines ( A , B , N , M ) ) ; } } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minFlips ( int [ , ] mat , String s ) { int N = mat . GetLength ( 0 ) ; int M = mat . GetLength ( 1 ) ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( mat [ i , j ] != s [ i + j ] - '0' ) { count ++ ; } } } return count ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 1 , 0 , 1 } , { 0 , 1 , 1 } , { 0 , 0 , 0 } } ; String s = "10001" ; Console . Write ( minFlips ( mat , s ) ) ; } }

Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void lcmpair ( int l , int r ) { int x , y ; x = l ; y = 2 * l ; if ( y > r ) { Console . Write ( " - 1 STRNEWLINE " ) ; } else { Console . Write ( " X ▁ = ▁ " + x + " ▁ Y ▁ = ▁ " + y + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int l = 13 , r = 69 ; lcmpair ( l , r ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int revNum ( int N ) { int x = 0 ; while ( N != 0 ) { x = x * 10 + N % 10 ; N = N / 10 ; } return x ; } static int ctNonPalin ( int [ ] arr , int N ) { int Res = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int x = revNum ( arr [ i ] ) ; if ( x == arr [ i ] ) { continue ; } else { if ( arr [ i ] % 10 == x % 10 ) Res += 1 ; } } return Res ; } public static void Main ( ) { int [ ] arr = new int [ ] { 121 , 134 , 2342 , 4514 } ; int N = arr . Length ; Console . WriteLine ( ctNonPalin ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: Res, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int minlt ( int [ ] arr , int target , int n ) { int [ , ] dp = new int [ arr . Length + 1 , target + 1 ] ; for ( int i = 0 ; i < arr . Length + 1 ; i ++ ) { for ( int j = 0 ; j < target + 1 ; j ++ ) { dp [ i , j ] = - 1 ; } } for ( int i = 0 ; i < arr . Length + 1 ; i ++ ) dp [ i , 0 ] = 0 ; for ( int j = 0 ; j < target + 1 ; j ++ ) dp [ 0 , j ] = int . MaxValue ; for ( int i = 1 ; i <= arr . Length ; i ++ ) { for ( int j = 1 ; j <= target ; j ++ ) { if ( arr [ i - 1 ] > j ) { dp [ i , j ] = dp [ i - 1 , j ] ; } else { dp [ i , j ] = Math . Min ( dp [ i - 1 , j ] , ( dp [ i , j - arr [ i - 1 ] ] ) != int . MaxValue ? ( dp [ i , j - arr [ i - 1 ] ] + 1 ) : int . MaxValue ) ; } } } if ( dp [ arr . Length , target ] == int . MaxValue ) { return - 1 ; } else { return dp [ arr . Length , target ] ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 5 , 4 , 1 } ; int target = 11 ; int n = arr . Length ; Console . Write ( minlt ( arr , target , n ) ) ; } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minServerLoads ( int n , int [ ] servers ) { int totalLoad = 0 ; for ( int i = 0 ; i < servers . Length ; i ++ ) totalLoad += servers [ i ] ; int requiredLoad = totalLoad / 2 ; int [ , ] dp = new int [ n + 1 , requiredLoad + 1 ] ; for ( int i = 1 ; i < n + 1 ; i ++ ) { for ( int j = 1 ; j < requiredLoad + 1 ; j ++ ) { if ( servers [ i - 1 ] > j ) dp [ i , j ] = dp [ i - 1 , j ] ; else dp [ i , j ] = Math . Max ( dp [ i - 1 , j ] , servers [ i - 1 ] + dp [ i - 1 , j - servers [ i - 1 ] ] ) ; } } return totalLoad - 2 * dp [ n , requiredLoad ] ; } public static void Main ( string [ ] args ) { int N = 5 ; int [ ] servers = { 1 , 2 , 3 , 4 , 5 } ; Console . Write ( minServerLoads ( N , servers ) ) ; } }

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