dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int minimize ( int n ) { int optEle = n ; string strEle = n . ToString ( ) ; for ( int idx = 0 ; idx < strEle . Length ; idx ++ ) { int temp = Int32 . Parse ( strEle . Substring ( idx ) + strEle . Substring ( 0 , idx ) ) ; optEle = Math . Min ( optEle , temp ) ; } return optEle ; } static int maximize ( int n ) { int optEle = n ; string strEle = n . ToString ( ) ; for ( int idx = 0 ; idx < strEle . Length ; idx ++ ) { int temp = Int32 . Parse ( strEle . Substring ( idx ) + strEle . Substring ( 0 , idx ) ) ; optEle = Math . Max ( optEle , temp ) ; } return optEle ; } static void minimumDifference ( int [ ] arr ) { int caseOne = 0 ; int minVal = 0 ; int maxVal = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( i % 2 == 0 ) minVal += minimize ( arr [ i ] ) ; else maxVal += maximize ( arr [ i ] ) ; } caseOne = Math . Abs ( maxVal - minVal ) ; int caseTwo = 0 ; minVal = 0 ; maxVal = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) { if ( i % 2 == 0 ) maxVal += maximize ( arr [ i ] ) ; else minVal += minimize ( arr [ i ] ) ; caseTwo = Math . Abs ( maxVal - minVal ) ; } Console . WriteLine ( Math . Max ( caseOne , caseTwo ) ) ; } public static void Main ( ) { int [ ] arr = { 332 , 421 , 215 , 584 , 232 } ; minimumDifference ( arr ) ; } }

Index/key variables: i
Accumulator variables: i, idx, maxVal, minVal
Iterator variables: i, idx
Class/struct names: GFG
C# program:
using System ; class GFG { static int minimumStepReqArr ( int [ ] arr , int N ) { int cntStep = 0 ; N += 1 ; for ( int i = 31 ; i >= 0 ; i -- ) { if ( ( N & ( 1 << i ) ) != 0 ) { cntStep += 1 ; } } return cntStep ; } static void Main ( ) { int [ ] arr = { 1 , 2 , 3 } ; int N = arr . Length ; Console . WriteLine ( minimumStepReqArr ( arr , N ) ) ; } }

Accumulator variables: N, cntStep, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void minOpsToEmptyString ( string S , int N ) { int one = 0 , zero = 0 ; int x0 = 0 , x1 = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S [ i ] == '0' ) { x0 ++ ; x1 = 0 ; } else { x1 ++ ; x0 = 0 ; } zero = Math . Max ( x0 , zero ) ; one = Math . Max ( x1 , one ) ; } Console . WriteLine ( Math . Max ( one , zero ) ) ; } static public void Main ( ) { int N = S . Length ; string S = "0100100111" ; int N = S . Length ; minOpsToEmptyString ( S , N ) ; } }

Index/key variables: i
Accumulator variables: i, x0, x1
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void ReverseSwap ( int [ , ] mat , int n ) { int [ ] lowerEle = new int [ n ] ; int [ ] upperEle = new int [ n ] ; int index ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { index = Math . Abs ( i - j ) ; if ( i == j ) { continue ; } else if ( j < i ) { lowerEle [ index ] = mat [ i , j ] ; } else { upperEle [ index ] = mat [ i , j ] ; } } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { index = Math . Abs ( i - j ) ; if ( i == j ) { continue ; } else if ( j < i ) { mat [ i , j ] = upperEle [ index ] ; } else { mat [ i , j ] = lowerEle [ index -- ] ; } } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { Console . Write ( mat [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } static public void Main ( ) { int [ , ] mat = new int [ , ] { { 1 , 2 } , { 4 , 5 } } ; int N = mat . GetLength ( 0 ) ; ReverseSwap ( mat , N ) ; } }

Index/key variables: index, n
Accumulator variables: i, index, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static List < int > primePower ( int X ) { List < int > primePow = new List < int > ( ) ; for ( int i = 2 ; i * i <= X ; i ++ ) { if ( X % i == 0 ) { int p = 1 ; while ( X % i == 0 ) { X /= i ; p *= i ; } primePow . Add ( p ) ; } } if ( X > 1 ) { primePow . Add ( X ) ; } return primePow ; } static int getSum ( int [ ] ar ) { int sum = 0 ; foreach ( int i in ar ) { sum += i ; } return sum ; } static int getMinSum ( int pos , int [ ] arr , List < int > primePow ) { if ( pos == primePow . Count ) { return getSum ( arr ) ; } int res = int . MaxValue ; for ( int i = 0 ; i < arr . Length ; i ++ ) { arr [ i ] *= primePow [ pos ] ; res = Math . Min ( res , getMinSum ( pos + 1 , arr , primePow ) ) ; arr [ i ] /= primePow [ pos ] ; } return res ; } static int minimumSumWithGivenLCM ( int k , int x ) { List < int > primePow = primePower ( x ) ; int n = primePow . Count ; int sum = 0 ; if ( n <= k ) { foreach ( int i in primePow ) { sum += i ; } sum += k - n ; } else { int [ ] arr = new int [ k ] ; for ( int l = 0 ; l < arr . Length ; l ++ ) arr [ l ] = 1 ; sum = getMinSum ( 0 , arr , primePow ) ; } return sum ; } public static void Main ( String [ ] args ) { int k = 3 , x = 210 ; Console . Write ( minimumSumWithGivenLCM ( k , x ) ) ; } }

Index/key variables: i, k, l, pos
Accumulator variables: X, i, l, p, sum
Iterator variables: i, l
Class/struct names: GFG
C# program:
using System ; class GFG { static int findMinOperationsReqEmpStr ( String str ) { int cntOne = 0 ; int cntZero = 0 ; int N = str . Length ; for ( int i = 0 ; i < N ; i ++ ) { if ( str [ i ] == '0' ) { if ( cntOne != 0 ) { cntOne -- ; } cntZero ++ ; } else { if ( cntZero != 0 ) { cntZero -- ; } cntOne ++ ; } } return ( cntOne + cntZero ) ; } public static void Main ( String [ ] args ) { String str = "0100100111" ; Console . Write ( findMinOperationsReqEmpStr ( str ) ) ; } }

Index/key variables: i
Accumulator variables: cntOne, cntZero, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int countChanges ( char [ , ] mat ) { int n = mat . GetLength ( 0 ) ; int m = mat . GetLength ( 1 ) ; int ans = 0 ; for ( int j = 0 ; j < m - 1 ; j ++ ) { if ( mat [ n - 1 , j ] != ' R ' ) ans ++ ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( mat [ i , m - 1 ] != ' D ' ) ans ++ ; } return ans ; } public static void Main ( String [ ] args ) { char [ , ] arr = { { ' R ' , ' R ' , ' R ' , ' D ' } , { ' D ' , ' D ' , ' D ' , ' R ' } , { ' R ' , ' D ' , ' R ' , ' F ' } } ; int cnt = countChanges ( arr ) ; Console . WriteLine ( cnt ) ; } }

Accumulator variables: ans, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public class Node { public int key ; public Node left , right ; } static Node newNode ( int key ) { Node temp = new Node ( ) ; temp . key = key ; temp . left = null ; temp . right = null ; return temp ; } static int isSorted ( Node root ) { int prevMax = int . MinValue ; int minval ; int maxval ; int levelSize ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; while ( q . Count != 0 ) { levelSize = q . Count ; minval = int . MaxValue ; maxval = int . MinValue ; while ( levelSize > 0 ) { root = q . Peek ( ) ; q . Dequeue ( ) ; levelSize -- ; minval = Math . Min ( minval , root . key ) ; maxval = Math . Max ( maxval , root . key ) ; if ( root . left != null ) q . Enqueue ( root . left ) ; if ( root . right != null ) q . Enqueue ( root . right ) ; } if ( minval <= prevMax ) return 0 ; prevMax = maxval ; } return 1 ; } public static void Main ( String [ ] args ) { Node root = newNode ( 1 ) ; root . left = newNode ( 4 ) ; root . left . right = newNode ( 6 ) ; root . left . right . left = newNode ( 8 ) ; root . left . right . right = newNode ( 9 ) ; root . left . right . left . left = newNode ( 12 ) ; root . left . right . right . right = newNode ( 10 ) ; if ( isSorted ( root ) == 1 ) Console . WriteLine ( " Sorted " ) ; else Console . WriteLine ( " Not ▁ sorted " ) ; } }

Accumulator variables: levelSize
Class/struct names: GFG, Node
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static void printSmallSub ( int [ ] arr , int N ) { int gcdArr = 0 ; for ( int i = 0 ; i < N ; i ++ ) { gcdArr = gcd ( gcdArr , arr [ i ] ) ; } for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == gcdArr ) { Console . Write ( arr [ i ] + " ▁ " ) ; return ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = i + 1 ; j < N ; j ++ ) { if ( gcd ( arr [ i ] , arr [ j ] ) == gcdArr ) { Console . Write ( arr [ i ] + " ▁ " + arr [ j ] ) ; return ; } } } } public static void Main ( ) { int [ ] arr = { 4 , 6 , 12 } ; int N = arr . Length ; printSmallSub ( arr , N ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { public static int X = 1000000 ; public static bool [ ] getPrimeNum ( ) { bool [ ] isPrime = new bool [ X ] ; for ( int i = 0 ; i < X ; i ++ ) isPrime [ i ] = true ; isPrime [ 0 ] = false ; isPrime [ 1 ] = false ; for ( int i = 2 ; i * i <= X ; i ++ ) { if ( isPrime [ i ] == true ) { for ( int j = i * i ; j < X ; j += i ) { isPrime [ j ] = false ; } } } return isPrime ; } public static int cntPairs ( int [ ] arr , int N ) { bool [ ] isPrime = getPrimeNum ( ) ; int cntOne = 0 ; int cntPrime = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( arr [ i ] == 1 ) { cntOne += 1 ; } else if ( isPrime [ i ] ) { cntPrime += 1 ; } } int cntNonComp = 0 ; cntNonComp = cntPrime * cntOne + cntOne * ( cntOne - 1 ) / 2 ; int res = 0 ; res = N * ( N - 1 ) / 2 - cntNonComp ; return res ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 1 , 2 , 2 , 8 } ; int N = arr . Length ; Console . WriteLine ( cntPairs ( arr , N ) ) ; } }

Index/key variables: X, i, j
Accumulator variables: cntOne, cntPrime, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int power ( int X , int n ) { int res = 1 ; while ( n != 0 ) { if ( ( n & 1 ) != 0 ) res = res * X ; X = X * X ; n = n >> 1 ; } return res ; } static int closestgtNum ( int N ) { int n = ( int ) Math . Log10 ( N ) + 1 ; int P = power ( 10 , n - 1 ) ; int Y = N % P ; int res = N + ( P - Y ) ; return res ; } public static void Main ( ) { int N = 120 ; Console . Write ( closestgtNum ( N ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static void RearrangeB ( int [ ] A , int [ ] B ) { int n = A . Length ; if ( n == 1 && A [ 0 ] == B [ 0 ] ) { Console . WriteLine ( " - 1" ) ; return ; } for ( int i = 0 ; i < n / 2 ; i ++ ) { int t = B [ i ] ; B [ i ] = B [ n - i - 1 ] ; B [ n - i - 1 ] = t ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( B [ i ] == A [ i ] ) { int t = B [ i + 1 ] ; B [ i + 1 ] = B [ i ] ; B [ i ] = t ; break ; } } foreach ( int k in B ) Console . Write ( k + " ▁ " ) ; } public static void Main ( String [ ] args ) { int [ ] A = { 2 , 4 , 5 , 8 } ; int [ ] B = { 2 , 4 , 5 , 8 } ; RearrangeB ( A , B ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, k
Class/struct names: GFG
C# program:
using System ; class GFG { static void swap ( int N , int M , int [ , ] mat , int startx_X , int starty_X , int startx_Y , int starty_Y ) { int row = 0 ; int col = 0 ; for ( int i = startx_X ; ; i ++ ) { col = 0 ; for ( int j = startx_X ; ; j ++ ) { int temp = mat [ i , j ] ; mat [ i , j ] = mat [ startx_Y + row , starty_Y + col ] ; mat [ startx_Y + row , starty_Y + col ] = temp ; col ++ ; if ( col >= M / 2 ) break ; } row ++ ; if ( row >= N / 2 ) break ; } } static void swapQuadOfMatrix ( int N , int M , int [ , ] mat , int X , int Y ) { if ( X == 1 && Y == 2 ) { swap ( N , M , mat , 0 , 0 , 0 , M / 2 ) ; } else if ( X == 1 && Y == 3 ) { swap ( N , M , mat , 0 , 0 , N / 2 , 0 ) ; } else if ( X == 1 && Y == 4 ) { swap ( N , M , mat , 0 , 0 , N / 2 , M / 2 ) ; } else if ( X == 2 && Y == 3 ) { swap ( N , M , mat , 0 , M / 2 , N / 2 , 0 ) ; } else if ( X == 2 && Y == 4 ) { swap ( N , M , mat , 0 , M / 2 , N / 2 , M / 2 ) ; } else if ( X == 3 && Y == 4 ) { swap ( N , M , mat , N / 2 , 0 , N / 2 , M / 2 ) ; } printMat ( N , M , mat ) ; } static void printMat ( int N , int M , int [ , ] mat ) { for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { Console . Write ( mat [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } } public static void Main ( String [ ] args ) { int N = 6 , M = 6 ; int [ , ] mat = { { 1 , 2 , 3 , 4 , 5 , 6 } , { 7 , 8 , 9 , 10 , 11 , 12 } , { 13 , 14 , 15 , 16 , 17 , 18 } , { 19 , 20 , 21 , 22 , 23 , 24 } , { 25 , 26 , 27 , 28 , 29 , 30 } , { 31 , 32 , 33 , 34 , 35 , 36 } } ; int X = 1 , Y = 4 ; swapQuadOfMatrix ( N , M , mat , X , Y ) ; } }

Accumulator variables: col, i, j, row
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class Node { public int data ; public int hd ; public Node left , right ; public Node ( int key ) { data = key ; hd = 1000000 ; left = right = null ; } } class Tree { Node root ; public Tree ( ) { } public Tree ( Node node ) { root = node ; } public void bottomView ( ) { if ( root == null ) return ; int hd = 0 ; SortedDictionary < int , int > map = new SortedDictionary < int , int > ( ) ; Queue queue = new Queue ( ) ; root . hd = hd ; queue . Enqueue ( root ) ; while ( queue . Count != 0 ) { Node temp = ( Node ) queue . Dequeue ( ) ; hd = temp . hd ; map [ hd ] = temp . data ; if ( temp . left != null ) { temp . left . hd = hd - 1 ; queue . Enqueue ( temp . left ) ; } if ( temp . right != null ) { temp . right . hd = hd + 1 ; queue . Enqueue ( temp . right ) ; } } foreach ( int i in map . Values ) { Console . Write ( i + " ▁ " ) ; } } } public class BottomView { public static void Main ( string [ ] args ) { Node root = new Node ( 20 ) ; root . left = new Node ( 8 ) ; root . right = new Node ( 22 ) ; root . left . left = new Node ( 5 ) ; root . left . right = new Node ( 3 ) ; root . right . left = new Node ( 4 ) ; root . right . right = new Node ( 25 ) ; root . left . right . left = new Node ( 10 ) ; root . left . right . right = new Node ( 14 ) ; Tree tree = new Tree ( root ) ; Console . WriteLine ( " Bottom ▁ view ▁ of ▁ the ▁ " + " given ▁ binary ▁ tree : " ) ; tree . bottomView ( ) ; } }

Index/key variables: hd
Iterator variables: i
Class/struct names: BottomView, Node, Tree
C# program:
using System ; class GFG { static void incrementCount ( int [ ] arr , int N ) { int mini = arr [ 0 ] - arr [ 1 ] ; for ( int i = 2 ; i < N ; i ++ ) { mini = Math . Min ( mini , arr [ i - 1 ] - arr [ i ] ) ; } Console . WriteLine ( mini ) ; } public static void Main ( String [ ] args ) { int N = 3 ; int [ ] arr = { 12 , 8 , 4 } ; incrementCount ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void countOperations ( int n , int k ) { int div = 2 * k + 1 ; if ( n / 2 <= k ) { Console . Write ( 1 + " STRNEWLINE " ) ; if ( n > k ) Console . Write ( k + 1 ) ; else Console . Write ( n ) ; } else { if ( n % div == 0 ) { int oprn = n / div ; Console . Write ( oprn + " STRNEWLINE " ) ; int pos = k + 1 ; Console . Write ( pos + " ▁ " ) ; for ( int i = 1 ; i <= oprn ; i ++ ) { Console . Write ( pos + " ▁ " ) ; pos += div ; } } else { int oprn = n / div + 1 ; Console . Write ( oprn + " STRNEWLINE " ) ; int pos = n % div ; if ( n % div > k ) pos -= k ; for ( int i = 1 ; i <= oprn ; i ++ ) { Console . Write ( pos + " ▁ " ) ; pos += div ; } } } } public static void Main ( String [ ] args ) { String str = " edfreqwsazxet " ; int n = str . Length ; int k = 4 ; countOperations ( n , k ) ; } }

Accumulator variables: i, pos
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void largestSubsequence ( char [ ] s ) { int maxi = 0 ; char prev1 ; for ( int i = 0 ; i < 10 ; i ++ ) { for ( int j = 0 ; j < 10 ; j ++ ) { if ( i != j ) { int len = 0 ; prev1 = ( char ) ( j + '0' ) ; for ( int k = 0 ; k < s . Length ; k ++ ) { if ( s [ k ] == i + '0' && prev1 == j + '0' ) { prev1 = s [ k ] ; len ++ ; } else if ( s [ k ] == j + '0' && prev1 == i + '0' ) { prev1 = s [ k ] ; len ++ ; } } maxi = Math . Max ( len , maxi ) ; } } } if ( maxi != 1 ) Console . Write ( maxi + " STRNEWLINE " ) ; else Console . Write ( 0 + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { String s = "1542745249842" ; largestSubsequence ( s . ToCharArray ( ) ) ; } }

Index/key variables: k
Accumulator variables: i, j, k, len
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int maxm = 0 ; class Node { public int val ; public Node left , right ; public Node ( int x ) { val = x ; left = null ; right = null ; } } ; static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static int find_gcd ( List < int > arr ) { if ( arr . Count == 1 ) return arr [ 0 ] ; int g = arr [ 0 ] ; for ( int i = 1 ; i < arr . Count ; i ++ ) { g = gcd ( g , arr [ 1 ] ) ; } return g ; } static void maxm_gcd ( Node root , List < int > ans ) { if ( root == null ) return ; if ( root . left == null && root . right == null ) { ans . Add ( root . val ) ; maxm = Math . Max ( find_gcd ( ans ) , maxm ) ; return ; } ans . Add ( root . val ) ; maxm_gcd ( root . left , ans ) ; maxm_gcd ( root . right , ans ) ; } public static void Main ( String [ ] args ) { Node root = new Node ( 15 ) ; root . left = new Node ( 3 ) ; root . right = new Node ( 7 ) ; root . left . left = new Node ( 15 ) ; root . left . right = new Node ( 1 ) ; root . right . left = new Node ( 31 ) ; root . right . right = new Node ( 9 ) ; maxm_gcd ( root , new List < int > ( ) ) ; Console . Write ( maxm + " STRNEWLINE " ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG, Node
C# program:
using System ; class GFG { public static int numberOfPairs ( int n ) { int count = 0 ; int i = 1 , j = n - 1 ; while ( i < j ) { if ( i + j == n ) { count ++ ; } i ++ ; j -- ; } return count ; } public static void Main ( string [ ] args ) { int n = 8 ; Console . Write ( numberOfPairs ( n ) ) ; } }

Accumulator variables: count, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void Solve ( int N , int M ) { int temp = ( N - 1 ) * ( M - 1 ) ; int ans = ( int ) ( Math . Pow ( 2 , temp ) ) ; if ( ( N + M ) % 2 != 0 ) Console . Write ( ans ) ; else Console . Write ( 2 * ans ) ; } public static void Main ( string [ ] args ) { int N = 3 ; int M = 3 ; Solve ( N , M ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = ( int ) 1e5 + 5 ; static List < int > [ ] v = new List < int > [ N ] ; static List < int > [ ] g = new List < int > [ N ] ; static bool [ ] vis = new bool [ N ] ; static int [ ] init = new int [ N ] ; static int [ ] low = new int [ N ] ; static int [ ] parent = new int [ N ] ; static int [ ] rnk = new int [ N ] ; static List < pair > bridges = new List < pair > ( ) ; static int n , m ; static int timer = 0 ; static int diameter ; class pair { public int first , second ; public pair ( int first , int second ) { this . first = first ; this . second = second ; } } static void swap ( int x , int y ) { int temp = x ; x = y ; y = temp ; } static int find_set ( int a ) { if ( parent [ a ] == a ) return a ; return parent [ a ] = find_set ( parent [ a ] ) ; } static void union_set ( int a , int b ) { int x = find_set ( a ) , y = find_set ( b ) ; if ( x == y ) return ; if ( rnk [ x ] == rnk [ y ] ) rnk [ x ] ++ ; if ( rnk [ y ] > rnk [ x ] ) swap ( x , y ) ; parent [ y ] = x ; } static void dfsBridges ( int a , int par ) { vis [ a ] = true ; init [ a ] = low [ a ] = timer ++ ; foreach ( int i in v [ a ] ) { if ( i == par ) continue ; if ( vis [ i ] ) low [ a ] = Math . Min ( low [ a ] , init [ i ] ) ; else { dfsBridges ( i , a ) ; low [ a ] = Math . Min ( low [ a ] , low [ i ] ) ; if ( init [ a ] < low [ i ] ) bridges . Add ( new pair ( i , a ) ) ; else union_set ( i , a ) ; } } } static int dfsDiameter ( int a , int par ) { int x = 0 , y = 0 ; foreach ( int i in g [ a ] ) { if ( i == par ) continue ; int mx = dfsDiameter ( i , a ) ; if ( mx > x ) { y = x ; x = mx ; } else if ( mx > y ) y = mx ; } diameter = Math . Max ( diameter , x + y ) ; return x + 1 ; } static int findMaxBridges ( ) { for ( int i = 0 ; i <= n ; i ++ ) { parent [ i ] = i ; rnk [ i ] = 1 ; } dfsBridges ( 1 , 0 ) ; if ( bridges . Count == 0 ) return 0 ; int head = - 1 ; foreach ( pair i in bridges ) { int a = find_set ( i . first ) ; int b = find_set ( i . second ) ; g [ a ] . Add ( b ) ; g [ b ] . Add ( a ) ; head = a ; } diameter = 0 ; dfsDiameter ( head , 0 ) ; return diameter ; } public static void Main ( String [ ] args ) { n = 6 ; m = 6 ; for ( int i = 0 ; i < v . Length ; i ++ ) v [ i ] = new List < int > ( ) ; for ( int i = 0 ; i < g . Length ; i ++ ) g [ i ] = new List < int > ( ) ; v [ 1 ] . Add ( 2 ) ; v [ 2 ] . Add ( 1 ) ; v [ 2 ] . Add ( 3 ) ; v [ 3 ] . Add ( 2 ) ; v [ 2 ] . Add ( 5 ) ; v [ 5 ] . Add ( 2 ) ; v [ 5 ] . Add ( 6 ) ; v [ 6 ] . Add ( 5 ) ; v [ 6 ] . Add ( 3 ) ; v [ 3 ] . Add ( 6 ) ; v [ 3 ] . Add ( 4 ) ; v [ 4 ] . Add ( 4 ) ; int ans = findMaxBridges ( ) ; Console . Write ( ans + " STRNEWLINE " ) ; } }

Index/key variables: N, a, b, i, x, y
Accumulator variables: i, timer
Iterator variables: i
Class/struct names: GFG, pair
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right = null ; } } public class BinaryTree { public Node root ; public virtual int LeafCount { get { return getLeafCount ( root ) ; } } public virtual int getLeafCount ( Node node ) { if ( node == null ) { return 0 ; } if ( node . left == null && node . right == null ) { return 1 ; } else { return getLeafCount ( node . left ) + getLeafCount ( node . right ) ; } } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; tree . root = new Node ( 1 ) ; tree . root . left = new Node ( 2 ) ; tree . root . right = new Node ( 3 ) ; tree . root . left . left = new Node ( 4 ) ; tree . root . left . right = new Node ( 5 ) ; Console . WriteLine ( " The ▁ leaf ▁ count ▁ of ▁ binary ▁ tree ▁ is ▁ : ▁ " + tree . LeafCount ) ; } }

Class/struct names: BinaryTree, Node
C# program:
using System ; class GFG { static int palindromeWinner ( string S ) { int [ ] freq = new int [ 26 ] ; int count = 0 ; for ( int i = 0 ; i < ( int ) S . Length ; ++ i ) { if ( freq [ S [ i ] - ' a ' ] == 0 ) count ++ ; freq [ S [ i ] - ' a ' ] ++ ; } int unique = 0 ; int duplicate = 0 ; for ( int i = 0 ; i < 26 ; ++ i ) { if ( freq [ i ] == 1 ) unique ++ ; else if ( freq [ i ] >= 2 ) duplicate ++ ; } if ( unique == 1 && ( unique + duplicate ) == count ) return 1 ; return 2 ; } public static void Main ( string [ ] s ) { string S = " abcbc " ; Console . Write ( " Player - " + palindromeWinner ( S ) ) ; } }

Index/key variables: i
Accumulator variables: count, duplicate, unique
Iterator variables: i
Class/struct names: GFG