dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int check ( int N ) { if ( N == 0 || ( N & ( N - 1 ) ) != 0 ) return 0 ; return 1 ; } static void build_seg_tree ( int ss , int se , int si , int [ ] tree , int [ ] arr ) { if ( ss == se ) { tree [ si ] = check ( arr [ ss ] ) ; return ; } int mid = ( ss + se ) / 2 ; build_seg_tree ( ss , mid , 2 * si + 1 , tree , arr ) ; build_seg_tree ( mid + 1 , se , 2 * si + 2 , tree , arr ) ; tree [ si ] = tree [ 2 * si + 1 ] + tree [ 2 * si + 2 ] ; } static void update ( int ss , int se , int si , int X , int V , int [ ] tree , int [ ] arr ) { if ( ss == se ) { if ( ss == X ) { arr [ X ] = V ; tree [ si ] = check ( V ) ; } return ; } int mid = ( ss + se ) / 2 ; if ( X <= mid ) update ( ss , mid , 2 * si + 1 , X , V , tree , arr ) ; else update ( mid + 1 , se , 2 * si + 2 , X , V , tree , arr ) ; tree [ si ] = tree [ 2 * si + 1 ] + tree [ 2 * si + 2 ] ; } static int query ( int l , int r , int ss , int se , int si , int [ ] tree ) { if ( r < ss l > se ) return 0 ; if ( l <= ss && r >= se ) return tree [ si ] ; int mid = ( ss + se ) / 2 ; return query ( l , r , ss , mid , 2 * si + 1 , tree ) + query ( l , r , mid + 1 , se , 2 * si + 2 , tree ) ; } static void Query ( int [ ] arr , int N , List < List < int > > Q ) { int [ ] tree = new int [ 4 * N ] ; build_seg_tree ( 0 , N - 1 , 0 , tree , arr ) ; for ( int i = 0 ; i < ( int ) Q . Count ; i ++ ) { if ( Q [ i ] [ 0 ] == 1 ) Console . Write ( query ( Q [ i ] [ 1 ] , Q [ i ] [ 2 ] , 0 , N - 1 , 0 , tree ) + " ▁ " ) ; else update ( 0 , N - 1 , 0 , Q [ i ] [ 1 ] , Q [ i ] [ 2 ] , tree , arr ) ; } } static void Main ( ) { int [ ] arr = { 12 , 11 , 16 , 2 , 32 } ; List < List < int > > Q = new List < List < int > > ( ) ; Q . Add ( new List < int > ( new int [ ] { 1 , 0 , 2 } ) ) ; Q . Add ( new List < int > ( new int [ ] { 2 , 4 , 24 } ) ) ; Q . Add ( new List < int > ( new int [ ] { 1 , 1 , 4 } ) ) ; int N = arr . Length ; Query ( arr , N , Q ) ; } }

Index/key variables: X, i, si, ss
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isGreaterEqual ( int N , int X ) { return ( N * ( N + 1 ) / 2 ) >= X ; } static int minimumPossible ( int X ) { int low = 1 , high = X , res = - 1 ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( isGreaterEqual ( mid , X ) ) { res = mid ; high = mid - 1 ; } else low = mid + 1 ; } return res ; } static public void Main ( ) { int X = 14 ; Console . Write ( minimumPossible ( X ) ) ; } }

Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class GFG { class pair { public int x , y ; public pair ( int x , int y ) { this . x = x ; this . y = y ; } } static int m , n ; static int minStep ( int [ , ] mat ) { m = mat . GetLength ( 0 ) ; n = mat . GetLength ( 1 ) ; int [ ] dx = { 1 , - 1 , 0 , 0 } ; int [ ] dy = { 0 , 0 , 1 , - 1 } ; Queue < pair > pQ = new Queue < pair > ( ) ; Queue < pair > fQ = new Queue < pair > ( ) ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) { if ( mat [ i , j ] == 2 ) fQ . Enqueue ( new pair ( i , j ) ) ; else if ( mat [ i , j ] == 1 ) { if ( border ( i , j ) ) return 0 ; pQ . Enqueue ( new pair ( i , j ) ) ; } } int depth = 0 ; bool [ , ] visited = new bool [ n , m ] ; while ( pQ . Count != 0 ) { depth ++ ; for ( int i = pQ . Count ; i > 0 ; i -- ) { pair pos = pQ . Peek ( ) ; pQ . Dequeue ( ) ; if ( mat [ pos . x , pos . y ] == 2 ) continue ; for ( int j = 0 ; j < 4 ; j ++ ) { int x = pos . x + dx [ j ] ; int y = pos . y + dy [ j ] ; if ( valid ( x , y ) && mat [ x , y ] != 2 && ! visited [ x , y ] ) { visited [ x , y ] = true ; pQ . Enqueue ( new pair ( x , y ) ) ; if ( border ( x , y ) ) return depth ; } } } for ( int i = fQ . Count ; i > 0 ; i -- ) { pair pos = fQ . Peek ( ) ; fQ . Dequeue ( ) ; for ( int j = 0 ; j < 4 ; j ++ ) { int x = pos . x + dx [ j ] ; int y = pos . y + dy [ j ] ; if ( valid ( x , y ) && mat [ x , y ] != 2 ) { mat [ x , y ] = 2 ; fQ . Enqueue ( new pair ( x , y ) ) ; } } } } return - 1 ; } static bool valid ( int x , int y ) { return ( x >= 0 && x < m && y >= 0 && y < n ) ; } static bool border ( int x , int y ) { return ( x == 0 x == m - 1 y == 0 y == n - 1 ) ; } public static void Main ( String [ ] args ) { int [ , ] grid = { { 0 , 0 , 0 , 0 } , { 2 , 0 , 0 , 0 } , { 2 , 1 , 0 , 0 } , { 2 , 2 , 0 , 0 } } ; Console . WriteLine ( minStep ( grid ) ) ; } }

Index/key variables: j
Accumulator variables: depth, i, j
Iterator variables: i, j
Class/struct names: GFG, pair
C# program:
using System ; class GFG { static int findSum ( int [ ] arr , int n ) { Array . Sort ( arr ) ; int sum = arr [ 0 ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( arr [ i ] != arr [ i + 1 ] ) { sum = sum + arr [ i + 1 ] ; } } return sum ; } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 1 , 1 , 4 , 5 , 6 } ; int n = arr . Length ; Console . WriteLine ( findSum ( arr , n ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int xorSubsequence ( int [ ] a , int n , int k ) { int ans = 0 ; int [ ] dp = new int [ n ] ; dp [ 0 ] = 1 ; for ( int i = 1 ; i < n ; i ++ ) { for ( int j = i - 1 ; j >= 0 ; j -- ) { if ( ( a [ i ] ^ a [ j ] ) == k ) dp [ i ] = Math . Max ( dp [ i ] , dp [ j ] + 1 ) ; } ans = Math . Max ( ans , dp [ i ] ) ; dp [ i ] = Math . Max ( 1 , dp [ i ] ) ; } return ans >= 2 ? ans : 0 ; } static void Main ( ) { int [ ] arr = { 3 , 2 , 4 , 3 , 5 } ; int K = 1 ; int N = arr . Length ; Console . WriteLine ( xorSubsequence ( arr , N , K ) ) ; } }

Index/key variables: i, j, n
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static char MARKER = ' $ ' ; public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; } } ; public static String dupSubUtil ( Node root , HashSet < String > subtrees ) { String s = " " ; if ( root == null ) return s + MARKER ; String lStr = dupSubUtil ( root . left , subtrees ) ; if ( lStr . Equals ( s ) ) return s ; String rStr = dupSubUtil ( root . right , subtrees ) ; if ( rStr . Equals ( s ) ) return s ; s = s + root . data + lStr + rStr ; if ( s . Length > 3 && subtrees . Contains ( s ) ) return " " ; subtrees . Add ( s ) ; return s ; } public static String dupSub ( Node root ) { HashSet < String > subtrees = new HashSet < String > ( ) ; return dupSubUtil ( root , subtrees ) ; } public static void Main ( String [ ] args ) { Node root = new Node ( ' A ' ) ; root . left = new Node ( ' B ' ) ; root . right = new Node ( ' C ' ) ; root . left . left = new Node ( ' D ' ) ; root . left . right = new Node ( ' E ' ) ; root . right . right = new Node ( ' B ' ) ; root . right . right . right = new Node ( ' E ' ) ; root . right . right . left = new Node ( ' D ' ) ; String str = dupSub ( root ) ; if ( str . Equals ( " " ) ) Console . Write ( " ▁ Yes ▁ " ) ; else Console . Write ( " ▁ No ▁ " ) ; } }

Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int getCount ( int rows , int columns , int [ , ] sides ) { int res = 0 ; Dictionary < double , int > ratio = new Dictionary < double , int > ( ) ; for ( int i = 0 ; i < rows ; i ++ ) { double rectRatio = ( double ) sides [ i , 0 ] / sides [ i , 1 ] ; if ( ! ratio . ContainsKey ( rectRatio ) ) { ratio [ rectRatio ] = 0 ; } ratio [ rectRatio ] = ratio [ rectRatio ] + 1 ; } foreach ( KeyValuePair < double , int > p in ratio ) { int val = p . Value ; if ( val > 1 ) { res += ( val * ( val - 1 ) ) / 2 ; } } return res ; } public static void Main ( string [ ] args ) { int [ , ] A = { { 4 , 8 } , { 10 , 20 } , { 15 , 30 } , { 3 , 6 } } ; int columns = 2 ; int rows = 4 ; Console . WriteLine ( getCount ( rows , columns , A ) ) ; } }

Index/key variables: rectRatio
Accumulator variables: i, res
Iterator variables: i, p
Class/struct names: GFG
C# program:
using System ; class GFG { static int firstNonRepeating ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { int j ; for ( j = 0 ; j < n ; j ++ ) if ( i != j && arr [ i ] == arr [ j ] ) break ; if ( j == n ) return arr [ i ] ; } return - 1 ; } public static void Main ( ) { int [ ] arr = { 9 , 4 , 9 , 6 , 7 , 4 } ; int n = arr . Length ; Console . Write ( firstNonRepeating ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int firstNonRepeating ( int [ ] arr , int n ) { Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( m . ContainsKey ( arr [ i ] ) ) { var val = m [ arr [ i ] ] ; m . Remove ( arr [ i ] ) ; m . Add ( arr [ i ] , val + 1 ) ; } else { m . Add ( arr [ i ] , 1 ) ; } } for ( int i = 0 ; i < n ; i ++ ) if ( m [ arr [ i ] ] == 1 ) return arr [ i ] ; return - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 9 , 4 , 9 , 6 , 7 , 4 } ; int n = arr . Length ; Console . WriteLine ( firstNonRepeating ( arr , n ) ) ; } }

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 void firstNonRepeating ( int [ ] arr , int n ) { Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( m . ContainsKey ( arr [ i ] ) ) { var val = m [ arr [ i ] ] ; m . Remove ( arr [ i ] ) ; m . Add ( arr [ i ] , val + 1 ) ; } else { m . Add ( arr [ i ] , 1 ) ; } } foreach ( KeyValuePair < int , int > x in m ) { if ( x . Value == 1 ) { Console . Write ( x . Key + " ▁ " ) ; } } } public static void Main ( String [ ] args ) { int [ ] arr = { 9 , 4 , 9 , 6 , 7 , 4 } ; int n = arr . Length ; firstNonRepeating ( arr , n ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { static void minOperationNeeded ( char [ ] str ) { str = modstring ( str ) ; int N = str . Length ; int [ ] res = new int [ 256 ] ; for ( int i = 0 ; i < N ; ++ i ) { res [ str [ i ] ] += 1 ; } res [ str [ 0 ] ] -= 1 ; res [ str [ N - 1 ] ] -= 1 ; int ans = Int32 . MaxValue ; for ( int i = 0 ; i < N ; ++ i ) { ans = Math . Min ( ans , res [ str [ i ] ] ) ; } Console . WriteLine ( ( ans + 1 ) + " STRNEWLINE " ) ; } private static char [ ] modstring ( char [ ] str ) { string s = " " ; bool b = true ; for ( int i = 1 ; i < str . Length ; ++ i ) { if ( str [ i - 1 ] != str [ i ] ) b = true ; if ( b ) { s += str [ i - 1 ] ; b = false ; } } return s . ToCharArray ( ) ; } public static void Main ( ) { string str = " ABCDABCDABCDA " ; minOperationNeeded ( str . ToCharArray ( ) ) ; } }

Index/key variables: i
Accumulator variables: s
Iterator variables: i
Boolean variables: b
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class Node { public int data ; public List < Node > child ; public Node ( int x ) { this . data = x ; this . child = new List < Node > ( ) ; } } public class GFG { static void printPath ( List < int > vec ) { foreach ( int ele in vec ) { Console . Write ( ele + " ▁ " ) ; } Console . WriteLine ( ) ; } static void printAllRootToLeafPaths ( Node root , List < int > vec ) { if ( root == null ) return ; vec . Add ( root . data ) ; if ( root . child . Count == 0 ) { printPath ( vec ) ; vec . RemoveAt ( vec . Count - 1 ) ; return ; } for ( int i = 0 ; i < root . child . Count ; i ++ ) { printAllRootToLeafPaths ( root . child [ i ] , vec ) ; } vec . RemoveAt ( vec . Count - 1 ) ; } static void printAllRootToLeafPaths ( Node root ) { if ( root == null ) return ; List < int > vec = new List < int > ( ) ; printAllRootToLeafPaths ( root , vec ) ; } static public void Main ( ) { Node root = new Node ( 1 ) ; ( root . child ) . Add ( new Node ( 2 ) ) ; ( root . child ) . Add ( new Node ( 3 ) ) ; ( root . child [ 0 ] . child ) . Add ( new Node ( 4 ) ) ; ( root . child [ 1 ] . child ) . Add ( new Node ( 5 ) ) ; ( root . child [ 1 ] . child ) . Add ( new Node ( 6 ) ) ; ( root . child [ 1 ] . child [ 1 ] . child ) . Add ( new Node ( 7 ) ) ; ( root . child [ 1 ] . child [ 1 ] . child ) . Add ( new Node ( 8 ) ) ; printAllRootToLeafPaths ( root ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: ele, i
Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int minimumDeletions ( String s ) { int n = s . Length ; int [ ] zeroCount = new int [ n ] ; zeroCount [ n - 1 ] = ( s [ n - 1 ] == '0' ) ? 1 : 0 ; for ( int i = n - 2 ; i >= 0 ; i -- ) zeroCount [ i ] = ( s [ i ] == '0' ) ? zeroCount [ i + 1 ] + 1 : zeroCount [ i + 1 ] ; int oneCount = 0 ; int ans = int . MaxValue ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) { ans = Math . Min ( ans , oneCount + zeroCount [ i ] ) ; oneCount ++ ; } } ans = Math . Min ( ans , oneCount ) ; return ( ans == int . MaxValue ) ? 0 : ans ; } public static void Main ( String [ ] args ) { String str = "00101101" ; Console . WriteLine ( minimumDeletions ( str ) ) ; } }

Index/key variables: i, n
Accumulator variables: i, oneCount
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static void printPairs ( int [ ] arr , int n ) { List < int > v = new List < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = i + 1 ; j < n ; j ++ ) if ( Math . Abs ( arr [ i ] ) == Math . Abs ( arr [ j ] ) ) v . Add ( Math . Abs ( arr [ i ] ) ) ; if ( v . Count == 0 ) return ; v . Sort ( ) ; for ( int i = 0 ; i < v . Count ; i ++ ) Console . Write ( - v [ i ] + " ▁ " + v [ i ] ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 8 , 9 , - 4 , 1 , - 1 , - 8 , - 9 } ; int n = arr . Length ; printPairs ( arr , n ) ; } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System . Collections . Generic ; using System ; class GFG { static bool canPairs ( int [ ] ar , int k ) { if ( ar . Length % 2 == 1 ) return false ; Dictionary < Double , int > hm = new Dictionary < Double , int > ( ) ; for ( int i = 0 ; i < ar . Length ; i ++ ) { int rem = ( ( ar [ i ] % k ) + k ) % k ; if ( ! hm . ContainsKey ( rem ) ) { hm [ rem ] = 0 ; } hm [ rem ] ++ ; } for ( int i = 0 ; i < ar . Length ; i ++ ) { int rem = ( ( ar [ i ] % k ) + k ) % k ; if ( 2 * rem == k ) { if ( hm [ rem ] % 2 == 1 ) return false ; } else if ( rem == 0 ) { if ( hm [ rem ] % 2 == 1 ) return false ; } else { if ( hm [ k - rem ] != hm [ rem ] ) return false ; } } return true ; } public static void Main ( ) { int [ ] arr = { 92 , 75 , 65 , 48 , 45 , 35 } ; int k = 10 ; bool ans = canPairs ( arr , k ) ; if ( ans ) Console . WriteLine ( " True " ) ; else Console . WriteLine ( " False " ) ; } }

Index/key variables: i, rem
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; class GFG { static void subarrayDivisibleByK ( int [ ] arr , int n , int k ) { int [ ] mp = new int [ 1000 ] ; int s = 0 , e = 0 , maxs = 0 , maxe = 0 ; mp [ arr [ 0 ] % k ] ++ ; for ( int i = 1 ; i < n ; i ++ ) { int mod = arr [ i ] % k ; while ( mp [ k - mod ] != 0 || ( mod == 0 && mp [ mod ] != 0 ) ) { mp [ arr [ s ] % k ] -- ; s ++ ; } mp [ mod ] ++ ; e ++ ; if ( ( e - s ) > ( maxe - maxs ) ) { maxe = e ; maxs = s ; } } Console . Write ( " The ▁ maximum ▁ size ▁ is ▁ " + ( maxe - maxs + 1 ) + " ▁ and ▁ the ▁ subarray ▁ is ▁ as ▁ follows STRNEWLINE " ) ; for ( int i = maxs ; i <= maxe ; i ++ ) Console . Write ( arr [ i ] + " ▁ " ) ; } public static void Main ( ) { int k = 3 ; int [ ] arr = { 5 , 10 , 15 , 20 , 25 } ; int n = arr . Length ; subarrayDivisibleByK ( arr , n , k ) ; } }

Index/key variables: i, mod, s
Accumulator variables: e, i, s
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; public class GFG { static bool findTriplet ( int [ ] a1 , int [ ] a2 , int [ ] a3 , int n1 , int n2 , int n3 , int sum ) { for ( int i = 0 ; i < n1 ; i ++ ) for ( int j = 0 ; j < n2 ; j ++ ) for ( int k = 0 ; k < n3 ; k ++ ) if ( a1 [ i ] + a2 [ j ] + a3 [ k ] == sum ) return true ; return false ; } static public void Main ( ) { int [ ] a1 = { 1 , 2 , 3 , 4 , 5 } ; int [ ] a2 = { 2 , 3 , 6 , 1 , 2 } ; int [ ] a3 = { 3 , 2 , 4 , 5 , 6 } ; int sum = 9 ; int n1 = a1 . Length ; int n2 = a2 . Length ; int n3 = a3 . Length ; if ( findTriplet ( a1 , a2 , a3 , n1 , n2 , n3 , sum ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static bool findTriplet ( int [ ] a1 , int [ ] a2 , int [ ] a3 , int n1 , int n2 , int n3 , int sum ) { HashSet < int > s = new HashSet < int > ( ) ; for ( int i = 0 ; i < n1 ; i ++ ) { s . Add ( a1 [ i ] ) ; } List < int > al = new List < int > ( s ) ; for ( int i = 0 ; i < n2 ; i ++ ) { for ( int j = 0 ; j < n3 ; j ++ ) { if ( al . Contains ( sum - a2 [ i ] - a3 [ j ] ) & al . IndexOf ( sum - a2 [ i ] - a3 [ j ] ) != al [ al . Count - 1 ] ) { return true ; } } } return false ; } public static void Main ( String [ ] args ) { int [ ] a1 = { 1 , 2 , 3 , 4 , 5 } ; int [ ] a2 = { 2 , 3 , 6 , 1 , 2 } ; int [ ] a3 = { 3 , 2 , 4 , 5 , 6 } ; int sum = 9 ; int n1 = a1 . Length ; int n2 = a2 . Length ; int n3 = a3 . Length ; if ( findTriplet ( a1 , a2 , a3 , n1 , n2 , n3 , sum ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countSum ( int [ ] a , int n , int sum ) { int i , j , k ; int l ; int count = 0 ; for ( i = 0 ; i < n - 3 ; i ++ ) { for ( j = i + 1 ; j < n - 2 ; j ++ ) { int req = sum - a [ i ] - a [ j ] ; Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( k = j + 1 ; k < n ; k ++ ) if ( m . ContainsKey ( a [ k ] ) ) { m [ a [ k ] ] ++ ; } else { m . Add ( a [ k ] , 1 ) ; } int twice_count = 0 ; for ( k = j + 1 ; k < n ; k ++ ) { if ( m . ContainsKey ( req - a [ k ] ) ) twice_count += m [ req - a [ k ] ] ; if ( req - a [ k ] == a [ k ] ) twice_count -- ; } count += twice_count / 2 ; } } return count ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 5 , 3 , 1 , 2 , 4 } ; int S = 13 ; int N = arr . Length ; Console . Write ( countSum ( arr , N , S ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: count, i, j, k, twice_count
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; public class ArrayElements { public class pair { private readonly ArrayElements outerInstance ; public int first , second ; public pair ( ArrayElements outerInstance , int f , int s ) { this . outerInstance = outerInstance ; first = f ; second = s ; } } public virtual bool findPairs ( int [ ] arr ) { Dictionary < int , pair > map = new Dictionary < int , pair > ( ) ; int n = arr . Length ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = i + 1 ; j < n ; ++ j ) { int sum = arr [ i ] + arr [ j ] ; if ( ! map . ContainsKey ( sum ) ) { map [ sum ] = new pair ( this , i , j ) ; } else { pair p = map [ sum ] ; Console . WriteLine ( " ( " + arr [ p . first ] + " , ▁ " + arr [ p . second ] + " ) ▁ and ▁ ( " + arr [ i ] + " , ▁ " + arr [ j ] + " ) " ) ; return true ; } } } return false ; } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 3 , 4 , 7 , 1 , 2 , 9 , 8 } ; ArrayElements a = new ArrayElements ( ) ; a . findPairs ( arr ) ; } }

Index/key variables: i, j, sum
Iterator variables: i, j
Class/struct names: ArrayElements, pair
C# program:
using System ; using System . Collections . Generic ; class GFG { static String check ( int [ ] arr , int n ) { for ( int i = 0 ; i < n ; i ++ ) { Dictionary < int , int > hm = new Dictionary < int , int > ( ) ; int count = 0 ; for ( int j = i ; j < n ; j ++ ) { if ( hm . ContainsKey ( ( arr [ j ] ) ) ) hm [ arr [ j ] ] ++ ; else hm . Add ( arr [ j ] , 1 ) ; if ( hm [ arr [ j ] ] == 1 ) count ++ ; if ( hm [ arr [ j ] ] == 2 ) count -- ; if ( count == 0 ) return " No " ; } } return " Yes " ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 2 , 1 } ; int N = arr . Length ; Console . WriteLine ( check ( arr , N ) ) ; } }

Index/key variables: j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static void countPairsWithDiffK ( int [ ] arr , int N , int K ) { int [ ] vis = new int [ N ] ; int count = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( vis [ i ] == 1 ) continue ; for ( int j = i + 1 ; j < N ; j ++ ) { if ( vis [ j ] == 1 ) continue ; if ( Math . Abs ( arr [ i ] - arr [ j ] ) >= K ) { count ++ ; vis [ i ] = 1 ; vis [ j ] = 1 ; break ; } } } Console . Write ( count ) ; } public static void Main ( ) { int [ ] arr = { 1 , 3 , 3 , 5 } ; int N = arr . Length ; int K = 2 ; countPairsWithDiffK ( arr , N , K ) ; } }

Index/key variables: N, i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; public class Node { public int data ; public Node left , right ; public Node ( int data ) { this . data = data ; left = right = null ; } } public class BinaryTree { public Node a , b ; public virtual bool areMirror ( Node a , Node b ) { if ( a == null && b == null ) { return true ; } if ( a == null b == null ) { return false ; } return a . data == b . data && areMirror ( a . left , b . right ) && areMirror ( a . right , b . left ) ; } public static void Main ( string [ ] args ) { BinaryTree tree = new BinaryTree ( ) ; Node a = new Node ( 1 ) ; Node b = new Node ( 1 ) ; a . left = new Node ( 2 ) ; a . right = new Node ( 3 ) ; a . left . left = new Node ( 4 ) ; a . left . right = new Node ( 5 ) ; b . left = new Node ( 3 ) ; b . right = new Node ( 2 ) ; b . right . left = new Node ( 5 ) ; b . right . right = new Node ( 4 ) ; if ( tree . areMirror ( a , b ) == true ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }

Class/struct names: BinaryTree, Node
C# program:
using System ; using System . Collections . Generic ; public class MaxLenZeroSumSub { static int maxLen ( int [ ] arr ) { Dictionary < int , int > hM = new Dictionary < int , int > ( ) ; int sum = 0 ; int max_len = 0 ; for ( int i = 0 ; i < arr . GetLength ( 0 ) ; i ++ ) { sum += arr [ i ] ; if ( arr [ i ] == 0 && max_len == 0 ) max_len = 1 ; if ( sum == 0 ) max_len = i + 1 ; int prev_i = 0 ; if ( hM . ContainsKey ( sum ) ) { prev_i = hM [ sum ] ; } if ( hM . ContainsKey ( sum ) ) max_len = Math . Max ( max_len , i - prev_i ) ; else { if ( hM . ContainsKey ( sum ) ) hM . Remove ( sum ) ; hM . Add ( sum , i ) ; } } return max_len ; } public static void Main ( ) { int [ ] arr = { 15 , - 2 , 2 , - 8 , 1 , 7 , 10 , 23 } ; Console . WriteLine ( " Length ▁ of ▁ the ▁ longest ▁ 0 ▁ sum ▁ subarray ▁ is ▁ " + maxLen ( arr ) ) ; } }

Index/key variables: i, sum
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: MaxLenZeroSumSub
C# program:
using System ; class GFG { static void printAlter ( int [ ] arr , int N ) { for ( int currIndex = 0 ; currIndex < N ; currIndex += 2 ) { Console . Write ( arr [ currIndex ] + " ▁ " ) ; } } public static void Main ( ) { int [ ] arr = { 1 , 2 , 3 , 4 , 5 } ; int N = arr . Length ; printAlter ( arr , N ) ; } }

Index/key variables: currIndex
Accumulator variables: currIndex
Iterator variables: currIndex
Class/struct names: GFG