dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { public static bool nonLower ( String s ) { for ( int i = 0 ; i < s . Length ; i ++ ) { if ( ! char . IsLower ( s [ i ] ) ) { return true ; } } return false ; } public static void printCodes ( String [ ] output ) { for ( int i = 0 ; i < output . Length ; i ++ ) { if ( nonLower ( output [ i ] ) ) continue ; Console . WriteLine ( output [ i ] ) ; } } public static char getChar ( int n ) { return ( char ) ( n + 96 ) ; } public static String [ ] getCode ( String str ) { if ( str . Length == 0 ) { String [ ] ans = { " " } ; return ans ; } String [ ] output1 = getCode ( str . Substring ( 1 ) ) ; String [ ] output2 = new String [ 0 ] ; int firstDigit = ( str [ 0 ] - '0' ) ; int firstTwoDigit = 0 ; if ( str . Length >= 2 ) { firstTwoDigit = ( str [ 0 ] - '0' ) * 10 + ( str [ 1 ] - '0' ) ; if ( firstTwoDigit >= 10 && firstTwoDigit <= 26 ) { output2 = getCode ( str . Substring ( 2 ) ) ; } } String [ ] output = new String [ output1 . Length + output2 . Length ] ; int k = 0 ; for ( int i = 0 ; i < output1 . Length ; i ++ ) { char ch = getChar ( firstDigit ) ; output [ i ] = ch + output1 [ i ] ; k ++ ; } for ( int i = 0 ; i < output2 . Length ; i ++ ) { char ch = getChar ( firstTwoDigit ) ; output [ k ] = ch + output2 [ i ] ; k ++ ; } return output ; } public static void Main ( String [ ] args ) { String input = "101" ; String [ ] output = getCode ( input ) ; printCodes ( output ) ; } }

Index/key variables: i, k
Accumulator variables: i, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int isprm ( int n ) { if ( n <= 1 ) return 0 ; if ( n <= 3 ) return 1 ; if ( n % 2 == 0 n % 3 == 0 ) return 0 ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) return 0 ; } return 1 ; } static int countprime ( int n ) { int count = 0 ; List < int > primevector = new List < int > ( ) ; for ( int i = 2 ; i <= n ; i ++ ) { if ( isprm ( i ) == 1 ) { primevector . Add ( i ) ; } } int sum = primevector [ 0 ] ; for ( int i = 1 ; i < primevector . Count ; i ++ ) { sum += primevector [ i ] ; if ( sum > n ) break ; if ( isprm ( sum ) == 1 ) { count ++ ; } } return count ; } public static void Main ( String [ ] args ) { int N = 45 ; Console . Write ( countprime ( N ) ) ; } }

Index/key variables: i
Accumulator variables: count, i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { class pair { public int first , second ; } static bool isPerfectSquare ( int n ) { double sr = Math . Sqrt ( n ) ; return ( ( sr - Math . Floor ( sr ) ) == 0 ) ; } static void SubarrayHavingPerfectSquare ( int [ ] arr , int k ) { pair ans = new pair ( ) ; int sum = 0 , i ; for ( i = 0 ; i < k ; i ++ ) { sum += arr [ i ] ; } bool found = false ; if ( isPerfectSquare ( sum ) ) { ans . first = 0 ; ans . second = i - 1 ; } else { for ( int j = i ; j < arr . Length ; j ++ ) { sum = sum + arr [ j ] - arr [ j - k ] ; if ( isPerfectSquare ( sum ) ) { found = true ; ans . first = j - k + 1 ; ans . second = j ; } } for ( int k1 = ans . first ; k1 <= ans . second ; k1 ++ ) { Console . Write ( arr [ k1 ] + " ▁ " ) ; } } if ( found == false ) { Console . Write ( " - 1" ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 20 , 34 , 51 , 10 , 99 , 87 , 23 , 45 } ; int K = 3 ; SubarrayHavingPerfectSquare ( arr , K ) ; } }

Index/key variables: i, j, k1
Accumulator variables: i, j, k1, sum
Iterator variables: i, j, k1
Boolean variables: found
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static int TEN = 10 ; static void updateFreq ( int n , int [ ] freq ) { while ( n > 0 ) { int digit = n % TEN ; freq [ digit ] ++ ; n /= TEN ; } } static bool areAnagrams ( int a , int b ) { int [ ] freqA = new int [ TEN ] ; int [ ] freqB = new int [ TEN ] ; updateFreq ( a , freqA ) ; updateFreq ( b , freqB ) ; for ( int i = 0 ; i < TEN ; i ++ ) { if ( freqA [ i ] != freqB [ i ] ) return false ; } return true ; } static bool isPowerOf2 ( int N ) { for ( int i = 0 ; i < 32 ; i ++ ) { if ( areAnagrams ( 1 << i , N ) ) { Console . Write ( ( 1 << i ) ) ; return true ; } } return false ; } public static void Main ( String [ ] args ) { int N = 46 ; if ( ! isPowerOf2 ( N ) ) { Console . Write ( " No " ) ; } } }

Index/key variables: TEN, digit, i
Accumulator variables: i, n
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int right_angled ( int n ) { int count = 0 ; for ( int z = 1 ; z <= n ; z ++ ) { for ( int y = 1 ; y <= z ; y ++ ) { for ( int x = 1 ; x <= y ; x ++ ) { if ( ( x * x ) + ( y * y ) == ( z * z ) ) { count ++ ; } } } } return count ; } public static void Main ( string [ ] args ) { int n = 5 ; Console . Write ( right_angled ( n ) ) ; } }

Accumulator variables: count, x, y, z
Iterator variables: x, y, z
Class/struct names: GFG
C# program:
using System ; class GFG { static void mirrorMatrix ( int [ , ] mat1 , int [ , ] mat2 , int N ) { int row = 0 ; int col = 0 ; bool isMirrorImage = true ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = N - 1 ; j >= 0 ; j -- ) { if ( mat2 [ row , col ] != mat1 [ i , j ] ) { isMirrorImage = false ; } col ++ ; } col = 0 ; row ++ ; } if ( isMirrorImage ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( String [ ] args ) { int N = 4 ; int [ , ] mat1 = { { 1 , 2 , 3 , 4 } , { 0 , 6 , 7 , 8 } , { 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 } } ; int [ , ] mat2 = { { 4 , 3 , 2 , 1 } , { 8 , 7 , 6 , 0 } , { 12 , 11 , 10 , 9 } , { 16 , 15 , 14 , 13 } } ; mirrorMatrix ( mat1 , mat2 , N ) ; } }

Accumulator variables: col, i, j, row
Iterator variables: i, j
Boolean variables: isMirrorImage
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int dfs ( int src , int dest , int [ ] vis , List < int > [ ] adj ) { vis [ src ] = 1 ; if ( src == dest ) { return 1 ; } foreach ( int u in adj [ src ] ) { if ( vis [ u ] == 0 ) { int temp = dfs ( u , dest , vis , adj ) ; if ( temp != 0 ) { return temp + 1 ; } } } return 0 ; } static int countNodes ( int V , int E , int src , int dest , int [ , ] edges ) { List < int > [ ] adj = new List < int > [ V + 1 ] ; for ( int i = 0 ; i < adj . Length ; i ++ ) adj [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < E ; i ++ ) { adj [ edges [ i , 0 ] ] . Add ( edges [ i , 1 ] ) ; adj [ edges [ i , 1 ] ] . Add ( edges [ i , 0 ] ) ; } int [ ] vis = new int [ V + 1 ] ; int count = dfs ( src , dest , vis , adj ) ; return count - 2 ; } public static void Main ( String [ ] args ) { int V = 8 , E = 7 ; int src = 5 , dest = 2 ; int [ , ] edges = { { 1 , 4 } , { 4 , 5 } , { 4 , 2 } , { 2 , 6 } , { 6 , 3 } , { 2 , 7 } , { 3 , 8 } } ; Console . Write ( countNodes ( V , E , src , dest , edges ) ) ; } }

Index/key variables: i, src, u
Accumulator variables: i
Iterator variables: i, u
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static long GCD ( long a , long b ) { if ( a == 0 ) return b ; return GCD ( b % a , a ) ; } static long LCM ( long a , long b ) { return ( a * b ) / GCD ( a , b ) ; } static void checkPairwiseCoPrime ( int [ ] A , int n ) { long prod = 1 ; long lcm = 1 ; for ( int i = 0 ; i < n ; i ++ ) { prod *= A [ i ] ; lcm = LCM ( A [ i ] , lcm ) ; } if ( prod == lcm ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 2 , 3 , 5 } ; int n = A . Length ; checkPairwiseCoPrime ( A , n ) ; } }

Index/key variables: i
Accumulator variables: i, prod
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int maxDiffSubsets ( int [ ] arr ) { int totalSum = 0 ; bool pos = false , neg = false ; int min = int . MaxValue ; for ( int i = 0 ; i < arr . Length ; i ++ ) { totalSum += Math . Abs ( arr [ i ] ) ; if ( arr [ i ] > 0 ) pos = true ; if ( arr [ i ] < 0 ) neg = true ; if ( arr [ i ] < min ) min = arr [ i ] ; } if ( pos && neg ) return totalSum ; else return totalSum - 2 * min ; } public static void Main ( String [ ] args ) { int [ ] S = { 1 , 2 , 1 } ; int N = S . Length ; if ( N < 2 ) Console . WriteLine ( " Not ▁ Possible " ) ; else Console . WriteLine ( maxDiffSubsets ( S ) ) ; } }

Index/key variables: i
Accumulator variables: i, totalSum
Iterator variables: i
Boolean variables: neg, pos
Class/struct names: GFG
C# program:
using System ; class GFG { static int minDiffSubArray ( int [ ] arr , int n ) { int [ ] prefix_sum = new int [ n ] ; prefix_sum [ 0 ] = arr [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) prefix_sum [ i ] = prefix_sum [ i - 1 ] + arr [ i ] ; int [ ] suffix_sum = new int [ n ] ; suffix_sum [ n - 1 ] = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) suffix_sum [ i ] = suffix_sum [ i + 1 ] + arr [ i ] ; int minDiff = int . MaxValue ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int diff = Math . Abs ( prefix_sum [ i ] - suffix_sum [ i + 1 ] ) ; if ( diff < minDiff ) minDiff = diff ; } return minDiff ; } public static void Main ( String [ ] args ) { int [ ] arr = { 7 , 9 , 5 , 10 } ; int n = arr . Length ; Console . WriteLine ( minDiffSubArray ( arr , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void dailyTemperatures ( int [ ] T ) { int n = T . Length ; int [ ] daysOfWait = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) daysOfWait [ i ] = - 1 ; Stack < int > s = new Stack < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { while ( s . Count != 0 && T [ s . Peek ( ) ] < T [ i ] ) { daysOfWait [ s . Peek ( ) ] = i - s . Peek ( ) ; s . Pop ( ) ; } s . Push ( i ) ; } for ( int i = 0 ; i < n ; i ++ ) { Console . Write ( daysOfWait [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 73 , 74 , 75 , 71 , 69 , 72 , 76 , 73 } ; dailyTemperatures ( arr ) ; } }

Index/key variables: i, n
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int timeT = 0 ; static void dfs ( int u , int p , int dis , int [ ] vis , int [ ] distance , int [ ] parent , int [ ] preTime , int [ ] postTime , List < List < int > > Adj ) { distance [ u ] = dis ; parent [ u ] = p ; vis [ u ] = 1 ; timeT ++ ; preTime [ u ] = timeT ; for ( int i = 0 ; i < Adj [ u ] . Count ; i ++ ) { if ( vis [ Adj [ u ] [ i ] ] == 0 ) { dfs ( Adj [ u ] [ i ] , u , dis + 1 , vis , distance , parent , preTime , postTime , Adj ) ; } } timeT ++ ; postTime [ u ] = timeT ; } static void addEdge ( List < List < int > > Adj , int u , int v ) { Adj [ u ] . Add ( v ) ; Adj [ v ] . Add ( u ) ; } static void findNodeU ( int N , int V , int [ ] Vertices , int [ , ] Edges ) { int [ ] vis = new int [ N + 1 ] ; int [ ] distance = new int [ N + 1 ] ; int [ ] parent = new int [ N + 1 ] ; int [ ] preTime = new int [ N + 1 ] ; int [ ] postTime = new int [ N + 1 ] ; List < List < int > > Adj = new List < List < int > > ( ) ; for ( int i = 0 ; i < N + 1 ; i ++ ) Adj . Add ( new List < int > ( ) ) ; int u = 0 , v ; for ( int i = 0 ; i < N - 1 ; i ++ ) { addEdge ( Adj , Edges [ i , 0 ] , Edges [ i , 1 ] ) ; } dfs ( 1 , 0 , 0 , vis , distance , parent , preTime , postTime , Adj ) ; int maximumDistance = 0 ; maximumDistance = 0 ; for ( int k = 0 ; k < V ; k ++ ) { if ( maximumDistance < distance [ Vertices [ k ] ] ) { maximumDistance = distance [ Vertices [ k ] ] ; u = Vertices [ k ] ; } if ( parent [ Vertices [ k ] ] != 0 ) { Vertices [ k ] = parent [ Vertices [ k ] ] ; } } bool ans = true ; bool flag ; for ( int k = 0 ; k < V ; k ++ ) { if ( preTime [ Vertices [ k ] ] <= preTime [ u ] && postTime [ Vertices [ k ] ] >= postTime [ u ] ) flag = true ; else flag = false ; ans = ans & flag ; } if ( ans ) Console . WriteLine ( u ) ; else Console . WriteLine ( " NO " ) ; } public static void Main ( String [ ] args ) { int N = 10 ; int V = 5 ; int [ ] Vertices = { 4 , 3 , 8 , 9 , 10 } ; int [ , ] Edges = { { 1 , 2 } , { 1 , 3 } , { 1 , 4 } , { 2 , 5 } , { 2 , 6 } , { 3 , 7 } , { 7 , 8 } , { 7 , 9 } , { 9 , 10 } } ; findNodeU ( N , V , Vertices , Edges ) ; } }

Index/key variables: i, k, u, v
Accumulator variables: i, k, timeT
Iterator variables: i, k
Boolean variables: ans, flag
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void uniqueElement ( int [ ] arr ) { HashSet < int > set = new HashSet < int > ( ) ; for ( int i = 0 ; i < arr . Length ; i ++ ) { set . Add ( arr [ i ] ) ; } if ( set . Count == 1 ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 9 , 9 , 9 , 9 , 9 , 9 , 9 } ; uniqueElement ( arr ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int ans = 0 , allsum = 0 ; static List < int > [ ] edges = new List < int > [ 100001 ] ; static void addedge ( int a , int b ) { edges [ a ] . Add ( b ) ; edges [ b ] . Add ( a ) ; } static void findCost ( int r , int p , int [ ] arr ) { int i , cur ; for ( i = 0 ; i < edges [ r ] . Count ; i ++ ) { cur = edges [ r ] [ i ] ; if ( cur == p ) continue ; findCost ( cur , r , arr ) ; arr [ r ] += arr [ cur ] ; } int t1 = arr [ r ] ; int t2 = allsum - t1 ; if ( t1 * t2 > ans ) { ans = t1 * t2 ; } } static void maximumCost ( int r , int p , int N , int M , int [ ] arr , int [ , ] Edges ) { for ( int i = 0 ; i < N ; i ++ ) { allsum += arr [ i ] ; } for ( int i = 0 ; i < M ; i ++ ) { addedge ( Edges [ i , 0 ] , Edges [ i , 1 ] ) ; } findCost ( r , p , arr ) ; } public static void Main ( String [ ] args ) { int N = 6 ; int [ ] arr = { 13 , 8 , 7 , 4 , 5 , 9 } ; int M = 5 ; int [ , ] Edges = { { 0 , 1 } , { 1 , 2 } , { 1 , 4 } , { 3 , 4 } , { 4 , 5 } } ; for ( int i = 0 ; i < edges . Length ; i ++ ) edges [ i ] = new List < int > ( ) ; maximumCost ( 1 , - 1 , N , M , arr , Edges ) ; Console . Write ( ans ) ; } }

Index/key variables: a, b, cur, i, r
Accumulator variables: allsum, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int X = 1 ; static int diameter = 0 ; static Dictionary < int , Boolean > mp = new Dictionary < int , Boolean > ( ) ; static void dfs ( int current_node , int prev_node , int len , bool add_to_map , List < int > [ ] adj ) { if ( len > diameter ) { diameter = len ; X = current_node ; } if ( add_to_map && len == diameter ) { mp . Add ( current_node , true ) ; } foreach ( int it in adj [ current_node ] ) { if ( it != prev_node ) dfs ( it , current_node , len + 1 , add_to_map , adj ) ; } } static void dfsUtility ( List < int > [ ] adj ) { dfs ( 1 , - 1 , 0 , false , adj ) ; int farthest_node = X ; dfs ( farthest_node , - 1 , 0 , false , adj ) ; dfs ( farthest_node , - 1 , 0 , true , adj ) ; dfs ( X , - 1 , 0 , true , adj ) ; } static void printDiameters ( List < int > [ ] adj ) { dfsUtility ( adj ) ; for ( int i = 1 ; i <= 6 ; i ++ ) { if ( mp . ContainsKey ( i ) && mp [ i ] == true ) Console . Write ( diameter + 1 + " , ▁ " ) ; else Console . Write ( diameter + " , ▁ " ) ; } } public static void Main ( String [ ] args ) { List < int > [ ] adj = new List < int > [ 7 ] ; for ( int i = 0 ; i < adj . Length ; i ++ ) adj [ i ] = new List < int > ( ) ; adj [ 1 ] . Add ( 2 ) ; adj [ 2 ] . Add ( 1 ) ; adj [ 1 ] . Add ( 3 ) ; adj [ 3 ] . Add ( 1 ) ; adj [ 2 ] . Add ( 4 ) ; adj [ 4 ] . Add ( 2 ) ; adj [ 2 ] . Add ( 5 ) ; adj [ 5 ] . Add ( 2 ) ; adj [ 2 ] . Add ( 6 ) ; adj [ 6 ] . Add ( 2 ) ; printDiameters ( adj ) ; } }

Index/key variables: current_node, i
Accumulator variables: i
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int minimumReplacement ( int [ ] arr , int N , int K ) { int ans = int . MaxValue ; ArrayList max_values = new ArrayList ( ) ; ArrayList min_values = new ArrayList ( ) ; Dictionary < int , int > sum_equal_to_x = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < N / 2 ; i ++ ) { int mn = Math . Min ( arr [ i ] , arr [ N - i - 1 ] ) ; int mx = Math . Max ( arr [ i ] , arr [ N - i - 1 ] ) ; sum_equal_to_x [ arr [ i ] + arr [ N - i - 1 ] ] = sum_equal_to_x . GetValueOrDefault ( arr [ i ] + arr [ N - i - 1 ] , 0 ) + 1 ; min_values . Add ( mn ) ; max_values . Add ( mx ) ; } max_values . Sort ( ) ; min_values . Sort ( ) ; for ( int x = 2 ; x <= 2 * K ; x ++ ) { int mp1 = max_values . IndexOf ( x - K ) ; int mp2 = min_values . IndexOf ( x ) ; int rep2 = mp1 + ( N / 2 - mp2 ) ; int rep0 = sum_equal_to_x . GetValueOrDefault ( x , - 1 ) ; int rep1 = ( N / 2 - rep2 - rep0 ) ; ans = Math . Min ( ans , rep2 * 2 + rep1 ) ; } return ans ; } public static void Main ( string [ ] args ) { int N = 4 ; int K = 3 ; int [ ] arr = { 1 , 2 , 2 , 1 } ; Console . Write ( minimumReplacement ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: i, x
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static Dictionary < int , Boolean > mp = new Dictionary < int , Boolean > ( ) ; class Node { public int key ; public Node left , right ; } ; static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = temp . right = null ; return ( temp ) ; } static bool deleteNode ( int nodeVal ) { return mp . ContainsKey ( nodeVal ) ; } static Node treePruning ( Node root , List < Node > result ) { if ( root == null ) return null ; root . left = treePruning ( root . left , result ) ; root . right = treePruning ( root . right , result ) ; if ( deleteNode ( root . key ) ) { if ( root . left != null ) { result . Add ( root . left ) ; } if ( root . right != null ) { result . Add ( root . right ) ; } return null ; } return root ; } static void printInorderTree ( Node root ) { if ( root == null ) return ; printInorderTree ( root . left ) ; Console . Write ( root . key + " ▁ " ) ; printInorderTree ( root . right ) ; } static void printForests ( Node root , int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { mp . Add ( arr [ i ] , true ) ; } List < Node > result = new List < Node > ( ) ; if ( treePruning ( root , result ) != null ) result . Add ( root ) ; for ( int i = 0 ; i < result . Count ; i ++ ) { printInorderTree ( result [ i ] ) ; Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 12 ) ; root . right = newNode ( 13 ) ; root . right . left = newNode ( 14 ) ; root . right . right = newNode ( 15 ) ; root . right . left . left = newNode ( 21 ) ; root . right . left . right = newNode ( 22 ) ; root . right . right . left = newNode ( 23 ) ; root . right . right . right = newNode ( 24 ) ; int [ ] arr = { 14 , 23 , 1 } ; int n = arr . Length ; printForests ( root , arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int knapSack ( int [ ] nums , int S ) { int sum = 0 ; foreach ( int i in nums ) sum += i ; if ( sum < S || - sum > - S || ( S + sum ) % 2 == 1 ) return 0 ; int [ ] dp = new int [ ( S + sum ) / 2 + 1 ] ; dp [ 0 ] = 1 ; foreach ( int num in nums ) { for ( int i = dp . Length - 1 ; i >= num ; i -- ) { dp [ i ] += dp [ i - num ] ; } } return dp [ dp . Length - 1 ] ; } public static void Main ( String [ ] args ) { int S = 3 ; int [ ] arr = new int [ ] { 1 , 2 , 3 , 4 , 5 } ; int answer = knapSack ( arr , S ) ; Console . WriteLine ( answer ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i, num
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxDistance ( int [ ] arr , int K ) { Dictionary < int , int > map = new Dictionary < int , int > ( ) ; int maxDist = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( ! map . ContainsKey ( arr [ i ] ) ) map . Add ( arr [ i ] , i ) ; if ( map . ContainsKey ( arr [ i ] + K ) ) { maxDist = Math . Max ( maxDist , i - map [ arr [ i ] + K ] ) ; } if ( map . ContainsKey ( arr [ i ] - K ) ) { maxDist = Math . Max ( maxDist , i - map [ arr [ i ] - K ] ) ; } } if ( maxDist == 0 ) return - 1 ; else return maxDist ; } public static void Main ( String [ ] args ) { int [ ] arr = { 11 , 2 , 3 , 8 , 5 , 2 } ; int K = 2 ; Console . WriteLine ( maxDistance ( arr , K ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int no_of_subString ( String s , int N ) { int [ ] fre = new int [ 26 ] ; int str_len ; str_len = ( int ) s . Length ; int count = 0 ; for ( int i = 0 ; i < str_len ; i ++ ) { fre = new int [ 26 ] ; int max_index = 0 ; int dist = 0 ; for ( int j = i ; j < str_len ; j ++ ) { int x = s [ j ] - ' a ' ; if ( fre [ x ] == 0 ) dist ++ ; fre [ x ] ++ ; max_index = Math . Max ( max_index , fre [ x ] ) ; if ( dist >= N && ( ( max_index * dist ) == ( j - i + 1 ) ) ) count ++ ; } } return count ; } public static void Main ( String [ ] args ) { String s = " abhay " ; int N = 3 ; Console . Write ( no_of_subString ( s , N ) ) ; } }

Index/key variables: j, x
Accumulator variables: count, dist, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void solve ( int n ) { int ans = 0 ; for ( int y = n + 1 ; y <= n * n + n ; y ++ ) { if ( ( n * n ) % ( y - n ) == 0 ) { ans += 1 ; } } Console . Write ( ans ) ; } public static void Main ( String [ ] args ) { int n = 5 ; solve ( n ) ; } }

Accumulator variables: ans, y
Iterator variables: y
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > [ ] adj = new List < int > [ 100005 ] ; static int [ ] visited = new int [ 100005 ] ; static int ans = 0 ; static void dfs ( int node , int count , int m , int [ ] arr , int k ) { visited [ node ] = 1 ; if ( arr [ node - 1 ] == k ) { count ++ ; } else { count = 0 ; } if ( count > m ) { return ; } if ( adj [ node ] . Count == 1 && node != 1 ) { ans ++ ; } foreach ( int x in adj [ node ] ) { if ( visited [ x ] == 0 ) { dfs ( x , count , m , arr , k ) ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 3 , 2 , 1 , 2 , 1 } ; int K = 2 , M = 2 ; for ( int i = 0 ; i < adj . Length ; i ++ ) adj [ i ] = new List < int > ( ) ; adj [ 1 ] . Add ( 2 ) ; adj [ 2 ] . Add ( 1 ) ; adj [ 1 ] . Add ( 3 ) ; adj [ 3 ] . Add ( 1 ) ; adj [ 2 ] . Add ( 4 ) ; adj [ 4 ] . Add ( 2 ) ; adj [ 2 ] . Add ( 5 ) ; adj [ 5 ] . Add ( 2 ) ; adj [ 3 ] . Add ( 6 ) ; adj [ 6 ] . Add ( 3 ) ; adj [ 3 ] . Add ( 7 ) ; adj [ 7 ] . Add ( 3 ) ; int counter = 0 ; dfs ( 1 , counter , M , arr , K ) ; Console . Write ( ans + " STRNEWLINE " ) ; } }

Index/key variables: i, node, x
Accumulator variables: ans, count, i
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { public static long reverse ( long num ) { long rev = 0 ; while ( num > 0 ) { int r = ( int ) ( num % 10 ) ; rev = rev * 10 + r ; num /= 10 ; } return rev ; } public static long count ( int N , int A , int B ) { long l = ( long ) Math . Pow ( 10 , N - 1 ) , r = ( long ) Math . Pow ( 10 , N ) - 1 ; if ( l == 1 ) l = 0 ; long ans = 0 ; for ( long i = l ; i <= r ; i ++ ) { int even_sum = 0 , odd_sum = 0 ; long itr = 0 , num = reverse ( i ) ; while ( num > 0 ) { if ( itr % 2 == 0 ) odd_sum += ( int ) num % 10 ; else even_sum += ( int ) num % 10 ; num /= 10 ; itr ++ ; } if ( even_sum % A == 0 && odd_sum % B == 0 ) ans ++ ; } return ans ; } public static void Main ( String [ ] args ) { int N = 2 , A = 5 , B = 3 ; Console . WriteLine ( count ( N , A , B ) ) ; } }

Accumulator variables: ans, even_sum, i, itr, num, odd_sum
Iterator variables: i
Class/struct names: GFG