using
System;
using
System.Collections.Generic;
using
System.Linq;
class
pair
{
public
int
first, second;
public
pair(
int
f,
int
s)
{
this
.first = f;
this
.second = s;
}
public
override
bool
Equals(Object obj)
{
if
(
this
== obj)
return
true
;
if
(obj ==
null
|| obj.GetType() !=
this
.GetType())
return
false
;
pair p = (pair)obj;
return
(p.first ==
this
.first && p.second ==
this
.second);
}
public
override
int
GetHashCode()
{
return
this
.first +
this
.second / 2;
}
}
class
GFG
{
static
void
repeated_pairs(
int
[] arr,
int
N)
{
Dictionary<pair,
int
> m =
new
Dictionary<pair,
int
>();
List<pair> v =
new
List<pair>();
for
(
int
i = 0; i < N - 1; i++)
{
pair p =
new
pair(arr[i], arr[i + 1]);
if
(!m.ContainsKey(p))
{
m[p] = 0;
}
m[p]++;
}
foreach
(KeyValuePair<pair,
int
> k
in
m)
{
if
(k.Value > 1)
{
v.Add(k.Key);
}
}
v.Sort((a, b) => a.first - b.first);
foreach
(pair k
in
v)
{
Console.WriteLine(k.first +
" "
+ k.second);
}
}
public
static
void
Main(
string
[] args)
{
int
[] arr = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2 };
int
N = arr.Length
repeated_pairs(arr, N);
}
}