dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { public static void Main ( string [ ] args ) { int a = 0 , b = 0 ; int N = 4 , M = 4 ; for ( int i = 0 ; i < N ; i ++ ) { a = a + 10 ; } for ( int i = 0 ; i < M ; i ++ ) { b = b + 40 ; } Console . Write ( a + " ▁ " + b ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void stoogesort ( int [ ] arr , int l , int h ) { if ( l >= h ) return ; if ( arr [ l ] > arr [ h ] ) { int temp = arr [ l ] ; arr [ l ] = arr [ h ] ; arr [ h ] = temp ; } if ( h - l + 1 > 2 ) { int t = ( h - l + 1 ) / 3 ; stoogesort ( arr , l , h - t ) ; stoogesort ( arr , l + t , h ) ; stoogesort ( arr , l , h - t ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 5 , 3 , 1 } ; int N = arr . Length ; stoogesort ( arr , 0 , N - 1 ) ; for ( int i = 0 ; i < N ; i ++ ) { Console . Write ( arr [ i ] + " ▁ " ) ; } } }

Index/key variables: h, i, l
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int Fibonacci ( int N ) { if ( N < 2 ) return N ; return Fibonacci ( N - 1 ) + Fibonacci ( N - 2 ) ; } public static void Main ( string [ ] args ) { int N = 5 ; Console . Write ( Fibonacci ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void findWinner ( int n , int m ) { int X = 0 ; int Y = 0 ; if ( n >= m ) { X = n - 1 ; Y = m ; } else { X = m - 1 ; Y = n ; } if ( X > Y ) Console . Write ( " X " ) ; else if ( Y > X ) Console . Write ( " Y " ) ; else Console . Write ( " - 1" ) ; } public static void Main ( String [ ] args ) { int n = 3 , m = 1 ; findWinner ( n , m ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void checkPascaltriangle ( int N ) { double x = ( Math . Sqrt ( 8 * N + 1 ) - 1 ) / 2 ; if ( Math . Ceiling ( x ) - x == 0 ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( String [ ] args ) { int N = 10 ; checkPascaltriangle ( N ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void countSubarrays ( int [ ] arr , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int sum = 0 ; for ( int j = i ; j < n ; j ++ ) { if ( ( j - i ) % 2 == 0 ) sum += arr [ j ] ; else sum -= arr [ j ] ; if ( sum == 0 ) count ++ ; } } Console . WriteLine ( count ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 4 , 6 , 4 , 2 } ; int n = arr . Length ; countSubarrays ( arr , n ) ; } }

Index/key variables: j
Accumulator variables: count, i, j, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class P2Placerooks { static void findCountRooks ( int [ ] row , int [ ] col , int n , int k ) { int res = n - k ; Console . WriteLine ( res + " ▁ " ) ; int ri = 0 , ci = 0 ; while ( res -- > 0 ) { while ( ri < k && row [ ri ] == 1 ) { ri ++ ; } while ( ci < k && col [ ci ] == 1 ) { ci ++ ; } Console . WriteLine ( ( ri + 1 ) + " ▁ " + ( ci + 1 ) + " ▁ " ) ; ri ++ ; ci ++ ; } } public static void Main ( String [ ] args ) { int n = 4 ; int k = 2 ; int [ ] row = { 1 , 2 } ; int [ ] col = { 4 , 2 } ; findCountRooks ( row , col , n , k ) ; } }

Index/key variables: ci, ri
Accumulator variables: ci, res, ri
Class/struct names: P2Placerooks
C# program:
using System ; class GFG { static bool checkIfDivisible ( String str , long num ) { long powerOf2 = ( int ) ( Math . Log ( num ) / Math . Log ( 2 ) ) ; if ( str . Length < powerOf2 ) return false ; if ( powerOf2 == 0 ) return true ; long i , number = 0 ; int len = str . Length ; for ( i = len - powerOf2 ; i < len ; i ++ ) { number += ( long ) ( ( str [ ( int ) i ] - '0' ) * Math . Pow ( 10 , powerOf2 - 1 ) ) ; powerOf2 -- ; } if ( number % num != 0 ) return false ; else return true ; } public static void Main ( String [ ] args ) { String str = "213467756564" ; long num = 4 ; if ( checkIfDivisible ( str , num ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Accumulator variables: i, number, powerOf2
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool check_order ( int [ ] arr ) { int cnt = 0 ; for ( int i = 0 ; i < arr . Length - 1 ; i ++ ) { if ( Math . Abs ( arr [ i + 1 ] - arr [ i ] ) > 1 ) cnt ++ ; } if ( Math . Abs ( arr [ 0 ] - arr [ arr . Length - 1 ] ) > 1 ) cnt ++ ; if ( cnt > 1 ) return false ; return true ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 4 , 5 , 1 } ; if ( check_order ( arr ) ) Console . Write ( " YES " ) ; else Console . Write ( " NO " ) ; } }

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int getM ( int n ) { if ( n == 1 ) return - 1 ; else return n - 2 ; } static void Main ( ) { int n = 10 ; Console . Write ( getM ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int maxProfit ( int [ ] prices , int n ) { if ( n <= 1 ) return 0 ; int [ ] rest = new int [ n ] ; int [ ] hold = new int [ 9 ] ; int [ ] sold = new int [ 9 ] ; rest [ 0 ] = 0 ; hold [ 0 ] = - prices [ 0 ] ; sold [ 0 ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) { rest [ i ] = Math . Max ( rest [ i - 1 ] , sold [ i - 1 ] ) ; hold [ i ] = Math . Max ( hold [ i - 1 ] , rest [ i - 1 ] - prices [ i ] ) ; sold [ i ] = hold [ i - 1 ] + prices [ i ] ; } return Math . Max ( rest [ n - 1 ] , sold [ n - 1 ] ) ; } static void Main ( ) { int [ ] price = { 2 , 4 , 5 , 0 , 2 } ; int n = price . Length ; Console . WriteLine ( maxProfit ( price , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findSubarrays ( int [ ] arr , int N , int K ) { return N - K + 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 5 , 3 , 2 , 17 , 18 } ; int K = 4 ; int N = arr . Length ; Console . Write ( findSubarrays ( arr , N , K ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int longest_subarray ( int [ ] arr , int d ) { int i = 0 , j = 1 , e = 0 ; for ( i = 0 ; i < d - 1 ; i ++ ) { if ( arr [ i ] == arr [ i + 1 ] ) { j = j + 1 ; } else { j = 1 ; } if ( e < j ) { e = j ; } } return e ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 } ; int N = arr . Length ; Console . Write ( longest_subarray ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] factorial = { 1 , 1 , 2 , 6 , 24 , 120 , 720 , 5040 , 40320 , 362880 } ; public static bool isStrong ( int N ) { String num = N . ToString ( ) ; int sum = 0 ; for ( int i = 0 ; i < num . Length ; i ++ ) { sum += factorial [ int . Parse ( num [ i ] + " " ) ] ; } return sum == N ; } public static void printStrongNumbers ( int N ) { for ( int i = 1 ; i <= N ; i ++ ) { if ( isStrong ( i ) ) { Console . Write ( i + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { int N = 1000 ; printStrongNumbers ( N ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairs ( int A , int B ) { int countY = 0 , countX = ( B - A ) + 1 , next_val = 9 ; while ( next_val <= B ) { if ( next_val >= A ) { countY += 1 ; } next_val = next_val * 10 + 9 ; } return ( countX * countY ) ; } public static void Main ( ) { int A = 1 ; int B = 16 ; Console . Write ( countPairs ( A , B ) ) ; } }

Accumulator variables: countY
Class/struct names: GFG
C# program:
using System ; class GFG { public static int solve ( int n , int m ) { int ans = n * ( m / 2 ) ; if ( m % 2 == 1 ) { ans += ( n + 1 ) / 2 ; } return ans ; } public static void Main ( String [ ] args ) { int N = 5 ; int M = 3 ; Console . WriteLine ( solve ( N , M ) ) ; } }

Accumulator variables: ans
Class/struct names: GFG
C# program:
using System . IO ; using System ; class GFG { static int max_len = 100005 ; static int [ ] cnt = new int [ max_len ] ; static void precompute ( string s , string K ) { int n = s . Length ; for ( int i = 0 ; i < n - 2 ; i ++ ) { cnt [ i + 1 ] = cnt [ i ] ; if ( s . Substring ( i , K . Length ) . Equals ( K ) ) { cnt [ i + 1 ] += 1 ; } } cnt [ n - 2 + 1 ] = cnt [ n - 2 ] ; } static void Main ( ) { string s = " ABCABCABABC " ; string K = " ABC " ; precompute ( s , K ) ; int [ , ] Q = { { 1 , 6 } , { 5 , 11 } } ; for ( int it = 0 ; it < Q . GetLength ( 0 ) ; it ++ ) { Console . WriteLine ( cnt [ Q [ it , 1 ] - 1 ] - cnt [ Q [ it , 0 ] - 1 ] ) ; } } }

Index/key variables: i, max_len
Accumulator variables: i, it
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; class GFG { static int getXOR ( int [ ] BITree , int index ) { int ans = 0 ; index += 1 ; while ( index > 0 ) { ans ^= BITree [ index ] ; index -= index & ( - index ) ; } return ans ; } static void updateBIT ( int [ ] BITree , int n , int index , int val ) { index = index + 1 ; while ( index <= n ) { BITree [ index ] ^= val ; index += index & ( - index ) ; } } static int [ ] constructBITree ( int [ ] arr , int n ) { int [ ] BITree = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) BITree [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) updateBIT ( BITree , n , i , arr [ i ] ) ; return BITree ; } static int rangeXor ( int [ ] BITree , int l , int r ) { return getXOR ( BITree , r ) ^ getXOR ( BITree , l - 1 ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 2 , 1 , 1 , 3 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; int n = A . Length ; int [ , ] q = { { 1 , 0 , 9 } , { 2 , 3 , 6 } , { 2 , 5 , 5 } , { 2 , 8 , 1 } , { 1 , 0 , 9 } } ; int [ ] BITree = constructBITree ( A , n ) ; for ( int i = 0 ; i < q . GetLength ( 0 ) ; i ++ ) { int id = q [ i , 0 ] ; if ( id == 1 ) { int L = q [ i , 1 ] ; int R = q [ i , 2 ] ; Console . Write ( " XOR ▁ of ▁ elements ▁ " + " in ▁ given ▁ range ▁ is ▁ " + rangeXor ( BITree , L , R ) + " STRNEWLINE " ) ; } else { int idx = q [ i , 1 ] ; int val = q [ i , 2 ] ; A [ idx ] ^= val ; updateBIT ( BITree , n , idx , val ) ; } } } }

Index/key variables: i, idx, index
Accumulator variables: ans, i, index
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ ] arr = new int [ 1000001 ] ; static int [ ] dp = new int [ 1000001 ] ; static void count ( ) { int maxN = 1000000 , i , j ; for ( i = 0 ; i < maxN ; i ++ ) arr [ i ] = 1 ; arr [ 0 ] = 0 ; arr [ 1 ] = 0 ; for ( i = 2 ; i * i <= maxN ; i ++ ) { if ( arr [ i ] == 1 ) { for ( j = 2 * i ; j <= maxN ; j += i ) { arr [ j ] = 0 ; } } } int cnt = 0 ; for ( i = 0 ; i <= maxN ; i ++ ) { if ( arr [ i ] == 1 ) cnt ++ ; if ( arr [ cnt ] == 1 ) dp [ i ] = 1 ; else dp [ i ] = 0 ; } for ( i = 1 ; i <= maxN ; i ++ ) dp [ i ] += dp [ i - 1 ] ; } public static void Main ( ) { int L = 4 , R = 12 ; count ( ) ; Console . Write ( dp [ R ] - dp [ L - 1 ] ) ; } }

Index/key variables: R, cnt, i, j
Accumulator variables: cnt, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void findUngroupedElement ( String s , int k ) { int n = s . Length ; int [ ] b = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) b [ i ] = 0 ; for ( int i = 0 ; i < n ; i ++ ) { char p = s [ i ] ; b [ p - ' a ' ] += 1 ; } int sum = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( b [ i ] > k ) sum += b [ i ] - k ; } Console . WriteLine ( sum ) ; } public static void Main ( String [ ] srgs ) { String s = " stayinghomesaveslife " ; int k = 1 ; findUngroupedElement ( s , k ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findSolution ( int N ) { if ( N % 4 != 0 ) Console . Write ( - 1 + " STRNEWLINE " ) ; else { int temp = 0 , sum_odd = 0 ; int sum_even = 0 ; int [ ] result = new int [ N ] ; for ( int i = 0 ; i < N ; i += 2 ) { temp += 2 ; result [ i + 1 ] = temp ; sum_even += result [ i + 1 ] ; result [ i ] = temp - 1 ; sum_odd += result [ i ] ; } int diff = sum_even - sum_odd ; result [ N - 2 ] += diff ; for ( int i = 0 ; i < N ; i ++ ) Console . Write ( result [ i ] + " ▁ " ) ; Console . Write ( " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { int N = 8 ; findSolution ( N ) ; } }

Index/key variables: N, i
Accumulator variables: i, sum_even, sum_odd, temp
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static double possiblePositions ( double n ) { double term1 = Math . Pow ( n , 4 ) ; double term2 = Math . Pow ( n , 3 ) ; double term3 = Math . Pow ( n , 2 ) ; double term4 = n / 3 ; double ans = ( Math . Ceiling ( term1 / 2 ) ) - ( Math . Ceiling ( 5 * term2 ) / 3 ) + ( Math . Ceiling ( 3 * term3 ) / 2 ) - term4 ; return ( long ) ans ; } public static void Main ( String [ ] args ) { double n ; n = 3 ; double ans = possiblePositions ( n ) ; Console . Write ( ans + " STRNEWLINE " ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void mutually_coprime ( int n ) { if ( n <= 3 ) { for ( int j = 1 ; j < n + 1 ; j ++ ) Console . Write ( j + " ▁ " ) ; Console . WriteLine ( ) ; } else { Console . WriteLine ( "1 ▁ 2 ▁ 3" ) ; for ( int j = 4 ; j < n ; j += 2 ) { Console . WriteLine ( j + " ▁ " + ( j + 1 ) ) ; if ( n % 2 == 0 ) Console . WriteLine ( n ) ; } } } public static void Main ( String [ ] args ) { int n = 9 ; mutually_coprime ( n ) ; } }

Accumulator variables: j
Iterator variables: j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findMaxSum ( int [ ] arr , int n ) { List < int > a = new List < int > ( ) ; List < int > b = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 ) { a . Add ( arr [ i ] ) ; } else if ( arr [ i ] < 0 ) { b . Add ( arr [ i ] ) ; } } a . Sort ( ) ; b . Sort ( ) ; int p = a . Count - 1 ; int q = b . Count - 1 ; int s = 0 ; while ( p >= 0 && q >= 0 ) { if ( a [ p ] + b [ q ] > 0 ) { s = s + a [ p ] + b [ q ] ; } else { break ; } p = p - 1 ; q = q - 1 ; } return s ; } public static void Main ( String [ ] args ) { int [ ] arr1 = { 1 , - 2 , 3 , 4 , - 5 , 8 } ; int n1 = arr1 . Length ; Console . Write ( findMaxSum ( arr1 , n1 ) + " STRNEWLINE " ) ; } }

Index/key variables: i, p, q
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void SieveOfEratosthenes ( bool [ ] prime , int p_size ) { prime [ 0 ] = false ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= p_size ; p ++ ) { if ( prime [ p ] ) { for ( int i = p * 2 ; i <= p_size ; i += p ) prime [ i ] = false ; } } } static void PrimeDegreeNodes ( int [ ] prufer , int n ) { int nodes = n + 2 ; bool [ ] prime = new bool [ nodes + 1 ] ; for ( int i = 0 ; i < prime . Length ; i ++ ) prime [ i ] = true ; SieveOfEratosthenes ( prime , nodes + 1 ) ; int [ ] degree = new int [ n + 2 + 1 ] ; for ( int i = 1 ; i <= nodes ; i ++ ) degree [ i ] = 1 ; for ( int i = 0 ; i < n ; i ++ ) degree [ prufer [ i ] ] ++ ; for ( int i = 1 ; i <= nodes ; i ++ ) { if ( prime [ degree [ i ] ] ) { Console . Write ( i + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { int [ ] a = { 4 , 1 , 3 , 4 } ; int n = a . Length ; PrimeDegreeNodes ( a , n ) ; } }

Index/key variables: i, p
Accumulator variables: i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int n = 10005 ; static bool [ ] Prime = new bool [ n + 1 ] ; static void SieveOfEratosthenes ( ) { int i , j ; Prime [ 0 ] = Prime [ 1 ] = false ; for ( i = 2 ; i * i <= 10005 ; i ++ ) { if ( Prime [ i ] ) { for ( j = 2 * i ; j < 10005 ; j += i ) { Prime [ j ] = false ; } } } } static void primeDegreeNodes ( int N , int M , int [ , ] edges ) { List < int > [ ] Adj = new List < int > [ N + 1 ] ; for ( int i = 0 ; i < Adj . Length ; i ++ ) Adj [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < M ; i ++ ) { int x = edges [ i , 0 ] ; int y = edges [ i , 1 ] ; Adj [ x ] . Add ( y ) ; Adj [ y ] . Add ( x ) ; } SieveOfEratosthenes ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { int x = Adj [ i ] . Count ; if ( Prime [ x ] ) Console . Write ( i + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int N = 4 , M = 6 ; int [ , ] edges = { { 1 , 2 } , { 1 , 3 } , { 1 , 4 } , { 2 , 3 } , { 2 , 4 } , { 3 , 4 } } ; for ( int i = 0 ; i < Prime . Length ; i ++ ) Prime [ i ] = true ; primeDegreeNodes ( N , M , edges ) ; } }

Index/key variables: i, j, x, y
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int mod = 1000000007 ; static int countWays ( int [ ] colored , int count , int n ) { if ( count == n ) { return 1 ; } int answer = 0 ; for ( int i = 1 ; i < n + 1 ; i ++ ) { if ( colored [ i ] == 0 ) { if ( colored [ i - 1 ] == 1 colored [ i + 1 ] == 1 ) { colored [ i ] = 1 ; answer = ( answer + countWays ( colored , count + 1 , n ) ) % mod ; colored [ i ] = 0 ; } } } return answer ; } static int waysToColor ( int [ ] arr , int n , int k ) { int [ ] colored = new int [ n + 2 ] ; for ( int i = 0 ; i < k ; i ++ ) { colored [ arr [ i ] ] = 1 ; } return countWays ( colored , k , n ) ; } public static void Main ( ) { int N = 6 ; int K = 3 ; int [ ] arr = { 1 , 2 , 6 } ; Console . Write ( waysToColor ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static char ShortestPalindrome ( String s ) { int n = s . Length ; char ans = s [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { ans = ( char ) Math . Min ( ans , s [ i ] ) ; } return ans ; } public static void Main ( String [ ] args ) { String s = " geeksforgeeks " ; Console . Write ( ShortestPalindrome ( s ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void findSubsequence ( int [ ] arr , int n ) { int [ ] sign = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 ) sign [ i ] = 1 ; else sign [ i ] = - 1 ; } int k = 0 ; int [ ] result = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int cur = arr [ i ] ; int j = i ; while ( j < n && sign [ i ] == sign [ j ] ) { cur = Math . Max ( cur , arr [ j ] ) ; ++ j ; } result [ k ++ ] = cur ; i = j - 1 ; } for ( int i = 0 ; i < k ; i ++ ) Console . Write ( result [ i ] + " ▁ " ) ; Console . Write ( " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { - 4 , 9 , 4 , 11 , - 5 , - 17 , 9 , - 3 , - 5 , 2 } ; int n = arr . Length ; findSubsequence ( arr , n ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPalindrome ( String r ) { String p = r ; p = reverse ( p ) ; return ( r . Equals ( p ) ) ; } static String PrefixSuffixPalindrome ( String str ) { int n = str . Length , len = 0 ; for ( int i = 0 ; i < n / 2 ; i ++ ) { if ( str [ i ] != str [ n - i - 1 ] ) { len = i ; break ; } } String prefix = " " , suffix = " " ; String midPal = " " ; prefix = str . Substring ( 0 , len ) ; suffix = str . Substring ( n - len ) ; str = str . Substring ( len , ( n - 2 * len ) + len ) ; for ( int i = 1 ; i <= str . Length ; i ++ ) { String y = str . Substring ( 0 , i ) ; if ( isPalindrome ( y ) ) { if ( midPal . Length < y . Length ) { midPal = y ; } } } for ( int i = 1 ; i <= str . Length ; i ++ ) { String y = str . Substring ( str . Length - i ) ; if ( isPalindrome ( y ) ) { if ( midPal . Length < y . Length ) { midPal = y ; } } } String answer = prefix + midPal + suffix ; return answer ; } 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 str = " abcdfdcecba " ; Console . Write ( PrefixSuffixPalindrome ( str ) ) ; } }

Index/key variables: i, l, r
Accumulator variables: i, l, r
Iterator variables: i, l
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int minimumAdjacentDifference ( int [ ] a , int n , int k ) { int minDiff = int . MaxValue ; for ( int i = 0 ; i < ( 1 << n ) ; i ++ ) { int cnt = countSetBits ( i ) ; if ( cnt == n - k ) { List < int > temp = new List < int > ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( i & ( 1 << j ) ) != 0 ) temp . Add ( a [ j ] ) ; } int maxDiff = int . MinValue ; for ( int j = 0 ; j < temp . Count - 1 ; j ++ ) { maxDiff = Math . Max ( maxDiff , temp [ j + 1 ] - temp [ j ] ) ; } minDiff = Math . Min ( minDiff , maxDiff ) ; } } return minDiff ; } static int countSetBits ( int x ) { int setBits = 0 ; while ( x != 0 ) { x = x & ( x - 1 ) ; setBits ++ ; } return setBits ; } public static void Main ( String [ ] args ) { int n = 5 ; int k = 2 ; int [ ] a = { 3 , 7 , 8 , 10 , 14 } ; Console . WriteLine ( minimumAdjacentDifference ( a , n , k ) ) ; } }

Index/key variables: j
Accumulator variables: i, j, setBits
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimumAdjacentDifference ( int [ ] a , int n , int k ) { int minDiff = int . MaxValue ; for ( int i = 0 ; i <= k ; i ++ ) { int maxDiff = int . MinValue ; for ( int j = 0 ; j < n - k - 1 ; j ++ ) { for ( int p = i ; p <= i + j ; p ++ ) { maxDiff = Math . Max ( maxDiff , a [ p + 1 ] - a [ p ] ) ; } } minDiff = Math . Min ( minDiff , maxDiff ) ; } return minDiff ; } public static void Main ( string [ ] args ) { int n = 5 ; int k = 2 ; int [ ] a = { 3 , 7 , 8 , 10 , 14 } ; Console . WriteLine ( minimumAdjacentDifference ( a , n , k ) ) ; } }

Index/key variables: p
Accumulator variables: i, j, p
Iterator variables: i, j, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int gcdFunc ( int a , int b ) { if ( b == 0 ) return a ; return gcdFunc ( b , a % b ) ; } static int findMinimumElements ( int [ ] a , int n ) { int [ ] b = new int [ n - 1 ] ; for ( int i = 1 ; i < n ; i ++ ) { b [ i - 1 ] = a [ i ] - a [ i - 1 ] ; } int gcd = b [ 0 ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { gcd = gcdFunc ( gcd , b [ i ] ) ; } int ans = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { ans += ( b [ i ] / gcd ) - 1 ; } return ans ; } static public void Main ( ) { int [ ] arr1 = new int [ ] { 1 , 6 , 8 , 10 , 14 , 16 } ; int n1 = arr1 . Length ; Console . WriteLine ( findMinimumElements ( arr1 , n1 ) ) ; } }

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkPermutation ( int [ ] arr , int n ) { int 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 ++ ) { int lsum = prefix [ i ] ; int rsum = sum - prefix [ i ] ; int 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 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 5 , 3 , 4 , 1 , 2 } ; int n = arr . Length ; if ( checkPermutation ( arr , n ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findTheNumber ( int n ) { if ( n == 1 ) { Console . Write ( " Impossible " + " STRNEWLINE " ) ; return ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { Console . Write ( "5" ) ; } Console . Write ( "4" ) ; } public static void Main ( String [ ] args ) { int n = 12 ; findTheNumber ( n ) ; } }

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