dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { public static int checkValidity ( int a , int b , int c ) { if ( a + b <= c a + c <= b b + c <= a ) return 0 ; else return 1 ; } public static void Main ( ) { int a = 7 , b = 10 , c = 5 ; if ( ( checkValidity ( a , b , c ) ) == 1 ) Console . Write ( " Valid " ) ; else Console . Write ( " Invalid " ) ; } }

Class/struct names: GFG
C# program:
using System ; public class GFG { static String lcs ( String a , String b ) { int m = a . Length ; int n = b . Length ; char [ ] X = a . ToCharArray ( ) ; char [ ] Y = b . ToCharArray ( ) ; int [ , ] L = new int [ m + 1 , n + 1 ] ; int i , j ; for ( i = 0 ; i <= m ; i ++ ) { for ( j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) { L [ i , j ] = 0 ; } else if ( X [ i - 1 ] == Y [ j - 1 ] ) { L [ i , j ] = L [ i - 1 , j - 1 ] + 1 ; } else { L [ i , j ] = Math . Max ( L [ i - 1 , j ] , L [ i , j - 1 ] ) ; } } } int index = L [ m , n ] ; char [ ] lcs = new char [ index + 1 ] ; i = m ; j = n ; while ( i > 0 && j > 0 ) { if ( X [ i - 1 ] == Y [ j - 1 ] ) { lcs [ index - 1 ] = X [ i - 1 ] ; i -- ; j -- ; index -- ; else if ( L [ i - 1 , j ] > L [ i , j - 1 ] ) { i -- ; } else { j -- ; } } String ans = " " ; for ( int x = 0 ; x < lcs . Length ; x ++ ) { ans += lcs [ x ] ; } return ans ; } static String longestPalSubseq ( String str ) { String rev = str ; rev = reverse ( rev ) ; return lcs ( str , rev ) ; } static String reverse ( String str ) { String ans = " " ; char [ ] try1 = str . ToCharArray ( ) ; for ( int i = try1 . Length - 1 ; i >= 0 ; i -- ) { ans += try1 [ i ] ; } return ans ; } public static void Main ( ) { String str = " GEEKSFORGEEKS " ; Console . Write ( longestPalSubseq ( str ) ) ; } }

Index/key variables: i, x
Accumulator variables: ans, i, index, j, x
Iterator variables: i, j, x
Class/struct names: GFG
C# program:
using System ; class GFG { static int M = 3 ; static int N = 3 ; static int contribution_height ( int current , int previous ) { return Math . Abs ( current - previous ) ; } static int surfaceArea ( int [ , ] A ) { int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { int up = 0 ; int left = 0 ; if ( i > 0 ) up = A [ i - 1 , j ] ; if ( j > 0 ) left = A [ i , j - 1 ] ; ans += contribution_height ( A [ i , j ] , up ) + contribution_height ( A [ i , j ] , left ) ; if ( i == N - 1 ) ans += A [ i , j ] ; if ( j == M - 1 ) ans += A [ i , j ] ; } } ans += N * M * 2 ; return ans ; } public static void Main ( ) { int [ , ] A = { { 1 , 3 , 4 } , { 2 , 2 , 3 } , { 1 , 2 , 4 } } ; Console . WriteLine ( surfaceArea ( A ) ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static float area_equi_triangle ( float side ) { return ( float ) ( ( ( Math . Sqrt ( 3 ) ) / 4 ) * side * side ) ; } static float peri_equi_triangle ( float side ) { return 3 * side ; } public static void Main ( ) { float side = 4 ; Console . Write ( " Area ▁ of ▁ Equilateral ▁ Triangle : " ) ; Console . WriteLine ( area_equi_triangle ( side ) ) ; Console . Write ( " Perimeter ▁ of ▁ Equilateral ▁ Triangle : " ) ; Console . WriteLine ( peri_equi_triangle ( side ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static double areaCuboid ( double l , double h , double w ) { return ( l * h * w ) ; } static double surfaceAreaCuboid ( double l , double h , double w ) { return ( 2 * l * w + 2 * w * h + 2 * l * h ) ; } public static void Main ( ) { double l = 1 ; double h = 5 ; double w = 7 ; Console . WriteLine ( " Area ▁ = ▁ " + areaCuboid ( l , h , w ) ) ; Console . WriteLine ( " Total ▁ Surface ▁ Area ▁ = ▁ " + surfaceAreaCuboid ( l , h , w ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void cool_line ( int x1 , int y1 , int x2 , int y2 , int x3 , int y3 ) { if ( ( y3 - y2 ) * ( x2 - x1 ) == ( y2 - y1 ) * ( x3 - x2 ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } static public void Main ( ) { int a1 = 1 , a2 = 1 , a3 = 0 , b1 = 1 , b2 = 6 , b3 = 9 ; cool_line ( a1 , b1 , a2 , b2 , a3 , b3 ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { public static long rectCount ( int n , int m ) { return ( m * n * ( n + 1 ) * ( m + 1 ) ) / 4 ; } public static void Main ( ) { int n = 5 , m = 4 ; Console . WriteLine ( rectCount ( n , m ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int countRect ( int n ) { int ans = 0 ; for ( int length = 1 ; length <= Math . Sqrt ( n ) ; ++ length ) for ( int height = length ; height * length <= n ; ++ height ) ans ++ ; return ans ; } public static void Main ( ) { int n = 5 ; Console . Write ( countRect ( n ) ) ; } }

Accumulator variables: ans
Iterator variables: height, length
Class/struct names: GFG
C# program:
using System ; class GFG { static public void Main ( ) { int ax = 5 , ay = 0 ; int bx = 1 , by = 1 ; int cx = 2 , cy = 5 ; Console . WriteLine ( ax + ( cx - bx ) + " , ▁ " + ay + ( cy - by ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void bestApproximate ( int [ ] x , int [ ] y ) { int n = x . Length ; double m , c , sum_x = 0 , sum_y = 0 , sum_xy = 0 , sum_x2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum_x += x [ i ] ; sum_y += y [ i ] ; sum_xy += x [ i ] * y [ i ] ; sum_x2 += Math . Pow ( x [ i ] , 2 ) ; } m = ( n * sum_xy - sum_x * sum_y ) / ( n * sum_x2 - Math . Pow ( sum_x , 2 ) ) ; c = ( sum_y - m * sum_x ) / n ; Console . WriteLine ( " m ▁ = ▁ " + m ) ; Console . WriteLine ( " c ▁ = ▁ " + c ) ; } public static void Main ( ) { int [ ] x = { 1 , 2 , 3 , 4 , 5 } ; int [ ] y = { 14 , 27 , 40 , 55 , 68 } ; bestApproximate ( x , y ) ; } }

Index/key variables: i
Accumulator variables: i, sum_x, sum_x2, sum_xy, sum_y
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int size = 4 ; static bool checkStar ( int [ , ] mat ) { int vertexD1 = 0 , vertexDn_1 = 0 ; if ( size == 1 ) return ( mat [ 0 , 0 ] == 0 ) ; if ( size == 2 ) return ( mat [ 0 , 0 ] == 0 && mat [ 0 , 1 ] == 1 && mat [ 1 , 0 ] == 1 && mat [ 1 , 1 ] == 0 ) ; for ( int i = 0 ; i < size ; i ++ ) { int degreeI = 0 ; for ( int j = 0 ; j < size ; j ++ ) if ( mat [ i , j ] == 1 ) degreeI ++ ; if ( degreeI == 1 ) vertexD1 ++ ; else if ( degreeI == size - 1 ) vertexDn_1 ++ ; } return ( vertexD1 == ( size - 1 ) && vertexDn_1 == 1 ) ; } static void Main ( ) { int [ , ] mat = new int [ 4 , 4 ] { { 0 , 1 , 1 , 1 } , { 1 , 0 , 0 , 0 } , { 1 , 0 , 0 , 0 } , { 1 , 0 , 0 , 0 } } ; if ( checkStar ( mat ) ) Console . Write ( " Star ▁ Graph " ) ; else Console . Write ( " Not ▁ a ▁ Star ▁ Graph " ) ; } }

Accumulator variables: degreeI, i, j, vertexD1, vertexDn_1
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int orientation ( List < int > a , List < int > b , List < int > c ) { int res = ( b [ 1 ] - a [ 1 ] ) * ( c [ 0 ] - b [ 0 ] ) - ( c [ 1 ] - b [ 1 ] ) * ( b [ 0 ] - a [ 0 ] ) ; if ( res == 0 ) return 0 ; if ( res > 0 ) return 1 ; return - 1 ; } static int sqDist ( List < int > p1 , List < int > p2 ) { return ( p1 [ 0 ] - p2 [ 0 ] ) * ( p1 [ 0 ] - p2 [ 0 ] ) + ( p1 [ 1 ] - p2 [ 1 ] ) * ( p1 [ 1 ] - p2 [ 1 ] ) ; } static bool inside ( List < List < int > > A , List < int > p ) { List < int > mid = new List < int > ( ) { 0 , 0 } ; int n = A . Count ; for ( int i = 0 ; i < n ; i ++ ) { mid [ 0 ] += A [ i ] [ 0 ] ; mid [ 1 ] += A [ i ] [ 1 ] ; } for ( int i = 0 , j ; i < n ; i ++ ) { j = ( i + 1 ) % n ; int x1 = A [ i ] [ 0 ] * n , x2 = A [ j ] [ 0 ] * n ; int y1 = A [ i ] [ 1 ] * n , y2 = A [ j ] [ 1 ] * n ; int a1 = y1 - y2 ; int b1 = x2 - x1 ; int c1 = x1 * y2 - y1 * x2 ; int for_mid = a1 * mid [ 0 ] + b1 * mid [ 1 ] + c1 ; int for_p = a1 * p [ 0 ] * n + b1 * p [ 1 ] * n + c1 ; if ( for_mid * for_p < 0 ) return false ; } return true ; } static void addPoint ( List < List < int > > a , List < int > p ) { if ( inside ( a , p ) ) return ; int ind = 0 ; int n = a . Count ; for ( int i = 1 ; i < n ; i ++ ) { if ( sqDist ( p , a [ i ] ) < sqDist ( p , a [ ind ] ) ) { ind = i ; } } int up = ind ; while ( orientation ( p , a [ up ] , a [ ( up + 1 ) % n ] ) >= 0 ) up = ( up + 1 ) % n ; int low = ind ; while ( orientation ( p , a [ low ] , a [ ( n + low - 1 ) % n ] ) <= 0 ) low = ( n + low - 1 ) % n ; List < List < int > > ret = new List < List < int > > ( ) ; int curr = up ; ret . Add ( a [ curr ] ) ; while ( curr != low ) { curr = ( curr + 1 ) % n ; ret . Add ( a [ curr ] ) ; } ret . Add ( p ) ; a . Clear ( ) ; for ( int i = 0 ; i < ret . Count ; i ++ ) { a . Add ( ret [ i ] ) ; } } static public void Main ( ) { List < List < int > > a = new List < List < int > > ( ) ; a . Add ( new List < int > ( ) { 0 , 0 } ) ; a . Add ( new List < int > ( ) { 3 , - 1 } ) ; a . Add ( new List < int > ( ) { 4 , 5 } ) ; a . Add ( new List < int > ( ) { - 1 , 4 } ) ; int n = a . Count ; List < int > p = new List < int > ( ) { 100 , 100 } ; addPoint ( a , p ) ; foreach ( List < int > e in a ) { Console . Write ( " ( " + e [ 0 ] + " , ▁ " + e [ 1 ] + " ) ▁ " ) ; } } }

Index/key variables: curr, i, ind, j, low, up
Accumulator variables: i
Iterator variables: e, i
Class/struct names: GFG
C# program:
using System ; class GFG { class Point { public int x , y ; public Point ( int x , int y ) { this . x = x ; this . y = y ; } } static int lengthSquare ( Point p1 , Point p2 ) { int xDiff = p1 . x - p2 . x ; int yDiff = p1 . y - p2 . y ; return xDiff * xDiff + yDiff * yDiff ; } static void printAngle ( Point A , Point B , Point C ) { int a2 = lengthSquare ( B , C ) ; int b2 = lengthSquare ( A , C ) ; int c2 = lengthSquare ( A , B ) ; float a = ( float ) Math . Sqrt ( a2 ) ; float b = ( float ) Math . Sqrt ( b2 ) ; float c = ( float ) Math . Sqrt ( c2 ) ; float alpha = ( float ) Math . Acos ( ( b2 + c2 - a2 ) / ( 2 * b * c ) ) ; float betta = ( float ) Math . Acos ( ( a2 + c2 - b2 ) / ( 2 * a * c ) ) ; float gamma = ( float ) Math . Acos ( ( a2 + b2 - c2 ) / ( 2 * a * b ) ) ; alpha = ( float ) ( alpha * 180 / Math . PI ) ; betta = ( float ) ( betta * 180 / Math . PI ) ; gamma = ( float ) ( gamma * 180 / Math . PI ) ; Console . WriteLine ( " alpha ▁ : ▁ " + alpha ) ; Console . WriteLine ( " betta ▁ : ▁ " + betta ) ; Console . WriteLine ( " gamma ▁ : ▁ " + gamma ) ; } public static void Main ( String [ ] args ) { Point A = new Point ( 0 , 0 ) ; Point B = new Point ( 0 , 1 ) ; Point C = new Point ( 1 , 0 ) ; printAngle ( A , B , C ) ; } }

Class/struct names: GFG, Point
C# program:
using System ; public class GFG { public static int getDistance ( int x1 , int y1 , int x2 , int y2 ) { return ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) ; } public static void triangleWithNoPointInside ( int [ ] [ ] points , int N ) { int first = 0 ; int second = 0 ; int third = 0 ; int minD = int . MaxValue ; for ( int i = 0 ; i < N ; i ++ ) { if ( i == first ) { continue ; } int d = getDistance ( points [ i ] [ 0 ] , points [ i ] [ 1 ] , points [ first ] [ 0 ] , points [ first ] [ 1 ] ) ; if ( minD > d ) { minD = d ; second = i ; } } minD = int . MaxValue ; for ( int i = 0 ; i < N ; i ++ ) { if ( i == first i == second ) { continue ; } int d = getDistance ( points [ i ] [ 0 ] , points [ i ] [ 1 ] , points [ first ] [ 0 ] , points [ first ] [ 1 ] ) ; if ( ( points [ i ] [ 0 ] - points [ first ] [ 0 ] ) * ( points [ second ] [ 1 ] - points [ first ] [ 1 ] ) != ( points [ second ] [ 0 ] - points [ first ] [ 0 ] ) * ( points [ i ] [ 1 ] - points [ first ] [ 1 ] ) && minD > d ) { minD = d ; third = i ; } } Console . WriteLine ( points [ first ] [ 0 ] + " , ▁ " + points [ first ] [ 1 ] ) ; Console . WriteLine ( points [ second ] [ 0 ] + " , ▁ " + points [ second ] [ 1 ] ) ; Console . WriteLine ( points [ third ] [ 0 ] + " , ▁ " + points [ third ] [ 1 ] ) ; } public static void Main ( string [ ] args ) { int [ ] [ ] points = new int [ ] [ ] { new int [ ] { 0 , 0 } , new int [ ] { 0 , 2 } , new int [ ] { 2 , 0 } , new int [ ] { 2 , 2 } , new int [ ] { 1 , 1 } } ; int N = points . Length ; triangleWithNoPointInside ( points , N ) ; } }

Index/key variables: first, i, second, third
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool [ ] prime = new bool [ ( int ) 1e4 + 2 ] ; static void SieveOfEratosthenes ( ) { for ( int i = 0 ; i < ( int ) 1e4 + 2 ; i ++ ) prime [ i ] = true ; for ( int p = 2 ; p * p < ( int ) 1e4 + 2 ; p ++ ) { if ( prime [ p ] == true ) { for ( int i = p * p ; i < ( int ) 1e4 + 2 ; i += p ) prime [ i ] = false ; } } } static int countMin ( int [ ] arr , int n ) { int cMinSwaps = 0 ; int cPrimeIndices = 0 ; int cPrimeNos = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( prime [ i + 1 ] ) { cPrimeIndices ++ ; if ( prime [ arr [ i ] ] == false ) cMinSwaps ++ ; else cPrimeNos ++ ; } else if ( prime [ arr [ i ] ] ) { cPrimeNos ++ ; } } if ( cPrimeNos >= cPrimeIndices ) return cMinSwaps ; else return - 1 ; } public static void Main ( ) { SieveOfEratosthenes ( ) ; int n = 5 ; int [ ] arr = { 2 , 7 , 8 , 5 , 13 } ; Console . Write ( countMin ( arr , n ) ) ; } }

Index/key variables: i, p
Accumulator variables: cMinSwaps, cPrimeIndices, cPrimeNos, i, p
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static void largestSubset ( int [ ] a , int N ) { int [ ] bit = new int [ 32 ] ; for ( int i = 0 ; i < N ; i ++ ) { int x = 31 ; while ( a [ i ] > 0 ) { if ( ( int ) ( a [ i ] & 1 ) == ( int ) 1 ) { bit [ x ] ++ ; } a [ i ] = a [ i ] >> 1 ; x -- ; } } int max = Int32 . MinValue ; for ( int i = 0 ; i < 32 ; i ++ ) { max = Math . Max ( max , bit [ i ] ) ; } Console . WriteLine ( max ) ; } public static void Main ( string [ ] args ) { int [ ] arr = { 7 , 13 , 8 , 2 , 3 } ; int N = arr . Length ; largestSubset ( arr , N ) ; } }

Index/key variables: i, x
Accumulator variables: i, x
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { static int maxAns = int . MinValue ; static int Find ( int [ ] parent , int a ) { return parent [ a ] = ( parent [ a ] == a ) ? a : ( Find ( parent , parent [ a ] ) ) ; } static void Union ( int [ ] parent , int [ ] rank , int [ ] setSum , int a , int b ) { a = Find ( parent , a ) ; b = Find ( parent , b ) ; if ( a == b ) return ; if ( rank [ a ] > rank [ b ] ) rank [ a ] ++ ; if ( rank [ b ] > rank [ a ] ) { int x = a ; a = b ; b = x ; } parent [ b ] = a ; setSum [ a ] += setSum [ b ] ; } static void maxValues ( int [ ] arr , int [ ] queries , int N ) { int [ ] parent = new int [ N + 1 ] ; int [ ] rank = new int [ N + 1 ] ; int [ ] setSum = new int [ N + 1 ] ; List < int > currMax = new List < int > ( ) ; for ( int i = 1 ; i < N + 1 ; i ++ ) { parent [ i ] = - 1 ; setSum [ i ] = arr [ i - 1 ] ; } currMax . Add ( 0 ) ; for ( int i = N - 1 ; i > 0 ; i -- ) { if ( parent [ queries [ i ] ] == - 1 ) { parent [ queries [ i ] ] = queries [ i ] ; } if ( queries [ i ] - 1 >= 0 && parent [ queries [ i ] - 1 ] != - 1 ) { Union ( parent , rank , setSum , queries [ i ] , queries [ i ] - 1 ) ; } if ( queries [ i ] + 1 <= N && parent [ queries [ i ] + 1 ] != - 1 ) { Union ( parent , rank , setSum , queries [ i ] , queries [ i ] + 1 ) ; } maxAns = Math . Max ( setSum [ queries [ i ] ] , maxAns ) ; currMax . Add ( maxAns ) ; } for ( int i = currMax . Count - 1 ; i >= 0 ; i -- ) { Console . Write ( currMax [ i ] + " ▁ " ) ; } } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 3 , 2 , 5 } ; int [ ] queries = { 3 , 4 , 1 , 2 } ; int N = arr . Length ; maxValues ( arr , queries , N ) ; } }

Index/key variables: a, b, i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { class Node { public int val ; public List < Node > child ; public Node ( int key ) { val = key ; child = new List < Node > ( ) ; } } static Node newNode ( int key ) { Node temp = new Node ( key ) ; return temp ; } static void zigzagLevelOrder ( Node root ) { if ( root == null ) return ; List < List < int > > result = new List < List < int > > ( ) ; List < Node > q = new List < Node > ( ) ; q . Add ( root ) ; while ( q . Count > 0 ) { int size = q . Count ; List < int > curLevel = new List < int > ( ) ; for ( int i = 0 ; i < size ; i ++ ) { Node node = q [ 0 ] ; q . RemoveAt ( 0 ) ; curLevel . Add ( node . val ) ; for ( int j = 0 ; j < ( node . child ) . Count ; j ++ ) q . Add ( node . child [ j ] ) ; } result . Add ( curLevel ) ; } for ( int i = 0 ; i < result . Count ; i ++ ) { if ( ( i + 1 ) % 2 == 0 ) { result [ i ] . Reverse ( ) ; } for ( int j = 0 ; j < result [ i ] . Count ; j ++ ) Console . Write ( result [ i ] [ j ] + " ▁ " ) ; Console . WriteLine ( ) ; } } static void Main ( ) { Node root = newNode ( 1 ) ; ( root . child ) . Add ( newNode ( 2 ) ) ; ( root . child ) . Add ( newNode ( 3 ) ) ; ( root . child [ 0 ] . child ) . Add ( newNode ( 4 ) ) ; ( root . child [ 0 ] . child ) . Add ( newNode ( 5 ) ) ; ( root . child [ 1 ] . child ) . Add ( newNode ( 6 ) ) ; ( root . child [ 1 ] ) . child . Add ( newNode ( 7 ) ) ; ( root . child [ 1 ] . child ) . Add ( newNode ( 8 ) ) ; zigzagLevelOrder ( root ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int canPossibleReplacement ( int N , int [ ] arr ) { int S = 0 ; int i ; for ( i = 0 ; i < arr . Length ; i ++ ) S += arr [ i ] ; int P = 1 ; for ( i = 0 ; i < arr . Length ; i ++ ) { P *= i ; } foreach ( int x in arr ) { int y = ( S - x ) / ( P / x - 1 ) ; if ( ( S - x + y ) == ( P * y ) / x ) return 1 ; } return 0 ; } public static void Main ( string [ ] args ) { int N = 3 ; int [ ] arr = { 1 , 3 , 4 } ; if ( canPossibleReplacement ( N , arr ) == 1 ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } }

Index/key variables: i
Accumulator variables: P, S, i
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { public static String checkSameDigits ( int N ) { int length = ( ( int ) Math . Log10 ( N ) ) + 1 ; int M = ( ( int ) Math . Pow ( 10 , length ) - 1 ) / ( 10 - 1 ) ; M *= N % 10 ; if ( M == N ) return " Yes " ; return " No " ; } public static void Main ( ) { int N = 222 ; Console . WriteLine ( checkSameDigits ( N ) ) ; } }

Accumulator variables: M
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int maxSumPath = 0 ; class Node { public int val ; public List < Node > child ; public Node ( int key ) { val = key ; child = new List < Node > ( ) ; } } static Node newNode ( int key ) { Node temp = new Node ( key ) ; return temp ; } static void DFS ( Node root , int sum ) { if ( root . child . Count == 0 ) { maxSumPath = Math . Max ( maxSumPath , sum ) ; return ; } for ( int i = 0 ; i < root . child . Count ; i ++ ) { DFS ( root . child [ i ] , sum + root . child [ i ] . val ) ; } } static void Main ( ) { Node root = newNode ( 1 ) ; ( root . child ) . Add ( newNode ( 2 ) ) ; ( root . child ) . Add ( newNode ( 3 ) ) ; ( root . child [ 0 ] . child ) . Add ( newNode ( 4 ) ) ; ( root . child [ 1 ] . child ) . Add ( newNode ( 6 ) ) ; ( root . child [ 0 ] . child ) . Add ( newNode ( 5 ) ) ; ( root . child [ 1 ] ) . child . Add ( newNode ( 7 ) ) ; ( root . child [ 1 ] . child ) . Add ( newNode ( 8 ) ) ; DFS ( root , root . val ) ; Console . Write ( maxSumPath ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static void countTriplets ( int size , int queries , int [ ] arr , int [ , ] Q ) { int [ ] arr_even = new int [ size + 1 ] ; int [ ] arr_odd = new int [ size + 1 ] ; int even = 0 ; int odd = 0 ; arr_even [ 0 ] = 0 ; arr_odd [ 0 ] = 0 ; for ( int i = 0 ; i < size ; i ++ ) { if ( arr [ i ] % 2 == 1 ) { odd ++ ; } else { even ++ ; } arr_even [ i + 1 ] = even ; arr_odd [ i + 1 ] = odd ; } for ( int i = 0 ; i < queries ; i ++ ) { int l = Q [ i , 0 ] , r = Q [ i , 1 ] ; odd = arr_odd [ r ] - arr_odd [ l - 1 ] ; even = arr_even [ r ] - arr_even [ l - 1 ] ; int ans = ( even * ( even - 1 ) * ( even - 2 ) ) / 6 + ( odd * ( odd - 1 ) / 2 ) * even ; Console . Write ( ans + " ▁ " ) ; } } public static void Main ( ) { int N = 6 , Q = 2 ; int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 } ; int [ , ] queries = { { 1 , 3 } , { 2 , 5 } } ; countTriplets ( N , Q , arr , queries ) ; } }

Index/key variables: i, r
Accumulator variables: even, i, odd
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int maxRightmostElement ( int N , int k , int p , int [ ] arr ) { while ( k > 0 ) { for ( int i = N - 2 ; i >= 0 ; i -- ) { if ( arr [ i ] >= p ) { arr [ i ] = arr [ i ] - p ; arr [ i + 1 ] = arr [ i + 1 ] + p ; break ; } } k -- ; } return arr [ N - 1 ] ; } static public void Main ( ) { int N = 4 , k = 5 , p = 2 ; int [ ] arr = { 3 , 8 , 1 , 4 } ; Console . WriteLine ( maxRightmostElement ( N , k , p , arr ) ) ; } }

Index/key variables: i
Accumulator variables: i, k
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int nCr ( int n , int r , int [ ] f ) { if ( n < r ) { return 0 ; } return f [ n ] / ( f [ r ] * f [ n - r ] ) ; } static int findMean ( int N , int X ) { int [ ] f = new int [ N + 1 ] ; f [ 0 ] = 1 ; for ( int i = 1 ; i <= N ; i ++ ) { f [ i ] = f [ i - 1 ] * i ; } int total = nCr ( N , X , f ) ; int count = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { count += nCr ( N - i , X - 1 , f ) * i ; } double E_X = ( double ) ( count ) / ( double ) ( total ) ; Console . Write ( " { 0 : F9 } " , E_X ) ; return 0 ; } static publ int N = 3 , X = 2 ; findMean ( N , X ) ; } } void Main ( ) {

Index/key variables: i, n, r
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static int maximumNumberofpairs ( int n , int [ ] arr ) { int x = 0 ; int y = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] % 2 == 0 ) { x ++ ; } else { y ++ ; } } int answer = Math . Min ( x , y ) ; if ( Math . Abs ( x - y ) >= 2 ) { answer ++ ; } return answer ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 2 , 4 , 6 , 5 , 10 , 12 } ; int n = arr . Length ; Console . WriteLine ( maximumNumberofpairs ( n , arr ) ) ; } }

Index/key variables: i
Accumulator variables: answer, i, x, y
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static void pairwiseProductSum ( int [ ] a , int l , int r ) { int sum = 0 ; for ( int j = l - 1 ; j <= r - 1 ; j ++ ) { for ( int k = j + 1 ; k <= r - 1 ; k ++ ) { sum += ( a [ j ] * a [ k ] ) ; } } Console . Write ( sum + " STRNEWLINE " ) ; } static void updateArray ( int [ ] a , int p , int x ) { a [ p - 1 ] = x ; } static void solveQueries ( int [ ] a , int n , int Q , int [ ] [ ] query ) { for ( int i = 0 ; i < Q ; i ++ ) { if ( query [ i ] [ 0 ] == 1 ) pairwiseProductSum ( a , query [ i ] [ 1 ] , query [ i ] [ 2 ] ) ; else updateArray ( a , query [ i ] [ 1 ] , query [ i ] [ 2 ] ) ; } } static public void Main ( ) { int [ ] A = { 5 , 7 , 2 , 3 , 1 } ; int N = A . Length ; int Q = 3 ; int [ ] [ ] query = { new int [ 3 ] { 1 , 1 , 3 } , new int [ 3 ] { 2 , 2 , 5 } , new int [ 3 ] { 1 , 2 , 5 } } ; solveQueries ( A , N , Q , query ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k, sum
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFg { static int Reduced ( List < int > a , int n ) { List < int > original_array = new List < int > ( a ) ; while ( a . Count != 2 ) { int mid = a . Count / 2 ; int mid_ele = a [ mid ] ; int start = a [ 0 ] ; a . RemoveAt ( 0 ) ; int end = a [ a . Count - 1 ] ; a . RemoveAt ( a . Count - 1 ) ; int rmd = ( start * end ) % mid_ele ; a . Add ( rmd ) ; int remainder = ( a [ 0 ] * a [ 1 ] ) % n ; for ( int i = 0 ; i < original_array . Count ; i ++ ) { if ( original_array [ i ] == remainder ) { return 1 ; } } } return 0 ; } int x = Reduced ( Arr , N ) ; if ( x > 0 ) Console . WriteLine ( " YES " ) ; else Console . WriteLine ( " NO " ) ; } }

Index/key variables: i, mid
Accumulator variables: i
Iterator variables: i
Class/struct names: GFg