dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; using System . Collections . Generic ; class GFG { static int findGreatest ( 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 a = m [ arr [ i ] ] + 1 ; m . Add ( arr [ i ] , a ) ; } else { m . Add ( arr [ i ] , arr [ i ] ) ; } } Array . Sort ( arr ) ; for ( int i = n - 1 ; i > 1 ; i -- ) { for ( int j = 0 ; j < i && arr [ j ] <= Math . Sqrt ( arr [ i ] ) ; j ++ ) { if ( arr [ i ] % arr [ j ] == 0 ) { int result = arr [ i ] / arr [ j ] ; if ( result != arr [ j ] && m [ result ] == null m [ result ] > 0 ) { return arr [ i ] ; } else if ( result == arr [ j ] && m [ result ] > 1 ) { return arr [ i ] ; } } } } return - 1 ; } public static void Main ( String [ ] args ) { int [ ] arr = { 17 , 2 , 1 , 15 , 30 } ; int n = arr . Length ; Console . WriteLine ( findGreatest ( arr , n ) ) ; } }

Index/key variables: i, j, result
Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int minRemove ( int [ ] a , int [ ] b , int n , int m ) { Dictionary < int , int > countA = new Dictionary < int , int > ( ) ; Dictionary < int , int > countB = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( countA . ContainsKey ( a [ i ] ) ) { var v = countA [ a [ i ] ] ; countA . Remove ( countA [ a [ i ] ] ) ; countA . Add ( a [ i ] , v + 1 ) ; } else countA . Add ( a [ i ] , 1 ) ; } for ( int i = 0 ; i < m ; i ++ ) { if ( countB . ContainsKey ( b [ i ] ) ) { var v = countB [ b [ i ] ] ; countB . Remove ( countB [ b [ i ] ] ) ; countB . Add ( b [ i ] , v + 1 ) ; } else countB . Add ( b [ i ] , 1 ) ; } int res = 0 ; foreach ( int x in countA . Keys ) if ( countB . ContainsKey ( x ) ) res += Math . Min ( countB [ x ] , countA [ x ] ) ; return res ; } public static void Main ( String [ ] args ) { int [ ] a = { 1 , 2 , 3 , 4 } ; int [ ] b = { 2 , 3 , 4 , 5 , 8 } ; int n = a . Length ; int m = b . Length ; Console . WriteLine ( minRemove ( a , b , n , m ) ) ; } }

Index/key variables: i, x
Accumulator variables: i, res
Iterator variables: i, x
Class/struct names: GFG
C# program:
using System ; class GFG { class item { public String name ; public int price ; public item ( String name , int price ) { this . name = name ; this . price = price ; } } ; static int countItems ( item [ ] list1 , int m , item [ ] list2 , int n ) { int count = 0 ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) if ( ( list1 [ i ] . name . CompareTo ( list2 [ j ] . name ) == 0 ) && ( list1 [ i ] . price != list2 [ j ] . price ) ) count ++ ; return count ; } public static void Main ( String [ ] args ) { item [ ] list1 = { new item ( " apple " , 60 ) , new item ( " bread " , 20 ) , new item ( " wheat " , 50 ) , new item ( " oil " , 30 ) } ; item [ ] list2 = { new item ( " milk " , 20 ) , new item ( " bread " , 15 ) , new item ( " wheat " , 40 ) , new item ( " apple " , 60 ) } ; int m = list1 . Length ; int n = list2 . Length ; Console . Write ( " Count ▁ = ▁ " + countItems ( list1 , m , list2 , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG, item
C# program:
using System ; using System . Collections . Generic ; class GFG { public class item { public String name ; public int price ; public item ( String name , int price ) { this . name = name ; this . price = price ; } } ; static int countItems ( item [ ] list1 , int m , item [ ] list2 , int n ) { Dictionary < String , int > um = new Dictionary < String , int > ( ) ; int count = 0 ; for ( int i = 0 ; i < m ; i ++ ) um . Add ( list1 [ i ] . name , list1 [ i ] . price ) ; for ( int i = 0 ; i < n ; i ++ ) if ( ( um . ContainsKey ( list2 [ i ] . name ) ) && ( um [ list2 [ i ] . name ] != list2 [ i ] . price ) ) count ++ ; return count ; } public static void Main ( String [ ] args ) { item [ ] list1 = { new item ( " apple " , 60 ) , new item ( " bread " , 20 ) , new item ( " wheat " , 50 ) , new item ( " oil " , 30 ) } ; item [ ] list2 = { new item ( " milk " , 20 ) , new item ( " bread " , 15 ) , new item ( " wheat " , 40 ) , new item ( " apple " , 60 ) } ; int m = list1 . Length ; int n = list2 . Length ; Console . Write ( " Count ▁ = ▁ " + countItems ( list1 , m , list2 , n ) ) ; } }

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG, item
C# program:
using System ; using System . Collections . Generic ; class GFG { static void find ( List < String > list1 , List < String > list2 ) { List < String > res = new List < String > ( ) ; int max_possible_sum = list1 . Count + list2 . Count - 2 ; for ( int sum = 0 ; sum <= max_possible_sum ; sum ++ ) { for ( int i = 0 ; i <= sum ; i ++ ) if ( i < list1 . Count && ( sum - i ) < list2 . Count && list1 [ i ] == list2 [ sum - i ] ) res . Add ( list1 [ i ] ) ; if ( res . Count > 0 ) break ; } for ( int i = 0 ; i < res . Count ; i ++ ) Console . Write ( res [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { List < String > list1 = new List < String > ( ) ; list1 . Add ( " GeeksforGeeks " ) ; list1 . Add ( " Udemy " ) ; list1 . Add ( " Coursera " ) ; list1 . Add ( " edX " ) ; List < String > list2 = new List < String > ( ) ; list2 . Add ( " Codecademy " ) ; list2 . Add ( " Khan ▁ Academy " ) ; list2 . Add ( " GeeksforGeeks " ) ; find ( list1 , list2 ) ; } }

Index/key variables: i
Accumulator variables: i, sum
Iterator variables: i, sum
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void find ( List < String > list1 , List < String > list2 ) { Dictionary < String , int > map = new Dictionary < String , int > ( ) ; for ( int i = 0 ; i < list1 . Count ; i ++ ) map . Add ( list1 [ i ] , i ) ; List < String > res = new List < String > ( ) ; int minsum = int . MaxValue ; for ( int j = 0 ; j < list2 . Count ; j ++ ) { if ( map . ContainsKey ( list2 [ j ] ) ) { int sum = j + map [ list2 [ j ] ] ; if ( sum < minsum ) { minsum = sum ; res . Clear ( ) ; res . Add ( list2 [ j ] ) ; } else if ( sum == minsum ) res . Add ( list2 [ j ] ) ; } } for ( int i = 0 ; i < res . Count ; i ++ ) Console . Write ( res [ i ] + " ▁ " ) ; } public static void Main ( String [ ] args ) { List < String > list1 = new List < String > ( ) ; list1 . Add ( " GeeksforGeeks " ) ; list1 . Add ( " Udemy " ) ; list1 . Add ( " Coursera " ) ; list1 . Add ( " edX " ) ; List < String > list2 = new List < String > ( ) ; list2 . Add ( " Codecademy " ) ; list2 . Add ( " Khan ▁ Academy " ) ; list2 . Add ( " GeeksforGeeks " ) ; find ( list1 , list2 ) ; } }

Index/key variables: i, j
Accumulator variables: 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 item ) { data = item ; left = right = null ; } } class GFG { public Node root ; public virtual bool isFullTree ( Node node ) { if ( node == null ) { return true ; } if ( node . left == null && node . right == null ) { return true ; } if ( ( node . left != null ) && ( node . right != null ) ) { return ( isFullTree ( node . left ) && isFullTree ( node . right ) ) ; } return false ; } public static void Main ( string [ ] args ) { GFG tree = new GFG ( ) ; tree . root = new Node ( 10 ) ; tree . root . left = new Node ( 20 ) ; tree . root . right = new Node ( 30 ) ; tree . root . left . right = new Node ( 40 ) ; tree . root . left . left = new Node ( 50 ) ; tree . root . right . left = new Node ( 60 ) ; tree . root . left . left . left = new Node ( 80 ) ; tree . root . right . right = new Node ( 70 ) ; tree . root . left . left . right = new Node ( 90 ) ; tree . root . left . right . left = new Node ( 80 ) ; tree . root . left . right . right = new Node ( 90 ) ; tree . root . right . left . left = new Node ( 80 ) ; tree . root . right . left . right = new Node ( 90 ) ; tree . root . right . right . left = new Node ( 80 ) ; tree . root . right . right . right = new Node ( 90 ) ; if ( tree . isFullTree ( tree . root ) ) { Console . Write ( " The ▁ binary ▁ tree ▁ is ▁ full " ) ; } else { Console . Write ( " The ▁ binary ▁ tree ▁ is ▁ not ▁ full " ) ; } } }

Class/struct names: GFG, Node
C# program:
using System ; using System . Collections . Generic ; class GFG { static void makePermutation ( int [ ] a , int n ) { Dictionary < int , int > count = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( count . ContainsKey ( a [ i ] ) ) { count [ a [ i ] ] = count [ a [ i ] ] + 1 ; } else { count . Add ( a [ i ] , 1 ) ; } } int next_missing = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( count . ContainsKey ( a [ i ] ) && count [ a [ i ] ] != 1 a [ i ] > n a [ i ] < 1 ) { count [ a [ i ] ] = count [ a [ i ] ] - 1 ; while ( count . ContainsKey ( next_missing ) ) next_missing ++ ; a [ i ] = next_missing ; count . Add ( next_missing , 1 ) ; } } } public static void Main ( String [ ] args ) { int [ ] A = { 2 , 2 , 3 , 3 } ; int n = A . Length ; makePermutation ( A , n ) ; for ( int i = 0 ; i < n ; i ++ ) Console . Write ( A [ i ] + " ▁ " ) ; } }

Index/key variables: i
Accumulator variables: i, next_missing
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void getPairsCount ( int [ ] arr , int sum ) { int count = 0 ; for ( int i = 0 ; i < arr . Length ; i ++ ) for ( int j = i + 1 ; j < arr . Length ; j ++ ) if ( ( arr [ i ] + arr [ j ] ) == sum ) count ++ ; Console . WriteLine ( " Count ▁ of ▁ pairs ▁ is ▁ " + count ) ; } static public void Main ( ) { int [ ] arr = { 1 , 5 , 7 , - 1 , 5 } ; int sum = 6 ; getPairsCount ( arr , sum ) ; } }

Index/key variables: i, j
Accumulator variables: count, 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 data ; public Node left , right ; } static Node getNode ( int data ) { Node newNode = new Node ( ) ; newNode . data = data ; newNode . left = null ; newNode . right = null ; return newNode ; } static bool isFullBinaryTree ( Node root ) { if ( root == null ) return true ; Queue < Node > q = new Queue < Node > ( ) ; q . Enqueue ( root ) ; while ( q . Count != 0 ) { Node node = q . Peek ( ) ; q . Dequeue ( ) ; if ( node . left == null && node . right == null ) continue ; if ( node . left == null node . right == null ) return false ; q . Enqueue ( node . left ) ; q . Enqueue ( node . right ) ; } return true ; } public static void Main ( String [ ] args ) { Node root = getNode ( 1 ) ; root . left = getNode ( 2 ) ; root . right = getNode ( 3 ) ; root . left . left = getNode ( 4 ) ; root . left . right = getNode ( 5 ) ; if ( isFullBinaryTree ( root ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }

Class/struct names: GfG, Node
C# program:
using System ; class GFG { static bool linearSearch ( int [ ] a , int n , int key ) { for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == key ) return true ; } return false ; } static void Main ( ) { int [ ] arr = { 2 , 3 , 4 , 10 , 40 } ; int x = 10 ; int n = arr . Length ; if ( linearSearch ( arr , n , x ) ) Console . Write ( " Element ▁ is ▁ present ▁ in ▁ array " ) ; else Console . Write ( " Element ▁ is ▁ not ▁ present ▁ in ▁ array " ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int [ ] arr = new int [ ] { 1 , 5 , 7 , - 1 , 5 } ; public static int getPairsCount ( int n , int sum ) { Dictionary < int , int > hm = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! hm . ContainsKey ( arr [ i ] ) ) { hm [ arr [ i ] ] = 0 ; } hm [ arr [ i ] ] = hm [ arr [ i ] ] + 1 ; } int twice_count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( hm [ sum - arr [ i ] ] != 0 ) { twice_count += hm [ sum - arr [ i ] ] ; } if ( sum - arr [ i ] == arr [ i ] ) { twice_count -- ; } } return twice_count / 2 ; } public static void Main ( string [ ] args ) { int sum = 6 ; Console . WriteLine ( " Count ▁ of ▁ pairs ▁ is ▁ " + getPairsCount ( arr . Length , sum ) ) ; } }

Index/key variables: i
Accumulator variables: i, twice_count
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairs ( int [ ] arr1 , int [ ] arr2 , int m , int n , int x ) { int count = 0 ; for ( int i = 0 ; i < m ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) if ( ( arr1 [ i ] + arr2 [ j ] ) == x ) count ++ ; return count ; } public static void Main ( ) { int [ ] arr1 = { 1 , 3 , 5 , 7 } ; int [ ] arr2 = { 2 , 3 , 5 , 8 } ; int m = arr1 . Length ; int n = arr2 . Length ; int x = 10 ; Console . WriteLine ( " Count ▁ = ▁ " + countPairs ( arr1 , arr2 , m , n , x ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPresent ( int [ ] arr , int low , int high , int value ) { while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( arr [ mid ] == value ) return true ; else if ( arr [ mid ] > value ) high = mid - 1 ; else low = mid + 1 ; } return false ; } static int countPairs ( int [ ] arr1 , int [ ] arr2 , int m , int n , int x ) { int count = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int value = x - arr1 [ i ] ; if ( isPresent ( arr2 , 0 , n - 1 , value ) ) count ++ ; } return count ; } public static void Main ( ) { int [ ] arr1 = { 1 , 3 , 5 , 7 } ; int [ ] arr2 = { 2 , 3 , 5 , 8 } ; int m = arr1 . Length ; int n = arr2 . Length ; int x = 10 ; Console . WriteLine ( " Count ▁ = ▁ " + countPairs ( arr1 , arr2 , m , n , x ) ) ; } }

Index/key variables: i, mid
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countPairs ( int [ ] arr1 , int [ ] arr2 , int m , int n , int x ) { int count = 0 ; HashSet < int > us = new HashSet < int > ( ) ; for ( int i = 0 ; i < m ; i ++ ) us . Add ( arr1 [ i ] ) ; for ( int j = 0 ; j < n ; j ++ ) if ( us . Contains ( x - arr2 [ j ] ) ) count ++ ; return count ; } public static void Main ( String [ ] args ) { int [ ] arr1 = { 1 , 3 , 5 , 7 } ; int [ ] arr2 = { 2 , 3 , 5 , 8 } ; int m = arr1 . Length ; int n = arr2 . Length ; int x = 10 ; Console . Write ( " Count ▁ = ▁ " + countPairs ( arr1 , arr2 , m , n , x ) ) ; } }

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int countPairs ( int [ ] arr1 , int [ ] arr2 , int m , int n , int x ) { int count = 0 ; int l = 0 , r = n - 1 ; while ( l < m && r >= 0 ) { if ( ( arr1 [ l ] + arr2 [ r ] ) == x ) { l ++ ; r -- ; count ++ ; } else if ( ( arr1 [ l ] + arr2 [ r ] ) < x ) l ++ ; else r -- ; } return count ; } public static void Main ( ) { int [ ] arr1 = { 1 , 3 , 5 , 7 } ; int [ ] arr2 = { 2 , 3 , 5 , 8 } ; int m = arr1 . Length ; int n = arr2 . Length ; int x = 10 ; Console . WriteLine ( " Count ▁ = ▁ " + countPairs ( arr1 , arr2 , m , n , x ) ) ; } }

Index/key variables: l, r
Accumulator variables: count, l, r
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countPairs ( List < int > head1 , List < int > head2 , int x ) { int count = 0 ; foreach ( int itr1 in head1 ) { int t = itr1 ; foreach ( int itr2 in head2 ) { if ( ( t + itr2 ) == x ) count ++ ; } } return count ; } public static void Main ( String [ ] args ) { int [ ] arr1 = { 3 , 1 , 5 , 7 } ; int [ ] arr2 = { 8 , 2 , 5 , 3 } ; List < int > head1 = new List < int > ( arr1 ) ; List < int > head2 = new List < int > ( arr2 ) ; int x = 10 ; Console . WriteLine ( " Count ▁ = ▁ " + countPairs ( head1 , head2 , x ) ) ; } }

Accumulator variables: count
Iterator variables: itr1, itr2
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isPresent ( int [ ] arr , int low , int high , int value ) { while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( arr [ mid ] == value ) return true ; else if ( arr [ mid ] > value ) high = mid - 1 ; else low = mid + 1 ; } return false ; } static int countQuadruples ( int [ ] arr1 , int [ ] arr2 , int [ ] arr3 , int [ ] arr4 , int n , int x ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) for ( int k = 0 ; k < n ; k ++ ) { int T = arr1 [ i ] + arr2 [ j ] + arr3 [ k ] ; if ( isPresent ( arr4 , 0 , n - 1 , x - T ) ) count ++ ; } return count ; } public static void Main ( String [ ] args ) { int [ ] arr1 = { 1 , 4 , 5 , 6 } ; int [ ] arr2 = { 2 , 3 , 7 , 8 } ; int [ ] arr3 = { 1 , 4 , 6 , 10 } ; int [ ] arr4 = { 2 , 4 , 7 , 8 } ; int n = 4 ; int x = 30 ; Console . WriteLine ( " Count ▁ = ▁ " + countQuadruples ( arr1 , arr2 , arr3 , arr4 , n , x ) ) ; } }

Index/key variables: i, j, k, mid
Accumulator variables: count, i, j, k
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; public class GFG { static int countPairs ( int [ ] arr1 , int [ ] arr2 , int n , int value ) { int count = 0 ; int l = 0 , r = n - 1 ; while ( l < n & r >= 0 ) { int sum = arr1 [ l ] + arr2 [ r ] ; if ( sum == value ) { l ++ ; r -- ; count ++ ; } else if ( sum > value ) r -- ; else l ++ ; } return count ; } static int countQuadruples ( int [ ] arr1 , int [ ] arr2 , int [ ] arr3 , int [ ] arr4 , int n , int x ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) { int p_sum = arr1 [ i ] + arr2 [ j ] ; count += countPairs ( arr3 , arr4 , n , x - p_sum ) ; } return count ; } static public void Main ( ) { int [ ] arr1 = { 1 , 4 , 5 , 6 } ; int [ ] arr2 = { 2 , 3 , 7 , 8 } ; int [ ] arr3 = { 1 , 4 , 6 , 10 } ; int [ ] arr4 = { 2 , 4 , 7 , 8 } ; int n = arr1 . Length ; int x = 30 ; Console . Write ( " Count ▁ = ▁ " + countQuadruples ( arr1 , arr2 , arr3 , arr4 , n , x ) ) ; } }

Index/key variables: i, j, l, r
Accumulator variables: count, i, j, l, r
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countQuadruples ( int [ ] arr1 , int [ ] arr2 , int [ ] arr3 , int [ ] arr4 , int n , int x ) { int count = 0 ; Dictionary < int , int > m = new Dictionary < int , int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) for ( int j = 0 ; j < n ; j ++ ) if ( m . ContainsKey ( arr1 [ i ] + arr2 [ j ] ) ) { var val = m [ arr1 [ i ] + arr2 [ j ] ] ; m . Remove ( arr1 [ i ] + arr2 [ j ] ) ; m . Add ( ( arr1 [ i ] + arr2 [ j ] ) , val + 1 ) ; } else m . Add ( ( arr1 [ i ] + arr2 [ j ] ) , 1 ) ; for ( int k = 0 ; k < n ; k ++ ) for ( int l = 0 ; l < n ; l ++ ) { int p_sum = arr3 [ k ] + arr4 [ l ] ; if ( m . ContainsKey ( x - p_sum ) ) count += m [ x - p_sum ] ; } return count ; } public static void Main ( String [ ] args ) { int [ ] arr1 = { 1 , 4 , 5 , 6 } ; int [ ] arr2 = { 2 , 3 , 7 , 8 } ; int [ ] arr3 = { 1 , 4 , 6 , 10 } ; int [ ] arr4 = { 2 , 4 , 7 , 8 } ; int n = arr1 . Length ; int x = 30 ; Console . WriteLine ( " Count ▁ = ▁ " + countQuadruples ( arr1 , arr2 , arr3 , arr4 , n , x ) ) ; } }

Index/key variables: i, j, k, l
Accumulator variables: count, i, j, k, l
Iterator variables: i, j, k, l
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 ) ; } Console . WriteLine ( ) ; } } }

Accumulator variables: i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void Main ( ) { int [ ] arr = { 10 , 2 , - 2 , - 20 , 10 } ; int k = - 10 ; int n = arr . Length ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int sum = 0 ; for ( int j = i ; j < n ; j ++ ) { sum += arr [ j ] ; if ( sum == k ) res ++ ; } } Console . WriteLine ( res ) ; } }

Index/key variables: j
Accumulator variables: i, j, res, sum
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { public static int findSubarraySum ( int [ ] arr , int n , int sum ) { Dictionary < int , int > prevSum = new Dictionary < int , int > ( ) ; int res = 0 ; int currsum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { currsum += arr [ i ] ; if ( currsum == sum ) res ++ ; if ( prevSum . ContainsKey ( currsum - sum ) ) res += prevSum [ currsum - sum ] ; if ( ! prevSum . ContainsKey ( currsum ) ) prevSum . Add ( currsum , 1 ) ; else { int count = prevSum [ currsum ] ; prevSum [ currsum ] = count + 1 ; } } return res ; } public static void Main ( ) { int [ ] arr = { 10 , 2 , - 2 , - 20 , 10 } ; int sum = - 10 ; int n = arr . Length ; Console . Write ( findSubarraySum ( arr , n , sum ) ) ; } }

Index/key variables: currsum, i
Accumulator variables: currsum, i, res
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static int countPairs ( int [ ] arr , int n ) { int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int product = arr [ i ] * arr [ j ] ; for ( int k = 0 ; k < n ; k ++ ) { if ( arr [ k ] == product ) { result ++ ; break ; } } } } return result ; } public static void Main ( string [ ] args ) { int [ ] arr = new int [ ] { 6 , 2 , 4 , 12 , 5 , 3 } ; int n = arr . Length ; Console . WriteLine ( countPairs ( arr , n ) ) ; } }

Index/key variables: i, j, k
Accumulator variables: i, j, k, result
Iterator variables: i, j, k
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int countPairs ( int [ ] arr , int n ) { int result = 0 ; HashSet < int > Hash = new HashSet < int > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { Hash . Add ( arr [ i ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { int product = arr [ i ] * arr [ j ] ; if ( Hash . Contains ( product ) ) { result ++ ; } } } return result ; } public static void Main ( String [ ] args ) { int [ ] arr = { 6 , 2 , 4 , 12 , 5 , 3 } ; int n = arr . Length ; Console . WriteLine ( countPairs ( arr , n ) ) ; } }

Index/key variables: i, j
Accumulator variables: i, j, result
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static int fib ( int n ) { if ( n <= 1 ) return n ; return fib ( n - 1 ) + fib ( n - 2 ) ; } public static void Main ( String [ ] args ) { int n = 9 ; Console . WriteLine ( fib ( n ) ) ; } }

Class/struct names: GFG
C# program:
using System ; class GFG { static int factTR ( int n , int a ) { if ( n == 0 ) return a ; return factTR ( n - 1 , n * a ) ; } static int fact ( int n ) { return factTR ( n , 1 ) ; } static public void Main ( ) { Console . WriteLine ( fact ( 5 ) ) ; } }

Class/struct names: GFG