dhyuti-n/xlcost-variable-roles huggingface dataset:
C# program:
using System ; class GFG { static int calc_distance ( int [ ] A , int [ ] B , int n ) { int distance_traveled_A = 0 ; int distance_traveled_B = 0 ; int answer = 0 ; for ( int i = 0 ; i < 5 ; i ++ ) { distance_traveled_A += A [ i ] ; distance_traveled_B += B [ i ] ; if ( ( distance_traveled_A == distance_traveled_B ) && ( A [ i ] == B [ i ] ) ) { answer += A [ i ] ; } } return answer ; } public static void Main ( string [ ] s ) { int [ ] A = { 1 , 2 , 3 , 2 , 4 } ; int [ ] B = { 2 , 1 , 3 , 1 , 4 } ; int N = A . Length ; Console . Write ( calc_distance ( A , B , N ) ) ; } }

Index/key variables: i
Accumulator variables: answer, distance_traveled_A, distance_traveled_B, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { private static List < List < int > > constructTree ( int n , int [ , ] edges ) { List < List < int > > adjl = new List < List < int > > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { adjl . Add ( new List < int > ( ) ) ; } for ( int i = 0 ; i < edges . GetLength ( 0 ) ; i ++ ) { int u = edges [ i , 0 ] ; int v = edges [ i , 1 ] ; adjl [ u ] . Add ( v ) ; adjl [ v ] . Add ( u ) ; } return adjl ; } private static void DFS ( List < List < int > > adjl , int [ ] parent , int u , int p ) { parent [ u ] = p ; foreach ( int v in adjl [ u ] ) { if ( v != p ) { DFS ( adjl , parent , v , u ) ; } } } private static int [ ] valuesFromChildren ( int [ ] parent , int [ ] values ) { int [ ] valuesChildren = new int [ parent . Length ] ; for ( int i = 0 ; i < parent . Length ; i ++ ) { if ( parent [ i ] == - 1 ) continue ; else { int p = parent [ i ] ; valuesChildren [ p ] += values [ i ] ; } } return valuesChildren ; } private static int findSumOfValues ( int v , int [ ] parent , int [ ] valuesChildren ) { int cur_node = v ; int sum = 0 ; while ( cur_node != - 1 ) { sum += valuesChildren [ cur_node ] ; cur_node = parent [ cur_node ] ; } return sum ; } public static void Main ( string [ ] args ) { int n = 8 ; int [ , ] edges = { { 0 , 1 } , { 0 , 2 } , { 0 , 3 } , { 1 , 4 } , { 1 , 5 } , { 4 , 7 } , { 3 , 6 } } ; int v = 7 ; int [ ] values = new int [ ] { 1 , 2 , 3 , 0 , 0 , 4 , 3 , 6 } ; List < List < int > > adjl = constructTree ( n , edges ) ; int [ ] parent = new int [ n ] ; DFS ( adjl , parent , 0 , - 1 ) ; int [ ] valuesChildren = valuesFromChildren ( parent , values ) ; int sum = findSumOfValues ( v , parent , valuesChildren ) ; sum += values [ 0 ] ; Console . WriteLine ( sum ) ; } }

Index/key variables: cur_node, i, n, p, u, v
Accumulator variables: i, sum
Iterator variables: i, v
Class/struct names: GFG
C# program:
using System ; class GFG { static void maxProduct ( int [ ] arr , int N ) { if ( N < 3 ) { return ; } int a = arr [ 0 ] , b = arr [ 1 ] ; int c = 0 , d = 0 ; for ( int i = 0 ; i < N ; i ++ ) for ( int j = i + 1 ; j < N - 1 ; j ++ ) { if ( arr [ i ] * arr [ j ] > a * b ) { c = a ; d = b ; a = arr [ i ] ; b = arr [ j ] ; } if ( arr [ i ] * arr [ j ] < a * b && arr [ i ] * arr [ j ] > c * d ) c = arr [ i ] ; d = arr [ j ] ; } Console . WriteLine ( c + " ▁ " + d ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 5 , 2 , 67 , 45 , 160 , 78 } ; int N = arr . Length ; maxProduct ( 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 { static bool isVowel ( char c ) { if ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) return true ; return false ; } static void countSubstrings ( String s , int n ) { int result = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int count = 0 ; for ( int j = i ; j < n ; j ++ ) { if ( isVowel ( s [ j ] ) ) { count ++ ; } if ( count % 2 == 0 ) result ++ ; } } Console . WriteLine ( result ) ; } public static void Main ( String [ ] args ) { int n = 5 ; String s = " abcde " ; countSubstrings ( s , n ) ; } }

Index/key variables: j
Accumulator variables: count, i, j, result
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static bool isVowel ( char c ) { if ( c == ' a ' c == ' e ' c == ' i ' c == ' o ' c == ' u ' ) return true ; return false ; } static void countSubstrings ( String s , int n ) { int [ ] temp = { 1 , 0 } ; int result = 0 , sum = 0 ; for ( int i = 0 ; i <= n - 1 ; i ++ ) { sum += ( isVowel ( s [ i ] ) ? 1 : 0 ) ; sum %= 2 ; temp [ sum ] ++ ; } result += ( ( temp [ 0 ] * ( temp [ 0 ] - 1 ) ) / 2 ) ; result += ( ( temp [ 1 ] * ( temp [ 1 ] - 1 ) ) / 2 ) ; Console . Write ( result ) ; } public static void Main ( string [ ] args ) { int n = 5 ; String s = " abcde " ; countSubstrings ( s , n ) ; } }

Index/key variables: i, sum
Accumulator variables: i, result, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { class Node { public int data ; public Node left , right ; } ; class pair { public Node first ; public int second ; public pair ( Node first , int second ) { this . first = first ; this . second = second ; } } static Node newNode ( int data ) { Node temp = new Node ( ) ; temp . data = data ; temp . left = temp . right = null ; return temp ; } static int findLevel ( Node root , int k , int level ) { Queue qt = new Queue ( ) ; qt . Enqueue ( new pair ( root , 0 ) ) ; int count = 1 , b = 0 , a = 0 ; while ( qt . Count != 0 ) { pair temp = ( pair ) qt . Dequeue ( ) ; if ( count == 1 ) { b = temp . second ; } if ( temp . first . left != null ) { qt . Enqueue ( new pair ( temp . first . left , 2 * temp . second ) ) ; } if ( temp . first . right != null ) { qt . Enqueue ( new pair ( temp . first . right , 2 * temp . second + 1 ) ) ; } count -- ; if ( count == 0 ) { if ( ( b - a + 1 ) == k ) return level ; pair secondLabel = ( pair ) qt . Peek ( ) ; a = secondLabel . second ; level += 1 ; count = qt . Count ; } } return - 1 ; } public static void Main ( string [ ] args ) { Node root = newNode ( 5 ) ; root . left = newNode ( 6 ) ; root . right = newNode ( 2 ) ; root . right . right = newNode ( 8 ) ; root . left . left = newNode ( 7 ) ; root . left . left . left = newNode ( 5 ) ; root . left . right = newNode ( 3 ) ; root . left . right . right = newNode ( 4 ) ; int k = 4 ; Console . Write ( findLevel ( root , k , 1 ) ) ; } }

Accumulator variables: count, level
Class/struct names: GFG, Node, pair
C# program:
using System ; class GFG { static bool possible ( int [ ] arr , int N , int mid , int K ) { int add = 0 ; for ( int i = N / 2 - ( N + 1 ) % 2 ; i < N ; ++ i ) { if ( mid - arr [ i ] > 0 ) { add += ( mid - arr [ i ] ) ; if ( add > K ) return false ; } } if ( add <= K ) return true ; else return false ; } static int findMaxMedian ( int [ ] arr , int N , int K ) { int low = 1 ; int mx = 0 ; for ( int i = 0 ; i < N ; ++ i ) { mx = Math . Max ( mx , arr [ i ] ) ; } int high = K + mx ; while ( low <= high ) { int mid = ( high + low ) / 2 ; if ( possible ( arr , N , mid , K ) ) { low = mid + 1 ; } else { high = mid - 1 ; } } if ( N % 2 == 0 ) { if ( low - 1 < arr [ N / 2 ] ) { return ( arr [ N / 2 ] + low - 1 ) / 2 ; } } return low - 1 ; } public static void Main ( string [ ] args ) { int [ ] arr = { 1 , 3 , 6 } ; int K = 10 ; int N = arr . Length ; Array . Sort ( arr ) ; Console . Write ( findMaxMedian ( arr , N , K ) ) ; } }

Index/key variables: i
Accumulator variables: add
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static bool countLessThanMid ( int mid , int N , int M , int K ) { int count = 0 ; for ( int i = 1 ; i <= Math . Min ( N , mid ) ; ++ i ) { count = count + Math . Min ( mid / i , M ) ; } if ( count >= K ) return false ; else return true ; } public static int findKthElement ( int N , int M , int K ) { int low = 1 , high = N * M ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( countLessThanMid ( mid , N , M , K ) ) low = mid + 1 ; else high = mid - 1 ; } return high + 1 ; } public static void Main ( String [ ] args ) { int N = 2 , M = 3 ; int K = 5 ; Console . WriteLine ( findKthElement ( N , M , K ) ) ; } }

Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void countSubString ( String S , char C ) { int count = 0 ; int conCount = 0 ; for ( int i = 0 ; i < S . Length ; i ++ ) { char ch = S [ i ] ; if ( ch == C ) conCount ++ ; else { count += ( conCount * ( conCount + 1 ) ) / 2 ; conCount = 0 ; } } count += ( conCount * ( conCount + 1 ) ) / 2 ; Console . Write ( count ) ; } public static void Main ( String [ ] args ) { String S = " geeksforgeeks " ; char C = ' e ' ; countSubString ( S , C ) ; } }

Index/key variables: i
Accumulator variables: conCount, count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void checkPalindrome ( String S ) { int N = S . Length ; bool first_half = true ; bool second_half = true ; int cnt = ( N / 2 ) - 1 ; for ( int i = 0 ; i < ( N / 2 ) ; i ++ ) { if ( S [ i ] != S [ cnt ] ) { first_half = false ; break ; } if ( S [ N / 2 + i ] != S [ N / 2 + cnt ] ) { second_half = false ; break ; } cnt -- ; } if ( first_half && second_half ) { Console . Write ( " Yes " ) ; } else { Console . Write ( " No " ) ; } } public static void Main ( ) { String S = " momdad " ; checkPalindrome ( S ) ; } }

Index/key variables: cnt, i
Accumulator variables: cnt, i
Iterator variables: i
Boolean variables: first_half, second_half
Class/struct names: GFG
C# program:
using System ; class GFG { public class Node { public int key ; public Node left , right ; } ; static int kth_smallest ; public static Node newNode ( int item ) { Node temp = new Node ( ) ; temp . key = item ; temp . left = temp . right = null ; return temp ; } static Node insert ( Node node , int key ) { if ( node == null ) return newNode ( key ) ; if ( key < node . key ) node . left = insert ( node . left , key ) ; else if ( key > node . key ) node . right = insert ( node . right , key ) ; return node ; } static bool KSmallestPerfectBST ( Node root , int k , int treeSize ) { if ( root == null ) return false ; int median_loc = ( treeSize / 2 ) + 1 ; if ( k == median_loc ) { kth_smallest = root . key ; return true ; } int newTreeSize = treeSize / 2 ; if ( k < median_loc ) { return KSmallestPerfectBST ( root . left , k , newTreeSize ) ; } int newK = k - median_loc ; return KSmallestPerfectBST ( root . right , newK , newTreeSize ) ; } public static void Main ( String [ ] args ) { Node root = null ; root = insert ( root , 50 ) ; insert ( root , 30 ) ; insert ( root , 20 ) ; insert ( root , 40 ) ; insert ( root , 70 ) ; insert ( root , 60 ) ; insert ( root , 80 ) ; insert ( root , 14 ) ; insert ( root , 25 ) ; insert ( root , 35 ) ; insert ( root , 45 ) ; insert ( root , 55 ) ; insert ( root , 65 ) ; insert ( root , 75 ) ; insert ( root , 85 ) ; int n = 15 , k = 5 ; if ( KSmallestPerfectBST ( root , k , n ) ) { Console . Write ( kth_smallest + " ▁ " ) ; } } }

Class/struct names: GFG, Node
C# program:
using System ; class GFG { static bool checkrules ( String s ) { if ( s . Length == 0 ) return true ; if ( s [ 0 ] != '1' ) return false ; if ( s . Length > 2 ) { if ( s [ 1 ] == '0' && s [ 2 ] == '0' ) return checkrules ( s . Substring ( 3 ) ) ; } return checkrules ( s . Substring ( 1 ) ) ; } public static void Main ( String [ ] args ) { String str = "1111" ; if ( checkrules ( str ) ) { Console . Write ( " Valid ▁ String " ) ; } else { Console . Write ( " Invalid ▁ String " ) ; } } }

Class/struct names: GFG
C# program:
using System ; class GFG { static bool isNudeNum ( int n ) { int copy , length , flag = 0 ; copy = n ; String temp ; temp = String . Join ( " " , copy ) ; length = temp . Length ; for ( int i = 0 ; i < length ; i ++ ) { int num = temp [ i ] - '0' ; if ( num == 0 n % num != 0 ) { flag = 1 ; } } if ( flag == 1 ) return false ; else return true ; } static int longestNudeSubseq ( int [ ] arr , int n ) { int answer = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isNudeNum ( arr [ i ] ) ) answer ++ ; } return answer ; } public static void Main ( String [ ] args ) { int [ ] arr = { 34 , 34 , 2 , 2 , 3 , 333 , 221 , 32 } ; int n = arr . Length ; Console . Write ( longestNudeSubseq ( arr , n ) + " STRNEWLINE " ) ; } }

Index/key variables: i
Accumulator variables: answer, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static int longestSubarray ( int [ ] arr , int n , int k ) { int i , j , Max = 1 ; HashSet < int > s = new HashSet < int > ( ) ; for ( i = 0 ; i < n - 1 ; i ++ ) { s . Add ( arr [ i ] ) ; for ( j = i + 1 ; j < n ; j ++ ) { if ( Math . Abs ( arr [ i ] - arr [ j ] ) == 0 || Math . Abs ( arr [ i ] - arr [ j ] ) == k ) { if ( ! s . Contains ( arr [ j ] ) ) { if ( s . Count == 2 ) break ; else s . Add ( arr [ j ] ) ; } } else break ; } if ( s . Count == 2 ) { Max = Math . Max ( Max , j - i ) ; s . Clear ( ) ; } else s . Clear ( ) ; } return Max ; } public static void Main ( String [ ] args ) { int [ ] arr = { 1 , 0 , 2 , 2 , 5 , 5 , 5 } ; int N = arr . Length ; int K = 1 ; int length = longestSubarray ( arr , N , K ) ; if ( length == 1 ) Console . Write ( - 1 ) ; else Console . Write ( length ) ; } }

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 longestSubarray ( int [ ] a , int n ) { int [ ] l = new int [ n ] ; int [ ] r = new int [ n ] ; for ( int i = 0 , count = 0 ; i < n ; i ++ ) { if ( a [ i ] == 1 ) count ++ ; else { l [ i ] = count ; count = 0 ; } } for ( int i = n - 1 , count = 0 ; i >= 0 ; i -- ) { if ( a [ i ] == 1 ) count ++ ; else { r [ i ] = count ; count = 0 ; } } int ans = - 1 ; for ( int i = 0 ; i < n ; ++ i ) { if ( a [ i ] == 0 ) ans = Math . Max ( ans , l [ i ] + r [ i ] ) ; } return ans < 0 ? n : ans ; } public static void Main ( ) { int [ ] arr = { 0 , 1 , 1 , 1 , 0 , 1 , 0 , 1 , 1 } ; int n = arr . Length ; Console . Write ( longestSubarray ( arr , n ) ) ; } }

Index/key variables: i, n
Accumulator variables: count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void findMaxValue ( int N , int K ) { int packages ; int maxi = 1 ; for ( int i = 1 ; i <= K ; i ++ ) { if ( N % i == 0 ) maxi = Math . Max ( maxi , i ) ; } packages = N / maxi ; Console . WriteLine ( packages ) ; } public static void Main ( String [ ] args ) { int N = 8 , K = 7 ; findMaxValue ( N , K ) ; } }

Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void maxSide ( int [ ] a , int n ) { int sideLength = 0 ; Array . Sort ( a ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( a [ i ] > sideLength ) { sideLength ++ ; } else { break ; } } Console . Write ( sideLength ) ; } public static void Main ( ) { int N = 6 ; int [ ] arr = new int [ ] { 3 , 2 , 1 , 5 , 2 , 4 } ; maxSide ( arr , N ) ; } }

Index/key variables: i
Accumulator variables: i, sideLength
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { public static void minDiff ( long [ ] a , int n ) { for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] % 2 == 1 ) a [ i ] *= 2 ; } Array . Sort ( a ) ; long mindifference = a [ 1 ] - a [ 0 ] ; for ( int i = 1 ; i < a . Length ; i ++ ) { mindifference = Math . Min ( mindifference , a [ i ] - a [ i - 1 ] ) ; } Console . Write ( mindifference ) ; } public static void Main ( ) { long [ ] arr = { 3 , 8 , 13 , 30 , 50 } ; int n = arr . Length ; minDiff ( 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 List < int > v = new List < int > ( ) ; static int bin ( int val , int k , int n ) { int lo = 0 ; int hi = n ; int mid ; int ans = - 1 ; while ( lo <= hi ) { mid = lo + ( hi - lo ) / 2 ; if ( v [ mid ] - val <= k ) { lo = mid + 1 ; ans = mid ; } else hi = mid - 1 ; } return ans ; } static void findSubarraySumK ( int [ ] arr , int N , int K ) { int sum = 0 ; v . Add ( 0 ) ; for ( int i = 0 ; i < N ; i ++ ) { sum += arr [ i ] ; v . Add ( sum ) ; } int ans = 0 , r ; for ( int i = 0 ; i < v . Count ; i ++ ) { r = bin ( v [ i ] , K , N ) ; ans = Math . Max ( ans , r - i ) ; } Console . Write ( ans ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 6 , 8 , 14 , 9 , 4 , 11 , 10 } ; int N = arr . Length ; int K = 13 ; findSubarraySumK ( arr , N , K ) ; } }

Index/key variables: i, mid
Accumulator variables: i, sum
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; using System . Collections ; using System . Collections . Generic ; class GFG { static int minRev ( ArrayList edges , int n ) { Dictionary < int , ArrayList > graph = new Dictionary < int , ArrayList > ( ) ; Dictionary < int , ArrayList > graph_rev = new Dictionary < int , ArrayList > ( ) ; for ( int i = 0 ; i < edges . Count ; i ++ ) { int x = ( int ) ( ( ArrayList ) edges [ i ] ) [ 0 ] ; int y = ( int ) ( ( ArrayList ) edges [ i ] ) [ 1 ] ; if ( ! graph . ContainsKey ( x ) ) { graph [ x ] = new ArrayList ( ) ; } graph [ x ] . Add ( y ) ; if ( ! graph_rev . ContainsKey ( y ) ) { graph_rev [ y ] = new ArrayList ( ) ; } graph_rev [ y ] . Add ( x ) ; } Queue q = new Queue ( ) ; ArrayList visited = new ArrayList ( ) ; for ( int i = 0 ; i < n + 1 ; i ++ ) { visited . Add ( false ) ; } q . Enqueue ( 0 ) ; int ans = 0 ; while ( q . Count != 0 ) { int curr = ( int ) q . Peek ( ) ; visited [ curr ] = true ; int count = 0 ; q . Dequeue ( ) ; if ( graph_rev . ContainsKey ( curr ) ) { for ( int i = 0 ; i < graph_rev [ curr ] . Count ; i ++ ) { if ( ! ( bool ) visited [ ( int ) ( ( ArrayList ) graph_rev [ curr ] ) [ i ] ] ) { q . Enqueue ( ( int ) ( ( ArrayList ) graph_rev [ curr ] ) [ i ] ) ; } } } if ( graph . ContainsKey ( curr ) ) { for ( int i = 0 ; i < ( ( ArrayList ) graph [ curr ] ) . Count ; i ++ ) { if ( ! ( bool ) visited [ ( int ) ( ( ArrayList ) graph [ curr ] ) [ i ] ] ) { q . Enqueue ( ( int ) ( ( ArrayList ) graph [ curr ] ) [ i ] ) ; count ++ ; } } } ans += count ; } return ans ; } public static void Main ( string [ ] args ) { ArrayList edges = new ArrayList ( ) { new ArrayList ( ) { 0 , 1 } , new ArrayList ( ) { 1 , 3 } , new ArrayList ( ) { 2 , 3 } , new ArrayList ( ) { 4 , 0 } , new ArrayList ( ) { 4 , 5 } } ; int n = 6 ; Console . Write ( minRev ( edges , n ) ) ; } }

Index/key variables: curr, i, x, y
Accumulator variables: ans, count, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int splitArray ( int [ ] arr , int N ) { Array . Sort ( arr ) ; int result = Int32 . MaxValue ; for ( int i = 1 ; i < N ; i ++ ) { result = Math . Min ( result , arr [ i ] - arr [ i - 1 ] ) ; } return result ; } public static void Main ( ) { int [ ] arr = { 3 , 1 , 2 , 6 , 4 } ; int N = arr . Length ; Console . Write ( splitArray ( arr , N ) ) ; } }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static int findValue ( int R , int C ) { int k = ( R * ( R - 1 ) ) / 2 + 1 ; int diff = R + 1 ; for ( int i = 1 ; i < C ; i ++ ) { k = ( k + diff ) ; diff ++ ; } return k ; } public static void Main ( ) { int R = 4 ; int C = 4 ; int k = findValue ( R , C ) ; Console . Write ( k ) ; } }

Accumulator variables: diff, i
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static void makeGroups ( int [ ] a , int n ) { int [ ] v = new int [ n + 1 ] ; int i = 0 ; for ( i = 0 ; i < n ; i ++ ) { v [ a [ i ] ] ++ ; } int no_of_groups = 0 ; for ( i = 1 ; i <= n ; i ++ ) { no_of_groups += v [ i ] / i ; v [ i ] = v [ i ] % i ; } i = 1 ; int total = 0 ; for ( i = 1 ; i <= n ; i ++ ) { if ( v [ i ] != 0 ) { total = v [ i ] ; break ; } } i ++ ; while ( i <= n ) { if ( v [ i ] != 0 ) { total += v [ i ] ; if ( total >= i ) { int rem = total - i ; no_of_groups ++ ; total = rem ; } } i ++ ; } Console . Write ( no_of_groups + " STRNEWLINE " ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 3 , 1 , 2 , 2 } ; int size = arr . Length ; makeGroups ( arr , size ) ; } }

Index/key variables: i
Accumulator variables: i, no_of_groups, total
Iterator variables: i
Class/struct names: GFG
C# program:
using System ; class GFG { static readonly int N = 3 ; static readonly int M = 4 ; static int FindColumn ( int [ , ] mat ) { int row = 0 , col = M - 1 ; int flag = 0 ; while ( row < N && col >= 0 ) { if ( mat [ row , col ] == 1 ) { col -- ; flag = 1 ; } else { row ++ ; } } col ++ ; if ( flag != 0 ) return col + 1 ; else return - 1 ; } public static void Main ( String [ ] args ) { int [ , ] mat = { { 0 , 0 , 0 , 1 } , { 0 , 1 , 1 , 1 } , { 0 , 0 , 1 , 1 } } ; Console . Write ( FindColumn ( mat ) ) ; } }

Accumulator variables: col, row
Class/struct names: GFG
C# program:
using System ; using System . Collections . Generic ; class GFG { static void findNumbers ( int N , int M ) { int m = M ; Dictionary < int , int > remLen = new Dictionary < int , int > ( ) ; int len , remainder = 0 ; for ( len = 1 ; len <= N + 1 ; ++ len ) { remainder = M % N ; if ( ! remLen . ContainsKey ( remainder ) ) { remLen . Add ( remainder , len ) ; } else { break ; } M = M * 10 + m ; M = M % N ; } int LenA = len ; int LenB = remLen [ remainder ] ; for ( int i = 0 ; i < LenB ; ++ i ) Console . Write ( m ) ; Console . Write ( " ▁ " ) ; for ( int i = 0 ; i < LenA ; ++ i ) Console . Write ( m ) ; } public static void Main ( String [ ] args ) { int N = 8 , M = 2 ; findNumbers ( N , M ) ; } }

Index/key variables: remainder
Iterator variables: i, len
Class/struct names: GFG
C# program:
using System ; class GFG { static int [ , ] prefix_2D = new int [ 2005 , 2005 ] ; static int subMatrixSum ( int i , int j , int len ) { return prefix_2D [ i , j ] - prefix_2D [ i , j - len ] - prefix_2D [ i - len , j ] + prefix_2D [ i - len , j - len ] ; } static int numberOfWays ( int [ ] a , int [ ] b , int n , int m , int k ) { for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { if ( a [ i - 1 ] == b [ j - 1 ] ) prefix_2D [ i , j ] = 1 ; else prefix_2D [ i , j ] = 0 ; } } for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { prefix_2D [ i , j ] += prefix_2D [ i , j - 1 ] ; } } for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { prefix_2D [ i , j ] += prefix_2D [ i - 1 , j ] ; } } int answer = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= m ; j ++ ) { int low = 1 ; int high = Math . Min ( i , j ) ; while ( low < high ) { int mid = ( low + high ) >> 1 ; if ( subMatrixSum ( i , j , mid ) >= k ) { high = mid ; } else { low = mid + 1 ; } } if ( subMatrixSum ( i , j , low ) >= k ) { answer += ( Math . Min ( i , j ) - low + 1 ) ; } } } return answer ; } public static void Main ( String [ ] args ) { int N = 2 , M = 3 ; int [ ] A = { 1 , 2 } ; int [ ] B = { 1 , 2 , 3 } ; int K = 1 ; Console . Write ( numberOfWays ( A , B , N , M , K ) ) ; } }

Accumulator variables: answer, i, j
Iterator variables: i, j
Class/struct names: GFG
C# program:
using System ; class GFG { static String findSmallest ( char [ ] s ) { int len = s . Length ; int [ ] loccur = new int [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) loccur [ i ] = - 1 ; for ( int i = len - 1 ; i >= 0 ; -- i ) { int chI = s [ i ] - ' a ' ; if ( loccur [ chI ] == - 1 ) { loccur [ chI ] = i ; } } char [ ] sorted_s = s ; Array . Sort ( sorted_s ) ; for ( int i = 0 ; i < len ; ++ i ) { if ( s [ i ] != sorted_s [ i ] ) { int chI = sorted_s [ i ] - ' a ' ; int last_occ = loccur [ chI ] ; char temp = s [ last_occ ] ; s [ last_occ ] = s [ i ] ; s [ i ] = temp ; break ; } } return String . Join ( " " , s ) ; } public static void Main ( String [ ] args ) { String s = " geeks " ; Console . Write ( findSmallest ( s . ToCharArray ( ) ) ) ; } }

Index/key variables: chI, i, last_occ
Accumulator variables: i
Iterator variables: i
Class/struct names: GFG