dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { public static bool isDivisible ( String S ) { int n = S . Length ; if ( S [ n - 1 ] != '5' && S [ n - 1 ] != '0' ) return false ; int sum = 0 ; for ( int i = 0 ; i < S . Length ; i ++ ) sum += ( int ) S [ i ] ; if ( sum % 3 == 0 ) return true ; else return false ; } public static void Main ( ) { String S = "15645746327462384723984023940239" ; if ( isDivisible ( S ) == true ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; String S1 = "15645746327462384723984023940235" ; if ( isDivisible ( S1 ) == true ) 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 { const int V = 4 ; const int INF = Int32 . MaxValue ; int shortestPath ( int [ , ] graph , int u , int v , int k ) { if ( k == 0 && u == v ) return 0 ; if ( k == 1 && graph [ u , v ] != INF ) return graph [ u , v ] ; if ( k <= 0 ) return INF ; int res = INF ; for ( int i = 0 ; i < V ; i ++ ) { if ( graph [ u , i ] != INF && u != i && v != i ) { int rec_res = shortestPath ( graph , i , v , k - 1 ) ; if ( rec_res != INF ) res = Math . Min ( res , graph [ u , i ] + rec_res ) ; } } return res ; } public static void Main ( ) { int [ , ] graph = new int [ , ] { { 0 , 10 , 3 , 2 } , { INF , 0 , INF , 7 } , { INF , INF , 0 , 6 } , { INF , INF , INF , 0 } } ; GFG t = new GFG ( ) ; int u = 0 , v = 3 , k = 2 ; Console . WriteLine ( " Weight ▁ of ▁ the ▁ shortest ▁ path ▁ is ▁ " + t . shortestPath ( graph , u , v , k ) ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int V = 4 ; static readonly int INF = int . MaxValue ; int shortestPath ( int [ , ] graph , int u , int v , int k ) { int [ , , ] sp = new int [ V , V , k + 1 ] ; for ( int e = 0 ; e <= k ; e ++ ) { for ( int i = 0 ; i < V ; i ++ ) { for ( int j = 0 ; j < V ; j ++ ) { sp [ i , j , e ] = INF ; if ( e == 0 && i == j ) sp [ i , j , e ] = 0 ; if ( e == 1 && graph [ i , j ] != INF ) sp [ i , j , e ] = graph [ i , j ] ; if ( e > 1 ) { for ( int a = 0 ; a < V ; a ++ ) { if ( graph [ i , a ] != INF && i != a && j != a && sp [ a , j , e - 1 ] != INF ) sp [ i , j , e ] = Math . Min ( sp [ i , j , e ] , graph [ i , a ] + sp [ a , j , e - 1 ] ) ; } } } } } return sp [ u , v , k ] ; } public static void Main ( String [ ] args ) { int [ , ] graph = new int [ , ] { { 0 , 10 , 3 , 2 } , { INF , 0 , INF , 7 } , { INF , INF , 0 , 6 } , { INF , INF , INF , 0 } } ; GFG t = new GFG ( ) ; int u = 0 , v = 3 , k = 2 ; Console . WriteLine ( " Weight ▁ of ▁ the ▁ shortest ▁ path ▁ is ▁ " + t . shortestPath ( graph , u , v , k ) ) ; } }

Accumulator variables: a, e, i, j
Iterator variables: a, e, i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int N = 8 ; static int INF = int . MaxValue ; public static int shortestDist ( int [ , ] graph ) { int [ ] dist = new int [ N ] ; dist [ N - 1 ] = 0 ; for ( int i = N - 2 ; i >= 0 ; i -- ) { dist [ i ] = INF ; for ( int j = i ; j < N ; j ++ ) { if ( graph [ i , j ] == INF ) continue ; dist [ i ] = Math . Min ( dist [ i ] , graph [ i , j ] + dist [ j ] ) ; } } return dist [ 0 ] ; } static void Main ( ) { int [ , ] graph = new int [ , ] { { INF , 1 , 2 , 5 , INF , INF , INF , INF } , { INF , INF , INF , INF , 4 , 11 , INF , INF } , { INF , INF , INF , INF , 9 , 5 , 16 , INF } , { INF , INF , INF , INF , INF , INF , 2 , INF } , { INF , INF , INF , INF , INF , INF , INF , 18 } , { INF , INF , INF , INF , INF , INF , INF , 13 } , { INF , INF , INF , INF , INF , INF , INF , 2 } } ; Console . Write ( shortestDist ( graph ) ) ; } }

Index/key variables: N, i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class Node { public int data ; public Node left , right ; public Node ( int item ) { data = item ; left = right ; } } class BinaryTree { Node root ; void reverseLevelOrder ( Node node ) { int h = height ( node ) ; int i ; for ( i = h ; i >= 1 ; i -- ) { printGivenLevel ( node , i ) ; } } void printGivenLevel ( Node node , int level ) { if ( node == null ) return ; if ( level == 1 ) Console . Write ( node . data + " ▁ " ) ; else if ( level > 1 ) { printGivenLevel ( node . left , level - 1 ) ; printGivenLevel ( node . right , level - 1 ) ; } } int height ( Node node ) { if ( node == null ) return 0 ; else { int lheight = height ( node . left ) ; int rheight = height ( node . right ) ; if ( lheight > rheight ) return ( lheight + 1 ) ; else return ( rheight + 1 ) ; } } static public 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 ( " Level ▁ Order ▁ traversal ▁ " + " of ▁ binary ▁ tree ▁ is ▁ : ▁ " ) ; tree . reverseLevelOrder ( tree . root ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static HashSet < int > node = new HashSet < int > ( ) ; static List < int > [ ] Graph = new List < int > [ 10001 ] ; static void dfs ( bool [ ] visit , int src ) { visit [ src ] = true ; node . Add ( src ) ; int len = Graph [ src ] . Count ; for ( int i = 0 ; i < len ; i ++ ) if ( ! visit [ Graph [ src ] [ i ] ] ) dfs ( visit , Graph [ src ] [ i ] ) ; } static void buildGraph ( int [ ] x , int [ ] y , int len ) { for ( int i = 0 ; i < len ; i ++ ) { int p = x [ i ] ; int q = y [ i ] ; Graph [ p ] . Add ( q ) ; Graph [ q ] . Add ( p ) ; } } static int compute ( int n ) { bool [ ] visit = new bool [ n + 5 ] ; Array . Fill ( visit , false ) ; int number_of_nodes = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! visit [ i ] ) { node . Clear ( ) ; dfs ( visit , i ) ; int count = 0 ; foreach ( int it in node ) count += Graph [ ( it ) ] . Count ; count /= 2 ; if ( count == node . Count - 1 ) number_of_nodes ++ ; } } return number_of_nodes ; } static void Main ( string [ ] args ) { int n = 6 ; for ( int i = 0 ; i < 10001 ; i ++ ) { Graph [ i ] = new List < int > ( ) ; } int [ ] x = { 1 , 1 , 4 , 4 , 0 , 0 , 0 , 0 } ; int [ ] y = { 2 , 3 , 5 , 6 , 0 , 0 , 0 , 0 } ; buildGraph ( x , y , n ) ; Console . Write ( compute ( n ) + " ▁ weakly ▁ connected ▁ nodes " ) ; } }

Index/key variables: i, p, q, src
Accumulator variables: count, i, number_of_nodes
Iterator variables: i, it
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int V = 4 ; public class Edge { public int from , weight ; public Edge ( int from , int weight ) { this . from = from ; this . weight = weight ; } } static List < Edge > [ ] edges = new List < Edge > [ V ] ; static void addedge ( int u , int v , int w ) { edges [ v ] . Add ( new Edge ( u , w ) ) ; } static void shortestpath ( int [ , ] dp ) { for ( int i = 0 ; i <= V ; i ++ ) for ( int j = 0 ; j < V ; j ++ ) dp [ i , j ] = - 1 ; dp [ 0 , 0 ] = 0 ; for ( int i = 1 ; i <= V ; i ++ ) { for ( int j = 0 ; j < V ; j ++ ) { for ( int k = 0 ; k < edges [ j ] . Count ; k ++ ) { if ( dp [ i - 1 , edges [ j ] [ k ] . from ] != - 1 ) { int curr_wt = dp [ i - 1 , edges [ j ] [ k ] . from ] + edges [ j ] [ k ] . weight ; if ( dp [ i , j ] == - 1 ) dp [ i , j ] = curr_wt ; else dp [ i , j ] = Math . Min ( dp [ i , j ] , curr_wt ) ; } } } } } static double minAvgWeight ( ) { int [ , ] dp = new int [ V + 1 , V ] ; shortestpath ( dp ) ; double [ ] avg = new double [ V ] ; for ( int i = 0 ; i < V ; i ++ ) avg [ i ] = - 1 ; for ( int i = 0 ; i < V ; i ++ ) { if ( dp [ V , i ] != - 1 ) { for ( int j = 0 ; j < V ; j ++ ) if ( dp [ j , i ] != - 1 ) avg [ i ] = Math . Max ( avg [ i ] , ( ( double ) dp [ V , i ] - dp [ j , i ] ) / ( V - j ) ) ; } } double result = avg [ 0 ] ; for ( int i = 0 ; i < V ; i ++ ) if ( avg [ i ] != - 1 && avg [ i ] < result ) result = avg [ i ] ; return result ; } public static void Main ( String [ ] args ) { for ( int i = 0 ; i < V ; i ++ ) edges [ i ] = new List < Edge > ( ) ; addedge ( 0 , 1 , 1 ) ; addedge ( 0 , 2 , 10 ) ; addedge ( 1 , 2 , 3 ) ; addedge ( 2 , 3 , 2 ) ; addedge ( 3 , 1 , 0 ) ; addedge ( 3 , 0 , 8 ) ; Console . Write ( " { 0 : F5 } " , minAvgWeight ( ) ) ; } }

Index/key variables: V, i, j, k, v
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: Edge, GFG
C# program:
using System ; class GFG { static int findCount ( String s ) { int [ ] freq = new int [ 26 ] ; int [ , ] dp = new int [ 26 , 26 ] ; for ( int i = 0 ; i < s . Length ; ++ i ) { for ( int j = 0 ; j < 26 ; j ++ ) { dp [ j , s [ i ] - ' a ' ] += freq [ j ] ; } freq [ s [ i ] - ' a ' ] ++ ; } int ans = 0 ; for ( int i = 0 ; i < 26 ; i ++ ) ans = Math . Max ( freq [ i ] , ans ) ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 0 ; j < 26 ; j ++ ) { ans = Math . Max ( dp [ i , j ] , ans ) ; } } return ans ; } public static void Main ( String [ ] args ) { String str = " acbab " ; Console . Write ( findCount ( str ) ) ; } }

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 void constructArray ( int N , int K , int X ) { int [ ] ans = new int [ K ] ; ans [ 0 ] = X ; for ( int i = 0 ; i < N ; ++ i ) { Console . Write ( ans [ i % K ] + " ▁ " ) ; } } public static void Main ( string [ ] args ) { int N = 5 , K = 2 , X = 4 ; constructArray ( N , K , X ) ; } }

Index/key variables: K
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void game ( int [ ] v , int n ) { Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! m . ContainsKey ( v [ i ] ) ) m . Add ( v [ i ] , 1 ) ; else m [ v [ i ] ] = m [ v [ i ] ] + 1 ; } int count = 0 ; int check = 0 ; foreach ( KeyValuePair < int , int > i in m ) { if ( i . Value > 1 ) { if ( i . Value >= 4 && i . Value % 2 == 0 ) check ++ ; count ++ ; } } bool flag ; if ( check % 2 != 0 ) flag = false ; if ( check % 2 != 0 ) Console . WriteLine ( " Yes " ) ; else if ( n % 2 == 0 && count % 2 == 0 ) Console . WriteLine ( " No " ) ; else Console . WriteLine ( " Yes " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 3 , 2 , 2 , 3 , 3 , 5 } ; int size = arr . Length ; game ( arr , size ) ; } }

Index/key variables: i
Accumulator variables: check, count, i
Iterator variables: i
Boolean variables: flag
Class/struct names: GFG
C# program:
using System ; class GFG { static int solve ( int [ ] A , int n ) { int i , cnt = 0 , j ; int [ ] parent = new int [ n ] ; int [ ] vis = new int [ n ] ; Array . Fill ( parent , - 1 ) ; Array . Fill ( vis , 0 ) ; for ( i = 0 ; i < n ; i ++ ) { j = i ; if ( parent [ j ] == - 1 ) { while ( parent [ j ] == - 1 ) { parent [ j ] = i ; j = __gcd ( j , A [ j ] ) % n ; } if ( parent [ j ] == i ) { while ( vis [ j ] == 0 ) { vis [ j ] = 1 ; cnt ++ ; j = __gcd ( j , A [ j ] ) % n ; } } } } return cnt ; } static int __gcd ( int a , int b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } static void Main ( ) { int [ ] A = { 1 , 1 , 6 , 2 } ; int n = A . Length ; Console . WriteLine ( solve ( A , n ) ) ; } }

Index/key variables: j, n
Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int N = 10000 ; static List < int > [ ] adj = new List < int > [ N ] ; static int [ ] lvl = new int [ N ] , dist1 = new int [ N ] , dist2 = new int [ N ] ; static void AddEdge ( int u , int v ) { adj [ u ] . Add ( v ) ; adj [ v ] . Add ( u ) ; } static int end1 , end2 , maxi ; static void findFirstEnd ( int u , int p ) { lvl [ u ] = 1 + lvl [ p ] ; if ( lvl [ u ] > maxi ) { maxi = lvl [ u ] ; end1 = u ; } for ( int i = 0 ; i < adj [ u ] . Count ; i ++ ) { if ( adj [ u ] [ i ] != p ) { findFirstEnd ( adj [ u ] [ i ] , u ) ; } } } static void clear ( int n ) { for ( int i = 0 ; i <= n ; i ++ ) { lvl [ i ] = 0 ; } maxi = 0 ; dist1 [ 0 ] = dist2 [ 0 ] = - 1 ; } static void findSecondEnd ( int u , int p ) { lvl [ u ] = 1 + lvl [ p ] ; if ( lvl [ u ] > maxi ) { maxi = lvl [ u ] ; end2 = u ; } for ( int i = 0 ; i < adj [ u ] . Count ; i ++ ) { if ( adj [ u ] [ i ] != p ) { findSecondEnd ( adj [ u ] [ i ] , u ) ; } } } static void findDistancefromFirst ( int u , int p ) { dist1 [ u ] = 1 + dist1 [ p ] ; for ( int i = 0 ; i < adj [ u ] . Count ; i ++ ) { if ( adj [ u ] [ i ] != p ) { findDistancefromFirst ( adj [ u ] [ i ] , u ) ; } } } static void findDistancefromSecond ( int u , int p ) { dist2 [ u ] = 1 + dist2 [ p ] ; for ( int i = 0 ; i < adj [ u ] . Count ; i ++ ) { if ( adj [ u ] [ i ] != p ) { findDistancefromSecond ( adj [ u ] [ i ] , u ) ; } } } static void findNodes ( ) { int n = 5 ; AddEdge ( 1 , 2 ) ; AddEdge ( 1 , 3 ) ; AddEdge ( 3 , 4 ) ; AddEdge ( 3 , 5 ) ; findFirstEnd ( 1 , 0 ) ; clear ( n ) ; findSecondEnd ( end1 , 0 ) ; findDistancefromFirst ( end1 , 0 ) ; findDistancefromSecond ( end2 , 0 ) ; for ( int i = 1 ; i <= n ; i ++ ) { int x = dist1 [ i ] ; int y = dist2 [ i ] ; if ( x >= y ) { Console . Write ( end1 + " ▁ " ) ; } else { Console . Write ( end2 + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { for ( int i = 0 ; i < N ; i ++ ) { adj [ i ] = new List < int > ( ) ; } findNodes ( ) ; } }

Index/key variables: N, i, p, u, v
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { class Node { public int data ; public Node next ; } ; static Node push ( Node head_ref , int new_data ) { Node new_node = new Node ( ) ; new_node . data = new_data ; new_node . next = head_ref ; head_ref = new_node ; return head_ref ; } static int digitSum ( int num ) { int sum = 0 ; while ( num > 0 ) { sum += ( num % 10 ) ; num /= 10 ; } return sum ; } static void sumAndProduct ( Node head_ref ) { int prod = 1 ; int sum = 0 ; Node ptr = head_ref ; while ( ptr != null ) { if ( ( digitSum ( ptr . data ) % 2 != 1 ) ) { prod *= ptr . data ; sum += ptr . data ; } ptr = ptr . next ; } Console . Write ( " Sum ▁ = ▁ " + sum + " STRNEWLINE " ) ; Console . Write ( " Product ▁ = ▁ " + prod ) ; } public static void Main ( String [ ] args ) { Node head = null ; head = push ( head , 13 ) ; head = push ( head , 6 ) ; head = push ( head , 8 ) ; head = push ( head , 16 ) ; head = push ( head , 15 ) ; sumAndProduct ( head ) ; } }

Accumulator variables: num, prod, sum
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static string ShortestPalindrome ( string s ) { int n = s . Length ; List < string > v = new List < string > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int l = i ; int r = i ; string ans1 = " " ; string ans2 = " " ; while ( l >= 0 && r < n && s [ l ] == s [ r ] ) { ans1 += s [ l ] ; l -- ; r ++ ; } l = i - 1 ; r = i ; while ( l >= 0 && r < n && s [ l ] == s [ r ] ) { ans2 += s [ l ] ; l -- ; r ++ ; } v . Add ( ans1 ) ; v . Add ( ans2 ) ; } string ans = v [ 0 ] ; for ( int i = 0 ; i < v . Count ; i ++ ) { if ( v [ i ] != " " ) { if ( ans [ 0 ] >= v [ i ] [ 0 ] ) { ans = v [ i ] ; } } } return ans ; } static public void Main ( ) { string s = " geeksforgeeks " ; Console . WriteLine ( ShortestPalindrome ( s ) ) ; } }

Index/key variables: i, l, r
Accumulator variables: ans1, ans2, i, l, r
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Linq ; using System . Collections . Generic ; class GFG { static int getMinimumOps ( List < int > ar ) { int n = ar . Count ; int small = ar . Min ( ) ; int large = ar . Max ( ) ; int [ , ] dp = new int [ n , large + 1 ] ; for ( int j = small ; j <= large ; j ++ ) { dp [ 0 , j ] = Math . Abs ( ar [ 0 ] - j ) ; } for ( int i = 1 ; i < n ; i ++ ) { int minimum = int . MaxValue ; for ( int j = small ; j <= large ; j ++ ) { minimum = Math . Min ( minimum , dp [ i - 1 , j ] ) ; dp [ i , j ] = minimum + Math . Abs ( ar [ i ] - j ) ; } } int ans = int . MaxValue ; for ( int j = small ; j <= large ; j ++ ) { ans = Math . Min ( ans , dp [ n - 1 , j ] ) ; } return ans ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 1 , 4 , 3 } ; List < int > ar = new List < int > ( arr ) ; Console . WriteLine ( getMinimumOps ( ar ) ) ; } }

Index/key variables: i
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int getMinimumOps ( int [ ] ar , int k ) { int n = ar . Length ; int [ , ] dp = new int [ n , k + 1 ] ; dp [ 0 , 1 ] = 0 ; for ( int i = 1 ; i < n ; i ++ ) { int maxGroups = Math . Min ( k , i + 1 ) ; for ( int j = 1 ; j <= maxGroups ; j ++ ) { dp [ i , j ] = int . MaxValue ; if ( j == 1 ) { int [ ] freq = new int [ 100000 ] ; int freqOfMode = 0 ; for ( int it = 0 ; it <= i ; it ++ ) { freq [ ar [ it ] ] ++ ; int newElementFreq = freq [ ar [ it ] ] ; if ( newElementFreq > freqOfMode ) freqOfMode = newElementFreq ; } dp [ i , 1 ] = ( i + 1 ) - freqOfMode ; } else { int [ ] freq = new int [ 100000 ] ; int freqOfMode = 0 ; for ( int it = i ; it >= j - 1 ; it -- ) { freq [ ar [ it ] ] ++ ; int newElementFreq = freq [ ar [ it ] ] ; if ( newElementFreq > freqOfMode ) freqOfMode = newElementFreq ; int elementsToChange = i - it + 1 ; elementsToChange -= freqOfMode ; dp [ i , j ] = Math . Min ( dp [ it - 1 , j - 1 ] + elementsToChange , dp [ i , j ] ) ; } } } } return dp [ n - 1 , k ] ; } public static void Main ( String [ ] args ) { int k = 3 ; int [ ] ar = { 3 , 1 , 3 , 3 , 2 , 1 , 8 , 5 } ; Console . WriteLine ( getMinimumOps ( ar , k ) ) ; } }

Index/key variables: it
Accumulator variables: elementsToChange, i, it, j
Iterator variables: i, it, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int __gcd ( int a , int b ) { if ( b == 0 ) return a ; return __gcd ( b , a % b ) ; } static int lcm ( int x , int y ) { int temp = ( x * y ) / __gcd ( x , y ) ; return temp ; } static void findNumbers ( int [ ] a , int n , int [ ] b , int m ) { int lcmA = 1 , gcdB = 0 ; for ( int i = 0 ; i < n ; i ++ ) lcmA = lcm ( lcmA , a [ i ] ) ; for ( int i = 0 ; i < m ; i ++ ) gcdB = __gcd ( gcdB , b [ i ] ) ; if ( gcdB % lcmA != 0 ) { Console . Write ( " - 1" ) ; return ; } int num = lcmA ; while ( num <= gcdB ) { if ( gcdB % num == 0 ) Console . Write ( num + " ▁ " ) ; num += lcmA ; } } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 2 , 4 } ; int [ ] b = { 16 , 32 , 64 } ; int n = a . Length ; int m = b . Length ; findNumbers ( a , n , b , m ) ; } }

Index/key variables: i
Accumulator variables: i, num
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int binomialCoeff ( int n , int k ) { int res = 1 ; if ( k > n - k ) k = n - k ; for ( int i = 0 ; i < k ; ++ i ) { res *= ( n - i ) ; res /= ( i + 1 ) ; } return res ; } static int power ( int x , int y ) { int res = 1 ; while ( y > 0 ) { if ( ( y & 1 ) == 1 ) res = res * x ; y = y >> 1 ; x = x * x ; } return res ; } static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static void FindProbability ( int n ) { int up = binomialCoeff ( 2 * n , n ) ; int down = power ( 2 , 2 * n ) ; int g = gcd ( up , down ) ; up /= g ; down /= g ; Console . WriteLine ( up + " / " + down ) ; } public static void Main ( String [ ] args ) { int N = 8 ; FindProbability ( N ) ; } }

Accumulator variables: down, res, up
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void Main ( String [ ] args ) { int N = 4 , i , j , min ; Console . WriteLine ( " Value ▁ of ▁ N : ▁ " + N ) ; for ( i = 1 ; i <= N ; i ++ ) { for ( j = 1 ; j <= N ; j ++ ) { min = i < j ? i : j ; Console . Write ( N - min + 1 ) ; } for ( j = N - 1 ; j >= 1 ; j -- ) { min = i < j ? i : j ; Console . Write ( N - min + 1 ) ; } Console . WriteLine ( ) ; } for ( i = N - 1 ; i >= 1 ; i -- ) { for ( j = 1 ; j <= N ; j ++ ) { min = i < j ? i : j ; Console . Write ( N - min + 1 ) ; } for ( j = N - 1 ; j >= 1 ; j -- ) { min = i < j ? i : j ; Console . Write ( N - min + 1 ) ; } Console . WriteLine ( ) ; } } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool checkPerfectSquare ( double n ) { double d = Math . Sqrt ( n ) ; if ( d * d == n ) return true ; return false ; } static int largestPerfectSquareNumber ( int [ ] a , double n ) { int maxi = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( checkPerfectSquare ( a [ i ] ) ) maxi = Math . Max ( a [ i ] , maxi ) ; } return maxi ; } public static void Main ( ) { int [ ] a = { 16 , 20 , 25 , 2 , 3 , 10 } ; double n = a . Length ; Console . WriteLine ( largestPerfectSquareNumber ( a , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void convert ( int n , int [ ] a ) { int z = a [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( a [ i ] > z ) z = a [ i ] ; } z = z + 1 ; int [ ] ff = new int [ z ] ; for ( int i = 0 ; i < n ; i ++ ) { ff [ a [ i ] ] += 1 ; } int cc = 0 ; for ( int i = 0 ; i < z ; i ++ ) { cc += ( ff [ i ] / 4 ) ; ff [ i ] = ff [ i ] % 4 ; } int vv = 0 ; for ( int i = 0 ; i < z ; i ++ ) { if ( ff [ i ] >= 2 ) vv += 1 ; } cc += ( vv / 2 ) ; Console . WriteLine ( cc ) ; } static public void Main ( ) { int n = 4 ; int [ ] a = { 1 , 2 , 1 , 2 } ; convert ( n , a ) ; } }

Index/key variables: i, z
Accumulator variables: cc, i, vv
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int gcd ( int a , int b ) { return b == 0 ? a : gcd ( b , a % b ) ; } static int find_LCM ( int x , int y ) { return ( x * y ) / gcd ( x , y ) ; } static int CountPairs ( int n , int m , int A , int B ) { int cnt = 0 ; int lcm = find_LCM ( A , B ) ; for ( int i = 1 ; i <= n ; i ++ ) cnt += ( m + ( i % lcm ) ) / lcm ; return cnt ; } public static void Main ( ) { int n = 60 , m = 90 , A = 5 , B = 10 ; Console . WriteLine ( CountPairs ( n , m , A , B ) ) ; } }

Accumulator variables: cnt, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void sortArr ( int [ ] arr , int n , int min , int max ) { int m = max - min + 1 ; int [ ] c = new int [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { c [ arr [ i ] - min ] ++ ; } for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < c [ i ] ; j ++ ) { Console . Write ( ( i + min ) + " ▁ " ) ; } } } static public void Main ( ) { int [ ] arr = { 10 , 10 , 1 , 4 , 4 , 100 , 0 } ; int min = 0 , max = 100 ; int n = arr . Length ; sortArr ( arr , n , min , max ) ; } }

Index/key variables: i, m
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class GFG { public static bool isPossible ( double D , int [ ] arr , int N , int K ) { int used = 0 ; for ( int i = 0 ; i < N - 1 ; ++ i ) { used += ( int ) ( ( arr [ i + 1 ] - arr [ i ] ) / D ) ; } return used <= K ; } public static double minMaxDist ( int [ ] stations , int N , int K ) { double low = 0 , high = 1e8 ; while ( high - low > 1e-6 ) { double mid = ( low + high ) / 2.0 ; if ( isPossible ( mid , stations , N , K ) ) { high = mid ; } else { low = mid ; } } return low ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; int K = 9 ; int N = arr . Length ; Console . Write ( " { 0 : F1 } " , minMaxDist ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: used
Iterator variables: i
Class/struct names: GFG