title: How to find duplicated pairs in a list in python?
body: <p>Suppose I have a list of values</p>
  
  <pre><code>l = [1, 1, 2, 5, 2, 3, 4, 2]
  </code></pre>
  
  <p>I would like to extract duplicated pairs/clusters with their indices, e.g., <code>[(0, 1), (2, 4, 7)]</code>. Is there a fast way to do so? The length of the list could be >100000.</p>
  
  <p>Update: I tried to construct a <code>n^2</code> boolean matrix but that took too much memory.</p>